@Override public void ipcHandleRestored(IIPCHandle handle) throws IPCException { // we need to re-register in case of NC -> CC connection reset final CcConnection ccConnection = getCcConnection(ccAddressMap.get(ccAddress)); try { ccConnection.forceReregister(NodeControllerService.this); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IPCException(e); } } };
private HeartbeatManager(NodeControllerService ncs, CcConnection ccc, HeartbeatData hbData, InetSocketAddress ncAddress) { this.ncs = ncs; this.ccc = ccc; hbThread = new Thread(new HeartbeatTask(ncs.getId(), hbData, ccc.getClusterControllerService(), ccc.getNodeParameters().getHeartbeatPeriod(), ncAddress), ncs.getId() + "-Heartbeat"); hbThread.setPriority(Thread.MAX_PRIORITY); hbThread.setDaemon(true); ccId = ccc.getCcId(); }
void setNodeRegistrationResult(NodeParameters parameters, Exception exception) { CcConnection ccc = getPendingNodeRegistration(parameters); ccc.setNodeRegistrationResult(parameters, exception); }
public CcId registerNode(CcConnection ccc) throws Exception { LOGGER.info("Registering with Cluster Controller {}", ccc); int registrationId = nextRegistrationId.incrementAndGet(); pendingRegistrations.put(registrationId, ccc); CcId ccId = ccc.registerNode(nodeRegistration, registrationId); ccMap.put(ccId, ccc); ccAddressMap.put(ccc.getCcAddress(), ccId); Serializable distributedState = ccc.getNodeParameters().getDistributedState(); if (distributedState != null) { getDistributedState().put(ccId, distributedState); } IClusterController ccs = ccc.getClusterControllerService(); NodeParameters nodeParameters = ccc.getNodeParameters(); // Start heartbeat generator. heartbeatManagers.computeIfAbsent(ccId, newCcId -> HeartbeatManager.init(this, ccc, hbTask.getHeartbeatData(), nodeRegistration.getNodeControllerAddress())); if (!ccTimers.containsKey(ccId) && nodeParameters.getProfileDumpPeriod() > 0) { Timer ccTimer = new Timer("Timer-" + ccId, true); // Schedule profile dump generator. ccTimer.schedule(new ProfileDumpTask(ccs, ccId), 0, nodeParameters.getProfileDumpPeriod()); ccTimers.put(ccId, ccTimer); } ccc.notifyRegistrationCompleted(); LOGGER.info("Registering with Cluster Controller {} completed", ccc); return ccId; }
public IClusterController getClusterController(CcId ccId) { return getCcConnection(ccId).getClusterControllerService(); }
public NodeParameters getNodeParameters(CcId ccId) { return getCcConnection(ccId).getNodeParameters(); }
public CcId addCc(InetSocketAddress ccAddress) throws Exception { synchronized (ccLock) { LOGGER.info("addCc: {}", ccAddress); if (ccAddress.isUnresolved()) { throw new IllegalArgumentException("must use resolved InetSocketAddress"); } if (ccAddressMap.containsKey(ccAddress)) { throw new IllegalStateException("cc already registered: " + ccAddress); } final IIPCEventListener ipcEventListener = new IIPCEventListener() { @Override public void ipcHandleRestored(IIPCHandle handle) throws IPCException { // we need to re-register in case of NC -> CC connection reset final CcConnection ccConnection = getCcConnection(ccAddressMap.get(ccAddress)); try { ccConnection.forceReregister(NodeControllerService.this); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IPCException(e); } } }; ClusterControllerRemoteProxy ccProxy = new ClusterControllerRemoteProxy( ipc.getHandle(ccAddress, ncConfig.getClusterConnectRetries(), 1, ipcEventListener)); return registerNode(new CcConnection(ccProxy, ccAddress)); } }
public synchronized CcId registerNode(NodeRegistration nodeRegistration, int registrationId) throws Exception { registrationPending = true; ccs.registerNode(nodeRegistration, registrationId); try { InvokeUtil.runWithTimeout(() -> { this.wait(REGISTRATION_RESPONSE_POLL_PERIOD); // NOSONAR while loop in timeout call }, () -> !registrationPending, 1, TimeUnit.MINUTES); } catch (Exception e) { registrationException = e; } if (registrationException != null) { LOGGER.fatal("Registering with {} failed with exception", this, registrationException); ExitUtil.halt(ExitUtil.EC_NODE_REGISTRATION_FAILURE); } return getCcId(); }
ccc.getClusterControllerService().unregisterNode(id); } catch (Exception e) { LOGGER.warn("ignoring exception trying to gracefully unregister cc {}: ", () -> ccId,
public CcId getCcId() { return getNodeParameters().getClusterControllerInfo().getCcId(); }
ccMap.values().parallelStream().forEach(cc -> { try { cc.getClusterControllerService().notifyShutdown(id); } catch (Exception e) { LOGGER.log(Level.WARN, "Exception notifying CC of shutdown", e);
public void notifyAck(HyracksDataException exception) { LOGGER.debug("ack rec'd from {} w/ exception: {}", ccId::toString, () -> String.valueOf(exception)); if (exception != null && exception.matches(ErrorCode.HYRACKS, ErrorCode.NO_SUCH_NODE)) { LOGGER.info("{} indicates it does not recognize us; force a reconnect", ccId); try { ccc.forceReregister(ncs); } catch (Exception e) { LOGGER.warn("ignoring exception attempting to reregister with {}", ccId, e); } } } }