import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitAddLspInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitEnsureLspOperationalInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitRemoveLspInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitTriggerInitialSyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitTriggerInitialSyncInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitUpdateLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitUpdateLspInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.EnsureLspOperationalInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.NetworkTopologyPcepService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TriggerInitialSyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TriggerInitialSyncInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.programming.rev131030.PcepCreateP2pTunnelInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.programming.rev131030.PcepCreateP2pTunnelInputBuilder;
testAddLspRpce(consumerPcepService);
testEnsureLspRpce(consumerPcepService);
+ testTriggerInitialSyncRpce(consumerPcepService);
}
private void testAddLspRpce(final NetworkTopologyPcepService consumerPcepService) {
verify(pcepService2).addLsp(addLspInput);
}
+ private void testTriggerInitialSyncRpce(final NetworkTopologyPcepService consumerPcepService) {
+ TriggerInitialSyncInput triggerInput = getInputForRpc(topology, TriggerInitialSyncInputBuilder.class,
+ TriggerInitialSyncInput.class);
+ consumerPcepService.triggerInitialSync(triggerInput);
+
+ verify(pcepService1).triggerInitialSync(triggerInput);
+ verifyZeroInteractions(pcepService2);
+
+ triggerInput = getInputForRpc(topology2, TriggerInitialSyncInputBuilder.class, TriggerInitialSyncInput.class);
+
+ consumerPcepService.triggerInitialSync(triggerInput);
+
+ verifyZeroInteractions(pcepService1);
+ verify(pcepService2).triggerInitialSync(triggerInput);
+ }
+
private void testEnsureLspRpce(final NetworkTopologyPcepService consumerPcepService) {
EnsureLspOperationalInput ensureInput = getInputForRpc(topology, EnsureLspOperationalInputBuilder.class,
EnsureLspOperationalInput.class);
final ListenableFuture future = Futures.immediateFuture(RpcResultBuilder.<AddLspOutput>success().build());
when(pcepService.addLsp(Mockito.<AddLspInput>any())).thenReturn(future);
when(pcepService.removeLsp(Mockito.<RemoveLspInput>any())).thenReturn(future);
+ when(pcepService.triggerInitialSync(Mockito.<TriggerInitialSyncInput>any())).thenReturn(future);
when(pcepService.ensureLspOperational(Mockito.<EnsureLspOperationalInput>any())).thenReturn(future);
when(pcepService.updateLsp(Mockito.<UpdateLspInput>any())).thenReturn(future);
testSubmitAddLspRpc(consumerPcepService);
testSubmitUpdateLspRpc(consumerPcepService);
+ testTriggerInitialSyncRpc(consumerPcepService);
}
private void testSubmitAddLspRpc(final NetworkTopologyPcepProgrammingService consumerPcepService) {
verifyZeroInteractions(pcepService1);
verify(pcepService2).submitUpdateLsp(submitLspInput);
}
+
+ private void testTriggerInitialSyncRpc(final NetworkTopologyPcepProgrammingService consumerPcepService) {
+ SubmitTriggerInitialSyncInput submitTriggerInput = getInputForRpc(topology,
+ SubmitTriggerInitialSyncInputBuilder.class,
+ SubmitTriggerInitialSyncInput.class);
+ consumerPcepService.submitTriggerInitialSync(submitTriggerInput);
+
+ verify(pcepService1).submitTriggerInitialSync(submitTriggerInput);
+ verifyZeroInteractions(pcepService2);
+
+ submitTriggerInput = getInputForRpc(topology2, SubmitTriggerInitialSyncInputBuilder.class,
+ SubmitTriggerInitialSyncInput.class);
+
+ consumerPcepService.submitTriggerInitialSync(submitTriggerInput);
+
+ verifyZeroInteractions(pcepService1);
+ verify(pcepService2).submitTriggerInitialSync(submitTriggerInput);
+ }
};
broker.registerConsumer(consumer, getBundleContext());
}
final ListenableFuture future = Futures.immediateFuture(RpcResultBuilder.<AddLspOutput>success().build());
when(pcepService.submitAddLsp(Mockito.<SubmitAddLspInput>any())).thenReturn(future);
when(pcepService.submitRemoveLsp(Mockito.<SubmitRemoveLspInput>any())).thenReturn(future);
+ when(pcepService.submitTriggerInitialSync(Mockito.<SubmitTriggerInitialSyncInput>any())).thenReturn(future);
when(pcepService.submitEnsureLspOperational(Mockito.<SubmitEnsureLspOperationalInput>any())).thenReturn(future);
when(pcepService.submitUpdateLsp(Mockito.<SubmitUpdateLspInput>any())).thenReturn(future);
}
uses ntp:topology-instruction-output;
}
}
+
+ rpc submit-trigger-initial-sync {
+ input {
+ uses ntp:topology-instruction-input;
+ uses pcep:trigger-initial-sync-args;
+ }
+ output {
+ uses ntp:topology-instruction-output;
+ }
+ }
}
description
"Incremental state resynchronization is being performed.";
}
+ enum triggered-initial-sync {
+ description
+ "Triggered initial state resynchronization is being performed.";
+ }
enum synchronized {
description
"State synchronization has been achieved.";
uses operation-result;
}
}
+
+ grouping trigger-initial-sync-args {
+ leaf node {
+ type nt:node-ref;
+ mandatory true;
+ }
+ }
+
+ rpc trigger-initial-sync {
+ input {
+ uses ont:network-topology-reference;
+ uses trigger-initial-sync-args;
+ }
+ output {
+ uses operation-result;
+ }
+ }
}
return false;
}
+ protected final boolean isTriggeredInitialSynchro() {
+ if (syncOptimization != null) {
+ return syncOptimization.isTriggeredInitSyncEnabled();
+ }
+ return false;
+ }
+
protected final boolean isSynchronized() {
if (syncOptimization != null) {
return syncOptimization.doesLspDbMatch();
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspArgs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TopologyTypes1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TopologyTypes1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TriggerInitialSyncArgs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspArgs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.topology.pcep.type.TopologyPcepBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
return (l != null) ? l.ensureLspOperational(input) : OperationResults.UNSENT.future();
}
+ @Override
+ public synchronized ListenableFuture<OperationResult> triggerInitialSync(final TriggerInitialSyncArgs input) {
+ final TopologySessionListener l = checkSessionPresence(input.getNode());
+ return (l != null) ? l.triggerInitialSync(input) : OperationResults.UNSENT.future();
+ }
+
@Override
public void close() throws TransactionCommitFailedException {
if (this.runtimeRootRegistration.isPresent()) {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.symbolic.path.name.tlv.SymbolicPathNameBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.EroBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspArgs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.OperationResult;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.PccSyncState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspArgs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TriggerInitialSyncArgs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspArgs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.PathComputationClient;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.PathComputationClientBuilder;
pccBuilder.setReportedLsp(Collections.<ReportedLsp> emptyList());
if (isSynchronized()) {
pccBuilder.setStateSync(PccSyncState.Synchronized);
+ } else if (isTriggeredInitialSynchro()) {
+ pccBuilder.setStateSync(PccSyncState.TriggeredInitialSync);
} else if (isIncrementalSynchro()) {
pccBuilder.setStateSync(PccSyncState.IncrementalSync);
} else {
}
}
+ /**
+ * when PCE-triggered Initial State Synchronization Procedure is set during the session establishment, PCC will
+ * wait arrival of PCUpd message with PLSP-ID = 0 and SYNC = 1 in order to trigger the LSP-DB synchronization
+ * process.
+ * @param input
+ * @return
+ */
+ @Override
+ public synchronized ListenableFuture<OperationResult> triggerInitialSync(final TriggerInitialSyncArgs input) {
+ if(isTriggeredInitialSynchro() && !isSynchronized()) {
+ final PcupdMessageBuilder pcupdMessageBuilder = new PcupdMessageBuilder(MESSAGE_HEADER);
+ final SrpIdNumber srpIdNumber = createUpdateMessageSync(pcupdMessageBuilder);
+ final Message msg = new PcupdBuilder().setPcupdMessage(pcupdMessageBuilder.build()).build();
+ // Send the message
+ return sendMessage(msg, srpIdNumber, null);
+ }
+ return OperationResults.UNSENT.future();
+ }
+
+ private SrpIdNumber createUpdateMessageSync(final PcupdMessageBuilder pcupdMessageBuilder) {
+ final UpdatesBuilder updBuilder = new UpdatesBuilder();
+ // LSP mandatory in Upd
+ final Lsp lsp = new LspBuilder().setPlspId(new PlspId(0L)).setSync(Boolean.TRUE).build();
+ // SRP Mandatory in Upd
+ final SrpBuilder srpBuilder = new SrpBuilder();
+ // not sue wheter use 0 instead of nextRequest() or dont insert srp == SRP-ID-number = 0
+ srpBuilder.setOperationId(nextRequest());
+ final Srp srp = srpBuilder.build();
+ //ERO Mandatory in Upd
+ final PathBuilder pb = new PathBuilder();
+ pb.setEro(new EroBuilder().build());
+
+ updBuilder.setPath(pb.build());
+ updBuilder.setLsp(lsp).setSrp(srp).setPath(pb.build());
+
+ pcupdMessageBuilder.setUpdates(Collections.singletonList(updBuilder.build()));
+ return srp.getOperationId();
+ }
+
private boolean handleErrorMessage(final PcerrMessage message) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessage errMsg = message.getPcerrMessage();
if (errMsg.getErrorType() instanceof StatefulCase) {
private final boolean isSyncAvoidanceEnabled;
private final boolean isDeltaSyncEnabled;
private final boolean isDbVersionPresent;
+ private final boolean isTriggeredInitialSynEnable;
+ private final boolean isTriggeredReSynEnable;
public SyncOptimization(final PCEPSession session) {
Preconditions.checkNotNull(session);
this.isSyncAvoidanceEnabled = isSyncAvoidance(local) && isSyncAvoidance(remote);
this.isDeltaSyncEnabled = isDeltaSync(local) && isDeltaSync(remote);
this.isDbVersionPresent = localLspDbVersion != null || remoteLspDbVersion != null;
+ this.isTriggeredInitialSynEnable = isTriggeredInitialSync(local) && isTriggeredInitialSync(remote);
+ this.isTriggeredReSynEnable = isTriggeredReSync(local) && isTriggeredReSync(remote);
}
public boolean doesLspDbMatch() {
public boolean isDeltaSyncEnabled() {
return isDeltaSyncEnabled;
}
+ /**
+ * Returns
+ * @return isTriggeredInitialSynEnable
+ */
+ public boolean isTriggeredInitSyncEnabled() {
+ return isTriggeredInitialSynEnable;
+ }
public boolean isDbVersionPresent() {
return isDbVersionPresent;
return false;
}
+ private static boolean isTriggeredInitialSync(final Tlvs openTlvs) {
+ final Stateful1 stateful1 = getStateful1(openTlvs);
+ if (stateful1 != null && stateful1.isTriggeredInitialSync() != null) {
+ return stateful1.isTriggeredInitialSync();
+ }
+ return false;
+ }
+
+ private static boolean isTriggeredReSync(final Tlvs openTlvs) {
+ final Stateful1 stateful1 = getStateful1(openTlvs);
+ if (stateful1 != null && stateful1.isTriggeredResync() != null) {
+ return stateful1.isTriggeredResync();
+ }
+ return false;
+ }
}
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-
import org.opendaylight.bgpcep.pcep.topology.spi.AbstractInstructionExecutor;
import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
import org.opendaylight.bgpcep.programming.spi.SuccessfulRpcResult;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitRemoveLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitRemoveLspOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitRemoveLspOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitTriggerInitialSyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitTriggerInitialSyncOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitTriggerInitialSyncOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitUpdateLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitUpdateLspOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitUpdateLspOutputBuilder;
final RpcResult<SubmitEnsureLspOperationalOutput> res = SuccessfulRpcResult.create(b.build());
return Futures.immediateFuture(res);
}
+
+
+ @Override
+ public ListenableFuture<RpcResult<SubmitTriggerInitialSyncOutput>> submitTriggerInitialSync(final SubmitTriggerInitialSyncInput input) {
+ Preconditions.checkArgument(input.getNode() != null);
+
+ final SubmitTriggerInitialSyncOutputBuilder b = new SubmitTriggerInitialSyncOutputBuilder();
+ b.setResult(AbstractInstructionExecutor.schedule(scheduler, new AbstractInstructionExecutor(input) {
+ @Override
+ protected ListenableFuture<OperationResult> invokeOperation() {
+ return TopologyProgramming.this.manager.triggerInitialSync(input);
+ }
+ }));
+
+ final RpcResult<SubmitTriggerInitialSyncOutput> res = SuccessfulRpcResult.create(b.build());
+ return Futures.immediateFuture(res);
+ }
}
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
-
import java.util.concurrent.Future;
-
import org.opendaylight.bgpcep.programming.spi.SuccessfulRpcResult;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TriggerInitialSyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TriggerInitialSyncOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TriggerInitialSyncOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspOutputBuilder;
});
}
+ @Override
+ public Future<RpcResult<TriggerInitialSyncOutput>> triggerInitialSync(final TriggerInitialSyncInput input) {
+ return Futures.transform(manager.triggerInitialSync(input), new Function<OperationResult, RpcResult<TriggerInitialSyncOutput>>() {
+ @Override
+ public RpcResult<TriggerInitialSyncOutput> apply(final OperationResult input) {
+ return SuccessfulRpcResult.create(new TriggerInitialSyncOutputBuilder(input).build());
+ }
+ });
+ }
+
@Override
public Future<RpcResult<UpdateLspOutput>> updateLsp(final UpdateLspInput input) {
return Futures.transform(manager.updateLsp(input), new Function<OperationResult, RpcResult<UpdateLspOutput>>() {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.EnsureLspOperationalInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.OperationResult;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspArgs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TriggerInitialSyncArgs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspArgs;
interface TopologySessionRPCs {
ListenableFuture<OperationResult> updateLsp(UpdateLspArgs input);
ListenableFuture<OperationResult> ensureLspOperational(EnsureLspOperationalInput input);
+
+ ListenableFuture<OperationResult> triggerInitialSync(TriggerInitialSyncArgs input);
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.bgpcep.pcep.topology.provider;
+
+import static org.opendaylight.protocol.pcep.pcc.mock.MsgBuilderUtil.createLsp;
+import static org.opendaylight.protocol.pcep.pcc.mock.MsgBuilderUtil.createPath;
+
+import com.google.common.base.Optional;
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.concurrent.ExecutionException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.protocol.pcep.PCEPSession;
+import org.opendaylight.protocol.pcep.pcc.mock.MsgBuilderUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Tlvs3;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Tlvs3Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.lsp.db.version.tlv.LspDbVersion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.lsp.db.version.tlv.LspDbVersionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.OperationalStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Pcrpt;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.PlspId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.SymbolicPathName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.identifiers.tlv.LspIdentifiersBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.LspBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.stateful.capability.tlv.StatefulBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.symbolic.path.name.tlv.SymbolicPathNameBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.Node1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.PccSyncState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.PathComputationClient;
+
+public class PCETriggeredInitialSyncProcedureTest extends AbstractPCEPSessionTest<Stateful07TopologySessionListenerFactory> {
+ private Stateful07TopologySessionListener listener;
+
+ private PCEPSession session;
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ this.listener = (Stateful07TopologySessionListener) getSessionListener();
+ }
+
+ /**
+ * Test Triggered Initial Sync procedure
+ **/
+ @Test
+ public void testPcepTriggeredInitialSyncPerformed() throws InterruptedException, ExecutionException {
+ this.listener = (Stateful07TopologySessionListener) getSessionListener();
+
+ //session up - expect triggered sync (LSP-DBs do not match)
+ final LspDbVersion localDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(1l)).build();
+ final LspDbVersion localDbVersion2 = new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(2l)).build();
+ this.session = getPCEPSession(getOpen(localDbVersion, Boolean.FALSE), getOpen(localDbVersion2, Boolean.FALSE));
+ this.listener.onSessionUp(session);
+
+ final PathComputationClient pcc2 = getTopology().get().getNode().get(0).getAugmentation(Node1.class).getPathComputationClient();
+ //check node - not synchronized and TriggeredInitialSync state
+ Assert.assertEquals(PccSyncState.TriggeredInitialSync, pcc2.getStateSync());
+ //sync rpt + LSP-DB
+ final Pcrpt syncMsg = getsyncMsg();
+ this.listener.onMessage(session, syncMsg);
+ final PathComputationClient pcc3 = getTopology().get().getNode().get(0).getAugmentation(Node1.class).getPathComputationClient();
+ //check node - synchronized
+ Assert.assertEquals(PccSyncState.Synchronized, pcc3.getStateSync());
+ //check reported LSP is empty, LSP state from previous session was purged
+ Assert.assertTrue(pcc3.getReportedLsp().isEmpty());
+
+ //report LSP + LSP-DB version number
+ final Pcrpt pcRpt = getPcrpt();
+ this.listener.onMessage(session, pcRpt);
+ final PathComputationClient pcc = getTopology().get().getNode().get(0).getAugmentation(Node1.class).getPathComputationClient();
+ Assert.assertFalse(pcc.getReportedLsp().isEmpty());
+ }
+
+ private Open getOpen(final LspDbVersion dbVersion, final boolean incremental) {
+ return new OpenBuilder(super.getLocalPref()).setTlvs(new TlvsBuilder().addAugmentation(Tlvs1.class, new Tlvs1Builder().setStateful(new StatefulBuilder()
+ .addAugmentation(Stateful1.class, new Stateful1Builder().setInitiation(Boolean.TRUE).build())
+ .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync
+ .optimizations.rev150714.Stateful1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params
+ .xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1Builder().setIncludeDbVersion
+ (Boolean.TRUE).setTriggeredInitialSync(Boolean.TRUE).setDeltaLspSyncCapability(incremental).build())
+ .build()).build()).addAugmentation(Tlvs3.class, new Tlvs3Builder().setLspDbVersion(dbVersion).build()).build()).build();
+ }
+
+ private Pcrpt getsyncMsg() {
+ return MsgBuilderUtil.createPcRtpMessage(createLsp(0, false, Optional.of(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp
+ .object.lsp.TlvsBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params
+ .xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Tlvs1.class, new org.opendaylight
+ .yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714
+ .Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger
+ .valueOf(2l)).build()).build()).build()), true, false), Optional.<Srp>absent(),
+ createPath(Collections.<Subobject>emptyList()));
+ }
+
+ private Pcrpt getPcrpt() {
+ return MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setPlspId(new PlspId(1l)).setTlvs(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp
+ .object.lsp.TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setLspId(new LspId(1l)).build
+ ()).setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(new SymbolicPathName("test"
+ .getBytes())).build()).addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
+ .yang.controller.pcep.sync.optimizations.rev150714.Tlvs1.class, new org.opendaylight.yang.gen.v1
+ .urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Tlvs1Builder()
+ .setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(3l)).build())
+ .build()).build()).setPlspId(new PlspId(1L)).setSync(true).setRemove(false).setOperational
+ (OperationalStatus.Active).build(), Optional.<Srp>absent(), createPath(Collections.<Subobject>emptyList()));
+ }
+}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitAddLspInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitEnsureLspOperationalInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitRemoveLspInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitTriggerInitialSyncInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.SubmitUpdateLspInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspArgs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspArgs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TriggerInitialSyncArgs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TriggerInitialSyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.TriggerInitialSyncOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspArgs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspOutput;
private AddLspArgs addLspArgs;
private UpdateLspArgs updateLspArgs;
private RemoveLspArgs removeLspArgs;
+ private TriggerInitialSyncArgs triggerInitialSyncArgs;
private EnsureLspOperationalInput ensureLspInput;
@Mock
@Mock
private ListenableFuture<RpcResult<RemoveLspOutput>> futureRemoveLspOutput;
@Mock
+ private ListenableFuture<RpcResult<TriggerInitialSyncOutput>> futureTriggerInitialSyncOutput;
+ @Mock
private ListenableFuture<RpcResult<EnsureLspOperationalOutput>> futureEnsureLspOutput;
private TopologyProgramming topologyProgramming;
return null;
}
}).when(this.futureRemoveLspOutput).addListener(Mockito.any(Runnable.class), Mockito.any(Executor.class));
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(final InvocationOnMock invocation) throws Throwable {
+ final Runnable callback = (Runnable) invocation.getArguments()[0];
+ callback.run();
+ return null;
+ }
+ }).when(this.futureTriggerInitialSyncOutput).addListener(Mockito.any(Runnable.class), Mockito.any(Executor.class));
Mockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(final InvocationOnMock invocation) throws Throwable {
return TopologyProgrammingTest.this.futureRemoveLspOutput;
}
}).when(listener).removeLsp(Mockito.any(RemoveLspInput.class));
+ Mockito.doAnswer(new Answer<Future<RpcResult<TriggerInitialSyncOutput>>>() {
+ @Override
+ public Future<RpcResult<TriggerInitialSyncOutput>> answer(final InvocationOnMock invocation) throws Throwable {
+ TopologyProgrammingTest.this.triggerInitialSyncArgs = (TriggerInitialSyncArgs) invocation.getArguments()[0];
+ return TopologyProgrammingTest.this.futureTriggerInitialSyncOutput;
+ }
+ }).when(listener).triggerInitialSync(Mockito.any(TriggerInitialSyncInput.class));
Mockito.doAnswer(new Answer<Future<RpcResult<EnsureLspOperationalOutput>>>() {
@Override
public Future<RpcResult<EnsureLspOperationalOutput>> answer(final InvocationOnMock invocation) throws Throwable {
Assert.assertEquals(NODE_ID, this.removeLspArgs.getNode());
}
+ @Test
+ public void testSubmitTriggerInitialSync() {
+ final SubmitTriggerInitialSyncInputBuilder inputBuilder = new SubmitTriggerInitialSyncInputBuilder();
+ inputBuilder.setNode(NODE_ID);
+ this.topologyProgramming.submitTriggerInitialSync(inputBuilder.build());
+ Assert.assertNotNull(this.triggerInitialSyncArgs);
+ Assert.assertEquals(NODE_ID, this.triggerInitialSyncArgs.getNode());
+ }
+
protected static final class MockedTopologySessionListenerFactory implements TopologySessionListenerFactory {
@Override
public TopologySessionListener createTopologySessionListener(final ServerSessionManager manager) {