Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A1DB317FA8 for ; Tue, 21 Apr 2015 15:43:22 +0000 (UTC) Received: (qmail 82604 invoked by uid 500); 21 Apr 2015 15:43:22 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 82574 invoked by uid 500); 21 Apr 2015 15:43:22 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 82565 invoked by uid 99); 21 Apr 2015 15:43:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Apr 2015 15:43:22 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [54.164.171.186] (HELO mx1-us-east.apache.org) (54.164.171.186) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Apr 2015 15:43:17 +0000 Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 3D2B743E72 for ; Tue, 21 Apr 2015 15:42:57 +0000 (UTC) Received: (qmail 82038 invoked by uid 99); 21 Apr 2015 15:42:56 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Apr 2015 15:42:56 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BA726DFF85; Tue, 21 Apr 2015 15:42:56 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-ignite git commit: #ignite-710: Add tests - starting grids during putting data by datastreamer. . Date: Tue, 21 Apr 2015 15:42:56 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Repository: incubator-ignite Updated Branches: refs/heads/ignite-710 [created] b010fad7c #ignite-710: Add tests - starting grids during putting data by datastreamer. . Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b010fad7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b010fad7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b010fad7 Branch: refs/heads/ignite-710 Commit: b010fad7cfa5bd7e05c4ca3b5fc9f4a7ef6e8e69 Parents: 700cf08 Author: ivasilinets Authored: Tue Apr 21 18:42:07 2015 +0300 Committer: ivasilinets Committed: Tue Apr 21 18:42:07 2015 +0300 ---------------------------------------------------------------------- .../DataStreamerMultiThreadedSelfTest.java | 114 +++++++++++++++++++ 1 file changed, 114 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b010fad7/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java new file mode 100644 index 0000000..023730f --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java @@ -0,0 +1,114 @@ +/* + * 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.datastreamer; + +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.spi.discovery.tcp.*; +import org.apache.ignite.spi.discovery.tcp.ipfinder.*; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; +import org.apache.ignite.testframework.junits.common.*; + +import java.util.*; +import java.util.concurrent.atomic.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * Tests for DataStreamer. + */ +public class DataStreamerMultiThreadedSelfTest extends GridCommonAbstractTest { + /** IP finder. */ + private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); + discoSpi.setIpFinder(IP_FINDER); + + cfg.setDiscoverySpi(discoSpi); + + CacheConfiguration ccfg = defaultCacheConfiguration(); + + ccfg.setCacheMode(PARTITIONED); + ccfg.setBackups(1); + cfg.setCacheConfiguration(ccfg); + + if (gridName.contains("0")) + cfg.setClientMode(true); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + } + + /** + * @throws Exception If failed. + */ + public void testStartStopIgnites() throws Exception { + final Ignite ignite = startGrid(0); + + for (int a = 0; a < 10; ++a) { + final IgniteDataStreamer dataLdr = ignite.dataStreamer(null); + + final AtomicBoolean stop = new AtomicBoolean(); + final AtomicInteger id = new AtomicInteger(); + + IgniteInternalFuture fut = multithreadedAsync(new Runnable() { + @Override public void run() { + Set ignites = new HashSet<>(); + try { + for (int i = 1; i < 5; ++i) + ignites.add(startGrid(id.incrementAndGet())); + } + catch (Exception e) { + new IgniteException(e); + } + finally { + stop.set(true); + + System.out.println("!!!!!!!!!!!!!!!stop grid"); + + for (Ignite ignite1 : ignites) + stopGrid(ignite1.name()); + } + } + }, 2); + + int j = 0; + + while (!stop.get()) + dataLdr.addData(j++, j); + + fut.get(); + + ignite.cache(null).removeAll(); + } + } +}