ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: #ignite-710: Add tests - starting grids during putting data by datastreamer. .
Date Tue, 21 Apr 2015 15:42:56 GMT
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 <ivasilinets@gridgain.com>
Authored: Tue Apr 21 18:42:07 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
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<Object, Object> dataLdr = ignite.dataStreamer(null);
+
+            final AtomicBoolean stop = new AtomicBoolean();
+            final AtomicInteger id = new AtomicInteger();
+
+            IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+                @Override public void run() {
+                    Set<Ignite> 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();
+        }
+    }
+}


Mime
View raw message