本文整理匯總了Java中org.apache.flume.PollableSource.Status類的典型用法代碼示例。如果您正苦於以下問題:Java Status類的具體用法?Java Status怎麽用?Java Status使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Status類屬於org.apache.flume.PollableSource包,在下文中一共展示了Status類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testBatchEventsWithoutMatTotalEvents
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@Test
public void testBatchEventsWithoutMatTotalEvents() throws InterruptedException,
EventDeliveryException {
StressSource source = new StressSource();
source.setChannelProcessor(mockProcessor);
Context context = new Context();
context.put("batchSize", "10");
source.configure(context);
source.start();
for (int i = 0; i < 10; i++) {
Assert.assertFalse("StressSource with no maxTotalEvents should not return " +
Status.BACKOFF, source.process() == Status.BACKOFF);
}
verify(mockProcessor,
times(10)).processEventBatch(getLastProcessedEventList(source));
long successfulEvents = getCounterGroup(source).get("events.successful");
TestCase.assertTrue("Number of successful events should be 100 but was " +
successfulEvents, successfulEvents == 100);
long failedEvents = getCounterGroup(source).get("events.failed");
TestCase.assertTrue("Number of failure events should be 0 but was " +
failedEvents, failedEvents == 0);
}
示例2: testProcessItNotEmpty
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testProcessItNotEmpty() throws EventDeliveryException,
SecurityException, NoSuchFieldException, IllegalArgumentException,
IllegalAccessException, InterruptedException {
context.put(TOPICS, topic0);
context.put(BATCH_SIZE, "1");
kafkaSource.configure(context);
kafkaSource.start();
Thread.sleep(500L);
kafkaServer.produce(topic0, "", "hello, world");
Thread.sleep(500L);
Assert.assertEquals(Status.READY, kafkaSource.process());
Assert.assertEquals(Status.BACKOFF, kafkaSource.process());
Assert.assertEquals(1, events.size());
Assert.assertEquals("hello, world", new String(events.get(0).getBody(),
Charsets.UTF_8));
}
示例3: testProcessItNotEmptyBatch
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testProcessItNotEmptyBatch() throws EventDeliveryException,
SecurityException, NoSuchFieldException, IllegalArgumentException,
IllegalAccessException, InterruptedException {
context.put(TOPICS, topic0);
context.put(BATCH_SIZE,"2");
kafkaSource.configure(context);
kafkaSource.start();
Thread.sleep(500L);
kafkaServer.produce(topic0, "", "hello, world");
kafkaServer.produce(topic0, "", "foo, bar");
Thread.sleep(500L);
Status status = kafkaSource.process();
assertEquals(Status.READY, status);
Assert.assertEquals("hello, world", new String(events.get(0).getBody(),
Charsets.UTF_8));
Assert.assertEquals("foo, bar", new String(events.get(1).getBody(),
Charsets.UTF_8));
}
示例4: testBatchTime
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@Test
public void testBatchTime() throws InterruptedException, EventDeliveryException {
context.put(TOPICS, topic0);
context.put(BATCH_DURATION_MS, "250");
kafkaSource.configure(context);
kafkaSource.start();
Thread.sleep(500L);
for (int i = 1; i < 5000; i++) {
kafkaServer.produce(topic0, "", "hello, world " + i);
}
Thread.sleep(500L);
long error = 50;
long startTime = System.currentTimeMillis();
Status status = kafkaSource.process();
long endTime = System.currentTimeMillis();
assertEquals(Status.READY, status);
assertTrue(endTime - startTime < (context.getLong(BATCH_DURATION_MS) + error));
}
示例5: testCommit
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@Test
public void testCommit() throws InterruptedException, EventDeliveryException {
context.put(TOPICS, topic0);
context.put(BATCH_SIZE, "1");
kafkaSource.configure(context);
kafkaSource.start();
Thread.sleep(500L);
kafkaServer.produce(topic0, "", "hello, world");
Thread.sleep(500L);
Assert.assertEquals(Status.READY, kafkaSource.process());
kafkaSource.stop();
Thread.sleep(500L);
kafkaSource.start();
Thread.sleep(500L);
Assert.assertEquals(Status.BACKOFF, kafkaSource.process());
}
示例6: testNonCommit
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@Test
public void testNonCommit() throws EventDeliveryException, InterruptedException {
context.put(TOPICS, topic0);
context.put(BATCH_SIZE,"1");
context.put(BATCH_DURATION_MS,"30000");
kafkaSource.configure(context);
kafkaSource.start();
Thread.sleep(500L);
kafkaServer.produce(topic0, "", "hello, world");
Thread.sleep(500L);
kafkaSource.setChannelProcessor(createBadChannel());
log.debug("processing from kafka to bad channel");
Assert.assertEquals(Status.BACKOFF, kafkaSource.process());
log.debug("repairing channel");
kafkaSource.setChannelProcessor(createGoodChannel());
log.debug("re-process to good channel - this should work");
kafkaSource.process();
Assert.assertEquals("hello, world", new String(events.get(0).getBody(), Charsets.UTF_8));
}
示例7: testNullKey
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testNullKey() throws EventDeliveryException, SecurityException, NoSuchFieldException,
IllegalArgumentException, IllegalAccessException,
InterruptedException {
context.put(TOPICS, topic0);
context.put(BATCH_SIZE, "1");
kafkaSource.configure(context);
kafkaSource.start();
Thread.sleep(500L);
kafkaServer.produce(topic0, null, "hello, world");
Thread.sleep(500L);
Assert.assertEquals(Status.READY, kafkaSource.process());
Assert.assertEquals(Status.BACKOFF, kafkaSource.process());
Assert.assertEquals(1, events.size());
Assert.assertEquals("hello, world", new String(events.get(0).getBody(), Charsets.UTF_8));
}
示例8: noEventProcessTest
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
/**
* jedis client returns an empty list. Source should back off
*
* @throws EventDeliveryException
*/
@Test
public void noEventProcessTest() throws EventDeliveryException {
int batchSize = 1;
Jedis jedis = mock(Jedis.class);
JedisPool jedisPool = mock(JedisPool.class);
when(jedis.lrange(any(byte[].class), eq(0), eq(batchSize))).thenReturn(new ArrayList<byte[]>());
MockJedisPoolFactory mockJedisPoolFactory = new MockJedisPoolFactory(jedisPool, jedis);
RedisSource redisSource = new RedisSource(mockJedisPoolFactory);
Context context = new Context();
context.put(RedisSourceConfigurationConstant.HOST, "localhost");
context.put(RedisSourceConfigurationConstant.BATCH_SIZE, "1");
redisSource.configure(context);
redisSource.doStart();
Status status = redisSource.doProcess();
redisSource.doStop();
// No event returned, so source should back off
Assert.assertEquals(Status.BACKOFF, status);
verify(jedisPool, times(1)).getResource();
verify(jedisPool, times(1)).returnResource(jedis);
}
示例9: testBatchEvents
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@Test
public void testBatchEvents() throws InterruptedException,
EventDeliveryException {
StressSource source = new StressSource();
source.setChannelProcessor(mockProcessor);
Context context = new Context();
context.put("maxTotalEvents", "35");
context.put("batchSize", "10");
source.configure(context);
source.start();
for (int i = 0; i < 50; i++) {
if (source.process() == Status.BACKOFF) {
TestCase.assertTrue("Source should have sent all events in 4 batches", i == 4);
break;
}
if (i < 3) {
verify(mockProcessor,
times(i + 1)).processEventBatch(getLastProcessedEventList(source));
} else {
verify(mockProcessor,
times(1)).processEventBatch(getLastProcessedEventList(source));
}
}
long successfulEvents = getCounterGroup(source).get("events.successful");
TestCase.assertTrue("Number of successful events should be 35 but was " +
successfulEvents, successfulEvents == 35);
long failedEvents = getCounterGroup(source).get("events.failed");
TestCase.assertTrue("Number of failure events should be 0 but was " +
failedEvents, failedEvents == 0);
}
示例10: testProcessItEmpty
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testProcessItEmpty() throws EventDeliveryException,
SecurityException, NoSuchFieldException, IllegalArgumentException,
IllegalAccessException, InterruptedException {
context.put(TOPICS, topic0);
kafkaSource.configure(context);
kafkaSource.start();
Thread.sleep(500L);
Status status = kafkaSource.process();
assertEquals(Status.BACKOFF, status);
}
示例11: testNonExistingTopic
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testNonExistingTopic() throws EventDeliveryException,
SecurityException, NoSuchFieldException, IllegalArgumentException,
IllegalAccessException, InterruptedException {
context.put(TOPICS,"faketopic");
kafkaSource.configure(context);
kafkaSource.start();
Thread.sleep(500L);
Status status = kafkaSource.process();
assertEquals(Status.BACKOFF, status);
}
示例12: testNonExistingKafkaServer
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test(expected = FlumeException.class)
public void testNonExistingKafkaServer() throws EventDeliveryException, SecurityException,
NoSuchFieldException, IllegalArgumentException,
IllegalAccessException, InterruptedException {
context.put(TOPICS, topic0);
context.put(BOOTSTRAP_SERVERS,"blabla:666");
kafkaSource.configure(context);
kafkaSource.start();
Thread.sleep(500L);
Status status = kafkaSource.process();
assertEquals(Status.BACKOFF, status);
}
示例13: testQueue
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@Test
public void testQueue() throws Exception {
context.put(JMSSourceConfiguration.DESTINATION_TYPE,
JMSSourceConfiguration.DESTINATION_TYPE_QUEUE);
source.configure(context);
source.start();
Thread.sleep(500L);
List<String> expected = Lists.newArrayList();
for (int i = 0; i < 10; i++) {
expected.add(String.valueOf(i));
}
putQueue(expected);
Thread.sleep(500L);
Assert.assertEquals(Status.READY, source.process());
Assert.assertEquals(Status.BACKOFF, source.process());
Assert.assertEquals(expected.size(), events.size());
List<String> actual = Lists.newArrayList();
for (Event event : events) {
actual.add(new String(event.getBody(), Charsets.UTF_8));
}
Collections.sort(expected);
Collections.sort(actual);
Assert.assertEquals(expected, actual);
}
示例14: testTopic
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@Test
public void testTopic() throws Exception {
context.put(JMSSourceConfiguration.DESTINATION_TYPE,
JMSSourceConfiguration.DESTINATION_TYPE_TOPIC);
source.configure(context);
source.start();
Thread.sleep(500L);
List<String> expected = Lists.newArrayList();
for (int i = 0; i < 10; i++) {
expected.add(String.valueOf(i));
}
putTopic(expected);
Thread.sleep(500L);
Assert.assertEquals(Status.READY, source.process());
Assert.assertEquals(Status.BACKOFF, source.process());
Assert.assertEquals(expected.size(), events.size());
List<String> actual = Lists.newArrayList();
for (Event event : events) {
actual.add(new String(event.getBody(), Charsets.UTF_8));
}
Collections.sort(expected);
Collections.sort(actual);
Assert.assertEquals(expected, actual);
}
示例15: testConfigureWithUserNameButNoPasswordFile
import org.apache.flume.PollableSource.Status; //導入依賴的package包/類
@Test
public void testConfigureWithUserNameButNoPasswordFile() throws Exception {
context.put(JMSSourceConfiguration.USERNAME, "dummy");
source.configure(context);
source.start();
Assert.assertEquals(Status.READY, source.process());
Assert.assertEquals(batchSize, events.size());
assertBodyIsExpected(events);
}