ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [41/50] ignite git commit: IGNITE-3331: IGFS: Better affinity management for client tasks.
Date Mon, 20 Jun 2016 12:53:21 GMT
IGNITE-3331: IGFS: Better affinity management for client tasks.


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

Branch: refs/heads/ignite-3341
Commit: 06831b13f4a9693e767f2e299abcc57605c87da5
Parents: f7da0dd
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Fri Jun 17 13:27:18 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Fri Jun 17 13:27:18 2016 +0300

----------------------------------------------------------------------
 .../processors/igfs/IgfsMetaManager.java        | 45 ++++++++++++++++----
 .../igfs/client/IgfsClientAbstractCallable.java |  5 +++
 .../igfs/client/IgfsClientAffinityCallable.java |  5 +++
 .../igfs/client/IgfsClientDeleteCallable.java   |  5 +++
 .../igfs/client/IgfsClientExistsCallable.java   |  5 +++
 .../igfs/client/IgfsClientInfoCallable.java     |  5 +++
 .../client/IgfsClientListFilesCallable.java     |  5 +++
 .../client/IgfsClientListPathsCallable.java     |  5 +++
 .../igfs/client/IgfsClientMkdirsCallable.java   |  5 +++
 .../igfs/client/IgfsClientRenameCallable.java   |  5 +++
 .../igfs/client/IgfsClientSetTimesCallable.java |  5 +++
 .../igfs/client/IgfsClientSizeCallable.java     |  5 +++
 .../igfs/client/IgfsClientSummaryCallable.java  |  5 +++
 .../igfs/client/IgfsClientUpdateCallable.java   |  5 +++
 .../meta/IgfsClientMetaIdsForPathCallable.java  |  5 +++
 .../meta/IgfsClientMetaInfoForPathCallable.java |  5 +++
 16 files changed, 111 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/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 943c4c8..30c7d10 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
