use of org.opendaylight.controller.cluster.access.concepts.MemberName in project controller by opendaylight.
the class ShardManager method memberReachable.
private void memberReachable(final ClusterEvent.ReachableMember message) {
MemberName memberName = memberToName(message.member());
LOG.info("Received ReachableMember: memberName {}, address: {}", memberName, message.member().address());
addPeerAddress(memberName, message.member().address());
markMemberAvailable(memberName);
}
use of org.opendaylight.controller.cluster.access.concepts.MemberName in project controller by opendaylight.
the class ShardManager method createLocalShards.
/**
* Create shards that are local to the member on which the ShardManager runs.
*/
private void createLocalShards() {
MemberName memberName = this.cluster.getCurrentMemberName();
Collection<String> memberShardNames = this.configuration.getMemberShardNames(memberName);
Map<String, DatastoreSnapshot.ShardSnapshot> shardSnapshots = new HashMap<>();
if (restoreFromSnapshot != null) {
for (DatastoreSnapshot.ShardSnapshot snapshot : restoreFromSnapshot.getShardSnapshots()) {
shardSnapshots.put(snapshot.getName(), snapshot);
}
}
// null out to GC
restoreFromSnapshot = null;
for (String shardName : memberShardNames) {
ShardIdentifier shardId = getShardIdentifier(memberName, shardName);
LOG.debug("{}: Creating local shard: {}", persistenceId(), shardId);
Map<String, String> peerAddresses = getPeerAddresses(shardName);
localShards.put(shardName, new ShardInformation(shardName, shardId, peerAddresses, newShardDatastoreContext(shardName), Shard.builder().restoreFromSnapshot(shardSnapshots.get(shardName)), peerAddressResolver));
}
}
use of org.opendaylight.controller.cluster.access.concepts.MemberName in project controller by opendaylight.
the class ShardManager method memberUnreachable.
private void memberUnreachable(final ClusterEvent.UnreachableMember message) {
MemberName memberName = memberToName(message.member());
LOG.info("Received UnreachableMember: memberName {}, address: {}", memberName, message.member().address());
markMemberUnavailable(memberName);
}
use of org.opendaylight.controller.cluster.access.concepts.MemberName in project controller by opendaylight.
the class ShardManager method updateSchemaContext.
/**
* Notifies all the local shards of a change in the schema context.
*
* @param message the message to send
*/
private void updateSchemaContext(final Object message) {
schemaContext = ((UpdateSchemaContext) message).getSchemaContext();
LOG.debug("Got updated SchemaContext: # of modules {}", schemaContext.getModules().size());
for (ShardInformation info : localShards.values()) {
info.setSchemaContext(schemaContext);
if (info.getActor() == null) {
LOG.debug("Creating Shard {}", info.getShardId());
info.setActor(newShardActor(info));
// Update peer address for every existing peer memeber to avoid missing sending
// PeerAddressResolved and PeerUp to this shard while UpdateSchemaContext comes after MemberUp.
String shardName = info.getShardName();
for (MemberName memberName : peerAddressResolver.getPeerMembers()) {
String peerId = getShardIdentifier(memberName, shardName).toString();
String peerAddress = peerAddressResolver.getShardActorAddress(shardName, memberName);
info.updatePeerAddress(peerId, peerAddress, getSelf());
info.peerUp(memberName, peerId, getSelf());
LOG.debug("{}: updated peer {} on member {} with address {} on shard {} whose actor address is {}", persistenceId(), peerId, memberName, peerAddress, info.getShardId(), info.getActor());
}
} else {
info.getActor().tell(message, getSelf());
}
}
}
use of org.opendaylight.controller.cluster.access.concepts.MemberName in project controller by opendaylight.
the class ShardManager method applyShardManagerSnapshot.
private void applyShardManagerSnapshot(final ShardManagerSnapshot snapshot) {
currentSnapshot = snapshot;
LOG.debug("{}: onSnapshotOffer: {}", persistenceId(), currentSnapshot);
final MemberName currentMember = cluster.getCurrentMemberName();
Set<String> configuredShardList = new HashSet<>(configuration.getMemberShardNames(currentMember));
for (String shard : currentSnapshot.getShardList()) {
if (!configuredShardList.contains(shard)) {
// add the current member as a replica for the shard
LOG.debug("{}: adding shard {}", persistenceId(), shard);
configuration.addMemberReplicaForShard(shard, currentMember);
} else {
configuredShardList.remove(shard);
}
}
for (String shard : configuredShardList) {
// remove the member as a replica for the shard
LOG.debug("{}: removing shard {}", persistenceId(), shard);
configuration.removeMemberReplicaForShard(shard, currentMember);
}
}
Aggregations