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/18 15:45:57 UTC
[1/3] ignite git commit: IGNITE-2813: IGFS: Optimized metadata values
splitting file and directory into separate classes.
Repository: ignite
Updated Branches:
refs/heads/master 4af5316bf -> 4794f87b5
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
index 06ae40b..013bb18 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
@@ -17,12 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.nio.ByteBuffer;
-import java.security.SecureRandom;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.concurrent.Callable;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -44,6 +38,13 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.jetbrains.annotations.Nullable;
+import java.nio.ByteBuffer;
+import java.security.SecureRandom;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.Callable;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -168,8 +169,8 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
- IgfsFileInfo info = new IgfsFileInfo(200, 0L, null, IgfsUtils.DELETE_LOCK_ID,
- false, null, t, t);
+ IgfsEntryInfo info = IgfsUtils.createFile(IgniteUuid.randomUuid(), 200, 0L, null,
+ IgfsUtils.DELETE_LOCK_ID, false, null, t, t);
assertNull(mgr.dataBlock(info, path, 0, null).get());
@@ -181,11 +182,11 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
expectsStoreFail(info, data, "Not enough space reserved to store data");
- info = new IgfsFileInfo(info, info.length() + data.length - 3);
+ info = info.length(info.length() + data.length - 3);
expectsStoreFail(info, data, "Not enough space reserved to store data");
- info = new IgfsFileInfo(info, info.length() + 3);
+ info = info.length(info.length() + 3);
IgfsFileAffinityRange range = new IgfsFileAffinityRange();
@@ -253,8 +254,8 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 0L, null, IgfsUtils.DELETE_LOCK_ID,
- false, null, t, t);
+ IgfsEntryInfo info = IgfsUtils.createFile(IgniteUuid.randomUuid(), blockSize, 0L, null,
+ IgfsUtils.DELETE_LOCK_ID, false, null, t, t);
assertNull(mgr.dataBlock(info, path, 0, null).get());
@@ -266,7 +267,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
rnd.nextBytes(remainder);
- info = new IgfsFileInfo(info, info.length() + data.length + remainder.length);
+ info = info.length(info.length() + data.length + remainder.length);
IgniteInternalFuture<Boolean> fut = mgr.writeStart(info);
@@ -279,7 +280,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
byte[] remainder2 = new byte[blockSize / 2];
- info = new IgfsFileInfo(info, info.length() + remainder2.length);
+ info = info.length(info.length() + remainder2.length);
byte[] left2 = mgr.storeDataBlocks(info, info.length(), left, left.length, ByteBuffer.wrap(remainder2),
false, range, null);
@@ -344,9 +345,8 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
- IgfsFileInfo info =
- new IgfsFileInfo(blockSize, 0L, null, IgfsUtils.DELETE_LOCK_ID,
- false, null, t, t);
+ IgfsEntryInfo info = IgfsUtils.createFile(IgniteUuid.randomUuid(), blockSize, 0L, null,
+ IgfsUtils.DELETE_LOCK_ID, false, null, t, t);
IgfsFileAffinityRange range = new IgfsFileAffinityRange();
@@ -356,7 +356,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
byte[] data = new byte[chunkSize];
- info = new IgfsFileInfo(info, info.length() + data.length * writesCnt);
+ info = info.length(info.length() + data.length * writesCnt);
IgniteInternalFuture<Boolean> fut = mgr.writeStart(info);
@@ -416,7 +416,8 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
//IgfsFileInfo info = new IgfsFileInfo(blockSize, 0);
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 1024 * 1024, null, null, false, null, t, t);
+ IgfsEntryInfo info = IgfsUtils.createFile(IgniteUuid.randomUuid(), blockSize, 1024 * 1024, null, null, false,
+ null, t, t);
for (int pos = 0; pos < 5 * grpSize; pos++) {
assertEquals("Expects no affinity for zero length.", Collections.<IgfsBlockLocation>emptyList(),
@@ -466,7 +467,8 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 1024 * 1024, null, null, false, null, t, t);
+ IgfsEntryInfo info = IgfsUtils.createFile(IgniteUuid.randomUuid(), blockSize, 1024 * 1024, null, null, false,
+ null, t, t);
Collection<IgfsBlockLocation> affinity = mgr.affinity(info, 0, info.length());
@@ -499,7 +501,8 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 1024 * 1024, null, null, false, null, t, t);
+ IgfsEntryInfo info = IgfsUtils.createFile(IgniteUuid.randomUuid(), blockSize, 1024 * 1024, null, null, false,
+ null, t, t);
IgniteUuid affKey = IgniteUuid.randomUuid();
@@ -508,7 +511,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
map.addRange(new IgfsFileAffinityRange(3 * BLOCK_SIZE, 5 * BLOCK_SIZE - 1, affKey));
map.addRange(new IgfsFileAffinityRange(13 * BLOCK_SIZE, 17 * BLOCK_SIZE - 1, affKey));
- info.fileMap(map);
+ info = info.fileMap(map);
Collection<IgfsBlockLocation> affinity = mgr.affinity(info, 0, info.length());
@@ -542,7 +545,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
* @param info File info.
* @param affinity Affinity block locations to check.
*/
- private void checkAffinity(int blockSize, IgfsFileInfo info, Iterable<IgfsBlockLocation> affinity) {
+ private void checkAffinity(int blockSize, IgfsEntryInfo info, Iterable<IgfsBlockLocation> affinity) {
for (IgfsBlockLocation loc : affinity) {
info("Going to check IGFS block location: " + loc);
@@ -574,7 +577,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
* @param data Data to store.
* @param msg Expected failure message.
*/
- private void expectsStoreFail(final IgfsFileInfo reserved, final byte[] data, @Nullable String msg) {
+ private void expectsStoreFail(final IgfsEntryInfo reserved, final byte[] data, @Nullable String msg) {
GridTestUtils.assertThrows(log, new Callable() {
@Override public Object call() throws Exception {
IgfsFileAffinityRange range = new IgfsFileAffinityRange();
@@ -592,7 +595,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
* @param fileInfo File to delete data for.
* @param msg Expected failure message.
*/
- private void expectsDeleteFail(final IgfsFileInfo fileInfo, @Nullable String msg) {
+ private void expectsDeleteFail(final IgfsEntryInfo fileInfo, @Nullable String msg) {
GridTestUtils.assertThrows(log, new Callable() {
@Override public Object call() throws Exception {
mgr.delete(fileInfo);
@@ -610,7 +613,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
* @param len File part length to get affinity for.
* @param msg Expected failure message.
*/
- private void expectsAffinityFail(final IgfsFileInfo info, final long start, final long len,
+ private void expectsAffinityFail(final IgfsEntryInfo info, final long start, final long len,
@Nullable String msg) {
GridTestUtils.assertThrows(log, new Callable() {
@Override public Object call() throws Exception {
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
index 0731436..6e13280 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
@@ -17,13 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CyclicBarrier;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
import org.apache.ignite.igfs.IgfsFile;
@@ -36,6 +29,14 @@ import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.testframework.GridTestUtils;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CyclicBarrier;
+
import static org.apache.ignite.igfs.IgfsMode.DUAL_ASYNC;
import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC;
import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PERMISSION;
@@ -1254,7 +1255,7 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
// Wait for a while for prefetch to finish.
IgfsMetaManager meta = igfs.context().meta();
- IgfsFileInfo info = meta.info(meta.fileId(FILE));
+ IgfsEntryInfo info = meta.info(meta.fileId(FILE));
assert info != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java
index feccdb5..486179c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java
@@ -17,18 +17,19 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.Externalizable;
-import java.util.Random;
-import java.util.concurrent.Callable;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
import org.jetbrains.annotations.Nullable;
+import java.io.Externalizable;
+import java.util.Random;
+import java.util.concurrent.Callable;
+
/**
- * {@link IgfsFileInfo} test case.
+ * {@link IgfsEntryInfo} test case.
*/
public class IgfsFileInfoSelfTest extends IgfsCommonAbstractTest {
/** Marshaller to test {@link Externalizable} interface. */
@@ -49,23 +50,7 @@ public class IgfsFileInfoSelfTest extends IgfsCommonAbstractTest {
@SuppressWarnings("deprecation") // Suppress due to default constructor should never be used directly.
@Nullable @Override public Object call() throws IgniteCheckedException {
- for (int i = 0; i < 10000; i++) {
- testSerialization(new IgfsFileInfo());
- testSerialization(new IgfsFileInfo());
-
- long a = System.currentTimeMillis();
- long m = a + 1;
-
- testSerialization(new IgfsFileInfo(true, null, a, m));
- testSerialization(new IgfsFileInfo(false, null, a, m));
-
- IgfsFileInfo rndInfo =
- new IgfsFileInfo(rnd.nextInt(max), 0, false, null, a, m);
-
- testSerialization(rndInfo);
- testSerialization(new IgfsFileInfo(rndInfo, rnd.nextInt(max)));
- testSerialization(new IgfsFileInfo(rndInfo, F.asMap("desc", String.valueOf(rnd.nextLong()))));
- }
+ testSerialization(IgfsUtils.createDirectory(IgniteUuid.randomUuid()));
return null;
}
@@ -78,7 +63,7 @@ public class IgfsFileInfoSelfTest extends IgfsCommonAbstractTest {
* @param info Node info to test serialization for.
* @throws IgniteCheckedException If failed.
*/
- public void testSerialization(IgfsFileInfo info) throws IgniteCheckedException {
+ public void testSerialization(IgfsEntryInfo info) throws IgniteCheckedException {
assertEquals(info, mu(info));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/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 26424f0..3dc2791 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
@@ -147,12 +147,12 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
IgfsListingEntry dirEntry = mgr.directoryListing(ROOT_ID).get("dir");
assertNotNull(dirEntry);
assertTrue(dirEntry.isDirectory());
- IgfsFileInfo dir = mgr.info(dirEntry.fileId());
+ IgfsEntryInfo dir = mgr.info(dirEntry.fileId());
IgfsListingEntry fileEntry = mgr.directoryListing(ROOT_ID).get("file");
assertNotNull(fileEntry);
assertTrue(!fileEntry.isDirectory());
- IgfsFileInfo file = mgr.info(fileEntry.fileId());
+ IgfsEntryInfo file = mgr.info(fileEntry.fileId());
assertEquals(2, mgr.directoryListing(ROOT_ID).size());
@@ -166,7 +166,7 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
String key1 = UUID.randomUUID().toString();
String key2 = UUID.randomUUID().toString();
- IgfsFileInfo info = mgr.info(fileId);
+ IgfsEntryInfo info = mgr.info(fileId);
assertNull("Unexpected stored properties: " + info, info.properties().get(key1));
assertNull("Unexpected stored properties: " + info, info.properties().get(key2));
@@ -197,24 +197,24 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
assertNull(mgr.updateProperties(dir.id(), F.asMap("p", "7")));
}
- private IgfsFileInfo mkdirsAndGetInfo(String path) throws IgniteCheckedException {
+ private IgfsEntryInfo mkdirsAndGetInfo(String path) throws IgniteCheckedException {
IgfsPath p = path(path);
mgr.mkdirs(p, IgfsImpl.DFLT_DIR_META);
IgniteUuid id = mgr.fileId(p);
- IgfsFileInfo info = mgr.info(id);
+ IgfsEntryInfo info = mgr.info(id);
assert info.isDirectory();
return info;
}
- private IgfsFileInfo createFileAndGetInfo(String path) throws IgniteCheckedException {
+ private IgfsEntryInfo createFileAndGetInfo(String path) throws IgniteCheckedException {
IgfsPath p = path(path);
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = mgr.create(p, null, false, 400, null, false, null);
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = mgr.create(p, null, false, 400, null, false, null);
assert t2 != null;
assert !t2.get1().isDirectory();
@@ -228,7 +228,7 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testStructure() throws Exception {
- IgfsFileInfo rootInfo = new IgfsFileInfo();
+ IgfsEntryInfo rootInfo = IgfsUtils.createDirectory(ROOT_ID);
// Test empty structure.
assertEmpty(mgr.directoryListing(ROOT_ID));
@@ -236,15 +236,15 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
assertEquals(F.asMap(ROOT_ID, rootInfo), mgr.infos(Arrays.asList(ROOT_ID)));
// Directories:
- IgfsFileInfo a = mkdirsAndGetInfo("/a");
- IgfsFileInfo b = mkdirsAndGetInfo("/a/b");
- IgfsFileInfo k = mkdirsAndGetInfo("/a/b/k");
- IgfsFileInfo z = mkdirsAndGetInfo("/a/k");
+ IgfsEntryInfo a = mkdirsAndGetInfo("/a");
+ IgfsEntryInfo b = mkdirsAndGetInfo("/a/b");
+ IgfsEntryInfo k = mkdirsAndGetInfo("/a/b/k");
+ IgfsEntryInfo z = mkdirsAndGetInfo("/a/k");
// Files:
- IgfsFileInfo f1 = createFileAndGetInfo("/f1");
- IgfsFileInfo f2 = createFileAndGetInfo("/a/f2");
- IgfsFileInfo f3 = createFileAndGetInfo("/a/b/f3");
+ IgfsEntryInfo f1 = createFileAndGetInfo("/f1");
+ IgfsEntryInfo f2 = createFileAndGetInfo("/a/f2");
+ IgfsEntryInfo f3 = createFileAndGetInfo("/a/b/f3");
assertEquals(F.asMap("a", new IgfsListingEntry(a), "f1", new IgfsListingEntry(f1)),
mgr.directoryListing(ROOT_ID));
@@ -256,11 +256,11 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
"k", new IgfsListingEntry(k)), mgr.directoryListing(b.id()));
// Validate empty files listings.
- for (IgfsFileInfo info : Arrays.asList(f1, f2, f3))
+ for (IgfsEntryInfo info : Arrays.asList(f1, f2, f3))
assertEmpty(mgr.directoryListing(info.id()));
// Validate 'file info' operations.
- for (IgfsFileInfo info : Arrays.asList(rootInfo, a, b, f1, f2, f3)) {
+ for (IgfsEntryInfo info : Arrays.asList(rootInfo, a, b, f1, f2, f3)) {
assertEquals(info, mgr.info(info.id()));
assertEquals(F.asMap(info.id(), info), mgr.infos(Arrays.asList(info.id())));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
index 4112846..bcc2314 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
@@ -17,17 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.security.SecureRandom;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.cache.Cache;
import org.apache.commons.io.IOUtils;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
@@ -56,6 +45,18 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.jetbrains.annotations.Nullable;
+import javax.cache.Cache;
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicInteger;
+
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -227,8 +228,8 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
IgfsFileImpl info = (IgfsFileImpl)igfs.info(path);
for (int i = 0; i < nodesCount(); i++) {
- IgfsFileInfo fileInfo =
- (IgfsFileInfo)grid(i).cachex(metaCacheName).localPeek(info.fileId(), ONHEAP_PEEK_MODES, null);
+ IgfsEntryInfo fileInfo =
+ (IgfsEntryInfo)grid(i).cachex(metaCacheName).localPeek(info.fileId(), ONHEAP_PEEK_MODES, null);
assertNotNull(fileInfo);
assertNotNull(fileInfo.listing());
@@ -693,10 +694,10 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
IgniteUuid fileId = U.field(igfs.info(path), "fileId");
- GridCacheAdapter<IgniteUuid, IgfsFileInfo> metaCache = ((IgniteKernal)grid(0)).internalCache(META_CACHE_NAME);
+ GridCacheAdapter<IgniteUuid, IgfsEntryInfo> metaCache = ((IgniteKernal)grid(0)).internalCache(META_CACHE_NAME);
GridCacheAdapter<IgfsBlockKey, byte[]> dataCache = ((IgniteKernal)grid(0)).internalCache(DATA_CACHE_NAME);
- IgfsFileInfo info = metaCache.get(fileId);
+ IgfsEntryInfo info = metaCache.get(fileId);
assertNotNull(info);
assertTrue(info.isFile());
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
index fcf4b3b..3933e86 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
@@ -17,17 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheMode;
@@ -55,6 +44,18 @@ import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.transactions.Transaction;
import org.jsr166.ThreadLocalRandom8;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -505,12 +506,12 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
os.write(chunk((int)igfsMaxData));
os.close();
- final IgniteCache<IgniteUuid, IgfsFileInfo> metaCache = igfs.context().kernalContext().cache().jcache(
+ final IgniteCache<IgniteUuid, IgfsEntryInfo> metaCache = igfs.context().kernalContext().cache().jcache(
igfs.configuration().getMetaCacheName());
// Start a transaction in a separate thread which will lock file ID.
final IgniteUuid id = igfs.context().meta().fileId(path);
- final IgfsFileInfo info = igfs.context().meta().info(id);
+ final IgfsEntryInfo info = igfs.context().meta().info(id);
final AtomicReference<Throwable> err = new AtomicReference<>();
@@ -543,15 +544,15 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
new IgfsListingEntry(info));
// Clear root listing.
- metaCache.put(IgfsUtils.ROOT_ID, new IgfsFileInfo(IgfsUtils.ROOT_ID));
+ metaCache.put(IgfsUtils.ROOT_ID, IgfsUtils.createDirectory(IgfsUtils.ROOT_ID));
// Add file to trash listing.
- IgfsFileInfo trashInfo = metaCache.get(trashId);
+ IgfsEntryInfo trashInfo = metaCache.get(trashId);
if (trashInfo == null)
- metaCache.put(trashId, new IgfsFileInfo(listing, new IgfsFileInfo(trashId)));
+ metaCache.put(trashId, IgfsUtils.createDirectory(trashId).listing(listing));
else
- metaCache.put(trashId, new IgfsFileInfo(listing, trashInfo));
+ metaCache.put(trashId, trashInfo.listing(listing));
tx.commit();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
index 8383a18..7b7078f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
@@ -17,17 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
@@ -53,6 +42,18 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.jetbrains.annotations.Nullable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.atomic.AtomicInteger;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -276,7 +277,7 @@ public class IgfsStreamsSelfTest extends IgfsCommonAbstractTest {
GridCacheAdapter<Object, Object> metaCache = ((IgniteKernal)grid(0)).internalCache(META_CACHE_NAME);
- IgfsFileInfo fileInfo = (IgfsFileInfo)metaCache.get(fileImpl.fileId());
+ IgfsEntryInfo fileInfo = (IgfsEntryInfo)metaCache.get(fileImpl.fileId());
IgfsFileMap map = fileInfo.fileMap();
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
index 672b912..7a4648a 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
@@ -41,11 +41,12 @@ import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadabl
import org.apache.ignite.internal.processors.hadoop.HadoopPayloadAware;
import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsProperties;
import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsSecondaryFileSystemPositionedReadable;
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsFileImpl;
-import org.apache.ignite.internal.processors.igfs.IgfsFileInfo;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.lang.IgniteOutClosure;
+import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.lifecycle.LifecycleAware;
import org.jetbrains.annotations.Nullable;
@@ -350,13 +351,28 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
Collection<IgfsFile> res = new ArrayList<>(statuses.length);
- for (FileStatus status : statuses) {
- IgfsFileInfo fsInfo = status.isDirectory() ?
- new IgfsFileInfo(true, properties(status), status.getAccessTime(), status.getModificationTime()) :
- new IgfsFileInfo((int)status.getBlockSize(), status.getLen(), null, null, false, properties(status),
- status.getAccessTime(), status.getModificationTime());
-
- res.add(new IgfsFileImpl(new IgfsPath(path, status.getPath().getName()), fsInfo, 1));
+ for (FileStatus s : statuses) {
+ IgfsEntryInfo fsInfo = s.isDirectory() ?
+ IgfsUtils.createDirectory(
+ IgniteUuid.randomUuid(),
+ null,
+ properties(s),
+ s.getAccessTime(),
+ s.getModificationTime()
+ ) :
+ IgfsUtils.createFile(
+ IgniteUuid.randomUuid(),
+ (int)s.getBlockSize(),
+ s.getLen(),
+ null,
+ null,
+ false,
+ properties(s),
+ s.getAccessTime(),
+ s.getModificationTime()
+ );
+
+ res.add(new IgfsFileImpl(new IgfsPath(path, s.getPath().getName()), fsInfo, 1));
}
return res;
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
index 0ec8a78..40cf493 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
@@ -17,9 +17,6 @@
package org.apache.ignite.igfs;
-import java.io.IOException;
-import java.net.URI;
-import java.util.concurrent.Callable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
@@ -34,7 +31,7 @@ import org.apache.ignite.hadoop.fs.IgniteHadoopIgfsSecondaryFileSystem;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
import org.apache.ignite.internal.processors.igfs.IgfsBlockKey;
import org.apache.ignite.internal.processors.igfs.IgfsCommonAbstractTest;
-import org.apache.ignite.internal.processors.igfs.IgfsFileInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsImpl;
import org.apache.ignite.internal.processors.igfs.IgfsMetaManager;
import org.apache.ignite.internal.util.typedef.G;
@@ -44,6 +41,10 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.jetbrains.annotations.Nullable;
+import java.io.IOException;
+import java.net.URI;
+import java.util.concurrent.Callable;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -279,7 +280,7 @@ public abstract class HadoopIgfsDualAbstractSelfTest extends IgfsCommonAbstractT
// Wait for a while for prefetch to finish (if any).
IgfsMetaManager meta = igfs.context().meta();
- IgfsFileInfo info = meta.info(meta.fileId(FILE));
+ IgfsEntryInfo info = meta.info(meta.fileId(FILE));
IgfsBlockKey key = new IgfsBlockKey(info.id(), info.affinityKey(), info.evictExclude(), 2);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemLoggerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemLoggerSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemLoggerSelfTest.java
index e89d651..3013311 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemLoggerSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemLoggerSelfTest.java
@@ -17,6 +17,11 @@
package org.apache.ignite.igfs;
+import org.apache.ignite.internal.igfs.common.IgfsLogger;
+import org.apache.ignite.internal.processors.igfs.IgfsCommonAbstractTest;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -24,12 +29,6 @@ import java.io.FilenameFilter;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
-import org.apache.ignite.internal.igfs.common.IgfsLogger;
-import org.apache.ignite.internal.processors.igfs.IgfsCommonAbstractTest;
-import org.apache.ignite.internal.processors.igfs.IgfsFileImpl;
-import org.apache.ignite.internal.processors.igfs.IgfsFileInfo;
-import org.apache.ignite.internal.util.typedef.internal.SB;
-import org.apache.ignite.internal.util.typedef.internal.U;
import static org.apache.ignite.igfs.IgfsMode.PRIMARY;
import static org.apache.ignite.internal.igfs.common.IgfsLogger.DELIM_FIELD;
@@ -244,16 +243,6 @@ public class IgniteHadoopFileSystemLoggerSelfTest extends IgfsCommonAbstractTest
}
/**
- * Create IGFS file with the given path.
- *
- * @param path File path.
- * @return IGFS file instance.
- */
- private IgfsFile file(String path) {
- return new IgfsFileImpl(new IgfsPath(path), new IgfsFileInfo(), 64 * 1024 * 1024);
- }
-
- /**
* Ensure that log file has only the following lines.
*
* @param lines Expected lines.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/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 e03e4e1..ebc0c23 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
@@ -17,17 +17,6 @@
package org.apache.ignite.testsuites;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
import junit.framework.TestSuite;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
@@ -68,6 +57,7 @@ import org.apache.ignite.internal.processors.hadoop.HadoopJobTrackerSelfTest;
import org.apache.ignite.internal.processors.hadoop.HadoopMapReduceEmbeddedSelfTest;
import org.apache.ignite.internal.processors.hadoop.HadoopMapReduceTest;
import org.apache.ignite.internal.processors.hadoop.HadoopSerializationWrapperSelfTest;
+import org.apache.ignite.internal.processors.hadoop.HadoopSnappyFullMapReduceTest;
import org.apache.ignite.internal.processors.hadoop.HadoopSnappyTest;
import org.apache.ignite.internal.processors.hadoop.HadoopSortingTest;
import org.apache.ignite.internal.processors.hadoop.HadoopSplitWrapperSelfTest;
@@ -76,7 +66,6 @@ import org.apache.ignite.internal.processors.hadoop.HadoopTasksV1Test;
import org.apache.ignite.internal.processors.hadoop.HadoopTasksV2Test;
import org.apache.ignite.internal.processors.hadoop.HadoopV2JobSelfTest;
import org.apache.ignite.internal.processors.hadoop.HadoopValidationSelfTest;
-import org.apache.ignite.internal.processors.hadoop.HadoopSnappyFullMapReduceTest;
import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopConcurrentHashMultimapSelftest;
import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopHashMapSelfTest;
import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopSkipListSelfTest;
@@ -85,6 +74,18 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
import static org.apache.ignite.testframework.GridTestUtils.modeToPermissionSet;
/**
@@ -184,6 +185,7 @@ public class IgniteHadoopTestSuite extends TestSuite {
suite.addTest(new TestSuite(ldr.loadClass(HadoopSecondaryFileSystemConfigurationTest.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(HadoopTxConfigCacheTest.class.getName())));
+
return suite;
}
[2/3] ignite git commit: IGNITE-2813: IGFS: Optimized metadata values
splitting file and directory into separate classes.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/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 d91b0bc..84e4dae 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
@@ -86,8 +86,6 @@ import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.CountDownLatch;
-import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.builder;
-
/**
* Cache based structure (meta data) manager.
*/
@@ -117,7 +115,7 @@ public class IgfsMetaManager extends IgfsManager {
private CountDownLatch metaCacheStartLatch;
/** File ID to file info projection. */
- private IgniteInternalCache<IgniteUuid, IgfsFileInfo> id2InfoPrj;
+ private IgniteInternalCache<IgniteUuid, IgfsEntryInfo> id2InfoPrj;
/** Predefined key for sampling mode value. */
private GridCacheInternal sampling;
@@ -175,7 +173,7 @@ public class IgfsMetaManager extends IgfsManager {
}
});
- id2InfoPrj = (IgniteInternalCache<IgniteUuid, IgfsFileInfo>)metaCache.<IgniteUuid, IgfsFileInfo>cache();
+ id2InfoPrj = (IgniteInternalCache<IgniteUuid, IgfsEntryInfo>)metaCache.<IgniteUuid, IgfsEntryInfo>cache();
locNode = igfsCtx.kernalContext().discovery().localNode();
@@ -440,17 +438,17 @@ public class IgfsMetaManager extends IgfsManager {
* @return File info.
* @throws IgniteCheckedException If failed.
*/
- @Nullable public IgfsFileInfo info(@Nullable IgniteUuid fileId) throws IgniteCheckedException {
+ @Nullable public IgfsEntryInfo info(@Nullable IgniteUuid fileId) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
if (fileId == null)
return null;
- IgfsFileInfo info = getInfo(fileId);
+ IgfsEntryInfo info = getInfo(fileId);
// Force root ID always exist in cache.
if (info == null && IgfsUtils.ROOT_ID.equals(fileId))
- info = createSystemEntryIfAbsent(fileId);
+ info = createSystemDirectoryIfAbsent(fileId);
return info;
}
@@ -469,7 +467,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Files details.
* @throws IgniteCheckedException If failed.
*/
- public Map<IgniteUuid, IgfsFileInfo> infos(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
+ public Map<IgniteUuid, IgfsEntryInfo> infos(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
validTxState(false);
@@ -479,13 +477,13 @@ public class IgfsMetaManager extends IgfsManager {
if (F.isEmpty(fileIds))
return Collections.emptyMap();
- Map<IgniteUuid, IgfsFileInfo> map = getInfos(fileIds);
+ Map<IgniteUuid, IgfsEntryInfo> map = getInfos(fileIds);
// Force root ID always exist in cache.
if (fileIds.contains(IgfsUtils.ROOT_ID) && !map.containsKey(IgfsUtils.ROOT_ID)) {
map = new GridLeanMap<>(map);
- map.put(IgfsUtils.ROOT_ID, createSystemEntryIfAbsent(IgfsUtils.ROOT_ID));
+ map.put(IgfsUtils.ROOT_ID, createSystemDirectoryIfAbsent(IgfsUtils.ROOT_ID));
}
return map;
@@ -506,7 +504,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Locked file info or {@code null} if file cannot be locked or doesn't exist.
* @throws IgniteCheckedException If the file with such id does not exist, or on another failure.
*/
- public @Nullable IgfsFileInfo lock(IgniteUuid fileId, boolean delete) throws IgniteCheckedException {
+ public @Nullable IgfsEntryInfo lock(IgniteUuid fileId, boolean delete) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
validTxState(false);
@@ -517,7 +515,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
// Lock file ID for this transaction.
- IgfsFileInfo oldInfo = info(fileId);
+ IgfsEntryInfo oldInfo = info(fileId);
if (oldInfo == null)
return null;
@@ -525,7 +523,7 @@ public class IgfsMetaManager extends IgfsManager {
if (oldInfo.lockId() != null)
return null; // The file is already locked, we cannot lock it.
- IgfsFileInfo newInfo = invokeLock(fileId, delete);
+ IgfsEntryInfo newInfo = invokeLock(fileId, delete);
tx.commit();
@@ -566,7 +564,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param modificationTime Modification time to write to file info.
* @throws IgniteCheckedException If failed.
*/
- public void unlock(final IgfsFileInfo info, final long modificationTime) throws IgniteCheckedException {
+ public void unlock(final IgfsEntryInfo info, final long modificationTime) throws IgniteCheckedException {
validTxState(false);
assert info != null;
@@ -589,7 +587,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteUuid fileId = info.id();
// Lock file ID for this transaction.
- IgfsFileInfo oldInfo = info(fileId);
+ IgfsEntryInfo oldInfo = info(fileId);
if (oldInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to unlock file (file not " +
@@ -628,7 +626,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Locked file details. Resulting map doesn't contain details for not-existent files.
* @throws IgniteCheckedException If failed.
*/
- private Map<IgniteUuid, IgfsFileInfo> lockIds(IgniteUuid... fileIds) throws IgniteCheckedException {
+ private Map<IgniteUuid, IgfsEntryInfo> lockIds(IgniteUuid... fileIds) throws IgniteCheckedException {
validTxState(true);
assert fileIds != null && fileIds.length > 0;
@@ -668,7 +666,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Map with lock info.
* @throws IgniteCheckedException If failed.
*/
- private Map<IgniteUuid, IgfsFileInfo> lockIds(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
+ private Map<IgniteUuid, IgfsEntryInfo> lockIds(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
assert isSorted(fileIds);
validTxState(true);
@@ -676,7 +674,7 @@ public class IgfsMetaManager extends IgfsManager {
log.debug("Locking file ids: " + fileIds);
// Lock files and get their infos.
- Map<IgniteUuid, IgfsFileInfo> map = getInfos(fileIds);
+ Map<IgniteUuid, IgfsEntryInfo> map = getInfos(fileIds);
if (log.isDebugEnabled())
log.debug("Locked file ids: " + fileIds);
@@ -684,7 +682,7 @@ public class IgfsMetaManager extends IgfsManager {
for (IgniteUuid fileId : fileIds) {
if (IgfsUtils.isRootOrTrashId(fileId)) {
if (!map.containsKey(fileId))
- map.put(fileId, createSystemEntryIfAbsent(fileId));
+ map.put(fileId, createSystemDirectoryIfAbsent(fileId));
}
}
@@ -699,13 +697,15 @@ public class IgfsMetaManager extends IgfsManager {
* @return Value of created or existing system entry.
* @throws IgniteCheckedException On error.
*/
- private IgfsFileInfo createSystemEntryIfAbsent(IgniteUuid id)
+ private IgfsEntryInfo createSystemDirectoryIfAbsent(IgniteUuid id)
throws IgniteCheckedException {
assert IgfsUtils.isRootOrTrashId(id);
- IgfsFileInfo info = new IgfsFileInfo(id);
+ long time = System.currentTimeMillis();
+
+ IgfsEntryInfo info = IgfsUtils.createDirectory(id);
- IgfsFileInfo oldInfo = id2InfoPrj.getAndPutIfAbsent(id, info);
+ IgfsEntryInfo oldInfo = id2InfoPrj.getAndPutIfAbsent(id, info);
if (oldInfo != null)
info = oldInfo;
@@ -740,7 +740,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return First qualified file info.
* @throws IgniteCheckedException If failed to get file for fragmentizer.
*/
- public IgfsFileInfo fileForFragmentizer(Collection<IgniteUuid> exclude) throws IgniteCheckedException {
+ public IgfsEntryInfo fileForFragmentizer(Collection<IgniteUuid> exclude) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
return fileForFragmentizer0(IgfsUtils.ROOT_ID, exclude);
@@ -761,9 +761,9 @@ public class IgfsMetaManager extends IgfsManager {
* @return First qualified file info.
* @throws IgniteCheckedException If failed to get file for fragmentizer.
*/
- private IgfsFileInfo fileForFragmentizer0(IgniteUuid parentId, Collection<IgniteUuid> exclude)
+ private IgfsEntryInfo fileForFragmentizer0(IgniteUuid parentId, Collection<IgniteUuid> exclude)
throws IgniteCheckedException {
- IgfsFileInfo info = info(parentId);
+ IgfsEntryInfo info = info(parentId);
// Check if file was concurrently deleted.
if (info == null)
@@ -775,7 +775,7 @@ public class IgfsMetaManager extends IgfsManager {
for (IgfsListingEntry entry : listing.values()) {
if (entry.isFile()) {
- IgfsFileInfo fileInfo = info(entry.fileId());
+ IgfsEntryInfo fileInfo = info(entry.fileId());
if (fileInfo != null) {
if (!exclude.contains(fileInfo.id()) &&
@@ -785,7 +785,7 @@ public class IgfsMetaManager extends IgfsManager {
}
}
else {
- IgfsFileInfo fileInfo = fileForFragmentizer0(entry.fileId(), exclude);
+ IgfsEntryInfo fileInfo = fileForFragmentizer0(entry.fileId(), exclude);
if (fileInfo != null)
return fileInfo;
@@ -807,7 +807,7 @@ public class IgfsMetaManager extends IgfsManager {
throws IgniteCheckedException {
assert fileId != null;
- IgfsFileInfo info = skipTx ? id2InfoPrj.getAllOutTx(Collections.singleton(fileId)).get(fileId) :
+ IgfsEntryInfo info = skipTx ? id2InfoPrj.getAllOutTx(Collections.singleton(fileId)).get(fileId) :
getInfo(fileId);
return info == null ? Collections.<String, IgfsListingEntry>emptyMap() : info.listing();
@@ -822,7 +822,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return File id already stored in meta cache or {@code null} if passed file info was stored.
* @throws IgniteCheckedException If failed.
*/
- private IgniteUuid putIfAbsentNonTx(IgniteUuid parentId, String fileName, IgfsFileInfo newFileInfo)
+ private IgniteUuid putIfAbsentNonTx(IgniteUuid parentId, String fileName, IgfsEntryInfo newFileInfo)
throws IgniteCheckedException {
if (log.isDebugEnabled())
log.debug("Locking parent id [parentId=" + parentId + ", fileName=" + fileName + ", newFileInfo=" +
@@ -831,7 +831,7 @@ public class IgfsMetaManager extends IgfsManager {
validTxState(true);
// Lock only parent file ID.
- IgfsFileInfo parentInfo = info(parentId);
+ IgfsEntryInfo parentInfo = info(parentId);
if (parentInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to lock parent directory (not found): " +
@@ -858,7 +858,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return File info of renamed entry.
* @throws IgniteCheckedException In case of exception.
*/
- public IgfsFileInfo move(IgfsPath srcPath, IgfsPath dstPath) throws IgniteCheckedException {
+ public IgfsEntryInfo move(IgfsPath srcPath, IgfsPath dstPath) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
validTxState(false);
@@ -902,7 +902,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
// Obtain the locks.
- final Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(lockIds);
+ final Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
// Verify integrity of source and destination paths.
if (!srcPathIds.verifyIntegrity(lockInfos))
@@ -914,7 +914,7 @@ public class IgfsMetaManager extends IgfsManager {
"structure changed concurrently [src=" + srcPath + ", dst=" + dstPath + ']');
// Addiional check: is destination directory?
- IgfsFileInfo dstParentInfo = lockInfos.get(dstPathIds.lastId());
+ IgfsEntryInfo dstParentInfo = lockInfos.get(dstPathIds.lastId());
if (dstParentInfo.isFile())
throw new IgfsPathAlreadyExistsException("Failed to perform move because destination points " +
@@ -927,9 +927,9 @@ public class IgfsMetaManager extends IgfsManager {
", dst=" + dstPath + ']');
// Actual move: remove from source parent and add to destination target.
- IgfsFileInfo srcParentInfo = lockInfos.get(srcPathIds.lastParentId());
+ IgfsEntryInfo srcParentInfo = lockInfos.get(srcPathIds.lastParentId());
- IgfsFileInfo srcInfo = lockInfos.get(srcPathIds.lastId());
+ IgfsEntryInfo srcInfo = lockInfos.get(srcPathIds.lastId());
String srcName = srcPathIds.lastPart();
IgfsListingEntry srcEntry = srcParentInfo.listing().get(srcName);
@@ -940,7 +940,7 @@ public class IgfsMetaManager extends IgfsManager {
IgfsPath newPath = new IgfsPath(dstPathIds.path(), dstName);
// Set the new path to the info to simplify event creation:
- return IgfsFileInfo.builder(srcInfo).path(newPath).build();
+ return srcInfo.path(newPath);
}
finally {
tx.close();
@@ -965,7 +965,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return verification result.
*/
private static boolean verifyPathIntegrity(IgfsPath path, List<IgniteUuid> expIds,
- Map<IgniteUuid, IgfsFileInfo> infos) {
+ Map<IgniteUuid, IgfsEntryInfo> infos) {
List<String> pathParts = path.components();
assert pathParts.size() < expIds.size();
@@ -975,7 +975,7 @@ public class IgfsMetaManager extends IgfsManager {
// If parent ID is null, it doesn't exist.
if (parentId != null) {
- IgfsFileInfo parentInfo = infos.get(parentId);
+ IgfsEntryInfo parentInfo = infos.get(parentId);
// If parent info is null, it doesn't exist.
if (parentInfo != null) {
@@ -1019,9 +1019,9 @@ public class IgfsMetaManager extends IgfsManager {
}
// Lock file ID and parent IDs for this transaction.
- Map<IgniteUuid, IgfsFileInfo> infoMap = lockIds(srcParentId, fileId, destParentId);
+ Map<IgniteUuid, IgfsEntryInfo> infoMap = lockIds(srcParentId, fileId, destParentId);
- IgfsFileInfo srcInfo = infoMap.get(srcParentId);
+ IgfsEntryInfo srcInfo = infoMap.get(srcParentId);
if (srcInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to lock source directory (not found?)" +
@@ -1030,7 +1030,7 @@ public class IgfsMetaManager extends IgfsManager {
if (!srcInfo.isDirectory())
throw fsException(new IgfsPathIsNotDirectoryException("Source is not a directory: " + srcInfo));
- IgfsFileInfo destInfo = infoMap.get(destParentId);
+ IgfsEntryInfo destInfo = infoMap.get(destParentId);
if (destInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to lock destination directory (not found?)" +
@@ -1039,7 +1039,7 @@ public class IgfsMetaManager extends IgfsManager {
if (!destInfo.isDirectory())
throw fsException(new IgfsPathIsNotDirectoryException("Destination is not a directory: " + destInfo));
- IgfsFileInfo fileInfo = infoMap.get(fileId);
+ IgfsEntryInfo fileInfo = infoMap.get(fileId);
if (fileInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to lock target file (not found?) [fileId=" +
@@ -1080,7 +1080,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
// NB: We may lock root because its id is less than any other id:
- final IgfsFileInfo rootInfo = lockIds(IgfsUtils.ROOT_ID, trashId).get(IgfsUtils.ROOT_ID);
+ final IgfsEntryInfo rootInfo = lockIds(IgfsUtils.ROOT_ID, trashId).get(IgfsUtils.ROOT_ID);
assert rootInfo != null;
@@ -1094,13 +1094,17 @@ public class IgfsMetaManager extends IgfsManager {
// Construct new info and move locked entries from root to it.
Map<String, IgfsListingEntry> transferListing = new HashMap<>(rootListingMap);
- IgfsFileInfo newInfo = new IgfsFileInfo(transferListing);
+ IgfsEntryInfo newInfo = IgfsUtils.createDirectory(
+ IgniteUuid.randomUuid(),
+ transferListing,
+ (Map<String,String>)null
+ );
createNewEntry(newInfo, trashId, newInfo.id().toString());
// Remove listing entries from root.
// Note that root directory properties and other attributes are preserved:
- id2InfoPrj.put(IgfsUtils.ROOT_ID, new IgfsFileInfo(null/*listing*/, rootInfo));
+ id2InfoPrj.put(IgfsUtils.ROOT_ID, rootInfo.listing(null));
tx.commit();
@@ -1159,13 +1163,13 @@ public class IgfsMetaManager extends IgfsManager {
try {
// Lock participants.
- Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(allIds);
+ Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(allIds);
// Ensure that all participants are still in place.
if (!pathIds.verifyIntegrity(lockInfos))
return null;
- IgfsFileInfo victimInfo = lockInfos.get(victimId);
+ IgfsEntryInfo victimInfo = lockInfos.get(victimId);
// Cannot delete non-empty directory if recursive flag is not set.
if (!recursive && victimInfo.hasChildren())
@@ -1173,14 +1177,14 @@ public class IgfsMetaManager extends IgfsManager {
"empty and recursive flag is not set).");
// Prepare trash data.
- IgfsFileInfo trashInfo = lockInfos.get(trashId);
+ IgfsEntryInfo trashInfo = lockInfos.get(trashId);
final String trashName = victimId.toString();
assert !trashInfo.hasChild(trashName) : "Failed to add file name into the " +
"destination directory (file already exists) [destName=" + trashName + ']';
IgniteUuid parentId = pathIds.lastParentId();
- IgfsFileInfo parentInfo = lockInfos.get(parentId);
+ IgfsEntryInfo parentInfo = lockInfos.get(parentId);
transferEntry(parentInfo.listing().get(victimName), parentId, victimName, trashId, trashName);
@@ -1227,13 +1231,13 @@ public class IgfsMetaManager extends IgfsManager {
// Handle special case when we deleting root directory.
assert IgfsUtils.ROOT_ID.equals(id);
- IgfsFileInfo rootInfo = getInfo(IgfsUtils.ROOT_ID);
+ IgfsEntryInfo rootInfo = getInfo(IgfsUtils.ROOT_ID);
if (rootInfo == null)
return null; // Root was never created.
// Ensure trash directory existence.
- createSystemEntryIfAbsent(trashId);
+ createSystemDirectoryIfAbsent(trashId);
Map<String, IgfsListingEntry> rootListing = rootInfo.listing();
@@ -1253,13 +1257,18 @@ public class IgfsMetaManager extends IgfsManager {
transferListing.putAll(rootListing);
- IgfsFileInfo newInfo = new IgfsFileInfo(transferListing);
+ IgfsEntryInfo newInfo = IgfsUtils.createDirectory(
+ IgniteUuid.randomUuid(),
+ transferListing,
+ (Map<String,String>)null
+ );
createNewEntry(newInfo, trashId, newInfo.id().toString());
// Remove listing entries from root.
for (Map.Entry<String, IgfsListingEntry> entry : transferListing.entrySet())
- id2InfoPrj.invoke(IgfsUtils.ROOT_ID, new ListingRemoveProcessor(entry.getKey(), entry.getValue().fileId()));
+ id2InfoPrj.invoke(IgfsUtils.ROOT_ID,
+ new ListingRemoveProcessor(entry.getKey(), entry.getValue().fileId()));
resId = newInfo.id();
}
@@ -1268,7 +1277,7 @@ public class IgfsMetaManager extends IgfsManager {
}
else {
// Ensure trash directory existence.
- createSystemEntryIfAbsent(trashId);
+ createSystemDirectoryIfAbsent(trashId);
moveNonTx(id, name, parentId, id.toString(), trashId);
@@ -1310,9 +1319,9 @@ public class IgfsMetaManager extends IgfsManager {
for (IgfsListingEntry childEntry : listing.values())
allIds[i++] = childEntry.fileId();
- Map<IgniteUuid, IgfsFileInfo> locks = lockIds(allIds);
+ Map<IgniteUuid, IgfsEntryInfo> locks = lockIds(allIds);
- IgfsFileInfo parentInfo = locks.get(parentId);
+ IgfsEntryInfo parentInfo = locks.get(parentId);
// Ensure parent is still in place.
if (parentInfo != null) {
@@ -1327,7 +1336,7 @@ public class IgfsMetaManager extends IgfsManager {
String childName = entry.getKey();
IgniteUuid childId = entry.getValue().fileId();
- IgfsFileInfo entryInfo = locks.get(childId);
+ IgfsEntryInfo entryInfo = locks.get(childId);
if (entryInfo != null) {
// File must be locked for deletion:
@@ -1351,7 +1360,7 @@ public class IgfsMetaManager extends IgfsManager {
}
// Update parent listing.
- id2InfoPrj.put(parentId, new IgfsFileInfo(newListing, parentInfo));
+ id2InfoPrj.put(parentId, parentInfo.listing(newListing));
}
tx.commit();
@@ -1391,9 +1400,9 @@ public class IgfsMetaManager extends IgfsManager {
try {
boolean res = false;
- Map<IgniteUuid, IgfsFileInfo> infos = lockIds(parentId, id);
+ Map<IgniteUuid, IgfsEntryInfo> infos = lockIds(parentId, id);
- IgfsFileInfo victim = infos.get(id);
+ IgfsEntryInfo victim = infos.get(id);
if (victim == null)
return res;
@@ -1403,7 +1412,7 @@ public class IgfsMetaManager extends IgfsManager {
// Proceed only in case both parent and child exist.
if (infos.containsKey(parentId) && infos.containsKey(id)) {
- IgfsFileInfo parentInfo = infos.get(parentId);
+ IgfsEntryInfo parentInfo = infos.get(parentId);
assert parentInfo != null;
@@ -1448,7 +1457,7 @@ public class IgfsMetaManager extends IgfsManager {
for (int i = 0; i < IgfsUtils.TRASH_CONCURRENCY; i++) {
IgniteUuid trashId = IgfsUtils.trashId(i);
- IgfsFileInfo trashInfo = getInfo(trashId);
+ IgfsEntryInfo trashInfo = getInfo(trashId);
if (trashInfo != null && trashInfo.hasChildren()) {
for (IgfsListingEntry entry : trashInfo.listing().values())
@@ -1474,7 +1483,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Updated file info or {@code null} if such file ID not found.
* @throws IgniteCheckedException If operation failed.
*/
- @Nullable private IgfsFileInfo updatePropertiesNonTx(final IgniteUuid fileId, Map<String, String> props)
+ @Nullable private IgfsEntryInfo updatePropertiesNonTx(final IgniteUuid fileId, Map<String, String> props)
throws IgniteCheckedException {
assert fileId != null;
assert !F.isEmpty(props) : "Expects not-empty file's properties";
@@ -1485,7 +1494,7 @@ public class IgfsMetaManager extends IgfsManager {
log.debug("Update file properties [fileId=" + fileId + ", props=" + props + ']');
try {
- final IgfsFileInfo oldInfo = info(fileId);
+ final IgfsEntryInfo oldInfo = info(fileId);
if (oldInfo == null)
return null;
@@ -1505,7 +1514,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Updated file info or {@code null} if such file ID not found.
* @throws IgniteCheckedException If operation failed.
*/
- @Nullable public IgfsFileInfo updateProperties(IgniteUuid fileId, Map<String, String> props)
+ @Nullable public IgfsEntryInfo updateProperties(IgniteUuid fileId, Map<String, String> props)
throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
@@ -1514,7 +1523,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteInternalTx tx = startTx();
try {
- IgfsFileInfo info = updatePropertiesNonTx(fileId, props);
+ IgfsEntryInfo info = updatePropertiesNonTx(fileId, props);
tx.commit();
@@ -1542,7 +1551,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param affRange Affinity range.
* @return New file info.
*/
- public IgfsFileInfo reserveSpace(IgfsPath path, IgniteUuid fileId, long space, IgfsFileAffinityRange affRange)
+ public IgfsEntryInfo reserveSpace(IgfsPath path, IgniteUuid fileId, long space, IgfsFileAffinityRange affRange)
throws IgniteCheckedException {
validTxState(false);
@@ -1555,12 +1564,12 @@ public class IgfsMetaManager extends IgfsManager {
try {
// Lock file ID for this transaction.
- IgfsFileInfo oldInfo = info(fileId);
+ IgfsEntryInfo oldInfo = info(fileId);
if (oldInfo == null)
throw fsException("File has been deleted concurrently [path=" + path + ", id=" + fileId + ']');
- IgfsFileInfo newInfo = invokeAndGet(fileId, new FileReserveSpaceProcessor(space, affRange));
+ IgfsEntryInfo newInfo = invokeAndGet(fileId, new FileReserveSpaceProcessor(space, affRange));
tx.commit();
@@ -1590,8 +1599,8 @@ public class IgfsMetaManager extends IgfsManager {
* @return Updated file info or {@code null} if such file ID not found.
* @throws IgniteCheckedException If failed.
*/
- @Nullable public IgfsFileInfo updateInfo(IgniteUuid fileId,
- EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo> proc) throws IgniteCheckedException {
+ @Nullable public IgfsEntryInfo updateInfo(IgniteUuid fileId,
+ EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo> proc) throws IgniteCheckedException {
validTxState(false);
assert fileId != null;
assert proc != null;
@@ -1605,12 +1614,12 @@ public class IgfsMetaManager extends IgfsManager {
try {
// Lock file ID for this transaction.
- IgfsFileInfo oldInfo = info(fileId);
+ IgfsEntryInfo oldInfo = info(fileId);
if (oldInfo == null)
return null; // File not found.
- IgfsFileInfo newInfo = invokeAndGet(fileId, proc);
+ IgfsEntryInfo newInfo = invokeAndGet(fileId, proc);
if (newInfo == null)
throw fsException("Failed to update file info with null value" +
@@ -1673,7 +1682,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteInternalTx tx = startTx();
try {
- final Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(lockIds);
+ final Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (!pathIds.verifyIntegrity(lockInfos))
// Directory structure changed concurrently. So we simply re-try.
@@ -1779,7 +1788,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param name Name in parent.
* @throws IgniteCheckedException If failed.
*/
- private void createNewEntry(IgfsFileInfo info, IgniteUuid parentId, String name) throws IgniteCheckedException {
+ private void createNewEntry(IgfsEntryInfo info, IgniteUuid parentId, String name) throws IgniteCheckedException {
validTxState(true);
if (!id2InfoPrj.putIfAbsent(info.id(), info))
@@ -1815,7 +1824,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Resulting file info.
* @throws IgniteCheckedException If failed.
*/
- private IgfsFileInfo invokeLock(IgniteUuid id, boolean delete) throws IgniteCheckedException {
+ private IgfsEntryInfo invokeLock(IgniteUuid id, boolean delete) throws IgniteCheckedException {
return invokeAndGet(id, new FileLockProcessor(createFileLockId(delete)));
}
@@ -1840,7 +1849,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return New file info.
* @throws IgniteCheckedException If failed.
*/
- private IgfsFileInfo invokeAndGet(IgniteUuid id, EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo> proc)
+ private IgfsEntryInfo invokeAndGet(IgniteUuid id, EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo> proc)
throws IgniteCheckedException {
validTxState(true);
@@ -1854,7 +1863,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Info.
* @throws IgniteCheckedException If failed.
*/
- @Nullable private IgfsFileInfo getInfo(IgniteUuid id) throws IgniteCheckedException {
+ @Nullable private IgfsEntryInfo getInfo(IgniteUuid id) throws IgniteCheckedException {
return id2InfoPrj.get(id);
}
@@ -1865,7 +1874,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Infos map.
* @throws IgniteCheckedException If failed.
*/
- private Map<IgniteUuid, IgfsFileInfo> getInfos(Collection<IgniteUuid> ids) throws IgniteCheckedException {
+ private Map<IgniteUuid, IgfsEntryInfo> getInfos(Collection<IgniteUuid> ids) throws IgniteCheckedException {
return id2InfoPrj.getAll(ids);
}
@@ -1909,7 +1918,7 @@ public class IgfsMetaManager extends IgfsManager {
private OutputStream out;
@Override public IgfsSecondaryOutputStreamDescriptor onSuccess(Map<IgfsPath,
- IgfsFileInfo> infos) throws Exception {
+ IgfsEntryInfo> infos) throws Exception {
validTxState(true);
assert !infos.isEmpty();
@@ -1924,7 +1933,7 @@ public class IgfsMetaManager extends IgfsManager {
assert parentPath != null;
- IgfsFileInfo parentInfo = infos.get(parentPath);
+ IgfsEntryInfo parentInfo = infos.get(parentPath);
// Delegate to the secondary file system.
out = simpleCreate ? fs.create(path, overwrite) :
@@ -1963,15 +1972,23 @@ public class IgfsMetaManager extends IgfsManager {
throw fsException("Failed to open output stream to the file created in " +
"the secondary file system because the path points to a directory: " + path);
- IgfsFileInfo newInfo = new IgfsFileInfo(status.blockSize(), status.length(), affKey,
- createFileLockId(false), igfsCtx.igfs().evictExclude(path, false), status.properties(),
- status.accessTime(), status.modificationTime());
+ IgfsEntryInfo newInfo = IgfsUtils.createFile(
+ IgniteUuid.randomUuid(),
+ status.blockSize(),
+ status.length(),
+ affKey,
+ createFileLockId(false),
+ igfsCtx.igfs().evictExclude(path, false),
+ status.properties(),
+ status.accessTime(),
+ status.modificationTime()
+ );
// Add new file info to the listing optionally removing the previous one.
IgniteUuid oldId = putIfAbsentNonTx(parentInfo.id(), path.name(), newInfo);
if (oldId != null) {
- IgfsFileInfo oldInfo = info(oldId);
+ IgfsEntryInfo oldInfo = info(oldId);
assert oldInfo != null; // Otherwise cache is in inconsistent state.
@@ -2047,10 +2064,10 @@ public class IgfsMetaManager extends IgfsManager {
private OutputStream out;
@Override public IgfsSecondaryOutputStreamDescriptor onSuccess(Map<IgfsPath,
- IgfsFileInfo> infos) throws Exception {
+ IgfsEntryInfo> infos) throws Exception {
validTxState(true);
- final IgfsFileInfo info = infos.get(path);
+ final IgfsEntryInfo info = infos.get(path);
if (info.isDirectory())
throw fsException("Failed to open output stream to the file in the " +
@@ -2083,7 +2100,7 @@ public class IgfsMetaManager extends IgfsManager {
}
// Set lock and return.
- IgfsFileInfo lockedInfo = invokeLock(info.id(), false);
+ IgfsEntryInfo lockedInfo = invokeLock(info.id(), false);
return new IgfsSecondaryOutputStreamDescriptor(infos.get(path.parent()).id(),
lockedInfo, out);
@@ -2129,7 +2146,7 @@ public class IgfsMetaManager extends IgfsManager {
assert path != null;
// First, try getting file info without any transactions and synchronization.
- IgfsFileInfo info = info(fileId(path));
+ IgfsEntryInfo info = info(fileId(path));
if (info != null) {
if (!info.isFile())
@@ -2143,8 +2160,8 @@ public class IgfsMetaManager extends IgfsManager {
SynchronizationTask<IgfsSecondaryInputStreamDescriptor> task =
new SynchronizationTask<IgfsSecondaryInputStreamDescriptor>() {
@Override public IgfsSecondaryInputStreamDescriptor onSuccess(
- Map<IgfsPath, IgfsFileInfo> infos) throws Exception {
- IgfsFileInfo info = infos.get(path);
+ Map<IgfsPath, IgfsEntryInfo> infos) throws Exception {
+ IgfsEntryInfo info = infos.get(path);
if (info == null)
throw fsException(new IgfsPathNotFoundException("File not found: " + path));
@@ -2183,7 +2200,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return File info or {@code null} if file not found.
* @throws IgniteCheckedException If sync task failed.
*/
- @Nullable public IgfsFileInfo synchronizeFileDual(final IgfsSecondaryFileSystem fs, final IgfsPath path)
+ @Nullable public IgfsEntryInfo synchronizeFileDual(final IgfsSecondaryFileSystem fs, final IgfsPath path)
throws IgniteCheckedException {
assert fs != null;
assert path != null;
@@ -2191,20 +2208,20 @@ public class IgfsMetaManager extends IgfsManager {
if (busyLock.enterBusy()) {
try {
// First, try getting file info without any transactions and synchronization.
- IgfsFileInfo info = info(fileId(path));
+ IgfsEntryInfo info = info(fileId(path));
if (info != null)
return info;
// If failed, try synchronize.
- SynchronizationTask<IgfsFileInfo> task =
- new SynchronizationTask<IgfsFileInfo>() {
- @Override public IgfsFileInfo onSuccess(Map<IgfsPath, IgfsFileInfo> infos)
+ SynchronizationTask<IgfsEntryInfo> task =
+ new SynchronizationTask<IgfsEntryInfo>() {
+ @Override public IgfsEntryInfo onSuccess(Map<IgfsPath, IgfsEntryInfo> infos)
throws Exception {
return infos.get(path);
}
- @Override public IgfsFileInfo onFailure(@Nullable Exception err) throws IgniteCheckedException {
+ @Override public IgfsEntryInfo onFailure(@Nullable Exception err) throws IgniteCheckedException {
throw new IgniteCheckedException("Failed to synchronize path due to secondary file " +
"system exception: " + path, err);
}
@@ -2246,7 +2263,7 @@ public class IgfsMetaManager extends IgfsManager {
final Deque<IgfsEvent> pendingEvts = new LinkedList<>();
SynchronizationTask<Boolean> task = new SynchronizationTask<Boolean>() {
- @Override public Boolean onSuccess(Map<IgfsPath, IgfsFileInfo> infos) throws Exception {
+ @Override public Boolean onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception {
fs.mkdirs(path, props);
assert !infos.isEmpty();
@@ -2261,7 +2278,7 @@ public class IgfsMetaManager extends IgfsManager {
assert parentPath != null;
- IgfsFileInfo parentPathInfo = infos.get(parentPath);
+ IgfsEntryInfo parentPathInfo = infos.get(parentPath);
synchronize(fs, parentPath, parentPathInfo, path, true, null);
@@ -2330,11 +2347,11 @@ public class IgfsMetaManager extends IgfsManager {
final Collection<IgfsEvent> pendingEvts = new LinkedList<>();
SynchronizationTask<Boolean> task = new SynchronizationTask<Boolean>() {
- @Override public Boolean onSuccess(Map<IgfsPath, IgfsFileInfo> infos) throws Exception {
- IgfsFileInfo srcInfo = infos.get(src);
- IgfsFileInfo srcParentInfo = infos.get(src.parent());
- IgfsFileInfo destInfo = infos.get(dest);
- IgfsFileInfo destParentInfo = dest.parent() != null ? infos.get(dest.parent()) : null;
+ @Override public Boolean onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception {
+ IgfsEntryInfo srcInfo = infos.get(src);
+ IgfsEntryInfo srcParentInfo = infos.get(src.parent());
+ IgfsEntryInfo destInfo = infos.get(dest);
+ IgfsEntryInfo destParentInfo = dest.parent() != null ? infos.get(dest.parent()) : null;
// Source path and destination (or destination parent) must exist.
if (srcInfo == null)
@@ -2424,8 +2441,8 @@ public class IgfsMetaManager extends IgfsManager {
final IgniteUuid trashId = IgfsUtils.randomTrashId();
SynchronizationTask<Boolean> task = new SynchronizationTask<Boolean>() {
- @Override public Boolean onSuccess(Map<IgfsPath, IgfsFileInfo> infos) throws Exception {
- IgfsFileInfo info = infos.get(path);
+ @Override public Boolean onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception {
+ IgfsEntryInfo info = infos.get(path);
if (info == null)
return false; // File doesn't exist in the secondary file system.
@@ -2482,7 +2499,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Update file info.
* @throws IgniteCheckedException If update failed.
*/
- public IgfsFileInfo updateDual(final IgfsSecondaryFileSystem fs, final IgfsPath path,
+ public IgfsEntryInfo updateDual(final IgfsSecondaryFileSystem fs, final IgfsPath path,
final Map<String, String> props) throws IgniteCheckedException {
assert fs != null;
assert path != null;
@@ -2490,8 +2507,8 @@ public class IgfsMetaManager extends IgfsManager {
if (busyLock.enterBusy()) {
try {
- SynchronizationTask<IgfsFileInfo> task = new SynchronizationTask<IgfsFileInfo>() {
- @Override public IgfsFileInfo onSuccess(Map<IgfsPath, IgfsFileInfo> infos) throws Exception {
+ SynchronizationTask<IgfsEntryInfo> task = new SynchronizationTask<IgfsEntryInfo>() {
+ @Override public IgfsEntryInfo onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception {
if (infos.get(path) == null)
return null;
@@ -2500,7 +2517,7 @@ public class IgfsMetaManager extends IgfsManager {
return updatePropertiesNonTx(infos.get(path).id(), props);
}
- @Override public IgfsFileInfo onFailure(@Nullable Exception err) throws IgniteCheckedException {
+ @Override public IgfsEntryInfo onFailure(@Nullable Exception err) throws IgniteCheckedException {
U.error(log, "Path update in DUAL mode failed [path=" + path + ", properties=" + props + ']',
err);
@@ -2531,12 +2548,12 @@ public class IgfsMetaManager extends IgfsManager {
* @return File info of the end path.
* @throws IgniteCheckedException If failed.
*/
- private IgfsFileInfo synchronize(IgfsSecondaryFileSystem fs,
+ private IgfsEntryInfo synchronize(IgfsSecondaryFileSystem fs,
IgfsPath startPath,
- IgfsFileInfo startPathInfo,
+ IgfsEntryInfo startPathInfo,
IgfsPath endPath,
boolean strict,
- @Nullable Map<IgfsPath, IgfsFileInfo> created)
+ @Nullable Map<IgfsPath, IgfsEntryInfo> created)
throws IgniteCheckedException
{
assert fs != null;
@@ -2544,7 +2561,7 @@ public class IgfsMetaManager extends IgfsManager {
validTxState(true);
- IgfsFileInfo parentInfo = startPathInfo;
+ IgfsEntryInfo parentInfo = startPathInfo;
List<String> components = endPath.components();
@@ -2585,11 +2602,25 @@ public class IgfsMetaManager extends IgfsManager {
}
// Recreate the path locally.
- IgfsFileInfo curInfo = status.isDirectory() ?
- new IgfsFileInfo(true, status.properties(), status.accessTime(), status.modificationTime()) :
- new IgfsFileInfo(igfsCtx.configuration().getBlockSize(), status.length(),
- igfsCtx.igfs().evictExclude(curPath, false), status.properties(),
- status.accessTime(), status.modificationTime());
+ IgfsEntryInfo curInfo = status.isDirectory() ?
+ IgfsUtils.createDirectory(
+ IgniteUuid.randomUuid(),
+ null,
+ status.properties(),
+ status.accessTime(),
+ status.modificationTime()
+ ) :
+ IgfsUtils.createFile(
+ IgniteUuid.randomUuid(),
+ igfsCtx.configuration().getBlockSize(),
+ status.length(),
+ null,
+ null,
+ igfsCtx.igfs().evictExclude(curPath, false),
+ status.properties(),
+ status.accessTime(),
+ status.modificationTime()
+ );
IgniteUuid oldId = putIfAbsentNonTx(parentInfo.id(), components.get(i), curInfo);
@@ -2719,7 +2750,7 @@ public class IgfsMetaManager extends IgfsManager {
lockArr[idx++] = id;
}
- Map<IgniteUuid, IgfsFileInfo> idToInfo = lockIds(lockArr);
+ Map<IgniteUuid, IgfsEntryInfo> idToInfo = lockIds(lockArr);
if (extraLockIds != null) {
for (IgniteUuid id : extraLockIds)
@@ -2762,9 +2793,9 @@ public class IgfsMetaManager extends IgfsManager {
continue; // Release all locks and try again.
else {
// Perform synchronization.
- Map<IgfsPath, IgfsFileInfo> infos = new HashMap<>();
+ Map<IgfsPath, IgfsEntryInfo> infos = new HashMap<>();
- TreeMap<IgfsPath, IgfsFileInfo> created = new TreeMap<>();
+ TreeMap<IgfsPath, IgfsEntryInfo> created = new TreeMap<>();
for (IgfsPath path : paths) {
IgfsPath parentPath = path.parent();
@@ -2781,7 +2812,7 @@ public class IgfsMetaManager extends IgfsManager {
assert firstParentPath != null;
assert pathToId.get(firstParentPath) != null;
- IgfsFileInfo info = synchronize(fs,
+ IgfsEntryInfo info = synchronize(fs,
firstParentPath,
idToInfo.get(pathToId.get(firstParentPath)),
path,
@@ -2899,15 +2930,15 @@ public class IgfsMetaManager extends IgfsManager {
IgniteInternalTx tx = startTx();
try {
- Map<IgniteUuid, IgfsFileInfo> infoMap = lockIds(fileId, parentId);
+ Map<IgniteUuid, IgfsEntryInfo> infoMap = lockIds(fileId, parentId);
- IgfsFileInfo fileInfo = infoMap.get(fileId);
+ IgfsEntryInfo fileInfo = infoMap.get(fileId);
if (fileInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to update times " +
"(path was not found): " + fileName));
- IgfsFileInfo parentInfo = infoMap.get(parentId);
+ IgfsEntryInfo parentInfo = infoMap.get(parentId);
if (parentInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to update times " +
@@ -2967,7 +2998,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Task result.
* @throws Exception If failed.
*/
- public T onSuccess(Map<IgfsPath, IgfsFileInfo> infos) throws Exception;
+ public T onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception;
/**
* Callback handler in case synchronization failed.
@@ -2993,7 +3024,7 @@ public class IgfsMetaManager extends IgfsManager {
private IgfsPath parentPath;
/** Parent path info. */
- private IgfsFileInfo parentInfo;
+ private IgfsEntryInfo parentInfo;
/**
* Constructor.
@@ -3003,7 +3034,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param parentPath Parent path.
* @param parentInfo Parent info.
*/
- PathDescriptor(IgfsPath path, List<IgniteUuid> ids, IgfsPath parentPath, IgfsFileInfo parentInfo) {
+ PathDescriptor(IgfsPath path, List<IgniteUuid> ids, IgfsPath parentPath, IgfsEntryInfo parentInfo) {
assert path != null;
assert ids != null && !ids.isEmpty();
assert parentPath == null && parentInfo == null || parentPath != null && parentInfo != null;
@@ -3040,7 +3071,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param newParentPath New parent path.
* @param newParentInfo New parent info.
*/
- private void updateParent(IgfsPath newParentPath, IgfsFileInfo newParentInfo) {
+ private void updateParent(IgfsPath newParentPath, IgfsEntryInfo newParentInfo) {
assert newParentPath != null;
assert newParentInfo != null;
assert path.isSubDirectoryOf(newParentPath);
@@ -3065,7 +3096,7 @@ public class IgfsMetaManager extends IgfsManager {
*
* @return Parent path info.
*/
- private IgfsFileInfo parentInfo() {
+ private IgfsEntryInfo parentInfo() {
return parentInfo;
}
}
@@ -3074,7 +3105,7 @@ public class IgfsMetaManager extends IgfsManager {
* Remove entry from directory listing.
*/
@GridInternal
- private static final class ListingRemoveProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static final class ListingRemoveProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3104,9 +3135,9 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> e, Object... args)
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args)
throws EntryProcessorException {
- IgfsFileInfo fileInfo = e.getValue();
+ IgfsEntryInfo fileInfo = e.getValue();
assert fileInfo != null;
assert fileInfo.isDirectory();
@@ -3124,7 +3155,7 @@ public class IgfsMetaManager extends IgfsManager {
// Modify listing in-place.
listing.remove(fileName);
- e.setValue(new IgfsFileInfo(listing, fileInfo));
+ e.setValue(fileInfo.listing(listing));
return null;
}
@@ -3146,7 +3177,7 @@ public class IgfsMetaManager extends IgfsManager {
* Update directory listing closure.
*/
@GridInternal
- private static final class ListingAddProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static final class ListingAddProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3180,8 +3211,8 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> e, Object... args) {
- IgfsFileInfo fileInfo = e.getValue();
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) {
+ IgfsEntryInfo fileInfo = e.getValue();
assert fileInfo.isDirectory();
@@ -3195,7 +3226,7 @@ public class IgfsMetaManager extends IgfsManager {
" [listing=" + listing + ", fileName=" + fileName + ", entry=" + entry +
", oldEntry=" + oldEntry + ']');
- e.setValue(new IgfsFileInfo(listing, fileInfo));
+ e.setValue(fileInfo.listing(listing));
return null;
}
@@ -3221,7 +3252,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Listing replace processor.
*/
- private static final class ListingReplaceProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static final class ListingReplaceProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3251,9 +3282,9 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> e, Object... args)
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args)
throws EntryProcessorException {
- IgfsFileInfo fileInfo = e.getValue();
+ IgfsEntryInfo fileInfo = e.getValue();
assert fileInfo.isDirectory();
@@ -3267,7 +3298,7 @@ public class IgfsMetaManager extends IgfsManager {
listing.put(name, new IgfsListingEntry(id, oldEntry.isDirectory()));
- e.setValue(new IgfsFileInfo(listing, fileInfo));
+ e.setValue(fileInfo.listing(listing));
return null;
}
@@ -3289,7 +3320,7 @@ public class IgfsMetaManager extends IgfsManager {
* Update path closure.
*/
@GridInternal
- private static final class UpdatePathProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static final class UpdatePathProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3312,10 +3343,12 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> e, Object... args) {
- IgfsFileInfo info = e.getValue();
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) {
+ IgfsEntryInfo info = e.getValue();
- e.setValue(builder(info).path(path).build());
+ IgfsEntryInfo newInfo = info.path(path);
+
+ e.setValue(newInfo);
return null;
}
@@ -3349,7 +3382,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Tuple containing the file info and its parent id.
* @throws IgniteCheckedException If failed.
*/
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> append(
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> append(
final IgfsPath path,
Map<String, String> dirProps,
final boolean create,
@@ -3379,7 +3412,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteInternalTx tx = startTx();
try {
- Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(lockIds);
+ Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (!pathIds.verifyIntegrity(lockInfos))
// Directory structure changed concurrently. So we simply re-try.
@@ -3387,7 +3420,7 @@ public class IgfsMetaManager extends IgfsManager {
if (pathIds.allExists()) {
// All participants are found. Simply open the stream.
- IgfsFileInfo info = lockInfos.get(pathIds.lastId());
+ IgfsEntryInfo info = lockInfos.get(pathIds.lastId());
// Check: is it a file?
if (!info.isFile())
@@ -3400,7 +3433,7 @@ public class IgfsMetaManager extends IgfsManager {
// At this point we can open the stream safely.
info = invokeLock(info.id(), false);
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(info, pathIds.lastParentId());
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = new T2<>(info, pathIds.lastParentId());
tx.commit();
@@ -3450,7 +3483,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param simpleCreate Whether new file should be created in secondary FS using create(Path, boolean) method.
* @return Tuple containing the created file info and its parent id.
*/
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> create(
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> create(
final IgfsPath path,
Map<String, String> dirProps,
final boolean overwrite,
@@ -3488,7 +3521,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteInternalTx tx = startTx();
try {
- Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(lockIds);
+ Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (!pathIds.verifyIntegrity(lockInfos))
// Directory structure changed concurrently. So we simply re-try.
@@ -3496,7 +3529,7 @@ public class IgfsMetaManager extends IgfsManager {
if (pathIds.allExists()) {
// All participants found.
- IgfsFileInfo oldInfo = lockInfos.get(pathIds.lastId());
+ IgfsEntryInfo oldInfo = lockInfos.get(pathIds.lastId());
// Check: is it a file?
if (!oldInfo.isFile())
@@ -3527,14 +3560,14 @@ public class IgfsMetaManager extends IgfsManager {
// Third step: create the file.
long createTime = System.currentTimeMillis();
- IgfsFileInfo newInfo = invokeAndGet(overwriteId, new FileCreateProcessor(createTime,
+ IgfsEntryInfo newInfo = invokeAndGet(overwriteId, new FileCreateProcessor(createTime,
fileProps, blockSize, affKey, createFileLockId(false), evictExclude));
// Fourth step: update path of remove file.
invokeUpdatePath(oldId, path);
// Prepare result and commit.
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(newInfo, parentId);
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = new T2<>(newInfo, parentId);
tx.commit();
@@ -3581,7 +3614,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Result or {@code} if the first parent already contained child with the same name.
* @throws IgniteCheckedException If failed.
*/
- @Nullable IgfsPathsCreateResult createDirectory(IgfsPathIds pathIds, Map<IgniteUuid, IgfsFileInfo> lockInfos,
+ @Nullable IgfsPathsCreateResult createDirectory(IgfsPathIds pathIds, Map<IgniteUuid, IgfsEntryInfo> lockInfos,
Map<String, String> dirProps) throws IgniteCheckedException {
// Check if entry we are going to write to is directory.
if (lockInfos.get(pathIds.lastExistingId()).isFile())
@@ -3604,7 +3637,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Result or {@code} if the first parent already contained child with the same name.
* @throws IgniteCheckedException If failed.
*/
- @Nullable private IgfsPathsCreateResult createFile(IgfsPathIds pathIds, Map<IgniteUuid, IgfsFileInfo> lockInfos,
+ @Nullable private IgfsPathsCreateResult createFile(IgfsPathIds pathIds, Map<IgniteUuid, IgfsEntryInfo> lockInfos,
Map<String, String> dirProps, Map<String, String> fileProps, int blockSize, @Nullable IgniteUuid affKey,
boolean evictExclude) throws IgniteCheckedException{
// Check if entry we are going to write to is directory.
@@ -3630,11 +3663,11 @@ public class IgfsMetaManager extends IgfsManager {
* @throws IgniteCheckedException If failed.
*/
private IgfsPathsCreateResult createFileOrDirectory(boolean dir, IgfsPathIds pathIds,
- Map<IgniteUuid, IgfsFileInfo> lockInfos, Map<String, String> dirProps, Map<String, String> fileProps,
+ Map<IgniteUuid, IgfsEntryInfo> lockInfos, Map<String, String> dirProps, Map<String, String> fileProps,
int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude) throws IgniteCheckedException {
// This is our starting point.
int lastExistingIdx = pathIds.lastExistingIndex();
- IgfsFileInfo lastExistingInfo = lockInfos.get(pathIds.lastExistingId());
+ IgfsEntryInfo lastExistingInfo = lockInfos.get(pathIds.lastExistingId());
// If current info already contains entry with the same name as it's child, then something
// has changed concurrently. We must re-try because we cannot get info of this unexpected
@@ -3684,7 +3717,7 @@ public class IgfsMetaManager extends IgfsManager {
}
// Third step: create leaf.
- IgfsFileInfo info;
+ IgfsEntryInfo info;
if (dir)
info = invokeAndGet(curId, new DirectoryCreateProcessor(createTime, dirProps));
@@ -3723,7 +3756,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* File create processor.
*/
- private static class FileCreateProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class FileCreateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3774,12 +3807,19 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 0L, affKey, lockId, evictExclude, props,
- createTime, createTime);
-
- info.id(entry.getKey());
+ IgfsEntryInfo info = IgfsUtils.createFile(
+ entry.getKey(),
+ blockSize,
+ 0L,
+ affKey,
+ lockId,
+ evictExclude,
+ props,
+ createTime,
+ createTime
+ );
entry.setValue(info);
@@ -3810,7 +3850,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Directory create processor.
*/
- private static class DirectoryCreateProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class DirectoryCreateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3861,15 +3901,19 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo info = new IgfsFileInfo(true, props, createTime, createTime);
+ IgfsEntryInfo info = IgfsUtils.createDirectory(
+ entry.getKey(),
+ null,
+ props,
+ createTime,
+ createTime
+ );
if (childName != null)
- info = new IgfsFileInfo(Collections.singletonMap(childName, childEntry), info);
-
- info.id(entry.getKey());
+ info = info.listing(Collections.singletonMap(childName, childEntry));
entry.setValue(info);
@@ -3906,7 +3950,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* File lock entry processor.
*/
- private static class FileLockProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class FileLockProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3931,11 +3975,11 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo oldInfo = entry.getValue();
+ IgfsEntryInfo oldInfo = entry.getValue();
- IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, lockId, oldInfo.modificationTime());
+ IgfsEntryInfo newInfo = oldInfo.lock(lockId);
entry.setValue(newInfo);
@@ -3956,7 +4000,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* File unlock entry processor.
*/
- private static class FileUnlockProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static class FileUnlockProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3981,11 +4025,11 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo old = entry.getValue();
+ IgfsEntryInfo old = entry.getValue();
- entry.setValue(new IgfsFileInfo(old, null, modificationTime));
+ entry.setValue(old.unlock(modificationTime));
return null;
}
@@ -4004,7 +4048,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* File reserve space entry processor.
*/
- private static class FileReserveSpaceProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class FileReserveSpaceProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -4034,17 +4078,15 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo oldInfo = entry.getValue();
+ IgfsEntryInfo oldInfo = entry.getValue();
IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
newMap.addRange(affRange);
- IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, oldInfo.length() + space);
-
- newInfo.fileMap(newMap);
+ IgfsEntryInfo newInfo = oldInfo.length(oldInfo.length() + space).fileMap(newMap);
entry.setValue(newInfo);
@@ -4067,7 +4109,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Update properties processor.
*/
- private static class UpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class UpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -4092,9 +4134,9 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo oldInfo = entry.getValue();
+ IgfsEntryInfo oldInfo = entry.getValue();
Map<String, String> tmp = oldInfo.properties();
@@ -4109,7 +4151,7 @@ public class IgfsMetaManager extends IgfsManager {
tmp.put(e.getKey(), e.getValue());
}
- IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, tmp);
+ IgfsEntryInfo newInfo = oldInfo.properties(tmp);
entry.setValue(newInfo);
@@ -4130,7 +4172,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Update times entry processor.
*/
- private static class UpdateTimesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static class UpdateTimesProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -4160,12 +4202,12 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo oldInfo = entry.getValue();
+ IgfsEntryInfo oldInfo = entry.getValue();
- entry.setValue(new IgfsFileInfo(oldInfo, accessTime, modificationTime));
+ entry.setValue(oldInfo.accessModificationTime(accessTime, modificationTime));
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
index 3bf1011..ef2826b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
@@ -17,10 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.DataInput;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.igfs.IgfsException;
import org.apache.ignite.igfs.IgfsMode;
@@ -33,6 +29,11 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
+import java.io.DataInput;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.concurrent.atomic.AtomicBoolean;
+
import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC;
import static org.apache.ignite.igfs.IgfsMode.PRIMARY;
import static org.apache.ignite.igfs.IgfsMode.PROXY;
@@ -55,7 +56,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
/** File descriptor. */
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
- private IgfsFileInfo fileInfo;
+ private IgfsEntryInfo fileInfo;
/** Parent ID. */
private final IgniteUuid parentId;
@@ -102,7 +103,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
* @param batch Optional secondary file system batch.
* @param metrics Local IGFS metrics.
*/
- IgfsOutputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsFileInfo fileInfo, IgniteUuid parentId,
+ IgfsOutputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsEntryInfo fileInfo, IgniteUuid parentId,
int bufSize, IgfsMode mode, @Nullable IgfsFileWorkerBatch batch, IgfsLocalMetrics metrics) {
super(path, optimizeBufferSize(bufSize, fileInfo));
@@ -143,7 +144,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
* @return Optimized buffer size.
*/
@SuppressWarnings("IfMayBeConditional")
- private static int optimizeBufferSize(int bufSize, IgfsFileInfo fileInfo) {
+ private static int optimizeBufferSize(int bufSize, IgfsEntryInfo fileInfo) {
assert bufSize > 0;
if (fileInfo == null)
@@ -292,7 +293,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
if (space > 0) {
data.awaitAllAcksReceived(fileInfo.id());
- IgfsFileInfo fileInfo0 = meta.reserveSpace(path, fileInfo.id(), space, streamRange);
+ IgfsEntryInfo fileInfo0 = meta.reserveSpace(path, fileInfo.id(), space, streamRange);
if (fileInfo0 == null)
throw new IOException("File was concurrently deleted: " + path);
@@ -407,7 +408,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
* @param fileInfo File info to build initial range for.
* @return Affinity range.
*/
- private IgfsFileAffinityRange initialStreamRange(IgfsFileInfo fileInfo) {
+ private IgfsFileAffinityRange initialStreamRange(IgfsEntryInfo fileInfo) {
if (!igfsCtx.configuration().isFragmentizerEnabled())
return null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
index 1f669b0..2903239 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
@@ -267,10 +267,10 @@ public class IgfsPathIds {
* @param infos Info.
* @return {@code True} if full integrity is preserved.
*/
- public boolean verifyIntegrity(Map<IgniteUuid, IgfsFileInfo> infos) {
+ public boolean verifyIntegrity(Map<IgniteUuid, IgfsEntryInfo> infos) {
for (int i = 0; i <= lastExistingIdx; i++) {
IgniteUuid curId = ids[i];
- IgfsFileInfo curInfo = infos.get(curId);
+ IgfsEntryInfo curInfo = infos.get(curId);
// Check if required ID is there.
if (curInfo == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
index 3b620f8..9462aa4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
@@ -31,7 +31,7 @@ public class IgfsPathsCreateResult {
private final List<IgfsPath> paths;
/** Info of the last created file. */
- private final IgfsFileInfo info;
+ private final IgfsEntryInfo info;
/** Parent ID. */
private final IgniteUuid parentId;
@@ -43,7 +43,7 @@ public class IgfsPathsCreateResult {
* @param info Info of the last created file.
* @param parentId Parent ID.
*/
- public IgfsPathsCreateResult(List<IgfsPath> paths, IgfsFileInfo info, IgniteUuid parentId) {
+ public IgfsPathsCreateResult(List<IgfsPath> paths, IgfsEntryInfo info, IgniteUuid parentId) {
this.paths = paths;
this.info = info;
this.parentId = parentId;
@@ -59,7 +59,7 @@ public class IgfsPathsCreateResult {
/**
* @return Info of the last created file.
*/
- public IgfsFileInfo info() {
+ public IgfsEntryInfo info() {
return info;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java
index 54c0525..76d6be8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java
@@ -24,7 +24,7 @@ import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadabl
*/
public class IgfsSecondaryInputStreamDescriptor {
/** File info in the primary file system. */
- private final IgfsFileInfo info;
+ private final IgfsEntryInfo info;
/** Secondary file system input stream wrapper. */
private final IgfsSecondaryFileSystemPositionedReadable secReader;
@@ -35,7 +35,7 @@ public class IgfsSecondaryInputStreamDescriptor {
* @param info File info in the primary file system.
* @param secReader Secondary file system reader.
*/
- IgfsSecondaryInputStreamDescriptor(IgfsFileInfo info, IgfsSecondaryFileSystemPositionedReadable secReader) {
+ IgfsSecondaryInputStreamDescriptor(IgfsEntryInfo info, IgfsSecondaryFileSystemPositionedReadable secReader) {
assert info != null;
assert secReader != null;
@@ -46,7 +46,7 @@ public class IgfsSecondaryInputStreamDescriptor {
/**
* @return File info in the primary file system.
*/
- IgfsFileInfo info() {
+ IgfsEntryInfo info() {
return info;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java
index dd6372f..507ccfc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java
@@ -17,9 +17,10 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.OutputStream;
import org.apache.ignite.lang.IgniteUuid;
+import java.io.OutputStream;
+
/**
* Descriptor of an output stream opened to the secondary file system.
*/
@@ -28,7 +29,7 @@ public class IgfsSecondaryOutputStreamDescriptor {
private final IgniteUuid parentId;
/** File info in the primary file system. */
- private final IgfsFileInfo info;
+ private final IgfsEntryInfo info;
/** Output stream to the secondary file system. */
private final OutputStream out;
@@ -40,7 +41,7 @@ public class IgfsSecondaryOutputStreamDescriptor {
* @param info File info in the primary file system.
* @param out Output stream to the secondary file system.
*/
- IgfsSecondaryOutputStreamDescriptor(IgniteUuid parentId, IgfsFileInfo info, OutputStream out) {
+ IgfsSecondaryOutputStreamDescriptor(IgniteUuid parentId, IgfsEntryInfo info, OutputStream out) {
assert parentId != null;
assert info != null;
assert out != null;
@@ -60,7 +61,7 @@ public class IgfsSecondaryOutputStreamDescriptor {
/**
* @return File info in the primary file system.
*/
- IgfsFileInfo info() {
+ IgfsEntryInfo info() {
return info;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index ef7d5c7..325f636 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -43,6 +43,7 @@ import org.apache.ignite.transactions.Transaction;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
+import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
@@ -321,4 +322,71 @@ public class IgfsUtils {
}
}
}
+
+ /**
+ * Create empty directory with the given ID.
+ *
+ * @param id ID.
+ * @return File info.
+ */
+ public static IgfsDirectoryInfo createDirectory(IgniteUuid id) {
+ return createDirectory(id, null, null);
+ }
+
+ /**
+ * Create directory.
+ *
+ * @param id ID.
+ * @param listing Listing.
+ * @param props Properties.
+ * @return File info.
+ */
+ public static IgfsDirectoryInfo createDirectory(
+ IgniteUuid id,
+ @Nullable Map<String, IgfsListingEntry> listing,
+ @Nullable Map<String, String> props) {
+ long time = System.currentTimeMillis();
+
+ return createDirectory(id, listing, props, time, time);
+ }
+
+ /**
+ * Create directory.
+ *
+ * @param id ID.
+ * @param listing Listing.
+ * @param props Properties.
+ * @param createTime Create time.
+ * @param modificationTime Modification time.
+ * @return File info.
+ */
+ public static IgfsDirectoryInfo createDirectory(
+ IgniteUuid id,
+ @Nullable Map<String, IgfsListingEntry> listing,
+ @Nullable Map<String,String> props,
+ long createTime,
+ long modificationTime) {
+ return new IgfsDirectoryInfo(id, listing, props, createTime, modificationTime);
+ }
+
+ /**
+ * Create file.
+ *
+ * @param id File ID.
+ * @param blockSize Block size.
+ * @param len Length.
+ * @param affKey Affinity key.
+ * @param lockId Lock ID.
+ * @param evictExclude Evict exclude flag.
+ * @param props Properties.
+ * @param accessTime Access time.
+ * @param modificationTime Modification time.
+ * @return File info.
+ */
+ public static IgfsFileInfo createFile(IgniteUuid id, int blockSize, long len, @Nullable IgniteUuid affKey,
+ @Nullable IgniteUuid lockId, boolean evictExclude, @Nullable Map<String, String> props, long accessTime,
+ long modificationTime) {
+ return new IgfsFileInfo(id, blockSize, len, affKey, props, null, lockId, accessTime, modificationTime,
+ evictExclude);
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/package-info.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/package-info.java
index ea70f49..20051ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/package-info.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/package-info.java
@@ -17,6 +17,6 @@
/**
* <!-- Package description. -->
- * Contains high performance file system processer.
+ * Contains high performance file system processor.
*/
package org.apache.ignite.internal.processors.igfs;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java
index 22f427a..d52a918 100644
--- a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java
@@ -22,8 +22,8 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.igfs.IgfsCommonAbstractTest;
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsEx;
-import org.apache.ignite.internal.processors.igfs.IgfsFileInfo;
import org.apache.ignite.internal.processors.igfs.IgfsMetaManager;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -139,7 +139,7 @@ public class IgfsFragmentizerAbstractSelfTest extends IgfsCommonAbstractTest {
if (fileId == null)
throw new IgfsPathNotFoundException("File not found: " + path);
- IgfsFileInfo fileInfo = meta.info(fileId);
+ IgfsEntryInfo fileInfo = meta.info(fileId);
do {
if (fileInfo == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
index 2acf59c..edec572 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
@@ -3081,7 +3081,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param igfs The IGFS instance.
* @return The data cache.
*/
- protected static GridCacheAdapter<IgniteUuid, IgfsFileInfo> getMetaCache(IgniteFileSystem igfs) {
+ protected static GridCacheAdapter<IgniteUuid, IgfsEntryInfo> getMetaCache(IgniteFileSystem igfs) {
String dataCacheName = igfs.configuration().getMetaCacheName();
IgniteEx igniteEx = ((IgfsEx)igfs).context().kernalContext().grid();
@@ -3111,7 +3111,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
entry.getValue().await();
}
catch (IgniteCheckedException e) {
- if (!entry.getValue().cancelled())
+ if (!(e instanceof IgfsFileWorkerBatchCancelledException))
throw e;
}
}
[3/3] ignite git commit: IGNITE-2813: IGFS: Optimized metadata values
splitting file and directory into separate classes.
Posted by vo...@apache.org.
IGNITE-2813: IGFS: Optimized metadata values splitting file and directory into separate classes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4794f87b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4794f87b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4794f87b
Branch: refs/heads/master
Commit: 4794f87b5ebe2865b6afa541ce601df42fb8f6e3
Parents: 4af5316
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Mar 18 17:45:48 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Mar 18 17:45:48 2016 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsDataManager.java | 103 ++--
.../processors/igfs/IgfsDeleteWorker.java | 27 +-
.../processors/igfs/IgfsDirectoryInfo.java | 210 ++++++++
.../internal/processors/igfs/IgfsEntryInfo.java | 305 +++++++++++
.../internal/processors/igfs/IgfsFileImpl.java | 15 +-
.../internal/processors/igfs/IgfsFileInfo.java | 500 +++----------------
.../processors/igfs/IgfsFileWorkerBatch.java | 75 +--
.../IgfsFileWorkerBatchCancelledException.java | 51 ++
.../igfs/IgfsFragmentizerManager.java | 64 ++-
.../internal/processors/igfs/IgfsImpl.java | 28 +-
.../processors/igfs/IgfsInputStreamAdapter.java | 5 +-
.../processors/igfs/IgfsInputStreamImpl.java | 32 +-
.../processors/igfs/IgfsIpcHandler.java | 16 +-
.../processors/igfs/IgfsListingEntry.java | 12 +-
.../processors/igfs/IgfsMetaManager.java | 432 ++++++++--------
.../processors/igfs/IgfsOutputStreamImpl.java | 19 +-
.../internal/processors/igfs/IgfsPathIds.java | 4 +-
.../processors/igfs/IgfsPathsCreateResult.java | 6 +-
.../IgfsSecondaryInputStreamDescriptor.java | 6 +-
.../IgfsSecondaryOutputStreamDescriptor.java | 9 +-
.../internal/processors/igfs/IgfsUtils.java | 68 +++
.../internal/processors/igfs/package-info.java | 2 +-
.../igfs/IgfsFragmentizerAbstractSelfTest.java | 4 +-
.../processors/igfs/IgfsAbstractSelfTest.java | 4 +-
.../igfs/IgfsDataManagerSelfTest.java | 55 +-
.../igfs/IgfsDualAbstractSelfTest.java | 17 +-
.../processors/igfs/IgfsFileInfoSelfTest.java | 31 +-
.../igfs/IgfsMetaManagerSelfTest.java | 34 +-
.../processors/igfs/IgfsProcessorSelfTest.java | 31 +-
.../processors/igfs/IgfsSizeSelfTest.java | 35 +-
.../processors/igfs/IgfsStreamsSelfTest.java | 25 +-
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 32 +-
.../igfs/HadoopIgfsDualAbstractSelfTest.java | 11 +-
.../IgniteHadoopFileSystemLoggerSelfTest.java | 21 +-
.../testsuites/IgniteHadoopTestSuite.java | 26 +-
35 files changed, 1321 insertions(+), 994 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index 125d728..3825086 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@ -17,35 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.DataInput;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Deque;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.MutableEntry;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteException;
@@ -87,6 +58,36 @@ import org.apache.ignite.thread.IgniteThreadPoolExecutor;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.MutableEntry;
+import java.io.DataInput;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.internal.GridTopic.TOPIC_IGFS;
@@ -368,7 +369,7 @@ public class IgfsDataManager extends IgfsManager {
* @return Requested data block or {@code null} if nothing found.
* @throws IgniteCheckedException If failed.
*/
- @Nullable public IgniteInternalFuture<byte[]> dataBlock(final IgfsFileInfo fileInfo, final IgfsPath path,
+ @Nullable public IgniteInternalFuture<byte[]> dataBlock(final IgfsEntryInfo fileInfo, final IgfsPath path,
final long blockIdx, @Nullable final IgfsSecondaryFileSystemPositionedReadable secReader)
throws IgniteCheckedException {
//assert validTxState(any); // Allow this method call for any transaction state.
@@ -476,7 +477,7 @@ public class IgfsDataManager extends IgfsManager {
* @param fileInfo File info of file opened to write.
* @return Future that will be completed when all ack messages are received or when write failed.
*/
- public IgniteInternalFuture<Boolean> writeStart(IgfsFileInfo fileInfo) {
+ public IgniteInternalFuture<Boolean> writeStart(IgfsEntryInfo fileInfo) {
WriteCompletionFuture fut = new WriteCompletionFuture(fileInfo.id());
WriteCompletionFuture oldFut = pendingWrites.putIfAbsent(fileInfo.id(), fut);
@@ -495,7 +496,7 @@ public class IgfsDataManager extends IgfsManager {
*
* @param fileInfo File info being written.
*/
- public void writeClose(IgfsFileInfo fileInfo) {
+ public void writeClose(IgfsEntryInfo fileInfo) {
WriteCompletionFuture fut = pendingWrites.get(fileInfo.id());
if (fut != null)
@@ -524,7 +525,7 @@ public class IgfsDataManager extends IgfsManager {
* @throws IgniteCheckedException If failed.
*/
@Nullable public byte[] storeDataBlocks(
- IgfsFileInfo fileInfo,
+ IgfsEntryInfo fileInfo,
long reservedLen,
@Nullable byte[] remainder,
int remainderLen,
@@ -557,7 +558,7 @@ public class IgfsDataManager extends IgfsManager {
* @throws IOException If store failed.
*/
@Nullable public byte[] storeDataBlocks(
- IgfsFileInfo fileInfo,
+ IgfsEntryInfo fileInfo,
long reservedLen,
@Nullable byte[] remainder,
int remainderLen,
@@ -579,7 +580,7 @@ public class IgfsDataManager extends IgfsManager {
* @param fileInfo File details to remove data for.
* @return Delete future that will be completed when file is actually erased.
*/
- public IgniteInternalFuture<Object> delete(IgfsFileInfo fileInfo) {
+ public IgniteInternalFuture<Object> delete(IgfsEntryInfo fileInfo) {
if (!fileInfo.isFile()) {
if (log.isDebugEnabled())
log.debug("Cannot delete content of not-data file: " + fileInfo);
@@ -595,7 +596,7 @@ public class IgfsDataManager extends IgfsManager {
* @param fileInfo File info.
* @return Block key.
*/
- public IgfsBlockKey blockKey(long blockIdx, IgfsFileInfo fileInfo) {
+ public IgfsBlockKey blockKey(long blockIdx, IgfsEntryInfo fileInfo) {
if (fileInfo.affinityKey() != null)
return new IgfsBlockKey(fileInfo.id(), fileInfo.affinityKey(), fileInfo.evictExclude(), blockIdx);
@@ -616,7 +617,7 @@ public class IgfsDataManager extends IgfsManager {
* @param range Range to clean up.
* @param cleanNonColocated {@code True} if all blocks should be cleaned.
*/
- public void cleanBlocks(IgfsFileInfo fileInfo, IgfsFileAffinityRange range, boolean cleanNonColocated) {
+ public void cleanBlocks(IgfsEntryInfo fileInfo, IgfsFileAffinityRange range, boolean cleanNonColocated) {
long startIdx = range.startOffset() / fileInfo.blockSize();
long endIdx = range.endOffset() / fileInfo.blockSize();
@@ -646,7 +647,7 @@ public class IgfsDataManager extends IgfsManager {
* @param fileInfo File info to move data for.
* @param range Range to move.
*/
- public void spreadBlocks(IgfsFileInfo fileInfo, IgfsFileAffinityRange range) {
+ public void spreadBlocks(IgfsEntryInfo fileInfo, IgfsFileAffinityRange range) {
long startIdx = range.startOffset() / fileInfo.blockSize();
long endIdx = range.endOffset() / fileInfo.blockSize();
@@ -721,7 +722,7 @@ public class IgfsDataManager extends IgfsManager {
* @return Affinity blocks locations.
* @throws IgniteCheckedException If failed.
*/
- public Collection<IgfsBlockLocation> affinity(IgfsFileInfo info, long start, long len)
+ public Collection<IgfsBlockLocation> affinity(IgfsEntryInfo info, long start, long len)
throws IgniteCheckedException {
return affinity(info, start, len, 0);
}
@@ -736,7 +737,7 @@ public class IgfsDataManager extends IgfsManager {
* @return Affinity blocks locations.
* @throws IgniteCheckedException If failed.
*/
- public Collection<IgfsBlockLocation> affinity(IgfsFileInfo info, long start, long len, long maxLen)
+ public Collection<IgfsBlockLocation> affinity(IgfsEntryInfo info, long start, long len, long maxLen)
throws IgniteCheckedException {
assert validTxState(false);
assert info.isFile() : "Failed to get affinity (not a file): " + info;
@@ -845,7 +846,7 @@ public class IgfsDataManager extends IgfsManager {
* @param maxLen Maximum allowed split length.
* @param res Result collection to add regions to.
*/
- private void affinity0(IgfsFileInfo info, long start, long len, long maxLen, Deque<IgfsBlockLocation> res) {
+ private void affinity0(IgfsEntryInfo info, long start, long len, long maxLen, Deque<IgfsBlockLocation> res) {
long firstGrpIdx = start / grpBlockSize;
long limitGrpIdx = (start + len + grpBlockSize - 1) / grpBlockSize;
@@ -1327,7 +1328,7 @@ public class IgfsDataManager extends IgfsManager {
*/
private IgfsBlockKey createBlockKey(
long block,
- IgfsFileInfo fileInfo,
+ IgfsEntryInfo fileInfo,
IgfsFileAffinityRange locRange
) {
// If affinityKey is present, return block key as is.
@@ -1373,7 +1374,7 @@ public class IgfsDataManager extends IgfsManager {
* @return Data remainder if {@code flush} flag is {@code false}.
*/
@Nullable public byte[] storeDataBlocks(
- IgfsFileInfo fileInfo,
+ IgfsEntryInfo fileInfo,
long reservedLen,
@Nullable byte[] remainder,
final int remainderLen,
@@ -1632,10 +1633,10 @@ public class IgfsDataManager extends IgfsManager {
*/
private class AsyncDeleteWorker extends GridWorker {
/** File info for stop request. */
- private final IgfsFileInfo stopInfo = new IgfsFileInfo();
+ private final IgfsEntryInfo stopInfo;
/** Delete requests queue. */
- private BlockingQueue<IgniteBiTuple<GridFutureAdapter<Object>, IgfsFileInfo>> delReqs =
+ private BlockingQueue<IgniteBiTuple<GridFutureAdapter<Object>, IgfsEntryInfo>> delReqs =
new LinkedBlockingQueue<>();
/**
@@ -1645,6 +1646,10 @@ public class IgfsDataManager extends IgfsManager {
*/
protected AsyncDeleteWorker(@Nullable String gridName, String name, IgniteLogger log) {
super(gridName, name, log);
+
+ long time = System.currentTimeMillis();
+
+ stopInfo = IgfsUtils.createDirectory(IgniteUuid.randomUuid());
}
/**
@@ -1658,7 +1663,7 @@ public class IgfsDataManager extends IgfsManager {
* @param info File info to delete.
* @return Future which completes when entry is actually removed.
*/
- private IgniteInternalFuture<Object> deleteAsync(IgfsFileInfo info) {
+ private IgniteInternalFuture<Object> deleteAsync(IgfsEntryInfo info) {
GridFutureAdapter<Object> fut = new GridFutureAdapter<>();
delReqs.offer(F.t(fut, info));
@@ -1670,10 +1675,10 @@ public class IgfsDataManager extends IgfsManager {
@Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException {
try {
while (!isCancelled()) {
- IgniteBiTuple<GridFutureAdapter<Object>, IgfsFileInfo> req = delReqs.take();
+ IgniteBiTuple<GridFutureAdapter<Object>, IgfsEntryInfo> req = delReqs.take();
GridFutureAdapter<Object> fut = req.get1();
- IgfsFileInfo fileInfo = req.get2();
+ IgfsEntryInfo fileInfo = req.get2();
// Identity check.
if (fileInfo == stopInfo) {
@@ -1734,7 +1739,7 @@ public class IgfsDataManager extends IgfsManager {
if (log.isDebugEnabled())
log.debug("Stopping asynchronous igfs file delete thread: " + name());
- IgniteBiTuple<GridFutureAdapter<Object>, IgfsFileInfo> req = delReqs.poll();
+ IgniteBiTuple<GridFutureAdapter<Object>, IgfsEntryInfo> req = delReqs.poll();
while (req != null) {
req.get1().onCancelled();
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
index ffddd3e..f6b26ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
@@ -17,13 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
@@ -37,6 +30,14 @@ import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_PURGED;
import static org.apache.ignite.internal.GridTopic.TOPIC_IGFS;
@@ -162,7 +163,7 @@ public class IgfsDeleteWorker extends IgfsThread {
* @param trashId Trash ID.
*/
private void delete(IgniteUuid trashId) {
- IgfsFileInfo info = null;
+ IgfsEntryInfo info = null;
try {
info = meta.info(trashId);
@@ -220,7 +221,7 @@ public class IgfsDeleteWorker extends IgfsThread {
assert id != null;
while (true) {
- IgfsFileInfo info = meta.info(id);
+ IgfsEntryInfo info = meta.info(id);
if (info != null) {
if (info.isDirectory()) {
@@ -234,7 +235,7 @@ public class IgfsDeleteWorker extends IgfsThread {
assert info.isFile();
// Lock the file with special lock Id to prevent concurrent writing:
- IgfsFileInfo lockedInfo = meta.lock(id, true);
+ IgfsEntryInfo lockedInfo = meta.lock(id, true);
if (lockedInfo == null)
return false; // File is locked, we cannot delete it.
@@ -271,7 +272,7 @@ public class IgfsDeleteWorker extends IgfsThread {
assert id != null;
while (true) {
- IgfsFileInfo info = meta.info(id);
+ IgfsEntryInfo info = meta.info(id);
if (info != null) {
assert info.isDirectory();
@@ -298,12 +299,12 @@ public class IgfsDeleteWorker extends IgfsThread {
failedFiles++;
}
else {
- IgfsFileInfo fileInfo = meta.info(entry.getValue().fileId());
+ IgfsEntryInfo fileInfo = meta.info(entry.getValue().fileId());
if (fileInfo != null) {
assert fileInfo.isFile();
- IgfsFileInfo lockedInfo = meta.lock(fileInfo.id(), true);
+ IgfsEntryInfo lockedInfo = meta.lock(fileInfo.id(), true);
if (lockedInfo == null)
// File is already locked:
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
new file mode 100644
index 0000000..01c8ff9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
@@ -0,0 +1,210 @@
+/*
+ * 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.igfs;
+
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * IGFS directory info.
+ */
+public class IgfsDirectoryInfo extends IgfsEntryInfo {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Directory listing. */
+ @GridToStringInclude
+ private Map<String, IgfsListingEntry> listing;
+
+ /**
+ * {@link Externalizable} support.
+ */
+ public IgfsDirectoryInfo() {
+ // No-op.
+ }
+
+ /**
+ * Update length.
+ *
+ * @param len New length.
+ * @return Updated file info.
+ */
+ public IgfsEntryInfo length(long len) {
+ throw new UnsupportedOperationException("length");
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsDirectoryInfo listing(@Nullable Map<String, IgfsListingEntry> listing) {
+ IgfsDirectoryInfo res = copy();
+
+ res.listing = listing;
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo lock(IgniteUuid lockId) {
+ throw new UnsupportedOperationException("lock");
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo unlock(long modificationTime) {
+ throw new UnsupportedOperationException("unlock");
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo fileMap(IgfsFileMap fileMap) {
+ throw new UnsupportedOperationException("fileMap");
+ }
+
+ /**
+ * Constructs file info.
+ *
+ * @param id ID or {@code null} to generate it automatically.
+ * @param listing Directory listing.
+ * @param props File properties.
+ * @param accessTime Last access time.
+ * @param modificationTime Last modification time.
+ */
+ IgfsDirectoryInfo(IgniteUuid id, @Nullable Map<String, IgfsListingEntry> listing,
+ @Nullable Map<String, String> props, long accessTime, long modificationTime) {
+ super(id, props, accessTime, modificationTime);
+
+ this.listing = listing;
+ }
+
+ /** {@inheritDoc} */
+ protected IgfsDirectoryInfo copy() {
+ return new IgfsDirectoryInfo(id, listing, props, accessTime, modificationTime);
+ }
+
+ /** {@inheritDoc} */
+ public boolean isFile() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ public long length() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ public int blockSize() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ public long blocksCount() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ public Map<String, IgfsListingEntry> listing() {
+ return listing != null ? listing : Collections.<String, IgfsListingEntry>emptyMap();
+ }
+
+ /** {@inheritDoc} */
+ public boolean hasChildren() {
+ return !F.isEmpty(listing);
+ }
+
+ /** {@inheritDoc} */
+ public boolean hasChild(String name) {
+ return listing != null && listing.containsKey(name);
+ }
+
+ /** {@inheritDoc} */
+ public boolean hasChild(String name, IgniteUuid expId) {
+ if (listing != null) {
+ IgfsListingEntry entry = listing.get(name);
+
+ if (entry != null)
+ return F.eq(expId, entry.fileId());
+ }
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable public IgniteUuid affinityKey() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ public IgfsFileMap fileMap() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable public IgniteUuid lockId() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ public boolean evictExclude() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+
+ out.writeObject(listing);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+
+ listing = (Map<String, IgfsListingEntry>)in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return id.hashCode() ^ (props == null ? 0 : props.hashCode());
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ if (obj == this)
+ return true;
+
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+
+ IgfsDirectoryInfo that = (IgfsDirectoryInfo)obj;
+
+ return id.equals(that.id) && F.eq(props, that.props);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsDirectoryInfo.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
new file mode 100644
index 0000000..c5b1111
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
@@ -0,0 +1,305 @@
+/*
+ * 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.igfs;
+
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Base IGFS entry.
+ */
+public abstract class IgfsEntryInfo implements Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** ID. */
+ protected IgniteUuid id;
+
+ /** Properties. */
+ protected Map<String, String> props;
+
+ /** Last access time. */
+ protected long accessTime;
+
+ /** Last modification time. */
+ protected long modificationTime;
+
+ /** Original file path. This is a helper field used only during real file delete. */
+ protected IgfsPath path;
+
+ /**
+ * Default constructor.
+ */
+ protected IgfsEntryInfo() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param id ID.
+ * @param props Properties.
+ * @param accessTime Access time.
+ * @param modificationTime Modification time.
+ */
+ protected IgfsEntryInfo(IgniteUuid id, @Nullable Map<String, String> props, long accessTime,
+ long modificationTime) {
+ assert id != null;
+
+ this.id = id;
+ this.props = props == null || props.isEmpty() ? null : props;
+ this.accessTime = accessTime;
+ this.modificationTime = modificationTime;
+ }
+
+ /**
+ * Gets this item ID.
+ *
+ * @return This item ID.
+ */
+ public IgniteUuid id() {
+ return id;
+ }
+
+ /**
+ * Get properties of the file.
+ *
+ * @return Properties of the file.
+ */
+ public Map<String, String> properties() {
+ return props == null ? Collections.<String, String>emptyMap() : Collections.unmodifiableMap(props);
+ }
+
+ /**
+ * @return Last access time.
+ */
+ public long accessTime() {
+ return accessTime;
+ }
+
+ /**
+ * @return Last modification time.
+ */
+ public long modificationTime() {
+ return modificationTime;
+ }
+
+ /**
+ * @return Original file path. This is a helper field used only in some operations like delete.
+ */
+ public IgfsPath path() {
+ return path;
+ }
+
+ /**
+ * @return {@code True} if this is a file.
+ */
+ public abstract boolean isFile();
+
+ /**
+ * Update length.
+ *
+ * @param len New length.
+ * @return Updated file info.
+ */
+ public abstract IgfsEntryInfo length(long len);
+
+ /**
+ * Update listing.
+ *
+ * @param listing Listing.
+ * @return Updated file info.
+ */
+ public abstract IgfsEntryInfo listing(@Nullable Map<String, IgfsListingEntry> listing);
+
+ /**
+ * Update properties.
+ *
+ * @param props Properties.
+ * @return Updated file info.
+ */
+ public IgfsEntryInfo properties(@Nullable Map<String, String> props) {
+ IgfsEntryInfo res = copy();
+
+ res.props = props;
+
+ return res;
+ }
+
+ /**
+ * Update path.
+ *
+ * @param path Path.
+ * @return Updated file info.
+ */
+ public IgfsEntryInfo path(IgfsPath path) {
+ IgfsEntryInfo res = copy();
+
+ res.path = path;
+
+ return res;
+ }
+
+ /**
+ * Update access and modification time.
+ *
+ * @param accessTime Access time.
+ * @param modificationTime Modification time.
+ * @return Updated file info.
+ */
+ public IgfsEntryInfo accessModificationTime(long accessTime, long modificationTime) {
+ IgfsEntryInfo res = copy();
+
+ res.accessTime = accessTime;
+ res.modificationTime = modificationTime;
+
+ return res;
+ }
+
+ /**
+ * Lock file.
+ *
+ * @param lockId Lock ID.
+ * @return Update file info.
+ */
+ public abstract IgfsEntryInfo lock(IgniteUuid lockId);
+
+ /**
+ * Unlock file.
+ *
+ * @param modificationTime Modification time.
+ * @return Updated file info.
+ */
+ public abstract IgfsEntryInfo unlock(long modificationTime);
+
+ /**
+ * Update file map.
+ *
+ * @param fileMap File affinity map.
+ * @return Updated file info.
+ */
+ public abstract IgfsEntryInfo fileMap(IgfsFileMap fileMap);
+
+ /**
+ * Copy file info.
+ *
+ * @return Copy.
+ */
+ protected abstract IgfsEntryInfo copy();
+
+ /**
+ * @return {@code True} if this is a directory.
+ */
+ public boolean isDirectory() {
+ return !isFile();
+ }
+
+ /**
+ * Get file size.
+ *
+ * @return File size.
+ */
+ public abstract long length();
+
+ /**
+ * Get single data block size to store this file.
+ *
+ * @return Single data block size to store this file.
+ */
+ public abstract int blockSize();
+
+ /**
+ * @return Number of data blocks to store this file.
+ */
+ public abstract long blocksCount();
+
+ /**
+ * @return Directory listing.
+ */
+ public abstract Map<String, IgfsListingEntry> listing();
+
+ /**
+ * @return {@code True} if at least one child exists.
+ */
+ public abstract boolean hasChildren();
+
+ /**
+ * @param name Child name.
+ * @return {@code True} if child with such name exists.
+ */
+ public abstract boolean hasChild(String name);
+
+ /**
+ * @param name Child name.
+ * @param expId Expected child ID.
+ * @return {@code True} if child with such name exists.
+ */
+ public abstract boolean hasChild(String name, IgniteUuid expId);
+
+ /**
+ * @return Affinity key used for single-node file collocation. If {@code null}, usual
+ * mapper procedure is used for block affinity detection.
+ */
+ @Nullable public abstract IgniteUuid affinityKey();
+
+ /**
+ * @return File affinity map.
+ */
+ public abstract IgfsFileMap fileMap();
+
+ /**
+ * Get lock ID.
+ *
+ * @return Lock ID if file is locked or {@code null} if file is free of locks.
+ */
+ @Nullable public abstract IgniteUuid lockId();
+
+ /**
+ * Get evict exclude flag.
+ *
+ * @return Evict exclude flag.
+ */
+ public abstract boolean evictExclude();
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeGridUuid(out, id);
+ U.writeStringMap(out, props);
+ out.writeLong(accessTime);
+ out.writeLong(modificationTime);
+ out.writeObject(path);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = U.readGridUuid(in);
+ props = U.readStringMap(in);
+ accessTime = in.readLong();
+ modificationTime = in.readLong();
+ path = (IgfsPath)in.readObject();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
index 3576a06..be8d0fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
@@ -17,12 +17,6 @@
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.Collections;
-import java.util.Map;
import org.apache.ignite.igfs.IgfsFile;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.util.typedef.internal.A;
@@ -31,6 +25,13 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collections;
+import java.util.Map;
+
/**
* File or directory information.
*/
@@ -97,7 +98,7 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable {
*
* @param path Path.
*/
- public IgfsFileImpl(IgfsPath path, IgfsFileInfo info, long globalGrpBlockSize) {
+ public IgfsFileImpl(IgfsPath path, IgfsEntryInfo info, long globalGrpBlockSize) {
A.notNull(path, "path");
A.notNull(info, "info");
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/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 13c54ff..30f505e 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
@@ -17,44 +17,32 @@
package org.apache.ignite.internal.processors.igfs;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
+
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Collections;
import java.util.Map;
-import org.apache.ignite.configuration.FileSystemConfiguration;
-import org.apache.ignite.igfs.IgfsPath;
-import org.apache.ignite.internal.util.GridLeanMap;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteUuid;
-import org.jetbrains.annotations.Nullable;
/**
- * Unmodifiable file information.
+ * IGFS file info.
*/
-public final class IgfsFileInfo implements Externalizable {
+public final class IgfsFileInfo extends IgfsEntryInfo {
/** */
private static final long serialVersionUID = 0L;
- /** Special access time value, indicating that the modification time value should be taken. */
- private static final long ACCESS_TIME_TAKE_MODIFICATION_TIME = -1L;
-
- /** Info ID. */
- private IgniteUuid id;
-
/** File length in bytes. */
private long len;
/** File block size, {@code zero} for directories. */
private int blockSize;
- /** File properties. */
- private Map<String, String> props;
-
/** File lock ID. */
private IgniteUuid lockId;
@@ -64,491 +52,181 @@ public final class IgfsFileInfo implements Externalizable {
/** File affinity map. */
private IgfsFileMap fileMap;
- /** Last access time. Modified on-demand. */
- private long accessTime;
-
- /** Last modification time. */
- private long modificationTime;
-
- /** Directory listing. */
- @GridToStringInclude
- private Map<String, IgfsListingEntry> listing;
-
/** Whether data blocks of this entry should never be excluded. */
private boolean evictExclude;
/**
- * Original file path. This is a helper field used only in some
- * operations like delete.
- */
- private IgfsPath path;
-
- /**
* {@link Externalizable} support.
*/
public IgfsFileInfo() {
- this(IgfsUtils.ROOT_ID);
+ // No-op.
}
- /**
- * Constructs directory file info with the given ID.
- *
- * @param id ID.
- */
- IgfsFileInfo(IgniteUuid id) {
- this(true, id, 0, 0, null, null, null, null, false, ACCESS_TIME_TAKE_MODIFICATION_TIME,
- System.currentTimeMillis(), false);
- }
+ /** {@inheritDoc} */
+ @Override public IgfsFileInfo length(long len) {
+ IgfsFileInfo res = copy();
- /**
- * Constructs directory or file info with
- * {@link org.apache.ignite.configuration.FileSystemConfiguration#DFLT_BLOCK_SIZE default} block size.
- *
- * @param isDir Constructs directory info if {@code true} or file info if {@code false}.
- * @param props Meta properties to set.
- * @param accessTime The access time.
- * @param modificationTime The modification time.
- */
- public IgfsFileInfo(boolean isDir, @Nullable Map<String, String> props, long accessTime, long modificationTime) {
- this(isDir, null, isDir ? 0 : FileSystemConfiguration.DFLT_BLOCK_SIZE, 0, null, null, props, null, false,
- accessTime, modificationTime, false);
- }
+ res.len = len;
- /**
- * Consturcts directory with random ID and provided listing.
- *
- * @param listing Listing.
- */
- IgfsFileInfo(Map<String, IgfsListingEntry> listing) {
- this(listing, (Map<String,String>)null);
+ return res;
}
- /**
- * Consturcts directory with random ID, provided listing and properties.
- *
- * @param listing Listing.
- * @param props The properties to set for the new directory.
- */
- IgfsFileInfo(@Nullable Map<String, IgfsListingEntry> listing, @Nullable Map<String,String> props) {
- this(true/*dir*/, null, 0, 0, null, listing, props, null, false, ACCESS_TIME_TAKE_MODIFICATION_TIME,
- System.currentTimeMillis(), false);
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo listing(@Nullable Map<String, IgfsListingEntry> listing) {
+ throw new UnsupportedOperationException("listing");
}
- /**
- * Constructs file info.
- *
- * @param blockSize Block size.
- * @param len Length.
- * @param affKey Affinity key.
- * @param lockId Lock ID.
- * @param props Properties.
- * @param evictExclude Evict exclude flag.
- * @param accessTime The access time.
- * @param modificationTime The modification time.
- */
- public IgfsFileInfo(int blockSize, long len, @Nullable IgniteUuid affKey, @Nullable IgniteUuid lockId,
- boolean evictExclude, @Nullable Map<String, String> props, long accessTime, long modificationTime) {
- this(false, null, blockSize, len, affKey, null, props, lockId, true, accessTime, modificationTime,
- evictExclude);
- }
+ /** {@inheritDoc} */
+ @Override public IgfsFileInfo lock(IgniteUuid lockId) {
+ assert lockId != null;
+ assert this.lockId == null;
- /**
- * Constructs file information.
- *
- * @param info File information to copy data from.
- * @param len Size of a file.
- */
- IgfsFileInfo(IgfsFileInfo info, long len) {
- this(info.isDirectory(), info.id, info.blockSize, len, info.affKey, info.listing, info.props, info.fileMap(),
- info.lockId, true, info.accessTime, info.modificationTime, info.evictExclude());
- }
+ IgfsFileInfo res = copy();
- /**
- * Constructs file info.
- *
- * @param info File info.
- * @param accessTime Last access time.
- * @param modificationTime Last modification time.
- */
- IgfsFileInfo(IgfsFileInfo info, long accessTime, long modificationTime) {
- this(info.isDirectory(), info.id, info.blockSize, info.len, info.affKey, info.listing, info.props,
- info.fileMap(), info.lockId, false, accessTime, modificationTime, info.evictExclude());
- }
+ res.lockId = lockId;
- /**
- * Constructs file information.
- *
- * @param info File information to copy data from.
- * @param props File properties to set.
- */
- IgfsFileInfo(IgfsFileInfo info, @Nullable Map<String, String> props) {
- this(info.isDirectory(), info.id, info.blockSize, info.len, info.affKey, info.listing, props,
- info.fileMap(), info.lockId, true, info.accessTime, info.modificationTime, info.evictExclude());
+ return res;
}
- /**
- * Constructs file info.
- *
- * @param blockSize Block size,
- * @param len Size of a file.
- * @param props File properties to set.
- * @param evictExclude Evict exclude flag.
- * @param accessTime The access time.
- * @param modificationTime The modification time.
- */
- IgfsFileInfo(int blockSize, long len, boolean evictExclude, @Nullable Map<String, String> props,
- long accessTime, long modificationTime) {
- this(blockSize == 0, // NB The contract is: (blockSize == 0) <=> isDirectory()
- null, blockSize, len, null, null, props, null, true, accessTime, modificationTime, evictExclude);
- }
+ /** {@inheritDoc} */
+ @Override public IgfsFileInfo unlock(long modificationTime) {
+ IgfsFileInfo res = copy();
- /**
- * Constructs file information.
- *
- * @param info File information to copy data from.
- * @param lockId Lock ID.
- * @param modificationTime Last modification time.
- */
- IgfsFileInfo(IgfsFileInfo info, @Nullable IgniteUuid lockId, long modificationTime) {
- this(info.isDirectory(), info.id, info.blockSize, info.len, info.affKey, info.listing, info.props,
- info.fileMap(), lockId, true, info.accessTime, modificationTime, info.evictExclude());
+ res.lockId = null;
+ res.modificationTime = modificationTime;
+
+ return res;
}
- /**
- * Constructs file info.
- *
- * @param listing New directory listing.
- * @param old Old file info.
- */
- IgfsFileInfo(@Nullable Map<String, IgfsListingEntry> listing, IgfsFileInfo old) {
- this(old.isDirectory(), old.id, old.blockSize, old.len, old.affKey, listing, old.props, old.fileMap(),
- old.lockId, false, old.accessTime, old.modificationTime, old.evictExclude());
+ /** {@inheritDoc} */
+ @Override public IgfsFileInfo fileMap(IgfsFileMap fileMap) {
+ IgfsFileInfo res = copy();
+
+ res.fileMap = fileMap;
+
+ return res;
}
- /**
- * Constructs file info.
- *
- * @param isDir Constructs directory info if {@code true} or file info if {@code false}.
- * @param id ID or {@code null} to generate it automatically.
- * @param blockSize Block size.
- * @param len Size of a file.
- * @param affKey Affinity key for data blocks.
- * @param listing Directory listing.
- * @param props File properties.
- * @param lockId Lock ID.
- * @param cpProps Flag to copy properties map.
- * @param accessTime The access time.
- * @param modificationTime Last modification time.
- * @param evictExclude Evict exclude flag.
- */
- private IgfsFileInfo(boolean isDir, @Nullable IgniteUuid id, int blockSize, long len, @Nullable IgniteUuid affKey,
- @Nullable Map<String, IgfsListingEntry> listing, @Nullable Map<String, String> props,
- @Nullable IgniteUuid lockId, boolean cpProps, long accessTime, long modificationTime, boolean evictExclude) {
- this(isDir, id, blockSize, len, affKey, listing, props, null, lockId, cpProps, accessTime,
- modificationTime, evictExclude);
+ /** {@inheritDoc} */
+ @Override protected IgfsFileInfo copy() {
+ return new IgfsFileInfo(id, blockSize, len, affKey, props, fileMap, lockId, accessTime, modificationTime,
+ evictExclude);
}
/**
* Constructs file info.
*
- * @param isDir Constructs directory info if {@code true} or file info if {@code false}.
* @param id ID or {@code null} to generate it automatically.
* @param blockSize Block size.
* @param len Size of a file.
* @param affKey Affinity key for data blocks.
- * @param listing Directory listing.
* @param props File properties.
* @param fileMap File map.
* @param lockId Lock ID.
- * @param cpProps Flag to copy properties map.
* @param accessTime Last access time.
* @param modificationTime Last modification time.
* @param evictExclude Evict exclude flag.
*/
- private IgfsFileInfo(boolean isDir, @Nullable IgniteUuid id, int blockSize, long len, @Nullable IgniteUuid affKey,
- @Nullable Map<String, IgfsListingEntry> listing, @Nullable Map<String, String> props,
- @Nullable IgfsFileMap fileMap, @Nullable IgniteUuid lockId, boolean cpProps, long accessTime,
- long modificationTime, boolean evictExclude) {
- assert F.isEmpty(listing) || isDir;
-
- if (isDir) {
- assert len == 0 : "Directory length should be zero: " + len;
- assert blockSize == 0 : "Directory block size should be zero: " + blockSize;
- }
- else {
- assert len >= 0 : "File length cannot be negative: " + len;
- assert blockSize > 0 : "File block size should be positive: " + blockSize;
- }
-
- this.id = id == null ? IgniteUuid.randomUuid() : id;
- this.len = isDir ? 0 : len;
- this.blockSize = isDir ? 0 : blockSize;
+ IgfsFileInfo(IgniteUuid id, int blockSize, long len, @Nullable IgniteUuid affKey,
+ @Nullable Map<String, String> props, @Nullable IgfsFileMap fileMap, @Nullable IgniteUuid lockId,
+ long accessTime, long modificationTime, boolean evictExclude) {
+ super(id, props, accessTime, modificationTime);
+
+ this.len = len;
+ this.blockSize = blockSize;
this.affKey = affKey;
- this.listing = listing;
- if (fileMap == null && !isDir)
+ if (fileMap == null)
fileMap = new IgfsFileMap();
this.fileMap = fileMap;
- this.accessTime = accessTime == ACCESS_TIME_TAKE_MODIFICATION_TIME ? modificationTime : accessTime;
- this.modificationTime = modificationTime;
-
- // Always make a copy of passed properties collection to escape concurrent modifications.
- this.props = props == null || props.isEmpty() ? null :
- cpProps ? new GridLeanMap<>(props) : props;
-
this.lockId = lockId;
this.evictExclude = evictExclude;
}
- /**
- * A copy constructor, which takes all data from the specified
- * object field-by-field.
- *
- * @param info An object to copy data info.
- */
- public IgfsFileInfo(IgfsFileInfo info) {
- this(info.isDirectory(), info.id, info.blockSize, info.len, info.affKey, info.listing, info.props,
- info.fileMap(), info.lockId, true, info.accessTime, info.modificationTime, info.evictExclude());
- }
-
- /**
- * Creates a builder for the new instance of file info.
- *
- * @return A builder to construct a new unmodifiable instance
- * of this class.
- */
- public static Builder builder() {
- return new Builder(new IgfsFileInfo());
- }
-
- /**
- * Creates a builder for the new instance of file info,
- * based on the specified origin.
- *
- * @param origin An origin for new instance, from which
- * the data will be copied.
- * @return A builder to construct a new unmodifiable instance
- * of this class.
- */
- public static Builder builder(IgfsFileInfo origin) {
- return new Builder(new IgfsFileInfo(origin));
- }
-
- /**
- * Gets this item ID.
- *
- * @return This item ID.
- */
- public IgniteUuid id() {
- return id;
- }
-
- /**
- * 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.
- */
+ /** {@inheritDoc} */
public boolean isFile() {
- return blockSize > 0;
- }
-
- /**
- * @return {@code True} if this is a directory.
- */
- public boolean isDirectory() {
- return blockSize == 0;
+ return true;
}
- /**
- * Get file size.
- *
- * @return File size.
- */
+ /** {@inheritDoc} */
public long length() {
- assert isFile();
-
return len;
}
- /**
- * Get single data block size to store this file.
- *
- * @return Single data block size to store this file.
- */
+ /** {@inheritDoc} */
public int blockSize() {
- assert isFile();
-
return blockSize;
}
- /**
- * @return Number of data blocks to store this file.
- */
+ /** {@inheritDoc} */
public long blocksCount() {
- assert isFile();
-
return (len + blockSize() - 1) / blockSize();
}
- /**
- * @return Last access time.
- */
- public long accessTime() {
- return accessTime;
- }
-
- /**
- * @return Last modification time.
- */
- public long modificationTime() {
- return modificationTime;
- }
-
- /**
- * @return Directory listing.
- */
+ /** {@inheritDoc} */
public Map<String, IgfsListingEntry> listing() {
- return listing != null ? listing : Collections.<String, IgfsListingEntry>emptyMap();
+ return Collections.emptyMap();
}
- /**
- * @return {@code True} if at least one child exists.
- */
+ /** {@inheritDoc} */
public boolean hasChildren() {
- return !F.isEmpty(listing);
+ return false;
}
- /**
- * @param name Child name.
- * @return {@code True} if child with such name exists.
- */
+ /** {@inheritDoc} */
public boolean hasChild(String name) {
- return listing != null && listing.containsKey(name);
+ return false;
}
- /**
- * @param name Child name.
- * @param expId Expected child ID.
- * @return {@code True} if child with such name exists.
- */
+ /** {@inheritDoc} */
public boolean hasChild(String name, IgniteUuid expId) {
- if (listing != null) {
- IgfsListingEntry entry = listing.get(name);
-
- if (entry != null)
- return F.eq(expId, entry.fileId());
- }
-
return false;
}
- /**
- * @return Affinity key used for single-node file collocation. If {@code null}, usual
- * mapper procedure is used for block affinity detection.
- */
+ /** {@inheritDoc} */
@Nullable public IgniteUuid affinityKey() {
return affKey;
}
- /**
- * @param affKey Affinity key used for single-node file collocation.
- */
- public void affinityKey(IgniteUuid affKey) {
- this.affKey = affKey;
- }
-
- /**
- * @return File affinity map.
- */
+ /** {@inheritDoc} */
public IgfsFileMap fileMap() {
return fileMap;
}
- /**
- * @param fileMap File affinity map.
- */
- public void fileMap(IgfsFileMap fileMap) {
- this.fileMap = fileMap;
- }
-
- /**
- * Get properties of the file.
- *
- * @return Properties of the file.
- */
- public Map<String, String> properties() {
- return props == null || props.isEmpty() ? Collections.<String, String>emptyMap() :
- Collections.unmodifiableMap(props);
- }
-
- /**
- * Get lock ID.
- *
- * @return Lock ID if file is locked or {@code null} if file is free of locks.
- */
+ /** {@inheritDoc} */
@Nullable public IgniteUuid lockId() {
return lockId;
}
- /**
- * Get evict exclude flag.
- *
- * @return Evict exclude flag.
- */
+ /** {@inheritDoc} */
public boolean evictExclude() {
return evictExclude;
}
- /**
- * @return Original file path. This is a helper field used only in some operations like delete.
- */
- public IgfsPath path() {
- return path;
- }
-
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeGridUuid(out, id);
+ super.writeExternal(out);
+
out.writeInt(blockSize);
out.writeLong(len);
- U.writeStringMap(out, props);
U.writeGridUuid(out, lockId);
U.writeGridUuid(out, affKey);
- out.writeObject(listing);
out.writeObject(fileMap);
- out.writeLong(accessTime);
- out.writeLong(modificationTime);
out.writeBoolean(evictExclude);
- out.writeObject(path);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- id = U.readGridUuid(in);
+ super.readExternal(in);
+
blockSize = in.readInt();
len = in.readLong();
- props = U.readStringMap(in);
lockId = U.readGridUuid(in);
affKey = U.readGridUuid(in);
- listing = (Map<String, IgfsListingEntry>)in.readObject();
fileMap = (IgfsFileMap)in.readObject();
- accessTime = in.readLong();
- modificationTime = in.readLong();
evictExclude = in.readBoolean();
- path = (IgfsPath)in.readObject();
}
/** {@inheritDoc} */
@@ -575,42 +253,4 @@ public final class IgfsFileInfo implements Externalizable {
@Override public String toString() {
return S.toString(IgfsFileInfo.class, this);
}
-
- /**
- * Builder for {@link IgfsFileInfo}.
- */
- @SuppressWarnings("PublicInnerClass")
- public static class Builder {
- /** Instance to build. */
- private final IgfsFileInfo info;
-
- /**
- * Private constructor.
- *
- * @param info Instance to build.
- */
- private Builder(IgfsFileInfo info) {
- this.info = info;
- }
-
- /**
- * @param path A new path value.
- * @return This builder instance (for chaining).
- */
- public Builder path(IgfsPath path) {
- info.path = path;
-
- return this;
- }
-
- /**
- * Finishes instance construction and returns a resulting
- * unmodifiable instance.
- *
- * @return A constructed instance.
- */
- public IgfsFileInfo build() {
- return info;
- }
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatch.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatch.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatch.java
index 130846b..17875a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatch.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatch.java
@@ -17,22 +17,23 @@
package org.apache.ignite.internal.processors.igfs;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.igfs.IgfsPath;
-import org.apache.ignite.internal.util.future.GridFutureAdapter;
-import org.apache.ignite.internal.util.typedef.internal.U;
/**
* Work batch is an abstraction of the logically grouped tasks.
*/
public abstract class IgfsFileWorkerBatch implements Runnable {
/** Stop marker. */
- private static final byte[] STOP_MARKER = new byte[0];
+ private static final byte[] FINISH_MARKER = new byte[0];
/** Cancel marker. */
private static final byte[] CANCEL_MARKER = new byte[0];
@@ -49,9 +50,6 @@ public abstract class IgfsFileWorkerBatch implements Runnable {
/** Output stream to the file. */
private final OutputStream out;
- /** Cancel flag. */
- private volatile boolean cancelled;
-
/** Finishing flag. */
private volatile boolean finishing;
@@ -76,45 +74,55 @@ public abstract class IgfsFileWorkerBatch implements Runnable {
* @return {@code True} in case write was enqueued.
*/
synchronized boolean write(final byte[] data) {
- if (!finishing) {
- queue.add(data);
-
- return true;
- }
- else
- return false;
+ return offer(data, false, false);
}
/**
* Add the last task to that batch which will release all the resources.
+ *
+ * @return {@code True} if finish was signalled.
*/
- synchronized void finish() {
- if (!finishing) {
- finishing = true;
-
- queue.add(STOP_MARKER);
- }
+ synchronized boolean finish() {
+ return offer(FINISH_MARKER, false, true);
}
/**
* Cancel batch processing.
+ *
+ * @return {@code True} if cancel was signalled.
*/
- synchronized void cancel() {
- queue.addFirst(CANCEL_MARKER);
+ synchronized boolean cancel() {
+ return offer(CANCEL_MARKER, true, true);
}
/**
- * @return {@code True} if finish was called on this batch.
+ * Add request to queue.
+ *
+ * @param data Data.
+ * @param head Whether to add to head.
+ * @param finish Whether this is the last batch to be accepted.
+ * @return {@code True} if request was added to queue.
*/
- boolean finishing() {
- return finishing;
+ private synchronized boolean offer(byte[] data, boolean head, boolean finish) {
+ if (finishing)
+ return false;
+
+ if (head)
+ queue.addFirst(data);
+ else
+ queue.addLast(data);
+
+ if (finish)
+ finishing = true;
+
+ return true;
}
/**
- * @return {@code True} if batch write was terminated abruptly due to explicit cancellation.
+ * @return {@code True} if finish was called on this batch.
*/
- boolean cancelled() {
- return cancelled;
+ boolean finishing() {
+ return finishing;
}
/**
@@ -129,16 +137,13 @@ public abstract class IgfsFileWorkerBatch implements Runnable {
try {
byte[] data = queue.poll(1000, TimeUnit.MILLISECONDS);
- if (data == STOP_MARKER) {
+ if (data == FINISH_MARKER) {
assert queue.isEmpty();
break;
}
- else if (data == CANCEL_MARKER) {
- cancelled = true;
-
- throw new IgniteCheckedException("Write to file was cancelled due to node stop.");
- }
+ else if (data == CANCEL_MARKER)
+ throw new IgfsFileWorkerBatchCancelledException(path);
else if (data != null) {
try {
out.write(data);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatchCancelledException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatchCancelledException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatchCancelledException.java
new file mode 100644
index 0000000..4ae6964
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatchCancelledException.java
@@ -0,0 +1,51 @@
+/*
+ * 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.igfs;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.igfs.IgfsPath;
+
+/**
+ * Exception indicating that file batch processing was cancelled.
+ */
+public class IgfsFileWorkerBatchCancelledException extends IgniteCheckedException {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Path. */
+ private IgfsPath path;
+
+ /**
+ * Default constructor.
+ */
+ public IgfsFileWorkerBatchCancelledException() {
+ // No-op.
+ }
+
+ public IgfsFileWorkerBatchCancelledException(IgfsPath path) {
+ this.path = path;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getMessage() {
+ if (path == null)
+ return "Asynchronous file processing was cancelled due to node stop.";
+ else
+ return "Asynchronous file processing was cancelled due to node stop: " + path;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/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 7cc5cb6..194a8ac 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,23 +17,6 @@
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;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterNode;
@@ -60,6 +43,23 @@ import org.jetbrains.annotations.Nullable;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.MutableEntry;
+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;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
@@ -274,7 +274,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
Collection<IgfsFileAffinityRange> ranges = req.fragmentRanges();
IgniteUuid fileId = req.fileId();
- IgfsFileInfo fileInfo = igfsCtx.meta().info(fileId);
+ IgfsEntryInfo fileInfo = igfsCtx.meta().info(fileId);
if (fileInfo == null) {
if (log.isDebugEnabled())
@@ -288,7 +288,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
for (IgfsFileAffinityRange range : ranges) {
try {
- IgfsFileInfo updated;
+ IgfsEntryInfo updated;
switch (range.status()) {
case RANGE_STATUS_INITIAL: {
@@ -345,7 +345,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
/**
* Update range processor.
*/
- private static class RangeUpdateProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class RangeUpdateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -375,17 +375,15 @@ public class IgfsFragmentizerManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo oldInfo = entry.getValue();
+ IgfsEntryInfo oldInfo = entry.getValue();
IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
newMap.updateRangeStatus(range, status);
- IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, oldInfo.length());
-
- newInfo.fileMap(newMap);
+ IgfsEntryInfo newInfo = oldInfo.fileMap(newMap);
entry.setValue(newInfo);
@@ -413,7 +411,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
/**
* Delete range processor.
*/
- private static class RangeDeleteProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class RangeDeleteProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -438,17 +436,15 @@ public class IgfsFragmentizerManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo oldInfo = entry.getValue();
+ IgfsEntryInfo oldInfo = entry.getValue();
IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
newMap.deleteRange(range);
- IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, oldInfo.length());
-
- newInfo.fileMap(newMap);
+ IgfsEntryInfo newInfo = oldInfo.fileMap(newMap);
entry.setValue(newInfo);
@@ -507,7 +503,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
// If we have room for files, add them to fragmentizer.
try {
while (fragmentingFiles.size() < igfsCtx.configuration().getFragmentizerConcurrentFiles()) {
- IgfsFileInfo fileInfo = fileForFragmentizer(fragmentingFiles.keySet());
+ IgfsEntryInfo fileInfo = fileForFragmentizer(fragmentingFiles.keySet());
// If no colocated files found, exit loop.
if (fileInfo == null)
@@ -715,7 +711,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
*
* @param fileInfo File info to process.
*/
- private void requestFragmenting(IgfsFileInfo fileInfo) {
+ private void requestFragmenting(IgfsEntryInfo fileInfo) {
IgfsFileMap map = fileInfo.fileMap();
assert map != null && !map.ranges().isEmpty();
@@ -789,7 +785,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
* @return File ID to process or {@code null} if there are no such files.
* @throws IgniteCheckedException In case of error.
*/
- @Nullable private IgfsFileInfo fileForFragmentizer(Collection<IgniteUuid> exclude) throws IgniteCheckedException {
+ @Nullable private IgfsEntryInfo fileForFragmentizer(Collection<IgniteUuid> exclude) throws IgniteCheckedException {
return fragmentizerEnabled ? igfsCtx.meta().fileForFragmentizer(exclude) : null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/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 9ec583c..398428a 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
@@ -622,7 +622,7 @@ public final class IgfsImpl implements IgfsEx {
await(path);
- IgfsFileInfo info = meta.updateDual(secondaryFs, path, props);
+ IgfsEntryInfo info = meta.updateDual(secondaryFs, path, props);
if (info == null)
return null;
@@ -637,7 +637,7 @@ public final class IgfsImpl implements IgfsEx {
if (fileId == null)
return null;
- IgfsFileInfo info = meta.updateProperties(fileId, props);
+ IgfsEntryInfo info = meta.updateProperties(fileId, props);
if (info != null) {
if (evts.isRecordable(EVT_IGFS_META_UPDATED))
@@ -691,7 +691,7 @@ public final class IgfsImpl implements IgfsEx {
return null;
}
- IgfsFileInfo info = meta.move(src, dest);
+ IgfsEntryInfo info = meta.move(src, dest);
int evtTyp = info.isFile() ? EVT_IGFS_FILE_RENAMED : EVT_IGFS_DIR_RENAMED;
@@ -858,7 +858,7 @@ public final class IgfsImpl implements IgfsEx {
IgniteUuid fileId = meta.fileId(path);
if (fileId != null) {
- IgfsFileInfo info = meta.info(fileId);
+ IgfsEntryInfo info = meta.info(fileId);
// Handle concurrent deletion.
if (info != null) {
@@ -869,7 +869,7 @@ public final class IgfsImpl implements IgfsEx {
// Perform the listing.
for (Map.Entry<String, IgfsListingEntry> e : info.listing().entrySet()) {
- IgfsFileInfo childInfo = meta.info(e.getValue().fileId());
+ IgfsEntryInfo childInfo = meta.info(e.getValue().fileId());
if (childInfo != null) {
IgfsPath childPath = new IgfsPath(path, e.getKey());
@@ -933,7 +933,7 @@ public final class IgfsImpl implements IgfsEx {
return os;
}
- IgfsFileInfo info = meta.info(meta.fileId(path));
+ IgfsEntryInfo info = meta.info(meta.fileId(path));
if (info == null) {
checkConflictWithPrimary(path);
@@ -1034,7 +1034,7 @@ public final class IgfsImpl implements IgfsEx {
else
dirProps = fileProps = new HashMap<>(props);
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = meta.create(
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = meta.create(
path,
dirProps,
overwrite,
@@ -1112,7 +1112,7 @@ public final class IgfsImpl implements IgfsEx {
else
dirProps = fileProps = new HashMap<>(props);
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = meta.append(
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = meta.append(
path,
dirProps,
create,
@@ -1194,7 +1194,7 @@ public final class IgfsImpl implements IgfsEx {
// Check memory first.
IgniteUuid fileId = meta.fileId(path);
- IgfsFileInfo info = meta.info(fileId);
+ IgfsEntryInfo info = meta.info(fileId);
if (info == null && mode != PRIMARY) {
assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
@@ -1291,7 +1291,7 @@ public final class IgfsImpl implements IgfsEx {
private void summary0(IgniteUuid fileId, IgfsPathSummary sum) throws IgniteCheckedException {
assert sum != null;
- IgfsFileInfo info = meta.info(fileId);
+ IgfsEntryInfo info = meta.info(fileId);
if (info != null) {
if (info.isDirectory()) {
@@ -1401,7 +1401,7 @@ public final class IgfsImpl implements IgfsEx {
List<IgniteUuid> ids = meta.fileIds(path);
- IgfsFileInfo fileInfo = meta.info(ids.get(ids.size() - 1));
+ IgfsEntryInfo fileInfo = meta.info(ids.get(ids.size() - 1));
if (fileInfo == null)
return null; // File does not exist.
@@ -1571,7 +1571,7 @@ public final class IgfsImpl implements IgfsEx {
assert path != null;
assert mode != null;
- IgfsFileInfo info = null;
+ IgfsEntryInfo info = null;
switch (mode) {
case PRIMARY:
@@ -1698,7 +1698,7 @@ public final class IgfsImpl implements IgfsEx {
* @param mode IGFS mode.
* @param batch Optional secondary file system batch.
*/
- IgfsEventAwareOutputStream(IgfsPath path, IgfsFileInfo fileInfo,
+ IgfsEventAwareOutputStream(IgfsPath path, IgfsEntryInfo fileInfo,
IgniteUuid parentId, int bufSize, IgfsMode mode, @Nullable IgfsFileWorkerBatch batch) {
super(igfsCtx, path, fileInfo, parentId, bufSize, mode, batch, metrics);
@@ -1737,7 +1737,7 @@ public final class IgfsImpl implements IgfsEx {
* @param secReader Optional secondary file system reader.
* @param metrics Metrics.
*/
- IgfsEventAwareInputStream(IgfsContext igfsCtx, IgfsPath path, IgfsFileInfo fileInfo,
+ IgfsEventAwareInputStream(IgfsContext igfsCtx, IgfsPath path, IgfsEntryInfo fileInfo,
int prefetchBlocks, int seqReadsBeforePrefetch, @Nullable IgfsSecondaryFileSystemPositionedReadable secReader,
IgfsLocalMetrics metrics) {
super(igfsCtx, path, fileInfo, prefetchBlocks, seqReadsBeforePrefetch, secReader, metrics);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java
index afcece7..07ab051 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java
@@ -17,10 +17,11 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.IOException;
import org.apache.ignite.igfs.IgfsInputStream;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadable;
+import java.io.IOException;
+
/**
* Implementation adapter providing necessary methods.
*/
@@ -36,7 +37,7 @@ public abstract class IgfsInputStreamAdapter extends IgfsInputStream
*
* @return File info.
*/
- public abstract IgfsFileInfo fileInfo();
+ public abstract IgfsEntryInfo fileInfo();
/**
* Reads bytes from given position.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
index 62f8034..5d41543 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
@@ -17,16 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.EOFException;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.igfs.IgfsCorruptedFileException;
@@ -42,6 +32,17 @@ import org.apache.ignite.lang.IgniteInClosure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.io.EOFException;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
/**
* Input stream to read data from grid cache with separate blocks.
*/
@@ -66,7 +67,7 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
protected final IgfsPath path;
/** File descriptor. */
- private volatile IgfsFileInfo fileInfo;
+ private volatile IgfsEntryInfo fileInfo;
/** The number of already read bytes. Important! Access to the property is guarded by this object lock. */
private long pos;
@@ -121,7 +122,7 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
* @param secReader Optional secondary file system reader.
* @param metrics Local IGFS metrics.
*/
- IgfsInputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsFileInfo fileInfo, int prefetchBlocks,
+ IgfsInputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsEntryInfo fileInfo, int prefetchBlocks,
int seqReadsBeforePrefetch, @Nullable IgfsSecondaryFileSystemPositionedReadable secReader, IgfsLocalMetrics metrics) {
assert igfsCtx != null;
assert path != null;
@@ -157,7 +158,7 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo fileInfo() {
+ @Override public IgfsEntryInfo fileInfo() {
return fileInfo;
}
@@ -404,7 +405,7 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
// This failure may be caused by file being fragmented.
if (fileInfo.fileMap() != null && !fileInfo.fileMap().ranges().isEmpty()) {
- IgfsFileInfo newInfo = meta.info(fileInfo.id());
+ IgfsEntryInfo newInfo = meta.info(fileInfo.id());
// File was deleted.
if (newInfo == null)
@@ -534,7 +535,8 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
* @return Requested data block or {@code null} if nothing found.
* @throws IgniteCheckedException If failed.
*/
- @Nullable protected IgniteInternalFuture<byte[]> dataBlock(IgfsFileInfo fileInfo, long blockIdx) throws IgniteCheckedException {
+ @Nullable protected IgniteInternalFuture<byte[]> dataBlock(IgfsEntryInfo fileInfo, long blockIdx)
+ throws IgniteCheckedException {
return data.dataBlock(fileInfo, path, blockIdx, secReader);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java
index 0ed7c0d..eadbdb2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java
@@ -17,11 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.Closeable;
-import java.io.DataInput;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
@@ -46,6 +41,12 @@ import org.apache.ignite.lang.IgniteOutClosure;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
+import java.io.Closeable;
+import java.io.DataInput;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.concurrent.atomic.AtomicLong;
+
/**
* IGFS IPC handler.
*/
@@ -342,10 +343,7 @@ class IgfsIpcHandler implements IgfsServerHandler {
log.debug("Opened IGFS input stream for file read [igfsName=" + igfs.name() + ", path=" +
req.path() + ", streamId=" + streamId + ", ses=" + ses + ']');
- IgfsFileInfo info = new IgfsFileInfo(igfsIn.fileInfo(), null,
- igfsIn.fileInfo().modificationTime());
-
- res.response(new IgfsInputStreamDescriptor(streamId, info.length()));
+ res.response(new IgfsInputStreamDescriptor(streamId, igfsIn.fileInfo().length()));
break;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4794f87b/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 4fe0dca..ea05ca3 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
@@ -17,16 +17,16 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/**
* Directory listing entry.
*/
@@ -52,7 +52,7 @@ public class IgfsListingEntry implements Externalizable {
*
* @param fileInfo File info to construct listing entry from.
*/
- public IgfsListingEntry(IgfsFileInfo fileInfo) {
+ public IgfsListingEntry(IgfsEntryInfo fileInfo) {
id = fileInfo.id();
dir = fileInfo.isDirectory();
}