+ public DistributedDataStore setupDistributedDataStoreWithoutConfig(final String typeName,
+ final SchemaContext schemaContext) {
+ final ClusterWrapper cluster = new ClusterWrapperImpl(getSystem());
+ final ConfigurationImpl configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider());
+
+ getDatastoreContextBuilder().dataStoreName(typeName);
+
+ final DatastoreContext datastoreContext = getDatastoreContextBuilder().build();
+
+ final DatastoreContextFactory mockContextFactory = Mockito.mock(DatastoreContextFactory.class);
+ Mockito.doReturn(datastoreContext).when(mockContextFactory).getBaseDatastoreContext();
+ Mockito.doReturn(datastoreContext).when(mockContextFactory).getShardDatastoreContext(Mockito.anyString());
+
+ final DistributedDataStore dataStore = new DistributedDataStore(getSystem(), cluster,
+ configuration, mockContextFactory, restoreFromSnapshot);
+
+ dataStore.onGlobalContextUpdated(schemaContext);
+
+ datastoreContextBuilder = DatastoreContext.newBuilderFrom(datastoreContext);
+ return dataStore;
+ }
+
+ public DistributedDataStore setupDistributedDataStoreWithoutConfig(final String typeName,
+ final SchemaContext schemaContext,
+ final LogicalDatastoreType storeType) {
+ final ClusterWrapper cluster = new ClusterWrapperImpl(getSystem());
+ final ConfigurationImpl configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider());
+
+ getDatastoreContextBuilder().dataStoreName(typeName);
+
+ final DatastoreContext datastoreContext =
+ getDatastoreContextBuilder().logicalStoreType(storeType).build();
+
+ final DatastoreContextFactory mockContextFactory = Mockito.mock(DatastoreContextFactory.class);
+ Mockito.doReturn(datastoreContext).when(mockContextFactory).getBaseDatastoreContext();
+ Mockito.doReturn(datastoreContext).when(mockContextFactory).getShardDatastoreContext(Mockito.anyString());
+
+ final DistributedDataStore dataStore = new DistributedDataStore(getSystem(), cluster,
+ configuration, mockContextFactory, restoreFromSnapshot);
+
+ dataStore.onGlobalContextUpdated(schemaContext);
+
+ datastoreContextBuilder = DatastoreContext.newBuilderFrom(datastoreContext);
+ return dataStore;
+ }
+
+ public void waitUntilLeader(final ActorContext actorContext, final String... shardNames) {
+ for (String shardName: shardNames) {
+ ActorRef shard = findLocalShard(actorContext, shardName);
+
+ assertNotNull("Shard was not created for " + shardName, shard);
+
+ waitUntilLeader(shard);
+ }
+ }
+
+ public void waitUntilNoLeader(final ActorContext actorContext, final String... shardNames) {
+ for (String shardName: shardNames) {
+ ActorRef shard = findLocalShard(actorContext, shardName);
+ assertNotNull("No local shard found for " + shardName, shard);
+
+ waitUntilNoLeader(shard);
+ }
+ }
+
+ public void waitForMembersUp(final String... otherMembers) {
+ Set<String> otherMembersSet = Sets.newHashSet(otherMembers);
+ Stopwatch sw = Stopwatch.createStarted();
+ while (sw.elapsed(TimeUnit.SECONDS) <= 10) {
+ CurrentClusterState state = Cluster.get(getSystem()).state();
+ for (Member m: state.getMembers()) {
+ if (m.status() == MemberStatus.up() && otherMembersSet.remove(m.getRoles().iterator().next())
+ && otherMembersSet.isEmpty()) {
+ return;