Package org.elasticsearch.monitor.os

Examples of org.elasticsearch.monitor.os.OsStats$Mem


                        return new ExpList(src, null);
        }

        public Stm build(ExpList kids) {
                if (dst instanceof MEM)
                        return new MOVE(new MEM(kids.head), kids.tail.head);
                else
                        return new MOVE(dst, kids.head);
        }
View Full Code Here


        public ExpList kids() {
                return new ExpList(exp, null);
        }

        public Exp build(ExpList kids) {
                return new MEM(kids.head);
        }
View Full Code Here

            when(state.metaData()).thenReturn(metaData);
            when(clusterService.state()).thenReturn(state);
            bind(ClusterService.class).toInstance(clusterService);
            bind(Settings.class).toInstance(ImmutableSettings.EMPTY);
            OsService osService = mock(OsService.class);
            OsStats osStats = mock(OsStats.class);
            when(osService.stats()).thenReturn(osStats);
            when(osStats.loadAverage()).thenReturn(new double[]{1, 5, 15});
            bind(OsService.class).toInstance(osService);
            Discovery discovery = mock(Discovery.class);
            bind(Discovery.class).toInstance(discovery);
            DiscoveryNode node = mock(DiscoveryNode.class);
            when(discovery.localNode()).thenReturn(node);
View Full Code Here

    private void addChildImplementations() {
        childImplementations.put(SYS, new CpuExpression(SYS) {
            @Override
            public Short value() {
               OsStats os = nodeService.stats().getOs();
                if (os != null) {
                    return os.cpu().sys();
                } else { return -1; }
            }
        });
        childImplementations.put(USER, new CpuExpression(USER) {
            @Override
            public Short value() {
                OsStats os = nodeService.stats().getOs();
                if (os != null) {
                    return os.cpu().user();
                } else { return -1; }
            }
        });
        childImplementations.put(IDLE, new CpuExpression(IDLE) {
            @Override
            public Short value() {
                OsStats os = nodeService.stats().getOs();
                if (os != null) {
                    return os.cpu().idle();
                } else { return -1; }
            }
        });
        childImplementations.put(USAGE, new CpuExpression(USAGE) {
            @Override
            public Short value() {
                OsStats os = nodeService.stats().getOs();
                if (os != null) {
                    return (short) (os.cpu().sys() + os.cpu().user());
                } else { return -1; }
            }
        });
        childImplementations.put(STOLEN, new CpuExpression(STOLEN) {
            @Override
            public Short value() {
                OsStats os = nodeService.stats().getOs();
                if (os != null) {
                    return os.cpu().stolen();
                } else { return -1; }
            }
        });
    }
View Full Code Here

        @Override
        protected void configure() {
            bind(Settings.class).toInstance(ImmutableSettings.EMPTY);

            OsService osService = mock(OsService.class);
            OsStats osStats = mock(OsStats.class);
            when(osService.stats()).thenReturn(osStats);
            when(osStats.loadAverage()).thenAnswer(new Answer<double[]>() {
                @Override
                public double[] answer(InvocationOnMock invocation) throws Throwable {
                    if (onWindows) {
                        return new double[0];          // windows behaviour
                    } else {
                        return new double[]{1, 5, 15}; // unix behaviour
                    }
                }
            });
            ByteSizeValue byteSizeValue = mock(ByteSizeValue.class);
            when(byteSizeValue.bytes()).thenReturn(12345342234L);
            when(byteSizeValue.toString()).thenReturn("11.4gb");

            OsStats.Mem mem = mock(OsStats.Mem.class);
            when(osStats.mem()).thenReturn(mem);
            when(mem.actualFree()).thenReturn(byteSizeValue);
            when(mem.actualUsed()).thenReturn(byteSizeValue);
            when(mem.usedPercent()).thenReturn((short) 22);
            when(mem.freePercent()).thenReturn((short) 78);

            bind(OsService.class).toInstance(osService);

            NodeService nodeService = mock(NodeService.class);
            NodeStats nodeStats = mock(NodeStats.class);
            when(nodeService.stats()).thenReturn(nodeStats);
            when(nodeStats.getHostname()).thenReturn("localhost");

            DiscoveryNode node = mock(DiscoveryNode.class);
            when(nodeStats.getNode()).thenReturn(node);

            when(nodeStats.getOs()).thenReturn(osStats);
            when(osStats.uptime()).thenReturn(new TimeValue(3600000));
            OsStats.Cpu cpu = mock(OsStats.Cpu.class);
            when(osStats.cpu()).thenReturn(cpu);
            when(cpu.sys()).thenReturn((short) 2);
            when(cpu.user()).thenReturn((short) 4);
            when(cpu.idle()).thenReturn((short) 94);
            when(cpu.stolen()).thenReturn((short) 10);
View Full Code Here

        @Override
        protected void configure() {
            bind(Settings.class).toInstance(ImmutableSettings.EMPTY);

            OsService osService = mock(OsService.class);
            OsStats osStats = mock(OsStats.class);
            when(osService.stats()).thenReturn(osStats);
            when(osStats.loadAverage()).thenReturn(new double[]{1, 5, 15});
            bind(OsService.class).toInstance(osService);

            NodeService nodeService = mock(NodeService.class);
            bind(NodeService.class).toInstance(nodeService);
View Full Code Here

TOP

Related Classes of org.elasticsearch.monitor.os.OsStats$Mem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.