Search in sources :

Example 1 with TransportInfo

use of org.elasticsearch.transport.TransportInfo in project elasticsearch by elastic.

the class NodeInfoStreamingTests method createNodeInfo.

private static NodeInfo createNodeInfo() {
    Build build = Build.CURRENT;
    DiscoveryNode node = new DiscoveryNode("test_node", buildNewFakeTransportAddress(), emptyMap(), emptySet(), VersionUtils.randomVersion(random()));
    Settings settings = randomBoolean() ? null : Settings.builder().put("test", "setting").build();
    OsInfo osInfo = null;
    if (randomBoolean()) {
        int availableProcessors = randomIntBetween(1, 64);
        int allocatedProcessors = randomIntBetween(1, availableProcessors);
        long refreshInterval = randomBoolean() ? -1 : randomNonNegativeLong();
        String name = randomAsciiOfLengthBetween(3, 10);
        String arch = randomAsciiOfLengthBetween(3, 10);
        String version = randomAsciiOfLengthBetween(3, 10);
        osInfo = new OsInfo(refreshInterval, availableProcessors, allocatedProcessors, name, arch, version);
    }
    ProcessInfo process = randomBoolean() ? null : new ProcessInfo(randomInt(), randomBoolean(), randomNonNegativeLong());
    JvmInfo jvm = randomBoolean() ? null : JvmInfo.jvmInfo();
    ThreadPoolInfo threadPoolInfo = null;
    if (randomBoolean()) {
        int numThreadPools = randomIntBetween(1, 10);
        List<ThreadPool.Info> threadPoolInfos = new ArrayList<>(numThreadPools);
        for (int i = 0; i < numThreadPools; i++) {
            threadPoolInfos.add(new ThreadPool.Info(randomAsciiOfLengthBetween(3, 10), randomFrom(ThreadPool.ThreadPoolType.values()), randomInt()));
        }
        threadPoolInfo = new ThreadPoolInfo(threadPoolInfos);
    }
    Map<String, BoundTransportAddress> profileAddresses = new HashMap<>();
    BoundTransportAddress dummyBoundTransportAddress = new BoundTransportAddress(new TransportAddress[] { buildNewFakeTransportAddress() }, buildNewFakeTransportAddress());
    profileAddresses.put("test_address", dummyBoundTransportAddress);
    TransportInfo transport = randomBoolean() ? null : new TransportInfo(dummyBoundTransportAddress, profileAddresses);
    HttpInfo httpInfo = randomBoolean() ? null : new HttpInfo(dummyBoundTransportAddress, randomLong());
    PluginsAndModules pluginsAndModules = null;
    if (randomBoolean()) {
        int numPlugins = randomIntBetween(0, 5);
        List<PluginInfo> plugins = new ArrayList<>();
        for (int i = 0; i < numPlugins; i++) {
            plugins.add(new PluginInfo(randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10)));
        }
        int numModules = randomIntBetween(0, 5);
        List<PluginInfo> modules = new ArrayList<>();
        for (int i = 0; i < numModules; i++) {
            modules.add(new PluginInfo(randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10)));
        }
        pluginsAndModules = new PluginsAndModules(plugins, modules);
    }
    IngestInfo ingestInfo = null;
    if (randomBoolean()) {
        int numProcessors = randomIntBetween(0, 5);
        List<ProcessorInfo> processors = new ArrayList<>(numProcessors);
        for (int i = 0; i < numProcessors; i++) {
            processors.add(new ProcessorInfo(randomAsciiOfLengthBetween(3, 10)));
        }
        ingestInfo = new IngestInfo(processors);
    }
    ByteSizeValue indexingBuffer = null;
    if (randomBoolean()) {
        // pick a random long that sometimes exceeds an int:
        indexingBuffer = new ByteSizeValue(random().nextLong() & ((1L << 40) - 1));
    }
    return new NodeInfo(VersionUtils.randomVersion(random()), build, node, settings, osInfo, process, jvm, threadPoolInfo, transport, httpInfo, pluginsAndModules, ingestInfo, indexingBuffer);
}
Also used : DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) JvmInfo(org.elasticsearch.monitor.jvm.JvmInfo) ProcessorInfo(org.elasticsearch.ingest.ProcessorInfo) HashMap(java.util.HashMap) PluginsAndModules(org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules) ArrayList(java.util.ArrayList) ThreadPool(org.elasticsearch.threadpool.ThreadPool) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue) HttpInfo(org.elasticsearch.http.HttpInfo) OsInfo(org.elasticsearch.monitor.os.OsInfo) Build(org.elasticsearch.Build) IngestInfo(org.elasticsearch.ingest.IngestInfo) PluginInfo(org.elasticsearch.plugins.PluginInfo) Settings(org.elasticsearch.common.settings.Settings) ThreadPoolInfo(org.elasticsearch.threadpool.ThreadPoolInfo) TransportInfo(org.elasticsearch.transport.TransportInfo) ProcessInfo(org.elasticsearch.monitor.process.ProcessInfo) PluginInfo(org.elasticsearch.plugins.PluginInfo) OsInfo(org.elasticsearch.monitor.os.OsInfo) ThreadPoolInfo(org.elasticsearch.threadpool.ThreadPoolInfo) ProcessInfo(org.elasticsearch.monitor.process.ProcessInfo) IngestInfo(org.elasticsearch.ingest.IngestInfo) JvmInfo(org.elasticsearch.monitor.jvm.JvmInfo) ProcessorInfo(org.elasticsearch.ingest.ProcessorInfo) HttpInfo(org.elasticsearch.http.HttpInfo) TransportInfo(org.elasticsearch.transport.TransportInfo) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress)

