use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsOnHandlerTest method testRestUrl.
@Test
public void testRestUrl() throws Exception {
Reference refInfo = refInfo("sys.nodes.rest_url", DataTypes.STRING, RowGranularity.NODE);
collectExpression = resolver.getImplementation(refInfo);
collectExpression.setNextRow(CONTEXT);
assertThat(BytesRefs.toBytesRef("10.0.0.1:4200"), is(collectExpression.value()));
}
use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsOnHandlerTest method testLoad.
@Test
public void testLoad() throws Exception {
Reference refInfo = refInfo("sys.nodes.load", DataTypes.OBJECT, RowGranularity.NODE);
collectExpression = resolver.getImplementation(refInfo);
collectExpression.setNextRow(CONTEXT);
Map<String, Object> v = (Map<String, Object>) collectExpression.value();
assertThat(v.get("1"), is(1D));
assertThat(v.get("5"), is(5D));
assertThat(v.get("15"), is(15D));
}
use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsWithDefaultExtendedStatsTest method testLoad.
@Test
public void testLoad() throws Exception {
prepare(true);
Reference refInfo = refInfo("sys.nodes.load", DataTypes.OBJECT, RowGranularity.NODE);
io.crate.operation.reference.NestedObjectExpression load = (io.crate.operation.reference.NestedObjectExpression) resolver.getChildImplementation(refInfo.ident().columnIdent().name());
Map<String, Object> loadValue = load.value();
assertThat((Double) loadValue.get("1"), is(-1.0d));
assertThat((Double) loadValue.get("5"), is(-1.0d));
assertThat((Double) loadValue.get("15"), is(-1.0d));
}
use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsWithDefaultExtendedStatsTest method testFs.
@Test
public void testFs() throws Exception {
prepare(true);
Reference refInfo = refInfo("sys.nodes.fs", DataTypes.STRING, RowGranularity.NODE);
io.crate.operation.reference.NestedObjectExpression fs = (io.crate.operation.reference.NestedObjectExpression) resolver.getChildImplementation(refInfo.ident().columnIdent().name());
Map<String, Object> v = fs.value();
//noinspection unchecked
assertThat(mapToSortedString((Map<String, Object>) v.get("total")), is("available=-1, bytes_read=-1, bytes_written=-1, reads=-1, size=-1, used=-1, writes=-1"));
Object[] disks = (Object[]) v.get("disks");
assertThat(disks.length, is(0));
Object[] data = (Object[]) v.get("data");
assertThat(data.length, is(0));
}
use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsWithDefaultExtendedStatsTest method testFsDataOnNonDataNode.
@Test
public void testFsDataOnNonDataNode() throws Exception {
prepare(false);
Reference refInfo = refInfo("sys.nodes.fs", DataTypes.STRING, RowGranularity.NODE, "data");
ColumnIdent columnIdent = refInfo.ident().columnIdent();
NestedObjectExpression fs = (NestedObjectExpression) resolver.getChildImplementation(columnIdent.name());
assertThat(((Object[]) fs.getChildImplementation(columnIdent.path().get(0)).value()).length, is(0));
}
Aggregations