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


Java EventDeliveryException類代碼示例

本文整理匯總了Java中org.apache.flume.EventDeliveryException的典型用法代碼示例。如果您正苦於以下問題:Java EventDeliveryException類的具體用法?Java EventDeliveryException怎麽用?Java EventDeliveryException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EventDeliveryException類屬於org.apache.flume包,在下文中一共展示了EventDeliveryException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testSlowness

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
@Test(expected = EventDeliveryException.class)
public void testSlowness() throws Throwable {
  ch = new SlowMemoryChannel(2000);
  Configurables.configure(ch, new Context());
  configureSource();
  props.put("log4j.appender.out2.Timeout", "1000");
  props.put("log4j.appender.out2.layout", "org.apache.log4j.PatternLayout");
  props.put("log4j.appender.out2.layout.ConversionPattern",
      "%-5p [%t]: %m%n");
  PropertyConfigurator.configure(props);
  Logger logger = LogManager.getLogger(TestLog4jAppender.class);
  Thread.currentThread().setName("Log4jAppenderTest");
  int level = 10000;
  String msg = "This is log message number" + String.valueOf(1);
  try {
    logger.log(Level.toLevel(level), msg);
  } catch (FlumeException ex) {
    throw ex.getCause();
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:21,代碼來源:TestLog4jAppender.java

示例2: append

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
@Override
public void append(Event event) throws EventDeliveryException {
  throwIfClosed();
  boolean eventSent = false;
  Iterator<HostInfo> it = selector.createHostIterator();

  while (it.hasNext()) {
    HostInfo host = it.next();
    try {
      RpcClient client = getClient(host);
      client.append(event);
      eventSent = true;
      break;
    } catch (Exception ex) {
      selector.informFailure(host);
      LOGGER.warn("Failed to send event to host " + host, ex);
    }
  }

  if (!eventSent) {
    throw new EventDeliveryException("Unable to send event to any host");
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:24,代碼來源:LoadBalancingRpcClient.java

示例3: appendBatch

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
@Override
public void appendBatch(List<Event> events) throws EventDeliveryException {
  throwIfClosed();
  boolean batchSent = false;
  Iterator<HostInfo> it = selector.createHostIterator();

  while (it.hasNext()) {
    HostInfo host = it.next();
    try {
      RpcClient client = getClient(host);
      client.appendBatch(events);
      batchSent = true;
      break;
    } catch (Exception ex) {
      selector.informFailure(host);
      LOGGER.warn("Failed to send batch to host " + host, ex);
    }
  }

  if (!batchSent) {
    throw new EventDeliveryException("Unable to send batch to any host");
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:24,代碼來源:LoadBalancingRpcClient.java

示例4: remaining

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
public static int remaining(Channel ch) throws EventDeliveryException {
  Transaction t = ch.getTransaction();
  try {
    t.begin();
    int count = 0;
    while (ch.take() != null) {
      count += 1;
    }
    t.commit();
    return count;
  } catch (Throwable th) {
    t.rollback();
    Throwables.propagateIfInstanceOf(th, Error.class);
    Throwables.propagateIfInstanceOf(th, EventDeliveryException.class);
    throw new EventDeliveryException(th);
  } finally {
    t.close();
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:20,代碼來源:TestDatasetSink.java

示例5: appendBatch

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
@Override
public void appendBatch(List<Event> events) throws EventDeliveryException {
  try {
    appendBatch(events, requestTimeout, TimeUnit.MILLISECONDS);
  } catch (Throwable t) {
    // we mark as no longer active without trying to clean up resources
    // client is required to call close() to clean up resources
    setState(ConnState.DEAD);
    if (t instanceof Error) {
      throw (Error) t;
    }
    if (t instanceof TimeoutException) {
      throw new EventDeliveryException(this + ": Failed to send event. " +
          "RPC request timed out after " + requestTimeout + " ms", t);
    }
    throw new EventDeliveryException(this + ": Failed to send batch", t);
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:19,代碼來源:NettyAvroRpcClient.java

示例6: testThreeParamBatchAppend

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
@Test
public void testThreeParamBatchAppend() throws FlumeException,
    EventDeliveryException {
  int batchSize = 7;
  RpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    client = RpcClientFactory.getDefaultInstance(localhost, server.getPort(),
        batchSize);

    List<Event> events = new ArrayList<Event>();
    for (int i = 0; i < batchSize; i++) {
      events.add(EventBuilder.withBody("evt: " + i, Charset.forName("UTF8")));
    }
    client.appendBatch(events);
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:21,代碼來源:TestRpcClientFactory.java

示例7: handlerSimpleAppendTest

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
/**
 * Helper method for testing simple (single) with compression level 6 appends on handlers
 * @param handler
 * @throws FlumeException
 * @throws EventDeliveryException
 */
public static void handlerSimpleAppendTest(AvroSourceProtocol handler,
                                           boolean enableServerCompression,
                                           boolean enableClientCompression, int compressionLevel)
    throws FlumeException, EventDeliveryException {
  NettyAvroRpcClient client = null;
  Server server = startServer(handler, 0, enableServerCompression);
  try {
    Properties starterProp = new Properties();
    if (enableClientCompression) {
      starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_COMPRESSION_TYPE, "deflate");
      starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_COMPRESSION_LEVEL,
                              "" + compressionLevel);
    } else {
      starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_COMPRESSION_TYPE, "none");
    }
    client = getStockLocalClient(server.getPort(), starterProp);
    boolean isActive = client.isActive();
    Assert.assertTrue("Client should be active", isActive);
    client.append(EventBuilder.withBody("wheee!!!", Charset.forName("UTF8")));
  } finally {
    stopServer(server);
    if (client != null) client.close();
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:31,代碼來源:RpcTestUtils.java

示例8: testBatchAware

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
@Test
public void testBatchAware() throws EventDeliveryException {
  logger.info("Running testBatchAware()");
  initContextForIncrementHBaseSerializer();
  HBaseSink sink = new HBaseSink(testUtility.getConfiguration());
  Configurables.configure(sink, ctx);
  Channel channel = createAndConfigureMemoryChannel(sink);

  sink.start();
  int batchCount = 3;
  for (int i = 0; i < batchCount; i++) {
    sink.process();
  }
  sink.stop();
  Assert.assertEquals(batchCount,
      ((IncrementHBaseSerializer) sink.getSerializer()).getNumBatchesStarted());
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:18,代碼來源:TestHBaseSink.java

示例9: testDatasetUriOverridesOldConfig

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
@Test
public void testDatasetUriOverridesOldConfig() throws EventDeliveryException {
  // CONFIG_KITE_DATASET_URI is still set, otherwise this will cause an error
  config.put(DatasetSinkConstants.CONFIG_KITE_REPO_URI, "bad uri");
  config.put(DatasetSinkConstants.CONFIG_KITE_DATASET_NAME, "");

  DatasetSink sink = sink(in, config);

  // run the sink
  sink.start();
  sink.process();
  sink.stop();

  Assert.assertEquals(
      Sets.newHashSet(expected),
      read(Datasets.load(FILE_DATASET_URI)));
  Assert.assertEquals("Should have committed", 0, remaining(in));
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:19,代碼來源:TestDatasetSink.java

示例10: testOldConfig

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
@Test
public void testOldConfig() throws EventDeliveryException {
  config.put(DatasetSinkConstants.CONFIG_KITE_DATASET_URI, null);
  config.put(DatasetSinkConstants.CONFIG_KITE_REPO_URI, FILE_REPO_URI);
  config.put(DatasetSinkConstants.CONFIG_KITE_DATASET_NAME, DATASET_NAME);

  DatasetSink sink = sink(in, config);

  // run the sink
  sink.start();
  sink.process();
  sink.stop();

  Assert.assertEquals(
      Sets.newHashSet(expected),
      read(Datasets.load(FILE_DATASET_URI)));
  Assert.assertEquals("Should have committed", 0, remaining(in));
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:19,代碼來源:TestDatasetSink.java

示例11: handle

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
@Override
public void handle(Event event, Throwable cause) throws EventDeliveryException {
  try {
    if (writer == null) {
      writer = dataset.newWriter();
    }

    final AvroFlumeEvent avroEvent = new AvroFlumeEvent();
    avroEvent.setBody(ByteBuffer.wrap(event.getBody()));
    avroEvent.setHeaders(toCharSeqMap(event.getHeaders()));

    writer.write(avroEvent);
    nEventsHandled++;
  } catch (RuntimeException ex) {
    throw new EventDeliveryException(ex);
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:18,代碼來源:SavePolicy.java

示例12: testClientClosedRequest

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
/**
 * First connect the client, then close the client, then send a request.
 * @throws FlumeException
 * @throws EventDeliveryException
 */
@Test(expected = EventDeliveryException.class)
public void testClientClosedRequest() throws FlumeException,
    EventDeliveryException {
  NettyAvroRpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    client = RpcTestUtils.getStockLocalClient(server.getPort());
    client.close();
    Assert.assertFalse("Client should not be active", client.isActive());
    System.out.println("Yaya! I am not active after client close!");
    client.append(EventBuilder.withBody("hello", Charset.forName("UTF8")));
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:22,代碼來源:TestNettyAvroRpcClient.java

示例13: testBatchEventsWithoutMatTotalEvents

import org.apache.flume.EventDeliveryException; //導入依賴的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

示例14: testProcessItNotEmptyBatch

import org.apache.flume.EventDeliveryException; //導入依賴的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

示例15: testMissingSchema

import org.apache.flume.EventDeliveryException; //導入依賴的package包/類
@Test
public void testMissingSchema() throws EventDeliveryException {
  final DatasetSink sink = sink(in, config);

  Event badEvent = new SimpleEvent();
  badEvent.setHeaders(Maps.<String, String>newHashMap());
  badEvent.setBody(serialize(expected.get(0), RECORD_SCHEMA));
  putToChannel(in, badEvent);

  // run the sink
  sink.start();
  assertThrows("Should fail", EventDeliveryException.class,
      new Callable() {
        @Override
        public Object call() throws EventDeliveryException {
          sink.process();
          return null;
        }
      });
  sink.stop();

  Assert.assertEquals("Should have rolled back",
      expected.size() + 1, remaining(in));
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:25,代碼來源:TestDatasetSink.java


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