@Override public void pingRemoteHost(String id) { HostRegistration reg = hostRegistrationMap.get(id); if (reg != null && reg.pinger != null && !reg.pinger.isCancelled()) { reg.pinger.schedulePing(SlaveHostPinger.SHORT_TIMEOUT, 0); } }
protected Long getRemoteConnectionId() { if (pinger != null) { return pinger.getRemoteConnectionID(); } else { return null; } }
@Override public void unregisterRemoteHost(String id, Long remoteConnectionId) { HostRegistration hostRegistration = hostRegistrationMap.get(id); if (hostRegistration != null) { if ((remoteConnectionId == null || remoteConnectionId.equals(hostRegistration.remoteConnectionId)) && hostRegistrationMap.remove(id, hostRegistration)) { if (hostRegistration.pinger != null) { hostRegistration.pinger.cancel(); } hostProxies.remove(id); modelNodeRegistration.unregisterProxyController(PathElement.pathElement(HOST, id)); DOMAIN_LOGGER.unregisteredRemoteSlaveHost(id); } } }
SlaveHostPinger pinger = remoteConnectionId == null ? null : new SlaveHostPinger(hostName, handler, pingScheduler, remoteConnectionId); hostRegistrationMap.put(hostName, new HostRegistration(remoteConnectionId, handler, pinger));
@Override public void unregisterRemoteHost(String id, Long remoteConnectionId, boolean cleanShutdown) { DomainSlaveHostRegistrations.DomainHostConnection hostRegistration = slaveHostRegistrations.getRegistration(id); if (hostRegistration != null) { if ((remoteConnectionId == null || remoteConnectionId.equals(hostRegistration.getRemoteConnectionId()))) { final SlaveHostPinger pinger = hostRegistration.getPinger(); if (pinger != null) { pinger.cancel(); } boolean registered = hostProxies.remove(id) != null; modelNodeRegistration.unregisterProxyController(PathElement.pathElement(HOST, id)); if (registered) { final String address = hostRegistration.getAddress(); final Event event = cleanShutdown ? create(HostConnectionInfo.EventType.UNREGISTERED, address) : create(HostConnectionInfo.EventType.UNCLEAN_UNREGISTRATION, address); slaveHostRegistrations.unregisterHost(id, event); if (!cleanShutdown) { DOMAIN_LOGGER.lostConnectionToRemoteHost(id); } else { DOMAIN_LOGGER.unregisteredRemoteSlaveHost(id); } } } } }
@Override public void registerRemoteHost(final String hostName, final ManagementChannelHandler handler, final Transformers transformers, final Long remoteConnectionId, final boolean registerProxyController) 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()); } final SlaveHostPinger pinger = remoteConnectionId == null ? null : new SlaveHostPinger(hostName, handler, pingScheduler, remoteConnectionId); final String address = handler.getRemoteAddress().getHostAddress(); slaveHostRegistrations.registerHost(hostName, pinger, address); if (registerProxyController) { // Create the proxy controller final TransformingProxyController hostControllerClient = TransformingProxyController.Factory.create(handler, transformers, addr, ProxyOperationAddressTranslator.HOST); modelNodeRegistration.registerProxyController(pe, hostControllerClient); hostProxies.put(hostName, hostControllerClient); } }
@Override public void pingRemoteHost(String id) { DomainSlaveHostRegistrations.DomainHostConnection reg = slaveHostRegistrations.getRegistration(id); if (reg != null && reg.getPinger() != null && !reg.getPinger().isCancelled()) { reg.getPinger().schedulePing(SlaveHostPinger.SHORT_TIMEOUT, 0); } }
@Override public void unregisterRemoteHost(String id, Long remoteConnectionId, boolean cleanShutdown) { DomainSlaveHostRegistrations.DomainHostConnection hostRegistration = slaveHostRegistrations.getRegistration(id); if (hostRegistration != null) { if ((remoteConnectionId == null || remoteConnectionId.equals(hostRegistration.getRemoteConnectionId()))) { final SlaveHostPinger pinger = hostRegistration.getPinger(); if (pinger != null) { pinger.cancel(); } boolean registered = hostProxies.remove(id) != null; modelNodeRegistration.unregisterProxyController(PathElement.pathElement(HOST, id)); if (registered) { final String address = hostRegistration.getAddress(); final Event event = cleanShutdown ? create(HostConnectionInfo.EventType.UNREGISTERED, address) : create(HostConnectionInfo.EventType.UNCLEAN_UNREGISTRATION, address); slaveHostRegistrations.unregisterHost(id, event); if (!cleanShutdown) { DOMAIN_LOGGER.lostConnectionToRemoteHost(id); } else { DOMAIN_LOGGER.unregisteredRemoteSlaveHost(id); } } } } }
@Override public void registerRemoteHost(final String hostName, final ManagementChannelHandler handler, final Transformers transformers, final Long remoteConnectionId, final boolean registerProxyController) 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()); } final SlaveHostPinger pinger = remoteConnectionId == null ? null : new SlaveHostPinger(hostName, handler, pingScheduler, remoteConnectionId); final String address = handler.getRemoteAddress().getHostAddress(); slaveHostRegistrations.registerHost(hostName, pinger, address); if (registerProxyController) { // Create the proxy controller final TransformingProxyController hostControllerClient = TransformingProxyController.Factory.create(handler, transformers, addr, ProxyOperationAddressTranslator.HOST); modelNodeRegistration.registerProxyController(pe, hostControllerClient); hostProxies.put(hostName, hostControllerClient); } }
protected Long getRemoteConnectionId() { if (pinger != null) { return pinger.getRemoteConnectionID(); } else { return null; } }
@Override public void pingRemoteHost(String id) { DomainSlaveHostRegistrations.DomainHostConnection reg = slaveHostRegistrations.getRegistration(id); if (reg != null && reg.getPinger() != null && !reg.getPinger().isCancelled()) { reg.getPinger().schedulePing(SlaveHostPinger.SHORT_TIMEOUT, 0); } }