Package io.crate.metadata

Examples of io.crate.metadata.ReferenceIdent


        assertEquals(new BytesRef("node 1"), name.value());
    }

    @Test
    public void testId() throws Exception {
        ReferenceIdent ident = new ReferenceIdent(SysNodesTableInfo.IDENT, "id");
        SysExpression<BytesRef> id = (SysExpression<BytesRef>) resolver.getImplementation(ident);
        assertEquals(new BytesRef("node-id-1"), id.value());
    }
View Full Code Here


        assertEquals(new BytesRef("node-id-1"), id.value());
    }

    @Test
    public void testHostname() throws Exception {
        ReferenceIdent ident = new ReferenceIdent(SysNodesTableInfo.IDENT, "hostname");
        SysExpression<BytesRef> hostname = (SysExpression<BytesRef>) resolver.getImplementation(ident);
        assertEquals(new BytesRef("localhost"), hostname.value());
    }
View Full Code Here

    }

    @Test
    public void testPorts() throws Exception {

        ReferenceIdent ident = new ReferenceIdent(SysNodesTableInfo.IDENT, "port");
        SysObjectReference port = (SysObjectReference) resolver.getImplementation(ident);

        Map<String, Object> v = port.value();
        assertEquals(44200, v.get("http"));
        assertEquals(44300, v.get("transport"));
View Full Code Here

    }

    @Test
    public void testMemory() throws Exception {

        ReferenceIdent ident = new ReferenceIdent(SysNodesTableInfo.IDENT, "mem");
        SysObjectReference mem = (SysObjectReference) resolver.getImplementation(ident);

        Map<String, Object> v = mem.value();

        assertEquals(12345342234L, v.get("free"));
View Full Code Here

    }

    @Test
    public void testHeap() throws Exception {

        ReferenceIdent ident = new ReferenceIdent(SysNodesTableInfo.IDENT, "heap");
        SysObjectReference heap = (SysObjectReference) resolver.getImplementation(ident);

        Map<String, Object> v = heap.value();

        assertEquals(123456L, v.get("max"));
View Full Code Here

        assertEquals(0L, v.get("free"));
    }

    @Test
    public void testFs() throws Exception {
        ReferenceIdent ident = new ReferenceIdent(SysNodesTableInfo.IDENT, NodeFsExpression.NAME);
        SysObjectReference fs = (SysObjectReference) resolver.getImplementation(ident);

        Joiner.MapJoiner mapJoiner = Joiner.on(", ").withKeyValueSeparator(":");
        Map<String, Object> v = fs.value();
        Map<String, Object> total = (Map<String, Object>) v.get("total");
        assertThat(mapJoiner.join(total),
                is("reads:84, bytes_written:84, bytes_read:84, available:86016, " +
                        "writes:84, used:84, size:86016"));
        Object[] disks = (Object[]) v.get("disks");
        assertThat(disks.length, is(2));
        Map<String, Object> disk0 = (Map<String, Object>) disks[0];
        assertThat((String)disk0.get("dev"), is("/dev/sda1"));
        assertThat((Long)disk0.get("size"), is(42L*1024));

        Map<String, Object> disk1 = (Map<String, Object>) disks[1];
        assertThat((String)disk1.get("dev"), is("/dev/sda2"));
        assertThat((Long)disk0.get("used"), is(42L*1024));

        Object[] data = (Object[]) v.get("data");
        assertThat(data.length, is(2));
        assertThat((String)((Map<String, Object>)data[0]).get("dev"), is("/dev/sda1"));
        assertThat((String)((Map<String, Object>)data[0]).get("path"), is("/foo"));

        assertThat((String)((Map<String, Object>)data[1]).get("dev"), is("/dev/sda2"));
        assertThat((String)((Map<String, Object>)data[1]).get("path"), is("/bar"));

        ident = new ReferenceIdent(SysNodesTableInfo.IDENT, NodeFsExpression.NAME, ImmutableList.of(NodeFsDataExpression.NAME, "dev"));
        SysExpression<Object[]> fsData = (SysExpression<Object[]>)resolver.getImplementation(ident);
        for (Object arrayElement : fsData.value()) {
            assertThat(arrayElement, instanceOf(BytesRef.class));
        }

View Full Code Here

    }

    @Test
    public void testFsWithoutSigar() throws Exception {
        sigarAvailable = false;
        ReferenceIdent ident = new ReferenceIdent(SysNodesTableInfo.IDENT, NodeFsExpression.NAME);
        SysObjectReference fs = (SysObjectReference) resolver.getImplementation(ident);

        Joiner.MapJoiner mapJoiner = Joiner.on(", ").withKeyValueSeparator(":");
        Map<String, Object> v = fs.value();
        Map<String, Object> total = (Map<String, Object>) v.get("total");
View Full Code Here

    }

    @Test
    public void testFsDataOnNonDataNode() throws Exception {
        isDataNode = false;
        ReferenceIdent ident = new ReferenceIdent(SysNodesTableInfo.IDENT, NodeFsExpression.NAME,
                ImmutableList.of("data"));
        SysObjectArrayReference fs = (SysObjectArrayReference) resolver.getImplementation(ident);
        assertThat(fs.value().length, is(0));
        isDataNode = true;
    }
View Full Code Here


    @Test
    public void testVersion() throws Exception {

        ReferenceIdent ident = new ReferenceIdent(SysNodesTableInfo.IDENT, "version");
        SysObjectReference version = (SysObjectReference) resolver.getImplementation(ident);

        Map<String, Object> v = version.value();
        assertEquals(Version.CURRENT.number(), v.get("number"));
        assertEquals(Build.CURRENT.hash(), v.get("build_hash"));
View Full Code Here

    }

    @Test
    public void testNetwork() throws Exception {
        ReferenceIdent ident = new ReferenceIdent(SysNodesTableInfo.IDENT, "network");
        SysObjectReference networkRef = (SysObjectReference) resolver.getImplementation(ident);

        Map<String, Object> networkStats = networkRef.value();
        assertThat(Joiner.on(", ").withKeyValueSeparator("=").join(networkStats),
                is("tcp={" +
View Full Code Here

TOP

Related Classes of io.crate.metadata.ReferenceIdent

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.