Search in sources :

Example 1 with UnsupportedDbusEventVersionRuntimeException

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;
}
Also used : UnsupportedDbusEventVersionRuntimeException(com.linkedin.databus.core.UnsupportedDbusEventVersionRuntimeException) DbusEventInternalWritable(com.linkedin.databus.core.DbusEventInternalWritable) DbusEventV1Factory(com.linkedin.databus.core.DbusEventV1Factory) DbusEventFactory(com.linkedin.databus.core.DbusEventFactory) DbusEventV2Factory(com.linkedin.databus.core.DbusEventV2Factory)

Aggregations

DbusEventFactory (com.linkedin.databus.core.DbusEventFactory)1 DbusEventInternalWritable (com.linkedin.databus.core.DbusEventInternalWritable)1 DbusEventV1Factory (com.linkedin.databus.core.DbusEventV1Factory)1 DbusEventV2Factory (com.linkedin.databus.core.DbusEventV2Factory)1 UnsupportedDbusEventVersionRuntimeException (com.linkedin.databus.core.UnsupportedDbusEventVersionRuntimeException)1