You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/03/15 21:11:41 UTC
[3/9] ignite git commit: WIP.
WIP.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/57429a94
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/57429a94
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/57429a94
Branch: refs/heads/ignite-2817
Commit: 57429a9412734a52c4bebcce02fb719ef20da68e
Parents: 13e2c1e
Author: thatcoach <pp...@list.ru>
Authored: Tue Mar 15 22:25:38 2016 +0300
Committer: thatcoach <pp...@list.ru>
Committed: Tue Mar 15 22:25:38 2016 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsMetaManager.java | 137 ++++++++++---------
1 file changed, 76 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/57429a94/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 644f617..1a08a9b 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
@@ -1699,7 +1699,7 @@ public class IgfsMetaManager extends IgfsManager {
while (true) {
if (busyLock.enterBusy()) {
try {
- b = new DirectoryChainBuilder(path, props, props);
+ b = new DirectoryChainBuilder(path, props);
// Start TX.
IgniteInternalTx tx = startTx();
@@ -3341,15 +3341,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();
@@ -3506,7 +3498,7 @@ public class IgfsMetaManager extends IgfsManager {
protected final List<IgniteUuid> idList;
/** The set of ids. */
- protected final SortedSet<IgniteUuid> idSet;
+ protected final SortedSet<IgniteUuid> idSet = new TreeSet<IgniteUuid>(PATH_ID_SORTING_COMPARATOR);
/** The middle node properties. */
protected final Map<String, String> middleProps;
@@ -3529,22 +3521,71 @@ public class IgfsMetaManager extends IgfsManager {
/** The number of existing ids. */
protected final int existingIdCnt;
+ /** Whether laef is directory. */
+ private final boolean leafDir;
+
+ /** Block size. */
+ private int blockSize;
+
+ /** Affinity key. */
+ private IgniteUuid affKey;
+
+ /** Evict exclude flag. */
+ private 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();
@@ -3581,33 +3622,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 +3629,7 @@ 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 +3639,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 +3672,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 +3689,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);