use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.
the class PCETriggeredInitialSyncProcedureTest method testPcepTriggeredInitialSyncPerformed.
/**
* Test Triggered Initial Sync procedure.
*/
@Test
public void testPcepTriggeredInitialSyncPerformed() throws Exception {
this.listener = (Stateful07TopologySessionListener) getSessionListener();
// session up - expect triggered sync (LSP-DBs do not match)
final LspDbVersion localDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.ONE).build();
final LspDbVersion localDbVersion2 = new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(2L)).build();
final PCEPSession session = getPCEPSession(getOpen(localDbVersion, Boolean.FALSE), getOpen(localDbVersion2, Boolean.FALSE));
this.listener.onSessionUp(session);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check node - not synchronized and TriggeredInitialSync state
assertEquals(PccSyncState.TriggeredInitialSync, pcc.getStateSync());
return pcc;
});
// sync rpt + LSP-DB
final Pcrpt syncMsg = getsyncMsg();
this.listener.onMessage(session, syncMsg);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check node - synchronized
assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
// check reported LSP is empty, LSP state from previous session was purged
assertTrue(pcc.getReportedLsp().isEmpty());
return pcc;
});
// report LSP + LSP-DB version number
final Pcrpt pcRpt = getPcrpt();
this.listener.onMessage(session, pcRpt);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
assertFalse(pcc.getReportedLsp().isEmpty());
return pcc;
});
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.
the class StateSynchronizationAvoidanceProcedureTest method testStateSynchronizationPerformed.
@Test
public void testStateSynchronizationPerformed() throws Exception {
PCEPSession session = getPCEPSession(getOpen(null), getOpen(null));
this.listener.onSessionUp(session);
// report LSP + LSP-DB version number
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setPlspId(new PlspId(1L)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.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.rev171025.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.ONE).build()).build()).build()).setPlspId(new PlspId(1L)).setSync(true).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.absent(), createPath(Collections.emptyList()));
this.listener.onMessage(session, pcRpt);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
assertFalse(pcc.getReportedLsp().isEmpty());
return pcc;
});
this.listener.onSessionDown(session, new IllegalArgumentException("Simulate Exception"));
this.listener = (Stateful07TopologySessionListener) getSessionListener();
// session up - expect sync (LSP-DBs do not match)
final LspDbVersion localDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(2L)).build();
session = getPCEPSession(getOpen(localDbVersion), getOpen(null));
this.listener.onSessionUp(session);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check node - not synchronized
assertEquals(PccSyncState.InitialResync, pcc.getStateSync());
// check reported LSP - persisted from previous session
assertFalse(pcc.getReportedLsp().isEmpty());
return pcc;
});
// sync rpt + LSP-DB
final Pcrpt syncMsg = MsgBuilderUtil.createPcRtpMessage(createLsp(0, false, Optional.of(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(2L)).build()).build()).build()), true, false), Optional.absent(), createPath(Collections.emptyList()));
this.listener.onMessage(session, syncMsg);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check node - synchronized
assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
// check reported LSP is empty, LSP state from previous session was purged
assertTrue(pcc.getReportedLsp().isEmpty());
return pcc;
});
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.
the class AbstractTopologySessionListener method updatePccState.
synchronized void updatePccState(final PccSyncState pccSyncState) {
if (this.nodeState == null) {
LOG.info("Server Session Manager is closed.");
AbstractTopologySessionListener.this.session.close(TerminationReason.UNKNOWN);
return;
}
final MessageContext ctx = new MessageContext(this.nodeState.getChain().newWriteOnlyTransaction());
updatePccNode(ctx, new PathComputationClientBuilder().setStateSync(pccSyncState).build());
if (pccSyncState != PccSyncState.Synchronized) {
this.synced.set(false);
this.triggeredResyncInProcess = true;
}
// All set, commit the modifications
Futures.addCallback(ctx.trans.submit(), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
LOG.trace("Pcc Internal state for session {} updated successfully", AbstractTopologySessionListener.this.session);
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Failed to update Pcc internal state for session {}", AbstractTopologySessionListener.this.session, throwable);
AbstractTopologySessionListener.this.session.close(TerminationReason.UNKNOWN);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.
the class AbstractTopologySessionListener method onSessionUp.
@Override
public final synchronized void onSessionUp(final PCEPSession psession) {
/*
* The session went up. Look up the router in Inventory model,
* create it if it is not there (marking that fact for later
* deletion), and mark it as synchronizing. Also create it in
* the topology model, with empty LSP list.
*/
final InetAddress peerAddress = psession.getRemoteAddress();
this.syncOptimization = new SyncOptimization(psession);
final TopologyNodeState state = this.serverSessionManager.takeNodeState(peerAddress, this, isLspDbRetreived());
// takeNodeState(..) may fail when the server session manager is being restarted due to configuration change
if (state == null) {
LOG.error("Unable to fetch topology node state for PCEP session. Closing session {}", psession);
psession.close(TerminationReason.UNKNOWN);
this.onSessionTerminated(psession, new PCEPCloseTermination(TerminationReason.UNKNOWN));
return;
}
if (this.session != null || this.nodeState != null) {
LOG.error("PCEP session is already up with {}. Closing session {}", psession.getRemoteAddress(), psession);
psession.close(TerminationReason.UNKNOWN);
this.onSessionTerminated(psession, new PCEPCloseTermination(TerminationReason.UNKNOWN));
return;
}
this.session = psession;
this.nodeState = state;
this.serverSessionManager.bind(this.nodeState.getNodeId(), this.listenerState);
LOG.trace("Peer {} resolved to topology node {}", peerAddress, state.getNodeId());
// Our augmentation in the topology node
final PathComputationClientBuilder pccBuilder = new PathComputationClientBuilder();
onSessionUp(psession, pccBuilder);
this.synced.set(isSynchronized());
pccBuilder.setIpAddress(IpAddressBuilder.getDefaultInstance(peerAddress.getHostAddress()));
final InstanceIdentifier<Node1> topologyAugment = state.getNodeId().augmentation(Node1.class);
this.pccIdentifier = topologyAugment.child(PathComputationClient.class);
final Node initialNodeState = state.getInitialNodeState();
final boolean isNodePresent = isLspDbRetreived() && initialNodeState != null;
if (isNodePresent) {
loadLspData(initialNodeState, this.lspData, this.lsps, isIncrementalSynchro());
pccBuilder.setReportedLsp(initialNodeState.getAugmentation(Node1.class).getPathComputationClient().getReportedLsp());
}
state.storeNode(topologyAugment, new Node1Builder().setPathComputationClient(pccBuilder.build()).build(), this.session);
this.listenerState.init(psession);
LOG.info("Session with {} attached to topology node {}", psession.getRemoteAddress(), state.getNodeId());
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.
the class Stateful07TopologySessionListener method ensureLspOperational.
@Override
public synchronized ListenableFuture<OperationResult> ensureLspOperational(@Nonnull final EnsureLspOperationalInput input) {
Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null && input.getArguments() != null, MISSING_XML_TAG);
final OperationalStatus op;
final Arguments1 aa = input.getArguments().getAugmentation(Arguments1.class);
if (aa != null) {
op = aa.getOperational();
} else {
op = null;
}
// Make sure the LSP exists
final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName());
LOG.debug("Checking if LSP {} has operational state {}", lsp, op);
final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
if (f == null) {
return OperationResults.createUnsent(PCEPErrors.LSP_INTERNAL_ERROR).future();
}
return listenableFuture(f, input, op);
}
Aggregations