ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject incubator-ignite git commit: # GG-10281: WIP.
Date Tue, 09 Jun 2015 08:00:11 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-gg-10281 [created] 451754f96


# GG-10281: WIP.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/451754f9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/451754f9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/451754f9

Branch: refs/heads/ignite-gg-10281
Commit: 451754f96da928fee7b84a0d1abd8f3ef233f001
Parents: c232631
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Tue Jun 9 11:00:04 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Jun 9 11:00:04 2015 +0300

----------------------------------------------------------------------
 .../internal/interop/InteropIgnition.java       | 52 +++++++++++++++++++-
 .../internal/interop/InteropProcessor.java      |  8 +++
 2 files changed, 58 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/451754f9/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
index 3ccd361..d8cc276 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
@@ -35,6 +35,9 @@ import java.util.*;
  */
 @SuppressWarnings("UnusedDeclaration")
 public class InteropIgnition {
+    /** Map with active instances. */
+    private static final HashMap<String, InteropProcessor> instances = new HashMap<>();
+
     /**
      * Start Ignite node in interop mode.
      *
@@ -44,8 +47,8 @@ public class InteropIgnition {
      * @param envPtr Environment pointer.
      * @return Ignite instance.
      */
-    public static InteropProcessor start(@Nullable String springCfgPath, @Nullable String
gridName, int factoryId,
-        long envPtr) {
+    public static synchronized InteropProcessor start(@Nullable String springCfgPath, @Nullable
String gridName,
+        int factoryId, long envPtr) {
         IgniteConfiguration cfg = configuration(springCfgPath);
 
         if (gridName != null)
@@ -57,10 +60,55 @@ public class InteropIgnition {
 
         trackFinalization(proc);
 
+        InteropProcessor old = instances.put(gridName, proc);
+
+        assert old == null;
+
         return proc;
     }
 
     /**
+     * Get instance by environment pointer.
+     *
+     * @param gridName Grid name.
+     * @return Instance or {@code null} if it doesn't exists (never started or stopped).
+     */
+    @Nullable public static synchronized InteropProcessor instance(@Nullable String gridName)
{
+        return instances.get(gridName);
+    }
+
+    /**
+     * Stop single instance.
+     *
+     * @param gridName Grid name,
+     * @param cancel Cancel flag.
+     * @return {@code True} if instance was found and stopped.
+     */
+    public static synchronized boolean stop(@Nullable String gridName, boolean cancel) {
+        if (Ignition.stop(gridName, cancel)) {
+            InteropProcessor old = instances.remove(gridName);
+
+            assert old != null;
+
+            return true;
+        }
+        else
+            return false;
+    }
+
+    /**
+     * Stop all instances.
+     *
+     * @param cancel Cancel flag.
+     */
+    public static synchronized void stopAll(boolean cancel) {
+        for (InteropProcessor proc : instances.values())
+            Ignition.stop(proc.ignite().name(), cancel);
+
+        instances.clear();
+    }
+
+    /**
      * Create configuration.
      *
      * @param springCfgPath Path to Spring XML.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/451754f9/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java
index aa4f877..325a464 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.interop;
 
+import org.apache.ignite.*;
 import org.jetbrains.annotations.*;
 
 /**
@@ -24,6 +25,13 @@ import org.jetbrains.annotations.*;
  */
 public interface InteropProcessor {
     /**
+     * Get owning Ignite instance.
+     *
+     * @return Ignite instance.
+     */
+    public Ignite ignite();
+
+    /**
      * Get stop runnable to perform cleanup when interop is not longer used.
      * <p/>
      * <b>NOTE!</b> This runnable is called when current instance of interop
processor is eligible for garbage


Mime
View raw message