/** * Checks if is master. * * @return true, if is master */ public boolean isMaster() { ControlNodeInfo serverInfo = getControlServerInfo(); if (currentNodeInfo != null && serverInfo != null) { String curHost = currentNodeInfo.getConnectionInfo().getThriftHost().toString(); int curPort = currentNodeInfo.getConnectionInfo().getThriftPort(); String masterHost = serverInfo.getConnectionInfo().getThriftHost().toString(); int masterPort = serverInfo.getConnectionInfo().getThriftPort(); return curHost.equals(masterHost) && curPort == masterPort; } else { return false; } }
/** * Check neighbors. */ private void checkNeighbors() { if (neighbors == null) { synchronized (zkLock) { if (neighbors == null) { neighbors = new Neighbors<>( KaaThriftService.OPERATIONS_SERVICE, new NeighborTemplate<OperationsServiceMsg>() { @Override public void process(Iface client, List<OperationsServiceMsg> messages) throws TException { OperationsServiceMsg.dispatch(client, messages); } @Override public void onServerError(String serverId, Exception ex) { LOG.error("Can't send configuration update to {}", serverId, ex); } }, neighborConnectionsSize); ControlNode zkNode = controlZkService.getControlZkNode(); neighbors.setZkNode( KaaThriftService.KAA_NODE_SERVICE, zkNode.getControlServerInfo().getConnectionInfo(), zkNode); } } } }