Added test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/194df76c Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/194df76c Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/194df76c Branch: refs/heads/ignite-884 Commit: 194df76cbed6e0799f01819851bedabc00d39fab Parents: c47a706 Author: sboikov <sboi...@gridgain.com> Authored: Wed Aug 26 10:44:49 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Wed Aug 26 10:44:49 2015 +0300 ---------------------------------------------------------------------- .../IgniteCacheManyAsyncOperationsTest.java | 107 +++++++++++++++++++ 1 file changed, 107 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/194df76c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java new file mode 100644 index 0000000..ab4f1b8 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.lang.*; + +import java.util.*; + +import static org.apache.ignite.cache.CacheAtomicityMode.*; +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class IgniteCacheManyAsyncOperationsTest extends IgniteCacheAbstractTest { + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 2; + } + + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return PARTITIONED; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return TRANSACTIONAL; + } + + /** {@inheritDoc} */ + @Override protected NearCacheConfiguration nearConfiguration() { + return null; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + if (gridName.equals(getTestGridName(2))) + cfg.setClientMode(true); + + return cfg; + } + + /** + * @throws Exception If failed. + */ + public void testManyAsyncOperations() throws Exception { + try (Ignite client = startGrid(gridCount())) { + assertTrue(client.configuration().isClientMode()); + + IgniteCache<Object, Object> cache = client.cache(null).withAsync(); + + final int ASYNC_OPS = cache.getConfiguration(CacheConfiguration.class).getMaxConcurrentAsyncOperations(); + + log.info("Number of async operations: " + ASYNC_OPS); + + Map<Integer, byte[]> map = new HashMap<>(); + + for (int i = 0; i < 500; i++) + map.put(i, new byte[128]); + + for (int iter = 0; iter < 3; iter++) { + log.info("Iteration: " + iter); + + List<IgniteFuture<?>> futs = new ArrayList<>(ASYNC_OPS); + + for (int i = 0; i < ASYNC_OPS; i++) { + cache.putAll(map); + + futs.add(cache.future()); + + if (i % 50 == 0) + log.info("Created futures: " + (i + 1)); + } + + for (int i = 0; i < ASYNC_OPS; i++) { + IgniteFuture<?> fut = futs.get(i); + + fut.get(); + + if (i % 50 == 0) + log.info("Done: " + (i + 1)); + } + } + } + } +}