use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType in project controller by opendaylight.
the class ClusterAdminRpcService method addPrefixShardReplica.
@Override
public Future<RpcResult<Void>> addPrefixShardReplica(final AddPrefixShardReplicaInput input) {
final InstanceIdentifier<?> identifier = input.getShardPrefix();
if (identifier == null) {
return newFailedRpcResultFuture("A valid shard identifier must be specified");
}
final DataStoreType dataStoreType = input.getDataStoreType();
if (dataStoreType == null) {
return newFailedRpcResultFuture("A valid DataStoreType must be specified");
}
LOG.info("Adding replica for shard {}, datastore type {}", identifier, dataStoreType);
final YangInstanceIdentifier prefix = serializer.toYangInstanceIdentifier(identifier);
final SettableFuture<RpcResult<Void>> returnFuture = SettableFuture.create();
ListenableFuture<Success> future = sendMessageToShardManager(dataStoreType, new AddPrefixShardReplica(prefix));
Futures.addCallback(future, new FutureCallback<Success>() {
@Override
public void onSuccess(Success success) {
LOG.info("Successfully added replica for shard {}", prefix);
returnFuture.set(newSuccessfulResult());
}
@Override
public void onFailure(Throwable failure) {
onMessageFailure(String.format("Failed to add replica for shard %s", prefix), returnFuture, failure);
}
}, MoreExecutors.directExecutor());
return returnFuture;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType in project controller by opendaylight.
the class ClusterAdminRpcService method sendMessageToManagerForConfiguredShards.
private <T> void sendMessageToManagerForConfiguredShards(DataStoreType dataStoreType, List<Entry<ListenableFuture<T>, ShardResultBuilder>> shardResultData, Function<String, Object> messageSupplier) {
ActorContext actorContext = dataStoreType == DataStoreType.Config ? configDataStore.getActorContext() : operDataStore.getActorContext();
Set<String> allShardNames = actorContext.getConfiguration().getAllShardNames();
LOG.debug("Sending message to all shards {} for data store {}", allShardNames, actorContext.getDataStoreName());
for (String shardName : allShardNames) {
ListenableFuture<T> future = this.ask(actorContext.getShardManager(), messageSupplier.apply(shardName), SHARD_MGR_TIMEOUT);
shardResultData.add(new SimpleEntry<>(future, new ShardResultBuilder().setShardName(shardName).setDataStoreType(dataStoreType)));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType in project controller by opendaylight.
the class ClusterAdminRpcService method removePrefixShardReplica.
@Override
public Future<RpcResult<Void>> removePrefixShardReplica(final RemovePrefixShardReplicaInput input) {
final InstanceIdentifier<?> identifier = input.getShardPrefix();
if (identifier == null) {
return newFailedRpcResultFuture("A valid shard identifier must be specified");
}
final DataStoreType dataStoreType = input.getDataStoreType();
if (dataStoreType == null) {
return newFailedRpcResultFuture("A valid DataStoreType must be specified");
}
final String memberName = input.getMemberName();
if (Strings.isNullOrEmpty(memberName)) {
return newFailedRpcResultFuture("A valid member name must be specified");
}
LOG.info("Removing replica for shard {} memberName {}, datastoreType {}", identifier, memberName, dataStoreType);
final YangInstanceIdentifier prefix = serializer.toYangInstanceIdentifier(identifier);
final SettableFuture<RpcResult<Void>> returnFuture = SettableFuture.create();
final ListenableFuture<Success> future = sendMessageToShardManager(dataStoreType, new RemovePrefixShardReplica(prefix, MemberName.forName(memberName)));
Futures.addCallback(future, new FutureCallback<Success>() {
@Override
public void onSuccess(final Success success) {
LOG.info("Successfully removed replica for shard {}", prefix);
returnFuture.set(newSuccessfulResult());
}
@Override
public void onFailure(final Throwable failure) {
onMessageFailure(String.format("Failed to remove replica for shard %s", prefix), returnFuture, failure);
}
}, MoreExecutors.directExecutor());
return returnFuture;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType in project netvirt by opendaylight.
the class ElanL2GatewayUtils method getRemoteUcastMacs.
/**
* Gets the remote ucast macs from hwvtep node filtering based on logical
* switch.
*
* @param hwvtepNodeId
* the hwvtep node id
* @param logicalSwitch
* the logical switch
* @param datastoreType
* the datastore type
* @return the remote ucast macs
*/
public List<MacAddress> getRemoteUcastMacs(NodeId hwvtepNodeId, String logicalSwitch, LogicalDatastoreType datastoreType) {
List<MacAddress> lstMacs = Collections.emptyList();
Node hwvtepNode = HwvtepUtils.getHwVtepNode(broker, datastoreType, hwvtepNodeId);
if (hwvtepNode != null) {
List<RemoteUcastMacs> remoteUcastMacs = hwvtepNode.getAugmentation(HwvtepGlobalAugmentation.class).getRemoteUcastMacs();
if (remoteUcastMacs != null && !remoteUcastMacs.isEmpty()) {
// Filtering remoteUcastMacs based on the logical switch and
// forming a list of MacAddress
lstMacs = remoteUcastMacs.stream().filter(mac -> logicalSwitch.equals(mac.getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue())).map(HwvtepMacTableGenericAttributes::getMacEntryKey).collect(Collectors.toList());
}
}
return lstMacs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType in project netvirt by opendaylight.
the class ElanUtils method getExternalTunnel.
/**
* Gets the external tunnel.
*
* @param interfaceName
* the interface name
* @param datastoreType
* the datastore type
* @return the external tunnel
*/
public ExternalTunnel getExternalTunnel(String interfaceName, LogicalDatastoreType datastoreType) {
ExternalTunnel externalTunnel = null;
List<ExternalTunnel> externalTunnels = getAllExternalTunnels(datastoreType);
for (ExternalTunnel tunnel : externalTunnels) {
if (StringUtils.equalsIgnoreCase(interfaceName, tunnel.getTunnelInterfaceName())) {
externalTunnel = tunnel;
break;
}
}
return externalTunnel;
}
Aggregations