예제 #1
0
 /** Sets the local member properties for broadcasting */
 @Override
 public void setLocalMemberProperties(
     String listenHost, int listenPort, int securePort, int udpPort) {
   properties.setProperty("tcpListenHost", listenHost);
   properties.setProperty("tcpListenPort", String.valueOf(listenPort));
   properties.setProperty("udpListenPort", String.valueOf(udpPort));
   properties.setProperty("tcpSecurePort", String.valueOf(securePort));
   try {
     if (localMember != null) {
       localMember.setHostname(listenHost);
       localMember.setPort(listenPort);
     } else {
       localMember = new MemberImpl(listenHost, listenPort, 0);
       localMember.setUniqueId(UUIDGenerator.randomUUID(true));
       localMember.setPayload(getPayload());
       localMember.setDomain(getDomain());
     }
     localMember.setSecurePort(securePort);
     localMember.setUdpPort(udpPort);
     localMember.getData(true, true);
   } catch (IOException x) {
     throw new IllegalArgumentException(x);
   }
 }
예제 #2
0
  @Override
  public void start(int level) throws java.lang.Exception {
    hasProperty(properties, "mcastPort");
    hasProperty(properties, "mcastAddress");
    hasProperty(properties, "memberDropTime");
    hasProperty(properties, "mcastFrequency");
    hasProperty(properties, "tcpListenPort");
    hasProperty(properties, "tcpListenHost");
    hasProperty(properties, "tcpSecurePort");
    hasProperty(properties, "udpListenPort");

    if (impl != null) {
      impl.start(level);
      return;
    }
    String host = getProperties().getProperty("tcpListenHost");
    int port = Integer.parseInt(getProperties().getProperty("tcpListenPort"));
    int securePort = Integer.parseInt(getProperties().getProperty("tcpSecurePort"));
    int udpPort = Integer.parseInt(getProperties().getProperty("udpListenPort"));

    if (localMember == null) {
      localMember = new MemberImpl(host, port, 100);
      localMember.setUniqueId(UUIDGenerator.randomUUID(true));
    } else {
      localMember.setHostname(host);
      localMember.setPort(port);
      localMember.setMemberAliveTime(100);
    }
    localMember.setSecurePort(securePort);
    localMember.setUdpPort(udpPort);
    if (this.payload != null) localMember.setPayload(payload);
    if (this.domain != null) localMember.setDomain(domain);
    localMember.setServiceStartTime(System.currentTimeMillis());
    java.net.InetAddress bind = null;
    if (properties.getProperty("mcastBindAddress") != null) {
      bind = java.net.InetAddress.getByName(properties.getProperty("mcastBindAddress"));
    }
    int ttl = -1;
    int soTimeout = -1;
    if (properties.getProperty("mcastTTL") != null) {
      try {
        ttl = Integer.parseInt(properties.getProperty("mcastTTL"));
      } catch (Exception x) {
        log.error(sm.getString("McastService.parseTTL", properties.getProperty("mcastTTL")), x);
      }
    }
    if (properties.getProperty("mcastSoTimeout") != null) {
      try {
        soTimeout = Integer.parseInt(properties.getProperty("mcastSoTimeout"));
      } catch (Exception x) {
        log.error(
            sm.getString("McastService.parseSoTimeout", properties.getProperty("mcastSoTimeout")),
            x);
      }
    }

    impl =
        new McastServiceImpl(
            localMember,
            Long.parseLong(properties.getProperty("mcastFrequency")),
            Long.parseLong(properties.getProperty("memberDropTime")),
            Integer.parseInt(properties.getProperty("mcastPort")),
            bind,
            java.net.InetAddress.getByName(properties.getProperty("mcastAddress")),
            ttl,
            soTimeout,
            this,
            this,
            Boolean.valueOf(properties.getProperty("localLoopbackDisabled", "false"))
                .booleanValue());
    String value = properties.getProperty("recoveryEnabled", "true");
    boolean recEnabled = Boolean.valueOf(value).booleanValue();
    impl.setRecoveryEnabled(recEnabled);
    int recCnt = Integer.parseInt(properties.getProperty("recoveryCounter", "10"));
    impl.setRecoveryCounter(recCnt);
    long recSlpTime = Long.parseLong(properties.getProperty("recoverySleepTime", "5000"));
    impl.setRecoverySleepTime(recSlpTime);

    impl.start(level);
  }