use of io.crate.metadata.Reference in project crate by crate.
the class NodeStatsIteratorTest method prepare.
@Before
public void prepare() {
idRef = new Reference(new ReferenceIdent(SysNodesTableInfo.IDENT, SysNodesTableInfo.Columns.ID), RowGranularity.DOC, DataTypes.STRING);
nameRef = new Reference(new ReferenceIdent(SysNodesTableInfo.IDENT, SysNodesTableInfo.Columns.ID), RowGranularity.DOC, DataTypes.STRING);
hostnameRef = new Reference(new ReferenceIdent(SysNodesTableInfo.IDENT, SysNodesTableInfo.Columns.HOSTNAME), RowGranularity.DOC, DataTypes.STRING);
collectPhase = mock(RoutedCollectPhase.class);
when(collectPhase.whereClause()).thenReturn(WhereClause.NO_MATCH);
nodes.add(newNode("nodeOne"));
nodes.add(newNode("nodeTwo"));
}
use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsOnHandlerTest method testNestedBytesRefExpressionsString.
@Test
public void testNestedBytesRefExpressionsString() throws Exception {
Reference refInfo = refInfo("sys.nodes.version", DataTypes.OBJECT, RowGranularity.NODE);
collectExpression = resolver.getImplementation(refInfo);
collectExpression.setNextRow(CONTEXT);
Map<String, Object> version = (Map<String, Object>) collectExpression.value();
String versionNumber = (String) version.get("number");
refInfo = refInfo("sys.nodes.version", DataTypes.STRING, RowGranularity.NODE, "number");
collectExpression = resolver.getImplementation(refInfo);
collectExpression.setNextRow(CONTEXT);
assertThat(collectExpression.value(), Matchers.is(new BytesRef(versionNumber)));
}
use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsOnHandlerTest method testProcess.
@Test
public void testProcess() throws Exception {
Reference refInfo = refInfo("sys.nodes.process", DataTypes.OBJECT, RowGranularity.NODE);
collectExpression = resolver.getImplementation(refInfo);
collectExpression.setNextRow(CONTEXT);
Map<String, Object> expectedCpu = new HashMap<>(4);
expectedCpu.put("percent", (short) 50);
expectedCpu.put("system", 1000L);
expectedCpu.put("user", 500L);
Map<String, Object> v = (Map<String, Object>) collectExpression.value();
assertThat(v.get("open_file_descriptors"), is(42L));
assertThat(v.get("max_open_file_descriptors"), is(1000L));
assertThat(v.get("cpu"), Matchers.is(expectedCpu));
}
use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsOnHandlerTest method testNetworkTCP.
@Test
public void testNetworkTCP() throws Exception {
Reference refInfo = refInfo("sys.nodes.network", DataTypes.OBJECT, RowGranularity.NODE, "tcp");
collectExpression = resolver.getImplementation(refInfo);
collectExpression.setNextRow(CONTEXT);
Map<String, Object> tcpStats = (Map<String, Object>) collectExpression.value();
assertThat(tcpStats, instanceOf(Map.class));
assertThat(mapToSortedString(tcpStats), is("connections={accepted=42, curr_established=42, dropped=42, embryonic_dropped=42, initiated=42}, " + "packets={errors_received=42, received=42, retransmitted=42, rst_sent=42, sent=42}"));
}
use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsOnHandlerTest method testHeap.
@Test
public void testHeap() throws Exception {
Reference refInfo = refInfo("sys.nodes.heap", DataTypes.STRING, RowGranularity.NODE);
collectExpression = resolver.getImplementation(refInfo);
collectExpression.setNextRow(CONTEXT);
Map<String, Object> v = (Map<String, Object>) collectExpression.value();
assertThat(v.get("max"), is(123456L));
assertThat(v.get("used"), is(123456L));
assertThat(v.get("free"), is(0L));
}
Aggregations