use of com.thinkbiganalytics.provenance.api.ProvenanceException in project kylo by Teradata.
the class KyloKafkaProvenanceEventService method sendEvents.
@Override
public void sendEvents(List<ProvenanceEventRecordDTO> events) throws ProvenanceException {
try {
List<Future<RecordMetadata>> resultFutures = new ArrayList<>();
ProvenanceEventRecordDTOHolder eventRecordDTOHolder = new ProvenanceEventRecordDTOHolder();
List<ProvenanceEventRecordDTO> batchEvents = new ArrayList<>();
for (ProvenanceEventRecordDTO event : events) {
if (!event.isStream()) {
batchEvents.add(event);
}
}
eventRecordDTOHolder.setEvents(batchEvents);
byte[] data = SerializationUtils.serialize(eventRecordDTOHolder);
ProducerRecord<byte[], byte[]> eventsMessage = new ProducerRecord<>(KYLO_BATCH_EVENT_TOPIC, data);
log.info("Sending {} events to Kafka ", eventRecordDTOHolder);
resultFutures.add(kafkaProducer.send(eventsMessage));
AggregatedFeedProcessorStatisticsHolder stats = GroupedStatsUtil.gatherStats(events);
data = SerializationUtils.serialize(stats);
ProducerRecord<byte[], byte[]> statsMessage = new ProducerRecord<>(KYLO_EVENT_STATS_TOPIC, data);
resultFutures.add(kafkaProducer.send(statsMessage));
processAcks(resultFutures);
} catch (Exception e) {
throw new ProvenanceException(e);
}
}
use of com.thinkbiganalytics.provenance.api.ProvenanceException in project kylo by Teradata.
the class TestProvenanceRest method testProvenanceRest.
// @Test
public void testProvenanceRest() {
ProvenanceEventService restProvenanceEventService = new KyloRestProvenanceEventService();
Map<String, String> params = new HashMap<>();
params.put(KyloRestProvenanceEventService.USERNAME_CONFIG, "dladmin");
params.put(KyloRestProvenanceEventService.PASSWORD_CONFIG, "thinkbig");
params.put(KyloRestProvenanceEventService.HOST_CONFIG, "localhost");
params.put(KyloRestProvenanceEventService.PORT_CONFIG, "8400");
restProvenanceEventService.configure(params);
String feedName = "provenance.provenance_test";
String flowfileId = UUID.randomUUID().toString();
DateTime startTime = DateTime.now().minusMinutes(1);
Long start = startTime.getMillis();
ProvenanceEventRecordDTO event1 = new ProvenanceEventDtoBuilder(feedName, flowfileId, "First Step").startingEvent(true).startTime(start).build();
ProvenanceEventRecordDTO event2 = new ProvenanceEventDtoBuilder(feedName, flowfileId, "Second Step").startTime(startTime.plusSeconds(30).getMillis()).build();
ProvenanceEventRecordDTO event3 = new ProvenanceEventDtoBuilder(feedName, flowfileId, "Final Step").endingEvent(true).build();
List<ProvenanceEventRecordDTO> events = new ArrayList<>();
events.add(event1);
events.add(event2);
events.add(event3);
try {
restProvenanceEventService.sendEvents(events);
} catch (ProvenanceException e) {
e.printStackTrace();
}
}
Aggregations