Search in sources :

Example 1 with ClusterCommunicationService

use of org.onosproject.store.cluster.messaging.ClusterCommunicationService in project onos by opennetworkinglab.

the class EventuallyConsistentMapImplTest method setUp.

@Before
public void setUp() throws Exception {
    clusterCommunicator = createMock(ClusterCommunicationService.class);
    persistenceService = new TestPersistenceService();
    // Add expectation for adding cluster message subscribers which
    // delegate to our ClusterCommunicationService implementation. This
    // allows us to get a reference to the map's internal cluster message
    // handlers so we can induce events coming in from a peer.
    clusterCommunicator.<Object, Object>addSubscriber(anyObject(MessageSubject.class), anyObject(Function.class), anyObject(Function.class), anyObject(Function.class));
    expectLastCall().andDelegateTo(new TestClusterCommunicationService()).times(1);
    clusterCommunicator.<Object, Object>addSubscriber(anyObject(MessageSubject.class), anyObject(Function.class), anyObject(Function.class), anyObject(Function.class), anyObject(Executor.class));
    expectLastCall().andDelegateTo(new TestClusterCommunicationService()).times(1);
    clusterCommunicator.<Object>addSubscriber(anyObject(MessageSubject.class), anyObject(Function.class), anyObject(Consumer.class), anyObject(Executor.class));
    expectLastCall().andDelegateTo(new TestClusterCommunicationService()).times(1);
    clusterCommunicator.<Object, Object>addSubscriber(anyObject(MessageSubject.class), anyObject(Function.class), anyObject(Function.class), anyObject(Function.class), anyObject(Executor.class));
    expectLastCall().andDelegateTo(new TestClusterCommunicationService()).times(1);
    clusterCommunicator.<Object>addSubscriber(anyObject(MessageSubject.class), anyObject(Function.class), anyObject(Consumer.class), anyObject(Executor.class));
    expectLastCall().andDelegateTo(new TestClusterCommunicationService()).times(1);
    replay(clusterCommunicator);
    clockService = new SequentialClockService<>();
    KryoNamespace.Builder serializer = KryoNamespace.newBuilder().register(KryoNamespaces.API).register(TestTimestamp.class);
    ecMap = new EventuallyConsistentMapBuilderImpl<String, String>(NodeId.nodeId("0"), clusterCommunicator, persistenceService, peersHandler, peersHandler).withName(MAP_NAME).withSerializer(serializer).withTimestampProvider((k, v) -> clockService.getTimestamp(k, v)).withCommunicationExecutor(MoreExecutors.newDirectExecutorService()).withPersistence().build();
    // Reset ready for tests to add their own expectations
    reset(clusterCommunicator);
}
Also used : TestPersistenceService(org.onosproject.store.persistence.TestPersistenceService) MessageSubject(org.onosproject.store.cluster.messaging.MessageSubject) Function(java.util.function.Function) Executor(java.util.concurrent.Executor) Consumer(java.util.function.Consumer) ClusterCommunicationService(org.onosproject.store.cluster.messaging.ClusterCommunicationService) EasyMock.anyObject(org.easymock.EasyMock.anyObject) KryoNamespace(org.onlab.util.KryoNamespace) Before(org.junit.Before)

Aggregations

Executor (java.util.concurrent.Executor)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 EasyMock.anyObject (org.easymock.EasyMock.anyObject)1 Before (org.junit.Before)1 KryoNamespace (org.onlab.util.KryoNamespace)1 ClusterCommunicationService (org.onosproject.store.cluster.messaging.ClusterCommunicationService)1 MessageSubject (org.onosproject.store.cluster.messaging.MessageSubject)1 TestPersistenceService (org.onosproject.store.persistence.TestPersistenceService)1