use of org.apache.flume.EventDeliveryException in project phoenix by apache.
the class RegexEventSerializerIT method testMismatchKeyGenerator.
@Test
public void testMismatchKeyGenerator() throws EventDeliveryException, SQLException {
final String fullTableName = generateUniqueName();
initSinkContextWithDefaults(fullTableName);
setConfig(FlumeConstants.CONFIG_SERIALIZER_PREFIX + FlumeConstants.CONFIG_ROWKEY_TYPE_GENERATOR, DefaultKeyGenerator.UUID.name());
sink = new PhoenixSink();
Configurables.configure(sink, sinkContext);
assertEquals(LifecycleState.IDLE, sink.getLifecycleState());
final Channel channel = this.initChannel();
sink.setChannel(channel);
sink.start();
final String eventBody = "val1\tval2";
final Event event = EventBuilder.withBody(Bytes.toBytes(eventBody));
// put event in channel
Transaction transaction = channel.getTransaction();
transaction.begin();
channel.put(event);
transaction.commit();
transaction.close();
try {
sink.process();
fail();
} catch (Exception ex) {
assertTrue(ex.getCause().getMessage().contains("java.lang.IllegalArgumentException: Invalid format:"));
}
}
use of org.apache.flume.EventDeliveryException in project phoenix by apache.
the class JsonEventSerializerIT method testMismatchKeyGenerator.
@Test
public void testMismatchKeyGenerator() throws EventDeliveryException, SQLException {
final String fullTableName = "FLUME_JSON_TEST";
initSinkContextWithDefaults(fullTableName);
setConfig(FlumeConstants.CONFIG_SERIALIZER_PREFIX + FlumeConstants.CONFIG_ROWKEY_TYPE_GENERATOR, DefaultKeyGenerator.UUID.name());
sink = new PhoenixSink();
Configurables.configure(sink, sinkContext);
assertEquals(LifecycleState.IDLE, sink.getLifecycleState());
final Channel channel = this.initChannel();
sink.setChannel(channel);
sink.start();
final String eventBody = "{\"col1\" : \"kalyan\", \"col2\" : 10.5, \"col3\" : [\"abc\",\"pqr\",\"xyz\"], \"col4\" : [1,2,3,4]}";
final Event event = EventBuilder.withBody(Bytes.toBytes(eventBody));
// put event in channel
Transaction transaction = channel.getTransaction();
transaction.begin();
channel.put(event);
transaction.commit();
transaction.close();
try {
sink.process();
fail();
} catch (Exception ex) {
assertTrue(ex.getCause().getMessage().contains("java.lang.IllegalArgumentException: Invalid format:"));
}
dropTable(fullTableName);
}
use of org.apache.flume.EventDeliveryException in project rocketmq-externals by apache.
the class RocketMQSourceTest method testEvent.
@Test
public void testEvent() throws EventDeliveryException, MQBrokerException, MQClientException, InterruptedException, UnsupportedEncodingException {
// publish test message
DefaultMQProducer producer = new DefaultMQProducer(producerGroup);
producer.setNamesrvAddr(nameServer);
String sendMsg = "\"Hello Flume\"" + "," + DateFormatUtils.format(new Date(), "yyyy-MM-DD hh:mm:ss");
try {
producer.start();
Message msg = new Message(TOPIC_DEFAULT, tag, sendMsg.getBytes("UTF-8"));
SendResult sendResult = producer.send(msg);
log.info("publish message : {}, sendResult:{}", sendMsg, sendResult);
} catch (Exception e) {
throw new MQClientException("Failed to publish messages", e);
} finally {
producer.shutdown();
}
// start source
Context context = new Context();
context.put(NAME_SERVER_CONFIG, nameServer);
context.put(TAG_CONFIG, tag);
Channel channel = new MemoryChannel();
Configurables.configure(channel, context);
List<Channel> channels = new ArrayList<>();
channels.add(channel);
ChannelSelector channelSelector = new ReplicatingChannelSelector();
channelSelector.setChannels(channels);
ChannelProcessor channelProcessor = new ChannelProcessor(channelSelector);
RocketMQSource source = new RocketMQSource();
source.setChannelProcessor(channelProcessor);
Configurables.configure(source, context);
source.start();
PollableSource.Status status = source.process();
if (status == PollableSource.Status.BACKOFF) {
fail("Error");
}
/*
wait for processQueueTable init
*/
Thread.sleep(1000);
source.stop();
/*
mock flume sink
*/
Transaction transaction = channel.getTransaction();
transaction.begin();
Event event = channel.take();
if (event == null) {
transaction.commit();
fail("Error");
}
byte[] body = event.getBody();
String receiveMsg = new String(body, "UTF-8");
log.info("receive message : {}", receiveMsg);
assertEquals(sendMsg, receiveMsg);
}
use of org.apache.flume.EventDeliveryException in project cdap-ingest by caskdata.
the class CdapFlumeIT method writeEvents.
private void writeEvents(EmbeddedAgent agent, int startNumber, int endNumber) {
for (int i = startNumber; i < endNumber; i++) {
Event event = new SimpleEvent();
event.setBody((EVENT_STR + i).getBytes());
try {
agent.put(event);
} catch (EventDeliveryException ignored) {
}
}
}
use of org.apache.flume.EventDeliveryException in project ignite by apache.
the class IgniteSink method process.
/**
* Processes Flume events.
*/
@Override
public Status process() throws EventDeliveryException {
Channel channel = getChannel();
Transaction transaction = channel.getTransaction();
int eventCount = 0;
try {
transaction.begin();
List<Event> batch = new ArrayList<>(batchSize);
for (; eventCount < batchSize; ++eventCount) {
Event event = channel.take();
if (event == null) {
break;
}
batch.add(event);
}
if (!batch.isEmpty()) {
ignite.cache(cacheName).putAll(eventTransformer.transform(batch));
if (batch.size() < batchSize)
sinkCounter.incrementBatchUnderflowCount();
else
sinkCounter.incrementBatchCompleteCount();
} else {
sinkCounter.incrementBatchEmptyCount();
}
sinkCounter.addToEventDrainAttemptCount(batch.size());
transaction.commit();
sinkCounter.addToEventDrainSuccessCount(batch.size());
} catch (Exception e) {
log.error("Failed to process events", e);
try {
transaction.rollback();
} catch (Throwable e1) {
e.addSuppressed(e1);
}
throw new EventDeliveryException(e);
} finally {
transaction.close();
}
return eventCount == 0 ? Status.BACKOFF : Status.READY;
}
Aggregations