use of org.opendaylight.controller.cluster.datastore.utils.ActorContext in project controller by opendaylight.
the class DistributedShardedDOMDataTree method initDefaultShard.
@SuppressWarnings("checkstyle:IllegalCatch")
private void initDefaultShard(final LogicalDatastoreType logicalDatastoreType) throws ExecutionException, InterruptedException {
final PrefixedShardConfigWriter writer = writerMap.get(logicalDatastoreType);
if (writer.checkDefaultIsPresent()) {
LOG.debug("{}: Default shard for {} is already present in the config. Possibly saved in snapshot.", memberName, logicalDatastoreType);
} else {
try {
// Currently the default shard configuration is present in the out-of-box modules.conf and is
// expected to be present. So look up the local default shard here and create the frontend.
// TODO we don't have to do it for config and operational default shard separately. Just one of them
// should be enough
final ActorContext actorContext = logicalDatastoreType == LogicalDatastoreType.CONFIGURATION ? distributedConfigDatastore.getActorContext() : distributedOperDatastore.getActorContext();
final Optional<ActorRef> defaultLocalShardOptional = actorContext.findLocalShard(ClusterUtils.getCleanShardName(YangInstanceIdentifier.EMPTY));
if (defaultLocalShardOptional.isPresent()) {
LOG.debug("{}: Default shard for {} is already started, creating just frontend", memberName, logicalDatastoreType);
createShardFrontend(new DOMDataTreeIdentifier(logicalDatastoreType, YangInstanceIdentifier.EMPTY));
}
// The local shard isn't present - we assume that means the local member isn't in the replica list
// and will be dynamically created later via an explicit add-shard-replica request. This is the
// bootstrapping mechanism to add a new node into an existing cluster. The following code to create
// the default shard as a prefix shard is problematic in this scenario so it is commented out. Since
// the default shard is a module-based shard by default, it makes sense to always treat it as such,
// ie bootstrap it in the same manner as the special prefix-configuration and EOS shards.
// final Collection<MemberName> names = distributedConfigDatastore.getActorContext().getConfiguration()
// .getUniqueMemberNamesForAllShards();
// Await.result(FutureConverters.toScala(createDistributedShard(
// new DOMDataTreeIdentifier(logicalDatastoreType, YangInstanceIdentifier.EMPTY), names)),
// SHARD_FUTURE_TIMEOUT_DURATION);
// } catch (DOMDataTreeShardingConflictException e) {
// LOG.debug("{}: Default shard for {} already registered, possibly due to other node doing it faster",
// memberName, logicalDatastoreType);
} catch (Exception e) {
LOG.error("{}: Default shard initialization for {} failed", memberName, logicalDatastoreType, e);
throw new RuntimeException(e);
}
}
}
use of org.opendaylight.controller.cluster.datastore.utils.ActorContext in project controller by opendaylight.
the class ShardedDataTreeActor method onLookupPrefixShard.
@SuppressWarnings("checkstyle:IllegalCatch")
private void onLookupPrefixShard(final LookupPrefixShard message) {
LOG.debug("Member: {}, Received LookupPrefixShard: {}", clusterWrapper.getCurrentMemberName(), message);
final DOMDataTreeIdentifier prefix = message.getPrefix();
final ActorContext context = prefix.getDatastoreType() == LogicalDatastoreType.CONFIGURATION ? distributedConfigDatastore.getActorContext() : distributedOperDatastore.getActorContext();
// schedule a notification task for the reply
actorSystem.scheduler().scheduleOnce(SHARD_LOOKUP_TASK_INTERVAL, new ShardCreationLookupTask(actorSystem, getSender(), clusterWrapper, context, shardingService, prefix, lookupTaskMaxRetries), actorSystem.dispatcher());
}
use of org.opendaylight.controller.cluster.datastore.utils.ActorContext in project controller by opendaylight.
the class ShardedDataTreeActor method onStartConfigShardLookup.
private void onStartConfigShardLookup(final StartConfigShardLookup message) {
LOG.debug("Received StartConfigShardLookup: {}", message);
final ActorContext context = message.getType().equals(LogicalDatastoreType.CONFIGURATION) ? distributedConfigDatastore.getActorContext() : distributedOperDatastore.getActorContext();
// schedule a notification task for the reply
actorSystem.scheduler().scheduleOnce(SHARD_LOOKUP_TASK_INTERVAL, new ConfigShardLookupTask(actorSystem, getSender(), context, message, lookupTaskMaxRetries), actorSystem.dispatcher());
}
use of org.opendaylight.controller.cluster.datastore.utils.ActorContext in project controller by opendaylight.
the class AbstractClientHistoryTest method createActorContextMock.
protected static ActorContext createActorContextMock(final ActorSystem system, final ActorRef actor) {
final ActorContext mock = mock(ActorContext.class);
final Promise<PrimaryShardInfo> promise = new DefaultPromise<>();
final ActorSelection selection = system.actorSelection(actor.path());
final PrimaryShardInfo shardInfo = new PrimaryShardInfo(selection, (short) 0);
promise.success(shardInfo);
when(mock.findPrimaryShardAsync(any())).thenReturn(promise.future());
return mock;
}
use of org.opendaylight.controller.cluster.datastore.utils.ActorContext in project controller by opendaylight.
the class AbstractDataStoreClientBehaviorTest method setUp.
@Before
public void setUp() throws Exception {
system = ActorSystem.apply();
clientActorProbe = new TestProbe(system, "client");
actorContextProbe = new TestProbe(system, "actor-context");
final ActorContext context = createActorContextMock(system, actorContextProbe.ref());
clientContext = AccessClientUtil.createClientActorContext(system, clientActorProbe.ref(), CLIENT_ID, PERSISTENCE_ID);
behavior = createBehavior(clientContext, context);
}
Aggregations