Search in sources :

Example 1 with ThreadPools

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

the class NodeStatsContextTest method testStreamThreadPools.

@Test
public void testStreamThreadPools() throws Exception {
    ThreadPools pools1 = ThreadPools.newInstance();
    int size = 3;
    for (int i = 0; i < size; i++) {
        ThreadPools.ThreadPoolExecutorContext ctx = new ThreadPools.ThreadPoolExecutorContext(10 * i + 1, 10 * i + 2, 10 * i + 3, 10 * i + 4, 100L * i + 1L, 100L * i + 2L);
        pools1.add(String.format("threadpool-%d", i), ctx);
    }
    ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
    StreamOutput out = new OutputStreamStreamOutput(outBuffer);
    pools1.writeTo(out);
    ByteArrayInputStream inBuffer = new ByteArrayInputStream(outBuffer.toByteArray());
    InputStreamStreamInput in = new InputStreamStreamInput(inBuffer);
    ThreadPools pools2 = ThreadPools.newInstance();
    pools2.readFrom(in);
    assertThat(pools1, is(pools2));
}
Also used : ThreadPools(io.crate.monitor.ThreadPools) OutputStreamStreamOutput(org.elasticsearch.common.io.stream.OutputStreamStreamOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) StreamOutput(org.elasticsearch.common.io.stream.StreamOutput) OutputStreamStreamOutput(org.elasticsearch.common.io.stream.OutputStreamStreamOutput) InputStreamStreamInput(org.elasticsearch.common.io.stream.InputStreamStreamInput) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

ThreadPools (io.crate.monitor.ThreadPools)1 CrateUnitTest (io.crate.test.integration.CrateUnitTest)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStreamStreamInput (org.elasticsearch.common.io.stream.InputStreamStreamInput)1 OutputStreamStreamOutput (org.elasticsearch.common.io.stream.OutputStreamStreamOutput)1 StreamOutput (org.elasticsearch.common.io.stream.StreamOutput)1 Test (org.junit.Test)1