Пример #1
0
  Pool(
      IbisCapabilities capabilities,
      TypedProperties properties,
      Registry registry,
      Statistics statistics) {
    this.registry = registry;

    this.statistics = statistics;
    if (statistics != null) {
      statistics.newPoolSize(0);
    }

    if (properties.getBooleanProperty(RegistryProperties.TREE)) {
      members = new TreeMemberSet();
    } else {
      members = new ListMemberSet();
    }

    elections = new ElectionSet();
    eventList = new EventList();

    time = -1;
    initialized = false;
    closed = false;
    closeEvent = null;

    terminated = false;
    terminateEvent = null;

    stopped = false;

    // get the pool ....
    poolName = properties.getProperty(IbisProperties.POOL_NAME);
    if (poolName == null) {
      throw new IbisConfigurationException(
          "cannot initialize registry, property " + IbisProperties.POOL_NAME + " is not specified");
    }

    closedWorld = capabilities.hasCapability(IbisCapabilities.CLOSED_WORLD);

    if (closedWorld) {
      try {
        size = properties.getIntProperty(IbisProperties.POOL_SIZE);
      } catch (final NumberFormatException e) {
        throw new IbisConfigurationException(
            "could not start registry for a closed world ibis, "
                + "required property: "
                + IbisProperties.POOL_SIZE
                + " undefined",
            e);
      }
    } else {
      size = -1;
    }

    heartbeatInterval = properties.getIntProperty(RegistryProperties.HEARTBEAT_INTERVAL) * 1000;
  }
Пример #2
0
  CommunicationHandler(
      TypedProperties properties,
      Registry registry,
      MemberSet members,
      ElectionSet elections,
      Statistics statistics)
      throws IbisConfigurationException, IOException {
    this.registry = registry;
    this.pool = members;
    this.elections = elections;
    this.statistics = statistics;

    nrOfLeavesSend = properties.getIntProperty(RegistryProperties.LEAVES_SEND);

    gossipSize = properties.getIntProperty(RegistryProperties.GOSSIP_COUNT);

    String clientID = properties.getProperty(Ibis.ID_PROPERTY);
    Client client = Client.getOrCreateClient(clientID, properties, 0);
    socketFactory = client.getFactory();

    serverSocket = socketFactory.createServerSocket(0, CONNECTION_BACKLOG, null);

    VirtualSocketAddress serverAddress = client.getServiceAddress(Protocol.VIRTUAL_PORT);

    String[] bootstrapStringList = properties.getStringList(RegistryProperties.BOOTSTRAP_LIST);
    VirtualSocketAddress[] bootstrapList = new VirtualSocketAddress[bootstrapStringList.length];

    for (int i = 0; i < bootstrapList.length; i++) {
      bootstrapList[i] = new VirtualSocketAddress(bootstrapStringList[i]);
    }

    logger.debug("local address = " + serverSocket.getLocalSocketAddress());
    logger.debug("server address = " + serverAddress);

    arrg =
        new ARRG(
            serverSocket.getLocalSocketAddress(),
            false,
            bootstrapList,
            serverAddress,
            registry.getPoolName(),
            socketFactory,
            statistics);
  }