Package io.crate.action.sql

Examples of io.crate.action.sql.SQLResponse


    }

    @Test
    public void testThreadPools() throws Exception {
        SQLResponse response = executor.exec("select thread_pools from sys.nodes limit 1");

        Object[] threadPools = (Object[]) response.rows()[0][0];
        assertThat(threadPools.length, greaterThanOrEqualTo(1));

        Map<String, Object> threadPool = (Map<String, Object>) threadPools[0];
        assertThat((String) threadPool.get("name"), is("generic"));
        assertThat((Integer) threadPool.get("active"), greaterThanOrEqualTo(0));
View Full Code Here


        assertThat((Integer) threadPool.get("queue"), greaterThanOrEqualTo(0));
    }

    @Test
    public void testThreadPoolValue() throws Exception {
        SQLResponse response = executor.exec("select thread_pools['name'], thread_pools['queue'] from sys.nodes limit 1");
        assertThat(response.rowCount(), is(1L));

        Object[] names = (Object[]) response.rows()[0][0];
        assertThat(names.length, greaterThanOrEqualTo(1));
        assertThat((String) names[0], is("generic"));

        Object[] queues = (Object[]) response.rows()[0][1];
        assertThat(queues.length, greaterThanOrEqualTo(1));
        assertThat((Integer) queues[0], greaterThanOrEqualTo(0));
    }
View Full Code Here

        assertThat((Integer) queues[0], greaterThanOrEqualTo(0));
    }

    @Test
    public void testNetwork() throws Exception {
        SQLResponse response = executor.exec("select network from sys.nodes limit 1");
        assertThat(response.rowCount(), is(1L));

        Map<String, Object> network = (Map<String, Object>)response.rows()[0][0];
        assertThat(network, hasKey("tcp"));
        Map<String, Object> tcp = (Map<String, Object>)network.get("tcp");
        assertNetworkTCP(tcp);


        response = executor.exec("select network['tcp'] from sys.nodes limit 1");
        assertThat(response.rowCount(), is(1L));
        tcp = (Map<String, Object>)response.rows()[0][0];
        assertNetworkTCP(tcp);
    }
View Full Code Here

        assertThat(packets.keySet(), hasItems("sent", "received", "errors_received", "retransmitted", "rst_sent"));
    }

    @Test
    public void testNetworkTcpConnectionFields() throws Exception {
        SQLResponse response = executor.exec("select " +
                "network['tcp']['connections']['initiated'], " +
                "network['tcp']['connections']['accepted'], " +
                "network['tcp']['connections']['curr_established']," +
                "network['tcp']['connections']['dropped']," +
                "network['tcp']['connections']['embryonic_dropped']" +
                " from sys.nodes limit 1");
        assertThat(response.rowCount(), is(1L));
        for (int i=0; i< response.cols().length; i++) {
            assertThat((Long) response.rows()[0][i], greaterThanOrEqualTo(-1L));
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testNetworkTcpPacketsFields() throws Exception {
        SQLResponse response = executor.exec("select " +
                "network['tcp']['packets']['sent'], " +
                "network['tcp']['packets']['received'], " +
                "network['tcp']['packets']['retransmitted'], " +
                "network['tcp']['packets']['errors_received'], " +
                "network['tcp']['packets']['rst_sent'] " +
                "from sys.nodes limit 1");
        assertThat(response.rowCount(), is(1L));
        for (int i = 0; i < response.cols().length; i++) {
            assertThat((Long) response.rows()[0][i], greaterThanOrEqualTo(-1L));
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testSysNodesOs() throws Exception {
        SQLResponse response = executor.exec("select os from sys.nodes limit 1");
        Map results = (Map) response.rows()[0][0];
        assertThat(response.rowCount(), is(1L));

        assertThat((Long) results.get("timestamp"), greaterThan(0L));
        assertThat((Long) results.get("uptime"), greaterThan(0L));

        assertThat((Short) ((Map) results.get("cpu")).get("system"), greaterThanOrEqualTo((short) 0));
View Full Code Here

        assertThat((Short) ((Map) results.get("cpu")).get("stolen"), lessThanOrEqualTo((short) 100));
    }

    @Test
    public void testSysNodesProcess() throws Exception {
        SQLResponse response = executor.exec("select process['open_file_descriptors'], " +
                "process['max_open_file_descriptors'] " +
                "from sys.nodes limit 1");
        for (int i = 0; i < response.cols().length; i++) {
            assertThat((Long) response.rows()[0][i], greaterThanOrEqualTo(-1L));
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testFs() throws Exception {
        SQLResponse response = executor.exec("select fs from sys.nodes limit 1");
        assertThat(response.rowCount(), is(1L));
        assertThat(response.rows()[0][0], instanceOf(Map.class));
        Map<String, Object> fs = (Map<String, Object>)response.rows()[0][0];
        assertThat(fs.keySet().size(), is(3));
        assertThat(fs.keySet(), hasItems("total", "disks", "data"));

        Map<String, Object> total = (Map<String, Object>) fs.get("total");
        assertThat(total.keySet(), hasItems("size", "used", "available", "reads", "writes",
View Full Code Here

        assertThat(someData.keySet(), hasItems("dev", "path"));
    }

    @Test
    public void testFsNoRootFS() throws Exception {
        SQLResponse response = executor.exec("select fs['data']['dev'], fs['disks'] from sys.nodes");
        assertThat(response.rowCount(), is(2L));
        for (Object[] row : response.rows()) {
            // data device name
            for (Object diskDevName : (Object[])row[0]) {
                assertThat((String)diskDevName, is(not("rootfs")));
            }
            Object[] disks = (Object[])row[1];
View Full Code Here

        }
    }

    @Test
    public void testSysNodesObjectArrayStringChildColumn() throws Exception {
        SQLResponse response = executor.exec("select fs['data']['path'] from sys.nodes");
        assertThat(response.rowCount(), Matchers.is(2L));
        for (Object path : (Object[])response.rows()[0][0]) {
            assertThat(path, instanceOf(String.class));
        }
    }
View Full Code Here

TOP

Related Classes of io.crate.action.sql.SQLResponse

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.