Search in sources :

Example 1 with ExtendedNodeInfo

use of io.crate.monitor.ExtendedNodeInfo in project crate by crate.

the class PingTaskTest method prepare.

@Before
public void prepare() throws Exception {
    clusterService = mock(ClusterService.class);
    clusterIdService = mock(ClusterIdService.class);
    DiscoveryNode discoveryNode = mock(DiscoveryNode.class);
    SettableFuture<ClusterId> clusterIdFuture = SettableFuture.create();
    clusterIdFuture.set(new ClusterId());
    when(clusterIdService.clusterId()).thenReturn(clusterIdFuture);
    when(clusterService.localNode()).thenReturn(discoveryNode);
    when(discoveryNode.isMasterNode()).thenReturn(true);
    extendedNodeInfo = mock(ExtendedNodeInfo.class);
    when(extendedNodeInfo.networkInfo()).thenReturn(new ExtendedNetworkInfo(ExtendedNetworkInfo.NA_INTERFACE));
    when(extendedNodeInfo.osInfo()).thenReturn(new ExtendedOsInfo(Collections.emptyMap()));
}
Also used : DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) ClusterService(org.elasticsearch.cluster.ClusterService) ClusterId(io.crate.ClusterId) ExtendedNodeInfo(io.crate.monitor.ExtendedNodeInfo) ClusterIdService(io.crate.ClusterIdService) ExtendedOsInfo(io.crate.monitor.ExtendedOsInfo) ExtendedNetworkInfo(io.crate.monitor.ExtendedNetworkInfo) Before(org.junit.Before)

Example 2 with ExtendedNodeInfo

use of io.crate.monitor.ExtendedNodeInfo in project crate by crate.

the class SysNodesExpressionsOnHandlerTest method setup.

@BeforeClass
public static void setup() throws IOException {
    // jvm
    JvmStats jvmStats = mock(JvmStats.class);
    JvmStats.Mem jvmStatsMem = mock(JvmStats.Mem.class);
    ByteSizeValue heapByteSizeValueMax = new ByteSizeValue(123456L);
    when(jvmStatsMem.getHeapMax()).thenReturn(heapByteSizeValueMax);
    when(jvmStatsMem.getHeapUsed()).thenReturn(heapByteSizeValueMax);
    when(jvmStats.getMem()).thenReturn(jvmStatsMem);
    // mem
    ByteSizeValue byteSizeValue = new ByteSizeValue(12345342234L);
    // os service
    OsService osService = mock(OsService.class);
    OsStats osStats = mock(OsStats.class);
    when(osService.stats()).thenReturn(osStats);
    OsStats.Mem mem = mock(OsStats.Mem.class);
    when(osStats.getMem()).thenReturn(mem);
    when(mem.getFree()).thenReturn(byteSizeValue);
    when(mem.getUsed()).thenReturn(byteSizeValue);
    when(mem.getUsedPercent()).thenReturn((short) 22);
    when(mem.getFreePercent()).thenReturn((short) 78);
    // os info
    OsInfo osInfo = mock(OsInfo.class);
    when(osService.info()).thenReturn(osInfo);
    when(osInfo.getAvailableProcessors()).thenReturn(4);
    // node info
    NodeEnvironment nodeEnv = mock(NodeEnvironment.class);
    Path[] dataLocations = new Path[] { new File("/foo").toPath(), new File("/bar").toPath() };
    when(nodeEnv.hasNodeFile()).then(invocation -> true);
    when(nodeEnv.nodeDataPaths()).thenReturn(dataLocations);
    ExtendedNodeInfo extendedNodeInfo = new DummyExtendedNodeInfo(nodeEnv);
    // process stats
    ProcessStats processStats = mock(ProcessStats.class);
    when(processStats.getOpenFileDescriptors()).thenReturn(42L);
    when(processStats.getMaxFileDescriptors()).thenReturn(1000L);
    CONTEXT.id(BytesRefs.toBytesRef("93c7ff92-52fa-11e6-aad8-3c15c2d3ad18"));
    CONTEXT.name(BytesRefs.toBytesRef("crate1"));
    CONTEXT.hostname(BytesRefs.toBytesRef("crate1.example.com"));
    CONTEXT.version(Version.CURRENT);
    CONTEXT.build(Build.CURRENT);
    CONTEXT.timestamp(100L);
    CONTEXT.restUrl(BytesRefs.toBytesRef("10.0.0.1:4200"));
    CONTEXT.port(new HashMap<String, Integer>(2) {

        {
            put("http", 4200);
            put("transport", 4300);
        }
    });
    CONTEXT.jvmStats(jvmStats);
    CONTEXT.osInfo(osInfo);
    CONTEXT.processStats(processStats);
    CONTEXT.osStats(osStats);
    CONTEXT.extendedOsStats(extendedNodeInfo.osStats());
    CONTEXT.networkStats(extendedNodeInfo.networkStats());
    CONTEXT.extendedProcessCpuStats(extendedNodeInfo.processCpuStats());
    CONTEXT.extendedFsStats(extendedNodeInfo.fsStats());
}
Also used : JvmStats(org.elasticsearch.monitor.jvm.JvmStats) Path(java.nio.file.Path) ProcessStats(org.elasticsearch.monitor.process.ProcessStats) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue) DummyExtendedNodeInfo(io.crate.monitor.DummyExtendedNodeInfo) ExtendedNodeInfo(io.crate.monitor.ExtendedNodeInfo) OsStats(org.elasticsearch.monitor.os.OsStats) TestingHelpers.mapToSortedString(io.crate.testing.TestingHelpers.mapToSortedString) OsService(org.elasticsearch.monitor.os.OsService) OsInfo(org.elasticsearch.monitor.os.OsInfo) File(java.io.File) DummyExtendedNodeInfo(io.crate.monitor.DummyExtendedNodeInfo) BeforeClass(org.junit.BeforeClass)

Aggregations

ExtendedNodeInfo (io.crate.monitor.ExtendedNodeInfo)2 ClusterId (io.crate.ClusterId)1 ClusterIdService (io.crate.ClusterIdService)1 DummyExtendedNodeInfo (io.crate.monitor.DummyExtendedNodeInfo)1 ExtendedNetworkInfo (io.crate.monitor.ExtendedNetworkInfo)1 ExtendedOsInfo (io.crate.monitor.ExtendedOsInfo)1 TestingHelpers.mapToSortedString (io.crate.testing.TestingHelpers.mapToSortedString)1 File (java.io.File)1 Path (java.nio.file.Path)1 ClusterService (org.elasticsearch.cluster.ClusterService)1 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)1 ByteSizeValue (org.elasticsearch.common.unit.ByteSizeValue)1 NodeEnvironment (org.elasticsearch.env.NodeEnvironment)1 JvmStats (org.elasticsearch.monitor.jvm.JvmStats)1 OsInfo (org.elasticsearch.monitor.os.OsInfo)1 OsService (org.elasticsearch.monitor.os.OsService)1 OsStats (org.elasticsearch.monitor.os.OsStats)1 ProcessStats (org.elasticsearch.monitor.process.ProcessStats)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1