com.twitter.hbc.core.processor.HosebirdMessageProcessor Java Examples
The following examples show how to use
com.twitter.hbc.core.processor.HosebirdMessageProcessor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicClient.java From hbc with Apache License 2.0 | 6 votes |
public BasicClient(String name, Hosts hosts, StreamingEndpoint endpoint, Authentication auth, boolean enableGZip, HosebirdMessageProcessor processor, ReconnectionManager reconnectionManager, RateTracker rateTracker, ExecutorService executorService, @Nullable BlockingQueue<Event> eventsQueue, HttpParams params, SchemeRegistry schemeRegistry) { Preconditions.checkNotNull(auth); HttpClient client; if (enableGZip) { client = new RestartableHttpClient(auth, enableGZip, params, schemeRegistry); } else { DefaultHttpClient defaultClient = new DefaultHttpClient(new PoolingClientConnectionManager(schemeRegistry), params); /** Set auth **/ auth.setupConnection(defaultClient); client = defaultClient; } this.canRun = new AtomicBoolean(true); this.executorService = executorService; this.clientBase = new ClientBase(name, client, hosts, endpoint, auth, processor, reconnectionManager, rateTracker, eventsQueue); }
Example #2
Source File: ClientBase.java From hbc with Apache License 2.0 | 6 votes |
ClientBase(String name, HttpClient client, Hosts hosts, StreamingEndpoint endpoint, Authentication auth, HosebirdMessageProcessor processor, ReconnectionManager manager, RateTracker rateTracker, @Nullable BlockingQueue<Event> eventsQueue) { this.client = Preconditions.checkNotNull(client); this.name = Preconditions.checkNotNull(name); this.endpoint = Preconditions.checkNotNull(endpoint); this.hosts = Preconditions.checkNotNull(hosts); this.auth = Preconditions.checkNotNull(auth); this.processor = Preconditions.checkNotNull(processor); this.reconnectionManager = Preconditions.checkNotNull(manager); this.rateTracker = Preconditions.checkNotNull(rateTracker); this.eventsQueue = eventsQueue; this.exitEvent = new AtomicReference<Event>(); this.isRunning = new CountDownLatch(1); this.statsReporter = new StatsReporter(); this.connectionEstablished = new AtomicBoolean(false); this.reconnect = new AtomicBoolean(false); }
Example #3
Source File: LineDelimitedStreamProcessorTest.java From hbc with Apache License 2.0 | 6 votes |
private int processStream(SimpleStreamProvider simpleStream, HosebirdMessageProcessor processor, BlockingQueue<String> queue) throws InterruptedException { int count = 0; try { InputStream stream = simpleStream.createInputStream(); processor.setup(stream); // read until we hit the IOException while (count < messages.length * 2) { processor.process(); // trimming to get rid of the CRLF assertTrue(messages[count].equals(queue.take().trim())); count++; } fail(); } catch (IOException e) { // expected } return count; }
Example #4
Source File: LineDelimitedStreamProcessorTest.java From hbc with Apache License 2.0 | 6 votes |
@Test public void testIdleProbe() throws Exception { SimpleStreamProvider simpleStream = new SimpleStreamProvider(messages, true, true); int count = 0; try { InputStream stream = simpleStream.createInputStream(); BlockingQueue<String> queue = new ArrayBlockingQueue<String>(10); HosebirdMessageProcessor processor = new StringDelimitedProcessor(queue); processor.setup(stream); // read until we hit the IOException while (count < messages.length * 2) { processor.process(); // trimming to get rid of the CRLF assertTrue(messages[count].equals(queue.take().trim())); count++; } fail(); } catch (IOException e) { // expected } assertEquals(messages.length, count); }
Example #5
Source File: StreamProcessorTest.java From hbc with Apache License 2.0 | 6 votes |
private int processStream(SimpleStreamProvider simpleStream, HosebirdMessageProcessor processor, BlockingQueue<String> queue) throws InterruptedException { int count = 0; try { InputStream stream = simpleStream.createInputStream(); processor.setup(stream); // read until we hit the IOException while (count < messages.length * 2) { processor.process(); // trimming to get rid of the CRLF assertTrue(messages[count].equals(queue.take().trim())); count++; } fail(); } catch (IOException e) { // expected } return count; }
Example #6
Source File: StreamProcessorTest.java From hbc with Apache License 2.0 | 6 votes |
@Test public void testIdleProbe() throws Exception { SimpleStreamProvider simpleStream = new SimpleStreamProvider(messages, true, true); int count = 0; try { InputStream stream = simpleStream.createInputStream(); BlockingQueue<String> queue = new ArrayBlockingQueue<String>(10); HosebirdMessageProcessor processor = new StringDelimitedProcessor(queue); processor.setup(stream); // read until we hit the IOException while (count < messages.length * 2) { processor.process(); // trimming to get rid of the CRLF assertTrue(messages[count].equals(queue.take().trim())); count++; } fail(); } catch (IOException e) { // expected } assertEquals(messages.length, count); }
Example #7
Source File: ClientBaseTest.java From hbc with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { mock = mock(HttpClient.class); mockResponse = mock(HttpResponse.class); mockStatusLine = mock(StatusLine.class); mockConnection = mock(Connection.class); mockReconnectionManager = mock(BasicReconnectionManager.class); mockRateTracker = mock(RateTracker.class); mockInputStream = mock(InputStream.class); mockAuth = mock(Authentication.class); mockProcessor = mock(HosebirdMessageProcessor.class); HttpEntity mockHttpEntity = mock(HttpEntity.class); // set up required mocks to mock out all of the clientbase stuff when(mock.execute(any(HttpUriRequest.class))) .thenReturn(mockResponse); when(mockResponse.getStatusLine()) .thenReturn(mockStatusLine); when(mockResponse.getEntity()) .thenReturn(mockHttpEntity); when(mockHttpEntity.getContent()) .thenReturn(mockInputStream); }
Example #8
Source File: BasicClientTest.java From hbc with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { mockClient = mock(HttpClient.class); mockResponse = mock(HttpResponse.class); mockStatusLine = mock(StatusLine.class); mockReconnectionManager = mock(BasicReconnectionManager.class); mockConnectionManager = mock(ClientConnectionManager.class); mockRateTracker = mock(RateTracker.class); mockInputStream = mock(InputStream.class); mockAuth = mock(Authentication.class); mockProcessor = mock(HosebirdMessageProcessor.class); mockHttpEntity = mock(HttpEntity.class); // set up required mocks to mock out all of the clientbase stuff when(mockClient.execute(any(HttpUriRequest.class))) .thenReturn(mockResponse); when(mockClient.getConnectionManager()) .thenReturn(mockConnectionManager); when(mockResponse.getStatusLine()) .thenReturn(mockStatusLine); when(mockResponse.getEntity()) .thenReturn(mockHttpEntity); when(mockHttpEntity.getContent()) .thenReturn(mockInputStream); when(mockStatusLine.getReasonPhrase()) .thenReturn("reason"); }
Example #9
Source File: StreamProcessorTest.java From hbc with Apache License 2.0 | 5 votes |
/** * StringDelimitedProcessor properly processes streams */ @Test public void testDelimitedStreamProcessing() throws Exception { SimpleStreamProvider simpleStream = new SimpleStreamProvider(messages, true, false); BlockingQueue<String> queue = new ArrayBlockingQueue<String>(10); HosebirdMessageProcessor processor = new StringDelimitedProcessor(queue); int count = processStream(simpleStream, processor, queue); assertEquals(messages.length, count); }
Example #10
Source File: StreamProcessorTest.java From hbc with Apache License 2.0 | 5 votes |
@Test public void testSimpleStreamProcessing() throws Exception { SimpleStreamProvider simpleStream = new SimpleStreamProvider(messages, false, false); BlockingQueue<String> queue = new ArrayBlockingQueue<String>(10); HosebirdMessageProcessor processor = new LineStringProcessor(queue); int count = processStream(simpleStream, processor, queue); assertEquals(messages.length, count); }
Example #11
Source File: Connection.java From hbc with Apache License 2.0 | 4 votes |
public Connection(HttpClient client, HosebirdMessageProcessor processor) { this.client = Preconditions.checkNotNull(client); this.processor = Preconditions.checkNotNull(processor); }
Example #12
Source File: ClientBase.java From hbc with Apache License 2.0 | 4 votes |
ClientBase(String name, HttpClient client, Hosts hosts, StreamingEndpoint endpoint, Authentication auth, HosebirdMessageProcessor processor, ReconnectionManager manager, RateTracker rateTracker) { this(name, client, hosts, endpoint, auth, processor, manager, rateTracker, null); }
Example #13
Source File: LineDelimitedStreamProcessorTest.java From hbc with Apache License 2.0 | 3 votes |
@Test public void testLineStringProcessing() throws Exception { SimpleStreamProvider simpleStream = new SimpleStreamProvider(messages, false, false); BlockingQueue<String> queue = new ArrayBlockingQueue<String>(10); HosebirdMessageProcessor processor = new LineStringProcessor(queue); int count = processStream(simpleStream, processor, queue); assertEquals(messages.length, count); }