ClusterStatsNodes(List<ClusterStatsNodeResponse> nodeResponses) { this.versions = new HashSet<>(); this.fs = new FsInfo.Path(); this.plugins = new HashSet<>(); Set<InetAddress> seenAddresses = new HashSet<>(nodeResponses.size()); List<NodeInfo> nodeInfos = new ArrayList<>(); List<NodeStats> nodeStats = new ArrayList<>(); for (ClusterStatsNodeResponse nodeResponse : nodeResponses) { nodeInfos.add(nodeResponse.nodeInfo()); nodeStats.add(nodeResponse.nodeStats()); this.versions.add(nodeResponse.nodeInfo().getVersion()); this.plugins.addAll(nodeResponse.nodeInfo().getPlugins().getPluginInfos()); // now do the stats that should be deduped by hardware (implemented by ip deduping) TransportAddress publishAddress = nodeResponse.nodeInfo().getTransport().address().publishAddress(); final InetAddress inetAddress = publishAddress.address().getAddress(); if (!seenAddresses.add(inetAddress)) { continue; } if (nodeResponse.nodeStats().getFs() != null) { this.fs.add(nodeResponse.nodeStats().getFs().getTotal()); } } this.counts = new Counts(nodeInfos); this.os = new OsStats(nodeInfos, nodeStats); this.process = new ProcessStats(nodeStats); this.jvm = new JvmStats(nodeInfos, nodeStats); this.networkTypes = new NetworkTypes(nodeInfos); }
static HttpRequestBuilder httpClient() { NodeInfo info = nodeInfo(client()); info.getHttp().address().boundAddress(); TransportAddress publishAddress = info.getHttp().address().publishAddress(); assertEquals(1, publishAddress.uniqueAddressTypeId()); InetSocketAddress address = ((InetSocketTransportAddress) publishAddress).address(); return new HttpRequestBuilder(HttpClients.createDefault()) .host(address.getHostName()) .port(address.getPort()); }
public void testNonProductionMode() { // nothing should happen since we are in non-production mode final List<TransportAddress> transportAddresses = new ArrayList<>(); for (int i = 0; i < randomIntBetween(1, 8); i++) { TransportAddress localTransportAddress = mock(TransportAddress.class); when(localTransportAddress.isLoopbackOrLinkLocalAddress()).thenReturn(true); transportAddresses.add(localTransportAddress); } TransportAddress publishAddress = mock(TransportAddress.class); when(publishAddress.isLoopbackOrLinkLocalAddress()).thenReturn(true); BoundTransportAddress boundTransportAddress = mock(BoundTransportAddress.class); when(boundTransportAddress.boundAddresses()) .thenReturn(transportAddresses.toArray(new TransportAddress[0])); when(boundTransportAddress.publishAddress()).thenReturn(publishAddress); BootstrapCheck.check(Settings.EMPTY, boundTransportAddress); }
/** * Creates a new {@link DiscoveryNode} * * <p><b>Note:</b> if the version of the node is unknown {@link * Version#minimumCompatibilityVersion()} should be used for the current version. it corresponds * to the minimum version this elasticsearch version can communicate with. If a higher version is * used the node might not be able to communicate with the remove node. After initial handshakes * node versions will be discovered and updated. * * @param nodeName the nodes name * @param nodeId the nodes unique persistent id. An ephemeral id will be auto generated. * @param address the nodes transport address * @param attributes node attributes * @param roles node roles * @param version the version of the node */ public DiscoveryNode( String nodeName, String nodeId, TransportAddress address, Map<String, String> attributes, Set<Role> roles, Version version) { this( nodeName, nodeId, UUIDs.randomBase64UUID(), address.getHost(), address.getAddress(), address, attributes, roles, version); }
public void testEnforceLimitsWhenPublishingToNonLocalAddress() { final List<TransportAddress> transportAddresses = new ArrayList<>(); for (int i = 0; i < randomIntBetween(1, 8); i++) { final TransportAddress randomTransportAddress = mock(TransportAddress.class); when(randomTransportAddress.isLoopbackOrLinkLocalAddress()).thenReturn(false); transportAddresses.add(randomTransportAddress); } final TransportAddress publishAddress = mock(TransportAddress.class); when(publishAddress.isLoopbackOrLinkLocalAddress()).thenReturn(true); final BoundTransportAddress boundTransportAddress = mock(BoundTransportAddress.class); when(boundTransportAddress.boundAddresses()) .thenReturn(transportAddresses.toArray(new TransportAddress[0])); when(boundTransportAddress.publishAddress()).thenReturn(publishAddress); assertTrue(BootstrapCheck.enforceLimits(boundTransportAddress)); }
public ClusterStatsNodes(ClusterStatsNodeResponse[] nodeResponses) { this.counts = new Counts(); this.versions = new HashSet<Version>(); this.os = new OsStats(); this.jvm = new JvmStats(); this.fs = new FsStats.Info(); this.plugins = new HashSet<PluginInfo>(); this.process = new ProcessStats(); Set<InetAddress> seenAddresses = new HashSet<InetAddress>(nodeResponses.length); for (ClusterStatsNodeResponse nodeResponse : nodeResponses) { counts.addNodeInfo(nodeResponse.nodeInfo()); versions.add(nodeResponse.nodeInfo().getVersion()); process.addNodeStats(nodeResponse.nodeStats()); jvm.addNodeInfoStats(nodeResponse.nodeInfo(), nodeResponse.nodeStats()); plugins.addAll(nodeResponse.nodeInfo().getPlugins().getInfos()); // now do the stats that should be deduped by hardware (implemented by ip deduping) TransportAddress publishAddress = nodeResponse.nodeInfo().getTransport().address().publishAddress(); InetAddress inetAddress = null; if (publishAddress.uniqueAddressTypeId() == 1) { inetAddress = ((InetSocketTransportAddress) publishAddress).address().getAddress(); } if (!seenAddresses.add(inetAddress)) { continue; } os.addNodeInfo(nodeResponse.nodeInfo()); if (nodeResponse.nodeStats().getFs() != null) { fs.add(nodeResponse.nodeStats().getFs().total()); } } }