@@ -150,8 +150,11 @@ public class IgfsMetaManager extends IgfsManager {
     /** Client flag. */
     private final boolean client;
 
+    /** Compute facade. */
+    private IgniteCompute compute;
+
     /** Compute facade for client tasks. */
-    private IgniteCompute cliCompute;
+    private IgniteCompute metaCompute;
 
     /**
      * Constructor.
@@ -248,7 +251,12 @@ public class IgfsMetaManager extends IgfsManager {
      */
     <T> T runClientTask(IgfsClientAbstractCallable<T> task) {
         try {
-            return clientCompute().call(task);
+            if (!task.isReadOnly() && cfg.isColocateMetadata())
+                // If task mutates state and co-location is enabled, we route request to
primary node.
+                return compute().affinityCall(cfg.getMetaCacheName(), IgfsUtils.ROOT_ID,
task);
+            else
+                // Otherwise we route to any available data node.
+                return metaCompute().call(task);
         }
         catch (ClusterTopologyException e) {
             throw new IgfsException("Failed to execute operation because there are no IGFS
metadata nodes." , e);
@@ -260,24 +268,43 @@ public class IgfsMetaManager extends IgfsManager {
      *
      * @return Compute facade.
      */
-    private IgniteCompute clientCompute() {
+    private IgniteCompute compute() {
+        IgniteCompute compute0 = compute;
+
+        if (compute0 == null) {
+            compute0 = igfsCtx.kernalContext().grid().compute();
+
+            compute = compute0;
+        }
+
+        assert compute0 != null;
+
+        return compute0;
+    }
+
+    /**
+     * Get metadata compute facade for client tasks.
+     *
+     * @return Metadata compute facade.
+     */
+    private IgniteCompute metaCompute() {
         assert client;
 
-        IgniteCompute cliCompute0 = cliCompute;
+        IgniteCompute metaCompute0 = metaCompute;
 
-        if (cliCompute0 == null) {
+        if (metaCompute0 == null) {
             IgniteEx ignite = igfsCtx.kernalContext().grid();
 
             ClusterGroup cluster = ignite.cluster().forIgfsMetadataDataNodes(cfg.getName(),
cfg.getMetaCacheName());
 
-            cliCompute0 = ignite.compute(cluster);
+            metaCompute0 = ignite.compute(cluster);
 
-            cliCompute = cliCompute0;
+            metaCompute = metaCompute0;
         }
 
-        assert cliCompute0 != null;
+        assert metaCompute0 != null;
 
-        return cliCompute0;
+        return metaCompute0;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
index d9c3456..c06619f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
@@ -85,6 +85,11 @@ public abstract class IgfsClientAbstractCallable<T> implements IgniteCallable<T>
      */
     protected abstract T call0(IgfsContext ctx) throws Exception;
 
+    /**
+     * @return {@code True} if task is read-only and does not change metadata.
+     */
+    public abstract boolean isReadOnly();
+
     /** {@inheritDoc} */
     @Override public final void writeBinary(BinaryWriter writer) throws BinaryObjectException
{
         BinaryRawWriter rawWriter = writer.rawWriter();

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
index 1668f36..6e2748d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
@@ -74,6 +74,11 @@ public class IgfsClientAffinityCallable extends IgfsClientAbstractCallable<Colle
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
     @Override public void writeBinary0(BinaryRawWriter writer) throws BinaryObjectException
{
         writer.writeLong(start);
         writer.writeLong(len);

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
index c1b8be8..21f8c46 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
@@ -61,6 +61,11 @@ public class IgfsClientDeleteCallable extends IgfsClientAbstractCallable<Boolean
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
     @Override public void writeBinary0(BinaryRawWriter writer) throws BinaryObjectException
{
         writer.writeBoolean(recursive);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientExistsCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientExistsCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientExistsCallable.java
index 04b63d8..536cdc8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientExistsCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientExistsCallable.java
@@ -52,6 +52,11 @@ public class IgfsClientExistsCallable extends IgfsClientAbstractCallable<Boolean
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgfsClientExistsCallable.class, this);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientInfoCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientInfoCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientInfoCallable.java
index f97c3c4..6bab8b8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientInfoCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientInfoCallable.java
@@ -53,6 +53,11 @@ public class IgfsClientInfoCallable extends IgfsClientAbstractCallable<IgfsFile>
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgfsClientInfoCallable.class, this);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListFilesCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListFilesCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListFilesCallable.java
index 325e714..deb8836 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListFilesCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListFilesCallable.java
@@ -55,6 +55,11 @@ public class IgfsClientListFilesCallable extends IgfsClientAbstractCallable<Coll
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgfsClientListFilesCallable.class, this);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListPathsCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListPathsCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListPathsCallable.java
index 78b4c84..ad6c858 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListPathsCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListPathsCallable.java
@@ -54,6 +54,11 @@ public class IgfsClientListPathsCallable extends IgfsClientAbstractCallable<Coll
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgfsClientListPathsCallable.class, this);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
index 944da6f..6ecb6ea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
@@ -66,6 +66,11 @@ public class IgfsClientMkdirsCallable extends IgfsClientAbstractCallable<Void>
{
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
     @Override public void writeBinary0(BinaryRawWriter writer) throws BinaryObjectException
{
         IgfsUtils.writeProperties(writer, props);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
index 55afb83..142af47 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
@@ -64,6 +64,11 @@ public class IgfsClientRenameCallable extends IgfsClientAbstractCallable<Void>
{
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
     @Override public void writeBinary0(BinaryRawWriter writer) throws BinaryObjectException
{
         IgfsUtils.writePath(writer, destPath);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
index 277effc..8c302bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
@@ -69,6 +69,11 @@ public class IgfsClientSetTimesCallable extends IgfsClientAbstractCallable<Void>
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
     @Override public void writeBinary0(BinaryRawWriter writer) throws BinaryObjectException
{
         writer.writeLong(accessTime);
         writer.writeLong(modificationTime);

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
index 474a940..29a7b7a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
@@ -53,6 +53,11 @@ public class IgfsClientSizeCallable extends IgfsClientAbstractCallable<Long>
{
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgfsClientSizeCallable.class, this);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSummaryCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSummaryCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSummaryCallable.java
index 7e29029..1e2795c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSummaryCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSummaryCallable.java
@@ -53,6 +53,11 @@ public class IgfsClientSummaryCallable extends IgfsClientAbstractCallable<IgfsPa
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgfsClientSummaryCallable.class, this);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
index 4acf4eb..82d6e8d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
@@ -65,6 +65,11 @@ public class IgfsClientUpdateCallable extends IgfsClientAbstractCallable<IgfsFil
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
     @Override public void writeBinary0(BinaryRawWriter writer) throws BinaryObjectException
{
         IgfsUtils.writeProperties(writer, props);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaIdsForPathCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaIdsForPathCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaIdsForPathCallable.java
index 7b3d142..b07a0cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaIdsForPathCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaIdsForPathCallable.java
@@ -59,6 +59,11 @@ public class IgfsClientMetaIdsForPathCallable extends IgfsClientAbstractCallable
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgfsClientMetaIdsForPathCallable.class, this);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/06831b13/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaInfoForPathCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaInfoForPathCallable.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaInfoForPathCallable.java
index cb31663..e7e0164 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaInfoForPathCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaInfoForPathCallable.java
@@ -57,6 +57,11 @@ public class IgfsClientMetaInfoForPathCallable extends IgfsClientAbstractCallabl
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isReadOnly() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgfsClientMetaInfoForPathCallable.class, this);
     }


Mime
View raw message