use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.
the class SalRoleServiceImplTest method testSetRole.
@Test
public void testSetRole() throws Exception {
RoleRequestOutput roleRequestOutput = (new RoleRequestOutputBuilder()).setXid(testXid).setGenerationId(BigInteger.valueOf(1)).build();
ListenableFuture<RpcResult<RoleRequestOutput>> futureOutput = RpcResultBuilder.<RoleRequestOutput>success().withResult(roleRequestOutput).buildFuture();
Mockito.when(mockRequestContext.getFuture()).thenReturn(futureOutput);
SalRoleService salRoleService = new SalRoleServiceImpl(mockRequestContextStack, mockDeviceContext);
SetRoleInput setRoleInput = new SetRoleInputBuilder().setControllerRole(OfpRole.BECOMESLAVE).setNode(nodeRef).build();
Future<RpcResult<SetRoleOutput>> future = salRoleService.setRole(setRoleInput);
RpcResult<SetRoleOutput> roleOutputRpcResult = future.get(5, TimeUnit.SECONDS);
assertNotNull("RpcResult from future cannot be null.", roleOutputRpcResult);
assertTrue("RpcResult from future is not successful.", roleOutputRpcResult.isSuccessful());
SetRoleOutput setRoleOutput = roleOutputRpcResult.getResult();
assertNotNull(setRoleOutput);
assertEquals(BigInteger.valueOf(testXid), setRoleOutput.getTransactionId().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.
the class RoleContextImplTest method instantiateServiceInstance.
@Test
public void instantiateServiceInstance() throws Exception {
roleContext.instantiateServiceInstance();
verify(roleService).setRole(new SetRoleInputBuilder().setControllerRole(OfpRole.BECOMEMASTER).setNode(new NodeRef(deviceInfo.getNodeInstanceIdentifier())).build());
verify(contextChainMastershipWatcher).onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.MASTER_ON_DEVICE);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.
the class SalFlatBatchServiceImpl method prepareBatchChain.
@VisibleForTesting
List<BatchStepJob> prepareBatchChain(final List<BatchPlanStep> batchPlan, final NodeRef node, final boolean exitOnFirstError) {
// create batch API calls based on plan steps
final List<BatchStepJob> chainJobs = new ArrayList<>();
int stepOffset = 0;
for (final BatchPlanStep planStep : batchPlan) {
final int currentOffset = stepOffset;
chainJobs.add(new BatchStepJob(planStep, chainInput -> {
if (exitOnFirstError && !chainInput.isSuccessful()) {
LOG.debug("error on flat batch chain occurred -> skipping step {}", planStep.getStepType());
return FlatBatchUtil.createEmptyRpcBatchResultFuture(false);
}
LOG.trace("batch progressing on step type {}, previous steps result: {}", planStep.getStepType(), chainInput.isSuccessful());
return getChainOutput(node, planStep, currentOffset);
}));
stepOffset += planStep.getTaskBag().size();
}
return chainJobs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.
the class FlatBatchFlowAdapters method adaptFlatBatchAddFlow.
/**
* Adapt flat batch add flow.
* @param planStep batch step containing changes of the same type
* @param node pointer for RPC routing
* @return input suitable for {@link org.opendaylight.yang.gen.v1.urn
* .opendaylight.flows.service.rev160314.SalFlowsBatchService#addFlowsBatch(AddFlowsBatchInput)}
*/
public static AddFlowsBatchInput adaptFlatBatchAddFlow(final BatchPlanStep planStep, final NodeRef node) {
final List<BatchAddFlows> batchFlows = new ArrayList<>();
for (FlatBatchAddFlow batchAddFlows : planStep.<FlatBatchAddFlow>getTaskBag()) {
final BatchAddFlows addFlows = new BatchAddFlowsBuilder((Flow) batchAddFlows).setFlowId(batchAddFlows.getFlowId()).build();
batchFlows.add(addFlows);
}
return new AddFlowsBatchInputBuilder().setBarrierAfter(planStep.isBarrierAfter()).setNode(node).setBatchAddFlows(batchFlows).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.
the class FlatBatchFlowAdapters method adaptFlatBatchRemoveFlow.
/**
* Adapt flat batch remove flow.
* @param planStep batch step containing changes of the same type
* @param node pointer for RPC routing
* @return input suitable for {@link org.opendaylight.yang.gen.v1.urn
* .opendaylight.flows.service.rev160314.SalFlowsBatchService#removeFlowsBatch(RemoveFlowsBatchInput)}
*/
public static RemoveFlowsBatchInput adaptFlatBatchRemoveFlow(final BatchPlanStep planStep, final NodeRef node) {
final List<BatchRemoveFlows> batchFlows = new ArrayList<>();
for (FlatBatchRemoveFlow batchRemoveFlow : planStep.<FlatBatchRemoveFlow>getTaskBag()) {
final BatchRemoveFlows removeFlows = new BatchRemoveFlowsBuilder((Flow) batchRemoveFlow).setFlowId(batchRemoveFlow.getFlowId()).build();
batchFlows.add(removeFlows);
}
return new RemoveFlowsBatchInputBuilder().setBarrierAfter(planStep.isBarrierAfter()).setNode(node).setBatchRemoveFlows(batchFlows).build();
}
Aggregations