當前位置: 首頁>>代碼示例>>Java>>正文


Java Status類代碼示例

本文整理匯總了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);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:26,代碼來源:TestStressSource.java

示例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));
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:23,代碼來源:TestKafkaSource.java

示例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));

}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:26,代碼來源:TestKafkaSource.java

示例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));
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:22,代碼來源:TestKafkaSource.java

示例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());
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:21,代碼來源:TestKafkaSource.java

示例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));
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:24,代碼來源:TestKafkaSource.java

示例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));
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:23,代碼來源:TestKafkaSource.java

示例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);
}
 
開發者ID:DevOps-TangoMe,項目名稱:flume-redis,代碼行數:31,代碼來源:TestRedisSource.java

示例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);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:32,代碼來源:TestStressSource.java

示例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);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:14,代碼來源:TestKafkaSource.java

示例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);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:14,代碼來源:TestKafkaSource.java

示例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);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:15,代碼來源:TestKafkaSource.java

示例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);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:28,代碼來源:TestIntegrationActiveMQ.java

示例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);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:28,代碼來源:TestIntegrationActiveMQ.java

示例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);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:10,代碼來源:TestJMSSource.java


注:本文中的org.apache.flume.PollableSource.Status類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。