use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityType in project genius by opendaylight.
the class SrmRpcUtils method callSrmOp.
public static RecoverOutput callSrmOp(DataBroker broker, RecoverInput input) {
RecoverOutputBuilder outputBuilder = new RecoverOutputBuilder();
if (input.getEntityName() == null) {
outputBuilder.setResponse(RpcFailEntityName.class).setMessage("EntityName is null");
return outputBuilder.build();
}
if (input.getEntityType() == null) {
outputBuilder.setResponse(RpcFailEntityType.class).setMessage(String.format("EntityType for %s can't be null", input.getEntityName().getSimpleName()));
return outputBuilder.build();
}
String entityId;
if (EntityTypeInstance.class.equals(input.getEntityType()) && input.getEntityId() == null) {
outputBuilder.setResponse(RpcFailEntityId.class).setMessage(String.format("EntityId can't be null for %s", input.getEntityName().getSimpleName()));
return outputBuilder.build();
} else {
entityId = input.getEntityId();
}
Class<? extends EntityNameBase> serviceName = NAME_TO_SERVICE_MAP.get(input.getEntityName());
if (serviceName == null) {
outputBuilder.setResponse(RpcFailEntityName.class).setMessage(String.format("EntityName %s has no matching service", input.getEntityName().getSimpleName()));
return outputBuilder.build();
}
Class<? extends EntityTypeBase> entityType = NAME_TO_TYPE_MAP.get(input.getEntityName());
if (entityType == null || !input.getEntityType().equals(entityType)) {
outputBuilder.setResponse(RpcFailEntityType.class).setMessage(String.format("EntityName %s doesn't match with EntityType %s", input.getEntityName().getSimpleName(), entityType));
return outputBuilder.build();
}
OperationsBuilder opsBuilder = new OperationsBuilder().setEntityName(input.getEntityName()).setEntityType(entityType).setTriggerOperation(ServiceOpRecover.class);
if (entityId != null) {
opsBuilder.setEntityId(entityId);
}
Operations operation = opsBuilder.build();
InstanceIdentifier<Operations> opsIid = getInstanceIdentifier(operation, serviceName);
WriteTransaction tx = broker.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.OPERATIONAL, opsIid, operation, CREATE_MISSING_PARENT);
try {
tx.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error writing RecoveryOp to datastore. path:{}, data:{}", opsIid, operation);
outputBuilder.setResponse(RpcFailUnknown.class).setMessage(e.getMessage());
return outputBuilder.build();
}
outputBuilder.setResponse(RpcSuccess.class).setMessage("Recovery operation successfully triggered");
return outputBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityType in project genius by opendaylight.
the class NodeConnectorStatsImpl method getCounter.
/*
* This method returns counter and also creates counter if does not exist.
*
* @param counterName name of the counter
* @param switchId datapath-id value
* @param port port-id value
* @param aliasId alias-id value
* @param tableId table-id value of switch
* @return counter object
*/
private Counter getCounter(String counterName, BigInteger switchId, String port, String aliasId, String tableId) {
/*
* Pattern to be followed for key generation:
*
* genius.interfacemanager.entitycounter{entitytype=port,switchid=value,portid=value,aliasid=value,
* name=counterName}
* genius.interfacemanager.entitycounter{entitytype=flowtable,switchid=value,flowtableid=value,name=counterName}
*/
Counter counter = null;
if (port != null) {
Labeled<Labeled<Labeled<Labeled<Labeled<Counter>>>>> labeledCounter = metricProvider.newCounter(MetricDescriptor.builder().anchor(this).project("genius").module("interfacemanager").id(CounterConstants.CNT_TYPE_ENTITY_CNT_ID).build(), CounterConstants.LBL_KEY_ENTITY_TYPE, CounterConstants.LBL_KEY_SWITCHID, CounterConstants.LBL_KEY_PORTID, CounterConstants.LBL_KEY_ALIASID, CounterConstants.LBL_KEY_COUNTER_NAME);
counter = labeledCounter.label(CounterConstants.LBL_VAL_ENTITY_TYPE_PORT).label(switchId.toString()).label(port).label(aliasId).label(counterName);
}
if (tableId != null) {
Labeled<Labeled<Labeled<Labeled<Counter>>>> labeledCounter = metricProvider.newCounter(MetricDescriptor.builder().anchor(this).project("genius").module("interfacemanager").id(CounterConstants.CNT_TYPE_ENTITY_CNT_ID).build(), CounterConstants.LBL_KEY_ENTITY_TYPE, CounterConstants.LBL_KEY_SWITCHID, CounterConstants.LBL_KEY_FLOWTBLID, CounterConstants.LBL_KEY_COUNTER_NAME);
counter = labeledCounter.label(CounterConstants.LBL_VAL_ENTITY_TYPE_FLOWTBL).label(switchId.toString()).label(tableId).label(counterName);
}
// create counters set for node if absent.
// and then populate counter set with counter object
// which will be needed to close counters when node is removed.
metricsCountersPerNodeMap.computeIfAbsent(switchId, counterSet -> ConcurrentHashMap.newKeySet()).add(counter);
return counter;
}
Aggregations