Ejemplo n.º 1
0
  ManagedServer(
      final String hostControllerName,
      final String serverName,
      final String authKey,
      final ProcessControllerClient processControllerClient,
      final URI managementURI,
      final TransformationTarget transformationTarget) {

    assert hostControllerName != null : "hostControllerName is null";
    assert serverName != null : "serverName is null";
    assert processControllerClient != null : "processControllerSlave is null";
    assert managementURI != null : "managementURI is null";

    this.hostControllerName = hostControllerName;
    this.serverName = serverName;
    this.serverProcessName = getServerProcessName(serverName);
    this.processControllerClient = processControllerClient;
    this.managementURI = managementURI;

    this.authKey = authKey;

    // Setup the proxy controller
    final PathElement serverPath = PathElement.pathElement(RUNNING_SERVER, serverName);
    final PathAddress address =
        PathAddress.EMPTY_ADDRESS.append(
            PathElement.pathElement(HOST, hostControllerName), serverPath);
    this.protocolClient = new ManagedServerProxy(this);
    this.proxyController =
        TransformingProxyController.Factory.create(
            protocolClient,
            Transformers.Factory.create(transformationTarget),
            address,
            ProxyOperationAddressTranslator.SERVER);
  }
  @Override
  public void registerRemoteHost(
      final String hostName,
      final ManagementChannelHandler handler,
      final Transformers transformers,
      Long remoteConnectionId,
      DomainControllerRuntimeIgnoreTransformationEntry runtimeIgnoreTransformation)
      throws SlaveRegistrationException {
    if (!hostControllerInfo.isMasterDomainController()) {
      throw SlaveRegistrationException.forHostIsNotMaster();
    }

    if (runningModeControl.getRunningMode() == RunningMode.ADMIN_ONLY) {
      throw SlaveRegistrationException.forMasterInAdminOnlyMode(
          runningModeControl.getRunningMode());
    }

    final PathElement pe = PathElement.pathElement(ModelDescriptionConstants.HOST, hostName);
    final PathAddress addr = PathAddress.pathAddress(pe);
    ProxyController existingController = modelNodeRegistration.getProxyController(addr);

    if (existingController != null || hostControllerInfo.getLocalHostName().equals(pe.getValue())) {
      throw SlaveRegistrationException.forHostAlreadyExists(pe.getValue());
    }

    SlaveHostPinger pinger =
        remoteConnectionId == null
            ? null
            : new SlaveHostPinger(hostName, handler, pingScheduler, remoteConnectionId);
    hostRegistrationMap.put(hostName, new HostRegistration(remoteConnectionId, handler, pinger));

    // Create the proxy controller
    final TransformingProxyController hostControllerClient =
        TransformingProxyController.Factory.create(
            handler, transformers, addr, ProxyOperationAddressTranslator.HOST);

    modelNodeRegistration.registerProxyController(pe, hostControllerClient);
    runtimeIgnoreTransformationRegistry.registerHost(hostName, runtimeIgnoreTransformation);
    hostProxies.put(hostName, hostControllerClient);
    //        if (pinger != null) {
    //            pinger.schedulePing(SlaveHostPinger.STD_TIMEOUT, SlaveHostPinger.STD_INTERVAL);
    //        }
  }