use of org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker.AttributeVisitor in project ignite by apache.
the class SystemViewCommandTest method systemView.
/**
* Gets system view content via control utility from specified node. Here we also check if attributes names
* returned by the command match the real ones. And that both "SQL" and "Java" command names styles are supported.
*
* @param node The node to obtain system view from.
* @param sysViewName Name of the system view which content is required.
* @return Content of the requested system view.
*/
private List<List<String>> systemView(IgniteEx node, String sysViewName) {
List<String> attrNames = new ArrayList<>();
SystemView<?> sysView = node.context().systemView().view(sysViewName);
sysView.walker().visitAll(new AttributeVisitor() {
@Override
public <T> void accept(int idx, String name, Class<T> clazz) {
attrNames.add(name);
}
});
String nodeId = node.context().discovery().localNode().id().toString();
List<List<String>> rows = parseSystemViewCommandOutput(executeCommand(EXIT_CODE_OK, CMD_SYS_VIEW, toSqlName(sysViewName), NODE_ID.argName(), nodeId));
assertEquals(attrNames, rows.get(0));
rows = parseSystemViewCommandOutput(executeCommand(EXIT_CODE_OK, CMD_SYS_VIEW, toSqlName(sysViewName).toLowerCase(), NODE_ID.argName(), nodeId));
assertEquals(attrNames, rows.get(0));
rows = parseSystemViewCommandOutput(executeCommand(EXIT_CODE_OK, CMD_SYS_VIEW, sysViewName, NODE_ID.argName(), nodeId));
assertEquals(attrNames, rows.remove(0));
int attrsCnt = sysView.walker().count();
rows.forEach(row -> assertEquals(attrsCnt, row.size()));
return rows;
}
use of org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker.AttributeVisitor in project ignite by apache.
the class SystemViewLocal method columnsList.
/**
* Extract column array for specific {@link SystemView}.
*
* @param sysView System view.
* @param <R> Row type.
* @return SQL column array for {@code sysView}.
*/
private static <R> Column[] columnsList(SystemView<R> sysView) {
Column[] cols = new Column[sysView.walker().count()];
sysView.walker().visitAll(new AttributeVisitor() {
@Override
public <T> void accept(int idx, String name, Class<T> clazz) {
int type = CLS_TO_VAL_TYPE.getOrDefault(clazz, Value.STRING);
cols[idx] = newColumn(toSqlName(name), type);
}
});
return cols;
}
Aggregations