コード例 #1
0
  public void register(ProcessConf conf) {
    if (conf == null)
      throw new NullPointerException("must specify non-null process configuration.");

    __log.debug("register: " + conf.getProcessId());

    // Ok, IO out of the way, we will mod the server state, so need to get a
    // lock.

    // If the process is already active, do nothing.
    if (_registeredProcesses.containsKey(conf.getProcessId())) {
      __log.debug(
          "skipping doRegister" + conf.getProcessId() + ") -- process is already registered");
      return;
    }

    __log.debug("Registering process " + conf.getProcessId() + " with server.");

    ODEProcess process = new ODEProcess(this, conf, null, _myRoleMexCache);

    for (Endpoint e : process.getServiceNames()) {
      __log.debug("Register process: serviceId=" + e + ", process=" + process);
      // Get the list of processes associated with the given service
      List<ODEProcess> processes = _serviceMap.get(e.serviceName);
      if (processes == null) {
        // Create an empty list, if no processes were associated
        _serviceMap.put(e.serviceName, processes = new ArrayList<ODEProcess>());
      }
      // Remove any older version of the process from the list
      for (int i = 0; i < processes.size(); i++) {
        ODEProcess cachedVersion = processes.get(i);
        __log.debug(
            "cached version "
                + cachedVersion.getPID()
                + " vs registering version "
                + process.getPID());
        if (cachedVersion.getProcessType().equals(process.getProcessType())) {
          processes.remove(cachedVersion);
        }
      }
      // Add the given process to the list associated with the given service
      processes.add(process);
    }

    process.activate(_contexts);

    _registeredProcesses.put(process.getPID(), process);
    if (_dehydrationPolicy == null) process.hydrate();

    __log.info(__msgs.msgProcessRegistered(conf.getProcessId()));
  }