The timers have an uint8 range by definition, correct that.
JIRA: BGPCEP-1017
Change-Id: Ie2f59a1859c54883730cd2fd89b5f7efc67a8c7e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
grouping pcep-session-timers {
leaf dead-timer-value {
- // FIXME: uint8
- type uint16;
+ type uint8;
default 120;
units seconds;
}
leaf keep-alive-timer-value {
- // FIXME: uint8
- type uint16;
+ type uint8;
default 30;
units seconds;
}
*/
package org.opendaylight.protocol.pcep.impl;
-import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import java.net.InetSocketAddress;
private static final int KA_TO_DEADTIMER_RATIO = 4;
private final @NonNull List<PCEPCapability> capabilities;
- private final int keepAlive;
- private final int deadTimer;
+ private final @NonNull Uint8 keepAlive;
+ private final @NonNull Uint8 deadTimer;
public BasePCEPSessionProposalFactory(final PcepSessionTimers timers, final List<PCEPCapability> capabilities) {
- this(timers.getDeadTimerValue().toJava(), timers.getKeepAliveTimerValue().toJava(), capabilities);
+ this(timers.getDeadTimerValue(), timers.getKeepAliveTimerValue(), capabilities);
}
- public BasePCEPSessionProposalFactory(final int deadTimer, final int keepAlive,
+ public BasePCEPSessionProposalFactory(final Uint8 deadTimer, final Uint8 keepAlive,
final List<PCEPCapability> capabilities) {
- if (keepAlive != 0) {
- checkArgument(keepAlive >= 1, "Minimum value for keep-alive-timer-value is 1");
- if (deadTimer != 0 && deadTimer / keepAlive != KA_TO_DEADTIMER_RATIO) {
- LOG.warn("dead-timer-value should be {} times greater than keep-alive-timer-value",
- KA_TO_DEADTIMER_RATIO);
- }
- }
-
- this.deadTimer = deadTimer;
- this.keepAlive = keepAlive;
+ this.keepAlive = requireNonNull(keepAlive);
this.capabilities = requireNonNull(capabilities);
- }
- private void addTlvs(final InetSocketAddress address, final TlvsBuilder builder) {
- for (final PCEPCapability capability : capabilities) {
- capability.setCapabilityProposal(address, builder);
+ if (!Uint8.ZERO.equals(keepAlive)) {
+ this.deadTimer = requireNonNull(deadTimer);
+ if (!Uint8.ZERO.equals(deadTimer) && deadTimer.toJava() / keepAlive.toJava() != KA_TO_DEADTIMER_RATIO) {
+ LOG.warn("dead-timer-value ({}) should be {} times greater than keep-alive-timer-value ({}}",
+ deadTimer, KA_TO_DEADTIMER_RATIO, keepAlive);
+ }
+ } else {
+ this.deadTimer = Uint8.ZERO;
}
}
@Override
public Open getSessionProposal(final InetSocketAddress address, final int sessionId,
final PCEPPeerProposal peerProposal) {
- final OpenBuilder oBuilder = new OpenBuilder()
- .setSessionId(Uint8.valueOf(sessionId))
- .setKeepalive(Uint8.valueOf(keepAlive));
- if (keepAlive == 0) {
- oBuilder.setDeadTimer(Uint8.ZERO);
- } else {
- oBuilder.setDeadTimer(Uint8.valueOf(deadTimer));
+ final var builder = new TlvsBuilder();
+ for (final var capability : capabilities) {
+ capability.setCapabilityProposal(address, builder);
}
- final TlvsBuilder builder = new TlvsBuilder();
- addTlvs(address, builder);
-
if (peerProposal != null) {
peerProposal.setPeerSpecificProposal(address, builder);
}
- return oBuilder.setTlvs(builder.build()).build();
+
+ return new OpenBuilder()
+ .setSessionId(Uint8.valueOf(sessionId))
+ .setKeepalive(keepAlive)
+ .setDeadTimer(deadTimer)
+ .setTlvs(builder.build())
+ .build();
}
@Override
import java.util.Queue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.lock.qual.GuardedBy;
import org.opendaylight.protocol.pcep.PCEPCloseTermination;
import org.opendaylight.protocol.pcep.PCEPSession;
this.maxUnknownMessages = maxUnknownMessages;
}
- if (getDeadTimerValue() != 0) {
- channel.eventLoop().schedule(this::handleDeadTimer, getDeadTimerValue(), TimeUnit.SECONDS);
+ final var deadValue = getDeadTimerValue();
+ if (deadValue != 0) {
+ channel.eventLoop().schedule(this::handleDeadTimer, deadValue, TimeUnit.SECONDS);
}
-
- if (getKeepAliveTimerValue() != 0) {
- channel.eventLoop().schedule(this::handleKeepaliveTimer, getKeepAliveTimerValue(), TimeUnit.SECONDS);
+ final var keepAliveValue = getKeepAliveTimerValue();
+ if (keepAliveValue != 0) {
+ channel.eventLoop().schedule(this::handleKeepaliveTimer, keepAliveValue, TimeUnit.SECONDS);
}
LOG.info("Session {}[{}] <-> {}[{}] started",
sessionState = new PCEPSessionState(remoteOpen, localOpen, channel);
}
- public final Integer getKeepAliveTimerValue() {
- return localOpen.getKeepalive().intValue();
+ public final @NonNegative short getKeepAliveTimerValue() {
+ return localOpen.getKeepalive().toJava();
}
- public final Integer getDeadTimerValue() {
- return remoteOpen.getDeadTimer().intValue();
+ public final @NonNegative short getDeadTimerValue() {
+ return remoteOpen.getDeadTimer().toJava();
}
/**
import org.opendaylight.protocol.pcep.spi.MessageRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.DefaultPCEPExtensionConsumerContext;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
+import org.opendaylight.yangtools.yang.common.Uint8;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class PCEPDispatcherImplTest {
- private static final short DEAD_TIMER = 120;
- private static final short KEEP_ALIVE = 30;
+ private static final Uint8 DEAD_TIMER = Uint8.valueOf(120);
+ private static final Uint8 KEEP_ALIVE = Uint8.valueOf(30);
private static final int RETRY_TIMER = 0;
private static final int CONNECT_TIMEOUT = 500;
assertTrue(futureChannel.channel().isActive());
assertEquals(clientAddr1.getAddress().getHostAddress(), session1.getPeerPref().getIpAddress());
- assertEquals(DEAD_TIMER, session1.getDeadTimerValue().shortValue());
- assertEquals(KEEP_ALIVE, session1.getKeepAliveTimerValue().shortValue());
+ assertEquals(DEAD_TIMER.toJava(), session1.getDeadTimerValue());
+ assertEquals(KEEP_ALIVE.toJava(), session1.getKeepAliveTimerValue());
assertEquals(clientAddr2.getAddress().getHostAddress(), session2.getPeerPref().getIpAddress());
- assertEquals(DEAD_TIMER, session2.getDeadTimerValue().shortValue());
- assertEquals(KEEP_ALIVE, session2.getKeepAliveTimerValue().shortValue());
+ assertEquals(DEAD_TIMER.toJava(), session2.getDeadTimerValue());
+ assertEquals(KEEP_ALIVE.toJava(), session2.getKeepAliveTimerValue());
session1.close();
session2.close();
RETRY_TIMER, CONNECT_TIMEOUT, SimpleSessionListener::new).get();
assertEquals(clientAddr.getAddress(), session1.getRemoteAddress());
- assertEquals(DEAD_TIMER, session1.getDeadTimerValue().shortValue());
- assertEquals(KEEP_ALIVE, session1.getKeepAliveTimerValue().shortValue());
+ assertEquals(DEAD_TIMER.toJava(), session1.getDeadTimerValue());
+ assertEquals(KEEP_ALIVE.toJava(), session1.getKeepAliveTimerValue());
session1.closeChannel().sync();
final PCEPSessionImpl session2 = pccMock.createClient(clientAddr,
RETRY_TIMER, CONNECT_TIMEOUT, SimpleSessionListener::new).get();
assertEquals(clientAddr.getAddress(), session1.getRemoteAddress());
- assertEquals(DEAD_TIMER, session2.getDeadTimerValue().shortValue());
- assertEquals(KEEP_ALIVE, session2.getKeepAliveTimerValue().shortValue());
+ assertEquals(DEAD_TIMER.toJava(), session2.getDeadTimerValue());
+ assertEquals(KEEP_ALIVE.toJava(), session2.getKeepAliveTimerValue());
session2.close();
}
import org.opendaylight.protocol.pcep.ietf.stateful.PCEPStatefulCapability;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final int DEFAULT_REMOTE_PORT = 4189;
private static final int DEFAULT_LOCAL_PORT = 0;
- private static final short DEFAULT_KEEP_ALIVE = 30;
- private static final short DEFAULT_DEAD_TIMER = 120;
+ private static final Uint8 DEFAULT_KEEP_ALIVE = Uint8.valueOf(30);
+ private static final Uint8 DEFAULT_DEAD_TIMER = Uint8.valueOf(120);
private static final InetAddress LOCALHOST = InetAddresses.forString("127.0.0.1");
- private static boolean triggeredInitSync = Boolean.FALSE;
- private static boolean includeDbv = Boolean.FALSE;
- private static boolean incrementalSync = Boolean.FALSE;
- private static boolean triggeredResync = Boolean.FALSE;
+ private static boolean triggeredInitSync = false;
+ private static boolean includeDbv = false;
+ private static boolean incrementalSync = false;
+ private static boolean triggeredResync = false;
private static Uint64 syncOptDBVersion;
private static int reconnectAfterXSeconds;
private static int disonnectAfterXSeconds;
int lsps = 1;
boolean pcError = false;
final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- short ka = DEFAULT_KEEP_ALIVE;
- short dt = DEFAULT_DEAD_TIMER;
+ Uint8 ka = DEFAULT_KEEP_ALIVE;
+ Uint8 dt = DEFAULT_DEAD_TIMER;
String password = null;
long reconnectTime = -1;
int redelegationTimeout = 0;
break;
case "--keepalive":
case "-ka":
- ka = Short.valueOf(args[++argIdx]);
+ ka = Uint8.valueOf(args[++argIdx]);
break;
case "--deadtimer":
case "-d":
- dt = Short.valueOf(args[++argIdx]);
+ dt = Uint8.valueOf(args[++argIdx]);
break;
case "--password":
password = args[++argIdx];
break;
case "--state-sync-avoidance":
//"--state-sync-avoidance 10, 5, 10
- includeDbv = Boolean.TRUE;
+ includeDbv = true;
final Long dbVersionAfterReconnect = Long.valueOf(args[++argIdx]);
disonnectAfterXSeconds = Integer.parseInt(args[++argIdx]);
reconnectAfterXSeconds = Integer.parseInt(args[++argIdx]);
break;
case "--incremental-sync-procedure":
//TODO Check that DBv > Lsp always ??
- includeDbv = Boolean.TRUE;
- incrementalSync = Boolean.TRUE;
+ includeDbv = true;
+ incrementalSync = true;
//Version of database to be used after restart
final Long initialDbVersionAfterReconnect = Long.valueOf(args[++argIdx]);
disonnectAfterXSeconds = Integer.parseInt(args[++argIdx]);
syncOptDBVersion = Uint64.valueOf(initialDbVersionAfterReconnect);
break;
case "--triggered-initial-sync":
- triggeredInitSync = Boolean.TRUE;
+ triggeredInitSync = true;
break;
case "--triggered-re-sync":
- triggeredResync = Boolean.TRUE;
+ triggeredResync = true;
break;
default:
LOG.warn("WARNING: Unrecognized argument: {}", args[argIdx]);
*/
package org.opendaylight.protocol.pcep.pcc.mock;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.Lists;
import com.google.common.net.InetAddresses;
import io.netty.util.HashedWheelTimer;
import org.opendaylight.protocol.pcep.spi.MessageRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.DefaultPCEPExtensionConsumerContext;
import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
final class PCCsBuilder {
private final int lsps;
private final int pccCount;
private final InetSocketAddress localAddress;
private final List<InetSocketAddress> remoteAddress;
- private final short keepAlive;
- private final short deadTimer;
+ private final Uint8 keepAlive;
+ private final Uint8 deadTimer;
private final String password;
private final long reconnectTime;
private final int redelegationTimeout;
PCCsBuilder(final int lsps, final boolean pcError, final int pccCount,
final @NonNull InetSocketAddress localAddress, final @NonNull List<InetSocketAddress> remoteAddress,
- final short keepAlive, final short deadTimer, final @Nullable String password, final long reconnectTime,
- final int redelegationTimeout, final int stateTimeout, final @NonNull PCEPCapability pcepCapabilities) {
+ final @NonNull Uint8 keepAlive, final @NonNull Uint8 deadTimer, final @Nullable String password,
+ final long reconnectTime, final int redelegationTimeout, final int stateTimeout,
+ final @NonNull PCEPCapability pcepCapabilities) {
this.lsps = lsps;
this.pcError = pcError;
this.pccCount = pccCount;
this.localAddress = localAddress;
this.remoteAddress = remoteAddress;
- this.keepAlive = keepAlive;
- this.deadTimer = deadTimer;
+ this.keepAlive = requireNonNull(keepAlive);
+ this.deadTimer = requireNonNull(deadTimer);
this.password = password;
this.reconnectTime = reconnectTime;
this.redelegationTimeout = redelegationTimeout;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.concurrent.Future;
import java.net.InetSocketAddress;
-import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.opendaylight.protocol.pcep.spi.MessageRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.DefaultPCEPExtensionConsumerContext;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
+import org.opendaylight.yangtools.yang.common.Uint8;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class PCCDispatcherImplTest {
- private static final PCEPSessionProposalFactory PROPOSAL = new BasePCEPSessionProposalFactory(10, 40,
- new ArrayList<>());
+ private static final PCEPSessionProposalFactory PROPOSAL = new BasePCEPSessionProposalFactory(Uint8.TEN,
+ Uint8.valueOf(40), List.of());
private final DefaultPCEPSessionNegotiatorFactory nf = new DefaultPCEPSessionNegotiatorFactory(PROPOSAL, 0);
private PCCDispatcherImpl dispatcher;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
public abstract class PCCMockCommon {
- private static final short KEEP_ALIVE = 30;
- private static final short DEAD_TIMER = 120;
+ private static final Uint8 KEEP_ALIVE = Uint8.valueOf(30);
+ private static final Uint8 DEAD_TIMER = Uint8.valueOf(120);
private static final long SLEEP_FOR = 50;
private final int port = InetSocketAddressUtil.getRandomPort();
final InetSocketAddress remoteAddress = InetSocketAddressUtil
assertEquals(startingDBVersion, pceDBVersion);
}
- static void checkSession(final PCEPSession session, final int expectedDeadTimer,
- final int expectedKeepAlive) {
+ static void checkSession(final PCEPSession session, final Uint8 expectedDeadTimer,
+ final Uint8 expectedKeepAlive) {
assertNotNull(session);
- assertEquals(expectedDeadTimer, session.getPeerPref().getDeadtimer().shortValue());
- assertEquals(expectedKeepAlive, session.getPeerPref().getKeepalive().shortValue());
+ assertEquals(expectedDeadTimer, session.getPeerPref().getDeadtimer());
+ assertEquals(expectedKeepAlive, session.getPeerPref().getKeepalive());
final Stateful1 stateful = session.getRemoteTlvs().augmentation(Tlvs1.class)
.getStateful().augmentation(Stateful1.class);
assertTrue(stateful.getInitiation());
import org.junit.Test;
import org.opendaylight.protocol.pcep.PCEPCapability;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
+import org.opendaylight.yangtools.yang.common.Uint8;
public final class PCCMockTest extends PCCMockCommon {
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",
+ "--remote-address", InetSocketAddressUtil.toHostAndPort(remoteAddress).toString(), "--pcc", "1",
"--lsp", "3", "--log-level", "DEBUG", "-ka", "10", "-d", "40", "--reconnect", "-1",
"--redelegation-timeout", "0", "--state-timeout", "-1"};
@Test
public void testSessionEstablishment() throws Exception {
final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
- final Channel channel = createServer(factory, this.remoteAddress);
- Main.main(this.mainInput);
+ final Channel channel = createServer(factory, remoteAddress);
+ Main.main(mainInput);
Thread.sleep(1000);
//3 reported LSPs + syc
final int numMessages = 4;
final TestingSessionListener sessionListener = checkSessionListener(numMessages, channel, factory,
- this.localIpAddress);
- checkSession(sessionListener.getSession(), 40, 10);
+ localIpAddress);
+ checkSession(sessionListener.getSession(), Uint8.valueOf(40), Uint8.TEN);
}
final Channel channel2 = createServer(factory2, serverAddress3);
final Channel channel3 = createServer(factory3, serverAddress4);
- Main.main(new String[]{"--local-address", this.localIpAddress, "--remote-address",
+ Main.main(new String[]{"--local-address", 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.localIpAddress);
- checkSessionListener(numMessages, channel, factory, this.localAddress2);
+ checkSessionListener(numMessages, channel, factory, localIpAddress);
+ checkSessionListener(numMessages, channel, factory, localAddress2);
//PCE2
- checkSessionListener(numMessages, channel2, factory2, this.localIpAddress);
- checkSessionListener(numMessages, channel2, factory2, this.localAddress2);
+ checkSessionListener(numMessages, channel2, factory2, localIpAddress);
+ checkSessionListener(numMessages, channel2, factory2, localAddress2);
//PCE3
- checkSessionListener(numMessages, channel3, factory3, this.localIpAddress);
- checkSessionListener(numMessages, channel3, factory3, this.localAddress2);
+ checkSessionListener(numMessages, channel3, factory3, localIpAddress);
+ checkSessionListener(numMessages, channel3, factory3, localAddress2);
}
@Override
import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
import org.opendaylight.protocol.pcep.spi.MessageRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionConsumerContext;
+import org.opendaylight.yangtools.yang.common.Uint8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+ "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 Uint8 KA_DEFAULT = Uint8.valueOf(30);
private static final int MAX_UNKNOWN_MESSAGES = 5;
private Main() {
}
InetSocketAddress address = null;
- int keepAliveValue = KA_DEFAULT;
- int deadTimerValue = 0;
+ Uint8 keepAliveValue = KA_DEFAULT;
+ Uint8 deadTimerValue = Uint8.ZERO;
boolean stateful = false;
boolean active = false;
boolean instant = false;
address = new InetSocketAddress(InetAddress.getByName(ip[0]), Integer.parseInt(ip[1]));
pos++;
} else if (args[pos].equalsIgnoreCase("-d") || args[pos].equalsIgnoreCase("--deadtimer")) {
- deadTimerValue = Integer.parseInt(args[pos + 1]);
+ deadTimerValue = Uint8.valueOf(args[pos + 1]);
pos++;
} else if (args[pos].equalsIgnoreCase("-ka") || args[pos].equalsIgnoreCase("--keepalive")) {
- keepAliveValue = Integer.parseInt(args[pos + 1]);
+ keepAliveValue = Uint8.valueOf(args[pos + 1]);
pos++;
} else if (args[pos].equalsIgnoreCase("--stateful")) {
stateful = true;
}
pos++;
}
- if (deadTimerValue != 0 && deadTimerValue != keepAliveValue * KA_TO_DEADTIMER_RATIO) {
+ if (Uint8.ZERO.equals(deadTimerValue)) {
+ final var newValue = keepAliveValue.toJava() * KA_TO_DEADTIMER_RATIO;
+ deadTimerValue = newValue <= Uint8.MAX_VALUE.toJava() ? Uint8.valueOf(newValue) : Uint8.MAX_VALUE;
+ } else if (deadTimerValue.toJava() != keepAliveValue.toJava() * KA_TO_DEADTIMER_RATIO) {
LOG.warn("WARNING: The value of DeadTimer should be 4 times the value of KeepAlive.");
}
- if (deadTimerValue == 0) {
- deadTimerValue = keepAliveValue * KA_TO_DEADTIMER_RATIO;
- }
final List<PCEPCapability> caps = new ArrayList<>();
caps.add(new PCEPStatefulCapability(stateful, active, instant, false, false, false, false));
*/
package org.opendaylight.protocol.pcep.testtool;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import com.google.common.net.HostAndPort;
import java.net.InetSocketAddress;
-import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.opendaylight.protocol.concepts.KeyMapping;
-import org.opendaylight.protocol.pcep.PCEPCapability;
-import org.opendaylight.protocol.pcep.PCEPSession;
-import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl;
import org.opendaylight.protocol.pcep.spi.pojo.DefaultPCEPExtensionConsumerContext;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
+import org.opendaylight.yangtools.yang.common.Uint8;
public final class PCCMock {
private PCCMock() {
}
public static void main(final String[] args) throws InterruptedException, ExecutionException {
- Preconditions.checkArgument(args.length > 0, "Host and port of server must be provided.");
- final List<PCEPCapability> caps = new ArrayList<>();
- final PCEPSessionProposalFactory proposal = new BasePCEPSessionProposalFactory((short) 120, (short) 30, caps);
- final PCEPSessionNegotiatorFactory<? extends PCEPSession> snf
- = new DefaultPCEPSessionNegotiatorFactory(proposal, 0);
- final HostAndPort serverHostAndPort = HostAndPort.fromString(args[0]);
- final InetSocketAddress serverAddr = new InetSocketAddress(serverHostAndPort.getHost(), serverHostAndPort
- .getPortOrDefault(12345));
- final InetSocketAddress clientAddr = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(0);
+ checkArgument(args.length > 0, "Host and port of server must be provided.");
+ final var proposal = new BasePCEPSessionProposalFactory(Uint8.valueOf(120), Uint8.valueOf(30), List.of());
+ final var snf = new DefaultPCEPSessionNegotiatorFactory(proposal, 0);
+ final var serverHostAndPort = HostAndPort.fromString(args[0]);
+ final var serverAddr = new InetSocketAddress(serverHostAndPort.getHost(),
+ serverHostAndPort.getPortOrDefault(12345));
+ final var clientAddr = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(0);
- try (PCCDispatcherImpl pccDispatcher = new PCCDispatcherImpl(
+ try (var pccDispatcher = new PCCDispatcherImpl(
new DefaultPCEPExtensionConsumerContext().getMessageHandlerRegistry())) {
pccDispatcher.createClient(serverAddr, -1, SimpleSessionListener::new, snf, KeyMapping.of(), clientAddr)
.get();