Example 2 with TransportInfo

use of org.elasticsearch.transport.TransportInfo in project elasticsearch-jdbc by jprante.

the class NodeTestUtils method findNodeAddresses.

protected void findNodeAddresses() {
    NodesInfoRequest nodesInfoRequest = new NodesInfoRequest().transport(true);
    NodesInfoResponse response = client("1").admin().cluster().nodesInfo(nodesInfoRequest).actionGet();
    Iterator<NodeInfo> it = response.iterator();
    hosts = new LinkedList<>();
    hosts = new LinkedList<>();
    while (it.hasNext()) {
        NodeInfo nodeInfo = it.next();
        TransportInfo transportInfo = nodeInfo.getTransport();
        TransportAddress address = transportInfo.getAddress().publishAddress();
        if (address instanceof InetSocketTransportAddress) {
            InetSocketTransportAddress inetSocketTransportAddress = (InetSocketTransportAddress) address;
            hosts.add(inetSocketTransportAddress.address().getHostName() + ":" + inetSocketTransportAddress.address().getPort());
        }
    }
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) TransportInfo(org.elasticsearch.transport.TransportInfo) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) InetSocketTransportAddress(org.elasticsearch.common.transport.InetSocketTransportAddress) TransportAddress(org.elasticsearch.common.transport.TransportAddress) NodesInfoRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest) InetSocketTransportAddress(org.elasticsearch.common.transport.InetSocketTransportAddress)

Aggregations

NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)2 TransportInfo (org.elasticsearch.transport.TransportInfo)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Build (org.elasticsearch.Build)1 NodesInfoRequest (org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest)1 NodesInfoResponse (org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse)1 PluginsAndModules (org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules)1 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)1 Settings (org.elasticsearch.common.settings.Settings)1 BoundTransportAddress (org.elasticsearch.common.transport.BoundTransportAddress)1 InetSocketTransportAddress (org.elasticsearch.common.transport.InetSocketTransportAddress)1 TransportAddress (org.elasticsearch.common.transport.TransportAddress)1 ByteSizeValue (org.elasticsearch.common.unit.ByteSizeValue)1 HttpInfo (org.elasticsearch.http.HttpInfo)1 IngestInfo (org.elasticsearch.ingest.IngestInfo)1 ProcessorInfo (org.elasticsearch.ingest.ProcessorInfo)1 JvmInfo (org.elasticsearch.monitor.jvm.JvmInfo)1 OsInfo (org.elasticsearch.monitor.os.OsInfo)1 ProcessInfo (org.elasticsearch.monitor.process.ProcessInfo)1