public PccTunnelManagerImpl(
     final int lspsCount,
     final InetAddress address,
     final int redelegationTimeout,
     final int stateTimeout,
     final Timer timer) {
   Preconditions.checkArgument(lspsCount >= 0);
   Preconditions.checkNotNull(address);
   this.redelegationTimeout = redelegationTimeout;
   this.stateTimeout = stateTimeout;
   this.plspIDsCounter = new AtomicLong(lspsCount);
   this.address = InetAddresses.toAddrString(Preconditions.checkNotNull(address));
   this.timer = Preconditions.checkNotNull(timer);
   for (int i = 1; i <= lspsCount; i++) {
     final Tunnel tunnel =
         new Tunnel(
             MsgBuilderUtil.getDefaultPathName(this.address, i),
             PCC_DELEGATION,
             LspType.PCC_LSP,
             createPath(Lists.newArrayList(DEFAULT_ENDPOINT_HOP)));
     this.tunnels.put(new PlspId((long) i), tunnel);
   }
 }
Exemple #2
0
  public NodeInfo(
      String environment,
      String pool,
      String nodeId,
      InetAddress internalIp,
      String internalHostname,
      InetAddress bindIp,
      String externalAddress,
      String location,
      String binarySpec,
      String configSpec) {
    Preconditions.checkNotNull(environment, "environment is null");
    Preconditions.checkNotNull(pool, "pool is null");
    Preconditions.checkArgument(
        environment.matches(NodeConfig.ENV_REGEXP),
        String.format("environment '%s' is invalid", environment));
    Preconditions.checkArgument(
        pool.matches(NodeConfig.POOL_REGEXP), String.format("pool '%s' is invalid", pool));

    this.environment = environment;
    this.pool = pool;

    if (nodeId != null) {
      this.nodeId = nodeId;
    } else {
      this.nodeId = UUID.randomUUID().toString();
    }

    if (location != null) {
      this.location = location;
    } else {
      this.location = "/" + this.nodeId;
    }

    this.binarySpec = binarySpec;
    this.configSpec = configSpec;

    if (internalIp != null) {
      this.internalIp = internalIp;
    } else {
      this.internalIp = findPublicIp();
    }

    if (internalHostname != null) {
      Preconditions.checkArgument(
          internalHostname.matches(NodeConfig.HOSTNAME_REGEXP),
          String.format("hostname '%s' is invalid", environment));
      this.internalHostname = internalHostname;
    } else {
      this.internalHostname = findPublicHostname();
    }

    if (bindIp != null) {
      this.bindIp = bindIp;
    } else {
      this.bindIp = InetAddresses.fromInteger(0);
    }

    if (externalAddress != null) {
      this.externalAddress = externalAddress;
    } else {
      this.externalAddress = InetAddresses.toAddrString(this.internalIp);
    }
  }
 public void testToAddrStringIPv6() {
   assertEquals(
       "1:2:3:4:5:6:7:8", InetAddresses.toAddrString(InetAddresses.forString("1:2:3:4:5:6:7:8")));
   assertEquals(
       "2001:0:0:4::8", InetAddresses.toAddrString(InetAddresses.forString("2001:0:0:4:0:0:0:8")));
   assertEquals(
       "2001::4:5:6:7:8",
       InetAddresses.toAddrString(InetAddresses.forString("2001:0:0:4:5:6:7:8")));
   assertEquals(
       "2001:0:3:4:5:6:7:8",
       InetAddresses.toAddrString(InetAddresses.forString("2001:0:3:4:5:6:7:8")));
   assertEquals(
       "0:0:3::ffff", InetAddresses.toAddrString(InetAddresses.forString("0:0:3:0:0:0:0:ffff")));
   assertEquals(
       "::4:0:0:0:ffff",
       InetAddresses.toAddrString(InetAddresses.forString("0:0:0:4:0:0:0:ffff")));
   assertEquals(
       "::5:0:0:ffff", InetAddresses.toAddrString(InetAddresses.forString("0:0:0:0:5:0:0:ffff")));
   assertEquals(
       "1::4:0:0:7:8", InetAddresses.toAddrString(InetAddresses.forString("1:0:0:4:0:0:7:8")));
   assertEquals("::", InetAddresses.toAddrString(InetAddresses.forString("0:0:0:0:0:0:0:0")));
   assertEquals("::1", InetAddresses.toAddrString(InetAddresses.forString("0:0:0:0:0:0:0:1")));
   assertEquals(
       "2001:658:22a:cafe::",
       InetAddresses.toAddrString(InetAddresses.forString("2001:0658:022a:cafe::")));
   assertEquals("::102:304", InetAddresses.toAddrString(InetAddresses.forString("::1.2.3.4")));
 }
 public void testToAddrStringIPv4() {
   // Don't need to test IPv4 much; it just calls getHostAddress().
   assertEquals("1.2.3.4", InetAddresses.toAddrString(InetAddresses.forString("1.2.3.4")));
 }