Search in sources :

Example 11 with Timestamp

use of org.onosproject.store.Timestamp in project onos by opennetworkinglab.

the class IntentCleanupTestMock method installingPoll.

/**
 * Trigger resubmit of intent in INSTALLING for too long.
 */
@Test
@Ignore("The implementation is dependent on the SimpleStore")
public void installingPoll() {
    IntentStoreDelegate mockDelegate = new IntentStoreDelegate() {

        @Override
        public void process(IntentData intentData) {
            intentData.setState(INSTALLING);
            store.write(intentData);
        }

        @Override
        public void notify(IntentEvent event) {
            cleanup.event(event);
        }
    };
    store.setDelegate(mockDelegate);
    Intent intent = new MockIntent(1L);
    Timestamp version = new SystemClockTimestamp(1L);
    IntentData data = new IntentData(intent, INSTALL_REQ, version);
    store.addPending(data);
    service.addPending(data);
    expectLastCall().once();
    replay(service);
    cleanup.run();
    verify(service);
    reset(service);
}
Also used : IntentStoreDelegate(org.onosproject.net.intent.IntentStoreDelegate) SystemClockTimestamp(org.onosproject.store.trivial.SystemClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) Intent(org.onosproject.net.intent.Intent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) SystemClockTimestamp(org.onosproject.store.trivial.SystemClockTimestamp) Timestamp(org.onosproject.store.Timestamp) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) IntentEvent(org.onosproject.net.intent.IntentEvent) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 12 with Timestamp

use of org.onosproject.store.Timestamp 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 13 with Timestamp

use of org.onosproject.store.Timestamp in project onos by opennetworkinglab.

the class EventuallyConsistentMapImplTest method generateRemoveMessage.

private List<UpdateEntry<String, String>> generateRemoveMessage(String key1, String key2) {
    List<UpdateEntry<String, String>> list = new ArrayList<>();
    Timestamp timestamp1 = clockService.peek(1);
    Timestamp timestamp2 = clockService.peek(2);
    list.add(generateRemoveMessage(key1, timestamp1));
    list.add(generateRemoveMessage(key2, timestamp2));
    return list;
}
Also used : ArrayList(java.util.ArrayList) Timestamp(org.onosproject.store.Timestamp)

Example 14 with Timestamp

use of org.onosproject.store.Timestamp in project onos by opennetworkinglab.

the class MapValueTest method testConstruction.

@Test
public void testConstruction() {
    Timestamp ts = new LogicalTimestamp(10);
    MapValue<String> mv = new MapValue<>("foo", ts);
    assertEquals("foo", mv.get());
    assertEquals(ts, mv.timestamp());
    assertTrue(mv.isAlive());
}
Also used : LogicalTimestamp(org.onosproject.store.LogicalTimestamp) Timestamp(org.onosproject.store.Timestamp) LogicalTimestamp(org.onosproject.store.LogicalTimestamp) Test(org.junit.Test)

Example 15 with Timestamp

use of org.onosproject.store.Timestamp 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)

Aggregations

Timestamp (org.onosproject.store.Timestamp)32 Test (org.junit.Test)15 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)14 MastershipBasedTimestamp (org.onosproject.store.impl.MastershipBasedTimestamp)13 MultiValuedTimestamp (org.onosproject.store.service.MultiValuedTimestamp)13 ProviderId (org.onosproject.net.provider.ProviderId)9 DeviceEvent (org.onosproject.net.device.DeviceEvent)8 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)8 Intent (org.onosproject.net.intent.Intent)8 IntentData (org.onosproject.net.intent.IntentData)8 IntentEvent (org.onosproject.net.intent.IntentEvent)8 IntentStoreDelegate (org.onosproject.net.intent.IntentStoreDelegate)8 MockIntent (org.onosproject.net.intent.IntentTestsMocks.MockIntent)8 SystemClockTimestamp (org.onosproject.store.trivial.SystemClockTimestamp)8 DeviceId (org.onosproject.net.DeviceId)6 ArrayList (java.util.ArrayList)5 ControllerNodeToNodeId.toNodeId (org.onosproject.cluster.ControllerNodeToNodeId.toNodeId)5 NodeId (org.onosproject.cluster.NodeId)5 DefaultDevice (org.onosproject.net.DefaultDevice)5 Device (org.onosproject.net.Device)5