You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by nt...@apache.org on 2016/03/17 16:32:14 UTC

[01/11] ignite git commit: IGNITE-2817: IGFS: Optimized "updateProperties" and several other cache operations. Reafactored IgfsMetaManager a bit to simplify work with cache.

Repository: ignite
Updated Branches:
  refs/heads/ignite-2791 1f116776d -> fa97a07c0


IGNITE-2817: IGFS: Optimized "updateProperties" and several other cache operations. Reafactored IgfsMetaManager a bit to simplify work with cache.


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

Branch: refs/heads/ignite-2791
Commit: dda1f0ed449111b7e1011a669b30bc3b4c5d2d92
Parents: 7b7233e
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Mar 16 09:14:49 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Mar 16 09:14:49 2016 +0300

----------------------------------------------------------------------
 .../internal/processors/igfs/IgfsImpl.java      |   4 +-
 .../processors/igfs/IgfsMetaManager.java        | 641 ++++++++++---------
 .../igfs/IgfsMetaManagerSelfTest.java           |  23 +-
 3 files changed, 336 insertions(+), 332 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dda1f0ed/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
index f44eda8..3065427 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
@@ -636,9 +636,7 @@ public final class IgfsImpl implements IgfsEx {
                 if (fileId == null)
                     return null;
 
-                IgniteUuid parentId = fileIds.size() > 1 ? fileIds.get(fileIds.size() - 2) : null;
-
-                IgfsFileInfo info = meta.updateProperties(parentId, fileId, path.name(), props);
+                IgfsFileInfo info = meta.updateProperties(fileId, props);
 
                 if (info != null) {
                     if (evts.isRecordable(EVT_IGFS_META_UPDATED))

http://git-wip-us.apache.org/repos/asf/ignite/blob/dda1f0ed/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 463e7a8..df69d49 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
@@ -40,7 +40,6 @@ import java.util.TreeSet;
 import java.util.concurrent.CountDownLatch;
 import javax.cache.processor.EntryProcessor;
 import javax.cache.processor.EntryProcessorException;
-import javax.cache.processor.EntryProcessorResult;
 import javax.cache.processor.MutableEntry;
 
 import org.apache.ignite.IgniteCheckedException;
@@ -238,7 +237,7 @@ public class IgfsMetaManager extends IgfsManager {
     @Nullable public IgniteUuid fileId(IgfsPath path) throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
-                assert validTxState(false);
+                validTxState(false);
 
                 return fileId(path, false);
             }
@@ -322,7 +321,7 @@ public class IgfsMetaManager extends IgfsManager {
     public List<IgniteUuid> fileIds(IgfsPath path) throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
-                assert validTxState(false);
+                validTxState(false);
 
                 return fileIds(path, false);
             }
@@ -407,7 +406,7 @@ public class IgfsMetaManager extends IgfsManager {
                 if (fileId == null)
                     return null;
 
-                IgfsFileInfo info = id2InfoPrj.get(fileId);
+                IgfsFileInfo info = getInfo(fileId);
 
                 // Force root ID always exist in cache.
                 if (info == null && IgfsUtils.ROOT_ID.equals(fileId))
@@ -433,13 +432,14 @@ public class IgfsMetaManager extends IgfsManager {
     public Map<IgniteUuid, IgfsFileInfo> infos(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
-                assert validTxState(false);
+                validTxState(false);
+
                 assert fileIds != null;
 
                 if (F.isEmpty(fileIds))
                     return Collections.emptyMap();
 
-                Map<IgniteUuid, IgfsFileInfo> map = id2InfoPrj.getAll(fileIds);
+                Map<IgniteUuid, IgfsFileInfo> map = getInfos(fileIds);
 
                 // Force root ID always exist in cache.
                 if (fileIds.contains(IgfsUtils.ROOT_ID) && !map.containsKey(IgfsUtils.ROOT_ID)) {
@@ -469,7 +469,8 @@ public class IgfsMetaManager extends IgfsManager {
     public @Nullable IgfsFileInfo lock(IgniteUuid fileId, boolean delete) throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
-                assert validTxState(false);
+                validTxState(false);
+
                 assert fileId != null;
 
                 IgniteInternalTx tx = startTx();
@@ -484,11 +485,7 @@ public class IgfsMetaManager extends IgfsManager {
                     if (oldInfo.lockId() != null)
                         return null; // The file is already locked, we cannot lock it.
 
-                    IgniteUuid lockId = createFileLockId(delete);
-
-                    id2InfoPrj.invoke(fileId, new FileLockProcessor(lockId));
-
-                    IgfsFileInfo newInfo = id2InfoPrj.get(fileId);
+                    IgfsFileInfo newInfo = invokeLock(fileId, delete);
 
                     tx.commit();
 
@@ -530,7 +527,8 @@ public class IgfsMetaManager extends IgfsManager {
      * @throws IgniteCheckedException If failed.
      */
     public void unlock(final IgfsFileInfo info, final long modificationTime) throws IgniteCheckedException {
-        assert validTxState(false);
+        validTxState(false);
+
         assert info != null;
 
         if (busyLock.enterBusy()) {
@@ -546,7 +544,7 @@ public class IgfsMetaManager extends IgfsManager {
                 try {
                     IgfsUtils.doInTransactionWithRetries(id2InfoPrj, new IgniteOutClosureX<Void>() {
                         @Override public Void applyx() throws IgniteCheckedException {
-                            assert validTxState(true);
+                            validTxState(true);
 
                             IgniteUuid fileId = info.id();
 
@@ -569,7 +567,7 @@ public class IgfsMetaManager extends IgfsManager {
                     });
                 }
                 finally {
-                    assert validTxState(false);
+                    validTxState(false);
 
                     if (interrupted)
                         Thread.currentThread().interrupt();
@@ -591,7 +589,8 @@ public class IgfsMetaManager extends IgfsManager {
      * @throws IgniteCheckedException If failed.
      */
     private Map<IgniteUuid, IgfsFileInfo> lockIds(IgniteUuid... fileIds) throws IgniteCheckedException {
-        assert validTxState(true);
+        validTxState(true);
+
         assert fileIds != null && fileIds.length > 0;
 
         Arrays.sort(fileIds);
@@ -631,13 +630,13 @@ public class IgfsMetaManager extends IgfsManager {
      */
     private Map<IgniteUuid, IgfsFileInfo> lockIds(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
         assert isSorted(fileIds);
-        assert validTxState(true);
+        validTxState(true);
 
         if (log.isDebugEnabled())
             log.debug("Locking file ids: " + fileIds);
 
         // Lock files and get their infos.
-        Map<IgniteUuid, IgfsFileInfo> map = id2InfoPrj.getAll(fileIds);
+        Map<IgniteUuid, IgfsFileInfo> map = getInfos(fileIds);
 
         if (log.isDebugEnabled())
             log.debug("Locked file ids: " + fileIds);
@@ -769,7 +768,7 @@ public class IgfsMetaManager extends IgfsManager {
         assert fileId != null;
 
         IgfsFileInfo info = skipTx ? id2InfoPrj.getAllOutTx(Collections.singleton(fileId)).get(fileId) :
-            id2InfoPrj.get(fileId);
+            getInfo(fileId);
 
         return info == null ? Collections.<String, IgfsListingEntry>emptyMap() : info.listing();
     }
@@ -789,7 +788,7 @@ public class IgfsMetaManager extends IgfsManager {
             log.debug("Locking parent id [parentId=" + parentId + ", fileName=" + fileName + ", newFileInfo=" +
                 newFileInfo + ']');
 
-        assert validTxState(true);
+        validTxState(true);
 
         // Lock only parent file ID.
         IgfsFileInfo parentInfo = info(parentId);
@@ -806,10 +805,7 @@ public class IgfsMetaManager extends IgfsManager {
         if (childEntry != null)
             return childEntry.fileId();
 
-        if (!id2InfoPrj.putIfAbsent(newFileInfo.id(), newFileInfo))
-            throw fsException("Failed to add file details into cache: " + newFileInfo);
-
-        id2InfoPrj.invoke(parentId, new ListingAdd(fileName, new IgfsListingEntry(newFileInfo)));
+        createNewEntry(newFileInfo, parentId, fileName);
 
         return null;
     }
@@ -825,7 +821,7 @@ public class IgfsMetaManager extends IgfsManager {
     public IgfsFileInfo move(IgfsPath srcPath, IgfsPath dstPath) throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
-                assert validTxState(false);
+                validTxState(false);
 
                 // 1. First get source and destination path IDs.
                 List<IgniteUuid> srcPathIds = fileIds(srcPath);
@@ -918,8 +914,7 @@ public class IgfsMetaManager extends IgfsManager {
                     // 8. Actual move: remove from source parent and add to destination target.
                     IgfsListingEntry entry = srcTargetInfo.listing().get(srcName);
 
-                    id2InfoPrj.invoke(srcTargetId, new ListingRemove(srcName, entry.fileId()));
-                    id2InfoPrj.invoke(dstTargetId, new ListingAdd(dstName, entry));
+                    transferEntry(entry, srcTargetId, srcName, dstTargetId, dstName);
 
                     tx.commit();
 
@@ -990,7 +985,7 @@ public class IgfsMetaManager extends IgfsManager {
      */
     private void moveNonTx(IgniteUuid fileId, @Nullable String srcFileName, IgniteUuid srcParentId, String destFileName,
         IgniteUuid destParentId) throws IgniteCheckedException {
-        assert validTxState(true);
+        validTxState(true);
 
         assert fileId != null;
         assert srcFileName != null;
@@ -1047,11 +1042,7 @@ public class IgfsMetaManager extends IgfsManager {
                 " directory (file already exists) [fileId=" + fileId + ", destFileName=" + destFileName +
                 ", destParentId=" + destParentId + ']'));
 
-        // Remove listing entry from the source parent listing.
-        id2InfoPrj.invoke(srcParentId, new ListingRemove(srcFileName, srcEntry.fileId()));
-
-        // Add listing entry into the destination parent listing.
-        id2InfoPrj.invoke(destParentId, new ListingAdd(destFileName, srcEntry));
+        transferEntry(srcEntry, srcParentId, srcFileName, destParentId, destFileName);
     }
 
     /**
@@ -1064,7 +1055,7 @@ public class IgfsMetaManager extends IgfsManager {
     IgniteUuid format() throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
-                assert validTxState(false);
+                validTxState(false);
 
                 IgniteUuid trashId = IgfsUtils.randomTrashId();
 
@@ -1088,11 +1079,7 @@ public class IgfsMetaManager extends IgfsManager {
 
                     IgfsFileInfo newInfo = new IgfsFileInfo(transferListing);
 
-                    id2InfoPrj.put(newInfo.id(), newInfo);
-
-                    // Add new info to trash listing.
-                    id2InfoPrj.invoke(trashId, new ListingAdd(newInfo.id().toString(),
-                        new IgfsListingEntry(newInfo)));
+                    createNewEntry(newInfo, trashId, newInfo.id().toString());
 
                     // Remove listing entries from root.
                     // Note that root directory properties and other attributes are preserved:
@@ -1128,7 +1115,7 @@ public class IgfsMetaManager extends IgfsManager {
     IgniteUuid softDelete(final IgfsPath path, final boolean recursive) throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
-                assert validTxState(false);
+                validTxState(false);
 
                 final SortedSet<IgniteUuid> allIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
 
@@ -1191,15 +1178,12 @@ public class IgfsMetaManager extends IgfsManager {
 
                     assert victimId.equals(srcEntry.fileId());
 
-                    id2InfoPrj.invoke(srcParentId, new ListingRemove(srcFileName, srcEntry.fileId()));
-
-                    // Add listing entry into the destination parent listing.
-                    id2InfoPrj.invoke(trashId, new ListingAdd(destFileName, srcEntry));
+                    transferEntry(srcEntry, srcParentId, srcFileName, trashId, destFileName);
 
                     if (victimInfo.isFile())
                         // Update a file info of the removed file with a file path,
                         // which will be used by delete worker for event notifications.
-                        id2InfoPrj.invoke(victimId, new UpdatePath(path));
+                        invokeUpdatePath(victimId, path);
 
                     tx.commit();
 
@@ -1233,7 +1217,7 @@ public class IgfsMetaManager extends IgfsManager {
     @Nullable private IgniteUuid softDeleteNonTx(@Nullable IgniteUuid parentId, @Nullable String name, IgniteUuid id,
         IgniteUuid trashId)
         throws IgniteCheckedException {
-        assert validTxState(true);
+        validTxState(true);
 
         IgniteUuid resId;
 
@@ -1241,7 +1225,7 @@ public class IgfsMetaManager extends IgfsManager {
             // Handle special case when we deleting root directory.
             assert IgfsUtils.ROOT_ID.equals(id);
 
-            IgfsFileInfo rootInfo = id2InfoPrj.get(IgfsUtils.ROOT_ID);
+            IgfsFileInfo rootInfo = getInfo(IgfsUtils.ROOT_ID);
 
             if (rootInfo == null)
                 return null; // Root was never created.
@@ -1269,11 +1253,7 @@ public class IgfsMetaManager extends IgfsManager {
 
                 IgfsFileInfo newInfo = new IgfsFileInfo(transferListing);
 
-                id2InfoPrj.getAndPut(newInfo.id(), newInfo);
-
-                // Add new info to trash listing.
-                id2InfoPrj.invoke(trashId, new ListingAdd(newInfo.id().toString(),
-                    new IgfsListingEntry(newInfo)));
+                createNewEntry(newInfo, trashId, newInfo.id().toString());
 
                 // Remove listing entries from root.
                 for (Map.Entry<String, IgfsListingEntry> entry : transferListing.entrySet())
@@ -1311,7 +1291,7 @@ public class IgfsMetaManager extends IgfsManager {
             try {
                 assert parentId != null;
                 assert listing != null;
-                assert validTxState(false);
+                validTxState(false);
 
                 IgniteInternalTx tx = startTx();
 
@@ -1353,7 +1333,7 @@ public class IgfsMetaManager extends IgfsManager {
 
                                 // Delete only files or empty folders.
                                 if (!entryInfo.hasChildren()) {
-                                    id2InfoPrj.getAndRemove(childId);
+                                    id2InfoPrj.remove(childId);
 
                                     newListing.remove(childName);
 
@@ -1402,7 +1382,7 @@ public class IgfsMetaManager extends IgfsManager {
     boolean delete(IgniteUuid parentId, String name, IgniteUuid id) throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
-                assert validTxState(false);
+                validTxState(false);
 
                 IgniteInternalTx tx = startTx();
 
@@ -1428,11 +1408,9 @@ public class IgfsMetaManager extends IgfsManager {
                         IgfsListingEntry childEntry = parentInfo.listing().get(name);
 
                         if (childEntry != null)
-                            id2InfoPrj.invoke(parentId, new ListingRemove(name, childEntry.fileId()));
+                            id2InfoPrj.invoke(parentId, new ListingRemove(name, id));
 
-                        IgfsFileInfo deleted = id2InfoPrj.getAndRemove(id);
-
-                        assert victim.id().equals(deleted.id());
+                        id2InfoPrj.remove(id);
 
                         res = true;
                     }
@@ -1468,7 +1446,7 @@ public class IgfsMetaManager extends IgfsManager {
                 for (int i = 0; i < IgfsUtils.TRASH_CONCURRENCY; i++) {
                     IgniteUuid trashId = IgfsUtils.trashId(i);
 
-                    IgfsFileInfo trashInfo = id2InfoPrj.get(trashId);
+                    IgfsFileInfo trashInfo = getInfo(trashId);
 
                     if (trashInfo != null && trashInfo.hasChildren()) {
                         for (IgfsListingEntry entry : trashInfo.listing().values())
@@ -1489,75 +1467,28 @@ public class IgfsMetaManager extends IgfsManager {
     /**
      * Update file info (file properties) in cache in existing transaction.
      *
-     * @param parentId Parent ID ({@code null} if file is root).
-     * @param fileName To update listing.
      * @param fileId File ID to update information for.
      * @param props Properties to set for the file.
      * @return Updated file info or {@code null} if such file ID not found.
      * @throws IgniteCheckedException If operation failed.
      */
-    @Nullable private IgfsFileInfo updatePropertiesNonTx(final @Nullable IgniteUuid parentId, final IgniteUuid fileId,
-        String fileName, Map<String, String> props) throws IgniteCheckedException {
+    @Nullable private IgfsFileInfo updatePropertiesNonTx(final IgniteUuid fileId, Map<String, String> props)
+        throws IgniteCheckedException {
         assert fileId != null;
         assert !F.isEmpty(props) : "Expects not-empty file's properties";
-        assert validTxState(true);
+
+        validTxState(true);
 
         if (log.isDebugEnabled())
             log.debug("Update file properties [fileId=" + fileId + ", props=" + props + ']');
 
         try {
-            final IgfsFileInfo oldInfo;
-            final IgfsFileInfo parentInfo;
-
-            // Lock file ID for this transaction.
-            if (parentId == null) {
-                oldInfo = info(fileId);
-                parentInfo = null;
-            }
-            else {
-                Map<IgniteUuid, IgfsFileInfo> locked = lockIds(parentId, fileId);
-
-                oldInfo = locked.get(fileId);
-                parentInfo = locked.get(parentId);
-
-                if (parentInfo == null)
-                    return null; // Parent not found.
-            }
+            final IgfsFileInfo oldInfo = info(fileId);
 
             if (oldInfo == null)
-                return null; // File not found.
+                return null;
 
-            if (parentInfo != null) {
-                if (!parentInfo.hasChild(fileName, fileId)) // File was removed or recreated.
-                    return null;
-            }
-
-            Map<String, String> tmp = oldInfo.properties();
-
-            tmp = tmp == null ? new GridLeanMap<String, String>(props.size()) : new GridLeanMap<>(tmp);
-
-            for (Map.Entry<String, String> e : props.entrySet()) {
-                if (e.getValue() == null)
-                    // Remove properties with 'null' values.
-                    tmp.remove(e.getKey());
-                else
-                    // Add/overwrite property.
-                    tmp.put(e.getKey(), e.getValue());
-            }
-
-            IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, tmp);
-
-            id2InfoPrj.put(fileId, newInfo);
-
-            if (parentId != null) {
-                IgfsListingEntry entry = new IgfsListingEntry(newInfo);
-
-                assert id2InfoPrj.get(parentId) != null;
-
-                id2InfoPrj.invoke(parentId, new ListingAdd(fileName, entry));
-            }
-
-            return newInfo;
+            return invokeAndGet(fileId, new UpdatePropertiesProcessor(props));
         }
         catch (GridClosureException e) {
             throw U.cast(e);
@@ -1567,23 +1498,21 @@ public class IgfsMetaManager extends IgfsManager {
     /**
      * Update file info (file properties) in cache.
      *
-     * @param parentId Parent ID ({@code null} if file is root).
-     * @param fileName To update listing.
      * @param fileId File ID to update information for.
      * @param props Properties to set for the file.
      * @return Updated file info or {@code null} if such file ID not found.
      * @throws IgniteCheckedException If operation failed.
      */
-    @Nullable public IgfsFileInfo updateProperties(@Nullable IgniteUuid parentId, IgniteUuid fileId, String fileName,
-        Map<String, String> props) throws IgniteCheckedException {
+    @Nullable public IgfsFileInfo updateProperties(IgniteUuid fileId, Map<String, String> props)
+        throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
-                assert validTxState(false);
+                validTxState(false);
 
                 IgniteInternalTx tx = startTx();
 
                 try {
-                    IgfsFileInfo info = updatePropertiesNonTx(parentId, fileId, fileName, props);
+                    IgfsFileInfo info = updatePropertiesNonTx(fileId, props);
 
                     tx.commit();
 
@@ -1598,8 +1527,8 @@ public class IgfsMetaManager extends IgfsManager {
             }
         }
         else
-            throw new IllegalStateException("Failed to update properties because Grid is stopping [parentId=" +
-                parentId + ", fileId=" + fileId + ", fileName=" + fileName + ", props=" + props + ']');
+            throw new IllegalStateException("Failed to update properties because Grid is stopping [fileId=" + fileId +
+                ", props=" + props + ']');
     }
 
     /**
@@ -1613,7 +1542,7 @@ public class IgfsMetaManager extends IgfsManager {
      */
     public IgfsFileInfo reserveSpace(IgfsPath path, IgniteUuid fileId, long space, IgfsFileAffinityRange affRange)
         throws IgniteCheckedException {
-        assert validTxState(false);
+        validTxState(false);
 
         if (busyLock.enterBusy()) {
             try {
@@ -1629,9 +1558,7 @@ public class IgfsMetaManager extends IgfsManager {
                     if (oldInfo == null)
                         throw fsException("File has been deleted concurrently [path=" + path + ", id=" + fileId + ']');
 
-                    id2InfoPrj.invoke(fileId, new FileReserveSpaceProcessor(space, affRange));
-
-                    IgfsFileInfo newInfo = id2InfoPrj.get(fileId);
+                    IgfsFileInfo newInfo = invokeAndGet(fileId, new FileReserveSpaceProcessor(space, affRange));
 
                     tx.commit();
 
@@ -1663,7 +1590,7 @@ public class IgfsMetaManager extends IgfsManager {
      */
     @Nullable public IgfsFileInfo updateInfo(IgniteUuid fileId, IgniteClosure<IgfsFileInfo, IgfsFileInfo> c)
         throws IgniteCheckedException {
-        assert validTxState(false);
+        validTxState(false);
         assert fileId != null;
         assert c != null;
 
@@ -1672,7 +1599,7 @@ public class IgfsMetaManager extends IgfsManager {
                 if (log.isDebugEnabled())
                     log.debug("Update file info [fileId=" + fileId + ", c=" + c + ']');
 
-                IgniteInternalTx tx = id2InfoPrj.isLockedByThread(fileId) ? null : startTx();
+                IgniteInternalTx tx = startTx();
 
                 try {
                     // Lock file ID for this transaction.
@@ -1732,14 +1659,14 @@ public class IgfsMetaManager extends IgfsManager {
      */
     boolean mkdirs(final IgfsPath path, final Map<String, String> props) throws IgniteCheckedException {
         assert props != null;
-        assert validTxState(false);
+        validTxState(false);
 
         DirectoryChainBuilder b = null;
 
         while (true) {
             if (busyLock.enterBusy()) {
                 try {
-                    b = new DirectoryChainBuilder(path, props, props);
+                    b = new DirectoryChainBuilder(path, props);
 
                     // Start TX.
                     IgniteInternalTx tx = startTx();
@@ -1873,6 +1800,106 @@ public class IgfsMetaManager extends IgfsManager {
     }
 
     /**
+     * Put new entry to meta cache immediately linking it to parent.
+     *
+     * @param info Info to put.
+     * @param parentId Parent ID.
+     * @param name Name in parent.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void createNewEntry(IgfsFileInfo info, IgniteUuid parentId, String name) throws IgniteCheckedException {
+        validTxState(true);
+
+        if (!id2InfoPrj.putIfAbsent(info.id(), info))
+            throw fsException("Failed to create new metadata entry due to ID conflict: " + info.id());
+
+        if (parentId != null)
+            id2InfoPrj.invoke(parentId, new ListingAdd(name, new IgfsListingEntry(info)));
+    }
+
+    /**
+     * Transfer entry from one directory to another.
+     *
+     * @param entry Entry to be transfered.
+     * @param srcId Source ID.
+     * @param srcName Source name.
+     * @param destId Destination ID.
+     * @param destName Destination name.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void transferEntry(IgfsListingEntry entry, IgniteUuid srcId, String srcName,
+        IgniteUuid destId, String destName) throws IgniteCheckedException {
+        validTxState(true);
+
+        id2InfoPrj.invoke(srcId, new ListingRemove(srcName, entry.fileId()));
+        id2InfoPrj.invoke(destId, new ListingAdd(destName, entry));
+    }
+
+    /**
+     * Invoke lock processor.
+     *
+     * @param id File ID.
+     * @param delete Whether lock is taken for delete.
+     * @return Resulting file info.
+     * @throws IgniteCheckedException If failed.
+     */
+    private IgfsFileInfo invokeLock(IgniteUuid id, boolean delete) throws IgniteCheckedException {
+        return invokeAndGet(id, new FileLockProcessor(createFileLockId(delete)));
+    }
+
+    /**
+     * Invoke path update processor.
+     *
+     * @param id File ID.
+     * @param path Path to be updated.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void invokeUpdatePath(IgniteUuid id, IgfsPath path) throws IgniteCheckedException {
+        validTxState(true);
+
+        id2InfoPrj.invoke(id, new UpdatePath(path));
+    }
+
+    /**
+     * Invoke some processor and return new value.
+     *
+     * @param id ID.
+     * @param proc Processor.
+     * @return New file info.
+     * @throws IgniteCheckedException If failed.
+     */
+    private IgfsFileInfo invokeAndGet(IgniteUuid id, EntryProcessor<IgniteUuid, IgfsFileInfo, Void> proc)
+        throws IgniteCheckedException {
+        validTxState(true);
+
+        id2InfoPrj.invoke(id, proc);
+
+        return getInfo(id);
+    }
+
+    /**
+     * Get info.
+     *
+     * @param id ID.
+     * @return Info.
+     * @throws IgniteCheckedException If failed.
+     */
+    @Nullable private IgfsFileInfo getInfo(IgniteUuid id) throws IgniteCheckedException {
+        return id2InfoPrj.get(id);
+    }
+
+    /**
+     * Get several infos.
+     *
+     * @param ids IDs.
+     * @return Infos map.
+     * @throws IgniteCheckedException If failed.
+     */
+    private Map<IgniteUuid, IgfsFileInfo> getInfos(Collection<IgniteUuid> ids) throws IgniteCheckedException {
+        return id2InfoPrj.getAll(ids);
+    }
+
+    /**
      * Create the file in DUAL mode.
      *
      * @param fs File system.
@@ -1913,7 +1940,7 @@ public class IgfsMetaManager extends IgfsManager {
 
                         @Override public IgfsSecondaryOutputStreamDescriptor onSuccess(Map<IgfsPath,
                             IgfsFileInfo> infos) throws Exception {
-                            assert validTxState(true);
+                            validTxState(true);
 
                             assert !infos.isEmpty();
 
@@ -1983,12 +2010,10 @@ public class IgfsMetaManager extends IgfsManager {
                                         path + ", fileId=" + oldId + ", lockId=" + oldInfo.lockId() + ']');
 
                                 id2InfoPrj.remove(oldId); // Remove the old one.
-                                id2InfoPrj.put(newInfo.id(), newInfo); // Put the new one.
-
                                 id2InfoPrj.invoke(parentInfo.id(),
                                     new ListingRemove(path.name(), parentInfo.listing().get(path.name()).fileId()));
-                                id2InfoPrj.invoke(parentInfo.id(),
-                                    new ListingAdd(path.name(), new IgfsListingEntry(newInfo)));
+
+                                createNewEntry(newInfo, parentInfo.id(), path.name()); // Put new one.
 
                                 IgniteInternalFuture<?> delFut = igfsCtx.data().delete(oldInfo);
                             }
@@ -2052,7 +2077,7 @@ public class IgfsMetaManager extends IgfsManager {
 
                         @Override public IgfsSecondaryOutputStreamDescriptor onSuccess(Map<IgfsPath,
                             IgfsFileInfo> infos) throws Exception {
-                            assert validTxState(true);
+                            validTxState(true);
 
                             final IgfsFileInfo info = infos.get(path);
 
@@ -2087,11 +2112,7 @@ public class IgfsMetaManager extends IgfsManager {
                             }
 
                             // Set lock and return.
-                            IgniteUuid lockId = createFileLockId(false);
-
-                            id2InfoPrj.invoke(info.id(), new FileLockProcessor(lockId));
-
-                            IgfsFileInfo lockedInfo = id2InfoPrj.get(info.id());
+                            IgfsFileInfo lockedInfo = invokeLock(info.id(), false);
 
                             return new IgfsSecondaryOutputStreamDescriptor(infos.get(path.parent()).id(),
                                 lockedInfo, out);
@@ -2453,7 +2474,7 @@ public class IgfsMetaManager extends IgfsManager {
                         }
 
                         // Update the deleted file info with path information for delete worker.
-                        id2InfoPrj.invoke(info.id(), new UpdatePath(path));
+                        invokeUpdatePath(info.id(), path);
 
                         return true; // No additional handling is required.
                     }
@@ -2505,12 +2526,7 @@ public class IgfsMetaManager extends IgfsManager {
 
                         fs.update(path, props);
 
-                        IgfsFileInfo parentInfo = infos.get(path.parent());
-
-                        assert path.parent() == null || parentInfo != null;
-
-                        return updatePropertiesNonTx(parentInfo == null ? null : parentInfo.id(),
-                            infos.get(path).id(), path.name(), props);
+                        return updatePropertiesNonTx(infos.get(path).id(), props);
                     }
 
                     @Override public IgfsFileInfo onFailure(@Nullable Exception err) throws IgniteCheckedException {
@@ -2865,7 +2881,7 @@ public class IgfsMetaManager extends IgfsManager {
      */
     private <K, V> boolean putx(IgniteInternalCache<K, V> cache, K key, IgniteClosure<V, V> c)
         throws IgniteCheckedException {
-        assert validTxState(true);
+        validTxState(true);
 
         V oldVal = cache.get(key);
         V newVal = c.apply(oldVal);
@@ -2877,16 +2893,10 @@ public class IgfsMetaManager extends IgfsManager {
      * Check transaction is (not) started.
      *
      * @param inTx Expected transaction state.
-     * @return Transaction state is correct.
      */
-    private boolean validTxState(boolean inTx) {
-        boolean txState = inTx == (id2InfoPrj.tx() != null);
-
-        assert txState : (inTx ? "Method cannot be called outside transaction " :
-            "Method cannot be called in transaction ") + "[tx=" + id2InfoPrj.tx() + ", threadId=" +
-            Thread.currentThread().getId() + ']';
-
-        return txState;
+    private void validTxState(boolean inTx) {
+        assert (inTx && id2InfoPrj.tx() != null) || (!inTx && id2InfoPrj.tx() == null) :
+            "Invalid TX state [expected=" + inTx + ", actual=" + (id2InfoPrj.tx() != null) + ']';
     }
 
     /**
@@ -2912,7 +2922,7 @@ public class IgfsMetaManager extends IgfsManager {
         long modificationTime) throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
-                assert validTxState(false);
+                validTxState(false);
 
                 // Start pessimistic transaction.
                 IgniteInternalTx tx = startTx();
@@ -3310,7 +3320,8 @@ public class IgfsMetaManager extends IgfsManager {
         final @Nullable IgniteUuid affKey,
         final boolean evictExclude,
         @Nullable Map<String, String> fileProps) throws IgniteCheckedException {
-        assert validTxState(false);
+        validTxState(false);
+
         assert path != null;
 
         final String name = path.name();
@@ -3322,15 +3333,7 @@ public class IgfsMetaManager extends IgfsManager {
         while (true) {
             if (busyLock.enterBusy()) {
                 try {
-                    b = new DirectoryChainBuilder(path, dirProps, fileProps) {
-                        /** {@inheritDoc} */
-                        @Override protected IgfsFileInfo buildLeaf() {
-                            long t = System.currentTimeMillis();
-
-                            return new IgfsFileInfo(blockSize, 0L, affKey, createFileLockId(false),
-                                 evictExclude, leafProps, t, t);
-                        }
-                    };
+                    b = new DirectoryChainBuilder(path, dirProps, fileProps, blockSize, affKey, evictExclude);
 
                     // Start Tx:
                     IgniteInternalTx tx = startTx();
@@ -3377,18 +3380,7 @@ public class IgfsMetaManager extends IgfsManager {
                                                 + "[fileName=" + name + ", fileId=" + lowermostExistingInfo.id()
                                                 + ", lockId=" + lockId + ']');
 
-                                        IgniteUuid newLockId = createFileLockId(false);
-
-                                        EntryProcessorResult<IgfsFileInfo> result
-                                            = id2InfoPrj.invoke(lowermostExistingInfo.id(),
-                                                new LockFileProcessor(newLockId));
-
-                                        IgfsFileInfo lockedInfo = result.get();
-
-                                        assert lockedInfo != null; // we already checked lock above.
-                                        assert lockedInfo.lockId() != null;
-                                        assert lockedInfo.lockId().equals(newLockId);
-                                        assert lockedInfo.id().equals(lowermostExistingInfo.id());
+                                        IgfsFileInfo lockedInfo = invokeLock(lowermostExistingInfo.id(), false);
 
                                         IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(lockedInfo, parentId);
 
@@ -3411,15 +3403,12 @@ public class IgfsMetaManager extends IgfsManager {
 
                                         assert deletedEntry != null;
 
-                                        id2InfoPrj.invoke(parentId, new ListingRemove(name, deletedEntry.fileId()));
-
-                                        // Add listing entry into the destination parent listing.
-                                        id2InfoPrj.invoke(trashId,
-                                            new ListingAdd(lowermostExistingInfo.id().toString(), deletedEntry));
+                                        transferEntry(deletedEntry, parentId, name, trashId,
+                                            lowermostExistingInfo.id().toString());
 
                                         // Update a file info of the removed file with a file path,
                                         // which will be used by delete worker for event notifications.
-                                        id2InfoPrj.invoke(lowermostExistingInfo.id(), new UpdatePath(path));
+                                        invokeUpdatePath(lowermostExistingInfo.id(), path);
 
                                         // Make a new locked info:
                                         long t = System.currentTimeMillis();
@@ -3429,12 +3418,7 @@ public class IgfsMetaManager extends IgfsManager {
 
                                         assert newFileInfo.lockId() != null; // locked info should be created.
 
-                                        boolean put = id2InfoPrj.putIfAbsent(newFileInfo.id(), newFileInfo);
-
-                                        assert put;
-
-                                        id2InfoPrj.invoke(parentId,
-                                                new ListingAdd(name, new IgfsListingEntry(newFileInfo)));
+                                        createNewEntry(newFileInfo, parentId, name);
 
                                         IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(newFileInfo, parentId);
 
@@ -3497,54 +3481,103 @@ public class IgfsMetaManager extends IgfsManager {
     /** File chain builder. */
     private class DirectoryChainBuilder {
         /** The requested path to be created. */
-        protected final IgfsPath path;
+        private final IgfsPath path;
 
         /** Full path components. */
-        protected final List<String> components;
+        private final List<String> components;
 
         /** The list of ids. */
-        protected final List<IgniteUuid> idList;
+        private final List<IgniteUuid> idList;
 
         /** The set of ids. */
-        protected final SortedSet<IgniteUuid> idSet;
+        private final SortedSet<IgniteUuid> idSet = new TreeSet<IgniteUuid>(PATH_ID_SORTING_COMPARATOR);
 
         /** The middle node properties. */
-        protected final Map<String, String> middleProps;
+        private final Map<String, String> middleProps;
 
         /** The leaf node properties. */
-        protected final Map<String, String> leafProps;
+        private final Map<String, String> leafProps;
 
         /** The lowermost exsiting path id. */
-        protected final IgniteUuid lowermostExistingId;
+        private final IgniteUuid lowermostExistingId;
 
         /** The existing path. */
-        protected final IgfsPath existingPath;
+        private final IgfsPath existingPath;
 
         /** The created leaf info. */
-        protected IgfsFileInfo leafInfo;
+        private IgfsFileInfo leafInfo;
 
         /** The leaf parent id. */
-        protected IgniteUuid leafParentId;
+        private IgniteUuid leafParentId;
 
         /** The number of existing ids. */
-        protected final int existingIdCnt;
+        private final int existingIdCnt;
+
+        /** Whether laef is directory. */
+        private final boolean leafDir;
+
+        /** Block size. */
+        private final int blockSize;
+
+        /** Affinity key. */
+        private final IgniteUuid affKey;
+
+        /** Evict exclude flag. */
+        private final boolean evictExclude;
 
         /**
-         * Creates the builder and performa all the initial calculations.
+         * Constructor for directories.
+         *
+         * @param path Path.
+         * @param props Properties.
+         * @throws IgniteCheckedException If failed.
          */
-        protected DirectoryChainBuilder(IgfsPath path,
-                 Map<String,String> middleProps, Map<String,String> leafProps) throws IgniteCheckedException {
-            this.path = path;
+        protected DirectoryChainBuilder(IgfsPath path, Map<String, String> props) throws IgniteCheckedException {
+            this(path, props, props, true, 0, null, false);
+        }
 
-            this.components = path.components();
+        /**
+         * Constructor for files.
+         *
+         * @param path Path.
+         * @param dirProps Directory properties.
+         * @param fileProps File properties.
+         * @param blockSize Block size.
+         * @param affKey Affinity key (optional).
+         * @param evictExclude Evict exclude flag.
+         * @throws IgniteCheckedException If failed.
+         */
+        protected DirectoryChainBuilder(IgfsPath path, Map<String, String> dirProps, Map<String, String> fileProps,
+            int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude)
+            throws IgniteCheckedException {
+            this(path, dirProps, fileProps, false, blockSize, affKey, evictExclude);
+        }
 
+        /**
+         * Constructor.
+         *
+         * @param path Path.
+         * @param middleProps Middle properties.
+         * @param leafProps Leaf properties.
+         * @param leafDir Whether leaf is directory or file.
+         * @param blockSize Block size.
+         * @param affKey Affinity key (optional).
+         * @param evictExclude Evict exclude flag.
+         * @throws IgniteCheckedException If failed.
+         */
+        private DirectoryChainBuilder(IgfsPath path, Map<String,String> middleProps, Map<String,String> leafProps,
+            boolean leafDir, int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude)
+            throws IgniteCheckedException {
+            this.path = path;
+            this.components = path.components();
             this.idList = fileIds(path);
-
-            this.idSet = new TreeSet<IgniteUuid>(PATH_ID_SORTING_COMPARATOR);
-
             this.middleProps = middleProps;
-
             this.leafProps = leafProps;
+            this.leafDir = leafDir;
+            this.blockSize = blockSize;
+            this.affKey = affKey;
+            this.evictExclude = evictExclude;
+
             // Store all the non-null ids in the set & construct existing path in one loop:
             IgfsPath existingPath = path.root();
 
@@ -3555,7 +3588,7 @@ public class IgfsMetaManager extends IgfsManager {
 
             int idIdx = 0;
 
-            for (IgniteUuid id: idList) {
+            for (IgniteUuid id : idList) {
                 if (id == null)
                     break;
 
@@ -3581,33 +3614,6 @@ public class IgfsMetaManager extends IgfsManager {
         }
 
         /**
-         * Builds middle nodes.
-         */
-        protected IgfsFileInfo buildMiddleNode(String childName, IgfsFileInfo childInfo) {
-            return new IgfsFileInfo(Collections.singletonMap(childName,
-                    new IgfsListingEntry(childInfo)), middleProps);
-        }
-
-        /**
-         * Builds leaf.
-         */
-        protected IgfsFileInfo buildLeaf()  {
-            long t = System.currentTimeMillis();
-
-            return new IgfsFileInfo(true, leafProps, t, t);
-        }
-
-        /**
-         * Links newly created chain to existing parent.
-         */
-        final void linkBuiltChainToExistingParent(String childName, IgfsFileInfo childInfo)
-                throws IgniteCheckedException {
-            assert childInfo != null;
-
-            id2InfoPrj.invoke(lowermostExistingId, new ListingAdd(childName, new IgfsListingEntry(childInfo)));
-        }
-
-        /**
          * Does the main portion of job building the renmaining path.
          */
         public final void doBuild() throws IgniteCheckedException {
@@ -3615,7 +3621,8 @@ public class IgfsMetaManager extends IgfsManager {
 
             String childName = null;
 
-            IgfsFileInfo newLeafInfo;
+            IgfsFileInfo newInfo;
+
             IgniteUuid parentId = null;
 
             // This loop creates the missing directory chain from the bottom to the top:
@@ -3625,28 +3632,29 @@ public class IgfsMetaManager extends IgfsManager {
                 if (childName == null) {
                     assert childInfo == null;
 
-                    newLeafInfo = buildLeaf();
+                    long t = System.currentTimeMillis();
 
-                    assert newLeafInfo != null;
+                    if (leafDir)
+                        newInfo = new IgfsFileInfo(true, leafProps, t, t);
+                    else
+                        newInfo = new IgfsFileInfo(blockSize, 0L, affKey, createFileLockId(false), evictExclude,
+                            leafProps, t, t);
 
-                    leafInfo = newLeafInfo;
+                    leafInfo = newInfo;
                 }
                 else {
                     assert childInfo != null;
 
-                    newLeafInfo = buildMiddleNode(childName, childInfo);
-
-                    assert newLeafInfo != null;
+                    newInfo = new IgfsFileInfo(Collections.singletonMap(childName,
+                        new IgfsListingEntry(childInfo)), middleProps);
 
                     if (parentId == null)
-                        parentId = newLeafInfo.id();
+                        parentId = newInfo.id();
                 }
 
-                boolean put = id2InfoPrj.putIfAbsent(newLeafInfo.id(), newLeafInfo);
+                id2InfoPrj.put(newInfo.id(), newInfo);
 
-                assert put; // Because we used a new id that should be unique.
-
-                childInfo = newLeafInfo;
+                childInfo = newInfo;
 
                 childName = components.get(i);
             }
@@ -3657,7 +3665,7 @@ public class IgfsMetaManager extends IgfsManager {
             leafParentId = parentId;
 
             // Now link the newly created directory chain to the lowermost existing parent:
-            linkBuiltChainToExistingParent(childName, childInfo);
+            id2InfoPrj.invoke(lowermostExistingId, new ListingAdd(childName, new IgfsListingEntry(childInfo)));
         }
 
         /**
@@ -3674,7 +3682,7 @@ public class IgfsMetaManager extends IgfsManager {
                 }
             }
 
-            if (leafInfo.isDirectory())
+            if (leafDir)
                 IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_DIR_CREATED);
             else {
                 IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_FILE_CREATED);
@@ -3684,66 +3692,6 @@ public class IgfsMetaManager extends IgfsManager {
     }
 
     /**
-     * Processor closure to locks a file for writing.
-     */
-    private static class LockFileProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
-            Externalizable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** New lock id to lock the entry. */
-        private IgniteUuid newLockId;
-
-        /**
-         * Constructor.
-         */
-        public LockFileProcessor(IgniteUuid newLockId) {
-            assert newLockId != null;
-
-            this.newLockId = newLockId;
-        }
-
-        /**
-         * Empty constructor required for {@link Externalizable}.
-         */
-        public LockFileProcessor() {
-            // No-op.
-        }
-
-        /** {@inheritDoc} */
-        @Override @Nullable public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry,
-                 Object... arguments) throws EntryProcessorException {
-            final IgfsFileInfo info = entry.getValue();
-
-            assert info != null;
-
-            if (info.lockId() != null)
-                return null; // file is already locked.
-
-            IgfsFileInfo newInfo = new IgfsFileInfo(info, newLockId, info.modificationTime());
-
-            entry.setValue(newInfo);
-
-            return newInfo;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws IOException {
-            U.writeGridUuid(out, newLockId);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-            newLockId = U.readGridUuid(in);
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(LockFileProcessor.class, this);
-        }
-    }
-
-    /**
      * File lock entry processor.
      */
     private static class FileLockProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>, Externalizable {
@@ -3902,6 +3850,69 @@ public class IgfsMetaManager extends IgfsManager {
     }
 
     /**
+     * Update properties processor.
+     */
+    private static class UpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+        Externalizable {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** Properties to be updated. */
+        private Map<String, String> props;
+
+        /**
+         * Constructor.
+         */
+        public UpdatePropertiesProcessor() {
+            // No-op.
+        }
+
+        /**
+         * Constructor.
+         *
+         * @param props Properties.
+         */
+        public UpdatePropertiesProcessor(Map<String, String> props) {
+            this.props = props;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+            throws EntryProcessorException {
+            IgfsFileInfo oldInfo = entry.getValue();
+
+            Map<String, String> tmp = oldInfo.properties();
+
+            tmp = tmp == null ? new GridLeanMap<String, String>(props.size()) : new GridLeanMap<>(tmp);
+
+            for (Map.Entry<String, String> e : props.entrySet()) {
+                if (e.getValue() == null)
+                    // Remove properties with 'null' values.
+                    tmp.remove(e.getKey());
+                else
+                    // Add/overwrite property.
+                    tmp.put(e.getKey(), e.getValue());
+            }
+
+            IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, tmp);
+
+            entry.setValue(newInfo);
+
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            U.writeStringMap(out, props);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            props = U.readStringMap(in);
+        }
+    }
+
+    /**
      * Update times entry processor.
      */
     private static class UpdateTimesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,

http://git-wip-us.apache.org/repos/asf/ignite/blob/dda1f0ed/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
index f3d35f4..72a2bee 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
@@ -171,33 +171,30 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
             assertNull("Unexpected stored properties: " + info, info.properties().get(key1));
             assertNull("Unexpected stored properties: " + info, info.properties().get(key2));
 
-            info = mgr.updateProperties(ROOT_ID, fileId, fileName, F.asMap(key1, "1"));
+            info = mgr.updateProperties(fileId, F.asMap(key1, "1"));
 
             assertEquals("Unexpected stored properties: " + info, "1", info.properties().get(key1));
 
-            info = mgr.updateProperties(ROOT_ID, fileId, fileName, F.asMap(key2, "2"));
+            info = mgr.updateProperties(fileId, F.asMap(key2, "2"));
 
            // assertEquals("Unexpected stored properties: " + info, F.asMap(key1, "1", key2, "2"), info.properties());
             assertEquals("Unexpected stored properties: " + info, "1", info.properties().get(key1));
             assertEquals("Unexpected stored properties: " + info, "2", info.properties().get(key2));
 
-            info = mgr.updateProperties(ROOT_ID, fileId, fileName, F.<String, String>asMap(key1, null));
+            info = mgr.updateProperties(fileId, F.<String, String>asMap(key1, null));
 
             assertEquals("Unexpected stored properties: " + info, "2", info.properties().get(key2));
 
-            info = mgr.updateProperties(ROOT_ID, fileId, fileName, F.<String, String>asMap(key2, null));
+            info = mgr.updateProperties(fileId, F.<String, String>asMap(key2, null));
 
             assertNull("Unexpected stored properties: " + info, info.properties().get(key1));
             assertNull("Unexpected stored properties: " + info, info.properties().get(key2));
-
-            assertNull(mgr.updateProperties(ROOT_ID, fileId, "not_exists", F.<String, String>asMap(key2, null)));
         }
 
         mgr.softDelete(new IgfsPath("/dir"), true);
         mgr.softDelete(new IgfsPath("/file"), false);
 
-        assertNull(mgr.updateProperties(ROOT_ID, dir.id(), "dir", F.asMap("p", "7")));
-        assertNull(mgr.updateProperties(ROOT_ID, file.id(), "file", F.asMap("q", "8")));
+        assertNull(mgr.updateProperties(dir.id(), F.asMap("p", "7")));
     }
 
     private IgfsFileInfo mkdirsAndGetInfo(String path) throws IgniteCheckedException {
@@ -309,8 +306,8 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
         expectsRenameFail("/a/k", "/a/b/", "Failed to perform move because destination already " +
             "contains entry with the same name existing file");
 
-        mgr.delete(a.id(), "k", k.id());
-        mgr.delete(b.id(), "k", z.id());
+        mgr.delete(a.id(), "k", z.id());
+        mgr.delete(b.id(), "k", k.id());
 
         System.out.println("/: " + mgr.directoryListing(ROOT_ID));
         System.out.println("a: " + mgr.directoryListing(a.id()));
@@ -339,9 +336,7 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
         assertEquals(F.asMap("a", new IgfsListingEntry(a), "f1", new IgfsListingEntry(f1)),
                 mgr.directoryListing(ROOT_ID));
 
-        assertEquals(
-            F.asMap("b", new IgfsListingEntry(b),
-                "f2", new IgfsListingEntry(f2)),
+        assertEquals(F.asMap("b", new IgfsListingEntry(b), "f2", new IgfsListingEntry(f2)),
             mgr.directoryListing(a.id()));
 
         assertEmpty(mgr.directoryListing(b.id()));
@@ -423,7 +418,7 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
         Class<? extends Throwable> cls, @Nullable String msg) {
         assertThrows(log, new Callable() {
             @Override public Object call() throws Exception {
-                return mgr.updateProperties(null, fileId, "file", props);
+                return mgr.updateProperties(fileId, props);
             }
         }, cls, msg);
     }


[09/11] ignite git commit: IGNITE-2853 - Fixed cancellation of the job that depends on a service

Posted by nt...@apache.org.
IGNITE-2853 - Fixed cancellation of the job that depends on a service


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

Branch: refs/heads/ignite-2791
Commit: d3420e6bc5e833a6eb1daaad25b11843f97328d5
Parents: 69d1f4b
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Mar 16 22:21:24 2016 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Mar 16 22:21:24 2016 -0700

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |   2 +-
 .../ComputeJobCancelWithServiceSelfTest.java    | 154 +++++++++++++++++++
 .../testsuites/IgniteKernalSelfTestSuite.java   |   2 +
 3 files changed, 157 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d3420e6b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 5d8daf6..8df89f3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -849,6 +849,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
             startProcessor(createComponent(IgniteCacheObjectProcessor.class, ctx));
             startProcessor(new GridCacheProcessor(ctx));
             startProcessor(new GridQueryProcessor(ctx));
+            startProcessor(new GridServiceProcessor(ctx));
             startProcessor(new GridTaskSessionProcessor(ctx));
             startProcessor(new GridJobProcessor(ctx));
             startProcessor(new GridTaskProcessor(ctx));
@@ -860,7 +861,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
             startProcessor((GridProcessor)(cfg.isPeerClassLoadingEnabled() ?
                 IgniteComponentType.HADOOP.create(ctx, true): // No-op when peer class loading is enabled.
                 IgniteComponentType.HADOOP.createIfInClassPath(ctx, cfg.getHadoopConfiguration() != null)));
-            startProcessor(new GridServiceProcessor(ctx));
             startProcessor(new DataStructuresProcessor(ctx));
             startProcessor(createComponent(PlatformProcessor.class, ctx));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d3420e6b/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java
new file mode 100644
index 0000000..2718ed9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java
@@ -0,0 +1,154 @@
+/*
+ * 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;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskFuture;
+import org.apache.ignite.compute.ComputeTaskSplitAdapter;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test cancellation of a job that depends on service.
+ */
+public class ComputeJobCancelWithServiceSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testJobCancel() throws Exception {
+        Ignite server = startGrid("server");
+
+        server.services().deployNodeSingleton("my-service", new MyService());
+
+        Ignition.setClientMode(true);
+
+        Ignite client = startGrid("client");
+
+        IgniteCompute compute = client.compute().withAsync();
+
+        compute.execute(new MyTask(), null);
+
+        ComputeTaskFuture<Integer> fut = compute.future();
+
+        Thread.sleep(3000);
+
+        server.close();
+
+        assertEquals(42, fut.get().intValue());
+    }
+
+    /** */
+    private static class MyService implements Service {
+        /** */
+        private volatile boolean cancelled;
+
+        /** {@inheritDoc} */
+        @Override public void init(ServiceContext ctx) throws Exception {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void execute(ServiceContext ctx) throws Exception {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void cancel(ServiceContext ctx) {
+            cancelled = true;
+        }
+
+        /**
+         * @return Response.
+         */
+        public int hello() {
+            assertFalse("Service already cancelled!", cancelled);
+
+            return 42;
+        }
+    }
+
+    /** */
+    private static class MyTask extends ComputeTaskSplitAdapter<Object, Integer> {
+        /** {@inheritDoc} */
+        @Override protected Collection<? extends ComputeJob> split(int gridSize, Object arg) {
+            return Collections.singletonList(new ComputeJobAdapter() {
+                @IgniteInstanceResource
+                private Ignite ignite;
+
+                @Override
+                public Object execute() throws IgniteException {
+                    MyService svc = ignite.services().service("my-service");
+
+                    while (!isCancelled()) {
+                        try {
+                            Thread.sleep(1000);
+
+                            svc.hello();
+                        }
+                        catch (InterruptedException e) {
+                            // No-op.
+                        }
+                    }
+
+                    assertTrue(isCancelled());
+
+                    return svc.hello();
+                }
+            });
+        }
+
+        /** {@inheritDoc} */
+        @Override public Integer reduce(List<ComputeJobResult> results) {
+            assertEquals(1, results.size());
+
+            return results.get(0).getData();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/d3420e6b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
index 6233bab..a8d6e5c 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
@@ -19,6 +19,7 @@ package org.apache.ignite.testsuites;
 
 import java.util.Set;
 import junit.framework.TestSuite;
+import org.apache.ignite.internal.ComputeJobCancelWithServiceSelfTest;
 import org.apache.ignite.internal.GridCommunicationSelfTest;
 import org.apache.ignite.internal.GridDiscoveryEventSelfTest;
 import org.apache.ignite.internal.GridDiscoverySelfTest;
@@ -114,6 +115,7 @@ public class IgniteKernalSelfTestSuite extends TestSuite {
         suite.addTestSuite(IgniteUpdateNotifierPerClusterSettingSelfTest.class);
         suite.addTestSuite(GridLocalEventListenerSelfTest.class);
         suite.addTestSuite(IgniteTopologyPrintFormatSelfTest.class);
+        suite.addTestSuite(ComputeJobCancelWithServiceSelfTest.class);
 
         // Managed Services.
         suite.addTestSuite(GridServiceProcessorSingleNodeSelfTest.class);


[02/11] ignite git commit: IGNITE-2792: User-defined configuration is not passed to system caches anymore. This closes #551.

Posted by nt...@apache.org.
IGNITE-2792: User-defined configuration is not passed to system caches anymore. This closes #551.


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

Branch: refs/heads/ignite-2791
Commit: 297cbcbb5ba12ec688ea9e1ad4c32cdeea0ba7aa
Parents: dda1f0e
Author: dkarachentsev <dk...@gridgain.com>
Authored: Wed Mar 16 11:56:14 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Mar 16 11:56:14 2016 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      |  10 +-
 .../processors/cache/GridCacheUtils.java        |  14 ++
 .../transactions/IgniteTransactionsImpl.java    |   9 +-
 .../cache/IgniteTxConfigCacheSelfTest.java      | 249 +++++++++++++++++++
 .../ignite/testsuites/IgniteCacheTestSuite.java |   2 +
 .../hadoop/cache/HadoopTxConfigCacheTest.java   |  42 ++++
 .../testsuites/IgniteHadoopTestSuite.java       |   3 +
 7 files changed, 320 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/297cbcbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 9827dad..86036ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -3431,7 +3431,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         A.notNull(concurrency, "concurrency");
         A.notNull(isolation, "isolation");
 
-        TransactionConfiguration cfg = ctx.gridConfig().getTransactionConfiguration();
+        TransactionConfiguration cfg = CU.transactionConfiguration(ctx, ctx.kernalContext().config());
 
         return txStart(
             concurrency,
@@ -4220,7 +4220,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         IgniteTxLocalAdapter tx = ctx.tm().threadLocalTx(ctx);
 
         if (tx == null || tx.implicit()) {
-            TransactionConfiguration tCfg = ctx.gridConfig().getTransactionConfiguration();
+            TransactionConfiguration tCfg = CU.transactionConfiguration(ctx, ctx.kernalContext().config());
 
             CacheOperationContext opCtx = ctx.operationContextPerCall();
 
@@ -4317,6 +4317,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
 
         CacheOperationContext opCtx = ctx.operationContextPerCall();
 
+        final TransactionConfiguration txCfg = CU.transactionConfiguration(ctx, ctx.kernalContext().config());
+
         if (tx == null || tx.implicit()) {
             boolean skipStore = ctx.skipStore(); // Save value of thread-local flag.
 
@@ -4329,7 +4331,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
                     ctx.systemTx() ? ctx : null,
                     OPTIMISTIC,
                     READ_COMMITTED,
-                    ctx.kernalContext().config().getTransactionConfiguration().getDefaultTxTimeout(),
+                    txCfg.getDefaultTxTimeout(),
                     !skipStore,
                     0);
 
@@ -5001,7 +5003,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
                 ctx.systemTx() ? ctx : null,
                 OPTIMISTIC,
                 READ_COMMITTED,
-                ctx.kernalContext().config().getTransactionConfiguration().getDefaultTxTimeout(),
+                CU.transactionConfiguration(ctx, ctx.kernalContext().config()).getDefaultTxTimeout(),
                 opCtx == null || !opCtx.skipStore(),
                 0);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/297cbcbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 25ea14c..94307ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -57,6 +57,7 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.FileSystemConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.TransactionConfiguration;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
 import org.apache.ignite.internal.IgniteInternalFuture;
@@ -157,6 +158,9 @@ public class GridCacheUtils {
     /** Empty predicate array. */
     private static final IgnitePredicate[] EMPTY = new IgnitePredicate[0];
 
+    /** Default transaction config. */
+    private static final TransactionConfiguration DEFAULT_TX_CFG = new TransactionConfiguration();
+
     /** Partition to state transformer. */
     private static final IgniteClosure PART2STATE =
         new C1<GridDhtLocalPartition, GridDhtPartitionState>() {
@@ -1864,4 +1868,14 @@ public class GridCacheUtils {
     public static boolean isSwapEnabled(ClusterNode node) {
         return !node.attributes().containsKey(NOOP_SWAP_SPACE_SPI_ATTR_NAME);
     }
+
+    /**
+     * @return default TX configuration if system cache is used or current grid TX config otherwise.
+     */
+    public static TransactionConfiguration transactionConfiguration(final @Nullable GridCacheContext sysCacheCtx,
+        final IgniteConfiguration cfg) {
+        return sysCacheCtx != null && sysCacheCtx.systemTx()
+            ? DEFAULT_TX_CFG
+            : cfg.getTransactionConfiguration();
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/297cbcbb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
index 76f2f77..7c7b5a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
@@ -23,14 +23,13 @@ import org.apache.ignite.internal.IgniteTransactionsEx;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.transactions.Transaction;
 import org.apache.ignite.transactions.TransactionConcurrency;
 import org.apache.ignite.transactions.TransactionIsolation;
 import org.apache.ignite.transactions.TransactionMetrics;
 import org.jetbrains.annotations.Nullable;
 
-import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
-
 /**
  * Grid transactions implementation.
  */
@@ -47,7 +46,7 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
 
     /** {@inheritDoc} */
     @Override public Transaction txStart() throws IllegalStateException {
-        TransactionConfiguration cfg = cctx.gridConfig().getTransactionConfiguration();
+        TransactionConfiguration cfg = CU.transactionConfiguration(null, cctx.kernalContext().config());
 
         return txStart0(
             cfg.getDefaultTxConcurrency(),
@@ -63,7 +62,7 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
         A.notNull(concurrency, "concurrency");
         A.notNull(isolation, "isolation");
 
-        TransactionConfiguration cfg = cctx.gridConfig().getTransactionConfiguration();
+        TransactionConfiguration cfg = CU.transactionConfiguration(null, cctx.kernalContext().config());
 
         return txStart0(
             concurrency,
@@ -124,7 +123,7 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
 
         checkTransactional(ctx);
 
-        TransactionConfiguration cfg = cctx.gridConfig().getTransactionConfiguration();
+        TransactionConfiguration cfg = CU.transactionConfiguration(ctx, cctx.kernalContext().config());
 
         return txStart0(concurrency,
             isolation,

http://git-wip-us.apache.org/repos/asf/ignite/blob/297cbcbb/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java
new file mode 100644
index 0000000..94b5620
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java
@@ -0,0 +1,249 @@
+/*
+ * 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.cache;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.TransactionConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionTimeoutException;
+
+import javax.cache.CacheException;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
+
+/**
+ * Test checks that grid transaction configuration doesn't influence system caches.
+ */
+public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest {
+    /** Ip finder. */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** Test cache name. */
+    private static final String CACHE_NAME = "cache_name";
+
+    /** Timeout of transaction. */
+    private static final long TX_TIMEOUT = 100;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg =  super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setAtomicityMode(atomicityMode());
+        ccfg.setBackups(1);
+
+        cfg.setCacheConfiguration(ccfg);
+
+        final TransactionConfiguration txCfg = new TransactionConfiguration();
+
+        txCfg.setDefaultTxTimeout(TX_TIMEOUT);
+
+        cfg.setTransactionConfiguration(txCfg);
+
+        return cfg;
+    }
+
+    /**
+     * @return Cache atomicity mode.
+     */
+    public CacheAtomicityMode atomicityMode() {
+        return TRANSACTIONAL;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrids(1);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * Success if user tx was timed out.
+     *
+     * @throws Exception
+     */
+    public void testUserTxTimeout() throws Exception {
+        final Ignite ignite = grid(0);
+
+        final IgniteCache<Object, Object> cache = ignite.getOrCreateCache(CACHE_NAME);
+
+        checkImplicitTxTimeout(cache);
+        checkExplicitTxTimeout(cache, ignite);
+    }
+
+    /**
+     * Success if system caches weren't timed out.
+     *
+     * @throws Exception
+     */
+    public void testSystemCacheTx() throws Exception {
+        final Ignite ignite = grid(0);
+
+        final IgniteInternalCache<Object, Object> utilCache = getSystemCache(ignite, CU.UTILITY_CACHE_NAME);
+
+        checkImplicitTxSuccess(utilCache);
+        checkStartTxSuccess(utilCache);
+
+        final IgniteInternalCache<Object, Object> atomicsCache = getSystemCache(ignite, CU.ATOMICS_CACHE_NAME);
+
+        checkImplicitTxSuccess(atomicsCache);
+        checkStartTxSuccess(atomicsCache);
+    }
+
+    /**
+     * Extract system cache from kernal.
+     *
+     * @param ignite Ignite instance.
+     * @param cacheName System cache name.
+     * @return Internal cache instance.
+     */
+    protected IgniteInternalCache<Object, Object> getSystemCache(final Ignite ignite, final String cacheName) {
+        return ((IgniteKernal) ignite).context().cache().cache(cacheName);
+    }
+
+    /**
+     * Success if implicit tx fails.
+     *
+     * @param cache Cache name.
+     * @throws Exception
+     */
+    protected void checkImplicitTxTimeout(final IgniteCache<Object, Object> cache) throws Exception {
+        try {
+            cache.invoke("key", new EntryProcessor<Object, Object, Object>() {
+                @Override public Object process(final MutableEntry<Object, Object> entry, final Object... args)
+                    throws EntryProcessorException {
+                    try {
+                        sleepForTxFailure();
+                    } catch (InterruptedException e) {
+                        throw new EntryProcessorException(e);
+                    }
+
+                    return null;
+                }
+            });
+
+            fail("Timeout exception must be thrown");
+        }
+        catch (CacheException e) {
+            // OK
+        }
+
+        cache.clear();
+    }
+
+    /**
+     * Success if explicit tx fails.
+     *
+     * @param cache Cache name.
+     * @param ignite Ignite instance.
+     * @throws Exception
+     */
+    protected void checkExplicitTxTimeout(final IgniteCache<Object, Object> cache, final Ignite ignite)
+        throws Exception {
+        try (final Transaction tx = ignite.transactions().txStart()) {
+            assert tx != null;
+
+            sleepForTxFailure();
+
+            cache.put("key", "val");
+
+            fail("Timeout exception must be thrown");
+        }
+        catch (CacheException e) {
+            assert e.getCause() instanceof TransactionTimeoutException;
+        }
+
+        assert !cache.containsKey("key");
+    }
+
+    /**
+     * Success if explicit tx doesn't fail.
+     *
+     * @param cache Cache instance.
+     * @throws Exception
+     */
+    protected void checkStartTxSuccess(final IgniteInternalCache<Object, Object> cache) throws Exception {
+        try (final IgniteInternalTx tx = CU.txStartInternal(cache.context(), cache, PESSIMISTIC, READ_COMMITTED)) {
+            assert tx != null;
+
+            sleepForTxFailure();
+
+            cache.put("key", "val");
+
+            tx.commit();
+        }
+
+        assert cache.containsKey("key");
+
+        cache.clear();
+    }
+
+    /**
+     * Success if implicit tx fails.
+     *
+     * @param cache Cache instance.
+     * @throws Exception
+     */
+    protected void checkImplicitTxSuccess(final IgniteInternalCache<Object, Object> cache) throws Exception {
+        cache.invoke("key", new EntryProcessor<Object, Object, Object>() {
+            @Override public Object process(final MutableEntry<Object, Object> entry, final Object... args)
+                throws EntryProcessorException {
+                try {
+                    sleepForTxFailure();
+                } catch (InterruptedException e) {
+                    throw new EntryProcessorException(e);
+                }
+                return null;
+            }
+        });
+
+        cache.clear();
+    }
+
+    /**
+     * Sleep multiple {@link #TX_TIMEOUT} times.
+     *
+     * @throws InterruptedException
+     */
+    private void sleepForTxFailure() throws InterruptedException {
+        Thread.sleep(TX_TIMEOUT * 3);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/297cbcbb/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 045ff6f..2613175 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -107,6 +107,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheTxNearEnabledInvok
 import org.apache.ignite.internal.processors.cache.IgniteClientAffinityAssignmentSelfTest;
 import org.apache.ignite.internal.processors.cache.IgnitePutAllLargeBatchSelfTest;
 import org.apache.ignite.internal.processors.cache.IgnitePutAllUpdateNonPreloadedPartitionSelfTest;
+import org.apache.ignite.internal.processors.cache.IgniteTxConfigCacheSelfTest;
 import org.apache.ignite.internal.processors.cache.context.IgniteCacheAtomicExecutionContextTest;
 import org.apache.ignite.internal.processors.cache.context.IgniteCacheContinuousExecutionContextTest;
 import org.apache.ignite.internal.processors.cache.context.IgniteCacheIsolatedExecutionContextTest;
@@ -293,6 +294,7 @@ public class IgniteCacheTestSuite extends TestSuite {
 
         suite.addTestSuite(CachePutEventListenerErrorSelfTest.class);
 
+        suite.addTestSuite(IgniteTxConfigCacheSelfTest.class);
         return suite;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/297cbcbb/modules/hadoop/src/test/java/org/apache/ignite/hadoop/cache/HadoopTxConfigCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/hadoop/cache/HadoopTxConfigCacheTest.java b/modules/hadoop/src/test/java/org/apache/ignite/hadoop/cache/HadoopTxConfigCacheTest.java
new file mode 100644
index 0000000..6f910f1
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/hadoop/cache/HadoopTxConfigCacheTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.hadoop.cache;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.IgniteTxConfigCacheSelfTest;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+
+/**
+ * Test checks whether hadoop system cache doesn't use user defined TX config.
+ */
+public class HadoopTxConfigCacheTest  extends IgniteTxConfigCacheSelfTest {
+    /**
+     * Success if system caches weren't timed out.
+     *
+     * @throws Exception
+     */
+    public void testSystemCacheTx() throws Exception {
+        final Ignite ignite = grid(0);
+
+        final IgniteInternalCache<Object, Object> hadoopCache = getSystemCache(ignite, CU.SYS_CACHE_HADOOP_MR);
+
+        checkImplicitTxSuccess(hadoopCache);
+        checkStartTxSuccess(hadoopCache);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/297cbcbb/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
index acd255c..e03e4e1 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
@@ -35,6 +35,7 @@ import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
 import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.client.hadoop.HadoopClientProtocolEmbeddedSelfTest;
 import org.apache.ignite.client.hadoop.HadoopClientProtocolSelfTest;
+import org.apache.ignite.hadoop.cache.HadoopTxConfigCacheTest;
 import org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactorySelfTest;
 import org.apache.ignite.igfs.Hadoop1OverIgfsDualAsyncTest;
 import org.apache.ignite.igfs.Hadoop1OverIgfsDualSyncTest;
@@ -181,6 +182,8 @@ public class IgniteHadoopTestSuite extends TestSuite {
         suite.addTest(new TestSuite(ldr.loadClass(HadoopCommandLineTest.class.getName())));
 
         suite.addTest(new TestSuite(ldr.loadClass(HadoopSecondaryFileSystemConfigurationTest.class.getName())));
+
+        suite.addTest(new TestSuite(ldr.loadClass(HadoopTxConfigCacheTest.class.getName())));
         return suite;
     }
 


[05/11] ignite git commit: IGNITE-2843 .NET: Added CacheConfiguration.WriteThrough/ReadThrough properties. This closes #556.

Posted by nt...@apache.org.
IGNITE-2843 .NET: Added CacheConfiguration.WriteThrough/ReadThrough properties. This closes #556.


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

Branch: refs/heads/ignite-2791
Commit: c638f1e7e9a6994cf38de4d444354a0938de0d31
Parents: ad6bbd9
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Wed Mar 16 13:11:05 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Mar 16 13:11:05 2016 +0300

----------------------------------------------------------------------
 .../utils/PlatformConfigurationUtils.java       |   4 +
 .../Apache.Ignite.Core.Tests.csproj             |   1 +
 .../Cache/CacheConfigurationTest.cs             |   5 +-
 .../Cache/Store/CacheStoreTest.cs               |   5 +-
 .../Cache/Store/CacheStoreTestCodeConfig.cs     | 106 +++++++++++++++++++
 .../IgniteConfigurationSerializerTest.cs        |   4 +-
 .../Cache/Configuration/CacheConfiguration.cs   |  36 +++++++
 .../IgniteConfigurationSection.xsd              |   2 +
 8 files changed, 158 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c638f1e7/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index 50728a1..e08d1ba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -140,6 +140,8 @@ import java.util.Map;
         ccfg.setWriteBehindFlushSize(in.readInt());
         ccfg.setWriteBehindFlushThreadCount(in.readInt());
         ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.fromOrdinal(in.readInt()));
+        ccfg.setReadThrough(in.readBoolean());
+        ccfg.setWriteThrough(in.readBoolean());
 
         Object storeFactory = in.readObjectDetached();
 
@@ -419,6 +421,8 @@ import java.util.Map;
         writer.writeInt(ccfg.getWriteBehindFlushSize());
         writer.writeInt(ccfg.getWriteBehindFlushThreadCount());
         writer.writeInt(ccfg.getWriteSynchronizationMode() == null ? 0 : ccfg.getWriteSynchronizationMode().ordinal());
+        writer.writeBoolean(ccfg.isReadThrough());
+        writer.writeBoolean(ccfg.isWriteThrough());
 
         if (ccfg.getCacheStoreFactory() instanceof PlatformDotNetCacheStoreFactoryNative)
             writer.writeObject(((PlatformDotNetCacheStoreFactoryNative)ccfg.getCacheStoreFactory()).getNativeFactory());

http://git-wip-us.apache.org/repos/asf/ignite/blob/c638f1e7/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 8c266d7..0dcd1f0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -91,6 +91,7 @@
     <Compile Include="Cache\Store\CacheParallelLoadStoreTest.cs" />
     <Compile Include="Cache\Store\CacheStoreSessionTest.cs" />
     <Compile Include="Cache\Store\CacheStoreTest.cs" />
+    <Compile Include="Cache\Store\CacheStoreTestCodeConfig.cs" />
     <Compile Include="Cache\Store\CacheTestParallelLoadStore.cs" />
     <Compile Include="Cache\Store\CacheTestStore.cs" />
     <Compile Include="Compute\CancellationTest.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/c638f1e7/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
index 9f019832..bc259e5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
@@ -24,8 +24,6 @@ namespace Apache.Ignite.Core.Tests.Cache
     using Apache.Ignite.Core.Cache.Configuration;
     using Apache.Ignite.Core.Cache.Store;
     using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Discovery.Tcp;
-    using Apache.Ignite.Core.Discovery.Tcp.Static;
     using NUnit.Framework;
 
     /// <summary>
@@ -436,6 +434,9 @@ namespace Apache.Ignite.Core.Tests.Cache
                 WriteBehindBatchSize = 18,
                 WriteBehindEnabled = false,
                 WriteSynchronizationMode = CacheWriteSynchronizationMode.PrimarySync,
+                CacheStoreFactory = new CacheStoreFactoryTest(),
+                ReadThrough = true,
+                WriteThrough = true,
                 QueryEntities = new[]
                 {
                     new QueryEntity

http://git-wip-us.apache.org/repos/asf/ignite/blob/c638f1e7/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index b48cdc9..cc46642 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 
+#pragma warning disable 618
 namespace Apache.Ignite.Core.Tests.Cache.Store
 {
     using System;
@@ -134,7 +135,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
         ///
         /// </summary>
         [TestFixtureSetUp]
-        public void BeforeTests()
+        public virtual void BeforeTests()
         {
             TestUtils.KillProcesses();
 
@@ -156,7 +157,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
         ///
         /// </summary>
         [TestFixtureTearDown]
-        public virtual void AfterTests()
+        public void AfterTests()
         {
             Ignition.StopAll(true);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/c638f1e7/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTestCodeConfig.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTestCodeConfig.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTestCodeConfig.cs
new file mode 100644
index 0000000..0b6f771
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTestCodeConfig.cs
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache.Store
+{
+    using System;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Cache.Store;
+    using Apache.Ignite.Core.Common;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Tests cache store without Spring.
+    /// </summary>
+    public class CacheStoreTestCodeConfig : CacheStoreTest
+    {
+        /// <summary>
+        /// Fixture setup.
+        /// </summary>
+        [TestFixtureSetUp]
+        public override void BeforeTests()
+        {
+            var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                BinaryConfiguration = new BinaryConfiguration(typeof(Key), typeof(Value)),
+                CacheConfiguration = new[]
+                {
+                    new CacheConfiguration
+                    {
+                        Name = "binary_store",
+                        CacheMode = CacheMode.Local,
+                        AtomicityMode = CacheAtomicityMode.Transactional,
+                        WriteThrough = true,
+                        ReadThrough = true,
+                        KeepBinaryInStore = true,
+                        CacheStoreFactory = new StoreFactory()
+                    }, 
+                    new CacheConfiguration
+                    {
+                        Name = "object_store",
+                        CacheMode = CacheMode.Local,
+                        AtomicityMode = CacheAtomicityMode.Transactional,
+                        WriteThrough = true,
+                        ReadThrough = true,
+                        KeepBinaryInStore = false,
+                        CacheStoreFactory = new StoreFactory()
+                    }, 
+                    new CacheConfiguration
+                    {
+                        Name = "template_store*",
+                        CacheMode = CacheMode.Local,
+                        AtomicityMode = CacheAtomicityMode.Transactional,
+                        WriteThrough = true,
+                        ReadThrough = true,
+                        KeepBinaryInStore = false,
+                        CacheStoreFactory = new StoreFactory()
+                    }, 
+                    new CacheConfiguration
+                    {
+                        Name = "custom_store",
+                        CacheMode = CacheMode.Local,
+                        AtomicityMode = CacheAtomicityMode.Transactional,
+                        WriteThrough = true,
+                        ReadThrough = true,
+                        CacheStoreFactory = new CustomStoreFactory()
+                    }, 
+                }
+            };
+
+            Ignition.Start(cfg);
+        }
+
+        [Serializable]
+        private class StoreFactory : IFactory<ICacheStore>
+        {
+            public ICacheStore CreateInstance()
+            {
+                return new CacheTestStore();
+            }
+        }
+
+        [Serializable]
+        private class CustomStoreFactory : IFactory<ICacheStore>
+        {
+            public ICacheStore CreateInstance()
+            {
+                return new CacheTestStore {IntProperty = 42, StringProperty = "String value"};
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c638f1e7/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index d944a04..e221a55 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -68,7 +68,7 @@ namespace Apache.Ignite.Core.Tests
                                 <iLifecycleBean type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+LifecycleBean, Apache.Ignite.Core.Tests' foo='15' />
                             </lifecycleBeans>
                             <cacheConfiguration>
-                                <cacheConfiguration cacheMode='Replicated'>
+                                <cacheConfiguration cacheMode='Replicated' readThrough='true' writeThrough='true'>
                                     <queryEntities>    
                                         <queryEntity keyType='System.Int32' valueType='System.String'>    
                                             <fields>
@@ -120,6 +120,8 @@ namespace Apache.Ignite.Core.Tests
             var cacheCfg = cfg.CacheConfiguration.First();
 
             Assert.AreEqual(CacheMode.Replicated, cacheCfg.CacheMode);
+            Assert.IsTrue(cacheCfg.ReadThrough);
+            Assert.IsTrue(cacheCfg.WriteThrough);
 
             var queryEntity = cacheCfg.QueryEntities.Single();
             Assert.AreEqual(typeof(int), queryEntity.KeyType);

http://git-wip-us.apache.org/repos/asf/ignite/blob/c638f1e7/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
index b319be9..ba509fc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
@@ -135,6 +135,12 @@ namespace Apache.Ignite.Core.Cache.Configuration
         /// <summary> Default value for 'copyOnRead' flag. </summary>
         public const bool DefaultCopyOnRead = true;
 
+        /// <summary> Default value for read-through behavior. </summary>
+        public const bool DefaultReadThrough = false;
+
+        /// <summary> Default value for write-through behavior. </summary>
+        public const bool DefaultWriteThrough = false;
+
         /// <summary>
         /// Gets or sets the cache name.
         /// </summary>
@@ -255,6 +261,8 @@ namespace Apache.Ignite.Core.Cache.Configuration
             WriteBehindFlushSize = reader.ReadInt();
             WriteBehindFlushThreadCount = reader.ReadInt();
             WriteSynchronizationMode = (CacheWriteSynchronizationMode) reader.ReadInt();
+            ReadThrough = reader.ReadBoolean();
+            WriteThrough = reader.ReadBoolean();
             CacheStoreFactory = reader.ReadObject<IFactory<ICacheStore>>();
 
             var count = reader.ReadInt();
@@ -303,6 +311,8 @@ namespace Apache.Ignite.Core.Cache.Configuration
             writer.WriteInt(WriteBehindFlushSize);
             writer.WriteInt(WriteBehindFlushThreadCount);
             writer.WriteInt((int) WriteSynchronizationMode);
+            writer.WriteBoolean(ReadThrough);
+            writer.WriteBoolean(WriteThrough);
             writer.WriteObject(CacheStoreFactory);
 
             if (QueryEntities != null)
@@ -589,10 +599,36 @@ namespace Apache.Ignite.Core.Cache.Configuration
 
         /// <summary>
         /// Gets or sets the factory for underlying persistent storage for read-through and write-through operations.
+        /// <para />
+        /// See <see cref="ReadThrough"/> and <see cref="WriteThrough"/> properties to enable read-through and 
+        /// write-through behavior so that cache store is invoked on get and/or put operations.
+        /// <para />
+        /// If both <see cref="ReadThrough"/> and <see cref="WriteThrough"/> are <code>false</code>, cache store 
+        /// will be invoked only on <see cref="ICache{TK,TV}.LoadCache"/> calls.
         /// </summary>
         public IFactory<ICacheStore> CacheStoreFactory { get; set; }
 
         /// <summary>
+        /// Gets or sets a value indicating whether read-through should be enabled for cache operations.
+        /// <para />
+        /// When in read-through mode, cache misses that occur due to cache entries not existing 
+        /// as a result of performing a "get" operations will appropriately cause the 
+        /// configured <see cref="ICacheStore"/> (see <see cref="CacheStoreFactory"/>) to be invoked.
+        /// </summary>
+        [DefaultValue(DefaultReadThrough)]
+        public bool ReadThrough { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether write-through should be enabled for cache operations.
+        /// <para />
+        /// When in "write-through" mode, cache updates that occur as a result of performing "put" operations
+        /// will appropriately cause the configured 
+        /// <see cref="ICacheStore"/> (see <see cref="CacheStoreFactory"/>) to be invoked.
+        /// </summary>
+        [DefaultValue(DefaultWriteThrough)]
+        public bool WriteThrough { get; set; }
+
+        /// <summary>
         /// Gets or sets the query entity configuration.
         /// </summary>
         [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]

http://git-wip-us.apache.org/repos/asf/ignite/blob/c638f1e7/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
index 12a4660..8902d3a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -190,6 +190,8 @@
                                     <xs:attribute name="longQueryWarningTimeout" type="xs:string" />
                                     <xs:attribute name="sqlEscapeAll" type="xs:boolean" />
                                     <xs:attribute name="sqlOnheapRowCacheSize" type="xs:int" />
+                                    <xs:attribute name="readThrough" type="xs:boolean" />
+                                    <xs:attribute name="writeThrough" type="xs:boolean" />
                                 </xs:complexType>
                             </xs:element>
                         </xs:sequence>


[08/11] ignite git commit: IGNITE-2796 NPE during rebalancing

Posted by nt...@apache.org.
 IGNITE-2796 NPE during rebalancing


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

Branch: refs/heads/ignite-2791
Commit: 69d1f4b7774769ca7334b2290b492c8e0f0a8ddb
Parents: a1efc5a
Author: Anton Vinogradov <av...@apache.org>
Authored: Wed Mar 16 13:33:26 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Mar 16 13:33:26 2016 +0300

----------------------------------------------------------------------
 .../dht/preloader/GridDhtPartitionDemander.java | 29 ++++++++++++--------
 1 file changed, 17 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/69d1f4b7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 273b603..0cf974f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -841,6 +841,8 @@ public class GridDhtPartitionDemander {
          */
         private void appendPartitions(UUID nodeId, Collection<Integer> parts) {
             synchronized (this) {
+                assert parts != null : "Partitions are null [cache=" + cctx.name() + ", fromNode=" + nodeId + "]";
+
                 remaining.put(nodeId, new T2<>(U.currentTimeMillis(), parts));
             }
         }
@@ -972,22 +974,25 @@ public class GridDhtPartitionDemander {
                     preloadEvent(p, EVT_CACHE_REBALANCE_PART_LOADED,
                         exchFut.discoveryEvent());
 
-                Collection<Integer> parts = remaining.get(nodeId).get2();
+                T2<Long, Collection<Integer>> t = remaining.get(nodeId);
 
-                if (parts != null) {
-                    boolean rmvd = parts.remove(p);
+                assert t != null : "Remaining not found [cache=" + cctx.name() + ", fromNode=" + nodeId +
+                    ", part=" + p + "]";
 
-                    assert rmvd : "Partition already done [cache=" + cctx.name() + ", fromNode=" + nodeId +
-                        ", part=" + p + ", left=" + parts + "]";
+                Collection<Integer> parts = t.get2();
 
-                    if (parts.isEmpty()) {
-                        U.log(log, "Completed " + ((remaining.size() == 1 ? "(final) " : "") +
-                            "rebalancing [cache=" + cctx.name() +
-                            ", fromNode=" + nodeId + ", topology=" + topologyVersion() +
-                            ", time=" + (U.currentTimeMillis() - remaining.get(nodeId).get1()) + " ms]"));
+                boolean rmvd = parts.remove(p);
 
-                        remaining.remove(nodeId);
-                    }
+                assert rmvd : "Partition already done [cache=" + cctx.name() + ", fromNode=" + nodeId +
+                    ", part=" + p + ", left=" + parts + "]";
+
+                if (parts.isEmpty()) {
+                    U.log(log, "Completed " + ((remaining.size() == 1 ? "(final) " : "") +
+                        "rebalancing [cache=" + cctx.name() +
+                        ", fromNode=" + nodeId + ", topology=" + topologyVersion() +
+                        ", time=" + (U.currentTimeMillis() - t.get1()) + " ms]"));
+
+                    remaining.remove(nodeId);
                 }
 
                 checkIsDone();


[10/11] ignite git commit: CacheEntryProcessorCopySelfTest should be added to suite conditionally

Posted by nt...@apache.org.
CacheEntryProcessorCopySelfTest should be added to suite conditionally


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

Branch: refs/heads/ignite-2791
Commit: 3e53f17224c2fccfcce50b347a0dcc6aca543413
Parents: d3420e6
Author: agura <ag...@gridgain.com>
Authored: Thu Mar 17 16:03:20 2016 +0300
Committer: agura <ag...@gridgain.com>
Committed: Thu Mar 17 16:14:01 2016 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3e53f172/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 2613175..9892ff7 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -180,7 +180,7 @@ public class IgniteCacheTestSuite extends TestSuite {
         suite.addTestSuite(IgniteCacheAtomicLocalWithStoreInvokeTest.class);
         suite.addTestSuite(IgniteCacheTxInvokeTest.class);
         suite.addTestSuite(IgniteCacheEntryProcessorCallTest.class);
-        suite.addTestSuite(CacheEntryProcessorCopySelfTest.class);
+        GridTestUtils.addTestIfNeeded(suite, CacheEntryProcessorCopySelfTest.class, ignoredTests);
         suite.addTestSuite(IgniteCacheTxNearEnabledInvokeTest.class);
         suite.addTestSuite(IgniteCacheTxLocalInvokeTest.class);
         suite.addTestSuite(IgniteCrossCacheTxStoreSelfTest.class);
@@ -295,6 +295,7 @@ public class IgniteCacheTestSuite extends TestSuite {
         suite.addTestSuite(CachePutEventListenerErrorSelfTest.class);
 
         suite.addTestSuite(IgniteTxConfigCacheSelfTest.class);
+
         return suite;
     }
 }


[03/11] ignite git commit: IGNITE-2842: IGFS: Optimized create/mkdirs operations with help of entry processors.

Posted by nt...@apache.org.
IGNITE-2842: IGFS: Optimized create/mkdirs operations with help of entry processors.


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

Branch: refs/heads/ignite-2791
Commit: ad6bbd9ad55a5cc1fdf526b5d511465628a8dca5
Parents: 297cbcb
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Mar 16 12:31:37 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Mar 16 12:31:37 2016 +0300

----------------------------------------------------------------------
 .../internal/processors/igfs/IgfsFileInfo.java  |  13 +
 .../processors/igfs/IgfsListingEntry.java       |  15 +-
 .../processors/igfs/IgfsMetaManager.java        | 262 ++++++++++++++++---
 3 files changed, 251 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ad6bbd9a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
index ba484bb..13c54ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
@@ -345,6 +345,19 @@ public final class IgfsFileInfo implements Externalizable {
     }
 
     /**
+     * Temporal hack to change ID before saving entry to cache. Currently we have too much constructors and adding
+     * more will make things even worse. Instead, we use this method until directories and files are split into
+     * separate entities.
+     *
+     * @param id ID.
+     * @deprecated Use only on not-yet-saved entries.
+     */
+    @Deprecated
+    public void id(IgniteUuid id) {
+        this.id = id;
+    }
+
+    /**
      * @return {@code True} if this is a file.
      */
     public boolean isFile() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad6bbd9a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
index 61d9265..4fe0dca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
@@ -34,7 +34,7 @@ public class IgfsListingEntry implements Externalizable {
     /** */
     private static final long serialVersionUID = 0L;
 
-    /** File id. */
+    /** ID. */
     private IgniteUuid id;
 
     /** Directory marker. */
@@ -48,6 +48,8 @@ public class IgfsListingEntry implements Externalizable {
     }
 
     /**
+     * Constructor.
+     *
      * @param fileInfo File info to construct listing entry from.
      */
     public IgfsListingEntry(IgfsFileInfo fileInfo) {
@@ -56,6 +58,17 @@ public class IgfsListingEntry implements Externalizable {
     }
 
     /**
+     * Constructor.
+     *
+     * @param id File ID.
+     * @param dir Directory marker.
+     */
+    public IgfsListingEntry(IgniteUuid id, boolean dir) {
+        this.id = id;
+        this.dir = dir;
+    }
+
+    /**
      * @return Entry file ID.
      */
     public IgniteUuid fileId() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ad6bbd9a/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 df69d49..2a85cf8 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
@@ -1868,13 +1868,11 @@ public class IgfsMetaManager extends IgfsManager {
      * @return New file info.
      * @throws IgniteCheckedException If failed.
      */
-    private IgfsFileInfo invokeAndGet(IgniteUuid id, EntryProcessor<IgniteUuid, IgfsFileInfo, Void> proc)
+    private IgfsFileInfo invokeAndGet(IgniteUuid id, EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo> proc)
         throws IgniteCheckedException {
         validTxState(true);
 
-        id2InfoPrj.invoke(id, proc);
-
-        return getInfo(id);
+        return id2InfoPrj.invoke(id, proc).get();
     }
 
     /**
@@ -3493,7 +3491,7 @@ public class IgfsMetaManager extends IgfsManager {
         private final SortedSet<IgniteUuid> idSet = new TreeSet<IgniteUuid>(PATH_ID_SORTING_COMPARATOR);
 
         /** The middle node properties. */
-        private final Map<String, String> middleProps;
+        private final Map<String, String> props;
 
         /** The leaf node properties. */
         private final Map<String, String> leafProps;
@@ -3557,7 +3555,7 @@ public class IgfsMetaManager extends IgfsManager {
          * Constructor.
          *
          * @param path Path.
-         * @param middleProps Middle properties.
+         * @param props Middle properties.
          * @param leafProps Leaf properties.
          * @param leafDir Whether leaf is directory or file.
          * @param blockSize Block size.
@@ -3565,13 +3563,13 @@ public class IgfsMetaManager extends IgfsManager {
          * @param evictExclude Evict exclude flag.
          * @throws IgniteCheckedException If failed.
          */
-        private DirectoryChainBuilder(IgfsPath path, Map<String,String> middleProps, Map<String,String> leafProps,
+        private DirectoryChainBuilder(IgfsPath path, Map<String,String> props, Map<String,String> leafProps,
             boolean leafDir, int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude)
             throws IgniteCheckedException {
             this.path = path;
             this.components = path.components();
             this.idList = fileIds(path);
-            this.middleProps = middleProps;
+            this.props = props;
             this.leafProps = leafProps;
             this.leafDir = leafDir;
             this.blockSize = blockSize;
@@ -3617,44 +3615,46 @@ public class IgfsMetaManager extends IgfsManager {
          * Does the main portion of job building the renmaining path.
          */
         public final void doBuild() throws IgniteCheckedException {
-            IgfsFileInfo childInfo = null;
+            // Fix current time. It will be used in all created entities.
+            long createTime = System.currentTimeMillis();
 
+            IgfsListingEntry childInfo = null;
             String childName = null;
 
-            IgfsFileInfo newInfo;
-
             IgniteUuid parentId = null;
 
             // This loop creates the missing directory chain from the bottom to the top:
             for (int i = components.size() - 1; i >= existingIdCnt - 1; i--) {
-                // Required entry does not exist.
-                // Create new directory info:
+                IgniteUuid childId = IgniteUuid.randomUuid();
+                boolean childDir;
+
                 if (childName == null) {
                     assert childInfo == null;
 
-                    long t = System.currentTimeMillis();
+                    if (leafDir) {
+                        childDir = true;
 
-                    if (leafDir)
-                        newInfo = new IgfsFileInfo(true, leafProps, t, t);
-                    else
-                        newInfo = new IgfsFileInfo(blockSize, 0L, affKey, createFileLockId(false), evictExclude,
-                            leafProps, t, t);
+                        leafInfo = invokeAndGet(childId, new DirectoryCreateProcessor(createTime, leafProps));
+                    }
+                    else {
+                        childDir = false;
 
-                    leafInfo = newInfo;
+                        leafInfo = invokeAndGet(childId, new FileCreateProcessor(createTime, leafProps, blockSize,
+                            affKey, createFileLockId(false), evictExclude));
+                    }
                 }
                 else {
                     assert childInfo != null;
 
-                    newInfo = new IgfsFileInfo(Collections.singletonMap(childName,
-                        new IgfsListingEntry(childInfo)), middleProps);
+                    childDir = true;
+
+                    id2InfoPrj.invoke(childId, new DirectoryCreateProcessor(createTime, props, childName, childInfo));
 
                     if (parentId == null)
-                        parentId = newInfo.id();
+                        parentId = childId;
                 }
 
-                id2InfoPrj.put(newInfo.id(), newInfo);
-
-                childInfo = newInfo;
+                childInfo = new IgfsListingEntry(childId, childDir);
 
                 childName = components.get(i);
             }
@@ -3665,7 +3665,7 @@ public class IgfsMetaManager extends IgfsManager {
             leafParentId = parentId;
 
             // Now link the newly created directory chain to the lowermost existing parent:
-            id2InfoPrj.invoke(lowermostExistingId, new ListingAdd(childName, new IgfsListingEntry(childInfo)));
+            id2InfoPrj.invoke(lowermostExistingId, new ListingAdd(childName, childInfo));
         }
 
         /**
@@ -3692,9 +3692,193 @@ public class IgfsMetaManager extends IgfsManager {
     }
 
     /**
+     * File create processor.
+     */
+    private static class FileCreateProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+        Externalizable {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** Create time. */
+        private long createTime;
+
+        /** Properties. */
+        private Map<String, String> props;
+
+        /** Block size. */
+        private int blockSize;
+
+        /** Affintiy key. */
+        private IgniteUuid affKey;
+
+        /** Lcok ID. */
+        private IgniteUuid lockId;
+
+        /** Evict exclude flag. */
+        private boolean evictExclude;
+
+        /**
+         * Constructor.
+         */
+        public FileCreateProcessor() {
+            // No-op.
+        }
+
+        /**
+         * Constructor.
+         *
+         * @param createTime Create time.
+         * @param props Properties.
+         * @param blockSize Block size.
+         * @param affKey Affinity key.
+         * @param lockId Lock ID.
+         * @param evictExclude Evict exclude flag.
+         */
+        public FileCreateProcessor(long createTime, Map<String, String> props, int blockSize,
+            @Nullable IgniteUuid affKey, IgniteUuid lockId, boolean evictExclude) {
+            this.createTime = createTime;
+            this.props = props;
+            this.blockSize = blockSize;
+            this.affKey = affKey;
+            this.lockId = lockId;
+            this.evictExclude = evictExclude;
+        }
+
+        /** {@inheritDoc} */
+        @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+            throws EntryProcessorException {
+            IgfsFileInfo info = new IgfsFileInfo(blockSize, 0L, affKey, lockId, evictExclude, props,
+                createTime, createTime);
+
+            info.id(entry.getKey());
+
+            entry.setValue(info);
+
+            return info;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            out.writeLong(createTime);
+            U.writeStringMap(out, props);
+            out.writeInt(blockSize);
+            out.writeObject(affKey);
+            out.writeObject(lockId);
+            out.writeBoolean(evictExclude);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            createTime = in.readLong();
+            props = U.readStringMap(in);
+            blockSize = in.readInt();
+            affKey = (IgniteUuid)in.readObject();
+            lockId = (IgniteUuid)in.readObject();
+            evictExclude = in.readBoolean();
+        }
+    }
+
+    /**
+     * Directory create processor.
+     */
+    private static class DirectoryCreateProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+        Externalizable {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** Create time. */
+        private long createTime;
+
+        /** Properties. */
+        private Map<String, String> props;
+
+        /** Child name (optional). */
+        private String childName;
+
+        /** Child entry (optional. */
+        private IgfsListingEntry childEntry;
+
+        /**
+         * Constructor.
+         */
+        public DirectoryCreateProcessor() {
+            // No-op.
+        }
+
+        /**
+         * Constructor.
+         *
+         * @param createTime Create time.
+         * @param props Properties.
+         */
+        public DirectoryCreateProcessor(long createTime, Map<String, String> props) {
+            this(createTime, props, null, null);
+        }
+
+        /**
+         * Constructor.
+         *
+         * @param createTime Create time.
+         * @param props Properties.
+         * @param childName Child name.
+         * @param childEntry Child entry.
+         */
+        public DirectoryCreateProcessor(long createTime, Map<String, String> props, String childName,
+            IgfsListingEntry childEntry) {
+            this.createTime = createTime;
+            this.props = props;
+            this.childName = childName;
+            this.childEntry = childEntry;
+        }
+
+        /** {@inheritDoc} */
+        @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+            throws EntryProcessorException {
+
+            IgfsFileInfo info = new IgfsFileInfo(true, props, createTime, createTime);
+
+            if (childName != null)
+                info = new IgfsFileInfo(Collections.singletonMap(childName, childEntry), info);
+
+            info.id(entry.getKey());
+
+            entry.setValue(info);
+
+            return info;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            out.writeLong(createTime);
+            U.writeStringMap(out, props);
+
+            if (childName != null) {
+                out.writeBoolean(true);
+
+                U.writeString(out, childName);
+                out.writeObject(childEntry);
+            }
+            else
+                out.writeBoolean(false);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            createTime = in.readLong();
+            props = U.readStringMap(in);
+
+            if (in.readBoolean()) {
+                childName = U.readString(in);
+                childEntry = (IgfsListingEntry)in.readObject();
+            }
+        }
+    }
+
+    /**
      * File lock entry processor.
      */
-    private static class FileLockProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>, Externalizable {
+    private static class FileLockProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+        Externalizable {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -3718,13 +3902,15 @@ public class IgfsMetaManager extends IgfsManager {
         }
 
         /** {@inheritDoc} */
-        @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+        @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
             throws EntryProcessorException {
-            IgfsFileInfo old = entry.getValue();
+            IgfsFileInfo oldInfo = entry.getValue();
 
-            entry.setValue(new IgfsFileInfo(old, lockId, old.modificationTime()));
+            IgfsFileInfo newInfo =  new IgfsFileInfo(oldInfo, lockId, oldInfo.modificationTime());
 
-            return null;
+            entry.setValue(newInfo);
+
+            return newInfo;
         }
 
         /** {@inheritDoc} */
@@ -3789,7 +3975,7 @@ public class IgfsMetaManager extends IgfsManager {
     /**
      * File reserve space entry processor.
      */
-    private static class FileReserveSpaceProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+    private static class FileReserveSpaceProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
         Externalizable {
         /** */
         private static final long serialVersionUID = 0L;
@@ -3819,7 +4005,7 @@ public class IgfsMetaManager extends IgfsManager {
         }
 
         /** {@inheritDoc} */
-        @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+        @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
             throws EntryProcessorException {
             IgfsFileInfo oldInfo = entry.getValue();
 
@@ -3833,7 +4019,7 @@ public class IgfsMetaManager extends IgfsManager {
 
             entry.setValue(newInfo);
 
-            return null;
+            return newInfo;
         }
 
         /** {@inheritDoc} */
@@ -3852,7 +4038,7 @@ public class IgfsMetaManager extends IgfsManager {
     /**
      * Update properties processor.
      */
-    private static class UpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+    private static class UpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
         Externalizable {
         /** */
         private static final long serialVersionUID = 0L;
@@ -3877,7 +4063,7 @@ public class IgfsMetaManager extends IgfsManager {
         }
 
         /** {@inheritDoc} */
-        @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+        @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
             throws EntryProcessorException {
             IgfsFileInfo oldInfo = entry.getValue();
 
@@ -3898,7 +4084,7 @@ public class IgfsMetaManager extends IgfsManager {
 
             entry.setValue(newInfo);
 
-            return null;
+            return newInfo;
         }
 
         /** {@inheritDoc} */


[07/11] ignite git commit: IGNITE-2846: IGFS: Reworked IgfsMetaManager.updateInfo() operation to use "invoke" instead of "put".

Posted by nt...@apache.org.
IGNITE-2846: IGFS: Reworked IgfsMetaManager.updateInfo() operation to use "invoke" instead of "put".


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

Branch: refs/heads/ignite-2791
Commit: a1efc5a06b15acffa40ad0a9d3352206061b42f6
Parents: dfe5ea8
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Mar 16 13:22:07 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Mar 16 13:22:07 2016 +0300

----------------------------------------------------------------------
 .../internal/processors/igfs/IgfsFileMap.java   |   9 +-
 .../igfs/IgfsFragmentizerManager.java           | 166 ++++++++++++++-----
 .../igfs/IgfsInvalidRangeException.java         |   4 +-
 .../processors/igfs/IgfsMetaManager.java        |  67 ++++----
 .../igfs/IgfsMetaManagerSelfTest.java           |  11 --
 5 files changed, 161 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a1efc5a0/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java
index 2c0358b..9ea69ea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java
@@ -128,12 +128,11 @@ public class IgfsFileMap implements Externalizable {
      *
      * @param range Range to update status.
      * @param status New range status.
-     * @throws IgniteCheckedException If range was not found.
      */
-    public void updateRangeStatus(IgfsFileAffinityRange range, int status) throws IgniteCheckedException {
+    public void updateRangeStatus(IgfsFileAffinityRange range, int status) {
         if (ranges == null)
             throw new IgfsInvalidRangeException("Failed to update range status (file map is empty) " +
-                "[range=" + range + ", ranges=" + ranges + ']');
+                "[range=" + range + ", ranges=null]");
 
         assert !ranges.isEmpty();
 
@@ -190,10 +189,10 @@ public class IgfsFileMap implements Externalizable {
      *
      * @param range Range to delete.
      */
-    public void deleteRange(IgfsFileAffinityRange range) throws IgniteCheckedException {
+    public void deleteRange(IgfsFileAffinityRange range) {
         if (ranges == null)
             throw new IgfsInvalidRangeException("Failed to remove range (file map is empty) " +
-                "[range=" + range + ", ranges=" + ranges + ']');
+                "[range=" + range + ", ranges=null]");
 
         assert !ranges.isEmpty();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1efc5a0/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
index 899730d..7cc5cb6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
@@ -17,6 +17,10 @@
 
 package org.apache.ignite.internal.processors.igfs;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -41,19 +45,22 @@ import org.apache.ignite.internal.managers.communication.GridMessageListener;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
 import org.apache.ignite.internal.util.GridConcurrentHashSet;
 import org.apache.ignite.internal.util.GridSpinReadWriteLock;
-import org.apache.ignite.internal.util.typedef.CX1;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.P1;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.LT;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.util.worker.GridWorker;
 import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.thread.IgniteThread;
 import org.jetbrains.annotations.Nullable;
 
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
 import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
@@ -286,7 +293,8 @@ public class IgfsFragmentizerManager extends IgfsManager {
                 switch (range.status()) {
                     case RANGE_STATUS_INITIAL: {
                         // Mark range as moving.
-                        updated = igfsCtx.meta().updateInfo(fileId, updateRange(range, RANGE_STATUS_MOVING));
+                        updated = igfsCtx.meta().updateInfo(
+                            fileId, new RangeUpdateProcessor(range, RANGE_STATUS_MOVING));
 
                         if (updated == null) {
                             igfsCtx.data().cleanBlocks(fileInfo, range, true);
@@ -302,7 +310,8 @@ public class IgfsFragmentizerManager extends IgfsManager {
                         igfsCtx.data().spreadBlocks(fileInfo, range);
 
                         // Mark range as moved.
-                        updated = igfsCtx.meta().updateInfo(fileId, updateRange(range, RANGE_STATUS_MOVED));
+                        updated = igfsCtx.meta().updateInfo(
+                            fileId, new RangeUpdateProcessor(range, RANGE_STATUS_MOVED));
 
                         if (updated == null) {
                             igfsCtx.data().cleanBlocks(fileInfo, range, true);
@@ -318,7 +327,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
                         igfsCtx.data().cleanBlocks(fileInfo, range, false);
 
                         // Remove range from map.
-                        updated = igfsCtx.meta().updateInfo(fileId, deleteRange(range));
+                        updated = igfsCtx.meta().updateInfo(fileId, new RangeDeleteProcessor(range));
 
                         if (updated == null)
                             igfsCtx.data().cleanBlocks(fileInfo, range, true);
@@ -334,57 +343,132 @@ public class IgfsFragmentizerManager extends IgfsManager {
     }
 
     /**
-     * Creates update info closure that will mark given range as moving.
-     *
-     * @param range Range to mark as moving.
-     * @param status Status.
-     * @return Update closure.
+     * Update range processor.
      */
-    private IgniteClosure<IgfsFileInfo, IgfsFileInfo> updateRange(final IgfsFileAffinityRange range,
-        final int status) {
-        return new CX1<IgfsFileInfo, IgfsFileInfo>() {
-            @Override public IgfsFileInfo applyx(IgfsFileInfo info) throws IgniteCheckedException {
-                IgfsFileMap map = new IgfsFileMap(info.fileMap());
+    private static class RangeUpdateProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+        Externalizable {
+        /** */
+        private static final long serialVersionUID = 0L;
 
-                map.updateRangeStatus(range, status);
+        /** Range. */
+        private IgfsFileAffinityRange range;
 
-                if (log.isDebugEnabled())
-                    log.debug("Updated file map for range [fileId=" + info.id() + ", range=" + range +
-                        ", status=" + status + ", oldMap=" + info.fileMap() + ", newMap=" + map + ']');
+        /** Status. */
+        private int status;
 
-                IgfsFileInfo updated = new IgfsFileInfo(info, info.length());
+        /**
+         * Constructor.
+         */
+        public RangeUpdateProcessor() {
+            // No-op.
+        }
 
-                updated.fileMap(map);
+        /**
+         * Constructor.
+         *
+         * @param range Range.
+         * @param status Status.
+         */
+        public RangeUpdateProcessor(IgfsFileAffinityRange range, int status) {
+            this.range = range;
+            this.status = status;
+        }
 
-                return updated;
-            }
-        };
+        /** {@inheritDoc} */
+        @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+            throws EntryProcessorException {
+            IgfsFileInfo oldInfo = entry.getValue();
+
+            IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
+
+            newMap.updateRangeStatus(range, status);
+
+            IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, oldInfo.length());
+
+            newInfo.fileMap(newMap);
+
+            entry.setValue(newInfo);
+
+            return newInfo;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            out.writeObject(range);
+            out.writeInt(status);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            range = (IgfsFileAffinityRange)in.readObject();
+            status = in.readInt();
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(RangeUpdateProcessor.class, this);
+        }
     }
 
     /**
-     * Creates update info closure that will mark given range as moving.
-     *
-     * @param range Range to mark as moving.
-     * @return Update closure.
+     * Delete range processor.
      */
-    private IgniteClosure<IgfsFileInfo, IgfsFileInfo> deleteRange(final IgfsFileAffinityRange range) {
-        return new CX1<IgfsFileInfo, IgfsFileInfo>() {
-            @Override public IgfsFileInfo applyx(IgfsFileInfo info) throws IgniteCheckedException {
-                IgfsFileMap map = new IgfsFileMap(info.fileMap());
+    private static class RangeDeleteProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+        Externalizable {
+        /** */
+        private static final long serialVersionUID = 0L;
 
-                map.deleteRange(range);
+        /** Range. */
+        private IgfsFileAffinityRange range;
 
-                if (log.isDebugEnabled())
-                    log.debug("Deleted range from file map [fileId=" + info.id() + ", range=" + range +
-                        ", oldMap=" + info.fileMap() + ", newMap=" + map + ']');
+        /**
+         * Constructor.
+         */
+        public RangeDeleteProcessor() {
+            // No-op.
+        }
 
-                IgfsFileInfo updated = new IgfsFileInfo(info, info.length());
+        /**
+         * Constructor.
+         *
+         * @param range Range.
+         */
+        public RangeDeleteProcessor(IgfsFileAffinityRange range) {
+            this.range = range;
+        }
 
-                updated.fileMap(map);
+        /** {@inheritDoc} */
+        @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+            throws EntryProcessorException {
+            IgfsFileInfo oldInfo = entry.getValue();
 
-                return updated;
-            }
-        };
+            IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
+
+            newMap.deleteRange(range);
+
+            IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, oldInfo.length());
+
+            newInfo.fileMap(newMap);
+
+            entry.setValue(newInfo);
+
+            return newInfo;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            out.writeObject(range);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            range = (IgfsFileAffinityRange)in.readObject();
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(RangeDeleteProcessor.class, this);
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1efc5a0/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInvalidRangeException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInvalidRangeException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInvalidRangeException.java
index cd93278..d6ad2b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInvalidRangeException.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInvalidRangeException.java
@@ -17,13 +17,13 @@
 
 package org.apache.ignite.internal.processors.igfs;
 
-import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
 
 /**
  * Internal exception thrown when attempted to update range that is no longer present
  * in file affinity map.
  */
-public class IgfsInvalidRangeException extends IgniteCheckedException {
+public class IgfsInvalidRangeException extends IgniteException {
     /** */
     private static final long serialVersionUID = 0L;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1efc5a0/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 2a85cf8..b4774f2 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
@@ -1257,7 +1257,7 @@ public class IgfsMetaManager extends IgfsManager {
 
                 // Remove listing entries from root.
                 for (Map.Entry<String, IgfsListingEntry> entry : transferListing.entrySet())
-                    id2InfoPrj.invoke(IgfsUtils.ROOT_ID, new ListingRemove(entry.getKey(), entry.getValue().fileId()));
+                    id2InfoPrj.invoke(IgfsUtils.ROOT_ID, new ListingRemoveProcessor(entry.getKey(), entry.getValue().fileId()));
 
                 resId = newInfo.id();
             }
@@ -1408,7 +1408,7 @@ public class IgfsMetaManager extends IgfsManager {
                         IgfsListingEntry childEntry = parentInfo.listing().get(name);
 
                         if (childEntry != null)
-                            id2InfoPrj.invoke(parentId, new ListingRemove(name, id));
+                            id2InfoPrj.invoke(parentId, new ListingRemoveProcessor(name, id));
 
                         id2InfoPrj.remove(id);
 
@@ -1584,20 +1584,20 @@ public class IgfsMetaManager extends IgfsManager {
      * Update file info in cache.
      *
      * @param fileId File ID to update information for.
-     * @param c Closure to update file's info inside transaction.
+     * @param proc Entry processor to invoke.
      * @return Updated file info or {@code null} if such file ID not found.
      * @throws IgniteCheckedException If failed.
      */
-    @Nullable public IgfsFileInfo updateInfo(IgniteUuid fileId, IgniteClosure<IgfsFileInfo, IgfsFileInfo> c)
-        throws IgniteCheckedException {
+    @Nullable public IgfsFileInfo updateInfo(IgniteUuid fileId,
+        EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo> proc) throws IgniteCheckedException {
         validTxState(false);
         assert fileId != null;
-        assert c != null;
+        assert proc != null;
 
         if (busyLock.enterBusy()) {
             try {
                 if (log.isDebugEnabled())
-                    log.debug("Update file info [fileId=" + fileId + ", c=" + c + ']');
+                    log.debug("Update file info [fileId=" + fileId + ", proc=" + proc + ']');
 
                 IgniteInternalTx tx = startTx();
 
@@ -1608,27 +1608,21 @@ public class IgfsMetaManager extends IgfsManager {
                     if (oldInfo == null)
                         return null; // File not found.
 
-                    IgfsFileInfo newInfo = c.apply(oldInfo);
+                    IgfsFileInfo newInfo = invokeAndGet(fileId, proc);
 
                     if (newInfo == null)
                         throw fsException("Failed to update file info with null value" +
-                            " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", c=" + c + ']');
+                            " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", proc=" + proc + ']');
 
                     if (!oldInfo.id().equals(newInfo.id()))
                         throw fsException("Failed to update file info (file IDs differ)" +
-                            " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", c=" + c + ']');
+                            " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", proc=" + proc + ']');
 
                     if (oldInfo.isDirectory() != newInfo.isDirectory())
                         throw fsException("Failed to update file info (file types differ)" +
-                            " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", c=" + c + ']');
-
-                    boolean b = id2InfoPrj.replace(fileId, oldInfo, newInfo);
-
-                    assert b : "Inconsistent transaction state [oldInfo=" + oldInfo + ", newInfo=" + newInfo +
-                        ", c=" + c + ']';
+                            " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", proc=" + proc + ']');
 
-                    if (tx != null)
-                        tx.commit();
+                    tx.commit();
 
                     return newInfo;
                 }
@@ -1636,8 +1630,7 @@ public class IgfsMetaManager extends IgfsManager {
                     throw U.cast(e);
                 }
                 finally {
-                    if (tx != null)
-                        tx.close();
+                    tx.close();
                 }
             }
             finally {
@@ -1814,7 +1807,7 @@ public class IgfsMetaManager extends IgfsManager {
             throw fsException("Failed to create new metadata entry due to ID conflict: " + info.id());
 
         if (parentId != null)
-            id2InfoPrj.invoke(parentId, new ListingAdd(name, new IgfsListingEntry(info)));
+            id2InfoPrj.invoke(parentId, new ListingAddProcessor(name, new IgfsListingEntry(info)));
     }
 
     /**
@@ -1831,8 +1824,8 @@ public class IgfsMetaManager extends IgfsManager {
         IgniteUuid destId, String destName) throws IgniteCheckedException {
         validTxState(true);
 
-        id2InfoPrj.invoke(srcId, new ListingRemove(srcName, entry.fileId()));
-        id2InfoPrj.invoke(destId, new ListingAdd(destName, entry));
+        id2InfoPrj.invoke(srcId, new ListingRemoveProcessor(srcName, entry.fileId()));
+        id2InfoPrj.invoke(destId, new ListingAddProcessor(destName, entry));
     }
 
     /**
@@ -1857,7 +1850,7 @@ public class IgfsMetaManager extends IgfsManager {
     private void invokeUpdatePath(IgniteUuid id, IgfsPath path) throws IgniteCheckedException {
         validTxState(true);
 
-        id2InfoPrj.invoke(id, new UpdatePath(path));
+        id2InfoPrj.invoke(id, new UpdatePathProcessor(path));
     }
 
     /**
@@ -2009,7 +2002,7 @@ public class IgfsMetaManager extends IgfsManager {
 
                                 id2InfoPrj.remove(oldId); // Remove the old one.
                                 id2InfoPrj.invoke(parentInfo.id(),
-                                    new ListingRemove(path.name(), parentInfo.listing().get(path.name()).fileId()));
+                                    new ListingRemoveProcessor(path.name(), parentInfo.listing().get(path.name()).fileId()));
 
                                 createNewEntry(newInfo, parentInfo.id(), path.name()); // Put new one.
 
@@ -3101,7 +3094,7 @@ public class IgfsMetaManager extends IgfsManager {
      * Remove entry from directory listing.
      */
     @GridInternal
-    private static final class ListingRemove implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+    private static final class ListingRemoveProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
         Externalizable {
         /** */
         private static final long serialVersionUID = 0L;
@@ -3115,7 +3108,7 @@ public class IgfsMetaManager extends IgfsManager {
         /**
          * Default constructor.
          */
-        public ListingRemove() {
+        public ListingRemoveProcessor() {
             // No-op.
         }
 
@@ -3125,7 +3118,7 @@ public class IgfsMetaManager extends IgfsManager {
          * @param fileName File name.
          * @param fileId File ID.
          */
-        public ListingRemove(String fileName, IgniteUuid fileId) {
+        public ListingRemoveProcessor(String fileName, IgniteUuid fileId) {
             this.fileName = fileName;
             this.fileId = fileId;
         }
@@ -3173,7 +3166,7 @@ public class IgfsMetaManager extends IgfsManager {
      * Update directory listing closure.
      */
     @GridInternal
-    private static final class ListingAdd implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+    private static final class ListingAddProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
         Externalizable {
         /** */
         private static final long serialVersionUID = 0L;
@@ -3190,7 +3183,7 @@ public class IgfsMetaManager extends IgfsManager {
          * @param fileName File name to add into parent listing.
          * @param entry Listing entry to add or remove.
          */
-        private ListingAdd(String fileName, IgfsListingEntry entry) {
+        private ListingAddProcessor(String fileName, IgfsListingEntry entry) {
             assert fileName != null;
             assert entry != null;
 
@@ -3202,7 +3195,7 @@ public class IgfsMetaManager extends IgfsManager {
          * Empty constructor required for {@link Externalizable}.
          *
          */
-        public ListingAdd() {
+        public ListingAddProcessor() {
             // No-op.
         }
 
@@ -3242,7 +3235,7 @@ public class IgfsMetaManager extends IgfsManager {
 
         /** {@inheritDoc} */
         @Override public String toString() {
-            return S.toString(ListingAdd.class, this);
+            return S.toString(ListingAddProcessor.class, this);
         }
     }
 
@@ -3250,7 +3243,7 @@ public class IgfsMetaManager extends IgfsManager {
      * Update path closure.
      */
     @GridInternal
-    private static final class UpdatePath implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+    private static final class UpdatePathProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
         Externalizable {
         /** */
         private static final long serialVersionUID = 0L;
@@ -3261,14 +3254,14 @@ public class IgfsMetaManager extends IgfsManager {
         /**
          * @param path Path.
          */
-        private UpdatePath(IgfsPath path) {
+        private UpdatePathProcessor(IgfsPath path) {
             this.path = path;
         }
 
         /**
          * Default constructor (required by Externalizable).
          */
-        public UpdatePath() {
+        public UpdatePathProcessor() {
             // No-op.
         }
 
@@ -3293,7 +3286,7 @@ public class IgfsMetaManager extends IgfsManager {
 
         /** {@inheritDoc} */
         @Override public String toString() {
-            return S.toString(UpdatePath.class, this);
+            return S.toString(UpdatePathProcessor.class, this);
         }
     }
 
@@ -3665,7 +3658,7 @@ public class IgfsMetaManager extends IgfsManager {
             leafParentId = parentId;
 
             // Now link the newly created directory chain to the lowermost existing parent:
-            id2InfoPrj.invoke(lowermostExistingId, new ListingAdd(childName, childInfo));
+            id2InfoPrj.invoke(lowermostExistingId, new ListingAddProcessor(childName, childInfo));
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1efc5a0/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
index 72a2bee..19a91ad 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
@@ -352,17 +352,6 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
 
         assertEmpty(mgr.directoryListing(b.id()));
 
-        // Validate last actual data received from 'remove' operation.
-        IgfsFileInfo newF2 = mgr.updateInfo(f2.id(), new C1<IgfsFileInfo, IgfsFileInfo>() {
-            @Override public IgfsFileInfo apply(IgfsFileInfo e) {
-                return new IgfsFileInfo(e, e.length() + 20);
-            }
-        });
-
-        assertNotNull(newF2);
-        assertEquals(f2.id(), newF2.id());
-        assertNotSame(f2, newF2);
-
         del = mgr.softDelete(path("/a/f2"), false);
         assertEquals(f2.id(), del);
 


[06/11] ignite git commit: Merge remote-tracking branch 'origin/master'

Posted by nt...@apache.org.
Merge remote-tracking branch 'origin/master'


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

Branch: refs/heads/ignite-2791
Commit: dfe5ea80e7d24df78bdb85c80fd05bb7391391b4
Parents: c638f1e 843b286
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Mar 16 13:11:18 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Mar 16 13:11:18 2016 +0300

----------------------------------------------------------------------
 .../internal/websession/IgniteWebSessionSelfTestSuite.java      | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------



[04/11] ignite git commit: IGNITE-2765 WebSessionFilter doesn't survive client reconnect Test fixes.

Posted by nt...@apache.org.
IGNITE-2765 WebSessionFilter doesn't survive client reconnect
Test fixes.


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

Branch: refs/heads/ignite-2791
Commit: 843b2869d5b5663fd000aa0ac6320de87d776fb3
Parents: ad6bbd9
Author: Anton Vinogradov <av...@apache.org>
Authored: Wed Mar 16 13:07:50 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Mar 16 13:09:05 2016 +0300

----------------------------------------------------------------------
 .../internal/websession/IgniteWebSessionSelfTestSuite.java      | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/843b2869/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java b/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java
index c69b019..2e47262 100644
--- a/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java
+++ b/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java
@@ -62,6 +62,11 @@ public class IgniteWebSessionSelfTestSuite extends TestSuite {
         @Override public void testInvalidatedSession() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-810");
         }
+
+        /** {@inheritDoc} */
+        @Override public void testClientReconnectRequest() throws Exception {
+            fail("https://issues.apache.org/jira/browse/IGNITE-810");
+        }
     }
 
     /**


[11/11] ignite git commit: Merge branch 'master' into ignite-2791

Posted by nt...@apache.org.
Merge branch 'master' into ignite-2791


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

Branch: refs/heads/ignite-2791
Commit: fa97a07c00e94e9f2a2f6450dd96cda9e2db783a
Parents: 1f11677 3e53f17
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Thu Mar 17 18:31:43 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Thu Mar 17 18:31:43 2016 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |   2 +-
 .../processors/cache/GridCacheAdapter.java      |  10 +-
 .../processors/cache/GridCacheUtils.java        |  14 +
 .../dht/preloader/GridDhtPartitionDemander.java |  29 +-
 .../transactions/IgniteTransactionsImpl.java    |   9 +-
 .../internal/processors/igfs/IgfsFileInfo.java  |  13 +
 .../internal/processors/igfs/IgfsFileMap.java   |   9 +-
 .../igfs/IgfsFragmentizerManager.java           | 166 +++-
 .../internal/processors/igfs/IgfsImpl.java      |   4 +-
 .../igfs/IgfsInvalidRangeException.java         |   4 +-
 .../processors/igfs/IgfsListingEntry.java       |  15 +-
 .../processors/igfs/IgfsMetaManager.java        | 836 ++++++++++++-------
 .../utils/PlatformConfigurationUtils.java       |   4 +
 .../ComputeJobCancelWithServiceSelfTest.java    | 154 ++++
 .../cache/IgniteTxConfigCacheSelfTest.java      | 249 ++++++
 .../igfs/IgfsMetaManagerSelfTest.java           |  34 +-
 .../ignite/testsuites/IgniteCacheTestSuite.java |   5 +-
 .../testsuites/IgniteKernalSelfTestSuite.java   |   2 +
 .../hadoop/cache/HadoopTxConfigCacheTest.java   |  42 +
 .../testsuites/IgniteHadoopTestSuite.java       |   3 +
 .../Apache.Ignite.Core.Tests.csproj             |   1 +
 .../Cache/CacheConfigurationTest.cs             |   5 +-
 .../Cache/Store/CacheStoreTest.cs               |   5 +-
 .../Cache/Store/CacheStoreTestCodeConfig.cs     | 106 +++
 .../IgniteConfigurationSerializerTest.cs        |   4 +-
 .../Cache/Configuration/CacheConfiguration.cs   |  36 +
 .../IgniteConfigurationSection.xsd              |   2 +
 .../IgniteWebSessionSelfTestSuite.java          |   5 +
 28 files changed, 1340 insertions(+), 428 deletions(-)
----------------------------------------------------------------------