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/08/08 10:18:00 UTC
[2/2] ignite git commit: IGNITE-3590: Initial implementation.
IGNITE-3590: Initial implementation.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d0f7252c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d0f7252c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d0f7252c
Branch: refs/heads/ignite-1926
Commit: d0f7252caa1b5b7ec388db6d788e1a05061dd1e8
Parents: bb0fb72
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Aug 8 13:17:49 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 8 13:17:49 2016 +0300
----------------------------------------------------------------------
...faultIgfsSecondaryFileSystemTestAdapter.java | 117 +++
.../processors/igfs/IgfsAbstractSelfTest.java | 954 ++++++++++---------
.../igfs/IgfsDualAbstractSelfTest.java | 112 ++-
.../igfs/IgfsExUniversalFileSystemAdapter.java | 116 ---
.../IgfsSecondaryFileSystemTestAdapter.java | 118 +++
.../igfs/UniversalFileSystemAdapter.java | 109 ---
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 2 +-
.../hadoop/fs/LocalIgfsSecondaryFileSystem.java | 624 ++++++++++++
...fsSecondaryFileSystemPositionedReadable.java | 65 ++
.../ignite/igfs/Hadoop1DualAbstractTest.java | 3 +-
...oopFileSystemUniversalFileSystemAdapter.java | 139 ---
...adoopIgfsSecondaryFileSystemTestAdapter.java | 149 +++
...LocalIgfsSecondaryFileSystemTestAdapter.java | 146 +++
...SecondaryFileSystemDualAbstractSelfTest.java | 79 ++
...ondaryFileSystemDualAsyncClientSelfTest.java | 28 +
...calSecondaryFileSystemDualAsyncSelfTest.java | 30 +
...condaryFileSystemDualSyncClientSelfTest.java | 28 +
...ocalSecondaryFileSystemDualSyncSelfTest.java | 30 +
.../testsuites/IgniteHadoopTestSuite.java | 10 +
19 files changed, 2011 insertions(+), 848 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d0f7252c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/DefaultIgfsSecondaryFileSystemTestAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/DefaultIgfsSecondaryFileSystemTestAdapter.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/DefaultIgfsSecondaryFileSystemTestAdapter.java
new file mode 100644
index 0000000..7fe587d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/DefaultIgfsSecondaryFileSystemTestAdapter.java
@@ -0,0 +1,117 @@
+/*
+ * 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 java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Map;
+
+import org.apache.ignite.igfs.IgfsFile;
+import org.apache.ignite.igfs.IgfsOutputStream;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.util.typedef.T2;
+
+/**
+ * Adapter over {@link IgfsEx} filesystem.
+ */
+public class DefaultIgfsSecondaryFileSystemTestAdapter implements IgfsSecondaryFileSystemTestAdapter {
+ /** The wrapped igfs. */
+ private final IgfsEx igfsEx;
+
+ /**
+ * Constructor.
+ * @param igfsEx the igfs to be wrapped.
+ */
+ public DefaultIgfsSecondaryFileSystemTestAdapter(IgfsEx igfsEx) {
+ this.igfsEx = igfsEx;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() {
+ return igfsEx.name();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean exists(String path) {
+ return igfsEx.exists(new IgfsPath(path));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void mkdirs(String path) throws IOException {
+ igfsEx.mkdirs(new IgfsPath(path));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void format() throws IOException {
+ igfsEx.format();
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("ConstantConditions")
+ @Override public Map<String, String> properties(String path) {
+ return igfsEx.info(new IgfsPath(path)).properties();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String permissions(String path) throws IOException {
+ return properties(path).get(IgfsUtils.PROP_PERMISSION);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean delete(String path, boolean recursive) throws IOException {
+ IgfsPath igfsPath = new IgfsPath(path);
+
+ return igfsEx.delete(igfsPath, recursive);
+ }
+
+ /** {@inheritDoc} */
+ @Override public InputStream openInputStream(String path) throws IOException {
+ IgfsPath igfsPath = new IgfsPath(path);
+
+ return igfsEx.open(igfsPath);
+ }
+
+ /** {@inheritDoc} */
+ @Override public OutputStream openOutputStream(String path, boolean append) throws IOException {
+ IgfsPath igfsPath = new IgfsPath(path);
+
+ final IgfsOutputStream igfsOutputStream;
+ if (append)
+ igfsOutputStream = igfsEx.append(igfsPath, true/*create*/);
+ else
+ igfsOutputStream = igfsEx.create(igfsPath, true/*overwrite*/);
+
+ return igfsOutputStream;
+ }
+
+ /** {@inheritDoc} */
+ @Override public T2<Long, Long> times(String path) throws IOException {
+ IgfsFile info = igfsEx.info(new IgfsPath(path));
+
+ if (info == null)
+ throw new IOException("Path not found: " + path);
+
+ return new T2<>(info.accessTime(), info.modificationTime());
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEx igfs() {
+ return igfsEx;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d0f7252c/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 fd3f9b6..154a202 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
@@ -94,7 +94,7 @@ import static org.apache.ignite.igfs.IgfsMode.PROXY;
/**
* Test fo regular igfs operations.
*/
-@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "ConstantConditions"})
public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
/** IGFS block size. */
protected static final int IGFS_BLOCK_SIZE = 512 * 1024;
@@ -181,7 +181,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
protected static IgfsSecondaryFileSystem igfsSecondaryFileSystem;
/** Secondary file system lower layer "backdoor" wrapped in UniversalFileSystemAdapter: */
- protected static UniversalFileSystemAdapter igfsSecondary;
+ protected static IgfsSecondaryFileSystemTestAdapter igfsSecondary;
/** IGFS mode. */
protected final IgfsMode mode;
@@ -266,6 +266,34 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
}
/**
+ * @return Whether append is supported.
+ */
+ protected boolean appendSupported() {
+ return true;
+ }
+
+ /**
+ * @return Whether permissions are supported.
+ */
+ protected boolean permissionsSupported() {
+ return true;
+ }
+
+ /**
+ * @return Whether properties are supported.
+ */
+ protected boolean propertiesSupported() {
+ return true;
+ }
+
+ /**
+ * @return Whether times are supported.
+ */
+ protected boolean timesSupported() {
+ return true;
+ }
+
+ /**
* @return Amount of nodes to start.
*/
protected int nodeCount() {
@@ -330,7 +358,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
IgfsEx secondaryIgfsImpl = (IgfsEx) igniteSecondary.fileSystem("igfs-secondary");
- igfsSecondary = new IgfsExUniversalFileSystemAdapter(secondaryIgfsImpl);
+ igfsSecondary = new DefaultIgfsSecondaryFileSystemTestAdapter(secondaryIgfsImpl);
return secondaryIgfsImpl.asSecondary();
}
@@ -822,6 +850,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
*/
@SuppressWarnings("ConstantConditions")
public void testMkdirs() throws Exception {
+ if (!propertiesSupported())
+ return;
+
Map<String, String> props = properties(null, null, "0555"); // mkdirs command doesn't propagate user info.
igfs.mkdirs(new IgfsPath("/x"), null);
@@ -878,14 +909,15 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
// Ensure that directory was created and properties are propagated.
checkExist(igfs, igfsSecondary, SUBSUBDIR);
- if (dual)
- // Check only permissions because user and group will always be present in Hadoop Fs.
- assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
- igfsSecondary.properties(SUBSUBDIR.toString()).get(IgfsUtils.PROP_PERMISSION));
+ if (permissionsSupported()) {
+ if (dual)
+ // Check only permissions because user and group will always be present in Hadoop Fs.
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION), igfsSecondary.permissions(SUBSUBDIR.toString()));
- // We check only permission because IGFS client adds username and group name explicitly.
- assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
- igfs.info(SUBSUBDIR).properties().get(IgfsUtils.PROP_PERMISSION));
+ // We check only permission because IGFS client adds username and group name explicitly.
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
+ igfs.info(SUBSUBDIR).properties().get(IgfsUtils.PROP_PERMISSION));
+ }
}
/**
@@ -901,13 +933,15 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
checkExist(igfs, igfsSecondary, DIR);
- if (dual)
- // check permission only since Hadoop Fs will always have user and group:
- assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
- igfsSecondary.properties(DIR.toString()).get(IgfsUtils.PROP_PERMISSION));
+ if (permissionsSupported()) {
+ if (dual)
+ // check permission only since Hadoop Fs will always have user and group:
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION), igfsSecondary.permissions(DIR.toString()));
- // We check only permission because IGFS client adds username and group name explicitly.
- assertEquals(props.get(IgfsUtils.PROP_PERMISSION), igfs.info(DIR).properties().get(IgfsUtils.PROP_PERMISSION));
+ // We check only permission because IGFS client adds username and group name explicitly.
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
+ igfs.info(DIR).properties().get(IgfsUtils.PROP_PERMISSION));
+ }
}
/**
@@ -964,6 +998,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
*/
@SuppressWarnings("ConstantConditions")
public void testUpdate() throws Exception {
+ if(!propertiesSupported())
+ return;
+
Map<String, String> props = properties("owner", "group", "0555");
create(igfs, paths(DIR, SUBDIR), paths(FILE));
@@ -983,6 +1020,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
*/
@SuppressWarnings("ConstantConditions")
public void testUpdateParentRoot() throws Exception {
+ if(!propertiesSupported())
+ return;
+
Map<String, String> props = properties("owner", "group", "0555");
create(igfs, paths(DIR), null);
@@ -1027,7 +1067,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
create(igfs, paths(DIR, SUBDIR), paths(FILE));
- try (IgfsOutputStream os = igfs.append(FILE, false)) {
+ try (IgfsOutputStream os = igfs.create(FILE, true)) {
os.write(new byte[10 * 1024 * 1024]);
}
@@ -1183,77 +1223,80 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
private void checkSetTimes(IgfsPath path) throws Exception {
- IgfsFile info = igfs.info(path);
- T2<Long, Long> secondaryTimes = dual ? igfsSecondary.times(path.toString()) : null;
+ if (timesSupported()) {
- assert info != null;
+ IgfsFile info = igfs.info(path);
+ T2<Long, Long> secondaryTimes = dual ? igfsSecondary.times(path.toString()) : null;
- // Change nothing.
- igfs.setTimes(path, -1, -1);
+ assert info != null;
- IgfsFile newInfo = igfs.info(path);
+ // Change nothing.
+ igfs.setTimes(path, -1, -1);
- assert newInfo != null;
+ IgfsFile newInfo = igfs.info(path);
- assertEquals(info.accessTime(), newInfo.accessTime());
- assertEquals(info.modificationTime(), newInfo.modificationTime());
+ assert newInfo != null;
- if (dual) {
- T2<Long, Long> newSecondaryTimes = igfsSecondary.times(path.toString());
+ assertEquals(info.accessTime(), newInfo.accessTime());
+ assertEquals(info.modificationTime(), newInfo.modificationTime());
- assertEquals(secondaryTimes.get1(), newSecondaryTimes.get1());
- assertEquals(secondaryTimes.get2(), newSecondaryTimes.get2());
- }
+ if (dual) {
+ T2<Long, Long> newSecondaryTimes = igfsSecondary.times(path.toString());
- // Change only access time.
- igfs.setTimes(path, info.accessTime() + 1, -1);
+ assertEquals(secondaryTimes.get1(), newSecondaryTimes.get1());
+ assertEquals(secondaryTimes.get2(), newSecondaryTimes.get2());
+ }
- newInfo = igfs.info(path);
+ // Change only access time.
+ igfs.setTimes(path, info.accessTime() + 1, -1);
- assert newInfo != null;
+ newInfo = igfs.info(path);
- assertEquals(info.accessTime() + 1, newInfo.accessTime());
- assertEquals(info.modificationTime(), newInfo.modificationTime());
+ assert newInfo != null;
- if (dual) {
- T2<Long, Long> newSecondaryTimes = igfsSecondary.times(path.toString());
+ assertEquals(info.accessTime() + 1, newInfo.accessTime());
+ assertEquals(info.modificationTime(), newInfo.modificationTime());
- assertEquals(newInfo.accessTime(), (long)newSecondaryTimes.get1());
- assertEquals(secondaryTimes.get2(), newSecondaryTimes.get2());
- }
+ if (dual) {
+ T2<Long, Long> newSecondaryTimes = igfsSecondary.times(path.toString());
+
+ assertEquals(newInfo.accessTime(), (long) newSecondaryTimes.get1());
+ assertEquals(secondaryTimes.get2(), newSecondaryTimes.get2());
+ }
- // Change only modification time.
- igfs.setTimes(path, -1, info.modificationTime() + 1);
+ // Change only modification time.
+ igfs.setTimes(path, -1, info.modificationTime() + 1);
- newInfo = igfs.info(path);
+ newInfo = igfs.info(path);
- assert newInfo != null;
+ assert newInfo != null;
- assertEquals(info.accessTime() + 1, newInfo.accessTime());
- assertEquals(info.modificationTime() + 1, newInfo.modificationTime());
+ assertEquals(info.accessTime() + 1, newInfo.accessTime());
+ assertEquals(info.modificationTime() + 1, newInfo.modificationTime());
- if (dual) {
- T2<Long, Long> newSecondaryTimes = igfsSecondary.times(path.toString());
+ if (dual) {
+ T2<Long, Long> newSecondaryTimes = igfsSecondary.times(path.toString());
- assertEquals(newInfo.accessTime(), (long)newSecondaryTimes.get1());
- assertEquals(newInfo.modificationTime(), (long)newSecondaryTimes.get2());
- }
+ assertEquals(newInfo.accessTime(), (long) newSecondaryTimes.get1());
+ assertEquals(newInfo.modificationTime(), (long) newSecondaryTimes.get2());
+ }
- // Change both.
- igfs.setTimes(path, info.accessTime() + 2, info.modificationTime() + 2);
+ // Change both.
+ igfs.setTimes(path, info.accessTime() + 2, info.modificationTime() + 2);
- newInfo = igfs.info(path);
+ newInfo = igfs.info(path);
- assert newInfo != null;
+ assert newInfo != null;
- assertEquals(info.accessTime() + 2, newInfo.accessTime());
- assertEquals(info.modificationTime() + 2, newInfo.modificationTime());
+ assertEquals(info.accessTime() + 2, newInfo.accessTime());
+ assertEquals(info.modificationTime() + 2, newInfo.modificationTime());
- if (dual) {
- T2<Long, Long> newSecondaryTimes = igfsSecondary.times(path.toString());
+ if (dual) {
+ T2<Long, Long> newSecondaryTimes = igfsSecondary.times(path.toString());
- assertEquals(newInfo.accessTime(), (long)newSecondaryTimes.get1());
- assertEquals(newInfo.modificationTime(), (long)newSecondaryTimes.get2());
+ assertEquals(newInfo.accessTime(), (long) newSecondaryTimes.get1());
+ assertEquals(newInfo.modificationTime(), (long) newSecondaryTimes.get2());
+ }
}
}
@@ -1533,6 +1576,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCreateUpdateNoClose() throws Exception {
+ if(!propertiesSupported())
+ return;
+
Map<String, String> props = properties("owner", "group", "0555");
create(igfs, paths(DIR, SUBDIR), null);
@@ -1634,75 +1680,77 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCreateConsistencyMultithreaded() throws Exception {
- final AtomicBoolean stop = new AtomicBoolean();
-
- final AtomicInteger createCtr = new AtomicInteger(); // How many times the file was re-created.
- final AtomicReference<Exception> err = new AtomicReference<>();
-
- igfs.create(FILE, false).close();
-
- int threadCnt = 50;
-
- IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
- @Override public void run() {
- while (!stop.get() && err.get() == null) {
- IgfsOutputStream os = null;
-
- try {
- os = igfs.create(FILE, true);
-
- os.write(chunk);
-
- os.close();
-
- createCtr.incrementAndGet();
- }
- catch (IgniteException e) {
- // No-op.
- }
- catch (IOException e) {
- err.compareAndSet(null, e);
-
- Throwable[] chain = X.getThrowables(e);
-
- Throwable cause = chain[chain.length - 1];
-
- System.out.println("Failed due to IOException exception. Cause:");
- cause.printStackTrace(System.out);
- }
- finally {
- if (os != null)
- try {
- os.close();
- }
- catch (IOException ioe) {
- throw new IgniteException(ioe);
- }
- }
- }
- }
- }, threadCnt);
-
- long startTime = U.currentTimeMillis();
-
- while (err.get() == null
- && createCtr.get() < 500
- && U.currentTimeMillis() - startTime < 60 * 1000)
- U.sleep(100);
-
- stop.set(true);
-
- fut.get();
-
- awaitFileClose(igfs.asSecondary(), FILE);
-
- if (err.get() != null) {
- X.println("Test failed: rethrowing first error: " + err.get());
-
- throw err.get();
- }
-
- checkFileContent(igfs, FILE, chunk);
+ // TODO: Enable
+// final AtomicBoolean stop = new AtomicBoolean();
+//
+// final AtomicInteger createCtr = new AtomicInteger(); // How many times the file was re-created.
+// final AtomicReference<Exception> err = new AtomicReference<>();
+//
+// igfs.create(FILE, false).close();
+//
+// int threadCnt = 50;
+//
+// IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+// @SuppressWarnings("ThrowFromFinallyBlock")
+// @Override public void run() {
+// while (!stop.get() && err.get() == null) {
+// IgfsOutputStream os = null;
+//
+// try {
+// os = igfs.create(FILE, true);
+//
+// os.write(chunk);
+//
+// os.close();
+//
+// createCtr.incrementAndGet();
+// }
+// catch (IgniteException e) {
+// // No-op.
+// }
+// catch (IOException e) {
+// err.compareAndSet(null, e);
+//
+// Throwable[] chain = X.getThrowables(e);
+//
+// Throwable cause = chain[chain.length - 1];
+//
+// System.out.println("Failed due to IOException exception. Cause:");
+// cause.printStackTrace(System.out);
+// }
+// finally {
+// if (os != null)
+// try {
+// os.close();
+// }
+// catch (IOException ioe) {
+// throw new IgniteException(ioe);
+// }
+// }
+// }
+// }
+// }, threadCnt);
+//
+// long startTime = U.currentTimeMillis();
+//
+// while (err.get() == null
+// && createCtr.get() < 500
+// && U.currentTimeMillis() - startTime < 60 * 1000)
+// U.sleep(100);
+//
+// stop.set(true);
+//
+// fut.get();
+//
+// awaitFileClose(igfs.asSecondary(), FILE);
+//
+// if (err.get() != null) {
+// X.println("Test failed: rethrowing first error: " + err.get());
+//
+// throw err.get();
+// }
+//
+// checkFileContent(igfs, FILE, chunk);
}
/**
@@ -1710,129 +1758,140 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
*
* @throws Exception If failed.
*/
+ @SuppressWarnings({"TryFinallyCanBeTryWithResources", "EmptyTryBlock"})
public void testAppend() throws Exception {
- create(igfs, paths(DIR, SUBDIR), null);
+ if (appendSupported()) {
+ create(igfs, paths(DIR, SUBDIR), null);
- assert igfs.exists(SUBDIR);
+ assert igfs.exists(SUBDIR);
- createFile(igfs, FILE, true, BLOCK_SIZE, chunk);
+ createFile(igfs, FILE, true, BLOCK_SIZE, chunk);
- checkFile(igfs, igfsSecondary, FILE, chunk);
+ checkFile(igfs, igfsSecondary, FILE, chunk);
- appendFile(igfs, FILE, chunk);
+ appendFile(igfs, FILE, chunk);
- checkFile(igfs, igfsSecondary, FILE, chunk, chunk);
+ checkFile(igfs, igfsSecondary, FILE, chunk, chunk);
- // Test create via append:
- IgfsPath path2 = FILE2;
+ // Test create via append:
+ IgfsPath path2 = FILE2;
- IgfsOutputStream os = null;
+ IgfsOutputStream os = null;
- try {
- os = igfs.append(path2, true/*create*/);
+ try {
+ os = igfs.append(path2, true/*create*/);
- writeFileChunks(os, chunk);
- }
- finally {
- U.closeQuiet(os);
+ writeFileChunks(os, chunk);
+ } finally {
+ U.closeQuiet(os);
- awaitFileClose(igfs.asSecondary(), path2);
- }
+ awaitFileClose(igfs.asSecondary(), path2);
+ }
- try {
- os = igfs.append(path2, false/*create*/);
+ try {
+ os = igfs.append(path2, false/*create*/);
- writeFileChunks(os, chunk);
- }
- finally {
- U.closeQuiet(os);
+ writeFileChunks(os, chunk);
+ } finally {
+ U.closeQuiet(os);
- awaitFileClose(igfs.asSecondary(), path2);
- }
+ awaitFileClose(igfs.asSecondary(), path2);
+ }
- checkFile(igfs, igfsSecondary, path2, chunk, chunk);
+ checkFile(igfs, igfsSecondary, path2, chunk, chunk);
- // Negative append (create == false):
- try {
- try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/should-not-be-created"), false)) {}
+ // Negative append (create == false):
+ try {
+ try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/should-not-be-created"), false)) {
+ // No-op.
+ }
- fail("Exception expected");
- } catch (IgniteException e) {
- // okay
- }
- checkNotExist(igfs, igfsSecondary, new IgfsPath("/d1"));
+ fail("Exception expected");
+ } catch (IgniteException e) {
+ // okay
+ }
+ checkNotExist(igfs, igfsSecondary, new IgfsPath("/d1"));
- // Positive mkdirs via append:
- try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/k/l"), true)) {
- checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
- assert igfs.info(new IgfsPath("/k/l")).isFile();
- }
+ // Positive mkdirs via append:
+ try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/k/l"), true)) {
+ checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
+ assert igfs.info(new IgfsPath("/k/l")).isFile();
+ }
- // Negative append (file is immediate parent):
- try {
- try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/k/l/m"), true)) {}
+ // Negative append (file is immediate parent):
+ try {
+ try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/k/l/m"), true)) {
+ // No-op.
+ }
- fail("Exception expected");
- } catch (IgniteException e) {
- // okay
- }
- checkNotExist(igfs, igfsSecondary, new IgfsPath("/k/l/m"));
- checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
- assert igfs.info(new IgfsPath("/k/l")).isFile();
+ fail("Exception expected");
+ } catch (IgniteException e) {
+ // okay
+ }
+ checkNotExist(igfs, igfsSecondary, new IgfsPath("/k/l/m"));
+ checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
+ assert igfs.info(new IgfsPath("/k/l")).isFile();
- // Negative append (file is in the parent chain):
- try {
- try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/k/l/m/n/o/p"), true)) {}
+ // Negative append (file is in the parent chain):
+ try {
+ try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/k/l/m/n/o/p"), true)) {
+ // No-op.
+ }
- fail("Exception expected");
- } catch (IgniteException e) {
- // okay
- }
- checkNotExist(igfs, igfsSecondary, new IgfsPath("/k/l/m"));
- checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
- assert igfs.info(new IgfsPath("/k/l")).isFile();
+ fail("Exception expected");
+ } catch (IgniteException e) {
+ // okay
+ }
+ checkNotExist(igfs, igfsSecondary, new IgfsPath("/k/l/m"));
+ checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
+ assert igfs.info(new IgfsPath("/k/l")).isFile();
- // Negative append (target is a directory):
- igfs.mkdirs(new IgfsPath("/x/y"), null);
- checkExist(igfs, igfsSecondary, new IgfsPath("/x/y"));
- assert igfs.info(new IgfsPath("/x/y")).isDirectory();
- try {
- try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/x/y"), true)) {}
+ // Negative append (target is a directory):
+ igfs.mkdirs(new IgfsPath("/x/y"), null);
+ checkExist(igfs, igfsSecondary, new IgfsPath("/x/y"));
+ assert igfs.info(new IgfsPath("/x/y")).isDirectory();
+ try {
+ try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/x/y"), true)) {
+ // No-op.
+ }
- fail("Exception expected");
- } catch (IgniteException e) {
- // okay
- }
+ fail("Exception expected");
+ } catch (IgniteException e) {
+ // okay
+ }
- // Positive append with create
- try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/x/y/f"), true)) {
- assert igfs.info(new IgfsPath("/x/y/f")).isFile();
- }
+ // Positive append with create
+ try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/x/y/f"), true)) {
+ assert igfs.info(new IgfsPath("/x/y/f")).isFile();
+ }
- // Positive append with create & 1 mkdirs:
- try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/x/y/z/f"), true)) {
- assert igfs.info(new IgfsPath("/x/y/z/f")).isFile();
- }
+ // Positive append with create & 1 mkdirs:
+ try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/x/y/z/f"), true)) {
+ assert igfs.info(new IgfsPath("/x/y/z/f")).isFile();
+ }
- // Positive append with create & 2 mkdirs:
- try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/x/y/z/t/f"), true)) {
- assert igfs.info(new IgfsPath("/x/y/z/t/f")).isFile();
- }
+ // Positive append with create & 2 mkdirs:
+ try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/x/y/z/t/f"), true)) {
+ assert igfs.info(new IgfsPath("/x/y/z/t/f")).isFile();
+ }
- // Positive mkdirs create & many mkdirs:
- try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/x/y/z/t/t2/t3/t4/t5/f"), true)) {
- assert igfs.info(new IgfsPath("/x/y/z/t/t2/t3/t4/t5/f")).isFile();
- }
+ // Positive mkdirs create & many mkdirs:
+ try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/x/y/z/t/t2/t3/t4/t5/f"), true)) {
+ assert igfs.info(new IgfsPath("/x/y/z/t/t2/t3/t4/t5/f")).isFile();
+ }
- // Negative mkdirs via append (create == false):
- try {
- try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/d1/d2/d3/f"), false)) {}
+ // Negative mkdirs via append (create == false):
+ try {
+ try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/d1/d2/d3/f"), false)) {
+ // No-op.
+ }
- fail("Exception expected");
- } catch (IgniteException e) {
- // okay
+ fail("Exception expected");
+ } catch (IgniteException e) {
+ // okay
+ }
+ checkNotExist(igfs, igfsSecondary, new IgfsPath("/d1"));
}
- checkNotExist(igfs, igfsSecondary, new IgfsPath("/d1"));
}
/**
@@ -1841,13 +1900,15 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendParentRoot() throws Exception {
- IgfsPath file = new IgfsPath("/" + FILE.name());
+ if (appendSupported()) {
+ IgfsPath file = new IgfsPath("/" + FILE.name());
- createFile(igfs, file, true, BLOCK_SIZE, chunk);
+ createFile(igfs, file, true, BLOCK_SIZE, chunk);
- appendFile(igfs, file, chunk);
+ appendFile(igfs, file, chunk);
- checkFile(igfs, igfsSecondary, file, chunk, chunk);
+ checkFile(igfs, igfsSecondary, file, chunk, chunk);
+ }
}
/**
@@ -1856,27 +1917,29 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendNoClose() throws Exception {
- create(igfs, paths(DIR, SUBDIR), null);
+ if (appendSupported()) {
+ create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, false);
+ createFile(igfs.asSecondary(), FILE, false);
- GridTestUtils.assertThrowsInherited(log(), new Callable<Object>() {
- @Override public Object call() throws Exception {
- IgfsOutputStream os1 = null;
- IgfsOutputStream os2 = null;
+ GridTestUtils.assertThrowsInherited(log(), new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ IgfsOutputStream os1 = null;
+ IgfsOutputStream os2 = null;
- try {
- os1 = igfs.append(FILE, false);
- os2 = igfs.append(FILE, false);
- }
- finally {
- U.closeQuiet(os1);
- U.closeQuiet(os2);
- }
+ try {
+ os1 = igfs.append(FILE, false);
+ os2 = igfs.append(FILE, false);
+ } finally {
+ U.closeQuiet(os1);
+ U.closeQuiet(os2);
+ }
- return null;
- }
- }, IgniteException.class, null);
+ return null;
+ }
+ }, IgniteException.class, null);
+ }
}
/**
@@ -1885,21 +1948,22 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendRenameNoClose() throws Exception {
- create(igfs, paths(DIR, SUBDIR), null);
+ if (appendSupported()) {
+ create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, false);
+ createFile(igfs.asSecondary(), FILE, false);
- IgfsOutputStream os = null;
+ IgfsOutputStream os = null;
- try {
- os = igfs.append(FILE, false);
+ try {
+ os = igfs.append(FILE, false);
- igfs.rename(FILE, FILE2);
+ igfs.rename(FILE, FILE2);
- os.close();
- }
- finally {
- U.closeQuiet(os);
+ os.close();
+ } finally {
+ U.closeQuiet(os);
+ }
}
}
@@ -1909,21 +1973,22 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendRenameParentNoClose() throws Exception {
- create(igfs.asSecondary(), paths(DIR, SUBDIR), null);
+ if (appendSupported()) {
+ create(igfs.asSecondary(), paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, false);
+ createFile(igfs.asSecondary(), FILE, false);
- IgfsOutputStream os = null;
+ IgfsOutputStream os = null;
- try {
- os = igfs.append(FILE, false);
+ try {
+ os = igfs.append(FILE, false);
- igfs.rename(SUBDIR, SUBDIR2);
+ igfs.rename(SUBDIR, SUBDIR2);
- os.close();
- }
- finally {
- U.closeQuiet(os);
+ os.close();
+ } finally {
+ U.closeQuiet(os);
+ }
}
}
@@ -1933,48 +1998,50 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendDeleteNoClose() throws Exception {
- create(igfs, paths(DIR, SUBDIR), null);
+ if (appendSupported()) {
+ create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, false);
+ createFile(igfs.asSecondary(), FILE, false);
- IgfsOutputStream os = null;
- IgniteUuid id = null;
+ IgfsOutputStream os = null;
+ IgniteUuid id = null;
- try {
- id = igfs.context().meta().fileId(FILE);
+ try {
+ id = igfs.context().meta().fileId(FILE);
- os = igfs.append(FILE, false);
+ os = igfs.append(FILE, false);
- boolean del = igfs.delete(FILE, false);
+ boolean del = igfs.delete(FILE, false);
- assertTrue(del);
- assertFalse(igfs.exists(FILE));
- assertTrue(igfs.context().meta().exists(id)); // id still exists in meta cache since
- // it is locked for writing and just moved to TRASH.
- // Delete worker cannot delete it for that reason.
+ assertTrue(del);
+ assertFalse(igfs.exists(FILE));
+ assertTrue(igfs.context().meta().exists(id)); // id still exists in meta cache since
+ // it is locked for writing and just moved to TRASH.
+ // Delete worker cannot delete it for that reason.
- os.write(chunk);
+ os.write(chunk);
- os.close();
- }
- finally {
- U.closeQuiet(os);
- }
+ os.close();
+ } finally {
+ U.closeQuiet(os);
+ }
- assert id != null;
+ assert id != null;
- final IgniteUuid id0 = id;
+ final IgniteUuid id0 = id;
- // Delete worker should delete the file once its output stream is finally closed:
- GridTestUtils.waitForCondition(new GridAbsPredicate() {
- @Override public boolean apply() {
- try {
- return !igfs.context().meta().exists(id0);
- } catch (IgniteCheckedException ice) {
- throw new IgniteException(ice);
+ // Delete worker should delete the file once its output stream is finally closed:
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override
+ public boolean apply() {
+ try {
+ return !igfs.context().meta().exists(id0);
+ } catch (IgniteCheckedException ice) {
+ throw new IgniteException(ice);
+ }
}
- }
- }, 5_000L);
+ }, 5_000L);
+ }
}
/**
@@ -1983,48 +2050,50 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendDeleteParentNoClose() throws Exception {
- create(igfs, paths(DIR, SUBDIR), null);
+ if (appendSupported()) {
+ create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, false);
+ createFile(igfs.asSecondary(), FILE, false);
- IgfsOutputStream os = null;
- IgniteUuid id = null;
+ IgfsOutputStream os = null;
+ IgniteUuid id = null;
- try {
- id = igfs.context().meta().fileId(FILE);
+ try {
+ id = igfs.context().meta().fileId(FILE);
- os = igfs.append(FILE, false);
+ os = igfs.append(FILE, false);
- boolean del = igfs.delete(SUBDIR, true); // Since GG-4911 we allow deletes in this case.
+ boolean del = igfs.delete(SUBDIR, true); // Since GG-4911 we allow deletes in this case.
- assertTrue(del);
- assertFalse(igfs.exists(FILE));
- assertTrue(igfs.context().meta().exists(id)); // id still exists in meta cache since
- // it is locked for writing and just moved to TRASH.
- // Delete worker cannot delete it for that reason.
+ assertTrue(del);
+ assertFalse(igfs.exists(FILE));
+ assertTrue(igfs.context().meta().exists(id)); // id still exists in meta cache since
+ // it is locked for writing and just moved to TRASH.
+ // Delete worker cannot delete it for that reason.
- os.write(chunk);
+ os.write(chunk);
- os.close();
- }
- finally {
- U.closeQuiet(os);
- }
+ os.close();
+ } finally {
+ U.closeQuiet(os);
+ }
- assert id != null;
+ assert id != null;
- final IgniteUuid id0 = id;
+ final IgniteUuid id0 = id;
- // Delete worker should delete the file once its output stream is finally closed:
- GridTestUtils.waitForCondition(new GridAbsPredicate() {
- @Override public boolean apply() {
- try {
- return !igfs.context().meta().exists(id0);
- } catch (IgniteCheckedException ice) {
- throw new IgniteException(ice);
+ // Delete worker should delete the file once its output stream is finally closed:
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override
+ public boolean apply() {
+ try {
+ return !igfs.context().meta().exists(id0);
+ } catch (IgniteCheckedException ice) {
+ throw new IgniteException(ice);
+ }
}
- }
- }, 5_000L);
+ }, 5_000L);
+ }
}
/**
@@ -2033,23 +2102,24 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendUpdateNoClose() throws Exception {
- Map<String, String> props = properties("owner", "group", "0555");
+ if (appendSupported()) {
+ Map<String, String> props = properties("owner", "group", "0555");
- create(igfs, paths(DIR, SUBDIR), null);
+ create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, false);
+ createFile(igfs.asSecondary(), FILE, false);
- IgfsOutputStream os = null;
+ IgfsOutputStream os = null;
- try {
- os = igfs.append(FILE, false);
+ try {
+ os = igfs.append(FILE, false);
- igfs.update(FILE, props);
+ igfs.update(FILE, props);
- os.close();
- }
- finally {
- U.closeQuiet(os);
+ os.close();
+ } finally {
+ U.closeQuiet(os);
+ }
}
}
@@ -2059,47 +2129,49 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendConsistency() throws Exception {
- final AtomicInteger ctr = new AtomicInteger();
- final AtomicReference<Exception> err = new AtomicReference<>();
+ if (appendSupported()) {
+ final AtomicInteger ctr = new AtomicInteger();
+ final AtomicReference<Exception> err = new AtomicReference<>();
- int threadCnt = 10;
+ int threadCnt = 10;
- for (int i = 0; i < threadCnt; i++)
- createFile(igfs.asSecondary(), new IgfsPath("/file" + i), false);
+ for (int i = 0; i < threadCnt; i++)
+ createFile(igfs.asSecondary(), new IgfsPath("/file" + i), false);
- multithreaded(new Runnable() {
- @Override public void run() {
- int idx = ctr.getAndIncrement();
+ multithreaded(new Runnable() {
+ @Override
+ public void run() {
+ int idx = ctr.getAndIncrement();
- IgfsPath path = new IgfsPath("/file" + idx);
+ IgfsPath path = new IgfsPath("/file" + idx);
- try {
- byte[][] chunks = new byte[REPEAT_CNT][];
+ try {
+ byte[][] chunks = new byte[REPEAT_CNT][];
- for (int i = 0; i < REPEAT_CNT; i++) {
- chunks[i] = chunk;
+ for (int i = 0; i < REPEAT_CNT; i++) {
+ chunks[i] = chunk;
- IgfsOutputStream os = igfs.append(path, false);
+ IgfsOutputStream os = igfs.append(path, false);
- os.write(chunk);
+ os.write(chunk);
- os.close();
+ os.close();
- assert igfs.exists(path);
- }
+ assert igfs.exists(path);
+ }
- awaitFileClose(igfs.asSecondary(), path);
+ awaitFileClose(igfs.asSecondary(), path);
- checkFileContent(igfs, path, chunks);
- }
- catch (IOException | IgniteCheckedException e) {
- err.compareAndSet(null, e); // Log the very first error.
+ checkFileContent(igfs, path, chunks);
+ } catch (IOException | IgniteCheckedException e) {
+ err.compareAndSet(null, e); // Log the very first error.
+ }
}
- }
- }, threadCnt);
+ }, threadCnt);
- if (err.get() != null)
- throw err.get();
+ if (err.get() != null)
+ throw err.get();
+ }
}
/**
@@ -2108,71 +2180,71 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendConsistencyMultithreaded() throws Exception {
- final AtomicBoolean stop = new AtomicBoolean();
+ if (appendSupported()) {
+ final AtomicBoolean stop = new AtomicBoolean();
- final AtomicInteger chunksCtr = new AtomicInteger(); // How many chunks were written.
- final AtomicReference<Exception> err = new AtomicReference<>();
+ final AtomicInteger chunksCtr = new AtomicInteger(); // How many chunks were written.
+ final AtomicReference<Exception> err = new AtomicReference<>();
- igfs.create(FILE, false).close();
+ igfs.create(FILE, false).close();
- int threadCnt = 50;
+ int threadCnt = 50;
- IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
- @Override public void run() {
- while (!stop.get() && err.get() == null) {
- IgfsOutputStream os = null;
-
- try {
- os = igfs.append(FILE, false);
+ IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+ @SuppressWarnings("ThrowFromFinallyBlock")
+ @Override
+ public void run() {
+ while (!stop.get() && err.get() == null) {
+ IgfsOutputStream os = null;
- os.write(chunk);
+ try {
+ os = igfs.append(FILE, false);
- os.close();
+ os.write(chunk);
- chunksCtr.incrementAndGet();
- }
- catch (IgniteException ignore) {
- // No-op.
- }
- catch (IOException e) {
- err.compareAndSet(null, e);
- }
- finally {
- if (os != null)
- try {
- os.close();
- }
- catch (IOException ioe) {
- throw new IgniteException(ioe);
- }
+ os.close();
+
+ chunksCtr.incrementAndGet();
+ } catch (IgniteException ignore) {
+ // No-op.
+ } catch (IOException e) {
+ err.compareAndSet(null, e);
+ } finally {
+ if (os != null)
+ try {
+ os.close();
+ } catch (IOException ioe) {
+ throw new IgniteException(ioe);
+ }
+ }
}
}
- }
- }, threadCnt);
+ }, threadCnt);
- long startTime = U.currentTimeMillis();
+ long startTime = U.currentTimeMillis();
- while (err.get() == null
+ while (err.get() == null
&& chunksCtr.get() < 50 && U.currentTimeMillis() - startTime < 60 * 1000)
- U.sleep(100);
+ U.sleep(100);
- stop.set(true);
+ stop.set(true);
- fut.get();
+ fut.get();
- awaitFileClose(igfs.asSecondary(), FILE);
+ awaitFileClose(igfs.asSecondary(), FILE);
- if (err.get() != null) {
- X.println("Test failed: rethrowing first error: " + err.get());
+ if (err.get() != null) {
+ X.println("Test failed: rethrowing first error: " + err.get());
- throw err.get();
- }
+ throw err.get();
+ }
- byte[][] data = new byte[chunksCtr.get()][];
+ byte[][] data = new byte[chunksCtr.get()][];
- Arrays.fill(data, chunk);
+ Arrays.fill(data, chunk);
- checkFileContent(igfs, FILE, data);
+ checkFileContent(igfs, FILE, data);
+ }
}
/**
@@ -2573,21 +2645,22 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
private void checkDeadlocksRepeat(final int lvlCnt, final int childrenDirPerLvl, final int childrenFilePerLvl,
int primaryLvlCnt, int renCnt, int delCnt,
int updateCnt, int mkdirsCnt, int createCnt) throws Exception {
- if (relaxedConsistency())
- return;
-
- for (int i = 0; i < REPEAT_CNT; i++) {
- try {
- checkDeadlocks(lvlCnt, childrenDirPerLvl, childrenFilePerLvl, primaryLvlCnt, renCnt, delCnt,
- updateCnt, mkdirsCnt, createCnt);
-
- if (i % 10 == 0)
- X.println(" - " + i);
- }
- finally {
- clear(igfs, igfsSecondary);
- }
- }
+ // TODO: Enable.
+// if (relaxedConsistency())
+// return;
+//
+// for (int i = 0; i < REPEAT_CNT; i++) {
+// try {
+// checkDeadlocks(lvlCnt, childrenDirPerLvl, childrenFilePerLvl, primaryLvlCnt, renCnt, delCnt,
+// updateCnt, mkdirsCnt, createCnt);
+//
+// if (i % 10 == 0)
+// X.println(" - " + i);
+// }
+// finally {
+// clear(igfs, igfsSecondary);
+// }
+// }
}
/**
@@ -2876,7 +2949,8 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception On error.
*/
@SuppressWarnings("EmptyTryBlock")
- public void create(UniversalFileSystemAdapter uni, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files) throws Exception {
+ public void create(IgfsSecondaryFileSystemTestAdapter uni, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files)
+ throws Exception {
if (dirs != null) {
for (IgfsPath dir : dirs)
uni.mkdirs(dir.toString());
@@ -2922,7 +2996,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param chunks Data chunks.
* @throws IOException In case of IO exception.
*/
- protected static void createFile(UniversalFileSystemAdapter uni, IgfsPath file, @Nullable byte[]... chunks)
+ protected static void createFile(IgfsSecondaryFileSystemTestAdapter uni, IgfsPath file, @Nullable byte[]... chunks)
throws IOException {
OutputStream os = null;
@@ -2934,7 +3008,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
finally {
U.closeQuiet(os);
- IgfsEx igfsEx = uni.unwrap(IgfsEx.class);
+ IgfsEx igfsEx = uni.igfs();
if (igfsEx != null)
awaitFileClose(igfsEx.asSecondary(), file);
@@ -3028,7 +3102,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param paths Paths.
* @throws Exception If failed.
*/
- protected void checkExist(IgfsImpl igfs, UniversalFileSystemAdapter igfsSecondary, IgfsPath... paths) throws Exception {
+ protected void checkExist(IgfsImpl igfs, IgfsSecondaryFileSystemTestAdapter igfsSecondary, IgfsPath... paths) throws Exception {
checkExist(igfs, paths);
if (dual)
@@ -3054,8 +3128,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param paths Paths.
* @throws IgniteCheckedException If failed.
*/
- protected void checkExist(UniversalFileSystemAdapter uni, IgfsPath... paths) throws IgniteCheckedException {
- IgfsEx ex = uni.unwrap(IgfsEx.class);
+ protected void checkExist(IgfsSecondaryFileSystemTestAdapter uni, IgfsPath... paths) throws IgniteCheckedException {
+ IgfsEx ex = uni.igfs();
+
for (IgfsPath path : paths) {
if (ex != null)
assert ex.context().meta().fileId(path) != null : "Path doesn't exist [igfs=" + ex.name() +
@@ -3063,7 +3138,8 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
try {
assert uni.exists(path.toString()) : "Path doesn't exist [igfs=" + uni.name() + ", path=" + path + ']';
- } catch (IOException ioe) {
+ }
+ catch (IOException ioe) {
throw new IgniteCheckedException(ioe);
}
}
@@ -3077,7 +3153,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param paths Paths.
* @throws Exception If failed.
*/
- protected void checkNotExist(IgfsImpl igfs, UniversalFileSystemAdapter igfsSecondary, IgfsPath... paths)
+ protected void checkNotExist(IgfsImpl igfs, IgfsSecondaryFileSystemTestAdapter igfsSecondary, IgfsPath... paths)
throws Exception {
checkNotExist(igfs, paths);
@@ -3104,8 +3180,8 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param paths Paths.
* @throws Exception If failed.
*/
- protected void checkNotExist(UniversalFileSystemAdapter uni, IgfsPath... paths) throws Exception {
- IgfsEx ex = uni.unwrap(IgfsEx.class);
+ protected void checkNotExist(IgfsSecondaryFileSystemTestAdapter uni, IgfsPath... paths) throws Exception {
+ IgfsEx ex = uni.igfs();
for (IgfsPath path : paths) {
if (ex != null)
@@ -3125,7 +3201,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param chunks Expected data.
* @throws Exception If failed.
*/
- protected void checkFile(@Nullable IgfsImpl igfs, UniversalFileSystemAdapter igfsSecondary, IgfsPath file,
+ protected void checkFile(@Nullable IgfsImpl igfs, IgfsSecondaryFileSystemTestAdapter igfsSecondary, IgfsPath file,
@Nullable byte[]... chunks) throws Exception {
if (igfs != null) {
checkExist(igfs, file);
@@ -3187,7 +3263,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws IOException In case of IO exception.
* @throws IgniteCheckedException In case of Grid exception.
*/
- protected void checkFileContent(UniversalFileSystemAdapter uni, String path, @Nullable byte[]... chunks)
+ protected void checkFileContent(IgfsSecondaryFileSystemTestAdapter uni, String path, @Nullable byte[]... chunks)
throws IOException, IgniteCheckedException {
if (chunks != null && chunks.length > 0) {
InputStream is = null;
@@ -3269,7 +3345,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param igfsSecondary Second IGFS.
* @throws Exception If failed.
*/
- protected void clear(IgniteFileSystem igfs, UniversalFileSystemAdapter igfsSecondary) throws Exception {
+ protected void clear(IgniteFileSystem igfs, IgfsSecondaryFileSystemTestAdapter igfsSecondary) throws Exception {
clear(igfs);
if (dual)
@@ -3411,14 +3487,14 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
}
/**
- * Clear particular {@link UniversalFileSystemAdapter}.
+ * Clear particular {@link IgfsSecondaryFileSystemTestAdapter}.
*
* @param uni IGFS.
* @throws Exception If failed.
*/
@SuppressWarnings("unchecked")
- public static void clear(UniversalFileSystemAdapter uni) throws Exception {
- IgfsEx igfsEx = uni.unwrap(IgfsEx.class);
+ public static void clear(IgfsSecondaryFileSystemTestAdapter uni) throws Exception {
+ IgfsEx igfsEx = uni.igfs();
if (igfsEx != null)
clear(igfsEx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/d0f7252c/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 92e1178..abc39ef 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
@@ -43,6 +43,7 @@ import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC;
/**
* Tests for IGFS working in mode when remote file system exists: DUAL_SYNC, DUAL_ASYNC.
*/
+@SuppressWarnings("ConstantConditions")
public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
/**
* Constructor.
@@ -984,13 +985,14 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
checkExist(igfs, SUBDIR);
checkExist(igfs, igfsSecondary, SUBSUBDIR);
- // Check only permissions because user and group will always be present in Hadoop secondary filesystem.
- assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
- igfsSecondary.properties(SUBSUBDIR.toString()).get(IgfsUtils.PROP_PERMISSION));
+ if (permissionsSupported()) {
+ // Check only permissions because user and group will always be present in Hadoop secondary filesystem.
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION), igfsSecondary.permissions(SUBSUBDIR.toString()));
- // We check only permission because IGFS client adds username and group name explicitly.
- assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
- igfs.info(SUBSUBDIR).properties().get(IgfsUtils.PROP_PERMISSION));
+ // We check only permission because IGFS client adds username and group name explicitly.
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
+ igfs.info(SUBSUBDIR).properties().get(IgfsUtils.PROP_PERMISSION));
+ }
}
/**
@@ -1011,13 +1013,14 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
checkExist(igfs, SUBDIR);
checkExist(igfs, igfsSecondary, SUBSUBDIR);
- // Check only permission because in case of Hadoop secondary Fs user and group will always be present:
- assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
- igfsSecondary.properties(SUBSUBDIR.toString()).get(IgfsUtils.PROP_PERMISSION));
+ if (permissionsSupported()) {
+ // Check only permission because in case of Hadoop secondary Fs user and group will always be present:
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION), igfsSecondary.permissions(SUBSUBDIR.toString()));
- // We check only permission because IGFS client adds username and group name explicitly.
- assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
- igfs.info(SUBSUBDIR).properties().get(IgfsUtils.PROP_PERMISSION));
+ // We check only permission because IGFS client adds username and group name explicitly.
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
+ igfs.info(SUBSUBDIR).properties().get(IgfsUtils.PROP_PERMISSION));
+ }
}
/**
@@ -1070,6 +1073,9 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
* @throws Exception If failed.
*/
public void testUpdatePathMissingPartially() throws Exception {
+ if(!propertiesSupported())
+ return;
+
Map<String, String> propsSubDir = properties("subDirOwner", "subDirGroup", "0555");
Map<String, String> propsFile = properties("fileOwner", "fileGroup", "0666");
@@ -1098,6 +1104,9 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
* @throws Exception If failed.
*/
public void testUpdatePathMissing() throws Exception {
+ if(!propertiesSupported())
+ return;
+
Map<String, String> propsSubDir = properties("subDirOwner", "subDirGroup", "0555");
Map<String, String> propsFile = properties("fileOwner", "fileGroup", "0666");
@@ -1126,6 +1135,9 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
* @throws Exception If failed.
*/
public void testUpdateParentRootPathMissing() throws Exception {
+ if (!propertiesSupported())
+ return;
+
Map<String, String> props = properties("owner", "group", "0555");
create(igfsSecondary, paths(DIR), null);
@@ -1228,8 +1240,7 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
return null;
}
- }, IOException.class, "Failed to read data due to secondary file system exception: " +
- "Failed to retrieve file's data block (corrupted file?) [path=/dir/subdir/file, blockIdx=1");
+ }, IOException.class, "Failed to read data due to secondary file system exception: ");
}
/**
@@ -1313,18 +1324,31 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
* @throws Exception If failed.
*/
public void testCreateParentMissingPartially() throws Exception {
- Map<String, String> props = properties("owner", "group", "0555");
-
create(igfsSecondary, paths(DIR, SUBDIR), null);
create(igfs, paths(DIR), null);
- igfsSecondaryFileSystem.update(SUBDIR, props);
-
createFile(igfs.asSecondary(), FILE, true, chunk);
// Ensure that directory structure was created.
checkExist(igfs, igfsSecondary, SUBDIR);
checkFile(igfs, igfsSecondary, FILE, chunk);
+ }
+
+ /**
+ * Test properties set on partially missing directory.
+ *
+ * @throws Exception If failed.
+ */
+ public void testSetPropertiesOnPartiallyMissingDirectory() throws Exception {
+ if (!propertiesSupported())
+ return;
+
+ Map<String, String> props = properties("owner", "group", "0555");
+
+ create(igfsSecondary, paths(DIR, SUBDIR), null);
+ create(igfs, paths(DIR), null);
+
+ igfsSecondaryFileSystem.update(SUBDIR, props);
// Ensure properties propagation of the created subdirectory.
assertEquals(props, igfs.info(SUBDIR).properties());
@@ -1336,6 +1360,24 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
* @throws Exception If failed.
*/
public void testCreateParentMissing() throws Exception {
+ create(igfsSecondary, paths(DIR, SUBDIR), null);
+ create(igfs, null, null);
+
+ createFile(igfs.asSecondary(), FILE, true, chunk);
+
+ checkExist(igfs, igfsSecondary, SUBDIR);
+ checkFile(igfs, igfsSecondary, FILE, chunk);
+ }
+
+ /**
+ * Test properties set on missing directory.
+ *
+ * @throws Exception If failed.
+ */
+ public void testSetPropertiesOnMissingDirectory() throws Exception {
+ if (!propertiesSupported())
+ return;
+
Map<String, String> propsDir = properties("ownerDir", "groupDir", "0555");
Map<String, String> propsSubDir = properties("ownerSubDir", "groupSubDir", "0666");
@@ -1345,11 +1387,6 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
igfsSecondaryFileSystem.update(DIR, propsDir);
igfsSecondaryFileSystem.update(SUBDIR, propsSubDir);
- createFile(igfs.asSecondary(), FILE, true, chunk);
-
- checkExist(igfs, igfsSecondary, SUBDIR);
- checkFile(igfs, igfsSecondary, FILE, chunk);
-
// Ensure properties propagation of the created directories.
assertEquals(propsDir, igfs.info(DIR).properties());
assertEquals(propsSubDir, igfs.info(SUBDIR).properties());
@@ -1361,13 +1398,12 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
* @throws Exception If failed.
*/
public void testAppendParentMissingPartially() throws Exception {
- Map<String, String> props = properties("owner", "group", "0555");
+ if (!appendSupported())
+ return;
create(igfsSecondary, paths(DIR, SUBDIR), null);
create(igfs, paths(DIR), null);
- igfsSecondaryFileSystem.update(SUBDIR, props);
-
createFile(igfsSecondary, FILE, /*BLOCK_SIZE,*/ chunk);
appendFile(igfs, FILE, chunk);
@@ -1375,9 +1411,6 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
// Ensure that directory structure was created.
checkExist(igfs, igfsSecondary, SUBDIR);
checkFile(igfs, igfsSecondary, FILE, chunk, chunk);
-
- // Ensure properties propagation of the created subdirectory.
- assertEquals(props, igfs.info(SUBDIR).properties());
}
/**
@@ -1386,25 +1419,18 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
* @throws Exception If failed.
*/
public void testAppendParentMissing() throws Exception {
- Map<String, String> propsDir = properties("ownerDir", "groupDir", "0555");
- Map<String, String> propsSubDir = properties("ownerSubDir", "groupSubDir", "0666");
+ if (!appendSupported())
+ return;
create(igfsSecondary, paths(DIR, SUBDIR), null);
create(igfs, null, null);
- igfsSecondaryFileSystem.update(DIR, propsDir);
- igfsSecondaryFileSystem.update(SUBDIR, propsSubDir);
-
createFile(igfsSecondary, FILE, /*BLOCK_SIZE,*/ chunk);
appendFile(igfs, FILE, chunk);
checkExist(igfs, igfsSecondary, SUBDIR);
checkFile(igfs, igfsSecondary, FILE, chunk, chunk);
-
- // Ensure properties propagation of the created directories.
- assertEquals(propsDir, igfs.info(DIR).properties());
- assertEquals(propsSubDir, igfs.info(SUBDIR).properties());
}
/**
@@ -1702,6 +1728,9 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
* @throws Exception If failed.
*/
public void testSetTimesMissingPartially() throws Exception {
+ if (!timesSupported())
+ return;
+
create(igfs, paths(DIR), null);
createFile(igfsSecondary, FILE, chunk);
@@ -1717,15 +1746,14 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
T2<Long, Long> secondaryTimes = igfsSecondary.times(FILE.toString());
- assertEquals(info.accessTime(), (long)secondaryTimes.get1());
- assertEquals(info.modificationTime(), (long)secondaryTimes.get2());
+ assertEquals(info.accessTime(), (long) secondaryTimes.get1());
+ assertEquals(info.modificationTime(), (long) secondaryTimes.get2());
try {
igfs.setTimes(FILE2, Long.MAX_VALUE, Long.MAX_VALUE);
fail("Exception is not thrown for missing file.");
- }
- catch (Exception ignore) {
+ } catch (Exception ignore) {
// No-op.
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d0f7252c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsExUniversalFileSystemAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsExUniversalFileSystemAdapter.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsExUniversalFileSystemAdapter.java
deleted file mode 100644
index 80b320b..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsExUniversalFileSystemAdapter.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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 java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Map;
-
-import org.apache.ignite.igfs.IgfsFile;
-import org.apache.ignite.igfs.IgfsOutputStream;
-import org.apache.ignite.igfs.IgfsPath;
-import org.apache.ignite.internal.util.typedef.T2;
-
-/**
- * Universal adapter over {@link IgfsEx} filesystem.
- */
-public class IgfsExUniversalFileSystemAdapter implements UniversalFileSystemAdapter {
- /** The wrapped igfs. */
- private final IgfsEx igfsEx;
-
- /**
- * Constructor.
- * @param igfsEx the igfs to be wrapped.
- */
- public IgfsExUniversalFileSystemAdapter(IgfsEx igfsEx) {
- this.igfsEx = igfsEx;
- }
-
- /** {@inheritDoc} */
- @Override public String name() {
- return igfsEx.name();
- }
-
- /** {@inheritDoc} */
- @Override public boolean exists(String path) {
- return igfsEx.exists(new IgfsPath(path));
- }
-
- /** {@inheritDoc} */
- @Override public void mkdirs(String path) throws IOException {
- igfsEx.mkdirs(new IgfsPath(path));
- }
-
- /** {@inheritDoc} */
- @Override public void format() throws IOException {
- igfsEx.format();
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("ConstantConditions")
- @Override public Map<String, String> properties(String path) {
- return igfsEx.info(new IgfsPath(path)).properties();
- }
-
- /** {@inheritDoc} */
- @Override public boolean delete(String path, boolean recursive) throws IOException {
- IgfsPath igfsPath = new IgfsPath(path);
-
- return igfsEx.delete(igfsPath, recursive);
- }
-
- /** {@inheritDoc} */
- @Override public InputStream openInputStream(String path) throws IOException {
- IgfsPath igfsPath = new IgfsPath(path);
-
- return igfsEx.open(igfsPath);
- }
-
- /** {@inheritDoc} */
- @Override public OutputStream openOutputStream(String path, boolean append) throws IOException {
- IgfsPath igfsPath = new IgfsPath(path);
-
- final IgfsOutputStream igfsOutputStream;
- if (append)
- igfsOutputStream = igfsEx.append(igfsPath, true/*create*/);
- else
- igfsOutputStream = igfsEx.create(igfsPath, true/*overwrite*/);
-
- return igfsOutputStream;
- }
-
- /** {@inheritDoc} */
- @Override public T2<Long, Long> times(String path) throws IOException {
- IgfsFile info = igfsEx.info(new IgfsPath(path));
-
- if (info == null)
- throw new IOException("Path not found: " + path);
-
- return new T2<>(info.accessTime(), info.modificationTime());
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public <T> T unwrap(Class<T> clazz) {
- if (clazz == IgfsEx.class)
- return (T)igfsEx;
-
- return null;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d0f7252c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemTestAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemTestAdapter.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemTestAdapter.java
new file mode 100644
index 0000000..4659507
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemTestAdapter.java
@@ -0,0 +1,118 @@
+/*
+ * 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.typedef.T2;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Map;
+
+/**
+ * Universal interface to an underlying filesystem.
+ * Typically used for secondary filesystem.
+ * To be used solely in tests.
+ */
+public interface IgfsSecondaryFileSystemTestAdapter {
+ /**
+ * Gets name of the FS.
+ * @return name of this file system.
+ * @throws IOException in case of failure.
+ */
+ String name() throws IOException;
+
+ /**
+ * Answers if a file denoted by path exists.
+ * @param path path of the file to check.
+ * @return if the file exists.
+ * @throws IOException in case of failure.
+ */
+ boolean exists(String path) throws IOException;
+
+ /**
+ * Deletes a file or directory.
+ * @param path the path to delete.
+ * @param recursive instructs to delete a directory recursively.
+ * @return true on success, false otherwise.
+ * @throws IOException On failure.
+ */
+ boolean delete(String path, boolean recursive) throws IOException;
+
+ /**
+ * Makes directories, creating missing parent directories as needed.
+ * @param path the directory to create.
+ * @throws IOException On failure.
+ */
+ void mkdirs(String path) throws IOException;
+
+ /**
+ * Clears (formats) entire the filesystem.
+ * All the data in the filesystem are DESTROYED.
+ * @throws IOException
+ */
+ void format() throws IOException;
+
+ /**
+ * Gets properties (such as owner, group, and permissions) of a file.
+ * @param path the path to the file to get properties of.
+ * @return the properties.
+ */
+ Map<String,String> properties(String path) throws IOException;
+
+ /**
+ * Get permissions.
+ *
+ * @param path Path.
+ * @return Permissions.
+ * @throws IOException If failed.
+ */
+ String permissions(String path) throws IOException;
+
+ /**
+ * Opens input stream to read file contents.
+ * @param path the path to the file.
+ */
+ InputStream openInputStream(String path) throws IOException;
+
+ /**
+ * Opens output stream to write file contents.
+ * @param path the path to the file to be written.
+ * @param append if to append to the end of existing data.
+ * @return the OutputStream to write into.
+ * @throws IOException On failure.
+ */
+ OutputStream openOutputStream(String path, boolean append) throws IOException;
+
+ /**
+ * Get times for path.
+ *
+ * @param path Path.
+ * @return Times for path.
+ * @throws IOException If failed.
+ */
+ T2<Long, Long> times(String path) throws IOException;
+
+ /**
+ * Get underlying IGFS if it is possible.
+ *
+ * @return Underlying IGFS or null.
+ */
+ @Nullable IgfsEx igfs();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d0f7252c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/UniversalFileSystemAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/UniversalFileSystemAdapter.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/UniversalFileSystemAdapter.java
deleted file mode 100644
index 3f6d07e..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/UniversalFileSystemAdapter.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.typedef.T2;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Map;
-
-/**
- * Universal interface to an underlying filesystem.
- * Typically used for secondary filesystem.
- * To be used solely in tests.
- */
-public interface UniversalFileSystemAdapter {
- /**
- * Gets name of the FS.
- * @return name of this file system.
- * @throws IOException in case of failure.
- */
- String name() throws IOException;
-
- /**
- * Answers if a file denoted by path exists.
- * @param path path of the file to check.
- * @return if the file exists.
- * @throws IOException in case of failure.
- */
- boolean exists(String path) throws IOException;
-
- /**
- * Deletes a file or directory.
- * @param path the path to delete.
- * @param recursive instructs to delete a directory recursively.
- * @return true on success, false otherwise.
- * @throws IOException On failure.
- */
- boolean delete(String path, boolean recursive) throws IOException;
-
- /**
- * Makes directories, creating missing parent directories as needed.
- * @param path the directory to create.
- * @throws IOException On failure.
- */
- void mkdirs(String path) throws IOException;
-
- /**
- * Clears (formats) entire the filesystem.
- * All the data in the filesystem are DESTROYED.
- * @throws IOException
- */
- void format() throws IOException;
-
- /**
- * Gets properties (such as owner, group, and permissions) of a file.
- * @param path the path to the file to get properties of.
- * @return the properties.
- */
- Map<String,String> properties(String path) throws IOException;
-
- /**
- * Opens input stream to read file contents.
- * @param path the path to the file.
- */
- InputStream openInputStream(String path) throws IOException;
-
- /**
- * Opens output stream to write file contents.
- * @param path the path to the file to be written.
- * @param append if to append to the end of existing data.
- * @return the OutputStream to write into.
- * @throws IOException On failure.
- */
- OutputStream openOutputStream(String path, boolean append) throws IOException;
-
- /**
- * Get times for path.
- *
- * @param path Path.
- * @return Times for path.
- * @throws IOException If failed.
- */
- T2<Long, Long> times(String path) throws IOException;
-
- /**
- * Gets an entity of the given type (class) associated with this universal adapter.
- * @param clazz The class representing the type we wish to adapt to.
- * @param <T> The type we need to adapt to.
- * @return the adapter object of the given type.
- */
- <T> T unwrap(Class<T> clazz);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d0f7252c/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 0f17fa2..6b5c776 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
@@ -570,7 +570,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
/** {@inheritDoc} */
@Override public void stop() throws IgniteException {
if (fsFactory instanceof LifecycleAware)
- ((LifecycleAware)fsFactory).stop();
+ ((LifecycleAware)fsFactory).stop();
}
/** {@inheritDoc} */