Search in sources :

Example 36 with NodeRef

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());
}
Also used : RoleRequestOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput) RoleRequestOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder) SetRoleInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleInputBuilder) SetRoleOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) SetRoleInput(org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleInput) SalRoleService(org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SalRoleService) Test(org.junit.Test)

Example 37 with NodeRef

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);
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) SetRoleInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleInputBuilder) Test(org.junit.Test)

Example 38 with NodeRef

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;
}
Also used : BatchStepJob(org.opendaylight.openflowplugin.impl.services.batch.BatchStepJob) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AddFlowsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInput) ProcessFlatBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchInput) UpdateMetersBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.UpdateMetersBatchInput) AddGroupsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.AddGroupsBatchInput) LoggerFactory(org.slf4j.LoggerFactory) SalFlatBatchService(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService) SalFlowsBatchService(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.SalFlowsBatchService) FlatBatchGroupAdapters(org.opendaylight.openflowplugin.impl.services.batch.FlatBatchGroupAdapters) AddMetersBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.AddMetersBatchOutput) ArrayList(java.util.ArrayList) RemoveGroupsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.RemoveGroupsBatchInput) FlatBatchUtil(org.opendaylight.openflowplugin.impl.util.FlatBatchUtil) RemoveGroupsBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.RemoveGroupsBatchOutput) Future(java.util.concurrent.Future) BatchStepJob(org.opendaylight.openflowplugin.impl.services.batch.BatchStepJob) AddGroupsBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.AddGroupsBatchOutput) SalMetersBatchService(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.SalMetersBatchService) SalFlowService(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService) UpdateGroupsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInput) UpdateMetersBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.UpdateMetersBatchOutput) AddFlowsBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchOutput) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) RemoveFlowsBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.RemoveFlowsBatchOutput) Logger(org.slf4j.Logger) UpdateFlowsBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchOutput) AddMetersBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.AddMetersBatchInput) RemoveFlowsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.RemoveFlowsBatchInput) SalGroupsBatchService(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.SalGroupsBatchService) FlatBatchMeterAdapters(org.opendaylight.openflowplugin.impl.services.batch.FlatBatchMeterAdapters) ProcessFlatBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput) BatchPlanStep(org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) PathUtil(org.opendaylight.openflowplugin.impl.util.PathUtil) UpdateFlowsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchInput) RemoveMetersBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInput) Preconditions(com.google.common.base.Preconditions) UpdateGroupsBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchOutput) VisibleForTesting(com.google.common.annotations.VisibleForTesting) RemoveMetersBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchOutput) FlatBatchFlowAdapters(org.opendaylight.openflowplugin.impl.services.batch.FlatBatchFlowAdapters) ArrayList(java.util.ArrayList) BatchPlanStep(org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 39 with NodeRef

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();
}
Also used : AddFlowsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInputBuilder) BatchAddFlows(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.add.flows.batch.input.BatchAddFlows) ArrayList(java.util.ArrayList) FlatBatchAddFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow) BatchAddFlowsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.add.flows.batch.input.BatchAddFlowsBuilder)

Example 40 with NodeRef

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();
}
Also used : FlatBatchRemoveFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlow) BatchRemoveFlowsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.remove.flows.batch.input.BatchRemoveFlowsBuilder) RemoveFlowsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.RemoveFlowsBatchInputBuilder) ArrayList(java.util.ArrayList) BatchRemoveFlows(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.remove.flows.batch.input.BatchRemoveFlows)

Aggregations

NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)69 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)30 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)29 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)27 ArrayList (java.util.ArrayList)23 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)18 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)17 Test (org.junit.Test)16 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)14 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)14 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)12 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)12 TransmitPacketInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder)12 BigInteger (java.math.BigInteger)11 TransmitPacketInput (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput)11 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)10 FlowRef (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef)8 GroupRef (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef)8 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)8 AddFlowInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder)7