import ch.qos.logback.classic.LoggerContext;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterables;
-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;
throw new UnsupportedOperationException();
}
- public static void main(final String[] args) throws InterruptedException, ExecutionException, UnknownHostException {
+ public static void main(final String[] args) throws InterruptedException, ExecutionException {
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;
getRootLogger(lc).setLevel(ch.qos.logback.classic.Level.INFO);
int argIdx = 0;
while (argIdx < args.length) {
- if (args[argIdx].equals("--local-address")) {
- localAddress = InetSocketAddressUtil.getInetSocketAddress(args[++argIdx], DEFAULT_LOCAL_PORT);
- } else if (args[argIdx].equals("--remote-address")) {
- remoteAddress = InetSocketAddressUtil.parseAddresses(args[++argIdx], DEFAULT_REMOTE_PORT);
- } else if (args[argIdx].equals("--pcc")) {
- pccCount = Integer.valueOf(args[++argIdx]);
- } else if (args[argIdx].equals("--lsp")) {
- lsps = Integer.valueOf(args[++argIdx]);
- } else if (args[argIdx].equals("--pcerr")) {
- pcError = true;
- } else if (args[argIdx].equals("--log-level")) {
- getRootLogger(lc).setLevel(Level.toLevel(args[++argIdx], ch.qos.logback.classic.Level.INFO));
- } else if (args[argIdx].equals("--keepalive") || args[argIdx].equals("-ka")) {
- ka = Short.valueOf(args[++argIdx]);
- } else if (args[argIdx].equals("--deadtimer") || args[argIdx].equals("-d")) {
- dt = Short.valueOf(args[++argIdx]);
- } else if (args[argIdx].equals("--password")) {
- password = args[++argIdx];
- } else if (args[argIdx].equals("--reconnect")) {
- reconnectTime = Integer.valueOf(args[++argIdx]).intValue();
- } else if (args[argIdx].equals("--redelegation-timeout")) {
- redelegationTimeout = Integer.valueOf(args[++argIdx]);
- } else if (args[argIdx].equals("--state-timeout")) {
- stateTimeout = Integer.valueOf(args[++argIdx]);
- } else if (args[argIdx].equals("--state-sync-avoidance")) {
- //"--state-sync-avoidance 10, 5, 10
- includeDbv = Boolean.TRUE;
- final Long dbVersionAfterReconnect = Long.valueOf(args[++argIdx]);
- disonnectAfterXSeconds = Integer.valueOf(args[++argIdx]);
- reconnectAfterXSeconds = Integer.valueOf(args[++argIdx]);
- syncOptDBVersion = BigInteger.valueOf(dbVersionAfterReconnect);
- } else if (args[argIdx].equals("--incremental-sync-procedure")) {
- //TODO Check that DBv > Lsp always ??
- includeDbv = Boolean.TRUE;
- incrementalSync = Boolean.TRUE;
- //Version of database to be used after restart
- final Long initialDbVersionAfterReconnect = Long.valueOf(args[++argIdx]);
- disonnectAfterXSeconds = Integer.valueOf(args[++argIdx]);
- reconnectAfterXSeconds = Integer.valueOf(args[++argIdx]);
- syncOptDBVersion = BigInteger.valueOf(initialDbVersionAfterReconnect);
- } else if (args[argIdx].equals("--triggered-initial-sync")) {
- triggeredInitSync = Boolean.TRUE;
- } else if (args[argIdx].equals("--triggered-re-sync")) {
- triggeredResync = Boolean.TRUE;
- } else {
- LOG.warn("WARNING: Unrecognized argument: {}", args[argIdx]);
+ switch (args[argIdx]) {
+ case "--local-address":
+ localAddress = InetSocketAddressUtil.getInetSocketAddress(args[++argIdx], DEFAULT_LOCAL_PORT);
+ break;
+ case "--remote-address":
+ remoteAddress = InetSocketAddressUtil.parseAddresses(args[++argIdx], DEFAULT_REMOTE_PORT);
+ break;
+ case "--pcc":
+ pccCount = Integer.parseInt(args[++argIdx]);
+ break;
+ case "--lsp":
+ lsps = Integer.parseInt(args[++argIdx]);
+ break;
+ case "--pcerr":
+ pcError = true;
+ break;
+ case "--log-level":
+ getRootLogger(lc).setLevel(Level.toLevel(args[++argIdx], Level.INFO));
+ break;
+ case "--keepalive":
+ case "-ka":
+ ka = Short.valueOf(args[++argIdx]);
+ break;
+ case "--deadtimer":
+ case "-d":
+ dt = Short.valueOf(args[++argIdx]);
+ break;
+ case "--password":
+ password = args[++argIdx];
+ break;
+ case "--reconnect":
+ reconnectTime = Integer.parseInt(args[++argIdx]);
+ break;
+ case "--redelegation-timeout":
+ redelegationTimeout = Integer.parseInt(args[++argIdx]);
+ break;
+ case "--state-timeout":
+ stateTimeout = Integer.parseInt(args[++argIdx]);
+ break;
+ case "--state-sync-avoidance":
+ //"--state-sync-avoidance 10, 5, 10
+ includeDbv = Boolean.TRUE;
+ final Long dbVersionAfterReconnect = Long.valueOf(args[++argIdx]);
+ disonnectAfterXSeconds = Integer.parseInt(args[++argIdx]);
+ reconnectAfterXSeconds = Integer.parseInt(args[++argIdx]);
+ syncOptDBVersion = BigInteger.valueOf(dbVersionAfterReconnect);
+ break;
+ case "--incremental-sync-procedure":
+ //TODO Check that DBv > Lsp always ??
+ includeDbv = Boolean.TRUE;
+ incrementalSync = Boolean.TRUE;
+ //Version of database to be used after restart
+ final Long initialDbVersionAfterReconnect = Long.valueOf(args[++argIdx]);
+ disonnectAfterXSeconds = Integer.parseInt(args[++argIdx]);
+ reconnectAfterXSeconds = Integer.parseInt(args[++argIdx]);
+ syncOptDBVersion = BigInteger.valueOf(initialDbVersionAfterReconnect);
+ break;
+ case "--triggered-initial-sync":
+ triggeredInitSync = Boolean.TRUE;
+ break;
+ case "--triggered-re-sync":
+ triggeredResync = Boolean.TRUE;
+ break;
+ default:
+ LOG.warn("WARNING: Unrecognized argument: {}", args[argIdx]);
+ break;
}
argIdx++;
}
if (incrementalSync) {
- Preconditions.checkArgument(syncOptDBVersion.intValue() > lsps, "Synchronization Database Version which will be used after " +
- "reconnectes requires to be higher than lsps");
+ Preconditions.checkArgument(syncOptDBVersion.intValue() > lsps,
+ "Synchronization Database Version which will be used after "
+ + "reconnectes requires to be higher than lsps");
}
final Optional<BigInteger> dBVersion = Optional.fromNullable(syncOptDBVersion);
- final PCCsBuilder pccs = new PCCsBuilder(lsps, pcError, pccCount, localAddress, remoteAddress, ka, dt, password, reconnectTime, redelegationTimeout,
+ final PCCsBuilder pccs = new PCCsBuilder(lsps, pcError, pccCount, localAddress, remoteAddress, ka, dt,
+ password, reconnectTime, redelegationTimeout,
stateTimeout, getCapabilities());
- final TimerHandler timerHandler = new TimerHandler(pccs, dBVersion, disonnectAfterXSeconds, reconnectAfterXSeconds);
+ final TimerHandler timerHandler = new TimerHandler(pccs, dBVersion, disonnectAfterXSeconds,
+ reconnectAfterXSeconds);
pccs.createPCCs(BigInteger.valueOf(lsps), Optional.fromNullable(timerHandler));
if (!triggeredInitSync) {
timerHandler.createDisconnectTask();
if (triggeredInitSync) {
Preconditions.checkArgument(includeDbv);
}
- return new PCEPStatefulCapability(true, true, true, triggeredInitSync, triggeredResync, incrementalSync, includeDbv);
+ return new PCEPStatefulCapability(true, true, true, triggeredInitSync, triggeredResync,
+ incrementalSync, includeDbv);
}
private static ch.qos.logback.classic.Logger getRootLogger(final LoggerContext lc) {
- return Iterables.find(lc.getLoggerList(), input -> (input != null) ? input.getName().equals(Logger.ROOT_LOGGER_NAME) : false);
+ return lc.getLoggerList().stream().filter(input -> (input != null) && input.getName()
+ .equals(Logger.ROOT_LOGGER_NAME)).findFirst().get();
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder;
-public final class PCCTunnelBuilder {
- private static final Subobject DEFAULT_ENDPOINT_HOP = getDefaultEROEndpointHop();
+final class PCCTunnelBuilder {
+ static final int PCC_DELEGATION = -1;
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;
+ private static final Subobject DEFAULT_ENDPOINT_HOP = getDefaultEROEndpointHop();
private PCCTunnelBuilder() {
throw new UnsupportedOperationException();
}
- public static Map<PlspId, PCCTunnel> createTunnels(final String address, final int lsps) {
+ 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;
final SubobjectBuilder builder = new SubobjectBuilder();
builder.setLoose(false);
builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(
- new IpPrefix(new Ipv4Prefix(ENDPOINT_PREFIX))).build()).build());
+ new IpPrefix(new Ipv4Prefix(ENDPOINT_PREFIX))).build()).build());
return builder.build();
}
}
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.List;
-import java.util.concurrent.ExecutionException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.protocol.concepts.KeyMapping;
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;
startActivators();
}
- void createPCCs(final BigInteger initialDBVersion, final Optional<TimerHandler> timerHandler)
- throws InterruptedException, ExecutionException {
+ void createPCCs(final BigInteger initialDBVersion, final Optional<TimerHandler> timerHandler) {
InetAddress currentAddress = this.localAddress.getAddress();
this.pccDispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance()
.getMessageHandlerRegistry());
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 void createPCC(@Nonnull final InetSocketAddress localAddress, @Nonnull final PCCTunnelManager tunnelManager,
- final BigInteger initialDBVersion) throws InterruptedException, ExecutionException {
+ private void createPCC(@Nonnull final InetSocketAddress plocalAddress,
+ final PCCTunnelManager tunnelManager, final BigInteger initialDBVersion) {
final PCEPSessionNegotiatorFactory<PCEPSessionImpl> snf = getSessionNegotiatorFactory();
for (final InetSocketAddress pceAddress : this.remoteAddress) {
this.pccDispatcher.createClient(pceAddress, this.reconnectTime, () -> new PCCSessionListener(
- this.remoteAddress.indexOf(pceAddress), tunnelManager, this.pcError), snf,
- KeyMapping.getKeyMapping(pceAddress.getAddress(), this.password), localAddress, initialDBVersion);
+ this.remoteAddress.indexOf(pceAddress), tunnelManager, this.pcError), snf,
+ KeyMapping.getKeyMapping(pceAddress.getAddress(), this.password), plocalAddress, initialDBVersion);
}
}
final PCCReconnectPromise promise = new PCCReconnectPromise(remoteAddress, (int) retryTimer, CONNECT_TIMEOUT, b);
final ChannelInitializer<SocketChannel> channelInitializer = new ChannelInitializer<SocketChannel>() {
@Override
- protected void initChannel(final SocketChannel ch) throws Exception {
+ protected void initChannel(final SocketChannel ch) {
ch.pipeline().addLast(PCCDispatcherImpl.this.factory.getDecoders());
ch.pipeline().addLast("negotiator", negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise, new PCCPeerProposal(dbVersion)));
ch.pipeline().addLast(PCCDispatcherImpl.this.factory.getEncoders());
ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
@Override
- public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
+ public void channelInactive(final ChannelHandlerContext ctx) {
if (promise.isCancelled()) {
return;
}
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
+import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.protocol.pcep.PCEPCapability;
import org.opendaylight.protocol.pcep.PCEPDispatcher;
import org.opendaylight.protocol.pcep.PCEPPeerProposal;
private static final short DEAD_TIMER = 120;
private static final long SLEEP_FOR = 50;
private final int port = InetSocketAddressUtil.getRandomPort();
- protected final InetSocketAddress remoteAddress = InetSocketAddressUtil
- .getRandomLoopbackInetSocketAddress(this.port);
- protected final InetSocketAddress localAddress = new InetSocketAddress("127.0.0.1", this.port);
- protected PCCSessionListener pccSessionListener;
+ final InetSocketAddress remoteAddress = InetSocketAddressUtil
+ .getRandomLoopbackInetSocketAddress(this.port);
+ final InetSocketAddress localAddress = InetSocketAddressUtil
+ .getRandomLoopbackInetSocketAddress(this.port);
+ PCCSessionListener pccSessionListener;
private PCEPDispatcher pceDispatcher;
private PCEPExtensionProviderContext extensionProvider;
private MessageRegistry messageRegistry;
@Before
public void setUp() {
final BasePCEPSessionProposalFactory proposal = new BasePCEPSessionProposalFactory(DEAD_TIMER, KEEP_ALIVE,
- getCapabilities());
+ getCapabilities());
final DefaultPCEPSessionNegotiatorFactory nf = new DefaultPCEPSessionNegotiatorFactory(proposal, 0);
- this.extensionProvider = ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance();
+ this.extensionProvider = ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance();
this.messageRegistry = this.extensionProvider.getMessageHandlerRegistry();
this.pceDispatcher = new PCEPDispatcherImpl(this.messageRegistry, nf, new NioEventLoopGroup(),
- new NioEventLoopGroup());
+ new NioEventLoopGroup());
}
- protected static TestingSessionListener checkSessionListener(final int numMessages, final Channel channel,
- final TestingSessionListenerFactory factory,
- final String localAddress) throws
- Exception {
+ static TestingSessionListener checkSessionListener(final int numMessages, final Channel channel,
+ final TestingSessionListenerFactory factory,
+ final String localAddress) throws
+ Exception {
final TestingSessionListener sessionListener = checkSessionListenerNotNull(factory, localAddress);
assertTrue(sessionListener.isUp());
checkReceivedMessages(sessionListener, numMessages);
}
static TestingSessionListener checkSessionListenerNotNull(final TestingSessionListenerFactory factory,
- final String localAddress) {
+ final String localAddress) {
final Stopwatch sw = Stopwatch.createStarted();
TestingSessionListener listener;
final InetAddress address = InetAddresses.forString(localAddress);
throw new NullPointerException();
}
- protected Channel createServer(final TestingSessionListenerFactory factory,
- final InetSocketAddress serverAddress2) throws InterruptedException {
+ Channel createServer(final TestingSessionListenerFactory factory,
+ final InetSocketAddress serverAddress2) {
return createServer(factory, serverAddress2, null);
}
- protected Channel createServer(final TestingSessionListenerFactory factory, final InetSocketAddress
- serverAddress2, final PCEPPeerProposal peerProposal) {
+ Channel createServer(final TestingSessionListenerFactory factory, final InetSocketAddress
+ serverAddress2, final PCEPPeerProposal peerProposal) {
final StatefulActivator activator07 = new StatefulActivator();
final SyncOptimizationsActivator optimizationsActivator = new SyncOptimizationsActivator();
activator07.start(this.extensionProvider);
return future.channel();
}
- protected static void checkSynchronizedSession(final int numberOfLsp,
- final TestingSessionListener pceSessionListener, final BigInteger expectedeInitialDb) throws Exception {
+ static void checkSynchronizedSession(final int numberOfLsp,
+ final TestingSessionListener pceSessionListener, final BigInteger expectedeInitialDb) throws Exception {
assertTrue(pceSessionListener.isUp());
//Send Open with LspDBV = 1
final int numberOfSyncMessage = 1;
int numberOfLspExpected = numberOfLsp;
if (!expectedeInitialDb.equals(BigInteger.ZERO)) {
- checkEquals(()-> checkSequequenceDBVersionSync(pceSessionListener, expectedeInitialDb));
+ checkEquals(() -> checkSequequenceDBVersionSync(pceSessionListener, expectedeInitialDb));
numberOfLspExpected += numberOfSyncMessage;
}
checkReceivedMessages(pceSessionListener, numberOfLspExpected);
checkSession(session, DEAD_TIMER, KEEP_ALIVE);
assertTrue(session.getRemoteTlvs().getAugmentation(Tlvs1.class).getStateful()
- .getAugmentation(Stateful1.class).isInitiation());
+ .getAugmentation(Stateful1.class).isInitiation());
assertNull(session.localSessionCharacteristics().getAugmentation(Tlvs3.class)
- .getLspDbVersion().getLspDbVersionValue());
+ .getLspDbVersion().getLspDbVersionValue());
}
- protected static void checkResyncSession(final Optional<Integer> startAtNumberLsp, final int expectedNumberOfLsp,
- final int expectedTotalMessages, final BigInteger startingDBVersion, final BigInteger expectedDBVersion,
- final TestingSessionListener pceSessionListener) throws Exception {
+ static void checkResyncSession(final Optional<Integer> startAtNumberLsp, final int expectedNumberOfLsp,
+ final int expectedTotalMessages, final BigInteger startingDBVersion, final BigInteger expectedDBVersion,
+ final TestingSessionListener pceSessionListener) throws Exception {
assertNotNull(pceSessionListener.getSession());
assertTrue(pceSessionListener.isUp());
final List<Message> messages;
checkReceivedMessages(pceSessionListener, expectedTotalMessages);
if (startAtNumberLsp.isPresent()) {
messages = pceSessionListener.messages().subList(startAtNumberLsp.get(),
- startAtNumberLsp.get() + expectedNumberOfLsp);
+ startAtNumberLsp.get() + expectedNumberOfLsp);
} else {
messages = pceSessionListener.messages();
}
- checkEquals(()-> checkSequequenceDBVersionSync(pceSessionListener, expectedDBVersion));
+ checkEquals(() -> checkSequequenceDBVersionSync(pceSessionListener, expectedDBVersion));
assertEquals(expectedNumberOfLsp, messages.size());
final PCEPSession session = pceSessionListener.getSession();
checkSession(session, DEAD_TIMER, KEEP_ALIVE);
assertTrue(session.getRemoteTlvs().getAugmentation(Tlvs1.class).getStateful()
- .getAugmentation(Stateful1.class).isInitiation());
+ .getAugmentation(Stateful1.class).isInitiation());
final BigInteger pceDBVersion = session.localSessionCharacteristics().getAugmentation(Tlvs3.class)
- .getLspDbVersion().getLspDbVersionValue();
+ .getLspDbVersion().getLspDbVersionValue();
assertEquals(startingDBVersion, pceDBVersion);
}
- protected static void checkSession(final PCEPSession session, final int expectedDeadTimer,
- final int expectedKeepAlive) {
+ static void checkSession(final PCEPSession session, final int expectedDeadTimer,
+ final int expectedKeepAlive) {
assertNotNull(session);
assertEquals(expectedDeadTimer, session.getPeerPref().getDeadtimer().shortValue());
assertEquals(expectedKeepAlive, session.getPeerPref().getKeepalive().shortValue());
final Stateful1 stateful = session.getRemoteTlvs().getAugmentation(Tlvs1.class)
- .getStateful().getAugmentation(Stateful1.class);
+ .getStateful().getAugmentation(Stateful1.class);
assertTrue(stateful.isInitiation());
}
protected static void checkSequequenceDBVersionSync(final TestingSessionListener pceSessionListener,
- final BigInteger expectedDbVersion) {
+ final BigInteger expectedDbVersion) {
for (final Message msg : pceSessionListener.messages()) {
final List<Reports> pcrt = ((Pcrpt) msg).getPcrptMessage().getReports();
for (final Reports report : pcrt) {
final Lsp lsp = report.getLsp();
if (lsp.getPlspId().getValue() == 0) {
- assertEquals(false, lsp.isSync().booleanValue());
+ assertEquals(false, lsp.isSync());
} else {
- assertEquals(true, lsp.isSync().booleanValue());
+ 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.rev150714.Tlvs1.class)
}
}
- protected Future<PCEPSession> createPCCSession(final BigInteger dbVersion) {
+ Future<PCEPSession> createPCCSession(final BigInteger dbVersion) {
final PCCDispatcherImpl pccDispatcher = new PCCDispatcherImpl(this.messageRegistry);
final PCEPSessionNegotiatorFactory<PCEPSessionImpl> snf = getSessionNegotiatorFactory();
final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(3, this.localAddress.getAddress(),
- 0, -1, new HashedWheelTimer(), Optional.absent());
+ 0, -1, new HashedWheelTimer(), Optional.absent());
- return pccDispatcher.createClient(this.remoteAddress, -1,
- () -> {
- this.pccSessionListener = new PCCSessionListener(1, tunnelManager, false);
- return this.pccSessionListener;
- }, snf, null, 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() {
return new DefaultPCEPSessionNegotiatorFactory(new BasePCEPSessionProposalFactory(DEAD_TIMER, KEEP_ALIVE,
- getCapabilities()), 0);
+ getCapabilities()), 0);
}
- protected TestingSessionListener getListener(final TestingSessionListenerFactory factory) {
+ TestingSessionListener getListener(final TestingSessionListenerFactory factory) {
return checkSessionListenerNotNull(factory, this.localAddress.getHostString());
}
}
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 localAddress2 = "127.0.0.2";
+ private final String localIpAddress = "127.0.0.1";
+ private final String[] mainInput = new String[]{"--local-address", localIpAddress,
+ "--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.localIpAddress);
checkSession(sessionListener.getSession(), 40, 10);
}
@Test
public void testMockPCCToManyPCE() throws Exception {
- final String localAddress2 = "127.0.0.2";
final InetSocketAddress serverAddress2 = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
final InetSocketAddress serverAddress3 = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
final InetSocketAddress serverAddress4 = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
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(),
- "--pcc", "2"});
+ Main.main(new String[]{"--local-address", this.localIpAddress, "--remote-address",
+ InetSocketAddressUtil.toHostAndPort(serverAddress2).toString() + ","
+ + InetSocketAddressUtil.toHostAndPort(serverAddress3).toString() + ","
+ + InetSocketAddressUtil.toHostAndPort(serverAddress4).toString(), "--pcc", "2"});
Thread.sleep(1000);
//PCE1
final int numMessages = 2;
- checkSessionListener(numMessages, channel, factory, this.localAddress.getHostString());
- checkSessionListener(numMessages, channel, factory, localAddress2);
+ checkSessionListener(numMessages, channel, factory, this.localIpAddress);
+ checkSessionListener(numMessages, channel, factory, this.localAddress2);
//PCE2
- checkSessionListener(numMessages, channel2, factory2, this.localAddress.getHostString());
- checkSessionListener(numMessages, channel2, factory2, localAddress2);
+ checkSessionListener(numMessages, channel2, factory2, this.localIpAddress);
+ checkSessionListener(numMessages, channel2, factory2, this.localAddress2);
//PCE3
- checkSessionListener(numMessages, channel3, factory3, this.localAddress.getHostString());
- 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();
- }
+ checkSessionListener(numMessages, channel3, factory3, this.localIpAddress);
+ checkSessionListener(numMessages, channel3, factory3, this.localAddress2);
}
@Override