Пример #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);
  }
Пример #3
0
  /**
   * Constructs an <code>Ibis</code> instance with the specified parameters.
   *
   * @param registryHandler the registryHandler.
   * @param capabilities the capabilities.
   * @param applicationTag an application level tag for this Ibis instance
   * @param portTypes the port types requested for this ibis implementation.
   * @param userProperties the properties as provided by the Ibis factory.
   */
  protected Ibis(
      RegistryEventHandler registryHandler,
      IbisCapabilities capabilities,
      Credentials credentials,
      byte[] applicationTag,
      PortType[] portTypes,
      Properties userProperties,
      IbisStarter starter)
      throws IbisCreationFailedException {

    if (capabilities == null) {
      throw new IbisConfigurationException("capabilities not specified");
    }

    this.capabilities = capabilities;
    this.portTypes = portTypes;
    this.starter = starter;

    this.properties = new TypedProperties();

    // bottom up add properties, starting with hard coded ones
    properties.addProperties(IbisProperties.getHardcodedProperties());
    properties.addProperties(userProperties);

    // set unique ID for this Ibis.
    properties.setProperty(ID_PROPERTY, UUID.randomUUID().toString());

    if (logger.isDebugEnabled()) {
      logger.debug("Ibis constructor: properties = " + properties);
    }

    receivePorts = new HashMap<String, ReceivePort>();
    sendPorts = new HashMap<String, SendPort>();

    if (registryHandler != null) {
      // Only install wrapper if user actually has an event handler.
      // Otherwise, registry downcalls won't work. There needs to be another
      // way to let an Ibis know of died Ibises. --Ceriel
      registryHandler = new RegistryEventHandlerWrapper(registryHandler, this);
    }
    try {
      registry =
          Registry.createRegistry(
              this.capabilities,
              registryHandler,
              properties,
              getData(),
              getImplementationVersion(),
              applicationTag,
              credentials);
    } catch (IbisConfigurationException e) {
      throw e;
    } catch (Throwable e) {
      throw new IbisCreationFailedException("Could not create registry", e);
    }

    ident = registry.getIbisIdentifier();

    if (properties.getBooleanProperty("ibis.vivaldi")) {
      try {
        vivaldiClient = new VivaldiClient(properties, registry);
      } catch (Exception e) {
        throw new IbisCreationFailedException("Could not create vivaldi client", e);
      }
    } else {
      vivaldiClient = null;
    }

    if (properties.getBooleanProperty("ibis.bytescount")) {
      sentBytesPerIbis = new HashMap<ibis.ipl.IbisIdentifier, Long>();
      receivedBytesPerIbis = new HashMap<ibis.ipl.IbisIdentifier, Long>();
    }

    if (properties.getBooleanProperty("ibis.managementclient")) {
      try {
        managementClient = new ManagementClient(properties, this);
      } catch (Throwable e) {
        throw new IbisCreationFailedException("Could not create management client", e);
      }
    } else {
      managementClient = null;
    }

    /*
     * // add bean to JMX try { MBeanServer mbs =
     * ManagementFactory.getPlatformMBeanServer(); ObjectName name = new
     * ObjectName("ibis.ipl.impl:type=Ibis"); mbs.registerMBean(this, name);
     * } catch (Exception e) { logger.warn("cannot registry MBean", e); }
     */
  }