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;
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 = Collections
.singletonList(new InetSocketAddress(LOCALHOST, DEFAULT_REMOTE_PORT));
import com.google.common.collect.Lists;
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.Nonnull;
import org.opendaylight.protocol.pcep.pcc.mock.api.LspType;
import org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder;
final class PCCTunnelBuilder {
- private static final Subobject DEFAULT_ENDPOINT_HOP = getDefaultEROEndpointHop();
+ 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";
- static final int PCC_DELEGATION = -1;
+ private static final Subobject DEFAULT_ENDPOINT_HOP = getDefaultEROEndpointHop();
private PCCTunnelBuilder() {
throw new UnsupportedOperationException();
}
- @Nonnull
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 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;
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());
}
private void createPCC(@Nonnull final InetSocketAddress plocalAddress,
- final PCCTunnelManager tunnelManager, final BigInteger initialDBVersion)
- throws InterruptedException, ExecutionException {
+ 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(
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(
new PCEPSessionNegotiatorFactoryDependencies() {
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;
}
private final int port = InetSocketAddressUtil.getRandomPort();
final InetSocketAddress remoteAddress = InetSocketAddressUtil
.getRandomLoopbackInetSocketAddress(this.port);
- final InetSocketAddress localAddress = new InetSocketAddress("127.0.0.1", this.port);
+ final InetSocketAddress localAddress = InetSocketAddressUtil
+ .getRandomLoopbackInetSocketAddress(this.port);
PCCSessionListener pccSessionListener;
private PCEPDispatcher pceDispatcher;
private PCEPExtensionProviderContext extensionProvider;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
public final class PCCMockTest extends PCCMockCommon {
- private final String[] mainInput = new String[]{"--local-address", this.localAddress.getHostString(),
+ 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"};
//3 reported LSPs + syc
final int numMessages = 4;
final TestingSessionListener sessionListener = checkSessionListener(numMessages, channel, factory,
- this.localAddress.getHostString());
+ 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);
+ checkSessionListener(numMessages, channel3, factory3, this.localIpAddress);
+ checkSessionListener(numMessages, channel3, factory3, this.localAddress2);
}
@Override