This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"namespace":"io.shunters.coda.avro.api", | |
"type":"record", | |
"doc":"Record Array", | |
"name":"Records", | |
"fields":[ | |
{ | |
"name":"firstOffset", | |
"type":"long" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"namespace":"io.shunters.coda.avro.api", | |
"type":"record", | |
"doc":"Request Header", | |
"name":"RequestHeader", | |
"fields":[ | |
{ | |
"name":"correlationId", | |
"type":"int" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"namespace":"io.shunters.coda.avro.api", | |
"type":"record", | |
"doc":"Produce Request", | |
"name":"ProduceRequest", | |
"fields":[ | |
{ | |
"name":"requestHeader", | |
"type":"io.shunters.coda.avro.api.RequestHeader" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.shunters.coda.protocol; | |
import org.apache.avro.Schema; | |
import org.apache.commons.io.Charsets; | |
import org.apache.commons.io.IOUtils; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import java.io.IOException; | |
import java.io.InputStream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<appender name="eventLoggerDailyRollingFileAppender" class="org.apache.log4j.DailyRollingFileAppender"> | |
<param name="File" value="/any-temp/collection-logger.log" /> | |
<param name="DatePattern" value="'.'yyyy-MM-dd" /> | |
<param name="Encoding" value="UTF-8" /> | |
<param name="MaxBackupIndex" value="3"/> | |
<layout class="org.apache.log4j.PatternLayout"> | |
<param name="ConversionPattern" value="%m%n" /> | |
</layout> | |
</appender> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Logger eventLogger = LoggerFactory.getLogger("event-logger"); | |
... | |
@Override | |
public void onEvent(EventLog eventLog, long sequence, boolean endOfBatch) | |
throws Exception { | |
String eventType = eventLog.getEventType(); | |
String json = eventLog.getValue(); | |
if (this.eventLoggingEnabled) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onEvent(EventLog eventLog, long l, boolean b) throws Exception { | |
String topic = eventLog.getEventType(); | |
String json = eventLog.getValue(); | |
// send event log to kafka. | |
if (this.sendMessageEnabled) { | |
producer.send(new ProducerRecord<Integer, String>(topic, json)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.putDisruptor = DisruptorCreator.singleton(DisruptorCreator.DISRUPTOR_NAME_PUT, EventLog.FACTORY, 1024, produceToKafkaHandler, loggerEventHandler); | |
this.putEventTranslator = new BaseTranslator.EventLogTranslator(); | |
... | |
@Override | |
public void onEvent(final EventLog eventLog, final long sequence, final boolean endOfBatch) throws Exception { | |
String version = eventLog.getVersion(); | |
String json = eventLog.getValue(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseTranslator { | |
public static class EventLogTranslator extends EventLog implements EventTranslator<EventLog> | |
{ | |
@Override | |
public void translateTo(EventLog eventLog, long sequence) { | |
eventLog.setVersion(this.getVersion()); | |
eventLog.setEventType(this.getEventType()); | |
eventLog.setValue(this.getValue()); | |
} |