use of org.onlab.util.KryoNamespace in project onos by opennetworkinglab.
the class DistributedRouteStore method activate.
/**
* Sets up distributed route store.
*/
public void activate() {
routeTables = new ConcurrentHashMap<>();
executor = Executors.newSingleThreadExecutor(groupedThreads("onos/route", "store", log));
KryoNamespace masterRouteTableSerializer = KryoNamespace.newBuilder().register(RouteTableId.class).build();
masterRouteTable = storageService.<RouteTableId>setBuilder().withName("onos-master-route-table").withSerializer(Serializer.using(masterRouteTableSerializer)).build().asDistributedSet();
masterRouteTable.addListener(masterRouteTableListener);
// Add default tables (add is idempotent)
masterRouteTable.add(IPV4);
masterRouteTable.add(IPV6);
masterRouteTable.forEach(this::createRouteTable);
log.info("Started");
}
use of org.onlab.util.KryoNamespace in project onos by opennetworkinglab.
the class MastershipBasedTimestampTest method testKryoSerializableWithHandcraftedSerializer.
@Test
public final void testKryoSerializableWithHandcraftedSerializer() {
final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
final KryoNamespace kryos = KryoNamespace.newBuilder().register(new MastershipBasedTimestampSerializer(), MastershipBasedTimestamp.class).build();
kryos.serialize(TS_1_2, buffer);
buffer.flip();
Timestamp copy = kryos.deserialize(buffer);
new EqualsTester().addEqualityGroup(TS_1_2, copy).testEquals();
}
use of org.onlab.util.KryoNamespace in project onos by opennetworkinglab.
the class TimestampedTest method testKryoSerializable.
@Test
public final void testKryoSerializable() {
final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
final KryoNamespace kryos = KryoNamespace.newBuilder().register(Timestamped.class, MastershipBasedTimestamp.class).build();
Timestamped<String> original = new Timestamped<>("foobar", TS_1_1);
kryos.serialize(original, buffer);
buffer.flip();
Timestamped<String> copy = kryos.deserialize(buffer);
new EqualsTester().addEqualityGroup(original, copy).testEquals();
}
use of org.onlab.util.KryoNamespace in project onos by opennetworkinglab.
the class MastershipBasedTimestampTest method testKryoSerializable.
@Test
public final void testKryoSerializable() {
final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
final KryoNamespace kryos = KryoNamespace.newBuilder().register(MastershipBasedTimestamp.class).build();
kryos.serialize(TS_2_1, buffer);
buffer.flip();
Timestamp copy = kryos.deserialize(buffer);
new EqualsTester().addEqualityGroup(TS_2_1, copy).testEquals();
}
use of org.onlab.util.KryoNamespace in project onos by opennetworkinglab.
the class DistributedContextEventMapTreeStore method activate.
@Activate
public void activate() {
appId = coreService.registerApplication("org.onosproject.contexteventmapstore");
log.info("appId=" + appId);
KryoNamespace eventMapNamespace = KryoNamespace.newBuilder().register(KryoNamespaces.API).build();
eventMapTree = storageService.<String>documentTreeBuilder().withSerializer(Serializer.using(eventMapNamespace)).withName("context-event-map-store").withOrdering(Ordering.INSERTION).buildDocumentTree();
hintSetPerCxtMap = storageService.<String, Set<String>>eventuallyConsistentMapBuilder().withName("workflow-event-hint-per-cxt").withSerializer(eventMapNamespace).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
log.info("Started");
}
Aggregations