use of com.linkedin.databus.core.UnsupportedDbusEventVersionRuntimeException in project databus by linkedin.
the class DbusEventFactoryForTesting method createReadOnlyDbusEventFromBuffer.
/**
* Creates a read-only DbusEvent out of an already initialized (serialized) buffer,
* except with the specified SCN. The event's header CRC is updated appropriately.
*
* @param buf buffer containing the serialized event
* @param position byte-offset of the serialized event in the buffer
* @param seq sequence number (SCN) of the new event
* @param version desired version of the new event
* @return a read-only DbusEvent
*/
public static DbusEventInternalReadable createReadOnlyDbusEventFromBuffer(ByteBuffer buf, int position, long seq, byte version) {
DbusEventFactory eventFactory;
if (version == DbusEventFactory.DBUS_EVENT_V1) {
eventFactory = new DbusEventV1Factory();
} else if (version == DbusEventFactory.DBUS_EVENT_V2) {
eventFactory = new DbusEventV2Factory();
} else {
throw new UnsupportedDbusEventVersionRuntimeException(version);
}
DbusEventInternalWritable event = eventFactory.createWritableDbusEventFromBuffer(buf, position);
event.setSequence(seq);
event.applyCrc();
return event;
}
Aggregations