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/07/22 09:26:02 UTC
[1/4] ignite git commit: Documentation fix
Repository: ignite
Updated Branches:
refs/heads/ignite-3530 [created] 60fd9c721
Documentation fix
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/11c7e8fe
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/11c7e8fe
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/11c7e8fe
Branch: refs/heads/ignite-3530
Commit: 11c7e8fe53461f84924e5c29893865191f236c8c
Parents: 6b8020d
Author: Anton Vinogradov <av...@apache.org>
Authored: Wed Jul 20 11:31:14 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Jul 20 11:31:14 2016 +0300
----------------------------------------------------------------------
.../stream/kafka/connect/package-info.java | 21 ++++++++++++++++++++
.../connect/serialization/package-info.java | 21 ++++++++++++++++++++
2 files changed, 42 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/11c7e8fe/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/package-info.java
----------------------------------------------------------------------
diff --git a/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/package-info.java b/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/package-info.java
new file mode 100644
index 0000000..47f450e
--- /dev/null
+++ b/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Contains implementation of Kafka Streamer Connector.
+ */
+package org.apache.ignite.stream.kafka.connect;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/11c7e8fe/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/package-info.java
----------------------------------------------------------------------
diff --git a/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/package-info.java b/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/package-info.java
new file mode 100644
index 0000000..2fd61ff
--- /dev/null
+++ b/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Contains implementation of Kafka Streamer Serializer.
+ */
+package org.apache.ignite.stream.kafka.connect.serialization;
\ No newline at end of file
[4/4] ignite git commit: IGNITE-3530: Implemented missing
IgniteSecondaryFileSystem.setTimes() operation.
Posted by vo...@apache.org.
IGNITE-3530: Implemented missing IgniteSecondaryFileSystem.setTimes() operation.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/60fd9c72
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/60fd9c72
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/60fd9c72
Branch: refs/heads/ignite-3530
Commit: 60fd9c7212a5f1374f779224c1b1c84bc62aad0b
Parents: 6c5218f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Jul 22 12:25:49 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Jul 22 12:25:49 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsImpl.java | 12 +-
.../processors/igfs/IgfsMetaManager.java | 115 ++++++++++++-------
.../igfs/IgfsSecondaryFileSystemImpl.java | 15 ++-
.../igfs/IgfsSecondaryFileSystemV2.java | 40 +++++++
.../processors/igfs/IgfsAbstractSelfTest.java | 109 +++++++++++++++++-
.../igfs/IgfsDualAbstractSelfTest.java | 25 ++++
.../igfs/IgfsExUniversalFileSystemAdapter.java | 15 +++
.../igfs/UniversalFileSystemAdapter.java | 11 ++
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 16 ++-
...oopFileSystemUniversalFileSystemAdapter.java | 8 ++
10 files changed, 305 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/60fd9c72/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 5b87698..df7dfb5 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
@@ -1139,16 +1139,12 @@ public final class IgfsImpl implements IgfsEx {
safeOp(new Callable<Void>() {
@Override public Void call() throws Exception {
- FileDescriptor desc = getFileDescriptor(path);
-
- if (desc == null)
- throw new IgfsPathNotFoundException("Failed to update times (path not found): " + path);
+ IgfsMode mode = resolveMode(path);
- // Cannot update times for root.
- if (desc.parentId == null)
- return null;
+ boolean useSecondary = IgfsUtils.isDualMode(mode) && secondaryFs instanceof IgfsSecondaryFileSystemV2;
- meta.updateTimes(desc.parentId, desc.fileId, desc.fileName, accessTime, modificationTime);
+ meta.updateTimes(path, accessTime, modificationTime,
+ useSecondary ? (IgfsSecondaryFileSystemV2)secondaryFs : null);
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60fd9c72/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 1640918..d891b38 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
@@ -51,14 +51,14 @@ import org.apache.ignite.internal.processors.igfs.client.IgfsClientAbstractCalla
import org.apache.ignite.internal.processors.igfs.client.meta.IgfsClientMetaIdsForPathCallable;
import org.apache.ignite.internal.processors.igfs.client.meta.IgfsClientMetaInfoForPathCallable;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryCreateProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingAddProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingRemoveProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingRenameProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingReplaceProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileCreateProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileLockProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileReserveSpaceProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileUnlockProcessor;
-import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingAddProcessor;
-import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingRemoveProcessor;
-import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingReplaceProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdatePropertiesProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdateTimesProcessor;
import org.apache.ignite.internal.util.GridLeanMap;
@@ -1155,16 +1155,20 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * Wheter operation must be re-tries because we have suspicious links which may broke secondary file system
+ * Whether operation must be re-tried because we have suspicious links which may broke secondary file system
* consistency.
*
* @param pathIds Path IDs.
* @param lockInfos Lock infos.
* @return Whether to re-try.
*/
- private boolean isRetryForSecondary(IgfsPathIds pathIds, Map<IgniteUuid, IgfsEntryInfo> lockInfos) {
+ private static boolean isRetryForSecondary(IgfsPathIds pathIds, Map<IgniteUuid, IgfsEntryInfo> lockInfos) {
// We need to ensure that the last locked info is not linked with expected child.
// Otherwise there was some concurrent file system update and we have to re-try.
+ // That is, the following situation lead to re-try:
+ // 1) We queried path /A/B/C
+ // 2) Returned IDs are ROOT_ID, A_ID, B_ID, null
+ // 3) But B's info contains C as child. It mean's that
if (!pathIds.allExists()) {
// Find the last locked index
IgfsEntryInfo lastLockedInfo = null;
@@ -2754,59 +2758,82 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * Updates last access and last modification times.
+ * Update times.
*
- * @param parentId File parent ID.
- * @param fileId File ID to update.
- * @param fileName File name to update. Must match file ID.
- * @param accessTime Access time to set. If {@code -1}, will not be updated.
- * @param modificationTime Modification time to set. If {@code -1}, will not be updated.
- * @throws IgniteCheckedException If update failed.
+ * @param path Path.
+ * @param accessTime Access time.
+ * @param modificationTime Modification time.
+ * @param secondaryFs Secondary file system.
+ * @throws IgniteCheckedException If failed.
*/
- public void updateTimes(IgniteUuid parentId, IgniteUuid fileId, String fileName, long accessTime,
- long modificationTime) throws IgniteCheckedException {
- if (busyLock.enterBusy()) {
- try {
- validTxState(false);
+ public void updateTimes(IgfsPath path, long accessTime, long modificationTime,
+ IgfsSecondaryFileSystemV2 secondaryFs) throws IgniteCheckedException {
+ while (true) {
+ if (busyLock.enterBusy()) {
+ try {
+ validTxState(false);
- // Start pessimistic transaction.
- try (IgniteInternalTx tx = startTx()) {
- Map<IgniteUuid, IgfsEntryInfo> infoMap = lockIds(fileId, parentId);
+ // Prepare path IDs.
+ IgfsPathIds pathIds = pathIds(path);
+
+ // Prepare lock IDs.
+ Set<IgniteUuid> lockIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
+
+ pathIds.addExistingIds(lockIds, relaxed);
+
+ // Start TX.
+ try (IgniteInternalTx tx = startTx()) {
+ Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
- IgfsEntryInfo fileInfo = infoMap.get(fileId);
+ if (secondaryFs != null && isRetryForSecondary(pathIds, lockInfos))
+ continue;
- if (fileInfo == null)
- throw fsException(new IgfsPathNotFoundException("Failed to update times " +
- "(path was not found): " + fileName));
+ if (!pathIds.verifyIntegrity(lockInfos, relaxed))
+ // Directory structure changed concurrently. So we re-try.
+ continue;
- IgfsEntryInfo parentInfo = infoMap.get(parentId);
+ if (pathIds.allExists()) {
+ // All files are in place. Update both primary and secondary file systems.
+ if (secondaryFs != null)
+ secondaryFs.setTimes(path, accessTime, modificationTime);
- if (parentInfo == null)
- throw fsException(new IgfsPathNotFoundException("Failed to update times " +
- "(parent was not found): " + fileName));
+ IgniteUuid targetId = pathIds.lastExistingId();
+ IgfsEntryInfo targetInfo = lockInfos.get(targetId);
- // Validate listing.
- if (!parentInfo.hasChild(fileName, fileId))
- throw fsException(new IgfsConcurrentModificationException("Failed to update times " +
- "(file concurrently modified): " + fileName));
+ id2InfoPrj.invoke(targetId, new IgfsMetaUpdateTimesProcessor(
+ accessTime == -1 ? targetInfo.accessTime() : accessTime,
+ modificationTime == -1 ? targetInfo.modificationTime() : modificationTime)
+ );
- assert parentInfo.isDirectory();
+ tx.commit();
- id2InfoPrj.invoke(fileId, new IgfsMetaUpdateTimesProcessor(
- accessTime == -1 ? fileInfo.accessTime() : accessTime,
- modificationTime == -1 ? fileInfo.modificationTime() : modificationTime)
- );
+ return;
+ }
+ else {
+ // Propagate call to the secondary FS, as we might haven't cache this part yet.
+ if (secondaryFs != null) {
+ secondaryFs.setTimes(path, accessTime, modificationTime);
- tx.commit();
+ return;
+ }
+ else
+ throw new IgfsPathNotFoundException("Failed to update times (path not found): " + path);
+ }
+ }
+ }
+ catch (IgniteException | IgniteCheckedException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ throw new IgniteCheckedException("setTimes failed due to unexpected exception: " + path, e);
+ }
+ finally {
+ busyLock.leaveBusy();
}
}
- finally {
- busyLock.leaveBusy();
- }
+ else
+ throw new IllegalStateException("Failed to update times because Grid is stopping: " + path);
}
- else
- throw new IllegalStateException("Failed to update times because Grid is stopping [parentId=" + parentId +
- ", fileId=" + fileId + ", fileName=" + fileName + ']');
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/60fd9c72/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java
index 44e858f..453682c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java
@@ -17,20 +17,20 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Map;
import org.apache.ignite.IgniteException;
import org.apache.ignite.igfs.IgfsFile;
import org.apache.ignite.igfs.IgfsPath;
-import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadable;
import org.jetbrains.annotations.Nullable;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Map;
+
/**
* Secondary file system over native IGFS.
*/
-class IgfsSecondaryFileSystemImpl implements IgfsSecondaryFileSystem {
+class IgfsSecondaryFileSystemImpl implements IgfsSecondaryFileSystemV2 {
/** Delegate. */
private final IgfsEx igfs;
@@ -115,4 +115,9 @@ class IgfsSecondaryFileSystemImpl implements IgfsSecondaryFileSystem {
@Override public long usedSpaceSize() throws IgniteException {
return igfs.usedSpaceSize();
}
+
+ /** {@inheritDoc} */
+ @Override public void setTimes(IgfsPath path, long accessTime, long modificationTime) throws IgniteException {
+ igfs.setTimes(path, accessTime, modificationTime);
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/60fd9c72/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemV2.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemV2.java
new file mode 100644
index 0000000..3775574
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemV2.java
@@ -0,0 +1,40 @@
+/*
+ * 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.IgniteException;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
+
+/**
+ * Extended version of secondary file system with missing methods.
+ *
+ * @deprecated Will be removed in Apache Ignite 2.0. Methods will be merged to {@link IgfsSecondaryFileSystem}.
+ */
+@Deprecated
+public interface IgfsSecondaryFileSystemV2 extends IgfsSecondaryFileSystem {
+ /**
+ * Set times for the given path.
+ *
+ * @param path Path.
+ * @param accessTime Access time.
+ * @param modificationTime Modification time.
+ * @throws IgniteException If failed.
+ */
+ public void setTimes(IgfsPath path, long accessTime, long modificationTime) throws IgniteException;
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60fd9c72/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 c1c6c6c..0fda5c8 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
@@ -50,6 +50,7 @@ import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
@@ -1123,6 +1124,110 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
}
/**
+ * Test setTimes operation.
+ *
+ * @throws Exception If failed.
+ */
+ public void testSetTimes() throws Exception {
+ createFile(igfs.asSecondary(), FILE, true, chunk);
+
+ checkExist(igfs, igfsSecondary, DIR);
+ checkExist(igfs, igfsSecondary, SUBDIR);
+ checkExist(igfs, igfsSecondary, FILE);
+
+ checkSetTimes(SUBDIR);
+ checkSetTimes(FILE);
+
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ igfs.setTimes(FILE2, Long.MAX_VALUE, Long.MAX_VALUE);
+
+ return null;
+ }
+ }, Exception.class, null);
+ }
+
+ /**
+ * Check setTimes logic for path.
+ *
+ * @param path Path.
+ * @throws Exception If failed.
+ */
+ private void checkSetTimes(IgfsPath path) throws Exception {
+ IgfsFile info = igfs.info(path);
+
+ assert info != null;
+
+ // Change nothing.
+ igfs.setTimes(path, -1, -1);
+
+ IgfsFile newInfo = igfs.info(path);
+
+ assert newInfo != null;
+
+ assertEquals(info.accessTime(), newInfo.accessTime());
+ assertEquals(info.modificationTime(), newInfo.modificationTime());
+
+ if (dual) {
+ T2<Long, Long> secondaryTimes = igfsSecondary.times(path.toString());
+
+ assertEquals(newInfo.accessTime(), (long)secondaryTimes.get1());
+ assertEquals(newInfo.modificationTime(), (long)secondaryTimes.get2());
+ }
+
+ // Change only access time.
+ igfs.setTimes(path, info.accessTime() + 1, -1);
+
+ newInfo = igfs.info(path);
+
+ assert newInfo != null;
+
+ assertEquals(info.accessTime() + 1, newInfo.accessTime());
+ assertEquals(info.modificationTime(), newInfo.modificationTime());
+
+ if (dual) {
+ T2<Long, Long> secondaryTimes = igfsSecondary.times(path.toString());
+
+ assertEquals(newInfo.accessTime(), (long)secondaryTimes.get1());
+ assertEquals(newInfo.modificationTime(), (long)secondaryTimes.get2());
+ }
+
+ // Change only modification time.
+ igfs.setTimes(path, -1, info.modificationTime() + 1);
+
+ newInfo = igfs.info(path);
+
+ assert newInfo != null;
+
+ assertEquals(info.accessTime() + 1, newInfo.accessTime());
+ assertEquals(info.modificationTime() + 1, newInfo.modificationTime());
+
+ if (dual) {
+ T2<Long, Long> secondaryTimes = igfsSecondary.times(path.toString());
+
+ assertEquals(newInfo.accessTime(), (long)secondaryTimes.get1());
+ assertEquals(newInfo.modificationTime(), (long)secondaryTimes.get2());
+ }
+
+ // Change both.
+ igfs.setTimes(path, info.accessTime() + 2, info.modificationTime() + 2);
+
+ newInfo = igfs.info(path);
+
+ assert newInfo != null;
+
+ assertEquals(info.accessTime() + 2, newInfo.accessTime());
+ assertEquals(info.modificationTime() + 2, newInfo.modificationTime());
+
+ if (dual) {
+ T2<Long, Long> secondaryTimes = igfsSecondary.times(path.toString());
+
+ assertEquals(newInfo.accessTime(), (long)secondaryTimes.get1());
+ assertEquals(newInfo.modificationTime(), (long)secondaryTimes.get2());
+ }
+ }
+
+ /**
* Test regular create.
*
* @throws Exception If failed.
@@ -2764,8 +2869,8 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param chunks Data chunks.
* @throws IOException In case of IO exception.
*/
- protected static void createFile(IgfsSecondaryFileSystem igfs, IgfsPath file, boolean overwrite, @Nullable byte[]... chunks)
- throws IOException {
+ protected static void createFile(IgfsSecondaryFileSystem igfs, IgfsPath file, boolean overwrite,
+ @Nullable byte[]... chunks) throws IOException {
OutputStream os = null;
try {
http://git-wip-us.apache.org/repos/asf/ignite/blob/60fd9c72/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 b8c8978..1fa86ff 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
@@ -1682,4 +1682,29 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
assertEquals(timesFile0, timesFile1);
assertEquals(timesFile20, timesFile21);
}
+
+ /**
+ * Test setTimes method when path is partially missing.
+ *
+ * @throws Exception If failed.
+ */
+ public void testSetTimesMissingPartially() throws Exception {
+ create(igfs, paths(DIR), null);
+
+ createFile(igfsSecondary, FILE, chunk);
+
+ igfs.setTimes(FILE, Long.MAX_VALUE - 1, Long.MAX_VALUE);
+
+ IgfsFile info = igfs.info(FILE);
+
+ assert info != null;
+
+ assertEquals(Long.MAX_VALUE - 1, info.accessTime());
+ assertEquals(Long.MAX_VALUE, info.modificationTime());
+
+ T2<Long, Long> secondaryTimes = igfsSecondary.times(FILE.toString());
+
+ assertEquals(info.accessTime(), (long)secondaryTimes.get1());
+ assertEquals(info.modificationTime(), (long)secondaryTimes.get2());
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/60fd9c72/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
index c6bef72..80b320b 100644
--- 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
@@ -21,8 +21,11 @@ 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.
@@ -60,6 +63,7 @@ public class IgfsExUniversalFileSystemAdapter implements UniversalFileSystemAdap
}
/** {@inheritDoc} */
+ @SuppressWarnings("ConstantConditions")
@Override public Map<String, String> properties(String path) {
return igfsEx.info(new IgfsPath(path)).properties();
}
@@ -92,6 +96,17 @@ public class IgfsExUniversalFileSystemAdapter implements UniversalFileSystemAdap
}
/** {@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;
http://git-wip-us.apache.org/repos/asf/ignite/blob/60fd9c72/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
index eef0057..3f6d07e 100644
--- 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
@@ -17,6 +17,8 @@
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;
@@ -89,6 +91,15 @@ public interface UniversalFileSystemAdapter {
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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/60fd9c72/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 329c605..73a5c8d 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
@@ -36,13 +36,13 @@ import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.igfs.IgfsPathAlreadyExistsException;
import org.apache.ignite.igfs.IgfsPathNotFoundException;
import org.apache.ignite.igfs.IgfsUserContext;
-import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadable;
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.IgfsSecondaryFileSystemV2;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.lang.IgniteOutClosure;
@@ -66,7 +66,7 @@ import java.util.concurrent.Callable;
* <p>
* Target {@code FileSystem}'s are created on per-user basis using passed {@link HadoopFileSystemFactory}.
*/
-public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem, LifecycleAware,
+public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSystemV2, LifecycleAware,
HadoopPayloadAware {
/** The default user name. It is used if no user context is set. */
private String dfltUsrName;
@@ -515,6 +515,18 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
}
}
+ /** {@inheritDoc} */
+ @Override public void setTimes(IgfsPath path, long accessTime, long modificationTime) throws IgniteException {
+ try {
+ // We don't use FileSystem#getUsed() since it counts only the files
+ // in the filesystem root, not all the files recursively.
+ fileSystemForUser().setTimes(convert(path), accessTime, modificationTime);
+ }
+ catch (IOException e) {
+ throw handleSecondaryFsError(e, "Failed set times for path: " + path);
+ }
+ }
+
/**
* Gets the underlying {@link FileSystem}.
* This method is used solely for testing.
http://git-wip-us.apache.org/repos/asf/ignite/blob/60fd9c72/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
index 44b8f40..5239054 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
@@ -31,6 +31,7 @@ import org.apache.ignite.hadoop.fs.HadoopFileSystemFactory;
import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsUtils;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.processors.igfs.UniversalFileSystemAdapter;
+import org.apache.ignite.internal.util.typedef.T2;
/**
* Universal adapter wrapping {@link org.apache.hadoop.fs.FileSystem} instance.
@@ -111,6 +112,13 @@ public class HadoopFileSystemUniversalFileSystemAdapter implements UniversalFile
}
/** {@inheritDoc} */
+ @Override public T2<Long, Long> times(String path) throws IOException {
+ FileStatus status = get().getFileStatus(new Path(path));
+
+ return new T2<>(status.getAccessTime(), status.getModificationTime());
+ }
+
+ /** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public <T> T unwrap(Class<T> cls) {
if (HadoopFileSystemFactory.class.isAssignableFrom(cls))
[2/4] ignite git commit: IGNITE-3405: IGFS: Restricted path modes
interleaving,
so that now only DUAL -> PRIMARY and DUAL -> PROXY paths are possible.
Posted by vo...@apache.org.
IGNITE-3405: IGFS: Restricted path modes interleaving, so that now only DUAL -> PRIMARY and DUAL -> PROXY paths are possible.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9b556587
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9b556587
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9b556587
Branch: refs/heads/ignite-3530
Commit: 9b55658749d0e2a869bbb3614034d8aa1f0e95c1
Parents: 51add50
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Jul 20 14:14:50 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Jul 20 14:14:50 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsImpl.java | 77 ++---
.../processors/igfs/IgfsModeResolver.java | 94 +-----
.../internal/processors/igfs/IgfsUtils.java | 83 +++++
...sCachePerBlockLruEvictionPolicySelfTest.java | 7 +-
.../processors/igfs/IgfsMetricsSelfTest.java | 54 +--
.../igfs/IgfsModeResolverSelfTest.java | 124 +++++--
.../processors/igfs/IgfsModesSelfTest.java | 61 ++--
.../hadoop/fs/v2/IgniteHadoopFileSystem.java | 22 +-
.../igfs/HadoopFIleSystemFactorySelfTest.java | 2 +-
...teHadoopFileSystemSecondaryModeSelfTest.java | 327 -------------------
.../testsuites/IgniteHadoopTestSuite.java | 2 -
11 files changed, 276 insertions(+), 577 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/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 efb347f..5b87698 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
@@ -94,7 +94,6 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
@@ -210,7 +209,7 @@ public final class IgfsImpl implements IgfsEx {
Map<String, IgfsMode> cfgModes = new LinkedHashMap<>();
Map<String, IgfsMode> dfltModes = new LinkedHashMap<>(4, 1.0f);
- if (cfg.isInitializeDefaultPathModes()) {
+ if (cfg.isInitializeDefaultPathModes() && IgfsUtils.isDualMode(dfltMode)) {
dfltModes.put("/ignite/primary", PRIMARY);
if (secondaryFs != null) {
@@ -222,8 +221,8 @@ public final class IgfsImpl implements IgfsEx {
cfgModes.putAll(dfltModes);
- if (igfsCtx.configuration().getPathModes() != null) {
- for (Map.Entry<String, IgfsMode> e : igfsCtx.configuration().getPathModes().entrySet()) {
+ if (cfg.getPathModes() != null) {
+ for (Map.Entry<String, IgfsMode> e : cfg.getPathModes().entrySet()) {
if (!dfltModes.containsKey(e.getKey()))
cfgModes.put(e.getKey(), e.getValue());
else
@@ -249,7 +248,7 @@ public final class IgfsImpl implements IgfsEx {
}
}
- modeRslvr = new IgfsModeResolver(dfltMode, modes);
+ modeRslvr = new IgfsModeResolver(dfltMode, IgfsUtils.preparePathModes(dfltMode, modes));
Object secondaryFsPayload = null;
@@ -620,7 +619,7 @@ public final class IgfsImpl implements IgfsEx {
IgfsMode mode = resolveMode(path);
if (mode != PRIMARY) {
- assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
+ assert IgfsUtils.isDualMode(mode);
await(path);
@@ -671,8 +670,6 @@ public final class IgfsImpl implements IgfsEx {
IgfsMode mode = resolveMode(src);
- Set<IgfsMode> childrenModes = modeRslvr.resolveChildrenModes(src);
-
if (src.equals(dest))
return null; // Rename to itself is a no-op.
@@ -689,8 +686,8 @@ public final class IgfsImpl implements IgfsEx {
throw new IgfsInvalidPathException("Cannot move file to a path with different eviction " +
"exclude setting (need to copy and remove)");
- if (!childrenModes.equals(Collections.singleton(PRIMARY))) {
- assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
+ if (mode != PRIMARY) {
+ assert IgfsUtils.isDualMode(mode); // PROXY mode explicit usage is forbidden.
await(src, dest);
@@ -721,9 +718,9 @@ public final class IgfsImpl implements IgfsEx {
if (IgfsPath.SLASH.equals(path.toString()))
return false;
- Set<IgfsMode> childrenModes = modeRslvr.resolveChildrenModes(path);
+ IgfsMode mode = resolveMode(path);
- boolean dual = childrenModes.contains(DUAL_SYNC) ||childrenModes.contains(DUAL_ASYNC);
+ boolean dual = IgfsUtils.isDualMode(mode);;
if (dual)
await(path);
@@ -767,7 +764,7 @@ public final class IgfsImpl implements IgfsEx {
if (mode == PRIMARY)
meta.mkdirs(path, props0);
else {
- assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
+ assert IgfsUtils.isDualMode(mode);;
await(path);
@@ -794,11 +791,9 @@ public final class IgfsImpl implements IgfsEx {
IgfsMode mode = resolveMode(path);
- Set<IgfsMode> childrenModes = modeRslvr.resolveChildrenModes(path);
-
Collection<String> files = new HashSet<>();
- if (childrenModes.contains(DUAL_SYNC) || childrenModes.contains(DUAL_ASYNC)) {
+ if (IgfsUtils.isDualMode(mode)) {
assert secondaryFs != null;
try {
@@ -818,11 +813,8 @@ public final class IgfsImpl implements IgfsEx {
if (fileId != null)
files.addAll(meta.directoryListing(fileId).keySet());
- else if (mode == PRIMARY) {
- checkConflictWithPrimary(path);
-
+ else if (mode == PRIMARY)
throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
- }
return F.viewReadOnly(files, new C1<String, IgfsPath>() {
@Override public IgfsPath apply(String e) {
@@ -847,11 +839,9 @@ public final class IgfsImpl implements IgfsEx {
IgfsMode mode = resolveMode(path);
- Set<IgfsMode> childrenModes = modeRslvr.resolveChildrenModes(path);
-
Collection<IgfsFile> files = new HashSet<>();
- if (childrenModes.contains(DUAL_SYNC) || childrenModes.contains(DUAL_ASYNC)) {
+ if (IgfsUtils.isDualMode(mode)) {
assert secondaryFs != null;
try {
@@ -894,11 +884,8 @@ public final class IgfsImpl implements IgfsEx {
}
}
}
- else if (mode == PRIMARY) {
- checkConflictWithPrimary(path);
-
+ else if (mode == PRIMARY)
throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
- }
return files;
}
@@ -937,7 +924,7 @@ public final class IgfsImpl implements IgfsEx {
IgfsMode mode = resolveMode(path);
if (mode != PRIMARY) {
- assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
+ assert IgfsUtils.isDualMode(mode);
IgfsSecondaryInputStreamDescriptor desc = meta.openDual(secondaryFs, path, bufSize0);
@@ -951,11 +938,8 @@ public final class IgfsImpl implements IgfsEx {
IgfsEntryInfo info = meta.infoForPath(path);
- if (info == null) {
- checkConflictWithPrimary(path);
-
+ if (info == null)
throw new IgfsPathNotFoundException("File not found: " + path);
- }
if (!info.isFile())
throw new IgfsPathIsDirectoryException("Failed to open file (not a file): " + path);
@@ -1089,7 +1073,7 @@ public final class IgfsImpl implements IgfsEx {
IgfsFileWorkerBatch batch;
if (mode != PRIMARY) {
- assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
+ assert IgfsUtils.isDualMode(mode);
await(path);
@@ -1105,11 +1089,8 @@ public final class IgfsImpl implements IgfsEx {
final IgniteUuid id = ids.get(ids.size() - 1);
if (id == null) {
- if (!create) {
- checkConflictWithPrimary(path);
-
+ if (!create)
throw new IgfsPathNotFoundException("File not found: " + path);
- }
}
// Prevent attempt to append to ROOT in early stage:
@@ -1160,11 +1141,8 @@ public final class IgfsImpl implements IgfsEx {
@Override public Void call() throws Exception {
FileDescriptor desc = getFileDescriptor(path);
- if (desc == null) {
- checkConflictWithPrimary(path);
-
+ if (desc == null)
throw new IgfsPathNotFoundException("Failed to update times (path not found): " + path);
- }
// Cannot update times for root.
if (desc.parentId == null)
@@ -1177,21 +1155,6 @@ public final class IgfsImpl implements IgfsEx {
});
}
- /**
- * Checks if given path exists in secondary file system and throws exception if so.
- *
- * @param path Path to check.
- * @throws IgniteCheckedException If path exists.
- */
- private void checkConflictWithPrimary(IgfsPath path) throws IgniteCheckedException {
- if (secondaryFs != null) {
- if (secondaryFs.info(path) != null) {
- throw new IgfsInvalidPathException("Path mapped to a PRIMARY mode found in secondary file " +
- "system. Remove path from secondary file system or change path mapping: " + path);
- }
- }
- }
-
/** {@inheritDoc} */
@Override public Collection<IgfsBlockLocation> affinity(IgfsPath path, long start, long len) {
return affinity(path, start, len, 0L);
@@ -1218,7 +1181,7 @@ public final class IgfsImpl implements IgfsEx {
IgfsEntryInfo info = meta.infoForPath(path);
if (info == null && mode != PRIMARY) {
- assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
+ assert IgfsUtils.isDualMode(mode);
assert secondaryFs != null;
// Synchronize
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolver.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolver.java
index 70da103..907051f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolver.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolver.java
@@ -17,13 +17,9 @@
package org.apache.ignite.internal.processors.igfs;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap;
@@ -41,39 +37,26 @@ public class IgfsModeResolver {
private final IgfsMode dfltMode;
/** Modes for particular paths. Ordered from longest to shortest. */
- private ArrayList<T2<IgfsPath, IgfsMode>> modes;
+ private List<T2<IgfsPath, IgfsMode>> modes;
/** Cached modes per path. */
private Map<IgfsPath, IgfsMode> modesCache;
- /** Cached children modes per path. */
- private Map<IgfsPath, Set<IgfsMode>> childrenModesCache;
-
/**
+ * Constructor
+ *
* @param dfltMode Default IGFS mode.
- * @param modes List of configured modes.
+ * @param modes List of configured modes. The order is significant as modes are added in order of occurrence.
*/
public IgfsModeResolver(IgfsMode dfltMode, @Nullable List<T2<IgfsPath, IgfsMode>> modes) {
assert dfltMode != null;
this.dfltMode = dfltMode;
- if (modes != null) {
- ArrayList<T2<IgfsPath, IgfsMode>> modes0 = new ArrayList<>(modes);
-
- // Sort paths, longest first.
- Collections.sort(modes0, new Comparator<Map.Entry<IgfsPath, IgfsMode>>() {
- @Override public int compare(Map.Entry<IgfsPath, IgfsMode> o1,
- Map.Entry<IgfsPath, IgfsMode> o2) {
- return o2.getKey().components().size() - o1.getKey().components().size();
- }
- });
-
- this.modes = modes0;
+ this.modes = modes;
+ if (modes != null)
modesCache = new GridBoundedConcurrentLinkedHashMap<>(MAX_PATH_CACHE);
- childrenModesCache = new GridBoundedConcurrentLinkedHashMap<>(MAX_PATH_CACHE);
- }
}
/**
@@ -92,7 +75,7 @@ public class IgfsModeResolver {
if (mode == null) {
for (T2<IgfsPath, IgfsMode> entry : modes) {
- if (startsWith(path, entry.getKey())) {
+ if (path.isSame(entry.getKey()) || path.isSubDirectoryOf(entry.getKey())) {
// As modes ordered from most specific to least specific first mode found is ours.
mode = entry.getValue();
@@ -111,73 +94,10 @@ public class IgfsModeResolver {
}
/**
- * @param path Path.
- * @return Set of all modes that children paths could have.
- */
- public Set<IgfsMode> resolveChildrenModes(IgfsPath path) {
- assert path != null;
-
- if (modes == null)
- return Collections.singleton(dfltMode);
- else {
- Set<IgfsMode> children = childrenModesCache.get(path);
-
- if (children == null) {
- children = new HashSet<>(IgfsMode.values().length, 1.0f);
-
- IgfsMode pathDefault = dfltMode;
-
- for (T2<IgfsPath, IgfsMode> child : modes) {
- if (startsWith(path, child.getKey())) {
- pathDefault = child.getValue();
-
- break;
- }
- else if (startsWith(child.getKey(), path))
- children.add(child.getValue());
- }
-
- children.add(pathDefault);
-
- childrenModesCache.put(path, children);
- }
-
- return children;
- }
- }
-
- /**
* @return Unmodifiable copy of properly ordered modes prefixes
* or {@code null} if no modes set.
*/
@Nullable public List<T2<IgfsPath, IgfsMode>> modesOrdered() {
return modes != null ? Collections.unmodifiableList(modes) : null;
}
-
- /**
- * Check if path starts with prefix.
- *
- * @param path Path.
- * @param prefix Prefix.
- * @return {@code true} if path starts with prefix, {@code false} if not.
- */
- private static boolean startsWith(IgfsPath path, IgfsPath prefix) {
- List<String> p1Comps = path.components();
- List<String> p2Comps = prefix.components();
-
- if (p2Comps.size() > p1Comps.size())
- return false;
-
- for (int i = 0; i < p1Comps.size(); i++) {
- if (i >= p2Comps.size() || p2Comps.get(i) == null)
- // All prefix components already matched.
- return true;
-
- if (!p1Comps.get(i).equals(p2Comps.get(i)))
- return false;
- }
-
- // Path and prefix components had same length and all of them matched.
- return true;
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/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 7310b4c..03b7611 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
@@ -31,6 +31,7 @@ import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.IgfsEvent;
import org.apache.ignite.igfs.IgfsException;
+import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.GridKernalContext;
@@ -42,6 +43,7 @@ import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -52,12 +54,18 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_RETRIES_COUNT;
+import static org.apache.ignite.igfs.IgfsMode.DUAL_ASYNC;
+import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGFS;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
@@ -784,4 +792,79 @@ public class IgfsUtils {
return false;
}
+
+ /**
+ * Check whether mode is dual.
+ *
+ * @param mode Mode.
+ * @return {@code True} if dual.
+ */
+ public static boolean isDualMode(IgfsMode mode) {
+ return mode == DUAL_SYNC || mode == DUAL_ASYNC;
+ }
+
+ /**
+ * Answers if directory of this mode can contain a subdirectory of the given mode.
+ *
+ * @param parent Parent mode.
+ * @param child Child mode.
+ * @return {@code true} if directory of this mode can contain a directory of the given mode.
+ */
+ public static boolean canContain(IgfsMode parent, IgfsMode child) {
+ return isDualMode(parent) || parent == child;
+ }
+
+ /**
+ * Checks, filters and sorts the modes.
+ *
+ * @param dfltMode The root mode. Must always be not null.
+ * @param modes The subdirectory modes.
+ * @return Descending list of filtered and checked modes.
+ * @throws IgniteCheckedException On error or
+ */
+ public static ArrayList<T2<IgfsPath, IgfsMode>> preparePathModes(final IgfsMode dfltMode,
+ @Nullable List<T2<IgfsPath, IgfsMode>> modes) throws IgniteCheckedException {
+ if (modes == null)
+ return null;
+
+ // Sort by depth, shallow first.
+ Collections.sort(modes, new Comparator<Map.Entry<IgfsPath, IgfsMode>>() {
+ @Override public int compare(Map.Entry<IgfsPath, IgfsMode> o1, Map.Entry<IgfsPath, IgfsMode> o2) {
+ return o1.getKey().depth() - o2.getKey().depth();
+ }
+ });
+
+ ArrayList<T2<IgfsPath, IgfsMode>> resModes = new ArrayList<>(modes.size() + 1);
+
+ resModes.add(new T2<>(new IgfsPath("/"), dfltMode));
+
+ for (T2<IgfsPath, IgfsMode> mode : modes) {
+ assert mode.getKey() != null;
+
+ for (T2<IgfsPath, IgfsMode> resMode : resModes) {
+ if (mode.getKey().isSubDirectoryOf(resMode.getKey())) {
+ assert resMode.getValue() != null;
+
+ if (resMode.getValue() == mode.getValue())
+ // No reason to add a sub-path of the same mode, ignore this pair.
+ break;
+
+ if (!canContain(resMode.getValue(), mode.getValue()))
+ throw new IgniteCheckedException("Subdirectory " + mode.getKey() + " mode "
+ + mode.getValue() + " is not compatible with upper level "
+ + resMode.getKey() + " directory mode " + resMode.getValue() + ".");
+
+ // Add to the 1st position (deep first).
+ resModes.add(0, mode);
+
+ break;
+ }
+ }
+ }
+
+ // Remove root, because this class contract is that root mode is not contained in the list.
+ resModes.remove(resModes.size() - 1);
+
+ return resModes;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java
index 8cb8f44..93171ba 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java
@@ -102,14 +102,14 @@ public class IgfsCachePerBlockLruEvictionPolicySelfTest extends IgfsCommonAbstra
igfsCfg.setMetaCacheName("metaCache");
igfsCfg.setName(IGFS_PRIMARY);
igfsCfg.setBlockSize(512);
- igfsCfg.setDefaultMode(PRIMARY);
+ igfsCfg.setDefaultMode(DUAL_SYNC);
igfsCfg.setPrefetchBlocks(1);
igfsCfg.setSequentialReadsBeforePrefetch(Integer.MAX_VALUE);
igfsCfg.setSecondaryFileSystem(secondaryFs.asSecondary());
Map<String, IgfsMode> pathModes = new HashMap<>();
- pathModes.put(FILE_RMT.toString(), DUAL_SYNC);
+ pathModes.put(FILE.toString(), PRIMARY);
igfsCfg.setPathModes(pathModes);
@@ -487,7 +487,8 @@ public class IgfsCachePerBlockLruEvictionPolicySelfTest extends IgfsCommonAbstra
* @param curBlocks Current blocks.
* @param curBytes Current bytes.
*/
- private void checkEvictionPolicy(final int curBlocks, final long curBytes) throws IgniteInterruptedCheckedException {
+ private void checkEvictionPolicy(final int curBlocks, final long curBytes)
+ throws IgniteInterruptedCheckedException {
assert GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override public boolean apply() {
return evictPlc.getCurrentBlocks() == curBlocks && evictPlc.getCurrentSize() == curBytes;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetricsSelfTest.java
index fb1d6f7..38cfc00 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetricsSelfTest.java
@@ -123,12 +123,12 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
igfsCfg.setMetaCacheName("metaCache");
igfsCfg.setName(IGFS_PRIMARY);
igfsCfg.setBlockSize(PRIMARY_BLOCK_SIZE);
- igfsCfg.setDefaultMode(PRIMARY);
+ igfsCfg.setDefaultMode(DUAL_SYNC);
igfsCfg.setSecondaryFileSystem(igfsSecondary.asSecondary());
Map<String, IgfsMode> pathModes = new HashMap<>();
- pathModes.put("/fileRemote", DUAL_SYNC);
+ pathModes.put("/primary", PRIMARY);
igfsCfg.setPathModes(pathModes);
@@ -233,35 +233,35 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
assertEquals(0, m.filesOpenedForRead());
assertEquals(0, m.filesOpenedForWrite());
- fs.mkdirs(new IgfsPath("/dir1"));
+ fs.mkdirs(new IgfsPath("/primary/dir1"));
m = fs.metrics();
assertNotNull(m);
- assertEquals(1, m.directoriesCount());
+ assertEquals(2, m.directoriesCount());
assertEquals(0, m.filesCount());
assertEquals(0, m.filesOpenedForRead());
assertEquals(0, m.filesOpenedForWrite());
- fs.mkdirs(new IgfsPath("/dir1/dir2/dir3"));
- fs.mkdirs(new IgfsPath("/dir4"));
+ fs.mkdirs(new IgfsPath("/primary/dir1/dir2/dir3"));
+ fs.mkdirs(new IgfsPath("/primary/dir4"));
m = fs.metrics();
assertNotNull(m);
- assertEquals(4, m.directoriesCount());
+ assertEquals(5, m.directoriesCount());
assertEquals(0, m.filesCount());
assertEquals(0, m.filesOpenedForRead());
assertEquals(0, m.filesOpenedForWrite());
- IgfsOutputStream out1 = fs.create(new IgfsPath("/dir1/file1"), false);
- IgfsOutputStream out2 = fs.create(new IgfsPath("/dir1/file2"), false);
- IgfsOutputStream out3 = fs.create(new IgfsPath("/dir1/dir2/file"), false);
+ IgfsOutputStream out1 = fs.create(new IgfsPath("/primary/dir1/file1"), false);
+ IgfsOutputStream out2 = fs.create(new IgfsPath("/primary/dir1/file2"), false);
+ IgfsOutputStream out3 = fs.create(new IgfsPath("/primary/dir1/dir2/file"), false);
m = fs.metrics();
assertNotNull(m);
- assertEquals(4, m.directoriesCount());
+ assertEquals(5, m.directoriesCount());
assertEquals(3, m.filesCount());
assertEquals(0, m.filesOpenedForRead());
assertEquals(3, m.filesOpenedForWrite());
@@ -275,7 +275,7 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
m = fs.metrics();
assertNotNull(m);
- assertEquals(4, m.directoriesCount());
+ assertEquals(5, m.directoriesCount());
assertEquals(3, m.filesCount());
assertEquals(0, m.filesOpenedForRead());
assertEquals(2, m.filesOpenedForWrite());
@@ -286,19 +286,19 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
m = fs.metrics();
assertNotNull(m);
- assertEquals(4, m.directoriesCount());
+ assertEquals(5, m.directoriesCount());
assertEquals(3, m.filesCount());
assertEquals(0, m.filesOpenedForRead());
assertEquals(0, m.filesOpenedForWrite());
- IgfsOutputStream out = fs.append(new IgfsPath("/dir1/file1"), false);
+ IgfsOutputStream out = fs.append(new IgfsPath("/primary/dir1/file1"), false);
out.write(new byte[20]);
m = fs.metrics();
assertNotNull(m);
- assertEquals(4, m.directoriesCount());
+ assertEquals(5, m.directoriesCount());
assertEquals(3, m.filesCount());
assertEquals(0, m.filesOpenedForRead());
assertEquals(1, m.filesOpenedForWrite());
@@ -310,18 +310,18 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
m = fs.metrics();
assertNotNull(m);
- assertEquals(4, m.directoriesCount());
+ assertEquals(5, m.directoriesCount());
assertEquals(3, m.filesCount());
assertEquals(0, m.filesOpenedForRead());
assertEquals(0, m.filesOpenedForWrite());
- IgfsInputStream in1 = fs.open(new IgfsPath("/dir1/file1"));
- IgfsInputStream in2 = fs.open(new IgfsPath("/dir1/file2"));
+ IgfsInputStream in1 = fs.open(new IgfsPath("/primary/dir1/file1"));
+ IgfsInputStream in2 = fs.open(new IgfsPath("/primary/dir1/file2"));
m = fs.metrics();
assertNotNull(m);
- assertEquals(4, m.directoriesCount());
+ assertEquals(5, m.directoriesCount());
assertEquals(3, m.filesCount());
assertEquals(2, m.filesOpenedForRead());
assertEquals(0, m.filesOpenedForWrite());
@@ -332,18 +332,18 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
m = fs.metrics();
assertNotNull(m);
- assertEquals(4, m.directoriesCount());
+ assertEquals(5, m.directoriesCount());
assertEquals(3, m.filesCount());
assertEquals(0, m.filesOpenedForRead());
assertEquals(0, m.filesOpenedForWrite());
- fs.delete(new IgfsPath("/dir1/file1"), false);
- fs.delete(new IgfsPath("/dir1/dir2"), true);
+ fs.delete(new IgfsPath("/primary/dir1/file1"), false);
+ fs.delete(new IgfsPath("/primary/dir1/dir2"), true);
m = fs.metrics();
assertNotNull(m);
- assertEquals(2, m.directoriesCount());
+ assertEquals(3, m.directoriesCount());
assertEquals(1, m.filesCount());
assertEquals(0, m.filesOpenedForRead());
assertEquals(0, m.filesOpenedForWrite());
@@ -363,12 +363,12 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
public void testMultipleClose() throws Exception {
IgniteFileSystem fs = igfsPrimary[0];
- IgfsOutputStream out = fs.create(new IgfsPath("/file"), false);
+ IgfsOutputStream out = fs.create(new IgfsPath("/primary/file"), false);
out.close();
out.close();
- IgfsInputStream in = fs.open(new IgfsPath("/file"));
+ IgfsInputStream in = fs.open(new IgfsPath("/primary/file"));
in.close();
in.close();
@@ -388,8 +388,8 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
IgfsEx igfs = (IgfsEx)igfsPrimary[0];
IgfsPath fileRemote = new IgfsPath("/fileRemote");
- IgfsPath file1 = new IgfsPath("/file1");
- IgfsPath file2 = new IgfsPath("/file2");
+ IgfsPath file1 = new IgfsPath("/primary/file1");
+ IgfsPath file2 = new IgfsPath("/primary/file2");
// Create remote file and write some data to it.
IgfsOutputStream out = igfsSecondary.create(fileRemote, 256, true, null, 1, 256, null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolverSelfTest.java
index a05ddfc..f3bb516 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolverSelfTest.java
@@ -18,12 +18,13 @@
package org.apache.ignite.internal.processors.igfs;
import java.util.Arrays;
-import java.util.HashSet;
+import java.util.List;
import junit.framework.TestCase;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.util.typedef.T2;
-
+import static org.apache.ignite.igfs.IgfsMode.DUAL_ASYNC;
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;
@@ -33,48 +34,109 @@ import static org.apache.ignite.igfs.IgfsMode.PROXY;
*/
public class IgfsModeResolverSelfTest extends TestCase {
/** */
- private IgfsModeResolver resolver;
+ private IgfsModeResolver reslvr;
/** {@inheritDoc} */
@Override protected void setUp() throws Exception {
- resolver = new IgfsModeResolver(DUAL_SYNC, Arrays.asList(
- new T2<>(new IgfsPath("/a/b/"), PRIMARY),
- new T2<>(new IgfsPath("/a/b/c/d"), PROXY)));
+ reslvr = new IgfsModeResolver(DUAL_SYNC, Arrays.asList(new T2<>(new IgfsPath("/a/b/c/d"), PROXY), new T2<>
+ (new IgfsPath("/a/P/"), PRIMARY), new T2<>(new IgfsPath("/a/b/"), DUAL_ASYNC)));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCanContain() throws Exception {
+ for (IgfsMode m: IgfsMode.values()) {
+ // Each mode can contain itself:
+ assertTrue(IgfsUtils.canContain(m, m));
+
+ // PRIMARY and PROXY can contain itself only:
+ assertTrue(IgfsUtils.canContain(PRIMARY,m) == (m == PRIMARY));
+ assertTrue(IgfsUtils.canContain(PROXY,m) == (m == PROXY));
+
+ // Any mode but PRIMARY & PROXY can contain any mode:
+ if (m != PRIMARY && m != PROXY)
+ for (IgfsMode n: IgfsMode.values())
+ assertTrue(IgfsUtils.canContain(m,n));
+ }
}
/**
* @throws Exception If failed.
*/
public void testResolve() throws Exception {
- assertEquals(DUAL_SYNC, resolver.resolveMode(new IgfsPath("/")));
- assertEquals(DUAL_SYNC, resolver.resolveMode(new IgfsPath("/a")));
- assertEquals(DUAL_SYNC, resolver.resolveMode(new IgfsPath("/a/1")));
- assertEquals(PRIMARY, resolver.resolveMode(new IgfsPath("/a/b")));
- assertEquals(PRIMARY, resolver.resolveMode(new IgfsPath("/a/b/c")));
- assertEquals(PRIMARY, resolver.resolveMode(new IgfsPath("/a/b/c/2")));
- assertEquals(PROXY, resolver.resolveMode(new IgfsPath("/a/b/c/d")));
- assertEquals(PROXY, resolver.resolveMode(new IgfsPath("/a/b/c/d/e")));
+ assertEquals(DUAL_SYNC, reslvr.resolveMode(new IgfsPath("/")));
+ assertEquals(DUAL_SYNC, reslvr.resolveMode(new IgfsPath("/a")));
+ assertEquals(DUAL_SYNC, reslvr.resolveMode(new IgfsPath("/a/1")));
+
+ assertEquals(PRIMARY, reslvr.resolveMode(new IgfsPath("/a/P")));
+ assertEquals(PRIMARY, reslvr.resolveMode(new IgfsPath("/a/P/c")));
+ assertEquals(PRIMARY, reslvr.resolveMode(new IgfsPath("/a/P/c/2")));
+
+ assertEquals(DUAL_ASYNC, reslvr.resolveMode(new IgfsPath("/a/b/")));
+ assertEquals(DUAL_ASYNC, reslvr.resolveMode(new IgfsPath("/a/b/3")));
+ assertEquals(DUAL_ASYNC, reslvr.resolveMode(new IgfsPath("/a/b/3/4")));
+
+ assertEquals(PROXY, reslvr.resolveMode(new IgfsPath("/a/b/c/d")));
+ assertEquals(PROXY, reslvr.resolveMode(new IgfsPath("/a/b/c/d/5")));
+ assertEquals(PROXY, reslvr.resolveMode(new IgfsPath("/a/b/c/d/6")));
}
/**
* @throws Exception If failed.
*/
- public void testResolveChildren() throws Exception {
- assertEquals(new HashSet<IgfsMode>(){{add(DUAL_SYNC); add(PRIMARY); add(PROXY);}},
- resolver.resolveChildrenModes(new IgfsPath("/")));
- assertEquals(new HashSet<IgfsMode>(){{add(DUAL_SYNC); add(PRIMARY); add(PROXY);}},
- resolver.resolveChildrenModes(new IgfsPath("/a")));
- assertEquals(new HashSet<IgfsMode>(){{add(DUAL_SYNC);}},
- resolver.resolveChildrenModes(new IgfsPath("/a/1")));
- assertEquals(new HashSet<IgfsMode>(){{add(PRIMARY); add(PROXY);}},
- resolver.resolveChildrenModes(new IgfsPath("/a/b")));
- assertEquals(new HashSet<IgfsMode>(){{add(PRIMARY); add(PROXY);}},
- resolver.resolveChildrenModes(new IgfsPath("/a/b/c")));
- assertEquals(new HashSet<IgfsMode>(){{add(PRIMARY);}},
- resolver.resolveChildrenModes(new IgfsPath("/a/b/c/2")));
- assertEquals(new HashSet<IgfsMode>(){{add(PROXY);}},
- resolver.resolveChildrenModes(new IgfsPath("/a/b/c/d")));
- assertEquals(new HashSet<IgfsMode>(){{add(PROXY);}},
- resolver.resolveChildrenModes(new IgfsPath("/a/b/c/d/e")));
+ public void testModesValidation() throws Exception {
+ // Another mode inside PRIMARY directory:
+ try {
+ IgfsUtils.preparePathModes(DUAL_SYNC, Arrays.asList(
+ new T2<>(new IgfsPath("/a/"), PRIMARY),
+ new T2<>(new IgfsPath("/a/b/"), DUAL_ASYNC)));
+
+ fail("IgniteCheckedException expected");
+ }
+ catch (IgniteCheckedException ice) {
+ // Expected.
+ }
+
+ // PRIMARY default mode and non-primary subfolder:
+ for (IgfsMode m: IgfsMode.values()) {
+ if (m != IgfsMode.PRIMARY) {
+ try {
+ IgfsUtils.preparePathModes(PRIMARY, Arrays.asList(new T2<>(new IgfsPath("/a/"), DUAL_ASYNC)));
+
+ fail("IgniteCheckedException expected");
+ }
+ catch (IgniteCheckedException ice) {
+ // Expected.
+ }
+ }
+ }
+
+ // Duplicated sub-folders should be ignored:
+ List<T2<IgfsPath, IgfsMode>> modes = IgfsUtils.preparePathModes(DUAL_SYNC, Arrays.asList(
+ new T2<>(new IgfsPath("/a"), PRIMARY),
+ new T2<>(new IgfsPath("/c/d/"), PRIMARY),
+ new T2<>(new IgfsPath("/c/d/e/f"), PRIMARY)
+ ));
+ assertNotNull(modes);
+ assertEquals(2, modes.size());
+ assertEquals(modes, Arrays.asList(
+ new T2<>(new IgfsPath("/c/d/"), PRIMARY),
+ new T2<>(new IgfsPath("/a"), PRIMARY)
+ ));
+
+ // Non-duplicated sub-folders should not be ignored:
+ modes = IgfsUtils.preparePathModes(DUAL_SYNC, Arrays.asList(
+ new T2<>(new IgfsPath("/a/b"), DUAL_ASYNC),
+ new T2<>(new IgfsPath("/a/b/c"), DUAL_SYNC),
+ new T2<>(new IgfsPath("/a/b/c/d"), DUAL_ASYNC)
+ ));
+ assertNotNull(modes);
+ assertEquals(modes.size(), 3);
+ assertEquals(modes, Arrays.asList(
+ new T2<>(new IgfsPath("/a/b/c/d"), DUAL_ASYNC),
+ new T2<>(new IgfsPath("/a/b/c"), DUAL_SYNC),
+ new T2<>(new IgfsPath("/a/b"), DUAL_ASYNC)
+ ));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java
index 1e54f8c..a6b7502 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java
@@ -250,7 +250,7 @@ public class IgfsModesSelfTest extends IgfsCommonAbstractTest {
public void testDefaultFoldersNonPrimary() throws Exception {
setSecondaryFs = true;
- mode = PRIMARY;
+ mode = DUAL_ASYNC;
startUp();
@@ -258,43 +258,45 @@ public class IgfsModesSelfTest extends IgfsCommonAbstractTest {
checkMode("/ignite/proxy/", PROXY);
checkMode("/ignite/proxy/subfolder", PROXY);
checkMode("/ignite/proxy/folder/file.txt", PROXY);
- checkMode("/ignite/proxyx", PRIMARY);
- checkMode("/ignite/proxyx/", PRIMARY);
- checkMode("/ignite/proxyx/subfolder", PRIMARY);
- checkMode("/ignite/proxyx/folder/file.txt", PRIMARY);
+ checkMode("/ignite/proxyx", mode);
+ checkMode("/ignite/proxyx/", mode);
+ checkMode("/ignite/proxyx/subfolder", mode);
+ checkMode("/ignite/proxyx/folder/file.txt", mode);
- checkMode("/userdir/ignite/proxy", PRIMARY);
- checkMode("/userdir/ignite/proxy/", PRIMARY);
- checkMode("/userdir/ignite/proxy/subfolder", PRIMARY);
- checkMode("/userdir/ignite/proxy/folder/file.txt", PRIMARY);
+ checkMode("/userdir/ignite/proxy", mode);
+ checkMode("/userdir/ignite/proxy/", mode);
+ checkMode("/userdir/ignite/proxy/subfolder", mode);
+ checkMode("/userdir/ignite/proxy/folder/file.txt", mode);
checkMode("/ignite/sync", DUAL_SYNC);
checkMode("/ignite/sync/", DUAL_SYNC);
checkMode("/ignite/sync/subfolder", DUAL_SYNC);
checkMode("/ignite/sync/folder/file.txt", DUAL_SYNC);
- checkMode("/ignite/syncx", PRIMARY);
- checkMode("/ignite/syncx/", PRIMARY);
- checkMode("/ignite/syncx/subfolder", PRIMARY);
- checkMode("/ignite/syncx/folder/file.txt", PRIMARY);
- checkMode("/userdir/ignite/sync", PRIMARY);
- checkMode("/userdir/ignite/sync/", PRIMARY);
- checkMode("/userdir/ignite/sync/subfolder", PRIMARY);
- checkMode("/userdir/ignite/sync/folder/file.txt", PRIMARY);
+ checkMode("/ignite/syncx", mode);
+ checkMode("/ignite/syncx/", mode);
+ checkMode("/ignite/syncx/subfolder", mode);
+ checkMode("/ignite/syncx/folder/file.txt", mode);
+
+ checkMode("/userdir/ignite/sync", mode);
+ checkMode("/userdir/ignite/sync/", mode);
+ checkMode("/userdir/ignite/sync/subfolder", mode);
+ checkMode("/userdir/ignite/sync/folder/file.txt", mode);
checkMode("/ignite/async", DUAL_ASYNC);
checkMode("/ignite/async/", DUAL_ASYNC);
checkMode("/ignite/async/subfolder", DUAL_ASYNC);
checkMode("/ignite/async/folder/file.txt", DUAL_ASYNC);
- checkMode("/ignite/asyncx", PRIMARY);
- checkMode("/ignite/asyncx/", PRIMARY);
- checkMode("/ignite/asyncx/subfolder", PRIMARY);
- checkMode("/ignite/asyncx/folder/file.txt", PRIMARY);
-
- checkMode("/userdir/ignite/async", PRIMARY);
- checkMode("/userdir/ignite/async/", PRIMARY);
- checkMode("/userdir/ignite/async/subfolder", PRIMARY);
- checkMode("/userdir/ignite/async/folder/file.txt", PRIMARY);
+
+ checkMode("/ignite/asyncx", mode);
+ checkMode("/ignite/asyncx/", mode);
+ checkMode("/ignite/asyncx/subfolder", mode);
+ checkMode("/ignite/asyncx/folder/file.txt", mode);
+
+ checkMode("/userdir/ignite/async", mode);
+ checkMode("/userdir/ignite/async/", mode);
+ checkMode("/userdir/ignite/async/subfolder", mode);
+ checkMode("/userdir/ignite/async/folder/file.txt", mode);
}
/**
@@ -333,8 +335,11 @@ public class IgfsModesSelfTest extends IgfsCommonAbstractTest {
mode = DUAL_ASYNC;
- pathModes(F.t("/ignite/primary", PROXY), F.t("/ignite/proxy", DUAL_SYNC),
- F.t("/ignite/sync", DUAL_ASYNC), F.t("/ignite/async", PRIMARY));
+ pathModes(
+ F.t("/ignite/primary", PROXY),
+ F.t("/ignite/proxy", DUAL_SYNC),
+ F.t("/ignite/sync", DUAL_ASYNC),
+ F.t("/ignite/async", PRIMARY));
startUp();
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
index 66255c9..cc02d05 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
@@ -80,7 +80,6 @@ import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.ignite.configuration.FileSystemConfiguration.DFLT_IGFS_LOG_BATCH_SIZE;
@@ -653,21 +652,16 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
try {
IgfsPath srcPath = convert(src);
IgfsPath dstPath = convert(dst);
- Set<IgfsMode> childrenModes = modeRslvr.resolveChildrenModes(srcPath);
- if (childrenModes.contains(PROXY)) {
- if (clientLog.isLogEnabled())
- clientLog.logRename(srcPath, PROXY, dstPath);
+ IgfsMode srcMode = modeRslvr.resolveMode(srcPath);
- secondaryFileSystem().rename(toSecondary(src), toSecondary(dst));
- }
- else {
- if (clientLog.isLogEnabled())
- clientLog.logRename(srcPath, modeRslvr.resolveMode(srcPath), dstPath);
+ if (clientLog.isLogEnabled())
+ clientLog.logRename(srcPath, srcMode, dstPath);
+ if (srcMode == PROXY)
+ secondaryFileSystem().rename(toSecondary(src), toSecondary(dst));
+ else
rmtClient.rename(srcPath, dstPath);
- }
-
}
finally {
leaveBusy();
@@ -682,10 +676,10 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
try {
IgfsPath path = convert(f);
+
IgfsMode mode = modeRslvr.resolveMode(path);
- Set<IgfsMode> childrenModes = modeRslvr.resolveChildrenModes(path);
- if (childrenModes.contains(PROXY)) {
+ if (mode == PROXY) {
if (clientLog.isLogEnabled())
clientLog.logDelete(path, PROXY, recursive);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java
index e4c64ff..7cf1e4b 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java
@@ -198,7 +198,7 @@ public class HadoopFIleSystemFactorySelfTest extends IgfsCommonAbstractTest {
fs.setFileSystemFactory(factory);
// Start.
- return start("primary", 10500, IgfsMode.PRIMARY, fs);
+ return start("primary", 10500, IgfsMode.DUAL_ASYNC, fs);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemSecondaryModeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemSecondaryModeSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemSecondaryModeSelfTest.java
deleted file mode 100644
index 7255e8b..0000000
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemSecondaryModeSelfTest.java
+++ /dev/null
@@ -1,327 +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.igfs;
-
-import java.net.URI;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.FileSystemConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.hadoop.fs.IgniteHadoopIgfsSecondaryFileSystem;
-import org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem;
-import org.apache.ignite.internal.processors.igfs.IgfsCommonAbstractTest;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static org.apache.ignite.cache.CacheMode.REPLICATED;
-import static org.apache.ignite.igfs.IgfsMode.PRIMARY;
-import static org.apache.ignite.igfs.IgfsMode.PROXY;
-
-/**
- * Ensures correct modes resolution for SECONDARY paths.
- */
-public class IgniteHadoopFileSystemSecondaryModeSelfTest extends IgfsCommonAbstractTest {
- /** Path to check. */
- private static final Path PATH = new Path("/dir");
-
- /** Pattern matching the path. */
- private static final String PATTERN_MATCHES = "/dir";
-
- /** Pattern doesn't matching the path. */
- private static final String PATTERN_NOT_MATCHES = "/files";
-
- /** Default IGFS mode. */
- private IgfsMode mode;
-
- /** Path modes. */
- private Map<String, IgfsMode> pathModes;
-
- /** File system. */
- private IgniteHadoopFileSystem fs;
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- mode = null;
- pathModes = null;
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- U.closeQuiet(fs);
-
- fs = null;
-
- G.stopAll(true);
- }
-
- /**
- * Perform initial startup.
- *
- * @throws Exception If failed.
- */
- @SuppressWarnings("NullableProblems")
- private void startUp() throws Exception {
- startUpSecondary();
-
- FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
-
- igfsCfg.setDataCacheName("partitioned");
- igfsCfg.setMetaCacheName("replicated");
- igfsCfg.setName("igfs");
- igfsCfg.setBlockSize(512 * 1024);
- igfsCfg.setDefaultMode(mode);
- igfsCfg.setPathModes(pathModes);
-
- IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration();
-
- endpointCfg.setType(IgfsIpcEndpointType.TCP);
- endpointCfg.setPort(10500);
-
- igfsCfg.setIpcEndpointConfiguration(endpointCfg);
-
- igfsCfg.setManagementPort(-1);
- igfsCfg.setSecondaryFileSystem(new IgniteHadoopIgfsSecondaryFileSystem(
- "igfs://igfs-secondary:igfs-grid-secondary@127.0.0.1:11500/",
- "modules/core/src/test/config/hadoop/core-site-loopback-secondary.xml"));
-
- CacheConfiguration cacheCfg = defaultCacheConfiguration();
-
- cacheCfg.setName("partitioned");
- cacheCfg.setCacheMode(PARTITIONED);
- cacheCfg.setNearConfiguration(null);
- cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
- cacheCfg.setBackups(0);
- cacheCfg.setAtomicityMode(TRANSACTIONAL);
-
- CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
-
- metaCacheCfg.setName("replicated");
- metaCacheCfg.setCacheMode(REPLICATED);
- metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
-
- IgniteConfiguration cfg = new IgniteConfiguration();
-
- cfg.setGridName("igfs-grid");
-
- TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
- discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
-
- cfg.setDiscoverySpi(discoSpi);
- cfg.setCacheConfiguration(metaCacheCfg, cacheCfg);
- cfg.setFileSystemConfiguration(igfsCfg);
-
- cfg.setLocalHost("127.0.0.1");
-
- G.start(cfg);
-
- Configuration fsCfg = new Configuration();
-
- fsCfg.addResource(U.resolveIgniteUrl("modules/core/src/test/config/hadoop/core-site-loopback.xml"));
-
- fsCfg.setBoolean("fs.igfs.impl.disable.cache", true);
-
- fs = (IgniteHadoopFileSystem)FileSystem.get(new URI("igfs://igfs:igfs-grid@/"), fsCfg);
- }
-
- /**
- * Startup secondary file system.
- *
- * @throws Exception If failed.
- */
- private void startUpSecondary() throws Exception {
- FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
-
- igfsCfg.setDataCacheName("partitioned");
- igfsCfg.setMetaCacheName("replicated");
- igfsCfg.setName("igfs-secondary");
- igfsCfg.setBlockSize(512 * 1024);
- igfsCfg.setDefaultMode(PRIMARY);
-
- IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration();
-
- endpointCfg.setType(IgfsIpcEndpointType.TCP);
- endpointCfg.setPort(11500);
-
- igfsCfg.setIpcEndpointConfiguration(endpointCfg);
-
- CacheConfiguration cacheCfg = defaultCacheConfiguration();
-
- cacheCfg.setName("partitioned");
- cacheCfg.setCacheMode(PARTITIONED);
- cacheCfg.setNearConfiguration(null);
- cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
- cacheCfg.setBackups(0);
- cacheCfg.setAtomicityMode(TRANSACTIONAL);
-
- CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
-
- metaCacheCfg.setName("replicated");
- metaCacheCfg.setCacheMode(REPLICATED);
- metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
-
- IgniteConfiguration cfg = new IgniteConfiguration();
-
- cfg.setGridName("igfs-grid-secondary");
-
- TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
- discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
-
- cfg.setDiscoverySpi(discoSpi);
- cfg.setCacheConfiguration(metaCacheCfg, cacheCfg);
- cfg.setFileSystemConfiguration(igfsCfg);
-
- cfg.setLocalHost("127.0.0.1");
-
- G.start(cfg);
- }
-
- /**
- * Check path resolution when secondary mode is not default and there are no other exclusion paths.
- *
- * @throws Exception If failed.
- */
- public void testSecondaryNotDefaultNoExclusions() throws Exception {
- mode = PRIMARY;
-
- startUp();
-
- assert !secondary(PATH);
- assert !secondary(PATH);
- }
-
- /**
- * Check path resolution when secondary mode is not default and there is no matching exclusion paths.
- *
- * @throws Exception If failed.
- */
- public void testSecondaryNotDefaultNonMatchingExclusion() throws Exception {
- mode = PRIMARY;
-
- pathModes(F.t(PATTERN_NOT_MATCHES, PROXY));
-
- startUp();
-
- assert !secondary(PATH);
- assert !secondary(PATH);
- }
-
- /**
- * Check path resolution when secondary mode is not default and there is matching exclusion path.
- *
- * @throws Exception If failed.
- */
- public void testSecondaryNotDefaultMatchingExclusion() throws Exception {
- mode = PRIMARY;
-
- pathModes(F.t(PATTERN_NOT_MATCHES, PROXY), F.t(PATTERN_MATCHES, PROXY));
-
- startUp();
-
- assert secondary(PATH);
- assert secondary(PATH);
- }
-
- /**
- * Check path resolution when secondary mode is default and there is no exclusion paths.
- *
- * @throws Exception If failed.
- */
- public void testSecondaryDefaultNoExclusions() throws Exception {
- mode = PROXY;
-
- startUp();
-
- assert secondary(PATH);
- assert secondary(PATH);
- }
-
- /**
- * Check path resolution when secondary mode is default and there is no matching exclusion paths.
- *
- * @throws Exception If failed.
- */
- public void testSecondaryDefaultNonMatchingExclusion() throws Exception {
- mode = PROXY;
-
- pathModes(F.t(PATTERN_NOT_MATCHES, PRIMARY));
-
- startUp();
-
- assert secondary(PATH);
- assert secondary(PATH);
- }
-
- /**
- * Check path resolution when secondary mode is default and there is no matching exclusion paths.
- *
- * @throws Exception If failed.
- */
- public void testSecondaryDefaultMatchingExclusion() throws Exception {
- mode = PROXY;
-
- pathModes(F.t(PATTERN_NOT_MATCHES, PRIMARY), F.t(PATTERN_MATCHES, PRIMARY));
-
- startUp();
-
- assert !secondary(PATH);
- assert !secondary(PATH);
- }
-
- /**
- * Set IGFS modes for particular paths.
- *
- * @param modes Modes.
- */
- @SafeVarargs
- final void pathModes(IgniteBiTuple<String, IgfsMode>... modes) {
- assert modes != null;
-
- pathModes = new LinkedHashMap<>(modes.length, 1.0f);
-
- for (IgniteBiTuple<String, IgfsMode> mode : modes)
- pathModes.put(mode.getKey(), mode.getValue());
- }
-
- /**
- * Check whether the given path is threaten as SECONDARY in the file system.
- *
- * @param path Path to check.
- * @return {@code True} in case path is secondary.
- * @throws Exception If failed.
- */
- private boolean secondary(Path path) throws Exception {
- return fs.mode(path) == PROXY;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/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 6900425..3374547 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
@@ -50,7 +50,6 @@ import org.apache.ignite.igfs.IgniteHadoopFileSystemLoopbackExternalDualSyncSelf
import org.apache.ignite.igfs.IgniteHadoopFileSystemLoopbackExternalPrimarySelfTest;
import org.apache.ignite.igfs.IgniteHadoopFileSystemLoopbackExternalSecondarySelfTest;
import org.apache.ignite.igfs.IgniteHadoopFileSystemSecondaryFileSystemInitializationSelfTest;
-import org.apache.ignite.igfs.IgniteHadoopFileSystemSecondaryModeSelfTest;
import org.apache.ignite.internal.processors.hadoop.HadoopClassLoaderTest;
import org.apache.ignite.internal.processors.hadoop.HadoopCommandLineTest;
import org.apache.ignite.internal.processors.hadoop.HadoopDefaultMapReducePlannerSelfTest;
@@ -144,7 +143,6 @@ public class IgniteHadoopTestSuite extends TestSuite {
suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackEmbeddedDualSyncSelfTest.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackEmbeddedDualAsyncSelfTest.class.getName())));
- suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemSecondaryModeSelfTest.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemSecondaryFileSystemInitializationSelfTest.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemClientSelfTest.class.getName())));
[3/4] ignite git commit: Merge remote-tracking branch
'upstream/gridgain-7.6.2' into gridgain-7.6.2
Posted by vo...@apache.org.
Merge remote-tracking branch 'upstream/gridgain-7.6.2' into gridgain-7.6.2
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6c5218f4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6c5218f4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6c5218f4
Branch: refs/heads/ignite-3530
Commit: 6c5218f4d67c8e247f59dbe8deb58b51db2954a2
Parents: 9b55658 11c7e8f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Jul 20 14:15:11 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Jul 20 14:15:11 2016 +0300
----------------------------------------------------------------------
assembly/LICENSE_FABRIC | 7 +-
assembly/LICENSE_HADOOP | 7 +-
examples/pom-standalone-lgpl.xml | 6 +-
examples/pom-standalone.xml | 6 +-
examples/pom.xml | 6 +-
examples/schema-import/pom-standalone.xml | 6 +-
examples/schema-import/pom.xml | 6 +-
.../examples/IndexingBridgeMethodTest.java | 93 ++++++++++++++++++++
.../IgniteExamplesJ8SelfTestSuite.java | 2 +
modules/cassandra/pom.xml | 2 +-
modules/core/pom.xml | 6 +-
.../ignite/cache/query/ContinuousQuery.java | 47 +++++++---
.../configuration/CacheConfiguration.java | 3 +
.../processors/cache/IgniteCacheProxy.java | 3 +-
.../continuous/CacheContinuousQueryManager.java | 9 +-
...ridCacheContinuousQueryAbstractSelfTest.java | 47 ++++++++++
modules/flume/README.txt | 2 +-
modules/kafka/README.txt | 4 +-
.../stream/kafka/connect/package-info.java | 21 +++++
.../connect/serialization/package-info.java | 21 +++++
.../Apache.Ignite.Core.Tests/DeploymentTest.cs | 2 +-
parent/pom.xml | 1 +
22 files changed, 267 insertions(+), 40 deletions(-)
----------------------------------------------------------------------