Search in sources :

Example 1 with ShardStrategyFactory

use of org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory in project controller by opendaylight.

the class AbstractTransactionProxyTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    schemaContext = TestModel.createTestContext();
    doReturn(getSystem()).when(mockActorContext).getActorSystem();
    doReturn(getSystem().dispatchers().defaultGlobalDispatcher()).when(mockActorContext).getClientDispatcher();
    doReturn(MemberName.forName(memberName)).when(mockActorContext).getCurrentMemberName();
    doReturn(new ShardStrategyFactory(configuration, LogicalDatastoreType.CONFIGURATION)).when(mockActorContext).getShardStrategyFactory();
    doReturn(schemaContext).when(mockActorContext).getSchemaContext();
    doReturn(new Timeout(operationTimeoutInSeconds, TimeUnit.SECONDS)).when(mockActorContext).getOperationTimeout();
    doReturn(mockClusterWrapper).when(mockActorContext).getClusterWrapper();
    doReturn(mockClusterWrapper).when(mockActorContext).getClusterWrapper();
    doReturn(dataStoreContextBuilder.build()).when(mockActorContext).getDatastoreContext();
    final ClientIdentifier mockClientId = MockIdentifiers.clientIdentifier(getClass(), memberName);
    mockComponentFactory = new TransactionContextFactory(mockActorContext, mockClientId);
    Timer timer = new MetricRegistry().timer("test");
    doReturn(timer).when(mockActorContext).getOperationTimer(any(String.class));
}
Also used : ClientIdentifier(org.opendaylight.controller.cluster.access.concepts.ClientIdentifier) Timer(com.codahale.metrics.Timer) Timeout(akka.util.Timeout) MetricRegistry(com.codahale.metrics.MetricRegistry) ShardStrategyFactory(org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory) Before(org.junit.Before)

Example 2 with ShardStrategyFactory

use of org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory in project controller by opendaylight.

the class DistributedDataStoreClientBehaviorTest method createBehavior.

@Override
protected AbstractDataStoreClientBehavior createBehavior(final ClientActorContext clientContext, final ActorContext context) {
    final ShardStrategyFactory factory = mock(ShardStrategyFactory.class);
    final ShardStrategy strategy = mock(ShardStrategy.class);
    when(strategy.findShard(any())).thenReturn(SHARD);
    when(factory.getStrategy(any())).thenReturn(strategy);
    when(context.getShardStrategyFactory()).thenReturn(factory);
    return new DistributedDataStoreClientBehavior(clientContext, context);
}
Also used : ShardStrategy(org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy) ShardStrategyFactory(org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory)

Aggregations

ShardStrategyFactory (org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory)2 Timeout (akka.util.Timeout)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 Timer (com.codahale.metrics.Timer)1 Before (org.junit.Before)1 ClientIdentifier (org.opendaylight.controller.cluster.access.concepts.ClientIdentifier)1 ShardStrategy (org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy)1