@Override public void onNodeUpdated(BootstrapNodeInfo nodeInfo) { String dnsName = getNameFromConnectionInfo(nodeInfo.getConnectionInfo()); LOG.info("Bootstrap server {} updated", dnsName); bootstrapsMap.put(dnsName, nodeInfo); }
@Override public String toString() { return "BootstrapNode {" + "host =" + nodeInfo.getConnectionInfo().getThriftHost() + "port =" + nodeInfo.getConnectionInfo().getThriftPort() + "timeStarted =" + nodeInfo.getTimeStarted() + '}'; } }
@Override public void onTransportsStarted(List<TransportMetaData> mdList) { BootstrapNodeInfo info = bootstrapNode.getNodeInfo(); info.setTransports(mdList); try { bootstrapNode.updateNodeData(info); } catch (IOException ex) { LOG.error("Failed to update bootstrap node info", ex); } }
/** * Start zk. * * @throws Exception in case of error */ private void startZk() throws Exception { // NOSONAR if (getNodeConfig().isZkEnabled()) { LOG.info("Bootstrap service starting ZooKepper connection to {}", getNodeConfig().getZkHostPortList()); BootstrapNodeInfo nodeInfo = new BootstrapNodeInfo(); ByteBuffer keyData = ByteBuffer.wrap(bootstrapKeyStoreService.getPublicKey().getEncoded()); LOG.trace("Bootstrap service: registering in ZK: thriftHost {}; " + "thriftPort {}; nettyHost {}; nettyPort {}", getNodeConfig().getThriftHost(), getNodeConfig().getThriftPort()); nodeInfo.setConnectionInfo(new ConnectionInfo( getNodeConfig().getThriftHost(), getNodeConfig().getThriftPort(), keyData)); nodeInfo.setTransports(new ArrayList<>()); nodeInfo.setTimeStarted(System.currentTimeMillis()); bootstrapNode = new BootstrapNode(nodeInfo, zkClient); if (bootstrapNode != null) { bootstrapNode.start(); } } }
if (bootstrapNodes != null && !bootstrapNodes.isEmpty()) { for (BootstrapNodeInfo node : bootstrapNodes) { List<TransportMetaData> supportedChannels = node.getTransports(); int accessPointId = ServerNameUtil.crc32(node.getConnectionInfo());
@Override public BootstrapNodeInfo build() { try { BootstrapNodeInfo record = new BootstrapNodeInfo(); record.connectionInfo = fieldSetFlags()[0] ? this.connectionInfo : (org.kaaproject.kaa.server.common.zk.gen.ConnectionInfo) defaultValue(fields()[0]); record.transports = fieldSetFlags()[1] ? this.transports : (java.util.List<org.kaaproject.kaa.server.common.zk.gen.TransportMetaData>) defaultValue(fields()[1]); record.timeStarted = fieldSetFlags()[2] ? this.timeStarted : (java.lang.Long) defaultValue(fields()[2]); return record; } catch (Exception e) { throw new org.apache.avro.AvroRuntimeException(e); } } }
/** * Bootstrap added. * * @param data the data */ protected void bootstrapAdded(ChildData data) { BootstrapNodeInfo nodeInfo = extractBootstrapServerInfo(data); String bootstrapAddress = constructBootstrapAddress(nodeInfo); bootstrapNodesStartTimes.put(bootstrapAddress, nodeInfo.getTimeStarted()); for (BootstrapNodeListener listener : bootstrapListeners) { listener.onNodeAdded(nodeInfo); } }
List<TransportMetaData> supportedChannels = node.getTransports(); int accessPointId = ServerNameUtil.crc32(node.getConnectionInfo()); for (TransportMetaData transport : supportedChannels) { for (VersionConnectionInfoPair pair : transport.getConnectionInfo()) {
/** * Bootstrap updated. * * @param data the data */ protected void bootstrapUpdated(ChildData data) { BootstrapNodeInfo nodeInfo = extractBootstrapServerInfo(data); String bootstrapAddress = constructBootstrapAddress(nodeInfo); bootstrapNodesStartTimes.put(bootstrapAddress, nodeInfo.getTimeStarted()); for (BootstrapNodeListener listener : bootstrapListeners) { listener.onNodeUpdated(nodeInfo); } }
@Override public void onNodeRemoved(BootstrapNodeInfo nodeInfo) { String dnsName = getNameFromConnectionInfo(nodeInfo.getConnectionInfo()); LOG.info("Bootstrap server {} removed", dnsName); bootstrapsMap.remove(dnsName); }
/** * Bootstrap removed. * * @param data the data */ protected void bootstrapRemoved(ChildData data) { BootstrapNodeInfo nodeInfo = extractBootstrapServerInfo(data); String bootstrapAddress = constructBootstrapAddress(nodeInfo); Long removeTime = nodeInfo.getTimeStarted(); Long updateTime = bootstrapNodesStartTimes.get(bootstrapAddress); if (updateTime == null || removeTime >= updateTime) { for (BootstrapNodeListener listener : bootstrapListeners) { listener.onNodeRemoved(nodeInfo); } } else { LOG.debug("Ignoring [{}] bootstrap removal, as it was before add/update", bootstrapAddress); } }
private String constructBootstrapAddress(BootstrapNodeInfo nodeInfo) { return nodeInfo.getConnectionInfo().getThriftHost() + ":" + String.valueOf(nodeInfo.getConnectionInfo().getThriftPort()); }
@Override public void onNodeAdded(BootstrapNodeInfo nodeInfo) { final String dnsName = getNameFromConnectionInfo(nodeInfo.getConnectionInfo()); LOG.info("Bootstrap server {} added", dnsName); bootstrapsMap.put(dnsName, nodeInfo); updateBootstrap(nodeInfo); }
final String dnsName = getNameFromConnectionInfo(nodeInfo.getConnectionInfo()); LOG.debug("Update bootstrap service: {}", dnsName); try { ThriftClient<BootstrapThriftService.Client> thriftClient = new ThriftClient<>( nodeInfo.getConnectionInfo().getThriftHost().toString(), nodeInfo.getConnectionInfo().getThriftPort(), KaaThriftService.BOOTSTRAP_SERVICE, BootstrapThriftService.Client.class