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));
}
Aggregations