Search in sources :

Example 1 with IndexListInfoContainer

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);
}
Also used : CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) IndexListInfoContainer(org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer)

Example 2 with IndexListInfoContainer

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);
}
Also used : CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) IndexListInfoContainer(org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer)

Example 3 with IndexListInfoContainer

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;
}
Also used : GridClient(org.apache.ignite.internal.client.GridClient) UUID(java.util.UUID) IndexListTaskArg(org.apache.ignite.internal.visor.cache.index.IndexListTaskArg) IndexListInfoContainer(org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer)

Example 4 with IndexListInfoContainer

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("");
}
Also used : ArrayList(java.util.ArrayList) IndexListInfoContainer(org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer)

Example 5 with IndexListInfoContainer

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);
}
Also used : Arrays(java.util.Arrays) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) Predicate(java.util.function.Predicate) Set(java.util.Set) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) CACHE_NAME_SECOND(org.apache.ignite.util.GridCommandHandlerIndexingUtils.CACHE_NAME_SECOND) EXIT_CODE_OK(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK) GROUP_NAME_SECOND(org.apache.ignite.util.GridCommandHandlerIndexingUtils.GROUP_NAME_SECOND) CacheCommands(org.apache.ignite.internal.commandline.cache.CacheCommands) CACHE_NAME(org.apache.ignite.util.GridCommandHandlerIndexingUtils.CACHE_NAME) THREE_ENTRIES_CACHE_NAME_COMMON_PART(org.apache.ignite.util.GridCommandHandlerIndexingUtils.THREE_ENTRIES_CACHE_NAME_COMMON_PART) GridCommandHandlerIndexingUtils.createAndFillSeveralCaches(org.apache.ignite.util.GridCommandHandlerIndexingUtils.createAndFillSeveralCaches) IgniteDataStreamer(org.apache.ignite.IgniteDataStreamer) GROUP_NAME(org.apache.ignite.util.GridCommandHandlerIndexingUtils.GROUP_NAME) IndexListInfoContainer(org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) IndexListInfoContainer(org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer) Test(org.junit.Test)

Aggregations

IndexListInfoContainer (org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer)5 CommandHandler (org.apache.ignite.internal.commandline.CommandHandler)3 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Set (java.util.Set)1 UUID (java.util.UUID)1 Predicate (java.util.function.Predicate)1 Ignite (org.apache.ignite.Ignite)1 IgniteDataStreamer (org.apache.ignite.IgniteDataStreamer)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 GridClient (org.apache.ignite.internal.client.GridClient)1 EXIT_CODE_OK (org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK)1 CacheCommands (org.apache.ignite.internal.commandline.cache.CacheCommands)1 IndexListTaskArg (org.apache.ignite.internal.visor.cache.index.IndexListTaskArg)1 CACHE_NAME (org.apache.ignite.util.GridCommandHandlerIndexingUtils.CACHE_NAME)1 CACHE_NAME_SECOND (org.apache.ignite.util.GridCommandHandlerIndexingUtils.CACHE_NAME_SECOND)1 GROUP_NAME (org.apache.ignite.util.GridCommandHandlerIndexingUtils.GROUP_NAME)1 GROUP_NAME_SECOND (org.apache.ignite.util.GridCommandHandlerIndexingUtils.GROUP_NAME_SECOND)1 THREE_ENTRIES_CACHE_NAME_COMMON_PART (org.apache.ignite.util.GridCommandHandlerIndexingUtils.THREE_ENTRIES_CACHE_NAME_COMMON_PART)1 GridCommandHandlerIndexingUtils.createAndFillSeveralCaches (org.apache.ignite.util.GridCommandHandlerIndexingUtils.createAndFillSeveralCaches)1