本文整理汇总了Java中org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound类的典型用法代码示例。如果您正苦于以下问题:Java LocalShardNotFound类的具体用法?Java LocalShardNotFound怎么用?Java LocalShardNotFound使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LocalShardNotFound类属于org.opendaylight.controller.cluster.datastore.messages包,在下文中一共展示了LocalShardNotFound类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findLocalShardAsync
import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound; //导入依赖的package包/类
/**
* Finds a local shard async given its shard name and return a Future from which to obtain the
* ActorRef.
*
* @param shardName the name of the local shard that needs to be found
*/
public Future<ActorRef> findLocalShardAsync(final String shardName) {
Future<Object> future = executeOperationAsync(shardManager,
new FindLocalShard(shardName, true), shardInitializationTimeout);
return future.map(new Mapper<Object, ActorRef>() {
@Override
public ActorRef checkedApply(Object response) throws Throwable {
if (response instanceof LocalShardFound) {
LocalShardFound found = (LocalShardFound)response;
LOG.debug("Local shard found {}", found.getPath());
return found.getPath();
} else if (response instanceof NotInitializedException) {
throw (NotInitializedException)response;
} else if (response instanceof LocalShardNotFound) {
throw new LocalShardNotFoundException(
String.format("Local shard for %s does not exist.", shardName));
}
throw new UnknownMessageException(String.format(
"FindLocalShard returned unkown response: %s", response));
}
}, getClientDispatcher());
}
示例2: findLocalShard
import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound; //导入依赖的package包/类
private void findLocalShard(final FindLocalShard message) {
LOG.debug("{}: findLocalShard : {}", persistenceId(), message.getShardName());
final ShardInformation shardInformation = localShards.get(message.getShardName());
if (shardInformation == null) {
LOG.debug("{}: Local shard {} not found - shards present: {}",
persistenceId(), message.getShardName(), localShards.keySet());
getSender().tell(new LocalShardNotFound(message.getShardName()), getSelf());
return;
}
sendResponse(shardInformation, message.isWaitUntilInitialized(), false,
() -> new LocalShardFound(shardInformation.getActor()));
}
示例3: onReceive
import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound; //导入依赖的package包/类
@Override public void onReceive(final Object message) throws Exception {
if (message instanceof FindPrimary) {
FindPrimary fp = (FindPrimary)message;
Object resp = findPrimaryResponses.get(fp.getShardName());
if (resp == null) {
LOG.error("No expected FindPrimary response found for shard name {}", fp.getShardName());
} else {
getSender().tell(resp, getSelf());
}
return;
}
if (found) {
getSender().tell(new LocalShardFound(actorRef), getSelf());
} else {
getSender().tell(new LocalShardNotFound(((FindLocalShard) message).getShardName()), getSelf());
}
}
示例4: testOnReceiveFindLocalShardForNonExistentShard
import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound; //导入依赖的package包/类
@Test
public void testOnReceiveFindLocalShardForNonExistentShard() throws Exception {
new JavaTestKit(getSystem()) {
{
final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor());
shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
shardManager.tell(new FindLocalShard("non-existent", false), getRef());
LocalShardNotFound notFound = expectMsgClass(duration("5 seconds"), LocalShardNotFound.class);
assertEquals("getShardName", "non-existent", notFound.getShardName());
}
};
}
示例5: testShardPersistenceWithRestoredData
import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound; //导入依赖的package包/类
@Test
public void testShardPersistenceWithRestoredData() throws Exception {
LOG.info("testShardPersistenceWithRestoredData starting");
new JavaTestKit(getSystem()) {
{
MockConfiguration mockConfig =
new MockConfiguration(ImmutableMap.<String, List<String>>builder()
.put("default", Arrays.asList("member-1", "member-2"))
.put("astronauts", Arrays.asList("member-2"))
.put("people", Arrays.asList("member-1", "member-2")).build());
String[] restoredShards = {"default", "astronauts"};
ShardManagerSnapshot snapshot =
new ShardManagerSnapshot(Arrays.asList(restoredShards), Collections.emptyMap());
InMemorySnapshotStore.addSnapshot("shard-manager-" + shardMrgIDSuffix, snapshot);
// create shardManager to come up with restored data
TestActorRef<TestShardManager> newRestoredShardManager = actorFactory.createTestActor(
newShardMgrProps(mockConfig).withDispatcher(Dispatchers.DefaultDispatcherId()));
newRestoredShardManager.underlyingActor().waitForRecoveryComplete();
newRestoredShardManager.tell(new FindLocalShard("people", false), getRef());
LocalShardNotFound notFound = expectMsgClass(duration("5 seconds"), LocalShardNotFound.class);
assertEquals("for uninitialized shard", "people", notFound.getShardName());
// Verify a local shard is created for the restored shards,
// although we expect a NotInitializedException for the shards
// as the actor initialization
// message is not sent for them
newRestoredShardManager.tell(new FindLocalShard("default", false), getRef());
expectMsgClass(duration("5 seconds"), NotInitializedException.class);
newRestoredShardManager.tell(new FindLocalShard("astronauts", false), getRef());
expectMsgClass(duration("5 seconds"), NotInitializedException.class);
}
};
LOG.info("testShardPersistenceWithRestoredData ending");
}
示例6: testAddShardReplicaWithAddServerReplyFailure
import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound; //导入依赖的package包/类
@Test
public void testAddShardReplicaWithAddServerReplyFailure() throws Exception {
LOG.info("testAddShardReplicaWithAddServerReplyFailure starting");
new JavaTestKit(getSystem()) {
{
JavaTestKit mockShardLeaderKit = new JavaTestKit(getSystem());
MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.<String, List<String>>builder()
.put("astronauts", Arrays.asList("member-2")).build());
ActorRef mockNewReplicaShardActor = newMockShardActor(getSystem(), "astronauts", "member-1");
final TestActorRef<TestShardManager> shardManager = actorFactory.createTestActor(
newTestShardMgrBuilder(mockConfig).shardActor(mockNewReplicaShardActor).props()
.withDispatcher(Dispatchers.DefaultDispatcherId()), shardMgrID);
shardManager.underlyingActor()
.setMessageInterceptor(newFindPrimaryInterceptor(mockShardLeaderKit.getRef()));
shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
JavaTestKit terminateWatcher = new JavaTestKit(getSystem());
terminateWatcher.watch(mockNewReplicaShardActor);
shardManager.tell(new AddShardReplica("astronauts"), getRef());
AddServer addServerMsg = mockShardLeaderKit.expectMsgClass(AddServer.class);
assertEquals("AddServer serverId", "member-1-shard-astronauts-" + shardMrgIDSuffix,
addServerMsg.getNewServerId());
mockShardLeaderKit.reply(new AddServerReply(ServerChangeStatus.TIMEOUT, null));
Failure failure = expectMsgClass(duration("5 seconds"), Failure.class);
assertEquals("Failure cause", TimeoutException.class, failure.cause().getClass());
shardManager.tell(new FindLocalShard("astronauts", false), getRef());
expectMsgClass(duration("5 seconds"), LocalShardNotFound.class);
terminateWatcher.expectTerminated(mockNewReplicaShardActor);
shardManager.tell(new AddShardReplica("astronauts"), getRef());
mockShardLeaderKit.expectMsgClass(AddServer.class);
mockShardLeaderKit.reply(new AddServerReply(ServerChangeStatus.NO_LEADER, null));
failure = expectMsgClass(duration("5 seconds"), Failure.class);
assertEquals("Failure cause", NoShardLeaderException.class, failure.cause().getClass());
}
};
LOG.info("testAddShardReplicaWithAddServerReplyFailure ending");
}