ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [43/43] ignite git commit: IGNITE-3335: Improved affinity.
Date Fri, 17 Jun 2016 12:39:12 GMT
IGNITE-3335: Improved affinity.


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

Branch: refs/heads/ignite-3335
Commit: 87d654452c98cf0840c54e9b860c6d1bae8d07fc
Parents: df60f65
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Fri Jun 17 15:38:12 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Fri Jun 17 15:38:12 2016 +0300

----------------------------------------------------------------------
 .../processors/igfs/IgfsDeleteWorker.java       |  2 +-
 .../processors/igfs/IgfsMetaManager.java        | 50 ++++++++++++++++----
 2 files changed, 42 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/87d65445/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
index 310090d..8c87e97 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
@@ -39,7 +39,7 @@ import java.util.concurrent.locks.ReentrantLock;
  */
 public class IgfsDeleteWorker extends IgfsThread {
     /** Awake frequency, */
-    private static final long FREQUENCY = 1000;
+    private static final long FREQUENCY = 100;
 
     /** How many files/folders to delete at once (i.e in a single transaction). */
     private static final int MAX_DELETE_BATCH = 100;

http://git-wip-us.apache.org/repos/asf/ignite/blob/87d65445/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index 8f1bb69..16f3a4f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -22,6 +22,7 @@ import org.apache.ignite.IgniteCompute;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteInterruptedException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cluster.ClusterGroup;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.cluster.ClusterTopologyException;
@@ -52,14 +53,14 @@ import org.apache.ignite.internal.processors.igfs.client.meta.IgfsClientMetaFile
 import org.apache.ignite.internal.processors.igfs.client.meta.IgfsClientMetaIdsForPathCallable;
 import org.apache.ignite.internal.processors.igfs.client.meta.IgfsClientMetaInfoForPathCallable;
 import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryCreateProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingAddProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingRemoveProcessor;
 import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingRenameProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingReplaceProcessor;
 import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileCreateProcessor;
 import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileLockProcessor;
 import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileReserveSpaceProcessor;
 import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileUnlockProcessor;
-import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingAddProcessor;
-import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingRemoveProcessor;
-import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingReplaceProcessor;
 import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdatePropertiesProcessor;
 import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdateTimesProcessor;
 import org.apache.ignite.internal.util.GridLeanMap;
@@ -152,10 +153,13 @@ public class IgfsMetaManager extends IgfsManager {
     private final boolean client;
 
     /** Compute facade. */
-    private IgniteCompute compute;
+    private volatile IgniteCompute compute;
 
     /** Compute facade for client tasks. */
-    private IgniteCompute metaCompute;
+    private volatile IgniteCompute metaCompute;
+
+    /** Root partition. */
+    private volatile int rootPart = -1;
 
     /**
      * Constructor.
@@ -260,9 +264,14 @@ public class IgfsMetaManager extends IgfsManager {
 
                 return compute().affinityCall(cfg.getMetaCacheName(), affKey, task);
             }
-            else
-                // Otherwise we route to any available data node.
-                return metaCompute().call(task);
+            else {
+                if (metaCache.configuration().getCacheMode() == CacheMode.REPLICATED)
+                    // For replicated cache we do not bother much, just route to any data
node.
+                    return metaCompute().call(task);
+                else
+                    // Otherwise we must route request to one of affinity nodes.
+                    return rootCompute().call(task);
+            }
         }
         catch (ClusterTopologyException e) {
             throw new IgfsException("Failed to execute operation because there are no IGFS
metadata nodes." , e);
@@ -291,7 +300,7 @@ public class IgfsMetaManager extends IgfsManager {
     /**
      * Get metadata compute facade for client tasks.
      *
-     * @return Metadata compute facade.
+     * @return Compute facade.
      */
     private IgniteCompute metaCompute() {
         assert client;
@@ -314,6 +323,29 @@ public class IgfsMetaManager extends IgfsManager {
     }
 
     /**
+     * Get compute facade for root entry affinity nodes.
+     *
+     * @return Compute facade.
+     */
+    private IgniteCompute rootCompute() {
+        IgniteEx ignite = igfsCtx.kernalContext().grid();
+
+        int rootPart0 = rootPart;
+
+        if (rootPart0 == -1) {
+            rootPart0 = metaCache.affinity().partition(IgfsUtils.ROOT_ID);
+
+            rootPart = rootPart0;
+        }
+
+        Collection<ClusterNode> nodes = metaCache.affinity().mapPartitionToPrimaryAndBackups(rootPart0);
+
+        ClusterGroup cluster = ignite.cluster().forNodes(nodes);
+
+        return ignite.compute(cluster);
+    }
+
+    /**
      * Gets file ID for specified path.
      *
      * @param path Path.


Mime
View raw message