ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dma...@apache.org
Subject [04/25] ignite git commit: IGNITE-2869: IGFS: Slightly improved serialization of IgfsListingEntry.
Date Thu, 24 Mar 2016 11:41:06 GMT
IGNITE-2869: IGFS: Slightly improved serialization of IgfsListingEntry.


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

Branch: refs/heads/ignite-2849
Commit: 574f2cd20243fef2c62fc5506d31c14c84d00885
Parents: 49725e9
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Tue Mar 22 09:20:32 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Mar 22 09:20:32 2016 +0300

----------------------------------------------------------------------
 .../processors/igfs/IgfsDirectoryInfo.java      | 30 +++++++++++++++-
 .../internal/processors/igfs/IgfsUtils.java     | 38 ++++++++++++++++++++
 .../meta/IgfsMetaDirectoryCreateProcessor.java  |  4 +--
 .../IgfsMetaDirectoryListingAddProcessor.java   |  7 ++--
 4 files changed, 74 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/574f2cd2/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
index 233c8ee..a426e8c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
@@ -23,7 +23,6 @@ import org.apache.ignite.binary.BinaryRawWriter;
 import org.apache.ignite.binary.BinaryReader;
 import org.apache.ignite.binary.BinaryWriter;
 import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.internal.binary.BinaryUtils;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -35,6 +34,7 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -198,6 +198,20 @@ public class IgfsDirectoryInfo extends IgfsEntryInfo implements Binarylizable
{
 
         writeBinary(out);
 
+        if (listing != null) {
+            out.writeBoolean(true);
+
+            out.writeInt(listing.size());
+
+            for (Map.Entry<String, IgfsListingEntry> entry : listing.entrySet()) {
+                out.writeString(entry.getKey());
+
+                IgfsUtils.writeListingEntry(out, entry.getValue());
+            }
+        }
+        else
+            out.writeBoolean(false);
+
         out.writeMap(listing);
     }
 
@@ -207,6 +221,20 @@ public class IgfsDirectoryInfo extends IgfsEntryInfo implements Binarylizable
{
 
         readBinary(in);
 
+        if (in.readBoolean()) {
+            int listingSize = in.readInt();
+
+            listing = new HashMap<>(listingSize);
+
+            for (int i = 0; i < listingSize; i++) {
+                String key = in.readString();
+
+                IgfsListingEntry val = IgfsUtils.readListingEntry(in);
+
+                listing.put(key, val);
+            }
+        }
+
         listing = in.readMap();
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/574f2cd2/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index 325f636..7063f68 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -20,6 +20,8 @@ package org.apache.ignite.internal.processors.igfs;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.cluster.ClusterTopologyException;
@@ -30,6 +32,7 @@ import org.apache.ignite.events.IgfsEvent;
 import org.apache.ignite.igfs.IgfsException;
 import org.apache.ignite.igfs.IgfsPath;
 import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.binary.BinaryUtils;
 import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
 import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
@@ -389,4 +392,39 @@ public class IgfsUtils {
         return new IgfsFileInfo(id, blockSize, len, affKey, props, null, lockId, accessTime,
modificationTime,
             evictExclude);
     }
+
+    /**
+     * Write listing entry.
+     *
+     * @param out Writer.
+     * @param entry Entry.
+     */
+    public static void writeListingEntry(BinaryRawWriter out, @Nullable IgfsListingEntry
entry) {
+        if (entry != null) {
+            out.writeBoolean(true);
+
+            BinaryUtils.writeIgniteUuid(out, entry.fileId());
+
+            out.writeBoolean(entry.isDirectory());
+        }
+        else
+            out.writeBoolean(false);
+    }
+
+    /**
+     * Read listing entry.
+     *
+     * @param in Reader.
+     * @return Entry.
+     */
+    @Nullable public static IgfsListingEntry readListingEntry(BinaryRawReader in) {
+        if (in.readBoolean()) {
+            IgniteUuid id = BinaryUtils.readIgniteUuid(in);
+            boolean dir = in.readBoolean();
+
+            return new IgfsListingEntry(id, dir);
+        }
+        else
+            return null;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/574f2cd2/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
index dcca298..907019c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
@@ -148,7 +148,7 @@ public class IgfsMetaDirectoryCreateProcessor implements EntryProcessor<IgniteUu
         out.writeString(childName);
 
         if (childName != null)
-            out.writeObject(childEntry);
+            IgfsUtils.writeListingEntry(out, childEntry);
     }
 
     /** {@inheritDoc} */
@@ -160,7 +160,7 @@ public class IgfsMetaDirectoryCreateProcessor implements EntryProcessor<IgniteUu
         childName = in.readString();
 
         if (childName != null)
-            childEntry = in.readObject();
+            childEntry = IgfsUtils.readListingEntry(in);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/574f2cd2/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
index f27bdd5..e9fa867 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
@@ -26,6 +26,7 @@ import org.apache.ignite.binary.BinaryWriter;
 import org.apache.ignite.binary.Binarylizable;
 import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
 import org.apache.ignite.internal.processors.igfs.IgfsListingEntry;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteUuid;
@@ -113,7 +114,8 @@ public final class IgfsMetaDirectoryListingAddProcessor implements EntryProcesso
         BinaryRawWriter out = writer.rawWriter();
 
         out.writeString(fileName);
-        out.writeObject(entry);
+
+        IgfsUtils.writeListingEntry(out, entry);
     }
 
     /** {@inheritDoc} */
@@ -121,7 +123,8 @@ public final class IgfsMetaDirectoryListingAddProcessor implements EntryProcesso
         BinaryRawReader in = reader.rawReader();
 
         fileName = in.readString();
-        entry = in.readObject();
+
+        entry = IgfsUtils.readListingEntry(in);
     }
 
     /** {@inheritDoc} */


Mime
View raw message