Search in sources :

Example 6 with KryoNamespace

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");
}
Also used : RouteTableId(org.onosproject.routeservice.RouteTableId) KryoNamespace(org.onlab.util.KryoNamespace)

Example 7 with KryoNamespace

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();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) KryoNamespace(org.onlab.util.KryoNamespace) MastershipBasedTimestampSerializer(org.onosproject.store.serializers.custom.MastershipBasedTimestampSerializer) ByteBuffer(java.nio.ByteBuffer) Timestamp(org.onosproject.store.Timestamp) Test(org.junit.Test)

Example 8 with KryoNamespace

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();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) KryoNamespace(org.onlab.util.KryoNamespace) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 9 with KryoNamespace

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();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) KryoNamespace(org.onlab.util.KryoNamespace) ByteBuffer(java.nio.ByteBuffer) Timestamp(org.onosproject.store.Timestamp) Test(org.junit.Test)

Example 10 with KryoNamespace

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");
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) KryoNamespace(org.onlab.util.KryoNamespace) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

KryoNamespace (org.onlab.util.KryoNamespace)13 Activate (org.osgi.service.component.annotations.Activate)7 EqualsTester (com.google.common.testing.EqualsTester)4 ByteBuffer (java.nio.ByteBuffer)4 Test (org.junit.Test)4 Timestamp (org.onosproject.store.Timestamp)3 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)2 BaseJsonNode (com.fasterxml.jackson.databind.node.BaseJsonNode)1 BinaryNode (com.fasterxml.jackson.databind.node.BinaryNode)1 ContainerNode (com.fasterxml.jackson.databind.node.ContainerNode)1 DoubleNode (com.fasterxml.jackson.databind.node.DoubleNode)1 IntNode (com.fasterxml.jackson.databind.node.IntNode)1 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)1 LongNode (com.fasterxml.jackson.databind.node.LongNode)1 NullNode (com.fasterxml.jackson.databind.node.NullNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 POJONode (com.fasterxml.jackson.databind.node.POJONode)1 ValueNode (com.fasterxml.jackson.databind.node.ValueNode)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1