use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project genius by opendaylight.
the class IdManager method getIdBlockFromParentPool.
/**
* Changes made to availableIds and releasedIds will not be persisted to the datastore.
*/
private long getIdBlockFromParentPool(String parentPoolName, IdLocalPool localIdPool) throws OperationFailedException, IdManagerException {
if (LOG.isDebugEnabled()) {
LOG.debug("Allocating block of id from parent pool {}", parentPoolName);
}
InstanceIdentifier<IdPool> idPoolInstanceIdentifier = idUtils.getIdPoolInstance(parentPoolName);
parentPoolName = parentPoolName.intern();
idUtils.lock(lockManager, parentPoolName);
long idCount = 0;
try {
// Check if the childpool already got id block.
long availableIdCount = localIdPool.getAvailableIds().getAvailableIdCount() + localIdPool.getReleasedIds().getAvailableIdCount();
if (availableIdCount > 0) {
return availableIdCount;
}
WriteTransaction tx = broker.newWriteOnlyTransaction();
IdPool parentIdPool = singleTxDB.syncRead(CONFIGURATION, idPoolInstanceIdentifier);
idCount = allocateIdBlockFromParentPool(localIdPool, parentIdPool, tx);
tx.submit().checkedGet();
} catch (IdManagerException | NullPointerException e) {
LOG.error("Error getting id block from parent pool", e);
} finally {
idUtils.unlock(lockManager, parentPoolName);
}
return idCount;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project genius by opendaylight.
the class SrmRpcUtils method callSrmOp.
public static ReinstallOutput callSrmOp(DataBroker broker, ReinstallInput input) {
ReinstallOutputBuilder outputBuilder = new ReinstallOutputBuilder();
if (input.getEntityName() == null) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage("EntityName is null");
return outputBuilder.build();
}
if (input.getEntityType() == null) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityType for %s can't be null", input.getEntityName().getSimpleName()));
return outputBuilder.build();
}
if (!EntityTypeService.class.equals(input.getEntityType())) {
outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityType is %s, Reinstall is only for EntityTypeService", input.getEntityType()));
return outputBuilder.build();
}
Class<? extends EntityNameBase> serviceName = NAME_TO_SERVICE_MAP.get(input.getEntityName());
if (serviceName == null) {
outputBuilder.setSuccessful(REINSTALL_FAILED).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.setSuccessful(REINSTALL_FAILED).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(ServiceOpReinstall.class);
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.setSuccessful(REINSTALL_FAILED).setMessage(e.getMessage());
return outputBuilder.build();
}
outputBuilder.setSuccessful(REINSTALL_SUCCESS).setMessage("Recovery operation successfully triggered");
return outputBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project genius by opendaylight.
the class ReinstallCommand method doExecute.
@Override
protected Object doExecute() throws Exception {
ReinstallInput input = getInput();
if (input == null) {
// We've already shown the relevant error msg
return null;
}
Future<RpcResult<ReinstallOutput>> result = srmRpcService.reinstall(input);
RpcResult<ReinstallOutput> reinstallResult = result.get();
printResult(reinstallResult);
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project genius by opendaylight.
the class DataTreeEventCallbackRegistrarTest method testExceptionInCallbackMustBeLogged.
@Test
public void testExceptionInCallbackMustBeLogged() throws TransactionCommitFailedException, InterruptedException {
logCaptureRule.expectLastErrorMessageContains("TestConsumer");
AtomicBoolean added = new AtomicBoolean(false);
DataTreeEventCallbackRegistrar dataTreeEventCallbackRegistrar = new DataTreeEventCallbackRegistrarImpl(db);
dataTreeEventCallbackRegistrar.onAdd(OPERATIONAL, FOO_PATH, new Function<TopLevelList, NextAction>() {
@Override
public NextAction apply(TopLevelList topLevelList) {
added.set(true);
throw new IllegalStateException("TEST");
}
@Override
public String toString() {
return "TestConsumer";
}
});
db1.syncWrite(OPERATIONAL, FOO_PATH, FOO_DATA);
await().untilTrue(added);
// TODO see above we can remove this once we can await DataBroker listeners
// The sleep () is required :( so that the throw new IllegalStateException really leads to an ERROR log,
// because the (easily) await().untilTrue(...) could theoretically complete immediately after added.set(true)
// but before the throw new IllegalStateException("TEST") and LOG. To make this more reliable and without sleep
// would require more work inside DataBroker to be able to await listener event processing.
Thread.sleep(100);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project bgpcep by opendaylight.
the class PCEPErrorMessageParser method insertObject.
private static State insertObject(final State state, final List<Errors> errorObjects, final Object obj, final List<Rps> requestParameters, final PcerrMessageBuilder b) {
switch(state) {
case RP_IN:
if (obj instanceof Rp) {
final Rp o = (Rp) obj;
requestParameters.add(new RpsBuilder().setRp(o).build());
return State.RP_IN;
}
case ERROR_IN:
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
return State.ERROR_IN;
}
case OPEN:
if (obj instanceof Open) {
b.setErrorType(new SessionCaseBuilder().setSession(new SessionBuilder().setOpen((Open) obj).build()).build());
return State.OPEN_IN;
}
case ERROR:
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
return State.ERROR;
}
case OPEN_IN:
case END:
return State.END;
default:
return state;
}
}
Aggregations