<tag>HEAD</tag>
</scm>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odlparent</artifactId>
- <version>2.0.5</version>
- <relativePath/>
+ <groupId>org.opendaylight.bgpcep</groupId>
+ <artifactId>testtool-parent</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+ <relativePath>../../testtool-parent</relativePath>
</parent>
- <groupId>org.opendaylight.bgpcep</groupId>
<artifactId>bgp-testtool</artifactId>
<version>0.9.0-SNAPSHOT</version>
<packaging>jar</packaging>
<description>BGP Interop Testing Tool</description>
<name>${project.artifactId}</name>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>bgpcep-parent</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odlparent</artifactId>
- <version>2.0.5</version>
- <relativePath/>
+ <groupId>org.opendaylight.bgpcep</groupId>
+ <artifactId>testtool-parent</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+ <relativePath>../../testtool-parent</relativePath>
</parent>
- <groupId>org.opendaylight.bgpcep</groupId>
<artifactId>bgp-bmp-mock</artifactId>
<version>0.9.0-SNAPSHOT</version>
<name>bmp-mock</name>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>bgpcep-parent</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>org.opendaylight.bgpcep</groupId>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odlparent</artifactId>
- <version>2.0.5</version>
- <relativePath/>
+ <groupId>org.opendaylight.bgpcep</groupId>
+ <artifactId>testtool-parent</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+ <relativePath>../../testtool-parent</relativePath>
</parent>
- <groupId>org.opendaylight.bgpcep</groupId>
<artifactId>pcep-pcc-mock</artifactId>
<version>0.9.0-SNAPSHOT</version>
<packaging>jar</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>bgpcep-parent</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
import ch.qos.logback.classic.LoggerContext;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
import com.google.common.net.InetAddresses;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.opendaylight.protocol.pcep.PCEPCapability;
public static void main(final String[] args) throws InterruptedException, ExecutionException, UnknownHostException {
InetSocketAddress localAddress = new InetSocketAddress(LOCALHOST, DEFAULT_LOCAL_PORT);
- List<InetSocketAddress> remoteAddress = Lists.newArrayList(new InetSocketAddress(LOCALHOST, DEFAULT_REMOTE_PORT));
+ List<InetSocketAddress> remoteAddress = Collections
+ .singletonList(new InetSocketAddress(LOCALHOST, DEFAULT_REMOTE_PORT));
int pccCount = 1;
int lsps = 1;
boolean pcError = false;
if (incrementalSync) {
Preconditions.checkArgument(syncOptDBVersion.intValue() > lsps,
- "Synchronization Database Version which will be used after " +
- "reconnectes requires to be higher than lsps");
+ "Synchronization Database Version which will be used after "
+ + "reconnectes requires to be higher than lsps");
}
final Optional<BigInteger> dBVersion = Optional.fromNullable(syncOptDBVersion);
@Override
protected List<AutoCloseable> startImpl(final PCEPExtensionProviderContext context) {
final List<AutoCloseable> regs = new ArrayList<>();
- regs.add(context.registerObjectParser(PCCEndPointIpv4ObjectParser.CLASS, PCCEndPointIpv4ObjectParser.TYPE, new PCCEndPointIpv4ObjectParser()));
+ regs.add(context.registerObjectParser(PCCEndPointIpv4ObjectParser.CLASS, PCCEndPointIpv4ObjectParser.TYPE,
+ new PCCEndPointIpv4ObjectParser()));
return regs;
}
@Override
public Object parseObject(ObjectHeader header, ByteBuf bytes) throws PCEPDeserializerException {
- Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+ Preconditions.checkArgument(bytes != null && bytes.isReadable(),
+ "Array of bytes is mandatory. Can't be null or empty.");
final EndpointsObjBuilder builder = new EndpointsObjBuilder();
if (bytes.readableBytes() != Ipv4Util.IP4_LENGTH * 2) {
throw new PCEPDeserializerException("Wrong length of array of bytes.");
private BigInteger lspDBVersion = BigInteger.ONE;
private Boolean resynchronizing = Boolean.FALSE;
- public PCCSyncOptimization(@Nonnull final PCCSession session) {
+ PCCSyncOptimization(@Nonnull final PCCSession session) {
requireNonNull(session);
final Tlvs remote = session.getRemoteTlvs();
final Tlvs local = session.localSessionCharacteristics();
this.dbVersionMatch = compareLspDbVersion(this.localLspDbVersion, this.remoteLspDbVersion);
this.isSyncAvoidanceEnabled = isSyncAvoidance(local) && isSyncAvoidance(remote);
this.isDeltaSyncEnabled = isDeltaSync(local) && isDeltaSync(remote);
- this.isTriggeredInitialSynEnable = isTriggeredInitialSync(local) && isTriggeredInitialSync(remote) &&
- (this.isDeltaSyncEnabled || this.isSyncAvoidanceEnabled);
+ this.isTriggeredInitialSynEnable = isTriggeredInitialSync(local) && isTriggeredInitialSync(remote)
+ && (this.isDeltaSyncEnabled || this.isSyncAvoidanceEnabled);
this.isTriggeredReSyncEnable = isTriggeredReSync(local) && isTriggeredReSync(remote);
}
private Timeout redelegationTimeout;
private Timeout stateTimeout;
- public PCCTunnel(final byte[] pathName, final int delegationHolder, final LspType type, final Path lspState) {
+ PCCTunnel(final byte[] pathName, final int delegationHolder, final LspType type, final Path lspState) {
if (pathName != null) {
this.pathName = pathName.clone();
} else {
private static final Subobject DEFAULT_ENDPOINT_HOP = getDefaultEROEndpointHop();
private static final String ENDPOINT_ADDRESS = "1.1.1.1";
private static final String ENDPOINT_PREFIX = ENDPOINT_ADDRESS + "/32";
- public static final int PCC_DELEGATION = -1;
+ static final int PCC_DELEGATION = -1;
private PCCTunnelBuilder() {
throw new UnsupportedOperationException();
static Map<PlspId, PCCTunnel> createTunnels(final String address, final int lsps) {
final Map<PlspId, PCCTunnel> tunnels = new HashMap<>();
for (int i = 1; i <= lsps; i++) {
- final PCCTunnel tunnel = new PCCTunnel(MsgBuilderUtil.getDefaultPathName(address, i), PCC_DELEGATION, LspType.PCC_LSP,
- createPath(Lists.newArrayList(DEFAULT_ENDPOINT_HOP)));
+ final PCCTunnel tunnel = new PCCTunnel(MsgBuilderUtil.getDefaultPathName(address, i),
+ PCC_DELEGATION, LspType.PCC_LSP, createPath(Lists.newArrayList(DEFAULT_ENDPOINT_HOP)));
tunnels.put(new PlspId((long) i), tunnel);
}
return tunnels;
if (hasDelegation(tunnel, session)) {
//send report D=0
final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.absent());
- final Pcrpt pcrtp = createPcRtpMessage(new LspBuilder(update.getLsp()).setSync(true).setOperational(OperationalStatus.Up).setDelegate(false).
- setTlvs(tlvs).build(), Optional.of(createSrp(srpId)), tunnel.getLspState());
+ final Pcrpt pcrtp = createPcRtpMessage(new LspBuilder(update.getLsp()).setSync(true)
+ .setOperational(OperationalStatus.Up).setDelegate(false)
+ .setTlvs(tlvs).build(), Optional.of(createSrp(srpId)), tunnel.getLspState());
session.sendReport(pcrtp);
//start state timer
startStateTimeout(tunnel, plspId);
final long srpId = request.getSrp().getOperationId().getValue();
if (tunnel != null) {
//check if tunnel has no delegation
- if ((tunnel.getType() == LspType.PCE_LSP) && ((tunnel.getDelegationHolder() == -1) || (tunnel.getDelegationHolder() == session.getId()))) {
+ if ((tunnel.getType() == LspType.PCE_LSP) && ((tunnel.getDelegationHolder() == -1)
+ || (tunnel.getDelegationHolder() == session.getId()))) {
//set delegation
tunnel.cancelTimeouts();
setDelegation(plspId, session);
//send report
final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.absent());
session.sendReport(createPcRtpMessage(
- new LspBuilder(request.getLsp()).setSync(true).setOperational(OperationalStatus.Up).setDelegate(true).setTlvs(tlvs).build(),
+ new LspBuilder(request.getLsp()).setSync(true).setOperational(OperationalStatus.Up)
+ .setDelegate(true).setTlvs(tlvs).build(),
Optional.of(createSrp(srpId)), tunnel.getLspState()));
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.LSP_NOT_PCE_INITIATED, srpId));
protected void addTunnel(final Requests request, final PCCSession session) {
final PlspId plspId = new PlspId(this.plspIDsCounter.incrementAndGet());
- final PCCTunnel tunnel = new PCCTunnel(request.getLsp().getTlvs().getSymbolicPathName().getPathName().getValue(),
- session.getId(), LspType.PCE_LSP, reqToRptPath(request));
- sendToAll(tunnel, plspId, request.getEro().getSubobject(), createSrp(request.getSrp().getOperationId().getValue()),
- tunnel.getLspState(), new LspBuilder(request.getLsp()).addAugmentation(Lsp1.class, new Lsp1Builder().setCreate(true).build()).build());
+ final PCCTunnel tunnel = new PCCTunnel(request.getLsp().getTlvs().getSymbolicPathName()
+ .getPathName().getValue(), session.getId(), LspType.PCE_LSP, reqToRptPath(request));
+ sendToAll(tunnel, plspId, request.getEro().getSubobject(),
+ createSrp(request.getSrp().getOperationId().getValue()), tunnel.getLspState(),
+ new LspBuilder(request.getLsp())
+ .addAugmentation(Lsp1.class, new Lsp1Builder().setCreate(true).build()).build());
this.tunnels.put(plspId, tunnel);
}
if (hasDelegation(tunnel, session)) {
this.tunnels.remove(plspId);
sendToAll(tunnel, plspId, tunnel.getLspState().getEro().getSubobject(),
- new SrpBuilder(request.getSrp()).addAugmentation(Srp1.class, new Srp1Builder().setRemove(true).build()).build(),
+ new SrpBuilder(request.getSrp())
+ .addAugmentation(Srp1.class, new Srp1Builder().setRemove(true).build()).build(),
reqToRptPath(request), request.getLsp());
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UPDATE_REQ_FOR_NON_LSP, srpId));
@Override
public void onMessagePcInitiate(@Nonnull final Requests request, @Nonnull final PCCSession session) {
- if ((request.getSrp().getAugmentation(Srp1.class) != null) && request.getSrp().getAugmentation(Srp1.class).isRemove()) {
+ if ((request.getSrp().getAugmentation(Srp1.class) != null)
+ && request.getSrp().getAugmentation(Srp1.class).isRemove()) {
//remove LSP
removeTunnel(request, session);
- } else if ((request.getLsp().isDelegate() != null) && request.getLsp().isDelegate() && (request.getEndpointsObj() == null)) {
+ } else if ((request.getLsp().isDelegate() != null) && request.getLsp().isDelegate()
+ && (request.getEndpointsObj() == null)) {
//take LSP delegation
takeDelegation(request, session);
} else {
}
/**
- * Reports Missed Lsp when DbVersion doesnt match
- *
- * @param session
+ * Reports Missed Lsp when DbVersion doesnt match.
*/
private void reportMissedLsp(final PCCSession session) {
for (long missedLsp = this.syncOptimization.getRemoteLspDbVersionValue().longValue() + 1;
}
}
- private void createLspAndSendReport(final long plspId, final PCCTunnel tunnel, final PCCSession session, final Optional<Boolean> isSync, final Optional<Srp> srp) {
+ private void createLspAndSendReport(final long plspId, final PCCTunnel tunnel, final PCCSession session,
+ final Optional<Boolean> isSync, final Optional<Srp> srp) {
final boolean delegation = hasDelegation(tunnel, session);
if (delegation) {
tunnel.cancelTimeouts();
}
- final String destinationAddress = getDestinationAddress(tunnel.getLspState().getEro().getSubobject(), this.address);
- final Tlvs tlvs = createLspTlvs(plspId, true, destinationAddress, this.address, this.address, Optional.of(tunnel.getPathName()),
- this.syncOptimization.incrementLspDBVersion());
+ final String destinationAddress
+ = getDestinationAddress(tunnel.getLspState().getEro().getSubobject(), this.address);
+ final Tlvs tlvs = createLspTlvs(plspId, true, destinationAddress, this.address,
+ this.address, Optional.of(tunnel.getPathName()), this.syncOptimization.incrementLspDBVersion());
final boolean sync = isSync.isPresent() ? isSync.get() : this.syncOptimization.isSyncNeedIt();
final Lsp lsp = createLsp(plspId, sync, Optional.fromNullable(tlvs), delegation, false);
if (this.syncOptimization.isSyncAvoidanceEnabled()) {
tlv = createLspTlvsEndofSync(this.syncOptimization.incrementLspDBVersion().get());
}
- final Pcrpt pcrtp = createPcRtpMessage(createLsp(0, false, tlv, true, false), Optional.fromNullable(srp), createPath(Collections
- .emptyList()));
+ final Pcrpt pcrtp = createPcRtpMessage(createLsp(0, false, tlv, true, false),
+ Optional.fromNullable(srp), createPath(Collections.emptyList()));
session.sendReport(pcrtp);
}
createLspAndSendReport(plspId.getValue(), tunnel, session, Optional.of(Boolean.TRUE), Optional.of(srp));
}
- private void sendToAll(final PCCTunnel tunnel, final PlspId plspId, final List<Subobject> subobjects, final Srp srp, final Path path, final Lsp lsp) {
+ private void sendToAll(final PCCTunnel tunnel, final PlspId plspId, final List<Subobject> subobjects, final Srp srp,
+ final Path path, final Lsp lsp) {
for (final PCCSession session : this.sessions.values()) {
final boolean isDelegated = hasDelegation(tunnel, session);
final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.of(subobjects));
.setOperational(OperationalStatus.Up)
.setDelegate(isDelegated)
.setSync(true)
- .addAugmentation(Lsp1.class, new Lsp1Builder().setCreate(tunnel.getType() == LspType.PCE_LSP).build())
+ .addAugmentation(Lsp1.class, new Lsp1Builder()
+ .setCreate(tunnel.getType() == LspType.PCE_LSP).build())
.setTlvs(tlvs).build(),
Optional.fromNullable(srp), path);
session.sendReport(pcRpt);
private final Timer timer = new HashedWheelTimer();
private PCCDispatcherImpl pccDispatcher;
- PCCsBuilder(final int lsps, final boolean pcError, final int pccCount, @Nonnull final InetSocketAddress localAddress,
- @Nonnull final List<InetSocketAddress> remoteAddress, final short keepAlive, final short deadTimer,
- @Nullable final String password, final long reconnectTime, final int redelegationTimeout, final int stateTimeout,
- @Nonnull final PCEPCapability pcepCapabilities) {
+ PCCsBuilder(final int lsps, final boolean pcError, final int pccCount,
+ @Nonnull final InetSocketAddress localAddress, @Nonnull final List<InetSocketAddress> remoteAddress,
+ final short keepAlive, final short deadTimer, @Nullable final String password, final long reconnectTime,
+ final int redelegationTimeout, final int stateTimeout, @Nonnull final PCEPCapability pcepCapabilities) {
this.lsps = lsps;
this.pcError = pcError;
this.pccCount = pccCount;
for (int i = 0; i < this.pccCount; i++) {
final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(this.lsps, currentAddress,
this.redelegationTimeout, this.stateTimeout, this.timer, timerHandler);
- createPCC(new InetSocketAddress(currentAddress, this.localAddress.getPort()), tunnelManager, initialDBVersion);
+ createPCC(new InetSocketAddress(currentAddress, this.localAddress.getPort()), tunnelManager,
+ initialDBVersion);
currentAddress = InetAddresses.increment(currentAddress);
}
}
private final PCCsBuilder pcCsBuilder;
private boolean reconnectActive = false;
- public TimerHandler(final PCCsBuilder pcCsBuilder, final Optional<BigInteger> syncOptDBVersion, final int disconnectAfter, final int reconnectAfter) {
+ public TimerHandler(final PCCsBuilder pcCsBuilder, final Optional<BigInteger> syncOptDBVersion,
+ final int disconnectAfter, final int reconnectAfter) {
this.pcCsBuilder = pcCsBuilder;
this.syncOptDBVersion = syncOptDBVersion;
this.disconnectAfter = disconnectAfter;
LOG.debug("Disconnects PCCs, reconnect after {} seconds", TimerHandler.this.reconnectAfter);
TimerHandler.this.pccDispatcher.close();
if (TimerHandler.this.reconnectAfter > 0) {
- TimerHandler.this.timer.newTimeout(new ReconnectTask(), TimerHandler.this.reconnectAfter, TimeUnit.SECONDS);
+ TimerHandler.this.timer.newTimeout(new ReconnectTask(),
+ TimerHandler.this.reconnectAfter, TimeUnit.SECONDS);
}
}
}
@Override
public void run(final Timeout timeout) throws Exception {
LOG.debug("Reconnecting PCCs}");
- TimerHandler.this.pcCsBuilder.createPCCs(TimerHandler.this.syncOptDBVersion.isPresent() ? TimerHandler.this.syncOptDBVersion.get() : BigInteger.ONE, Optional.absent());
+ TimerHandler.this.pcCsBuilder.createPCCs(TimerHandler.this.syncOptDBVersion.isPresent()
+ ? TimerHandler.this.syncOptDBVersion.get() : BigInteger.ONE, Optional.absent());
}
}
public PCEPPeerProposal getPeerProposal() {
return new PCCPeerProposal(dbVersion);
}
- }
- , ch, promise));
+ }, ch, promise));
ch.pipeline().addLast(PCCDispatcherImpl.this.factory.getEncoders());
ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
@Override
}
@Override
- public void setPeerSpecificProposal(@Nonnull final InetSocketAddress address, @Nonnull final TlvsBuilder openBuilder) {
+ public void setPeerSpecificProposal(@Nonnull final InetSocketAddress address,
+ @Nonnull final TlvsBuilder openBuilder) {
requireNonNull(address);
final LspDbVersion lspDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(this.dbVersion).build();
openBuilder.addAugmentation(Tlvs3.class, new Tlvs3Builder().setLspDbVersion(lspDbVersion).build());
private final InetSocketAddress address;
private final int retryTimer;
private final int connectTimeout;
- private final Bootstrap b;
+ private final Bootstrap bootstrap;
@GuardedBy("this")
private Future<?> pending;
PCCReconnectPromise(final InetSocketAddress address, final int retryTimer,
- final int connectTimeout, final Bootstrap b) {
+ final int connectTimeout, final Bootstrap bootstrap) {
super(GlobalEventExecutor.INSTANCE);
this.address = address;
this.retryTimer = retryTimer;
this.connectTimeout = connectTimeout;
- this.b = b;
+ this.bootstrap = bootstrap;
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
synchronized void connect() {
try {
- this.b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, this.connectTimeout);
- this.b.remoteAddress(this.address);
- final ChannelFuture cf = this.b.connect();
+ this.bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, this.connectTimeout);
+ this.bootstrap.remoteAddress(this.address);
+ final ChannelFuture cf = this.bootstrap.connect();
cf.addListener(new BootstrapConnectListener(this));
this.pending = cf;
} catch (final Exception e) {
} else if (cf.isSuccess()) {
PCCReconnectPromise.LOG.debug("Promise connection is successful.");
} else {
- PCCReconnectPromise.LOG.debug("Attempt to connect to {} failed", PCCReconnectPromise.this.address, cf.cause());
+ PCCReconnectPromise.LOG.debug("Attempt to connect to {} failed",
+ PCCReconnectPromise.this.address, cf.cause());
if (PCCReconnectPromise.this.retryTimer == 0) {
PCCReconnectPromise.LOG.debug("Retry timer value is 0. Reconnection will not be attempted");
final EventLoop loop = cf.channel().eventLoop();
loop.schedule(() -> {
synchronized (PCCReconnectPromise.this) {
- PCCReconnectPromise.LOG.debug("Attempting to connect to {}", PCCReconnectPromise.this.address);
- final Future<Void> reconnectFuture = PCCReconnectPromise.this.b.connect();
+ PCCReconnectPromise.LOG.debug("Attempting to connect to {}",
+ PCCReconnectPromise.this.address);
+ final Future<Void> reconnectFuture = PCCReconnectPromise.this.bootstrap.connect();
reconnectFuture.addListener(this);
PCCReconnectPromise.this.pending = reconnectFuture;
}
}, PCCReconnectPromise.this.retryTimer, TimeUnit.SECONDS);
- PCCReconnectPromise.LOG.debug("Next reconnection attempt in {}s", PCCReconnectPromise.this.retryTimer);
+ PCCReconnectPromise.LOG.debug("Next reconnection attempt in {}s",
+ PCCReconnectPromise.this.retryTimer);
}
}
}
}
@Override
- public void setPeerSpecificProposal(@Nonnull final InetSocketAddress address, @Nonnull final TlvsBuilder openBuilder) {
+ public void setPeerSpecificProposal(@Nonnull final InetSocketAddress address,
+ @Nonnull final TlvsBuilder openBuilder) {
requireNonNull(address);
final LspDbVersionBuilder lspDbVersionBuilder = new LspDbVersionBuilder();
if (this.isAfterReconnection) {
} else {
this.isAfterReconnection = true;
}
- openBuilder.addAugmentation(Tlvs3.class, new Tlvs3Builder().setLspDbVersion(lspDbVersionBuilder.build()).build());
+ openBuilder.addAugmentation(Tlvs3.class, new Tlvs3Builder()
+ .setLspDbVersion(lspDbVersionBuilder.build()).build());
}
}
\ No newline at end of file
final Updates upd = ((Pcupd) message).getPcupdMessage().getUpdates().get(0);
this.tunnelManager.onMessagePcupd(upd, this);
} else if (message instanceof Pcinitiate) {
- this.tunnelManager.onMessagePcInitiate(((Pcinitiate) message).getPcinitiateMessage().getRequests().get(0), this);
+ this.tunnelManager.onMessagePcInitiate(((Pcinitiate) message)
+ .getPcinitiateMessage().getRequests().get(0), this);
}
}
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void onSessionDown(final PCEPSession session, final Exception exception) {
LOG.info("Session down with cause : {} or exception: {}", exception.getCause(), exception, exception);
this.tunnelManager.onSessionDown(this);
return rptBuilder.build();
}
- public static Lsp createLsp(final long plspId, final boolean sync, final Optional<Tlvs> tlvs, final boolean isDelegatedLsp, final boolean remove) {
+ public static Lsp createLsp(final long plspId, final boolean sync, final Optional<Tlvs> tlvs,
+ final boolean isDelegatedLsp, final boolean remove) {
final LspBuilder lspBuilder = new LspBuilder();
lspBuilder.setAdministrative(true);
lspBuilder.setDelegate(isDelegatedLsp);
return lspBuilder.build();
}
- public static Lsp createLsp(final long plspId, final boolean sync, final Optional<Tlvs> tlvs, final boolean isDelegatedLspe) {
+ public static Lsp createLsp(final long plspId, final boolean sync, final Optional<Tlvs> tlvs,
+ final boolean isDelegatedLspe) {
return createLsp(plspId, sync, tlvs, isDelegatedLspe, false);
}
return srpBuilder.build();
}
- public static Path updToRptPath(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path path) {
+ public static Path updToRptPath(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf
+ .stateful.rev171025.pcupd.message.pcupd.message.updates.Path path) {
final PathBuilder pathBuilder = new PathBuilder();
if (path != null) {
pathBuilder.fieldsFrom(path);
}
public static Tlvs createLspTlvs(final long lspId, final boolean symbolicPathName, final String tunnelEndpoint,
- final String tunnelSender, final String extendedTunnelAddress, final Optional<byte[]> symbolicName) {
- return createLspTlvs(lspId, symbolicPathName, tunnelEndpoint, tunnelSender, extendedTunnelAddress, symbolicName, Optional.absent());
+ final String tunnelSender, final String extendedTunnelAddress, final Optional<byte[]> symbolicName) {
+ return createLspTlvs(lspId, symbolicPathName, tunnelEndpoint, tunnelSender, extendedTunnelAddress, symbolicName,
+ Optional.absent());
}
public static Tlvs createLspTlvs(final long lspId, final boolean symbolicPathName, final String tunnelEndpoint,
- final String tunnelSender, final String extendedTunnelAddress, final Optional<byte[]> symbolicName, final Optional<BigInteger> lspDBVersion) {
+ final String tunnelSender, final String extendedTunnelAddress, final Optional<byte[]> symbolicName,
+ final Optional<BigInteger> lspDBVersion) {
final TlvsBuilder tlvs = new TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder()
.setLspId(new LspId(lspId))
.setAddressFamily(
}
if (lspDBVersion.isPresent()) {
- tlvs.addAugmentation(Tlvs1.class, new Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().
- setLspDbVersionValue(lspDBVersion.get()).build()).build());
+ tlvs.addAugmentation(Tlvs1.class, new Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder()
+ .setLspDbVersionValue(lspDBVersion.get()).build()).build());
}
return tlvs.build();
}
return Optional.of(tlvs);
}
- public static Pcerr createErrorMsg(@Nonnull final PCEPErrors e, final long srpId) {
+ public static Pcerr createErrorMsg(@Nonnull final PCEPErrors pcepErrors, final long srpId) {
final PcerrMessageBuilder msgBuilder = new PcerrMessageBuilder();
return new PcerrBuilder().setPcerrMessage(
msgBuilder
.build())).build()).build())
.setErrors(
Collections.singletonList(new ErrorsBuilder().setErrorObject(
- new ErrorObjectBuilder().setType(e.getErrorType()).setValue(e.getErrorValue())
+ new ErrorObjectBuilder().setType(pcepErrors.getErrorType()).setValue(pcepErrors.getErrorValue())
.build()).build())).build()).build();
}
public class PCCDispatcherImplTest {
private static final List<PCEPCapability> CAPS = new ArrayList<>();
- private static final PCEPSessionProposalFactory PROPOSAL = new BasePCEPSessionProposalFactory(10, 40, CAPS);
- private final DefaultPCEPSessionNegotiatorFactory nf = new DefaultPCEPSessionNegotiatorFactory(PROPOSAL, 0);
+ private static final PCEPSessionProposalFactory PROPOSAL
+ = new BasePCEPSessionProposalFactory(10, 40, CAPS);
+ private final DefaultPCEPSessionNegotiatorFactory nf
+ = new DefaultPCEPSessionNegotiatorFactory(PROPOSAL, 0);
private PCCDispatcherImpl dispatcher;
private PCEPDispatcher pcepDispatcher;
private InetSocketAddress serverAddress;
MockitoAnnotations.initMocks(this);
this.workerGroup = new NioEventLoopGroup();
this.bossGroup = new NioEventLoopGroup();
- this.dispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry());
- this.pcepDispatcher = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry(),
+ this.dispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance()
+ .getMessageHandlerRegistry());
+ this.pcepDispatcher = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance()
+ .getMessageHandlerRegistry(),
this.nf, this.bossGroup, this.workerGroup);
this.serverAddress = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
this.clientAddress = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(0);
@Test
public void testClientReconnect() throws Exception {
- final Future<PCEPSession> futureSession = this.dispatcher.createClient(this.serverAddress, 1, new TestingSessionListenerFactory(),
- this.nf, KeyMapping.getKeyMapping(), this.clientAddress);
+ final Future<PCEPSession> futureSession = this.dispatcher
+ .createClient(this.serverAddress, 1, new TestingSessionListenerFactory(), this.nf,
+ KeyMapping.getKeyMapping(), this.clientAddress);
final TestingSessionListenerFactory slf = new TestingSessionListenerFactory();
doReturn(slf).when(this.dispatcherDependencies).getListenerFactory();
final Channel channel = futureServer.channel();
Assert.assertNotNull(futureSession.get());
checkSessionListenerNotNull(slf, this.clientAddress.getHostString());
- final TestingSessionListener sl = checkSessionListenerNotNull(slf, this.clientAddress.getAddress().getHostAddress());
+ final TestingSessionListener sl
+ = checkSessionListenerNotNull(slf, this.clientAddress.getAddress().getHostAddress());
Assert.assertNotNull(sl.getSession());
Assert.assertTrue(sl.isUp());
channel.close().get();
this.workerGroup = new NioEventLoopGroup();
this.bossGroup = new NioEventLoopGroup();
- this.pcepDispatcher = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry(),
+ this.pcepDispatcher = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance()
+ .getMessageHandlerRegistry(),
this.nf, this.bossGroup, this.workerGroup);
final TestingSessionListenerFactory slf2 = new TestingSessionListenerFactory();
final ChannelFuture future2 = this.pcepDispatcher.createServer(this.dispatcherDependencies);
waitFutureSuccess(future2);
final Channel channel2 = future2.channel();
- final TestingSessionListener sl2 = checkSessionListenerNotNull(slf2, this.clientAddress.getAddress().getHostAddress());
+ final TestingSessionListener sl2
+ = checkSessionListenerNotNull(slf2, this.clientAddress.getAddress().getHostAddress());
Assert.assertNotNull(sl2.getSession());
Assert.assertTrue(sl2.isUp());
channel2.close();
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.Test;
private static final String IP1 = "1.2.3.4";
private static final String IP2 = "1.2.3.5";
- @Test(expected=PCEPDeserializerException.class)
+ @Test(expected = PCEPDeserializerException.class)
public void testParseEmptyObject() throws PCEPDeserializerException {
final ObjectHeader header = new ObjectHeaderImpl(false, false);
final ByteBuf bytes = Unpooled.buffer();
assertFalse(output.isProcessingRule());
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testNullBytes() throws PCEPDeserializerException {
final ObjectHeader header = new ObjectHeaderImpl(false, false);
final ByteBuf bytes = null;
new PCCEndPointIpv4ObjectParser().parseObject(header, bytes);
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testEmptyBytes() throws PCEPDeserializerException {
final ObjectHeader header = new ObjectHeaderImpl(false, false);
final ByteBuf bytes = Unpooled.buffer();
*/
private final String[] mainInputIncrementalSync = new String[]{"--local-address", this.localAddress.getHostString(),
"--remote-address", InetSocketAddressUtil.toHostAndPort(this.remoteAddress).toString(), "--pcc", "1", "--lsp",
- this.lsp.toString(), "--log-level", "DEBUG", "-ka", "30", "-d", "120", "--reconnect", "-1", "--redelegation-timeout",
- "0", "--state-timeout", "-1", "--incremental-sync-procedure", "10", "5", "5"};
+ this.lsp.toString(), "--log-level", "DEBUG", "-ka", "30", "-d", "120", "--reconnect", "-1",
+ "--redelegation-timeout", "0", "--state-timeout", "-1", "--incremental-sync-procedure", "10", "5", "5"};
@Test
public void testSessionIncrementalSyncEstablishment() throws Exception {
final int expetecdNumberOfLspAndEndOfSync = 3;
final BigInteger expectedFinalDBVersion = BigInteger.valueOf(10);
final TestingSessionListener sessionListenerAfterReconnect = getListener(factory);
- checkResyncSession(Optional.absent(), expetecdNumberOfLspAndEndOfSync, 3, numberOflspAndDBv, expectedFinalDBVersion, sessionListenerAfterReconnect);
+ checkResyncSession(Optional.absent(), expetecdNumberOfLspAndEndOfSync, 3, numberOflspAndDBv,
+ expectedFinalDBVersion, sessionListenerAfterReconnect);
channel.close().get();
}
assertEquals(true, lsp.isSync());
}
final BigInteger actuaLspDBVersion = lsp.getTlvs().getAugmentation(org.opendaylight.yang.gen
- .v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class)
- .getLspDbVersion().getLspDbVersionValue();
+ .v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class)
+ .getLspDbVersion().getLspDbVersionValue();
assertEquals(expectedDbVersion, actuaLspDBVersion);
}
}
final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(3, this.localAddress.getAddress(),
0, -1, new HashedWheelTimer(), Optional.absent());
- return pccDispatcher.createClient(this.remoteAddress, -1,
- () -> {
- this.pccSessionListener = new PCCSessionListener(1, tunnelManager, false);
- return this.pccSessionListener;
- }, snf, KeyMapping.getKeyMapping(), this.localAddress, dbVersion);
+ return pccDispatcher.createClient(this.remoteAddress, -1, () -> {
+ this.pccSessionListener = new PCCSessionListener(1, tunnelManager, false);
+ return this.pccSessionListener;
+ }, snf, KeyMapping.getKeyMapping(), this.localAddress, dbVersion);
}
private PCEPSessionNegotiatorFactory<PCEPSessionImpl> getSessionNegotiatorFactory() {
package org.opendaylight.protocol.pcep.pcc.mock;
import io.netty.channel.Channel;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.opendaylight.protocol.pcep.PCEPCapability;
-import org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
public final class PCCMockTest extends PCCMockCommon {
- private final String[] mainInput = new String[] {"--local-address", this.localAddress.getHostString(), "--remote-address",
- InetSocketAddressUtil.toHostAndPort(this.remoteAddress).toString(), "--pcc", "1", "--lsp", "3", "--log-level", "DEBUG", "-ka", "10", "-d", "40", "--reconnect", "-1",
+ private final String[] mainInput = new String[]{"--local-address", this.localAddress.getHostString(),
+ "--remote-address", InetSocketAddressUtil.toHostAndPort(this.remoteAddress).toString(), "--pcc", "1",
+ "--lsp", "3", "--log-level", "DEBUG", "-ka", "10", "-d", "40", "--reconnect", "-1",
"--redelegation-timeout", "0", "--state-timeout", "-1"};
@Test
Thread.sleep(1000);
//3 reported LSPs + syc
final int numMessages = 4;
- final TestingSessionListener sessionListener = checkSessionListener(numMessages, channel, factory, this.localAddress.getHostString());
+ final TestingSessionListener sessionListener = checkSessionListener(numMessages, channel, factory,
+ this.localAddress.getHostString());
checkSession(sessionListener.getSession(), 40, 10);
}
final Channel channel2 = createServer(factory2, serverAddress3);
final Channel channel3 = createServer(factory3, serverAddress4);
- Main.main(new String[] {"--local-address", this.localAddress.getHostString(), "--remote-address",
- InetSocketAddressUtil.toHostAndPort(serverAddress2).toString() + "," +
- InetSocketAddressUtil.toHostAndPort(serverAddress3).toString() + "," +
- InetSocketAddressUtil.toHostAndPort(serverAddress4).toString(),
+ Main.main(new String[]{"--local-address", this.localAddress.getHostString(), "--remote-address",
+ InetSocketAddressUtil.toHostAndPort(serverAddress2).toString() + ","
+ + InetSocketAddressUtil.toHostAndPort(serverAddress3).toString() + ","
+ + InetSocketAddressUtil.toHostAndPort(serverAddress4).toString(),
"--pcc", "2"});
Thread.sleep(1000);
//PCE1
checkSessionListener(numMessages, channel3, factory3, localAddress2);
}
- @Test(expected = UnsupportedOperationException.class)
- public void testPrivateConstructor() throws Throwable {
- final Constructor<MsgBuilderUtil> c = MsgBuilderUtil.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
@Override
protected List<PCEPCapability> getCapabilities() {
return Collections.emptyList();
private static final InetAddress ADDRESS = InetAddresses.forString("1.2.4.5");
private static final Timer TIMER = new HashedWheelTimer();
private static final byte[] SYMBOLIC_NAME = "tets".getBytes(StandardCharsets.UTF_8);
- private static final Ero ERO = new EroBuilder()
- .setSubobject(Lists.newArrayList(new SubobjectBuilder().setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(
- new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("127.0.0.2/32"))).build()).build()).build())).build();
+ private static final Ero ERO = new EroBuilder().setSubobject(Lists.newArrayList(new SubobjectBuilder()
+ .setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder()
+ .setIpPrefix(new IpPrefix(new Ipv4Prefix("127.0.0.2/32"))).build()).build()).build())).build();
private final List<PCEPErrors> errorsSession1 = new ArrayList<>();
private final List<PCEPErrors> errorsSession2 = new ArrayList<>();
@Mock
return updsBuilder.build();
}
- private static Requests createRequests(final long plspId, final Optional<Boolean> remove, final Optional<Boolean> delegate) {
+ private static Requests createRequests(final long plspId, final Optional<Boolean> remove,
+ final Optional<Boolean> delegate) {
final RequestsBuilder reqBuilder = new RequestsBuilder();
reqBuilder.setEro(ERO);
- final LspBuilder lsp = new LspBuilder().setTlvs(new TlvsBuilder().setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(
+ final LspBuilder lsp = new LspBuilder().setTlvs(new TlvsBuilder()
+ .setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(
new SymbolicPathName(SYMBOLIC_NAME)).build()).build()).setPlspId(new PlspId(plspId));
if (delegate.isPresent()) {
lsp.setDelegate(Boolean.TRUE);
return createRequests(plspId, Optional.absent(), Optional.of(Boolean.TRUE));
}
+ @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
private static Requests createRequests(final long plspId) {
return createRequests(plspId, Optional.absent(), Optional.absent());
}
return ImmutableList.copyOf(this.messages);
}
- boolean isUp () {
+ boolean isUp() {
return this.up;
}
public PCEPSession getSession() {
- Assert.assertEquals("Session up", true, Uninterruptibles.awaitUninterruptibly(this.sessionLatch, 10, TimeUnit.SECONDS));
+ Assert.assertEquals("Session up", true,
+ Uninterruptibles.awaitUninterruptibly(this.sessionLatch, 10, TimeUnit.SECONDS));
return this.session;
}
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odlparent</artifactId>
- <version>2.0.5</version>
- <relativePath/>
+ <groupId>org.opendaylight.bgpcep</groupId>
+ <artifactId>testtool-parent</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+ <relativePath>../../testtool-parent</relativePath>
</parent>
- <groupId>org.opendaylight.bgpcep</groupId>
<artifactId>pcep-testtool</artifactId>
<version>0.9.0-SNAPSHOT</version>
<description>PCEP Interop Testing Tool</description>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>bgpcep-parent</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.opendaylight.protocol.pcep.PCEPCapability;
-import org.opendaylight.protocol.pcep.PCEPDispatcherDependencies;
import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
import org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator;
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
- public static final String USAGE = "DESCRIPTION:\n"
- + "\tCreates a server with given parameters. As long as it runs, it accepts connections " + "from PCCs.\n" + "USAGE:\n"
+ private static final String USAGE = "DESCRIPTION:\n"
+ + "\tCreates a server with given parameters. As long as it runs, it accepts connections "
+ + "from PCCs.\n" + "USAGE:\n"
+ "\t-a, --address\n" + "\t\tthe ip address to which is this server bound.\n"
- + "\t\tFormat: x.x.x.x:y where y is port number.\n\n" +
+ + "\t\tFormat: x.x.x.x:y where y is port number.\n\n"
- "\t-d, --deadtimer\n" + "\t\tin seconds, value of the desired deadtimer\n"
+ + "\t-d, --deadtimer\n" + "\t\tin seconds, value of the desired deadtimer\n"
+ "\t\tAccording to RFC5440, recommended value for deadtimer is 4 times the value\n"
+ "\t\tof KeepAlive timer. If it's not, a warning is printed.\n"
- + "\t\tIf not set, it's value will be derived from KeepAlive timer value.\n\n" +
+ + "\t\tIf not set, it's value will be derived from KeepAlive timer value.\n\n"
- "\t-ka, --keepalive\n" + "\t\tin seconds, value of the desired KeepAlive timer.\n"
- + "\t\tIf not present, KeepAlive timer will be set to recommended value (30s).\n\n" +
+ + "\t-ka, --keepalive\n" + "\t\tin seconds, value of the desired KeepAlive timer.\n"
+ + "\t\tIf not present, KeepAlive timer will be set to recommended value (30s).\n\n"
- "\t--stateful\n" + "\t\tpassive stateful\n\n" +
+ + "\t--stateful\n" + "\t\tpassive stateful\n\n"
- "\t--active\n" + "\t\tactive stateful (implies --stateful)\n\n" +
+ + "\t--active\n" + "\t\tactive stateful (implies --stateful)\n\n"
- "\t--instant\n"
- + "\t\tinstantiated stateful, <seconds> cleanup timeout (default value, if not included = 0) (implies --stateful)\n\n" +
+ + "\t--instant\n"
+ + "\t\tinstantiated stateful, <seconds> cleanup timeout "
+ + "(default value, if not included = 0) (implies --stateful)\n\n"
- "\t-arm, --autoResponseMessages <path to file>\n"
+ + "\t-arm, --autoResponseMessages <path to file>\n"
+ "\t\t <path to file> with groovy script which implements MessageGeneratorService.\n"
- + "\t\t Messages are used as auto response for every message received. Purely for testing puposes! \n\n" +
+ + "\t\t Messages are used as auto response for every message received. Purely for testing puposes! \n\n"
- "\t-psm, --periodicallySendMessages <path to file> <period>\n"
- + "\t\t <path to file> with groovy script which implements MessageGeneratorService followed by <period> in seconds.\n"
- + "\t\t Messages which are sent periodically. Purely for testing puposes! \n\n" +
+ + "\t-psm, --periodicallySendMessages <path to file> <period>\n"
+ + "\t\t <path to file> with groovy script which implements"
+ + " MessageGeneratorService followed by <period> in seconds.\n"
+ + "\t\t Messages which are sent periodically. Purely for testing puposes! \n\n"
- "\t-snm, --sendNowMessage <path to file>\n"
+ + "\t-snm, --sendNowMessage <path to file>\n"
+ "\t\t <path to file> with groovy script which implements MessageGeneratorService.\n"
- + "\t\t Messages are sent in defined states defined by programmer. Purely for testing puposes! \n\n" +
+ + "\t\t Messages are sent in defined states defined by programmer. Purely for testing puposes! \n\n"
- "\t--help\n" + "\t\tdisplay this help and exits\n\n" +
+ + "\t--help\n" + "\t\tdisplay this help and exits\n\n"
- "With no parameters, this help is printed.";
+ + "With no parameters, this help is printed.";
+ private static final int KA_TO_DEADTIMER_RATIO = 4;
+ private static final int KA_DEFAULT = 30;
+ private static final int MAX_UNKNOWN_MESSAGES = 5;
private Main() {
}
- private static final int KA_TO_DEADTIMER_RATIO = 4;
-
- private static final int KA_DEFAULT = 30;
-
- private static final int MAX_UNKNOWN_MESSAGES = 5;
-
public static void main(final String[] args) throws UnknownHostException, InterruptedException, ExecutionException {
if (args.length == 0 || (args.length == 1 && args[0].equalsIgnoreCase("--help"))) {
LOG.info(Main.USAGE);
boolean active = false;
boolean instant = false;
- int i = 0;
- while (i < args.length) {
- if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("--address")) {
- final String[] ip = args[i + 1].split(":");
+ int pos = 0;
+ while (pos < args.length) {
+ if (args[pos].equalsIgnoreCase("-a") || args[pos].equalsIgnoreCase("--address")) {
+ final String[] ip = args[pos + 1].split(":");
address = new InetSocketAddress(InetAddress.getByName(ip[0]), Integer.parseInt(ip[1]));
- i++;
- } else if (args[i].equalsIgnoreCase("-d") || args[i].equalsIgnoreCase("--deadtimer")) {
- deadTimerValue = Integer.parseInt(args[i + 1]);
- i++;
- } else if (args[i].equalsIgnoreCase("-ka") || args[i].equalsIgnoreCase("--keepalive")) {
- keepAliveValue = Integer.parseInt(args[i + 1]);
- i++;
- } else if (args[i].equalsIgnoreCase("--stateful")) {
+ pos++;
+ } else if (args[pos].equalsIgnoreCase("-d") || args[pos].equalsIgnoreCase("--deadtimer")) {
+ deadTimerValue = Integer.parseInt(args[pos + 1]);
+ pos++;
+ } else if (args[pos].equalsIgnoreCase("-ka") || args[pos].equalsIgnoreCase("--keepalive")) {
+ keepAliveValue = Integer.parseInt(args[pos + 1]);
+ pos++;
+ } else if (args[pos].equalsIgnoreCase("--stateful")) {
stateful = true;
- } else if (args[i].equalsIgnoreCase("--active")) {
+ } else if (args[pos].equalsIgnoreCase("--active")) {
stateful = true;
active = true;
- } else if (args[i].equalsIgnoreCase("--instant")) {
+ } else if (args[pos].equalsIgnoreCase("--instant")) {
stateful = true;
instant = true;
} else {
- LOG.warn("WARNING: Unrecognized argument: {}", args[i]);
+ LOG.warn("WARNING: Unrecognized argument: {}", args[pos]);
}
- i++;
+ pos++;
}
if (deadTimerValue != 0 && deadTimerValue != keepAliveValue * KA_TO_DEADTIMER_RATIO) {
LOG.warn("WARNING: The value of DeadTimer should be 4 times the value of KeepAlive.");
caps.add(new PCEPStatefulCapability(stateful, active, instant, false, false, false, false));
final PCEPSessionProposalFactory spf = new BasePCEPSessionProposalFactory(deadTimerValue, keepAliveValue, caps);
- try (final StatefulActivator activator07 = new StatefulActivator()) {
+ try (StatefulActivator activator07 = new StatefulActivator()) {
activator07.start(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance());
final PCEPDispatcherImpl dispatcher = new PCEPDispatcherImpl(
public class TestingSessionListener implements PCEPSessionListener {
+ private static final Logger LOG = LoggerFactory.getLogger(TestingSessionListener.class);
private final List<Message> messages = Lists.newArrayList();
-
private boolean up = false;
- private static final Logger LOG = LoggerFactory.getLogger(TestingSessionListener.class);
-
- public TestingSessionListener() {
- }
-
@Override
public void onMessage(final PCEPSession session, final Message message) {
LOG.debug("Received message: {}", message);
LOG.debug("Session terminated. Cause : {}", cause);
}
- public List<Message> messages() {
+ List<Message> messages() {
return this.messages;
}
- public boolean isUp () {
+ boolean isUp() {
return this.up;
}
}
final PCEPSessionNegotiatorFactory snf = new DefaultPCEPSessionNegotiatorFactory(proposal, 0);
final HostAndPort serverHostAndPort = HostAndPort.fromString(args[0]);
final InetSocketAddress serverAddr = new InetSocketAddress(serverHostAndPort.getHost(), serverHostAndPort
- .getPortOrDefault(12345));
+ .getPortOrDefault(12345));
final InetSocketAddress clientAddr = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(0);
- try (final PCCDispatcherImpl pccDispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext
- .getSingletonInstance().getMessageHandlerRegistry())) {
+ try (PCCDispatcherImpl pccDispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext
+ .getSingletonInstance().getMessageHandlerRegistry())) {
pccDispatcher.createClient(serverAddr, -1, SimpleSessionListener::new, snf,
- KeyMapping.getKeyMapping(), clientAddr).get();
+ KeyMapping.getKeyMapping(), clientAddr).get();
}
}
}
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void onSessionDown(final PCEPSession session, final Exception exception) {
LOG.debug("Session down with cause : {} or exception: {}", exception.getCause(), exception, exception);
try {
<module>binding-parent</module>
<module>bundle-parent</module>
<module>config-parent</module>
+ <module>testtool-parent</module>
<!-- Common infra -->
<module>concepts</module>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (c) 2017 AT&T Intellectual Property. 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
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>odlparent</artifactId>
+ <version>2.0.5</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.opendaylight.bgpcep</groupId>
+ <artifactId>testtool-parent</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>${project.artifactId}</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.bgpcep</groupId>
+ <artifactId>bgpcep-parent</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <failOnError>true</failOnError>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
+ <url>https://wiki.opendaylight.org/view/BGP_LS_PCEP:Main</url>
+ <tag>HEAD</tag>
+ </scm>
+</project>
\ No newline at end of file