use of org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer in project ignite by apache.
the class GridCommandHandlerIndexListTest method checkGroup.
/**
*/
private void checkGroup(String grpRegEx, Predicate<String> predicate, int expectedResNum) {
final CommandHandler handler = new CommandHandler(createTestLogger());
assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_list", "--group-name", grpRegEx));
Set<IndexListInfoContainer> cmdResult = handler.getLastOperationResult();
assertNotNull(cmdResult);
boolean isResCorrect = cmdResult.stream().map(IndexListInfoContainer::groupName).allMatch(predicate);
assertTrue("Unexpected command result", isResCorrect);
int indexesNum = cmdResult.size();
assertEquals("Unexpected number of indexes: " + indexesNum, indexesNum, expectedResNum);
}
use of org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer in project ignite by apache.
the class GridCommandHandlerIndexListTest method checkCacheNameFilter.
/**
*/
private void checkCacheNameFilter(String cacheRegEx, Predicate<String> predicate, int expectedResNum) {
final CommandHandler handler = new CommandHandler(createTestLogger());
assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_list", "--cache-name", cacheRegEx));
Set<IndexListInfoContainer> cmdResult = handler.getLastOperationResult();
assertNotNull(cmdResult);
boolean isResCorrect = cmdResult.stream().map(IndexListInfoContainer::cacheName).allMatch(predicate);
assertTrue("Unexpected command result", isResCorrect);
int indexesNum = cmdResult.size();
assertEquals("Unexpected number of indexes: " + indexesNum, indexesNum, expectedResNum);
}
use of org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer in project ignite by apache.
the class CacheIndexesList method execute.
/**
* {@inheritDoc}
*/
@Override
public Object execute(GridClientConfiguration clientCfg, Logger logger) throws Exception {
Set<IndexListInfoContainer> taskRes;
final UUID nodeId = args.nodeId;
IndexListTaskArg taskArg = new IndexListTaskArg(args.groupsRegEx, args.cachesRegEx, args.indexesRegEx);
try (GridClient client = Command.startClient(clientCfg)) {
taskRes = TaskExecutor.executeTaskByNameOnNode(client, "org.apache.ignite.internal.visor.cache.index.IndexListTask", taskArg, nodeId, clientCfg);
}
printIndexes(taskRes, logger);
return taskRes;
}
use of org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer in project ignite by apache.
the class CacheIndexesList method printIndexes.
/**
* Prints indexes info.
*
* @param res Set of indexes info to print.
* @param logger Logger to use.
*/
private void printIndexes(Set<IndexListInfoContainer> res, Logger logger) {
List<IndexListInfoContainer> sorted = new ArrayList<>(res);
sorted.sort(IndexListInfoContainer.comparator());
String prevGrpName = "";
for (IndexListInfoContainer container : sorted) {
if (!prevGrpName.equals(container.groupName())) {
prevGrpName = container.groupName();
logger.info("");
}
logger.info(container.toString());
}
logger.info("");
}
use of org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer in project ignite by apache.
the class GridCommandHandlerIndexListTest method testCacheIndexList.
/**
* Tests --index name option and output correctness.
*/
@Test
public void testCacheIndexList() {
final String idxName = "PERSON_ORGID_ASC_IDX";
final int expectedLinesNum = 15;
final int expectedIndexDescrLinesNum = 2;
injectTestSystemOut();
final CommandHandler handler = new CommandHandler(createTestLogger());
assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_list", "--index-name", idxName));
String outStr = testOut.toString();
assertTrue(outStr.contains("grpName=" + GROUP_NAME + ", cacheName=" + CACHE_NAME + ", idxName=PERSON_ORGID_ASC_IDX, " + "colsNames=ArrayList [ORGID, _KEY], tblName=PERSON"));
assertTrue(outStr.contains("grpName=" + GROUP_NAME_SECOND + ", cacheName=" + CACHE_NAME_SECOND + ", idxName=PERSON_ORGID_ASC_IDX, colsNames=ArrayList [ORGID, _KEY], tblName=PERSON"));
final String[] outputLines = outStr.split("\n");
int outputLinesNum = outputLines.length;
assertEquals("Unexpected number of lines: " + outputLinesNum, outputLinesNum, expectedLinesNum);
long indexDescrLinesNum = Arrays.stream(outputLines).filter(s -> s.contains("grpName=")).count();
assertEquals("Unexpected number of index description lines: " + indexDescrLinesNum, indexDescrLinesNum, expectedIndexDescrLinesNum);
Set<IndexListInfoContainer> cmdResult = handler.getLastOperationResult();
assertNotNull(cmdResult);
final int resSetSize = cmdResult.size();
assertEquals("Unexpected result set size: " + resSetSize, resSetSize, 2);
boolean isResSetCorrect = cmdResult.stream().map(IndexListInfoContainer::indexName).allMatch((name) -> name.equals(idxName));
assertTrue("Unexpected result set", isResSetCorrect);
}
Aggregations