@Override public void addHostEvent(String hostName, Event event) { slaveHostRegistrations.addEvent(hostName, event); }
@Override public boolean has(String name) { return slaveHostRegistrations.contains(name); }
public void pruneExpired() { evictEntries(EXPIRED); }
@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 HostConnectionInfo getHostInfo(String hostName) { return slaveHostRegistrations.getRegistration(hostName); }
@Override public void pruneExpired() { slaveHostRegistrations.pruneExpired(); }
@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 pruneDisconnected() { slaveHostRegistrations.pruneDisconnected(); }
@Override public Set<String> children() { return slaveHostRegistrations.getHosts(); }
@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 HostConnectionInfo getHostInfo(String hostName) { return slaveHostRegistrations.getRegistration(hostName); }
@Override public void pruneExpired() { slaveHostRegistrations.pruneExpired(); }
@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 pruneDisconnected() { slaveHostRegistrations.pruneDisconnected(); }
@Override public Set<String> children() { return slaveHostRegistrations.getHosts(); }
@Override public boolean isHostRegistered(String id) { final DomainSlaveHostRegistrations.DomainHostConnection registration = slaveHostRegistrations.getRegistration(id); return registration != null && registration.isConnected(); }
@Override public void run() { try { slaveHostRegistrations.pruneExpired(); } catch (Exception e) { HostControllerLogger.DOMAIN_LOGGER.debugf(e, "failed to execute eviction task"); } } }, 1, 1, TimeUnit.MINUTES);
public void pruneExpired() { evictEntries(EXPIRED); }
slaveHostRegistrations.registerHost(hostName, null, "local");
@Override public boolean has(String name) { return slaveHostRegistrations.contains(name); }