use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class AppPeerBenchmark method start.
public void start() {
LOG.debug("Instantiating App Peer Benchmark : {}", this.appRibId);
final ApplicationRib appRib = new ApplicationRibBuilder().setId(new ApplicationRibId(new ApplicationRibId(this.appRibId))).setTables(EMPTY_TABLES).build();
final WriteTransaction wTx = this.txChain.newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.CONFIGURATION, this.appIID, appRib);
wTx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.info("Empty Structure created for Application Peer Benchmark {}", AppPeerBenchmark.this.appRibId);
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Failed to create Empty Structure for Application Peer Benchmark {}", AppPeerBenchmark.this.appRibId, throwable);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class PeerGroupStateCliUtilsTest method testEmptyPeerGroupStateCli.
@Test
public void testEmptyPeerGroupStateCli() throws IOException {
final PeerGroupBuilder peerGroup = new PeerGroupBuilder().setPeerGroupName(TEST_GROUP);
PeerGroupStateCliUtils.displayPeerOperationalState(Collections.singletonList(peerGroup.build()), this.stream);
final String expected = Resources.toString(getClass().getClassLoader().getResource("empty-peer-group.txt"), StandardCharsets.UTF_8);
assertEquals(expected, this.output.toString());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class StrictBGPPeerRegistry method getPeer.
@Override
public synchronized BGPSessionListener getPeer(final IpAddressNoZone ip, final Ipv4AddressNoZone sourceId, final Ipv4AddressNoZone remoteId, final Open openObj) throws BGPDocumentedException {
requireNonNull(ip);
requireNonNull(sourceId);
requireNonNull(remoteId);
final AsNumber remoteAsNumber = AsNumberUtil.advertizedAsNumber(openObj);
requireNonNull(remoteAsNumber);
final BGPSessionPreferences prefs = getPeerPreferences(ip);
checkPeerConfigured(ip);
final BGPSessionId currentConnection = new BGPSessionId(sourceId, remoteId, remoteAsNumber);
final BGPSessionListener p = this.peers.get(ip);
final BGPSessionId previousConnection = this.sessionIds.get(ip);
if (previousConnection != null) {
LOG.warn("Duplicate BGP session established with {}", ip);
// Session reestablished with different ids
if (!previousConnection.equals(currentConnection)) {
LOG.warn("BGP session with {} {} has to be dropped. Same session already present {}", ip, currentConnection, previousConnection);
throw new BGPDocumentedException(String.format("BGP session with %s %s has to be dropped. Same session already present %s", ip, currentConnection, previousConnection), BGPError.CEASE);
// Session reestablished with lower source bgp id, dropping current
} else if (previousConnection.isHigherDirection(currentConnection) || previousConnection.hasHigherAsNumber(currentConnection)) {
LOG.warn("BGP session with {} {} has to be dropped. Opposite session already present", ip, currentConnection);
throw new BGPDocumentedException(String.format("BGP session with %s initiated %s has to be dropped. " + "Opposite session already present", ip, currentConnection), BGPError.CEASE);
// Session reestablished with higher source bgp id, dropping previous
} else if (currentConnection.isHigherDirection(previousConnection) || currentConnection.hasHigherAsNumber(previousConnection)) {
LOG.warn("BGP session with {} {} released. Replaced by opposite session", ip, previousConnection);
this.peers.get(ip).releaseConnection();
return this.peers.get(ip);
// Session reestablished with same source bgp id, dropping current as duplicate
} else {
LOG.warn("BGP session with {} initiated from {} to {} has to be dropped. Same session already present", ip, sourceId, remoteId);
throw new BGPDocumentedException(String.format("BGP session with %s initiated %s has to be dropped. " + "Same session already present", ip, currentConnection), BGPError.CEASE);
}
}
validateAs(remoteAsNumber, openObj, prefs);
// Map session id to peer IP address
this.sessionIds.put(ip, currentConnection);
for (final PeerRegistrySessionListener peerRegistrySessionListener : this.sessionListeners) {
peerRegistrySessionListener.onSessionCreated(ip);
}
return p;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class AbstractBGPSessionNegotiator method startNegotiation.
@SuppressWarnings("checkstyle:illegalCatch")
private synchronized void startNegotiation() {
LOG.debug("Starting negotiating with {}, current state: {}", channel.remoteAddress(), state);
if (!(this.state == State.IDLE || this.state == State.OPEN_CONFIRM)) {
return;
}
// Open can be sent first either from ODL (IDLE) or from peer (OPEN_CONFIRM)
final IpAddressNoZone remoteIp = getRemoteIp();
try {
// Check if peer is configured in registry before retrieving preferences
if (!this.registry.isPeerConfigured(remoteIp)) {
final BGPDocumentedException cause = new BGPDocumentedException(String.format("BGP peer with ip: %s not configured, check configured peers in : %s", remoteIp, this.registry), BGPError.CONNECTION_REJECTED);
negotiationFailed(cause);
return;
}
final BGPSessionPreferences preferences = this.registry.getPeerPreferences(remoteIp);
final Uint16 as = openASNumber(preferences.getMyAs().getValue().longValue());
sendMessage(new OpenBuilder().setMyAsNumber(as).setHoldTimer(Uint16.valueOf(preferences.getHoldTime())).setBgpIdentifier(preferences.getBgpId()).setBgpParameters(preferences.getParams()).build());
if (this.state != State.FINISHED) {
this.state = State.OPEN_SENT;
this.pending = this.channel.eventLoop().schedule(() -> {
synchronized (AbstractBGPSessionNegotiator.this) {
AbstractBGPSessionNegotiator.this.pending = null;
if (AbstractBGPSessionNegotiator.this.state != State.FINISHED) {
AbstractBGPSessionNegotiator.this.sendMessage(buildErrorNotify(BGPError.HOLD_TIMER_EXPIRED));
negotiationFailed(new BGPDocumentedException("HoldTimer expired", BGPError.FSM_ERROR));
AbstractBGPSessionNegotiator.this.state = State.FINISHED;
}
}
}, INITIAL_HOLDTIMER, TimeUnit.MINUTES);
}
} catch (final Exception e) {
LOG.warn("Unexpected negotiation failure", e);
negotiationFailedCloseChannel(e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class AdjRibInWriter method transform.
AdjRibInWriter transform(final PeerId newPeerId, final YangInstanceIdentifier peerPath, final RIBSupportContextRegistry registry, final Set<TablesKey> tableTypes, final Map<TablesKey, SendReceive> addPathTablesType, @Nullable final RegisterAppPeerListener registerAppPeerListener) {
final DOMDataTreeWriteTransaction tx = this.chain.getDomChain().newWriteOnlyTransaction();
createEmptyPeerStructure(newPeerId, peerPath, tx);
final ImmutableMap<TablesKey, TableContext> tb = createNewTableInstances(peerPath, registry, tableTypes, addPathTablesType, tx);
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
if (registerAppPeerListener != null) {
LOG.trace("Application Peer Listener registered");
registerAppPeerListener.register();
}
}
@Override
public void onFailure(final Throwable throwable) {
if (registerAppPeerListener != null) {
LOG.error("Failed to create Empty Structure, Application Peer Listener won't be registered", throwable);
} else {
LOG.error("Failed to create Empty Structure", throwable);
}
}
}, MoreExecutors.directExecutor());
return new AdjRibInWriter(this.ribPath, this.chain, this.role, tb);
}
Aggregations