Search in sources :

Example 1 with Arrays.stream

use of java.util.Arrays.stream in project ignite by apache.

the class GridCommandHandlerClusterByClassTest method testCacheDistribution.

/**
 */
@Test
public void testCacheDistribution() {
    Ignite ignite = crd;
    createCacheAndPreload(ignite, 100);
    injectTestSystemOut();
    // Run distribution for all node and all cache
    assertEquals(EXIT_CODE_OK, execute("--cache", "distribution", "null"));
    String out = testOut.toString();
    // Result include info by cache "default"
    assertContains(log, out, "[next group: id=1544803905, name=default]");
    // Result include info by cache "ignite-sys-cache"
    assertContains(log, out, "[next group: id=-2100569601, name=ignite-sys-cache]");
    // Run distribution for all node and all cache and include additional user attribute
    assertEquals(EXIT_CODE_OK, execute("--cache", "distribution", "null", "--user-attributes", "ZONE,CELL,DC"));
    out += "\n" + testOut.toString();
    List<String> outLines = Arrays.stream(out.split("\n")).map(String::trim).collect(toList());
    int firstIndex = outLines.indexOf("[next group: id=1544803905, name=default]");
    int lastIndex = outLines.lastIndexOf("[next group: id=1544803905, name=default]");
    String dataLine = outLines.get(firstIndex + 1);
    String userArrtDataLine = outLines.get(lastIndex + 1);
    long commaNum = dataLine.chars().filter(i -> i == ',').count();
    long userArrtCommaNum = userArrtDataLine.chars().filter(i -> i == ',').count();
    // Check that number of columns increased by 3
    assertEquals(3, userArrtCommaNum - commaNum);
}
Also used : Arrays(java.util.Arrays) CacheType(org.apache.ignite.internal.processors.cache.CacheType) STRATEGY(org.apache.ignite.internal.commandline.consistency.ConsistencyCommand.STRATEGY) CACHE_NAMES_ARG(org.apache.ignite.internal.commandline.cache.CacheDestroy.CACHE_NAMES_ARG) Matcher(java.util.regex.Matcher) EXIT_CODE_INVALID_ARGUMENTS(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_INVALID_ARGUMENTS) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) DESTROY_ALL_ARG(org.apache.ignite.internal.commandline.cache.CacheDestroy.DESTROY_ALL_ARG) Path(java.nio.file.Path) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) EnumMap(java.util.EnumMap) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Set(java.util.Set) READ_COMMITTED(org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED) CacheSubcommands(org.apache.ignite.internal.commandline.cache.CacheSubcommands) Executors(java.util.concurrent.Executors) IgniteCache(org.apache.ignite.IgniteCache) EXIT_CODE_CONNECTION_FAILED(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_CONNECTION_FAILED) CountDownLatch(java.util.concurrent.CountDownLatch) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) CommonArgParser(org.apache.ignite.internal.commandline.CommonArgParser) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) BASELINE(org.apache.ignite.internal.commandline.CommandList.BASELINE) CommandArg(org.apache.ignite.internal.commandline.argument.CommandArg) U(org.apache.ignite.internal.util.typedef.internal.U) MULTI_LINE(org.apache.ignite.internal.commandline.OutputFormat.MULTI_LINE) EXIT_CODE_OK(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) S(org.apache.ignite.internal.util.typedef.internal.S) CONSISTENCY(org.apache.ignite.internal.commandline.CommandList.CONSISTENCY) StreamHandler(java.util.logging.StreamHandler) IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager) GridAbstractTest(org.apache.ignite.testframework.junits.GridAbstractTest) Files(java.nio.file.Files) IOException(java.io.IOException) VisorTxTaskResult(org.apache.ignite.internal.visor.tx.VisorTxTaskResult) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) TRANSACTIONAL(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) TransactionRollbackException(org.apache.ignite.transactions.TransactionRollbackException) TreeMap(java.util.TreeMap) Paths(java.nio.file.Paths) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IgniteVersionUtils(org.apache.ignite.internal.IgniteVersionUtils) IGNITE_ENABLE_EXPERIMENTAL_COMMAND(org.apache.ignite.IgniteSystemProperties.IGNITE_ENABLE_EXPERIMENTAL_COMMAND) IgniteDataStreamer(org.apache.ignite.IgniteDataStreamer) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) Transaction(org.apache.ignite.transactions.Transaction) CONFIRM_MSG(org.apache.ignite.internal.commandline.CommandHandler.CONFIRM_MSG) CMD_VERBOSE(org.apache.ignite.internal.commandline.CommonArgParser.CMD_VERBOSE) IgniteEx(org.apache.ignite.internal.IgniteEx) Formatter(java.util.logging.Formatter) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteCluster(org.apache.ignite.IgniteCluster) CacheDestroy(org.apache.ignite.internal.commandline.cache.CacheDestroy) X(org.apache.ignite.internal.util.typedef.X) METADATA(org.apache.ignite.internal.commandline.CommandList.METADATA) TestStorageUtils.corruptDataEntry(org.apache.ignite.util.TestStorageUtils.corruptDataEntry) Collection(java.util.Collection) OPTIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC) UUID(java.util.UUID) CommandList(org.apache.ignite.internal.commandline.CommandList) LogRecord(java.util.logging.LogRecord) Logger(java.util.logging.Logger) List(java.util.List) CU(org.apache.ignite.internal.util.typedef.internal.CU) UTILITY_NAME(org.apache.ignite.internal.commandline.CommandHandler.UTILITY_NAME) GridTestUtils.readResource(org.apache.ignite.testframework.GridTestUtils.readResource) Pattern(java.util.regex.Pattern) GridCacheInternalKeyImpl(org.apache.ignite.internal.processors.datastructures.GridCacheInternalKeyImpl) NotNull(org.jetbrains.annotations.NotNull) Objects.nonNull(java.util.Objects.nonNull) Arrays.stream(java.util.Arrays.stream) SINGLE_LINE(org.apache.ignite.internal.commandline.OutputFormat.SINGLE_LINE) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) WAL(org.apache.ignite.internal.commandline.CommandList.WAL) DESTROY(org.apache.ignite.internal.commandline.cache.CacheSubcommands.DESTROY) CacheGroupContext(org.apache.ignite.internal.processors.cache.CacheGroupContext) HashSet(java.util.HashSet) PARTITION(org.apache.ignite.internal.commandline.consistency.ConsistencyCommand.PARTITION) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration) GridTestUtils.assertNotContains(org.apache.ignite.testframework.GridTestUtils.assertNotContains) ExecutorService(java.util.concurrent.ExecutorService) G(org.apache.ignite.internal.util.typedef.G) F(org.apache.ignite.internal.util.typedef.F) CACHE(org.apache.ignite.internal.commandline.consistency.ConsistencyCommand.CACHE) HELP(org.apache.ignite.internal.commandline.cache.CacheSubcommands.HELP) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) EXIT_CODE_UNEXPECTED_ERROR(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_UNEXPECTED_ERROR) GridTestUtils.assertContains(org.apache.ignite.testframework.GridTestUtils.assertContains) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Collectors.toList(java.util.stream.Collectors.toList) TransactionState(org.apache.ignite.transactions.TransactionState) TRACING_CONFIGURATION(org.apache.ignite.internal.commandline.CommandList.TRACING_CONFIGURATION) Collections(java.util.Collections) Ignite(org.apache.ignite.Ignite) GridAbstractTest(org.apache.ignite.testframework.junits.GridAbstractTest) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Arrays.stream (java.util.Arrays.stream)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 EnumMap (java.util.EnumMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects.nonNull (java.util.Objects.nonNull)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 UUID (java.util.UUID)1 CountDownLatch (java.util.concurrent.CountDownLatch)1