You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2016/08/22 03:26:33 UTC
[01/28] ignite git commit: IGNITE-3618: Client can not load data
after server restarts. This closes #941.
Repository: ignite
Updated Branches:
refs/heads/master f0c3b343e -> 2d4360707
IGNITE-3618: Client can not load data after server restarts. This closes #941.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1d0cbb45
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1d0cbb45
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1d0cbb45
Branch: refs/heads/master
Commit: 1d0cbb45cd61c5c8e6ec926d7e629eb94111b32f
Parents: ff3e00c
Author: vd-pyatkov <vp...@gridgain.com>
Authored: Thu Aug 11 08:43:50 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Aug 11 08:43:50 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/binary/BinaryContext.java | 7 +
.../binary/CacheObjectBinaryProcessorImpl.java | 19 ++
.../ClientReconnectAfterClusterRestartTest.java | 225 +++++++++++++++++++
.../IgniteCacheWithIndexingTestSuite.java | 5 +-
4 files changed, 255 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1d0cbb45/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index d78c126..a603894 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -1252,6 +1252,13 @@ public class BinaryContext {
}
/**
+ * Unregister all binary schemas.
+ */
+ public void unregisterBinarySchemas() {
+ schemas = null;
+ }
+
+ /**
* Returns instance of {@link OptimizedMarshaller}.
*
* @return Optimized marshaller.
http://git-wip-us.apache.org/repos/asf/ignite/blob/1d0cbb45/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index 6d980a8..0337874 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -50,6 +50,7 @@ import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.cluster.ClusterTopologyException;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.events.Event;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteNodeAttributes;
import org.apache.ignite.internal.binary.BinaryContext;
@@ -67,6 +68,7 @@ import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
import org.apache.ignite.internal.binary.streams.BinaryOffheapInputStream;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicateAdapter;
@@ -103,6 +105,7 @@ import org.jsr166.ConcurrentHashMap8;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
import static org.apache.ignite.IgniteSystemProperties.getBoolean;
+import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED;
/**
* Binary processor implementation.
@@ -146,6 +149,13 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
@GridToStringExclude
private IgniteBinary binaries;
+ /** Listener removes all registred binary schemas after the local client reconnected. */
+ private final GridLocalEventListener clientDisconLsnr = new GridLocalEventListener() {
+ @Override public void onEvent(Event evt) {
+ binaryContext().unregisterBinarySchemas();
+ }
+ };
+
/** Metadata updates collected before metadata cache is initialized. */
private final Map<Integer, BinaryMetadata> metaBuf = new ConcurrentHashMap<>();
@@ -165,6 +175,9 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public void start() throws IgniteCheckedException {
if (marsh instanceof BinaryMarshaller) {
+ if (ctx.clientNode())
+ ctx.event().addLocalEventListener(clientDisconLsnr, EVT_CLIENT_NODE_DISCONNECTED);
+
BinaryMetadataHandler metaHnd = new BinaryMetadataHandler() {
@Override public void addMeta(int typeId, BinaryType newMeta) throws BinaryObjectException {
assert newMeta != null;
@@ -252,6 +265,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
}
/** {@inheritDoc} */
+ @Override public void stop(boolean cancel) {
+ if (ctx.clientNode())
+ ctx.event().removeLocalEventListener(clientDisconLsnr);
+ }
+
+ /** {@inheritDoc} */
@Override public void onContinuousProcessorStarted(GridKernalContext ctx) throws IgniteCheckedException {
if (clientNode && !ctx.isDaemon()) {
ctx.continuous().registerStaticRoutine(
http://git-wip-us.apache.org/repos/asf/ignite/blob/1d0cbb45/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ClientReconnectAfterClusterRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ClientReconnectAfterClusterRestartTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ClientReconnectAfterClusterRestartTest.java
new file mode 100644
index 0000000..b31447c
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ClientReconnectAfterClusterRestartTest.java
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.events.EventType;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+/**
+ */
+public class ClientReconnectAfterClusterRestartTest extends GridCommonAbstractTest {
+ /** Client id. */
+ public static final int CLIENT_ID = 1;
+
+ /** Cache params. */
+ public static final String CACHE_PARAMS = "PPRB_PARAMS";
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setMarshaller(new BinaryMarshaller());
+ cfg.setIncludeEventTypes(EventType.EVTS_CACHE);
+
+ if (getTestGridName(CLIENT_ID).equals(gridName))
+ cfg.setClientMode(true);
+ else {
+ CacheConfiguration ccfg = getCacheConfiguration();
+
+ cfg.setCacheConfiguration(ccfg);
+ }
+
+ return cfg;
+ }
+
+ /**
+ * @return CacheConfiguration Cache configuration.
+ */
+ @NotNull private CacheConfiguration getCacheConfiguration() {
+ CacheConfiguration ccfg = defaultCacheConfiguration();
+
+ ccfg.setName(CACHE_PARAMS);
+ ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ ccfg.setCacheMode(CacheMode.PARTITIONED);
+ ccfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED);
+
+ List<QueryEntity> queryEntities = new ArrayList<>();
+
+ QueryEntity entity = new QueryEntity();
+
+ entity.setValueType("Params");
+ entity.setKeyType("java.lang.Long");
+
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+ fields.put("ID", "java.lang.Long" );
+ fields.put("PARTITIONID", "java.lang.Long");
+ fields.put("CLIENTID", "java.lang.Long");
+ fields.put("PARAMETRCODE", "java.lang.Long");
+ fields.put("PARAMETRVALUE", "java.lang.Object");
+ fields.put("PARENTID", "java.lang.Long");
+
+ entity.setFields(fields);
+
+ List<QueryIndex> indexes = new ArrayList<>();
+
+ indexes.add(new QueryIndex("CLIENTID"));
+ indexes.add(new QueryIndex("ID"));
+ indexes.add(new QueryIndex("PARENTID"));
+
+ entity.setIndexes(indexes);
+
+ queryEntities.add(entity);
+
+ ccfg.setQueryEntities(queryEntities);
+ return ccfg;
+ }
+
+ /** */
+ public void testReconnectClient() throws Exception {
+ try {
+ Ignite igniteSrv = startGrid(0);
+
+ Ignite client = startGrid(1);
+
+ checkTopology(2);
+
+ client.events().localListen(new IgnitePredicate<Event>() {
+
+ @Override public boolean apply(Event event) {
+ switch (event.type()) {
+ case EventType.EVT_CLIENT_NODE_DISCONNECTED:
+ info("Client disconnected");
+
+ break;
+ case EventType.EVT_CLIENT_NODE_RECONNECTED:
+ info("Client reconnected");
+ }
+
+ return true;
+ }
+ }, EventType.EVT_CLIENT_NODE_DISCONNECTED, EventType.EVT_CLIENT_NODE_RECONNECTED);
+
+ IgniteDataStreamer<Long, BinaryObject> streamer = client.dataStreamer(CACHE_PARAMS);
+
+ streamer.allowOverwrite(true);
+ streamer.keepBinary(true);
+ streamer.perNodeBufferSize(10000);
+ streamer.perNodeParallelOperations(100);
+
+ BinaryObjectBuilder builder = client.binary().builder("PARAMS");
+
+ builder.setField("ID", 1L);
+ builder.setField("PARTITIONID", 1L);
+ builder.setField("CLIENTID", 1L);
+ builder.setField("PARAMETRCODE", 1L);
+ builder.setField("PARAMETRVALUE", "Test value");
+ builder.setField("PARENTID", 1L);
+ BinaryObject obj = builder.build();
+
+ streamer.addData(1L, obj);
+ streamer.flush();
+
+ stopAllServers(false);
+
+ Thread.sleep(2_000);
+
+ igniteSrv = startGrid(0);
+
+ Thread.sleep(2_000);
+
+ checkTopology(2);
+
+ info("Pre-insert");
+
+ streamer = client.dataStreamer("PPRB_PARAMS");
+ streamer.allowOverwrite(true);
+ streamer.keepBinary(true);
+ streamer.perNodeBufferSize(10000);
+ streamer.perNodeParallelOperations(100);
+
+ IgniteCache<Long, BinaryObject> cache = client.getOrCreateCache(CACHE_PARAMS).withKeepBinary();
+
+ builder = client.binary().builder("PARAMS");
+ builder.setField("ID", 2L);
+ builder.setField("PARTITIONID", 1L);
+ builder.setField("CLIENTID", 1L);
+ builder.setField("PARAMETRCODE", 1L);
+ builder.setField("PARAMETRVALUE", "Test value");
+ builder.setField("PARENTID", 1L);
+ obj = builder.build();
+
+ //streamer.addData(2L, obj);
+ cache.put(2L, obj);
+
+ builder = client.binary().builder("PARAMS");
+ builder.setField("ID", 3L);
+ builder.setField("PARTITIONID", 1L);
+ builder.setField("CLIENTID", 1L);
+ builder.setField("PARAMETRCODE", 1L);
+ builder.setField("PARAMETRVALUE", "Test value");
+ builder.setField("PARENTID", 1L);
+ obj = builder.build();
+
+ //streamer.addData(3L, obj);
+ cache.put(3L, obj);
+
+ builder = client.binary().builder("PARAMS");
+ builder.setField("ID", 4L);
+ builder.setField("PARTITIONID", 1L);
+ builder.setField("CLIENTID", 1L);
+ builder.setField("PARAMETRCODE", 1L);
+ builder.setField("PARAMETRVALUE", "Test value");
+ builder.setField("PARENTID", 1L);
+ obj = builder.build();
+
+ cache.put(4L, obj);
+
+ info("Post-insert");
+
+ obj = cache.get(4L);
+
+ assertNotNull(obj);
+
+ info("End");
+ }
+ finally {
+ stopAllGrids();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1d0cbb45/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
index 96e8551..4528b30 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
@@ -23,6 +23,7 @@ import org.apache.ignite.internal.processors.cache.CacheConfigurationP2PTest;
import org.apache.ignite.internal.processors.cache.CacheIndexStreamerTest;
import org.apache.ignite.internal.processors.cache.CacheOperationsWithExpirationTest;
import org.apache.ignite.internal.processors.cache.CacheRandomOperationsMultithreadedTest;
+import org.apache.ignite.internal.processors.cache.ClientReconnectAfterClusterRestartTest;
import org.apache.ignite.internal.processors.cache.GridCacheOffHeapAndSwapSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheOffHeapSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheOffheapIndexEntryEvictTest;
@@ -79,6 +80,8 @@ public class IgniteCacheWithIndexingTestSuite extends TestSuite {
suite.addTestSuite(CacheOperationsWithExpirationTest.class);
suite.addTestSuite(CacheBinaryKeyConcurrentQueryTest.class);
+ suite.addTestSuite(ClientReconnectAfterClusterRestartTest.class);
+
return suite;
}
-}
\ No newline at end of file
+}
[03/28] ignite git commit: IGNITE-2852: Fixed TreeMap and TreeSet
serialization.
Posted by ak...@apache.org.
IGNITE-2852: Fixed TreeMap and TreeSet serialization.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0b4ffdbc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0b4ffdbc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0b4ffdbc
Branch: refs/heads/master
Commit: 0b4ffdbcce63e5ce53572f71af967cff300d5670
Parents: 1139a9f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Sun Aug 14 18:18:40 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Sun Aug 14 18:18:40 2016 +0300
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 10 +
.../internal/binary/BinaryClassDescriptor.java | 43 ++-
.../ignite/internal/binary/BinaryContext.java | 14 +-
.../binary/BinaryMethodWriteReplacer.java | 59 ++++
.../ignite/internal/binary/BinaryTreeMap.java | 96 ++++++
.../binary/BinaryTreeMapWriteReplacer.java | 34 ++
.../ignite/internal/binary/BinaryTreeSet.java | 93 +++++
.../binary/BinaryTreeSetWriteReplacer.java | 34 ++
.../ignite/internal/binary/BinaryUtils.java | 37 +-
.../internal/binary/BinaryWriteReplacer.java | 33 ++
.../internal/binary/BinaryWriterExImpl.java | 35 +-
.../internal/binary/BinaryTreeSelfTest.java | 341 +++++++++++++++++++
.../IgniteBinaryObjectsTestSuite.java | 2 +
13 files changed, 790 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 0c22c9d..7c428a6 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -452,6 +452,16 @@ public final class IgniteSystemProperties {
public static final String IGNITE_SERVICES_COMPATIBILITY_MODE = "IGNITE_SERVICES_COMPATIBILITY_MODE";
/**
+ * When set to {@code true} tree-based data structures - {@code TreeMap} and {@code TreeSet} - will not be
+ * wrapped into special holders introduced to overcome serialization issue caused by missing {@code Comparable}
+ * interface on {@code BinaryObject}.
+ * <p>
+ * @deprecated Should be removed in Apache Ignite 2.0.
+ */
+ @Deprecated
+ public static final String IGNITE_BINARY_DONT_WRAP_TREE_STRUCTURES = "IGNITE_BINARY_DONT_WRAP_TREE_STRUCTURES";
+
+ /**
* Enforces singleton.
*/
private IgniteSystemProperties() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
index d2d715b..083057d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
@@ -89,8 +89,8 @@ public class BinaryClassDescriptor {
/** */
private final BinaryFieldAccessor[] fields;
- /** */
- private final Method writeReplaceMtd;
+ /** Write replacer. */
+ private final BinaryWriteReplacer writeReplacer;
/** */
private final Method readResolveMtd;
@@ -147,7 +147,7 @@ public class BinaryClassDescriptor {
initialSerializer = serializer;
- // If serializer is not defined at this point, then we have to user OptimizedMarshaller.
+ // If serializer is not defined at this point, then we have to use OptimizedMarshaller.
useOptMarshaller = serializer == null;
// Reset reflective serializer so that we rely on existing reflection-based serialization.
@@ -298,11 +298,8 @@ public class BinaryClassDescriptor {
schemaBuilder.addField(fieldId);
- if (metaDataEnabled) {
- assert stableFieldsMeta != null;
-
+ if (metaDataEnabled)
stableFieldsMeta.put(name, fieldInfo.mode().typeId());
- }
}
}
}
@@ -320,14 +317,24 @@ public class BinaryClassDescriptor {
throw new BinaryObjectException("Invalid mode: " + mode);
}
+ BinaryWriteReplacer writeReplacer0 = BinaryUtils.writeReplacer(cls);
+
+ Method writeReplaceMthd;
+
if (mode == BinaryWriteMode.BINARY || mode == BinaryWriteMode.OBJECT) {
readResolveMtd = U.findNonPublicMethod(cls, "readResolve");
- writeReplaceMtd = U.findNonPublicMethod(cls, "writeReplace");
+
+ writeReplaceMthd = U.findNonPublicMethod(cls, "writeReplace");
}
else {
readResolveMtd = null;
- writeReplaceMtd = null;
+ writeReplaceMthd = null;
}
+
+ if (writeReplaceMthd != null && writeReplacer0 == null)
+ writeReplacer0 = new BinaryMethodWriteReplacer(writeReplaceMthd);
+
+ writeReplacer = writeReplacer0;
}
/**
@@ -469,10 +476,22 @@ public class BinaryClassDescriptor {
}
/**
- * @return binaryWriteReplace() method
+ * @return {@code True} if write-replace should be performed for class.
*/
- @Nullable Method getWriteReplaceMethod() {
- return writeReplaceMtd;
+ public boolean isWriteReplace() {
+ return writeReplacer != null;
+ }
+
+ /**
+ * Perform write replace.
+ *
+ * @param obj Original object.
+ * @return Replaced object.
+ */
+ public Object writeReplace(Object obj) {
+ assert isWriteReplace();
+
+ return writeReplacer.replace(obj);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index a603894..8517acf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -105,6 +105,8 @@ import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
import java.util.jar.JarEntry;
@@ -182,6 +184,11 @@ public class BinaryContext {
sysClss.add(GridClosureProcessor.C4V2.class.getName());
sysClss.add(GridClosureProcessor.C4MLAV2.class.getName());
+ if (BinaryUtils.wrapTrees()) {
+ sysClss.add(TreeMap.class.getName());
+ sysClss.add(TreeSet.class.getName());
+ }
+
BINARYLIZABLE_SYS_CLSS = Collections.unmodifiableSet(sysClss);
}
@@ -332,11 +339,16 @@ public class BinaryContext {
* @param cls Class.
* @return {@code True} if must be deserialized.
*/
+ @SuppressWarnings("SimplifiableIfStatement")
public boolean mustDeserialize(Class cls) {
BinaryClassDescriptor desc = descByCls.get(cls);
- if (desc == null)
+ if (desc == null) {
+ if (BinaryUtils.wrapTrees() && (cls == TreeMap.class || cls == TreeSet.class))
+ return false;
+
return marshCtx.isSystemType(cls.getName()) || serializerForClass(cls) == null;
+ }
else
return desc.useOptimizedMarshaller();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMethodWriteReplacer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMethodWriteReplacer.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMethodWriteReplacer.java
new file mode 100644
index 0000000..783048e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMethodWriteReplacer.java
@@ -0,0 +1,59 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.jetbrains.annotations.Nullable;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Write replacer based on method invocation.
+ */
+public class BinaryMethodWriteReplacer implements BinaryWriteReplacer {
+ /** Method. */
+ private final Method mthd;
+
+ /**
+ * Constructor.
+ *
+ * @param mthd Method.
+ */
+ public BinaryMethodWriteReplacer(Method mthd) {
+ assert mthd != null;
+
+ this.mthd = mthd;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object replace(Object target) {
+ try {
+ return mthd.invoke(target);
+ }
+ catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ catch (InvocationTargetException e) {
+ if (e.getTargetException() instanceof BinaryObjectException)
+ throw (BinaryObjectException)e.getTargetException();
+
+ throw new BinaryObjectException("Failed to execute writeReplace() method on " + target, e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeMap.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeMap.java
new file mode 100644
index 0000000..6a7cf9b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeMap.java
@@ -0,0 +1,96 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+
+import java.io.ObjectStreamException;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * Binary {@link TreeMap} wrapper.
+ */
+public class BinaryTreeMap implements Binarylizable {
+ /** Original map. */
+ private TreeMap map;
+
+ /**
+ * Default constructor.
+ */
+ public BinaryTreeMap() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param map Original map.
+ */
+ public BinaryTreeMap(TreeMap map) {
+ this.map = map;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter rawWriter = writer.rawWriter();
+
+ rawWriter.writeObject(map.comparator());
+
+ int size = map.size();
+
+ rawWriter.writeInt(size);
+
+ for (Map.Entry<Object, Object> entry : ((TreeMap<Object, Object>)map).entrySet()) {
+ rawWriter.writeObject(entry.getKey());
+ rawWriter.writeObject(entry.getValue());
+ }
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader rawReader = reader.rawReader();
+
+ Comparator comp = rawReader.readObject();
+
+ map = comp == null ? new TreeMap() : new TreeMap(comp);
+
+ int size = rawReader.readInt();
+
+ for (int i = 0; i < size; i++)
+ map.put(rawReader.readObject(), rawReader.readObject());
+ }
+
+ /**
+ * Reconstructs object on unmarshalling.
+ *
+ * @return Reconstructed object.
+ * @throws ObjectStreamException Thrown in case of unmarshalling error.
+ */
+ protected Object readResolve() throws ObjectStreamException {
+ return map;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeMapWriteReplacer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeMapWriteReplacer.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeMapWriteReplacer.java
new file mode 100644
index 0000000..049db8e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeMapWriteReplacer.java
@@ -0,0 +1,34 @@
+/*
+ * 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.binary;
+
+import org.jetbrains.annotations.Nullable;
+
+import java.util.TreeMap;
+
+/**
+ * Binary {@link TreeMap} write replacer.
+ */
+public class BinaryTreeMapWriteReplacer implements BinaryWriteReplacer {
+ /** {@inheritDoc} */
+ @Nullable @Override public Object replace(Object target) {
+ assert target instanceof TreeMap;
+
+ return new BinaryTreeMap((TreeMap)target);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeSet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeSet.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeSet.java
new file mode 100644
index 0000000..2b01528
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeSet.java
@@ -0,0 +1,93 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+
+import java.io.ObjectStreamException;
+import java.util.Comparator;
+import java.util.TreeSet;
+
+/**
+ * Binary {@link TreeSet} wrapper.
+ */
+public class BinaryTreeSet implements Binarylizable {
+ /** Original set. */
+ private TreeSet set;
+
+ /**
+ * Default constructor.
+ */
+ public BinaryTreeSet() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param set Original set.
+ */
+ public BinaryTreeSet(TreeSet set) {
+ this.set = set;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter rawWriter = writer.rawWriter();
+
+ rawWriter.writeObject(set.comparator());
+
+ int size = set.size();
+
+ rawWriter.writeInt(size);
+
+ for (Object val : set)
+ rawWriter.writeObject(val);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader rawReader = reader.rawReader();
+
+ Comparator comp = rawReader.readObject();
+
+ set = comp == null ? new TreeSet() : new TreeSet(comp);
+
+ int size = rawReader.readInt();
+
+ for (int i = 0; i < size; i++)
+ set.add(rawReader.readObject());
+ }
+
+ /**
+ * Reconstructs object on unmarshalling.
+ *
+ * @return Reconstructed object.
+ * @throws ObjectStreamException Thrown in case of unmarshalling error.
+ */
+ protected Object readResolve() throws ObjectStreamException {
+ return set;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeSetWriteReplacer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeSetWriteReplacer.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeSetWriteReplacer.java
new file mode 100644
index 0000000..4350777
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTreeSetWriteReplacer.java
@@ -0,0 +1,34 @@
+/*
+ * 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.binary;
+
+import org.jetbrains.annotations.Nullable;
+
+import java.util.TreeSet;
+
+/**
+ * Binary {@link TreeSet} write replacer.
+ */
+public class BinaryTreeSetWriteReplacer implements BinaryWriteReplacer {
+ /** {@inheritDoc} */
+ @Nullable @Override public Object replace(Object target) {
+ assert target instanceof TreeSet;
+
+ return new BinaryTreeSet((TreeSet)target);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index 76e5b31..b5834a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -82,6 +82,9 @@ public class BinaryUtils {
public static final boolean USE_STR_SERIALIZATION_VER_2 = IgniteSystemProperties.getBoolean(
IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2, false);
+ /** Map from class to associated write replacer. */
+ public static final Map<Class, BinaryWriteReplacer> CLS_TO_WRITE_REPLACER = new HashMap<>();
+
/** {@code true} if serialized value of this type cannot contain references to objects. */
private static final boolean[] PLAIN_TYPE_FLAG = new boolean[102];
@@ -118,6 +121,10 @@ public class BinaryUtils {
/** Field ID length. */
public static final int FIELD_ID_LEN = 4;
+ /** Whether to skip TreeMap/TreeSet wrapping. */
+ public static final boolean WRAP_TREES =
+ !IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_BINARY_DONT_WRAP_TREE_STRUCTURES);
+
/** Field type names. */
private static final String[] FIELD_TYPE_NAMES;
@@ -244,6 +251,11 @@ public class BinaryUtils {
FIELD_TYPE_NAMES[GridBinaryMarshaller.TIMESTAMP_ARR] = "Timestamp[]";
FIELD_TYPE_NAMES[GridBinaryMarshaller.OBJ_ARR] = "Object[]";
FIELD_TYPE_NAMES[GridBinaryMarshaller.ENUM_ARR] = "Enum[]";
+
+ if (wrapTrees()) {
+ CLS_TO_WRITE_REPLACER.put(TreeMap.class, new BinaryTreeMapWriteReplacer());
+ CLS_TO_WRITE_REPLACER.put(TreeSet.class, new BinaryTreeSetWriteReplacer());
+ }
}
/**
@@ -584,6 +596,13 @@ public class BinaryUtils {
}
/**
+ * @return Whether tree structures should be wrapped.
+ */
+ public static boolean wrapTrees() {
+ return WRAP_TREES;
+ }
+
+ /**
* @param map Map to check.
* @return {@code True} if this map type is supported.
*/
@@ -592,7 +611,7 @@ public class BinaryUtils {
return cls == HashMap.class ||
cls == LinkedHashMap.class ||
- cls == TreeMap.class ||
+ (!wrapTrees() && cls == TreeMap.class) ||
cls == ConcurrentHashMap8.class ||
cls == ConcurrentHashMap.class;
}
@@ -611,7 +630,7 @@ public class BinaryUtils {
return U.newHashMap(((Map)map).size());
else if (cls == LinkedHashMap.class)
return U.newLinkedHashMap(((Map)map).size());
- else if (cls == TreeMap.class)
+ else if (!wrapTrees() && cls == TreeMap.class)
return new TreeMap<>(((TreeMap<Object, Object>)map).comparator());
else if (cls == ConcurrentHashMap8.class)
return new ConcurrentHashMap8<>(U.capacity(((Map)map).size()));
@@ -650,7 +669,7 @@ public class BinaryUtils {
return cls == HashSet.class ||
cls == LinkedHashSet.class ||
- cls == TreeSet.class ||
+ (!wrapTrees() && cls == TreeSet.class) ||
cls == ConcurrentSkipListSet.class ||
cls == ArrayList.class ||
cls == LinkedList.class;
@@ -686,7 +705,7 @@ public class BinaryUtils {
return U.newHashSet(((Collection)col).size());
else if (cls == LinkedHashSet.class)
return U.newLinkedHashSet(((Collection)col).size());
- else if (cls == TreeSet.class)
+ else if (!wrapTrees() && cls == TreeSet.class)
return new TreeSet<>(((TreeSet<Object>)col).comparator());
else if (cls == ConcurrentSkipListSet.class)
return new ConcurrentSkipListSet<>(((ConcurrentSkipListSet<Object>)col).comparator());
@@ -2214,6 +2233,16 @@ public class BinaryUtils {
}
/**
+ * Get predefined write-replacer associated with class.
+ *
+ * @param cls Class.
+ * @return Write replacer.
+ */
+ public static BinaryWriteReplacer writeReplacer(Class cls) {
+ return cls != null ? CLS_TO_WRITE_REPLACER.get(cls) : null;
+ }
+
+ /**
* Enum type.
*/
private static class EnumType {
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriteReplacer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriteReplacer.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriteReplacer.java
new file mode 100644
index 0000000..9376c37
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriteReplacer.java
@@ -0,0 +1,33 @@
+/*
+ * 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.binary;
+
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Interface to perform write replace.
+ */
+public interface BinaryWriteReplacer {
+ /**
+ * Perform replace.
+ *
+ * @param target Original object.
+ * @return Replaced object.
+ */
+ @Nullable public Object replace(Object target);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index 30710f4..9450482 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -17,10 +17,18 @@
package org.apache.ignite.internal.binary;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
+import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.jetbrains.annotations.Nullable;
+
import java.io.IOException;
import java.io.ObjectOutput;
import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -29,14 +37,6 @@ import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
-import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
-import org.apache.ignite.internal.util.typedef.internal.A;
-import org.jetbrains.annotations.Nullable;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -170,21 +170,8 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
return;
}
- if (enableReplace && desc.getWriteReplaceMethod() != null) {
- Object replacedObj;
-
- try {
- replacedObj = desc.getWriteReplaceMethod().invoke(obj);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- catch (InvocationTargetException e) {
- if (e.getTargetException() instanceof BinaryObjectException)
- throw (BinaryObjectException)e.getTargetException();
-
- throw new BinaryObjectException("Failed to execute writeReplace() method on " + obj, e);
- }
+ if (enableReplace && desc.isWriteReplace()) {
+ Object replacedObj = desc.writeReplace(obj);
if (replacedObj == null) {
out.writeByte(GridBinaryMarshaller.NULL);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryTreeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryTreeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryTreeSelfTest.java
new file mode 100644
index 0000000..d57b34d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryTreeSelfTest.java
@@ -0,0 +1,341 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+/**
+ * Tests for TreeMap and TreeSet structures.
+ */
+public class BinaryTreeSelfTest extends GridCommonAbstractTest {
+ /** Data structure size. */
+ private static final int SIZE = 100;
+
+ /** Node name: server. */
+ private static final String NODE_SRV = "srv";
+
+ /** Node name: client. */
+ private static final String NODE_CLI = "cli";
+
+ /** Key to be used for cache operations. */
+ private static final int KEY = 1;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ Ignition.start(configuration(NODE_SRV, false));
+ Ignition.start(configuration(NODE_CLI, true));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ G.stop(NODE_CLI, true);
+ G.stop(NODE_SRV, true);
+ }
+
+ /**
+ * Test {@code TreeMap} data structure.
+ *
+ * @throws Exception If failed.
+ */
+ public void testTreeMapRegularNoComparator() throws Exception {
+ checkTreeMap(false, false);
+ }
+
+ /**
+ * Test {@code TreeMap} data structure with comparator.
+ *
+ * @throws Exception If failed.
+ */
+ public void testTreeMapRegularComparator() throws Exception {
+ checkTreeMap(false, true);
+ }
+
+ /**
+ * Test {@code TreeMap} data structure with binary mode.
+ *
+ * @throws Exception If failed.
+ */
+ public void testTreeMapBinaryNoComparator() throws Exception {
+ checkTreeMap(true, false);
+ }
+
+ /**
+ * Test {@code TreeMap} data structure with binary mode and comparator.
+ *
+ * @throws Exception If failed.
+ */
+ public void testTreeMapBinaryComparator() throws Exception {
+ checkTreeMap(true, true);
+ }
+
+ /**
+ * Check {@code TreeMap} data structure.
+ *
+ * @param useBinary Whether to go through binary mode.
+ * @param useComparator Whether comparator should be used.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("unchecked")
+ private void checkTreeMap(boolean useBinary, boolean useComparator) throws Exception {
+ // Populate map.
+ TreeMap<TestKey, Integer> map;
+
+ if (useComparator) {
+ map = new TreeMap<>(new TestKeyComparator());
+
+ for (int i = 0; i < SIZE; i++)
+ map.put(key(false, i), i);
+ }
+ else {
+ map = new TreeMap<>();
+
+ for (int i = 0; i < SIZE; i++)
+ map.put(key(true, i), i);
+ }
+
+ // Put and get value from cache.
+ cache().put(KEY, map);
+
+ TreeMap<TestKey, Integer> resMap;
+
+ if (useBinary) {
+ BinaryObject resMapBinary = (BinaryObject)cache().withKeepBinary().get(KEY);
+
+ resMap = resMapBinary.deserialize();
+ }
+ else
+ resMap = (TreeMap<TestKey, Integer>)cache().get(KEY);
+
+ // Ensure content is correct.
+ if (useComparator)
+ assert resMap.comparator() instanceof TestKeyComparator;
+ else
+ assertNull(resMap.comparator());
+
+ assertEquals(map, resMap);
+ }
+
+ /**
+ * Test {@code TreeSet} data structure.
+ *
+ * @throws Exception If failed.
+ */
+ public void testTreeSetRegularNoComparator() throws Exception {
+ checkTreeSet(false, false);
+ }
+
+ /**
+ * Test {@code TreeSet} data structure with comparator.
+ *
+ * @throws Exception If failed.
+ */
+ public void testTreeSetRegularComparator() throws Exception {
+ checkTreeSet(false, true);
+ }
+
+ /**
+ * Test {@code TreeSet} data structure with binary mode.
+ *
+ * @throws Exception If failed.
+ */
+ public void testTreeSetBinaryNoComparator() throws Exception {
+ checkTreeSet(true, false);
+ }
+
+ /**
+ * Test {@code TreeSet} data structure with binary mode and comparator.
+ *
+ * @throws Exception If failed.
+ */
+ public void testTreeSetBinaryComparator() throws Exception {
+ checkTreeSet(true, true);
+ }
+
+ /**
+ * Check {@code TreeSet} data structure.
+ *
+ * @param useBinary Whether to go through binary mode.
+ * @param useComparator Whether comparator should be used.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("unchecked")
+ private void checkTreeSet(boolean useBinary, boolean useComparator) throws Exception {
+ // Populate set.
+ TreeSet<TestKey> set;
+
+ if (useComparator) {
+ set = new TreeSet<>(new TestKeyComparator());
+
+ for (int i = 0; i < SIZE; i++)
+ set.add(key(false, i));
+ }
+ else {
+ set = new TreeSet<>();
+
+ for (int i = 0; i < SIZE; i++)
+ set.add(key(true, i));
+ }
+
+ // Put and get value from cache.
+ cache().put(KEY, set);
+
+ TreeSet<TestKey> resSet;
+
+ if (useBinary) {
+ BinaryObject resMapBinary = (BinaryObject)cache().withKeepBinary().get(KEY);
+
+ resSet = resMapBinary.deserialize();
+ }
+ else
+ resSet = (TreeSet<TestKey>)cache().get(KEY);
+
+ // Ensure content is correct.
+ if (useComparator)
+ assert resSet.comparator() instanceof TestKeyComparator;
+ else
+ assertNull(resSet.comparator());
+
+ assertEquals(set, resSet);
+ }
+
+ /**
+ * @return Cache.
+ */
+ private IgniteCache cache() {
+ return G.ignite(NODE_CLI).cache(null);
+ }
+
+ /**
+ * Get key.
+ *
+ * @param comparable Whether it should be comparable.
+ * @param id ID.
+ * @return Key.
+ */
+ private static TestKey key(boolean comparable, int id) {
+ return comparable ? new TestKeyComparable(id) : new TestKey(id);
+ }
+
+ /**
+ * Create configuration.
+ *
+ * @param name Node name.
+ * @param client Client mode flag.
+ * @return Configuration.
+ */
+ private static IgniteConfiguration configuration(String name, boolean client) {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setGridName(name);
+
+ cfg.setClientMode(client);
+
+ cfg.setLocalHost("127.0.0.1");
+ cfg.setPeerClassLoadingEnabled(false);
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
+
+ ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500"));
+
+ discoSpi.setIpFinder(ipFinder);
+
+ cfg.setDiscoverySpi(discoSpi);
+
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ ccfg.setCacheMode(CacheMode.PARTITIONED);
+
+ cfg.setCacheConfiguration(ccfg);
+
+ return cfg;
+ }
+
+ /**
+ * Test key.
+ */
+ private static class TestKey {
+ /** ID. */
+ private int id;
+
+ /**
+ * Constructor.
+ *
+ * @param id ID.
+ */
+ public TestKey(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return ID.
+ */
+ public int id() {
+ return id;
+ }
+ }
+
+ /**
+ * Test key implementing comparable interface.
+ */
+ private static class TestKeyComparable extends TestKey implements Comparable<TestKey> {
+ /**
+ * Constructor.
+ *
+ * @param id ID.
+ */
+ private TestKeyComparable(int id) {
+ super(id);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int compareTo(@NotNull TestKey o) {
+ return id() - o.id();
+ }
+ }
+
+ /**
+ * Test key comparator.
+ */
+ private static class TestKeyComparator implements Comparator<TestKey> {
+ /** {@inheritDoc} */
+ @Override public int compare(TestKey o1, TestKey o2) {
+ return o1.id() - o2.id();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4ffdbc/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
index cedf9a7..dc0540d 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.binary.BinaryObjectBuilderAdditionalSelfTest;
import org.apache.ignite.internal.binary.BinaryObjectBuilderDefaultMappersSelfTest;
import org.apache.ignite.internal.binary.BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest;
import org.apache.ignite.internal.binary.BinarySimpleNameTestPropertySelfTest;
+import org.apache.ignite.internal.binary.BinaryTreeSelfTest;
import org.apache.ignite.internal.binary.GridBinaryAffinityKeySelfTest;
import org.apache.ignite.internal.binary.GridBinaryMarshallerCtxDisabledSelfTest;
import org.apache.ignite.internal.binary.GridBinaryWildcardsSelfTest;
@@ -85,6 +86,7 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
suite.addTestSuite(BinaryBasicIdMapperSelfTest.class);
suite.addTestSuite(BinaryBasicNameMapperSelfTest.class);
+ suite.addTestSuite(BinaryTreeSelfTest.class);
suite.addTestSuite(BinaryMarshallerSelfTest.class);
suite.addTestSuite(BinaryConfigurationConsistencySelfTest.class);
suite.addTestSuite(GridBinaryMarshallerCtxDisabledSelfTest.class);
[26/28] ignite git commit: IGNITE-3702 Fixed missing query index type
setter generation. Added tests. Minor code improvements.
Posted by ak...@apache.org.
IGNITE-3702 Fixed missing query index type setter generation. Added tests. Minor code improvements.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/974467aa
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/974467aa
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/974467aa
Branch: refs/heads/master
Commit: 974467aa1e8a1cdfcd25bd2218d71e70c0dceddc
Parents: 7422195
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Aug 22 10:14:27 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Aug 22 10:14:27 2016 +0700
----------------------------------------------------------------------
.../parser/dialect/DatabaseMetadataDialect.java | 18 +
.../parser/dialect/JdbcMetadataDialect.java | 5 +-
.../parser/dialect/OracleMetadataDialect.java | 5 +-
.../ignite/schema/generator/CodeGenerator.java | 7 +-
.../schema/parser/DatabaseMetadataParser.java | 4 +-
.../ignite/schema/ui/SchemaImportApp.java | 3 +-
.../schema/test/AbstractSchemaImportTest.java | 27 +-
.../test/generator/CodeGeneratorTest.java | 28 +-
.../schema/test/generator/XmlGeneratorTest.java | 22 +-
.../ignite/schema/test/model/CacheConfig.txt | 409 +++++++++++++++++++
.../schema/test/model/ignite-type-metadata.xml | 50 ++-
.../test/parser/DbMetadataParserTest.java | 6 +-
12 files changed, 538 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/974467aa/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java
index f34eee4..5ef088a 100644
--- a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java
+++ b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java
@@ -21,10 +21,12 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.cache.QueryIndexType;
import org.apache.ignite.schema.parser.DbColumn;
import org.apache.ignite.schema.parser.DbTable;
@@ -72,4 +74,20 @@ public abstract class DatabaseMetadataDialect {
protected DbTable table(String schema, String tbl, Collection<DbColumn> cols, Collection<QueryIndex>idxs) {
return new DbTable(schema, tbl, cols, idxs);
}
+
+ /**
+ * Create index descriptor.
+ *
+ * @param idxName Index name.
+ * @return New initialized {@code QueryIndex} instance.
+ */
+ protected QueryIndex index(String idxName) {
+ QueryIndex idx = new QueryIndex();
+
+ idx.setName(idxName);
+ idx.setIndexType(QueryIndexType.SORTED);
+ idx.setFields(new LinkedHashMap<String, Boolean>());
+
+ return idx;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/974467aa/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
index 0b54b25..235c84c 100644
--- a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
+++ b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
@@ -171,10 +171,7 @@ public class JdbcMetadataDialect extends DatabaseMetadataDialect {
QueryIndex idx = idxs.get(idxName);
if (idx == null) {
- idx = new QueryIndex();
- idx.setName(idxName);
- idx.setIndexType(QueryIndexType.SORTED);
- idx.setFields(new LinkedHashMap<String, Boolean>());
+ idx = index(idxName);
idxs.put(idxName, idx);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/974467aa/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
index ed5cdc5..3535655 100644
--- a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
+++ b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
@@ -272,10 +272,7 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
QueryIndex idx = idxs.get(idxName);
if (idx == null) {
- idx = new QueryIndex();
- idx.setName(idxName);
- idx.setIndexType(QueryIndexType.SORTED);
- idx.setFields(new LinkedHashMap<String, Boolean>());
+ idx = index(idxName);
idxs.put(idxName, idx);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/974467aa/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java
index 01fcfa6..59dfdc4 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java
@@ -728,6 +728,9 @@ public class CodeGenerator {
add2(src, "idx.setName(\"" + idx.getName() + "\");");
add0(src, "");
+ add2(src, "idx.setIndexType(QueryIndexType." + idx.getIndexType() + ");");
+ add0(src, "");
+
add2(src, (firstIdx ? "LinkedHashMap<String, Boolean> " : "") +
"idxFlds = new LinkedHashMap<>();");
add0(src, "");
@@ -781,7 +784,7 @@ public class CodeGenerator {
add2(src, "ccfg.setWriteThrough(true);");
add0(src, "");
- add2(src, "// Configure JDBC types. ");
+ add2(src, "// Configure JDBC types.");
add2(src, "Collection<JdbcType> jdbcTypes = new ArrayList<>();");
add0(src, "");
@@ -794,7 +797,7 @@ public class CodeGenerator {
add0(src, "");
- add2(src, "// Configure query entities. ");
+ add2(src, "// Configure query entities.");
add2(src, "Collection<QueryEntity> qryEntities = new ArrayList<>();");
add0(src, "");
http://git-wip-us.apache.org/repos/asf/ignite/blob/974467aa/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
index b86346f..6d87ed5 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
@@ -99,8 +99,8 @@ public class DatabaseMetadataParser {
if (!children.isEmpty()) {
parent.children(children);
- res.add(parent);
- res.addAll(children);
+ res.add(parent); // Add schema description.
+ res.addAll(children); // Add tables in schema.
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/974467aa/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
index a02d31e..6305341 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
@@ -798,8 +798,9 @@ public class SchemaImportApp extends Application {
/**
* Check that system has Nautilus.
+ *
* @return {@code True} when Nautilus is installed or {@code false} otherwise.
- * @throws IOException
+ * @throws IOException If failed to detect Nautilus.
*/
private boolean canUseNautilus() throws IOException {
if (U.isUnix() || new File("/usr/bin/xdg-mime").canExecute() || new File("/usr/bin/nautilus").canExecute()) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/974467aa/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java
index d4534be..8cb1196 100644
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java
+++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java
@@ -35,8 +35,6 @@ import org.apache.ignite.schema.parser.DatabaseMetadataParser;
import org.apache.ignite.schema.ui.ConfirmCallable;
import org.apache.ignite.schema.ui.MessageBox;
-import static org.apache.ignite.schema.ui.MessageBox.Result.YES_TO_ALL;
-
/**
* Base functional for Ignite Schema Import utility tests.
*/
@@ -48,13 +46,16 @@ public abstract class AbstractSchemaImportTest extends TestCase {
protected static final String OUT_DIR_PATH = System.getProperty("java.io.tmpdir") + "/ignite-schema-import/out";
/** Auto confirmation of file conflicts. */
- protected final ConfirmCallable askOverwrite = new ConfirmCallable(null, "") {
+ protected static final ConfirmCallable YES_TO_ALL = new ConfirmCallable(null, "") {
@Override public MessageBox.Result confirm(String msg) {
- return YES_TO_ALL;
+ return MessageBox.Result.YES_TO_ALL;
}
};
- /** List of generated for test database POJO objects. */
+ /** List of ALL object parsed from test database. */
+ protected List<PojoDescriptor> all;
+
+ /** List of ONLY POJO descriptors. */
protected List<PojoDescriptor> pojos;
/** {@inheritDoc} */
@@ -99,6 +100,10 @@ public abstract class AbstractSchemaImportTest extends TestCase {
" arrCol BINARY(10)," +
" FIELD_WITH_ALIAS VARCHAR(10))");
+ stmt.executeUpdate("CREATE INDEX IF NOT EXISTS IDX_1 ON OBJECTS (INTCOL ASC, LONGCOL ASC)");
+
+ stmt.executeUpdate("CREATE INDEX IF NOT EXISTS IDX_2 ON OBJECTS (INTCOL ASC, LONGCOL DESC)");
+
stmt.executeUpdate("CREATE SCHEMA IF NOT EXISTS TESTSCHEMA");
stmt.executeUpdate("CREATE TABLE IF NOT EXISTS TESTSCHEMA.TST(pk INTEGER PRIMARY KEY, " +
@@ -118,13 +123,23 @@ public abstract class AbstractSchemaImportTest extends TestCase {
" arrCol BINARY(10)," +
" FIELD_WITH_ALIAS VARCHAR(10))");
+ stmt.executeUpdate("CREATE INDEX IF NOT EXISTS IDX_3 ON TESTSCHEMA.TST (INTCOL ASC, LONGCOL ASC)");
+
+ stmt.executeUpdate("CREATE INDEX IF NOT EXISTS IDX_4 ON TESTSCHEMA.TST (INTCOL ASC, LONGCOL DESC)");
+
conn.commit();
U.closeQuiet(stmt);
List<String> schemas = new ArrayList<>();
- pojos = DatabaseMetadataParser.parse(conn, schemas, false);
+ all = DatabaseMetadataParser.parse(conn, schemas, false);
+
+ pojos = new ArrayList<>();
+
+ for (PojoDescriptor pojo : all)
+ if (pojo.parent() != null)
+ pojos.add(pojo);
U.closeQuiet(conn);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/974467aa/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java
index 2fef9e1..0917139 100644
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java
+++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java
@@ -29,26 +29,29 @@ public class CodeGeneratorTest extends AbstractSchemaImportTest {
/** Marker string to skip date generation while comparing.*/
private static final String GEN_PTRN = "Code generated by Apache Ignite Schema Import utility";
+ /** Test package. */
+ private static final String TEST_PACKAGE = "org.apache.ignite.schema.test.model";
+
+ /** Path to generated model. */
+ private static final String TEST_PATH = "org/apache/ignite/schema/test/model";
+
/**
* Test that POJOs generated correctly.
*/
public void testPojoGeneration() throws Exception {
- String pkg = "org.apache.ignite.schema.test.model";
- String intPath = "org/apache/ignite/schema/test/model";
-
Boolean containsSchema = false;
- for (PojoDescriptor pojo : pojos) {
+ for (PojoDescriptor pojo : all) {
if (pojo.valueClassName().isEmpty())
containsSchema = true;
else {
- CodeGenerator.pojos(pojo, OUT_DIR_PATH, pkg, true, true, askOverwrite);
+ CodeGenerator.pojos(pojo, OUT_DIR_PATH, TEST_PACKAGE, true, true, YES_TO_ALL);
assertTrue("Generated key class POJO content is differ from expected for type " + pojo.keyClassName(),
- compareFiles(pojo.keyClassName(), intPath, GEN_PTRN));
+ compareFiles(pojo.keyClassName(), TEST_PATH, GEN_PTRN));
assertTrue("Generated value class POJO content is differ from expected for type " + pojo.valueClassName(),
- compareFiles(pojo.valueClassName(), intPath, GEN_PTRN));
+ compareFiles(pojo.valueClassName(), TEST_PATH, GEN_PTRN));
}
}
@@ -56,6 +59,15 @@ public class CodeGeneratorTest extends AbstractSchemaImportTest {
}
/**
+ * Test that configuration generated correctly.
+ */
+ public void testConfigGeneration() throws Exception {
+ CodeGenerator.snippet(pojos, TEST_PACKAGE, true, true, OUT_DIR_PATH, YES_TO_ALL);
+
+ assertTrue("Generated configuration is differ from expected", compareFiles("CacheConfig", TEST_PATH, GEN_PTRN));
+ }
+
+ /**
* @param typeName Type name.
* @param intPath Internal path.
* @return {@code true} if generated POJO as expected.
@@ -66,4 +78,4 @@ public class CodeGeneratorTest extends AbstractSchemaImportTest {
return compareFilesInt(getClass().getResourceAsStream("/" + relPath + ".txt"),
new File(OUT_DIR_PATH + "/" + relPath + ".java"), excludePtrn);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/974467aa/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
index 2ed36e9..8b12392 100644
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
+++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
@@ -18,33 +18,25 @@
package org.apache.ignite.schema.test.generator;
import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
import org.apache.ignite.schema.generator.XmlGenerator;
-import org.apache.ignite.schema.model.PojoDescriptor;
import org.apache.ignite.schema.test.AbstractSchemaImportTest;
/**
* Tests for XML generator.
*/
public class XmlGeneratorTest extends AbstractSchemaImportTest {
+ /** */
+ private static final String TEST_XML_FILE_NAME = "ignite-type-metadata.xml";
+
/**
* Test that XML generated correctly.
*/
public void testXmlGeneration() throws Exception {
- Collection<PojoDescriptor> all = new ArrayList<>();
-
- for (PojoDescriptor pojo : pojos)
- if (pojo.parent() != null)
- all.add(pojo);
-
- String fileName = "ignite-type-metadata.xml";
-
- XmlGenerator.generate("org.apache.ignite.schema.test.model", all, true, true, new File(OUT_DIR_PATH, fileName),
- askOverwrite);
+ XmlGenerator.generate("org.apache.ignite.schema.test.model", pojos, true, true,
+ new File(OUT_DIR_PATH, TEST_XML_FILE_NAME), YES_TO_ALL);
assertTrue("Generated XML file content is differ from expected one",
- compareFilesInt(getClass().getResourceAsStream("/org/apache/ignite/schema/test/model/" + fileName),
- new File(OUT_DIR_PATH + "/" + fileName), "XML generated by Apache Ignite Schema Import utility"));
+ compareFilesInt(getClass().getResourceAsStream("/org/apache/ignite/schema/test/model/" + TEST_XML_FILE_NAME),
+ new File(OUT_DIR_PATH, TEST_XML_FILE_NAME), "XML generated by Apache Ignite Schema Import utility"));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/974467aa/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/CacheConfig.txt
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/CacheConfig.txt b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/CacheConfig.txt
new file mode 100644
index 0000000..9573eb7
--- /dev/null
+++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/CacheConfig.txt
@@ -0,0 +1,409 @@
+/*
+ * 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.schema.test.model;
+
+import java.sql.*;
+import java.util.*;
+
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.store.jdbc.*;
+import org.apache.ignite.configuration.*;
+
+/**
+ * CacheConfig definition.
+ *
+ * Code generated by Apache Ignite Schema Import utility: 08/18/2016.
+ */
+public class CacheConfig {
+ /**
+ * Create JDBC type for OBJECTS.
+ *
+ * @param cacheName Cache name.
+ * @return Configured JDBC type.
+ */
+ private static JdbcType jdbcTypeObjects(String cacheName) {
+ JdbcType jdbcType = new JdbcType();
+
+ jdbcType.setCacheName(cacheName);
+ jdbcType.setDatabaseSchema("PUBLIC");
+ jdbcType.setDatabaseTable("OBJECTS");
+ jdbcType.setKeyType("org.apache.ignite.schema.test.model.ObjectsKey");
+ jdbcType.setValueType("org.apache.ignite.schema.test.model.Objects");
+
+ // Key fields for OBJECTS.
+ Collection<JdbcTypeField> keys = new ArrayList<>();
+ keys.add(new JdbcTypeField(Types.INTEGER, "PK", int.class, "pk"));
+ jdbcType.setKeyFields(keys.toArray(new JdbcTypeField[keys.size()]));
+
+ // Value fields for OBJECTS.
+ Collection<JdbcTypeField> vals = new ArrayList<>();
+ vals.add(new JdbcTypeField(Types.INTEGER, "PK", int.class, "pk"));
+ vals.add(new JdbcTypeField(Types.BOOLEAN, "BOOLCOL", Boolean.class, "boolcol"));
+ vals.add(new JdbcTypeField(Types.TINYINT, "BYTECOL", Byte.class, "bytecol"));
+ vals.add(new JdbcTypeField(Types.SMALLINT, "SHORTCOL", Short.class, "shortcol"));
+ vals.add(new JdbcTypeField(Types.INTEGER, "INTCOL", Integer.class, "intcol"));
+ vals.add(new JdbcTypeField(Types.BIGINT, "LONGCOL", Long.class, "longcol"));
+ vals.add(new JdbcTypeField(Types.REAL, "FLOATCOL", Float.class, "floatcol"));
+ vals.add(new JdbcTypeField(Types.DOUBLE, "DOUBLECOL", Double.class, "doublecol"));
+ vals.add(new JdbcTypeField(Types.DOUBLE, "DOUBLECOL2", Double.class, "doublecol2"));
+ vals.add(new JdbcTypeField(Types.DECIMAL, "BIGDECIMALCOL", java.math.BigDecimal.class, "bigdecimalcol"));
+ vals.add(new JdbcTypeField(Types.VARCHAR, "STRCOL", String.class, "strcol"));
+ vals.add(new JdbcTypeField(Types.DATE, "DATECOL", java.sql.Date.class, "datecol"));
+ vals.add(new JdbcTypeField(Types.TIME, "TIMECOL", java.sql.Time.class, "timecol"));
+ vals.add(new JdbcTypeField(Types.TIMESTAMP, "TSCOL", java.sql.Timestamp.class, "tscol"));
+ vals.add(new JdbcTypeField(Types.VARBINARY, "ARRCOL", Object.class, "arrcol"));
+ vals.add(new JdbcTypeField(Types.VARCHAR, "FIELD_WITH_ALIAS", String.class, "fieldWithAlias"));
+ jdbcType.setValueFields(vals.toArray(new JdbcTypeField[vals.size()]));
+
+ return jdbcType;
+ }
+
+ /**
+ * Create SQL Query descriptor for OBJECTS.
+ *
+ * @return Configured query entity.
+ */
+ private static QueryEntity queryEntityObjects() {
+ QueryEntity qryEntity = new QueryEntity();
+
+ qryEntity.setKeyType("org.apache.ignite.schema.test.model.ObjectsKey");
+ qryEntity.setValueType("org.apache.ignite.schema.test.model.Objects");
+
+ // Query fields for OBJECTS.
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+ fields.put("pk", "java.lang.Integer");
+ fields.put("boolcol", "java.lang.Boolean");
+ fields.put("bytecol", "java.lang.Byte");
+ fields.put("shortcol", "java.lang.Short");
+ fields.put("intcol", "java.lang.Integer");
+ fields.put("longcol", "java.lang.Long");
+ fields.put("floatcol", "java.lang.Float");
+ fields.put("doublecol", "java.lang.Double");
+ fields.put("doublecol2", "java.lang.Double");
+ fields.put("bigdecimalcol", "java.math.BigDecimal");
+ fields.put("strcol", "java.lang.String");
+ fields.put("datecol", "java.sql.Date");
+ fields.put("timecol", "java.sql.Time");
+ fields.put("tscol", "java.sql.Timestamp");
+ fields.put("arrcol", "java.lang.Object");
+ fields.put("fieldWithAlias", "java.lang.String");
+
+ qryEntity.setFields(fields);
+
+ // Aliases for fields.
+ Map<String, String> aliases = new HashMap<>();
+
+ aliases.put("fieldWithAlias", "FIELD_WITH_ALIAS");
+
+ qryEntity.setAliases(aliases);
+
+ // Indexes for OBJECTS.
+ Collection<QueryIndex> idxs = new ArrayList<>();
+
+ idxs.add(new QueryIndex("pk", true, "PRIMARY_KEY_C"));
+
+ QueryIndex idx = new QueryIndex();
+
+ idx.setName("IDX_1");
+
+ idx.setIndexType(QueryIndexType.SORTED);
+
+ LinkedHashMap<String, Boolean> idxFlds = new LinkedHashMap<>();
+
+ idxFlds.put("intcol", true);
+ idxFlds.put("longcol", true);
+
+ idx.setFields(idxFlds);
+
+ idxs.add(idx);
+
+ idx = new QueryIndex();
+
+ idx.setName("IDX_2");
+
+ idx.setIndexType(QueryIndexType.SORTED);
+
+ idxFlds = new LinkedHashMap<>();
+
+ idxFlds.put("intcol", true);
+ idxFlds.put("longcol", false);
+
+ idx.setFields(idxFlds);
+
+ idxs.add(idx);
+
+ qryEntity.setIndexes(idxs);
+
+ return qryEntity;
+ }
+
+ /**
+ * Create JDBC type for PRIMITIVES.
+ *
+ * @param cacheName Cache name.
+ * @return Configured JDBC type.
+ */
+ private static JdbcType jdbcTypePrimitives(String cacheName) {
+ JdbcType jdbcType = new JdbcType();
+
+ jdbcType.setCacheName(cacheName);
+ jdbcType.setDatabaseSchema("PUBLIC");
+ jdbcType.setDatabaseTable("PRIMITIVES");
+ jdbcType.setKeyType("org.apache.ignite.schema.test.model.PrimitivesKey");
+ jdbcType.setValueType("org.apache.ignite.schema.test.model.Primitives");
+
+ // Key fields for PRIMITIVES.
+ Collection<JdbcTypeField> keys = new ArrayList<>();
+ keys.add(new JdbcTypeField(Types.INTEGER, "PK", int.class, "pk"));
+ jdbcType.setKeyFields(keys.toArray(new JdbcTypeField[keys.size()]));
+
+ // Value fields for PRIMITIVES.
+ Collection<JdbcTypeField> vals = new ArrayList<>();
+ vals.add(new JdbcTypeField(Types.INTEGER, "PK", int.class, "pk"));
+ vals.add(new JdbcTypeField(Types.BOOLEAN, "BOOLCOL", boolean.class, "boolcol"));
+ vals.add(new JdbcTypeField(Types.TINYINT, "BYTECOL", byte.class, "bytecol"));
+ vals.add(new JdbcTypeField(Types.SMALLINT, "SHORTCOL", short.class, "shortcol"));
+ vals.add(new JdbcTypeField(Types.INTEGER, "INTCOL", int.class, "intcol"));
+ vals.add(new JdbcTypeField(Types.BIGINT, "LONGCOL", long.class, "longcol"));
+ vals.add(new JdbcTypeField(Types.REAL, "FLOATCOL", float.class, "floatcol"));
+ vals.add(new JdbcTypeField(Types.DOUBLE, "DOUBLECOL", double.class, "doublecol"));
+ vals.add(new JdbcTypeField(Types.DOUBLE, "DOUBLECOL2", double.class, "doublecol2"));
+ vals.add(new JdbcTypeField(Types.DECIMAL, "BIGDECIMALCOL", java.math.BigDecimal.class, "bigdecimalcol"));
+ vals.add(new JdbcTypeField(Types.VARCHAR, "STRCOL", String.class, "strcol"));
+ vals.add(new JdbcTypeField(Types.DATE, "DATECOL", java.sql.Date.class, "datecol"));
+ vals.add(new JdbcTypeField(Types.TIME, "TIMECOL", java.sql.Time.class, "timecol"));
+ vals.add(new JdbcTypeField(Types.TIMESTAMP, "TSCOL", java.sql.Timestamp.class, "tscol"));
+ vals.add(new JdbcTypeField(Types.VARBINARY, "ARRCOL", Object.class, "arrcol"));
+ vals.add(new JdbcTypeField(Types.VARCHAR, "FIELD_WITH_ALIAS", String.class, "fieldWithAlias"));
+ jdbcType.setValueFields(vals.toArray(new JdbcTypeField[vals.size()]));
+
+ return jdbcType;
+ }
+
+ /**
+ * Create SQL Query descriptor for PRIMITIVES.
+ *
+ * @return Configured query entity.
+ */
+ private static QueryEntity queryEntityPrimitives() {
+ QueryEntity qryEntity = new QueryEntity();
+
+ qryEntity.setKeyType("org.apache.ignite.schema.test.model.PrimitivesKey");
+ qryEntity.setValueType("org.apache.ignite.schema.test.model.Primitives");
+
+ // Query fields for PRIMITIVES.
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+ fields.put("pk", "java.lang.Integer");
+ fields.put("boolcol", "java.lang.Boolean");
+ fields.put("bytecol", "java.lang.Byte");
+ fields.put("shortcol", "java.lang.Short");
+ fields.put("intcol", "java.lang.Integer");
+ fields.put("longcol", "java.lang.Long");
+ fields.put("floatcol", "java.lang.Float");
+ fields.put("doublecol", "java.lang.Double");
+ fields.put("doublecol2", "java.lang.Double");
+ fields.put("bigdecimalcol", "java.math.BigDecimal");
+ fields.put("strcol", "java.lang.String");
+ fields.put("datecol", "java.sql.Date");
+ fields.put("timecol", "java.sql.Time");
+ fields.put("tscol", "java.sql.Timestamp");
+ fields.put("arrcol", "java.lang.Object");
+ fields.put("fieldWithAlias", "java.lang.String");
+
+ qryEntity.setFields(fields);
+
+ // Aliases for fields.
+ Map<String, String> aliases = new HashMap<>();
+
+ aliases.put("fieldWithAlias", "FIELD_WITH_ALIAS");
+
+ qryEntity.setAliases(aliases);
+
+ // Indexes for PRIMITIVES.
+ Collection<QueryIndex> idxs = new ArrayList<>();
+
+ idxs.add(new QueryIndex("pk", true, "PRIMARY_KEY_D"));
+
+ qryEntity.setIndexes(idxs);
+
+ return qryEntity;
+ }
+
+ /**
+ * Create JDBC type for TST.
+ *
+ * @param cacheName Cache name.
+ * @return Configured JDBC type.
+ */
+ private static JdbcType jdbcTypeTst(String cacheName) {
+ JdbcType jdbcType = new JdbcType();
+
+ jdbcType.setCacheName(cacheName);
+ jdbcType.setDatabaseSchema("TESTSCHEMA");
+ jdbcType.setDatabaseTable("TST");
+ jdbcType.setKeyType("org.apache.ignite.schema.test.model.TstKey");
+ jdbcType.setValueType("org.apache.ignite.schema.test.model.Tst");
+
+ // Key fields for TST.
+ Collection<JdbcTypeField> keys = new ArrayList<>();
+ keys.add(new JdbcTypeField(Types.INTEGER, "PK", int.class, "pk"));
+ jdbcType.setKeyFields(keys.toArray(new JdbcTypeField[keys.size()]));
+
+ // Value fields for TST.
+ Collection<JdbcTypeField> vals = new ArrayList<>();
+ vals.add(new JdbcTypeField(Types.INTEGER, "PK", int.class, "pk"));
+ vals.add(new JdbcTypeField(Types.BOOLEAN, "BOOLCOL", boolean.class, "boolcol"));
+ vals.add(new JdbcTypeField(Types.TINYINT, "BYTECOL", byte.class, "bytecol"));
+ vals.add(new JdbcTypeField(Types.SMALLINT, "SHORTCOL", short.class, "shortcol"));
+ vals.add(new JdbcTypeField(Types.INTEGER, "INTCOL", int.class, "intcol"));
+ vals.add(new JdbcTypeField(Types.BIGINT, "LONGCOL", long.class, "longcol"));
+ vals.add(new JdbcTypeField(Types.REAL, "FLOATCOL", float.class, "floatcol"));
+ vals.add(new JdbcTypeField(Types.DOUBLE, "DOUBLECOL", double.class, "doublecol"));
+ vals.add(new JdbcTypeField(Types.DOUBLE, "DOUBLECOL2", double.class, "doublecol2"));
+ vals.add(new JdbcTypeField(Types.DECIMAL, "BIGDECIMALCOL", java.math.BigDecimal.class, "bigdecimalcol"));
+ vals.add(new JdbcTypeField(Types.VARCHAR, "STRCOL", String.class, "strcol"));
+ vals.add(new JdbcTypeField(Types.DATE, "DATECOL", java.sql.Date.class, "datecol"));
+ vals.add(new JdbcTypeField(Types.TIME, "TIMECOL", java.sql.Time.class, "timecol"));
+ vals.add(new JdbcTypeField(Types.TIMESTAMP, "TSCOL", java.sql.Timestamp.class, "tscol"));
+ vals.add(new JdbcTypeField(Types.VARBINARY, "ARRCOL", Object.class, "arrcol"));
+ vals.add(new JdbcTypeField(Types.VARCHAR, "FIELD_WITH_ALIAS", String.class, "fieldWithAlias"));
+ jdbcType.setValueFields(vals.toArray(new JdbcTypeField[vals.size()]));
+
+ return jdbcType;
+ }
+
+ /**
+ * Create SQL Query descriptor for TST.
+ *
+ * @return Configured query entity.
+ */
+ private static QueryEntity queryEntityTst() {
+ QueryEntity qryEntity = new QueryEntity();
+
+ qryEntity.setKeyType("org.apache.ignite.schema.test.model.TstKey");
+ qryEntity.setValueType("org.apache.ignite.schema.test.model.Tst");
+
+ // Query fields for TST.
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+ fields.put("pk", "java.lang.Integer");
+ fields.put("boolcol", "java.lang.Boolean");
+ fields.put("bytecol", "java.lang.Byte");
+ fields.put("shortcol", "java.lang.Short");
+ fields.put("intcol", "java.lang.Integer");
+ fields.put("longcol", "java.lang.Long");
+ fields.put("floatcol", "java.lang.Float");
+ fields.put("doublecol", "java.lang.Double");
+ fields.put("doublecol2", "java.lang.Double");
+ fields.put("bigdecimalcol", "java.math.BigDecimal");
+ fields.put("strcol", "java.lang.String");
+ fields.put("datecol", "java.sql.Date");
+ fields.put("timecol", "java.sql.Time");
+ fields.put("tscol", "java.sql.Timestamp");
+ fields.put("arrcol", "java.lang.Object");
+ fields.put("fieldWithAlias", "java.lang.String");
+
+ qryEntity.setFields(fields);
+
+ // Aliases for fields.
+ Map<String, String> aliases = new HashMap<>();
+
+ aliases.put("fieldWithAlias", "FIELD_WITH_ALIAS");
+
+ qryEntity.setAliases(aliases);
+
+ // Indexes for TST.
+ Collection<QueryIndex> idxs = new ArrayList<>();
+
+ idxs.add(new QueryIndex("pk", true, "PRIMARY_KEY_1"));
+
+ QueryIndex idx = new QueryIndex();
+
+ idx.setName("IDX_3");
+
+ idx.setIndexType(QueryIndexType.SORTED);
+
+ LinkedHashMap<String, Boolean> idxFlds = new LinkedHashMap<>();
+
+ idxFlds.put("intcol", true);
+ idxFlds.put("longcol", true);
+
+ idx.setFields(idxFlds);
+
+ idxs.add(idx);
+
+ idx = new QueryIndex();
+
+ idx.setName("IDX_4");
+
+ idx.setIndexType(QueryIndexType.SORTED);
+
+ idxFlds = new LinkedHashMap<>();
+
+ idxFlds.put("intcol", true);
+ idxFlds.put("longcol", false);
+
+ idx.setFields(idxFlds);
+
+ idxs.add(idx);
+
+ qryEntity.setIndexes(idxs);
+
+ return qryEntity;
+ }
+
+ /**
+ * Configure cache.
+ *
+ * @param cacheName Cache name.
+ * @param storeFactory Cache store factory.
+ * @return Cache configuration.
+ */
+ public static <K, V> CacheConfiguration<K, V> cache(String cacheName, CacheJdbcPojoStoreFactory<K, V> storeFactory) {
+ if (storeFactory == null)
+ throw new IllegalArgumentException("Cache store factory cannot be null.");
+
+ CacheConfiguration<K, V> ccfg = new CacheConfiguration<>(cacheName);
+
+ ccfg.setCacheStoreFactory(storeFactory);
+ ccfg.setReadThrough(true);
+ ccfg.setWriteThrough(true);
+
+ // Configure JDBC types.
+ Collection<JdbcType> jdbcTypes = new ArrayList<>();
+
+ jdbcTypes.add(jdbcTypeObjects(cacheName));
+ jdbcTypes.add(jdbcTypePrimitives(cacheName));
+ jdbcTypes.add(jdbcTypeTst(cacheName));
+
+ storeFactory.setTypes(jdbcTypes.toArray(new JdbcType[jdbcTypes.size()]));
+
+ // Configure query entities.
+ Collection<QueryEntity> qryEntities = new ArrayList<>();
+
+ qryEntities.add(queryEntityObjects());
+ qryEntities.add(queryEntityPrimitives());
+ qryEntities.add(queryEntityTst());
+
+ ccfg.setQueryEntities(qryEntities);
+
+ return ccfg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/974467aa/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
index 514445f..fc481f0 100644
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
+++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
@@ -18,7 +18,7 @@
-->
<!--
- XML generated by Apache Ignite Schema Import utility: 11/20/2015
+ XML generated by Apache Ignite Schema Import utility: 08/18/2016
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
@@ -524,6 +524,30 @@
</map>
</property>
</bean>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <property name="name" value="IDX_1"/>
+ <property name="indexType">
+ <util:constant static-field="org.apache.ignite.cache.QueryIndexType.SORTED"/>
+ </property>
+ <property name="fields">
+ <map>
+ <entry key="intcol" value="true"/>
+ <entry key="longcol" value="true"/>
+ </map>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <property name="name" value="IDX_2"/>
+ <property name="indexType">
+ <util:constant static-field="org.apache.ignite.cache.QueryIndexType.SORTED"/>
+ </property>
+ <property name="fields">
+ <map>
+ <entry key="intcol" value="true"/>
+ <entry key="longcol" value="false"/>
+ </map>
+ </property>
+ </bean>
</list>
</property>
</bean>
@@ -612,6 +636,30 @@
</map>
</property>
</bean>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <property name="name" value="IDX_3"/>
+ <property name="indexType">
+ <util:constant static-field="org.apache.ignite.cache.QueryIndexType.SORTED"/>
+ </property>
+ <property name="fields">
+ <map>
+ <entry key="intcol" value="true"/>
+ <entry key="longcol" value="true"/>
+ </map>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <property name="name" value="IDX_4"/>
+ <property name="indexType">
+ <util:constant static-field="org.apache.ignite.cache.QueryIndexType.SORTED"/>
+ </property>
+ <property name="fields">
+ <map>
+ <entry key="intcol" value="true"/>
+ <entry key="longcol" value="false"/>
+ </map>
+ </property>
+ </bean>
</list>
</property>
</bean>
http://git-wip-us.apache.org/repos/asf/ignite/blob/974467aa/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java
index f918012..a550bfc 100644
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java
+++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java
@@ -106,7 +106,7 @@ public class DbMetadataParserTest extends AbstractSchemaImportTest {
*
* @param type Type to check.
*/
- public void checkSchemaHasFullDbName(PojoDescriptor type) {
+ private void checkSchemaHasFullDbName(PojoDescriptor type) {
assertNotNull("The DB schema should have a non-null fullDbName", type.fullDbName());
}
@@ -114,9 +114,9 @@ public class DbMetadataParserTest extends AbstractSchemaImportTest {
* Test that metadata generated correctly.
*/
public void testCheckMetadata() {
- assertEquals("Metadata should contain 5 elements", 5, pojos.size());
+ assertEquals("Metadata should contain 5 elements", 5, all.size());
- Iterator<PojoDescriptor> it = pojos.iterator();
+ Iterator<PojoDescriptor> it = all.iterator();
PojoDescriptor schema = it.next();
[20/28] ignite git commit: Fixed isReadFromBackup behaviour for
transaction. This closes #955.
Posted by ak...@apache.org.
Fixed isReadFromBackup behaviour for transaction. This closes #955.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/476081b9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/476081b9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/476081b9
Branch: refs/heads/master
Commit: 476081b9171b1b8e5ec0a1ffd7e87092da3601d6
Parents: 09a3922
Author: Tikhonov Nikolay <ti...@gmail.com>
Authored: Wed Aug 17 14:31:20 2016 +0300
Committer: Tikhonov Nikolay <ti...@gmail.com>
Committed: Wed Aug 17 14:31:20 2016 +0300
----------------------------------------------------------------------
.../near/GridNearTransactionalCache.java | 2 +-
.../cache/distributed/near/GridNearTxLocal.java | 4 +-
.../CacheTxNotAllowReadFromBackupTest.java | 297 +++++++++++++++++++
.../testsuites/IgniteCacheTestSuite4.java | 2 +
4 files changed, 302 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/476081b9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index e954a7f..cf5d2e2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -192,7 +192,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
GridNearGetFuture<K, V> fut = new GridNearGetFuture<>(ctx,
keys,
readThrough,
- /*force primary*/needVer,
+ /*force primary*/needVer || !ctx.config().isReadFromBackup(),
tx,
CU.subjectId(tx, ctx.shared()),
tx.resolveTaskName(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/476081b9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index db736a5..62cf74b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -363,7 +363,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
return cacheCtx.colocated().loadAsync(
key,
readThrough,
- /*force primary*/needVer,
+ /*force primary*/needVer || !cacheCtx.config().isReadFromBackup(),
topVer,
CU.subjectId(this, cctx),
resolveTaskName(),
@@ -394,7 +394,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
return cacheCtx.colocated().loadAsync(
keys,
readThrough,
- /*force primary*/needVer,
+ /*force primary*/needVer || !cacheCtx.config().isReadFromBackup(),
topVer,
CU.subjectId(this, cctx),
resolveTaskName(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/476081b9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxNotAllowReadFromBackupTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxNotAllowReadFromBackupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxNotAllowReadFromBackupTest.java
new file mode 100644
index 0000000..30de2f9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxNotAllowReadFromBackupTest.java
@@ -0,0 +1,297 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ThreadLocalRandom;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Test for query with BinaryMarshaller and different serialization modes and with reflective serializer.
+ */
+public class CacheTxNotAllowReadFromBackupTest extends GridCommonAbstractTest {
+ /** */
+ private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final int NODES = 2;
+
+ /** */
+ private static final int KEYS = 1000;
+
+ /** */
+ private static final int BATCH_SIZE = 10;
+
+ /** */
+ private static final int ITERATION_CNT = 5;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGridsMultiThreaded(NODES);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBackupConsistencyReplicated() throws Exception {
+ CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");
+
+ cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
+ cfg.setCacheMode(CacheMode.REPLICATED);
+ cfg.setReadFromBackup(false);
+
+ checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBackupConsistencyReplicatedFullSync() throws Exception {
+ CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");
+
+ cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+ cfg.setCacheMode(CacheMode.REPLICATED);
+ cfg.setReadFromBackup(false);
+
+ checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBackupConsistencyPartitioned() throws Exception {
+ CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");
+
+ cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
+ cfg.setCacheMode(CacheMode.PARTITIONED);
+ cfg.setBackups(NODES - 1);
+ cfg.setReadFromBackup(false);
+
+ checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBackupConsistencyPartitionedFullSync() throws Exception {
+ CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");
+
+ cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+ cfg.setCacheMode(CacheMode.PARTITIONED);
+ cfg.setBackups(NODES - 1);
+ cfg.setReadFromBackup(false);
+
+ checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
+ }
+
+ /**
+ * @param ccfg Cache configuration.
+ * @throws Exception If failed.
+ */
+ private void checkBackupConsistency(CacheConfiguration<Integer, Integer> ccfg, TransactionConcurrency txConcurrency,
+ TransactionIsolation txIsolation) throws Exception {
+ IgniteCache<Integer, Integer> cache = grid(0).getOrCreateCache(ccfg);
+
+ int nodeIdx = ThreadLocalRandom.current().nextInt(NODES);
+
+ try {
+ for (int i = 0; i < ITERATION_CNT; i++) {
+ log.info("Iteration: " + i);
+
+ // Put data in one transaction.
+ try (Transaction tx = grid(nodeIdx).transactions().txStart(txConcurrency, txIsolation)) {
+ for (int key = 0; key < KEYS; key++)
+ cache.put(key, key);
+
+ tx.commit();
+ }
+
+ int missCnt = 0;
+
+ // Try to load data from another transaction.
+ try (Transaction tx = grid(nodeIdx).transactions().txStart(txConcurrency, txIsolation)) {
+ for (int key = 0; key < KEYS; key++)
+ if (cache.get(key) == null)
+ ++missCnt;
+
+ tx.commit();
+ }
+
+ assertEquals("Failed. Found missing get()", 0, missCnt);
+ }
+ }
+ finally {
+ grid(0).destroyCache(ccfg.getName());
+ }
+ }
+
+ /**
+ * @param ccfg Cache configuration.
+ * @throws Exception If failed.
+ */
+ private void checkBackupConsistencyGetAll(CacheConfiguration<Integer, Integer> ccfg,
+ TransactionConcurrency txConcurrency, TransactionIsolation txIsolation) throws Exception {
+ IgniteCache<Integer, Integer> cache = grid(0).getOrCreateCache(ccfg);
+
+ int nodeIdx = ThreadLocalRandom.current().nextInt(NODES);
+
+ try {
+ for (int i = 0; i < ITERATION_CNT; i++) {
+ log.info("Iteration: " + i);
+
+ List<Set<Integer>> batches = createBatches();
+
+ // Put data in one transaction.
+ try (Transaction tx = grid(nodeIdx).transactions().txStart(txConcurrency, txIsolation)) {
+ for (int key = 0; key < KEYS; key++)
+ cache.put(key, key);
+
+ tx.commit();
+ }
+
+ // Try to load data from another transaction.
+ try (Transaction tx = grid(nodeIdx).transactions().txStart(txConcurrency, txIsolation)) {
+ for (Set<Integer> batch : batches)
+ assertEquals("Failed. Found missing entries.", batch.size(), cache.getAll(batch).size());
+
+ tx.commit();
+ }
+ }
+ }
+ finally {
+ grid(0).destroyCache(ccfg.getName());
+ }
+ }
+
+ /**
+ * @return Batches.
+ */
+ @NotNull private List<Set<Integer>> createBatches() {
+ List<Set<Integer>> batches = new ArrayList<>(KEYS / BATCH_SIZE + 1);
+
+ int size = BATCH_SIZE;
+ Set<Integer> batch = new HashSet<>();
+
+ for (int key = 0; key < KEYS; key++) {
+ batch.add(key);
+
+ if (--size == 0) {
+ size = BATCH_SIZE;
+ batch = new HashSet<>();
+ batches.add(batch);
+ }
+ }
+ return batches;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/476081b9/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index 018fa17..60d59d7 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -41,6 +41,7 @@ import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeDynam
import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeStaticStartAtomicTest;
import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeStaticStartTxTest;
import org.apache.ignite.internal.processors.cache.CacheSwapUnswapGetTest;
+import org.apache.ignite.internal.processors.cache.CacheTxNotAllowReadFromBackupTest;
import org.apache.ignite.internal.processors.cache.CrossCacheLockTest;
import org.apache.ignite.internal.processors.cache.GridCacheMarshallingNodeJoinSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheMultinodeUpdateAtomicNearEnabledSelfTest;
@@ -263,6 +264,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
suite.addTestSuite(CacheGetEntryPessimisticReadCommittedSeltTest.class);
suite.addTestSuite(CacheGetEntryPessimisticRepeatableReadSeltTest.class);
suite.addTestSuite(CacheGetEntryPessimisticSerializableSeltTest.class);
+ suite.addTestSuite(CacheTxNotAllowReadFromBackupTest.class);
suite.addTestSuite(CacheStopAndDestroySelfTest.class);
[08/28] ignite git commit: IGNITE-3343: IGFS: Secondary file system
is not queried for statuses during MKDIRS and CREATE operations. This closes
#896.
Posted by ak...@apache.org.
IGNITE-3343: IGFS: Secondary file system is not queried for statuses during MKDIRS and CREATE operations. This closes #896.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/dc81069b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/dc81069b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/dc81069b
Branch: refs/heads/master
Commit: dc81069ba9ebb88bc11cf6917e8733cc1f6de2fb
Parents: 9ddf9d8
Author: Ivan Veselovskiy <iv...@gridgain.com>
Authored: Tue Aug 2 11:11:24 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 12:30:53 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/IgniteFileSystem.java | 3 +-
.../igfs/secondary/IgfsSecondaryFileSystem.java | 4 +-
.../processors/igfs/IgfsCreateResult.java | 2 +-
.../internal/processors/igfs/IgfsImpl.java | 63 ++++++-----------
.../processors/igfs/IgfsMetaManager.java | 74 +++++---------------
.../processors/igfs/IgfsModeResolver.java | 31 ++++++--
.../internal/processors/igfs/IgfsPaths.java | 6 +-
.../IgfsSecondaryFileSystemCreateContext.java | 3 +
.../internal/processors/igfs/IgfsUtils.java | 12 +++-
.../processors/igfs/IgfsAbstractSelfTest.java | 34 ++++++++-
.../igfs/IgfsDualAbstractSelfTest.java | 13 ++++
.../igfs/IgfsModeResolverSelfTest.java | 51 ++++++++++++--
.../hadoop/fs/v1/IgniteHadoopFileSystem.java | 7 +-
.../hadoop/fs/v2/IgniteHadoopFileSystem.java | 7 +-
.../IgniteHadoopFileSystemAbstractSelfTest.java | 1 -
.../hadoop/HadoopAbstractMapReduceTest.java | 13 +++-
16 files changed, 196 insertions(+), 128 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
index bbc5bea..f9aeb8d 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
@@ -362,8 +362,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* will not be affected. Other properties will be added or overwritten. Passed properties with {@code null} values
* will be removed from the stored properties or ignored if they don't exist in the file info.
* <p>
- * When working in {@code DUAL_SYNC} or {@code DUAL_ASYNC} modes only the following properties will be propagated
- * to the secondary file system:
+ * When working in {@code DUAL_SYNC} or {@code DUAL_ASYNC} modes with Hadoop secondary file system only the following properties will be updated:
* <ul>
* <li>{@code usrName} - file owner name;</li>
* <li>{@code grpName} - file owner group;</li>
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
index 3f124eb..4d9d255 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
@@ -43,8 +43,8 @@ public interface IgfsSecondaryFileSystem {
* will not be affected. Other properties will be added or overwritten. Passed properties with {@code null} values
* will be removed from the stored properties or ignored if they don't exist in the file info.
* <p>
- * When working in {@code DUAL_SYNC} or {@code DUAL_ASYNC} modes only the following properties will be propagated
- * to the secondary file system:
+ * When working in {@code DUAL_SYNC} or {@code DUAL_ASYNC} modes with Hadoop secondary file system only the
+ * following properties will be updated on the secondary file system:
* <ul>
* <li>{@code usrName} - file owner name;</li>
* <li>{@code grpName} - file owner group;</li>
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCreateResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCreateResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCreateResult.java
index 0b09e02..eb1bc9d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCreateResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCreateResult.java
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
import java.io.OutputStream;
/**
- * IGFS file create result.
+ * IGFS file create or append result.
*/
public class IgfsCreateResult {
/** File info in the primary file system. */
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/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 0d1ffc1..e1f8e61 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
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.processors.igfs;
+import java.util.Set;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
@@ -248,7 +249,7 @@ public final class IgfsImpl implements IgfsEx {
}
}
- modeRslvr = new IgfsModeResolver(dfltMode, IgfsUtils.preparePathModes(dfltMode, modes));
+ modeRslvr = new IgfsModeResolver(dfltMode, modes);
Object secondaryFsPayload = null;
@@ -816,12 +817,14 @@ public final class IgfsImpl implements IgfsEx {
}
}
- IgniteUuid fileId = meta.fileId(path);
+ if (!IgfsUtils.isDualMode(mode) || modeRslvr.hasPrimaryChild(path)) {
+ IgniteUuid fileId = meta.fileId(path);
- if (fileId != null)
- files.addAll(meta.directoryListing(fileId).keySet());
- else if (mode == PRIMARY)
- throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
+ if (fileId != null)
+ files.addAll(meta.directoryListing(fileId).keySet());
+ 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) {
@@ -846,7 +849,7 @@ public final class IgfsImpl implements IgfsEx {
IgfsMode mode = resolveMode(path);
- Collection<IgfsFile> files = new HashSet<>();
+ Set<IgfsFile> files = new HashSet<>();
if (IgfsUtils.isDualMode(mode)) {
assert secondaryFs != null;
@@ -859,6 +862,9 @@ public final class IgfsImpl implements IgfsEx {
files.add(impl);
}
+
+ if (!modeRslvr.hasPrimaryChild(path))
+ return files;
}
catch (Exception e) {
U.error(log, "List files in DUAL mode failed [path=" + path + ']', e);
@@ -1345,29 +1351,6 @@ public final class IgfsImpl implements IgfsEx {
return fut;
}
- /**
- * Get file descriptor for specified path.
- *
- * @param path Path to file.
- * @return Detailed file descriptor or {@code null}, if file does not exist.
- * @throws IgniteCheckedException If failed.
- */
- @Nullable private FileDescriptor getFileDescriptor(IgfsPath path) throws IgniteCheckedException {
- assert path != null;
-
- List<IgniteUuid> ids = meta.idsForPath(path);
-
- IgfsEntryInfo fileInfo = meta.info(ids.get(ids.size() - 1));
-
- if (fileInfo == null)
- return null; // File does not exist.
-
- // Resolve parent ID for removed file.
- IgniteUuid parentId = ids.size() >= 2 ? ids.get(ids.size() - 2) : null;
-
- return new FileDescriptor(parentId, path.name(), fileInfo.id(), fileInfo.isFile());
- }
-
/** {@inheritDoc} */
@Override public <T, R> R execute(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
Collection<IgfsPath> paths, @Nullable T arg) {
@@ -1519,20 +1502,16 @@ public final class IgfsImpl implements IgfsEx {
case DUAL_SYNC:
case DUAL_ASYNC:
- info = meta.infoForPath(path);
-
- if (info == null) {
- try {
- IgfsFile status = secondaryFs.info(path);
+ try {
+ IgfsFile status = secondaryFs.info(path);
- if (status != null)
- return new IgfsFileImpl(status, data.groupBlockSize());
- }
- catch (Exception e) {
- U.error(log, "File info operation in DUAL mode failed [path=" + path + ']', e);
+ if (status != null)
+ return new IgfsFileImpl(status, data.groupBlockSize());
+ }
+ catch (Exception e) {
+ U.error(log, "File info operation in DUAL mode failed [path=" + path + ']', e);
- throw e;
- }
+ throw e;
}
break;
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/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 d891b38..0d14a3a 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
@@ -3051,29 +3051,19 @@ public class IgfsMetaManager extends IgfsManager {
if (secondaryCtx != null) {
secondaryOut = secondaryCtx.create();
- IgfsFile secondaryFile = secondaryCtx.info();
-
- if (secondaryFile == null)
- throw fsException("Failed to open output stream to the file created in " +
- "the secondary file system because it no longer exists: " + path);
- else if (secondaryFile.isDirectory())
- throw fsException("Failed to open output stream to the file created in " +
- "the secondary file system because the path points to a directory: " + path);
-
- newAccessTime = secondaryFile.accessTime();
- newModificationTime = secondaryFile.modificationTime();
- newProps = secondaryFile.properties();
- newLen = secondaryFile.length();
- newBlockSize = secondaryFile.blockSize();
+ newAccessTime = 0L;
+ newModificationTime = 0L;
+ newProps = null;
}
else {
newAccessTime = System.currentTimeMillis();
newModificationTime = newAccessTime;
newProps = fileProps;
- newLen = 0L;
- newBlockSize = blockSize;
}
+ newLen = 0L;
+ newBlockSize = blockSize;
+
IgfsEntryInfo newInfo = invokeAndGet(overwriteId,
new IgfsMetaFileCreateProcessor(newAccessTime, newModificationTime, newProps,
newBlockSize, affKey, newLockId, evictExclude, newLen));
@@ -3254,18 +3244,9 @@ public class IgfsMetaManager extends IgfsManager {
Map<String, String> props;
if (secondaryCtx != null) {
- IgfsFile secondaryInfo = secondaryCtx.fileSystem().info(lastCreatedPath);
-
- if (secondaryInfo == null)
- throw new IgfsException("Failed to perform operation because secondary file system path was " +
- "modified concurrently: " + lastCreatedPath);
- else if (secondaryInfo.isFile())
- throw new IgfsException("Failed to perform operation because secondary file system entity is " +
- "not directory: " + lastCreatedPath);
-
- accessTime = secondaryInfo.accessTime();
- modificationTime = secondaryInfo.modificationTime();
- props = secondaryInfo.properties();
+ accessTime = 0L;
+ modificationTime = 0L;
+ props = null;
}
else {
accessTime = curTime;
@@ -3293,18 +3274,9 @@ public class IgfsMetaManager extends IgfsManager {
Map<String, String> props;
if (secondaryCtx != null) {
- IgfsFile secondaryInfo = secondaryCtx.fileSystem().info(pathIds.path());
-
- if (secondaryInfo == null)
- throw new IgfsException("Failed to perform operation because secondary file system path was " +
- "modified concurrnetly: " + pathIds.path());
- else if (secondaryInfo.isFile())
- throw new IgfsException("Failed to perform operation because secondary file system entity is " +
- "not directory: " + lastCreatedPath);
-
- accessTime = secondaryInfo.accessTime();
- modificationTime = secondaryInfo.modificationTime();
- props = secondaryInfo.properties();
+ accessTime = 0L;
+ modificationTime = 0L;
+ props = null;
}
else {
accessTime = curTime;
@@ -3322,29 +3294,19 @@ public class IgfsMetaManager extends IgfsManager {
int newBlockSize;
if (secondaryCtx != null) {
- IgfsFile secondaryFile = secondaryCtx.info();
-
- if (secondaryFile == null)
- throw fsException("Failed to open output stream to the file created in " +
- "the secondary file system because it no longer exists: " + pathIds.path());
- else if (secondaryFile.isDirectory())
- throw fsException("Failed to open output stream to the file created in " +
- "the secondary file system because the path points to a directory: " + pathIds.path());
-
- newAccessTime = secondaryFile.accessTime();
- newModificationTime = secondaryFile.modificationTime();
- newProps = secondaryFile.properties();
- newLen = secondaryFile.length();
- newBlockSize = secondaryFile.blockSize();
+ newAccessTime = 0L;
+ newModificationTime = 0L;
+ newProps = null;
}
else {
newAccessTime = curTime;
newModificationTime = curTime;
newProps = fileProps;
- newLen = 0L;
- newBlockSize = blockSize;
}
+ newLen = 0L;
+ newBlockSize = blockSize;
+
procMap.put(curId, new IgfsMetaFileCreateProcessor(newAccessTime, newModificationTime, newProps,
newBlockSize, affKey, createFileLockId(false), evictExclude, newLen));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/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 907051f..33b835f 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,9 +17,12 @@
package org.apache.ignite.internal.processors.igfs;
-import java.util.Collections;
+import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap;
@@ -42,18 +45,24 @@ public class IgfsModeResolver {
/** Cached modes per path. */
private Map<IgfsPath, IgfsMode> modesCache;
+ /** Set to store parent dual paths that have primary children. */
+ private final Set<IgfsPath> dualParentsWithPrimaryChildren;
+
/**
* Constructor
*
* @param dfltMode Default IGFS mode.
* @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) {
+ public IgfsModeResolver(IgfsMode dfltMode, @Nullable ArrayList<T2<IgfsPath, IgfsMode>> modes)
+ throws IgniteCheckedException {
assert dfltMode != null;
this.dfltMode = dfltMode;
- this.modes = modes;
+ this.dualParentsWithPrimaryChildren = new HashSet<>();
+
+ this.modes = IgfsUtils.preparePathModes(dfltMode, modes, dualParentsWithPrimaryChildren);
if (modes != null)
modesCache = new GridBoundedConcurrentLinkedHashMap<>(MAX_PATH_CACHE);
@@ -94,10 +103,20 @@ public class IgfsModeResolver {
}
/**
- * @return Unmodifiable copy of properly ordered modes prefixes
+ * @return 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;
+ @Nullable public ArrayList<T2<IgfsPath, IgfsMode>> modesOrdered() {
+ return modes != null ? new ArrayList<>(modes) : null;
+ }
+
+ /**
+ * Answers if the given path has an immediate child of PRIMARY mode.
+ *
+ * @param path The path to query.
+ * @return If the given path has an immediate child of PRIMARY mode.
+ */
+ public boolean hasPrimaryChild(IgfsPath path) {
+ return dualParentsWithPrimaryChildren.contains(path);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
index 4a79259..2bdb23b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
@@ -48,7 +48,7 @@ public class IgfsPaths implements Externalizable {
private IgfsMode dfltMode;
/** Path modes. */
- private List<T2<IgfsPath, IgfsMode>> pathModes;
+ private ArrayList<T2<IgfsPath, IgfsMode>> pathModes;
/**
* Empty constructor required by {@link Externalizable}.
@@ -65,7 +65,7 @@ public class IgfsPaths implements Externalizable {
* @param pathModes Path modes.
* @throws IgniteCheckedException If failed.
*/
- public IgfsPaths(Object payload, IgfsMode dfltMode, @Nullable List<T2<IgfsPath, IgfsMode>> pathModes)
+ public IgfsPaths(Object payload, IgfsMode dfltMode, @Nullable ArrayList<T2<IgfsPath, IgfsMode>> pathModes)
throws IgniteCheckedException {
this.dfltMode = dfltMode;
this.pathModes = pathModes;
@@ -91,7 +91,7 @@ public class IgfsPaths implements Externalizable {
/**
* @return Path modes.
*/
- @Nullable public List<T2<IgfsPath, IgfsMode>> pathModes() {
+ @Nullable public ArrayList<T2<IgfsPath, IgfsMode>> pathModes() {
return pathModes;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemCreateContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemCreateContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemCreateContext.java
index 1c0efd6..788efe3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemCreateContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemCreateContext.java
@@ -28,6 +28,7 @@ import java.util.Map;
/**
* Context for secondary file system create request.
+ * Note that it is never used for dual mode append operation.
*/
public class IgfsSecondaryFileSystemCreateContext {
/** File system. */
@@ -68,6 +69,8 @@ public class IgfsSecondaryFileSystemCreateContext {
*/
public IgfsSecondaryFileSystemCreateContext(IgfsSecondaryFileSystem fs, IgfsPath path, boolean overwrite,
boolean simpleCreate, @Nullable Map<String, String> props, short replication, long blockSize, int bufSize) {
+ assert fs != null;
+
this.fs = fs;
this.path = path;
this.overwrite = overwrite;
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/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 03b7611..b9788f8 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
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.processors.igfs;
+import java.util.Set;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteSystemProperties;
@@ -66,6 +67,7 @@ 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.igfs.IgfsMode.PRIMARY;
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;
@@ -819,11 +821,13 @@ public class IgfsUtils {
*
* @param dfltMode The root mode. Must always be not null.
* @param modes The subdirectory modes.
+ * @param dualParentsContainingPrimaryChildren The set to store parents into.
* @return Descending list of filtered and checked modes.
- * @throws IgniteCheckedException On error or
+ * @throws IgniteCheckedException On error.
*/
public static ArrayList<T2<IgfsPath, IgfsMode>> preparePathModes(final IgfsMode dfltMode,
- @Nullable List<T2<IgfsPath, IgfsMode>> modes) throws IgniteCheckedException {
+ @Nullable List<T2<IgfsPath, IgfsMode>> modes, Set<IgfsPath> dualParentsContainingPrimaryChildren)
+ throws IgniteCheckedException {
if (modes == null)
return null;
@@ -857,6 +861,10 @@ public class IgfsUtils {
// Add to the 1st position (deep first).
resModes.add(0, mode);
+ // Store primary paths inside dual paths in separate collection:
+ if (mode.getValue() == PRIMARY)
+ dualParentsContainingPrimaryChildren.add(mode.getKey().parent());
+
break;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/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 384da95..fd3f9b6 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
@@ -245,6 +245,13 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
}
/**
+ * @return Relaxed consistency flag.
+ */
+ protected boolean initializeDefaultPathModes() {
+ return false;
+ }
+
+ /**
* @return Client flag.
*/
protected boolean client() {
@@ -369,6 +376,8 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
igfsCfg.setSequentialReadsBeforePrefetch(SEQ_READS_BEFORE_PREFETCH);
igfsCfg.setRelaxedConsistency(relaxedConsistency());
+ igfsCfg.setInitializeDefaultPathModes(initializeDefaultPathModes());
+
CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
dataCacheCfg.setName("dataCache");
@@ -1071,17 +1080,36 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testRootPropertiesPersistAfterFormat() throws Exception {
- igfs.update(new IgfsPath("/"), Collections.singletonMap("foo", "moo"));
+ if (dual && !(igfsSecondaryFileSystem instanceof IgfsSecondaryFileSystemImpl)) {
+ // In case of Hadoop dual mode only user name, group name, and permission properties are updated,
+ // an arbitrary named property is just ignored:
+ checkRootPropertyUpdate("foo", "moo", null);
+ checkRootPropertyUpdate(IgfsUtils.PROP_PERMISSION, "0777", "0777");
+ }
+ else {
+ checkRootPropertyUpdate("foo", "moo", "moo");
+ checkRootPropertyUpdate(IgfsUtils.PROP_PERMISSION, "0777", "0777");
+ }
+ }
+
+ /**
+ *
+ * @throws Exception
+ */
+ private void checkRootPropertyUpdate(String prop, String setVal, String expGetVal) throws Exception {
+ final IgfsPath rootPath = new IgfsPath("/");
+
+ igfs.update(rootPath, Collections.singletonMap(prop, setVal));
igfs.format();
- IgfsFile file = igfs.info(new IgfsPath("/"));
+ IgfsFile file = igfs.info(rootPath);
assert file != null;
Map<String,String> props = file.properties();
- assertEquals("moo", props.get("foo"));
+ assertEquals(expGetVal, props.get(prop));
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/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 124bec6..92e1178 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
@@ -55,6 +55,12 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
}
+ /** {@inheritDoc} */
+ @Override protected boolean initializeDefaultPathModes() {
+ // Enable default modes in order to test various modes.
+ return true;
+ }
+
/**
* @throws Exception If failed.
*/
@@ -68,6 +74,13 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
for (IgfsPath p : paths)
assert igfs.exists(p);
+ assert igfs.modeResolver().resolveMode(gg) == mode;
+ assert igfs.modeResolver().resolveMode(new IgfsPath(gg, "sync")) == IgfsMode.DUAL_SYNC;
+ assert igfs.modeResolver().resolveMode(new IgfsPath(gg, "async")) == IgfsMode.DUAL_ASYNC;
+ assert igfs.modeResolver().resolveMode(new IgfsPath(gg, "primary")) == IgfsMode.PRIMARY;
+ assert !igfsSecondary.exists("/ignite/primary"); // PRIMARY mode path must exist in upper level fs only.
+
+ // All the child paths of "/ignite/" must be visible in listings:
assert igfs.listFiles(gg).size() == 3;
assert igfs.listPaths(gg).size() == 3;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/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 f3bb516..bd7e413 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
@@ -17,8 +17,11 @@
package org.apache.ignite.internal.processors.igfs;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import junit.framework.TestCase;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.igfs.IgfsMode;
@@ -38,8 +41,9 @@ public class IgfsModeResolverSelfTest extends TestCase {
/** {@inheritDoc} */
@Override protected void setUp() throws Exception {
- 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)));
+ reslvr = new IgfsModeResolver(DUAL_SYNC, new ArrayList<>(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))));
}
/**
@@ -90,7 +94,7 @@ public class IgfsModeResolverSelfTest extends TestCase {
try {
IgfsUtils.preparePathModes(DUAL_SYNC, Arrays.asList(
new T2<>(new IgfsPath("/a/"), PRIMARY),
- new T2<>(new IgfsPath("/a/b/"), DUAL_ASYNC)));
+ new T2<>(new IgfsPath("/a/b/"), DUAL_ASYNC)), new HashSet<IgfsPath>());
fail("IgniteCheckedException expected");
}
@@ -102,7 +106,8 @@ public class IgfsModeResolverSelfTest extends TestCase {
for (IgfsMode m: IgfsMode.values()) {
if (m != IgfsMode.PRIMARY) {
try {
- IgfsUtils.preparePathModes(PRIMARY, Arrays.asList(new T2<>(new IgfsPath("/a/"), DUAL_ASYNC)));
+ IgfsUtils.preparePathModes(PRIMARY, Arrays.asList(new T2<>(new IgfsPath("/a/"), DUAL_ASYNC)),
+ new HashSet<IgfsPath>());
fail("IgniteCheckedException expected");
}
@@ -117,7 +122,7 @@ public class IgfsModeResolverSelfTest extends TestCase {
new T2<>(new IgfsPath("/a"), PRIMARY),
new T2<>(new IgfsPath("/c/d/"), PRIMARY),
new T2<>(new IgfsPath("/c/d/e/f"), PRIMARY)
- ));
+ ), new HashSet<IgfsPath>());
assertNotNull(modes);
assertEquals(2, modes.size());
assertEquals(modes, Arrays.asList(
@@ -130,7 +135,7 @@ public class IgfsModeResolverSelfTest extends TestCase {
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)
- ));
+ ), new HashSet<IgfsPath>());
assertNotNull(modes);
assertEquals(modes.size(), 3);
assertEquals(modes, Arrays.asList(
@@ -139,4 +144,38 @@ public class IgfsModeResolverSelfTest extends TestCase {
new T2<>(new IgfsPath("/a/b"), DUAL_ASYNC)
));
}
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDualParentsWithPrimaryChild() throws Exception {
+ Set<IgfsPath> set = new HashSet<>();
+
+ IgfsUtils.preparePathModes(DUAL_SYNC, Arrays.asList(
+ new T2<>(new IgfsPath("/a/b"), DUAL_ASYNC),
+ new T2<>(new IgfsPath("/a/b/c"), PRIMARY),
+ new T2<>(new IgfsPath("/a/b/x/y"), PRIMARY),
+ new T2<>(new IgfsPath("/a/b/x/z"), PRIMARY),
+ new T2<>(new IgfsPath("/m"), PRIMARY)
+ ), set);
+ assertEquals(set, new HashSet<IgfsPath>() {{
+ add(new IgfsPath("/a/b"));
+ add(new IgfsPath("/a/b/x"));
+ add(new IgfsPath("/"));
+ }});
+
+ set = new HashSet<>();
+
+ IgfsUtils.preparePathModes(DUAL_ASYNC, Arrays.asList(
+ new T2<>(new IgfsPath("/a/b/x/y/z"), PRIMARY),
+ new T2<>(new IgfsPath("/a/b/c"), PRIMARY),
+ new T2<>(new IgfsPath("/a/k"), PRIMARY),
+ new T2<>(new IgfsPath("/a/z"), PRIMARY)
+ ), set);
+ assertEquals(set, new HashSet<IgfsPath>() {{
+ add(new IgfsPath("/a/b"));
+ add(new IgfsPath("/a"));
+ add(new IgfsPath("/a/b/x/y"));
+ }});
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
index 83991aa..a06129e 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
@@ -309,7 +309,12 @@ public class IgniteHadoopFileSystem extends FileSystem {
else
clientLog = IgfsLogger.disabledLogger();
- modeRslvr = new IgfsModeResolver(paths.defaultMode(), paths.pathModes());
+ try {
+ modeRslvr = new IgfsModeResolver(paths.defaultMode(), paths.pathModes());
+ }
+ catch (IgniteCheckedException ice) {
+ throw new IOException(ice);
+ }
boolean initSecondary = paths.defaultMode() == PROXY;
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/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 cc02d05..bd8ed2d 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
@@ -318,7 +318,12 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
else
clientLog = IgfsLogger.disabledLogger();
- modeRslvr = new IgfsModeResolver(paths.defaultMode(), paths.pathModes());
+ try {
+ modeRslvr = new IgfsModeResolver(paths.defaultMode(), paths.pathModes());
+ }
+ catch (IgniteCheckedException ice) {
+ throw new IOException(ice);
+ }
boolean initSecondary = paths.defaultMode() == PROXY;
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
index 083ee54..f793ec3 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
@@ -48,7 +48,6 @@ import org.apache.ignite.internal.util.GridConcurrentHashSet;
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.X;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
http://git-wip-us.apache.org/repos/asf/ignite/blob/dc81069b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopAbstractMapReduceTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopAbstractMapReduceTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopAbstractMapReduceTest.java
index ef886e4..3731213 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopAbstractMapReduceTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopAbstractMapReduceTest.java
@@ -41,6 +41,7 @@ import org.apache.ignite.configuration.HadoopConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.hadoop.fs.IgniteHadoopFileSystemCounterWriter;
import org.apache.ignite.hadoop.fs.IgniteHadoopIgfsSecondaryFileSystem;
+import org.apache.ignite.igfs.IgfsFile;
import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
import org.apache.ignite.igfs.IgfsIpcEndpointConfiguration;
import org.apache.ignite.igfs.IgfsMode;
@@ -123,8 +124,16 @@ public class HadoopAbstractMapReduceTest extends HadoopAbstractWordCountTest {
* @param p The path.
* @return The owner.
*/
- private static String getOwner(IgfsEx i, IgfsPath p) {
- return i.info(p).property(IgfsUtils.PROP_USER_NAME);
+ private static String getOwner(final IgfsEx i, final IgfsPath p) {
+ return IgfsUserContext.doAs(USER, new IgniteOutClosure<String>() {
+ @Override public String apply() {
+ IgfsFile f = i.info(p);
+
+ assert f != null;
+
+ return f.property(IgfsUtils.PROP_USER_NAME);
+ }
+ });
}
/**
[17/28] ignite git commit: Merge branch 'ignite-1.6.5' into
ignite-1.7.2
Posted by ak...@apache.org.
Merge branch 'ignite-1.6.5' into ignite-1.7.2
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3029108a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3029108a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3029108a
Branch: refs/heads/master
Commit: 3029108a6f023e01882878496d4dec8586664d58
Parents: 1de9c0f 5cf3bea
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Aug 15 13:41:18 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 13:41:18 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/IgniteFileSystem.java | 27 +-
.../igfs/secondary/IgfsSecondaryFileSystem.java | 2 +-
.../local/LocalIgfsSecondaryFileSystem.java | 396 ++++++++
.../igfs/secondary/local/package-info.java | 22 +
.../ignite/igfs/secondary/package-info.java | 2 +-
.../internal/processors/igfs/IgfsFileImpl.java | 20 +-
.../processors/igfs/IgfsMetaManager.java | 2 +-
.../internal/processors/igfs/IgfsUtils.java | 53 +
.../local/LocalFileSystemIgfsFile.java | 134 +++
...fsSecondaryFileSystemPositionedReadable.java | 65 ++
...faultIgfsSecondaryFileSystemTestAdapter.java | 117 +++
.../processors/igfs/IgfsAbstractSelfTest.java | 995 +++++++++++--------
.../igfs/IgfsDualAbstractSelfTest.java | 198 ++--
.../igfs/IgfsExUniversalFileSystemAdapter.java | 116 ---
...SecondaryFileSystemDualAbstractSelfTest.java | 76 ++
...ondaryFileSystemDualAsyncClientSelfTest.java | 28 +
...calSecondaryFileSystemDualAsyncSelfTest.java | 32 +
...condaryFileSystemDualSyncClientSelfTest.java | 28 +
...ocalSecondaryFileSystemDualSyncSelfTest.java | 32 +
...IgfsLocalSecondaryFileSystemTestAdapter.java | 141 +++
.../IgfsSecondaryFileSystemTestAdapter.java | 118 +++
.../igfs/UniversalFileSystemAdapter.java | 109 --
.../ignite/testsuites/IgniteIgfsTestSuite.java | 9 +
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 2 +-
.../ignite/igfs/Hadoop1DualAbstractTest.java | 3 +-
...oopFileSystemUniversalFileSystemAdapter.java | 139 ---
...adoopIgfsSecondaryFileSystemTestAdapter.java | 149 +++
27 files changed, 2066 insertions(+), 949 deletions(-)
----------------------------------------------------------------------
[16/28] ignite git commit: IGNITE-1926: IGFS: Implemented local
secondary file system.
Posted by ak...@apache.org.
IGNITE-1926: IGFS: Implemented local secondary file system.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5cf3bea3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5cf3bea3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5cf3bea3
Branch: refs/heads/master
Commit: 5cf3bea32a25ccc78641f083aa7f1ac81b4187ba
Parents: f5a040a
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Aug 15 13:40:41 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 13:40:41 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/IgniteFileSystem.java | 27 +-
.../igfs/secondary/IgfsSecondaryFileSystem.java | 2 +-
.../local/LocalIgfsSecondaryFileSystem.java | 396 ++++++++
.../igfs/secondary/local/package-info.java | 22 +
.../ignite/igfs/secondary/package-info.java | 2 +-
.../internal/processors/igfs/IgfsFileImpl.java | 20 +-
.../processors/igfs/IgfsMetaManager.java | 2 +-
.../internal/processors/igfs/IgfsUtils.java | 53 +
.../local/LocalFileSystemIgfsFile.java | 134 +++
...fsSecondaryFileSystemPositionedReadable.java | 65 ++
...faultIgfsSecondaryFileSystemTestAdapter.java | 117 +++
.../processors/igfs/IgfsAbstractSelfTest.java | 995 +++++++++++--------
.../igfs/IgfsDualAbstractSelfTest.java | 198 ++--
.../igfs/IgfsExUniversalFileSystemAdapter.java | 116 ---
...SecondaryFileSystemDualAbstractSelfTest.java | 76 ++
...ondaryFileSystemDualAsyncClientSelfTest.java | 28 +
...calSecondaryFileSystemDualAsyncSelfTest.java | 32 +
...condaryFileSystemDualSyncClientSelfTest.java | 28 +
...ocalSecondaryFileSystemDualSyncSelfTest.java | 32 +
...IgfsLocalSecondaryFileSystemTestAdapter.java | 141 +++
.../IgfsSecondaryFileSystemTestAdapter.java | 118 +++
.../igfs/UniversalFileSystemAdapter.java | 109 --
.../ignite/testsuites/IgniteIgfsTestSuite.java | 9 +
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 2 +-
.../ignite/igfs/Hadoop1DualAbstractTest.java | 3 +-
...oopFileSystemUniversalFileSystemAdapter.java | 139 ---
...adoopIgfsSecondaryFileSystemTestAdapter.java | 149 +++
27 files changed, 2066 insertions(+), 949 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
index f9aeb8d..8fb4fcd 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
@@ -34,6 +34,7 @@ import org.apache.ignite.lang.IgniteAsyncSupport;
import org.apache.ignite.lang.IgniteAsyncSupported;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
+import org.apache.ignite.igfs.IgfsPathNotFoundException;
/**
* <b>IG</b>nite <b>F</b>ile <b>S</b>ystem API. It provides a typical file system "view" on a particular cache:
@@ -90,7 +91,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
*
* @param path Path to get information for.
* @return Summary object.
- * @throws org.apache.ignite.igfs.IgfsPathNotFoundException If path is not found.
+ * @throws IgfsPathNotFoundException If path is not found.
* @throws IgniteException If failed.
*/
public IgfsPathSummary summary(IgfsPath path) throws IgniteException;
@@ -101,7 +102,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* @param path File path to read.
* @return File input stream to read data from.
* @throws IgniteException In case of error.
- * @throws org.apache.ignite.igfs.IgfsPathNotFoundException If path doesn't exist.
+ * @throws IgfsPathNotFoundException If path doesn't exist.
*/
public IgfsInputStream open(IgfsPath path) throws IgniteException;
@@ -112,7 +113,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* @param bufSize Read buffer size (bytes) or {@code zero} to use default value.
* @return File input stream to read data from.
* @throws IgniteException In case of error.
- * @throws org.apache.ignite.igfs.IgfsPathNotFoundException If path doesn't exist.
+ * @throws IgfsPathNotFoundException If path doesn't exist.
*/
public IgfsInputStream open(IgfsPath path, int bufSize) throws IgniteException;
@@ -124,7 +125,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* @param seqReadsBeforePrefetch Amount of sequential reads before prefetch is started.
* @return File input stream to read data from.
* @throws IgniteException In case of error.
- * @throws org.apache.ignite.igfs.IgfsPathNotFoundException If path doesn't exist.
+ * @throws IgfsPathNotFoundException If path doesn't exist.
*/
public IgfsInputStream open(IgfsPath path, int bufSize, int seqReadsBeforePrefetch) throws IgniteException;
@@ -178,7 +179,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* @param create Create file if it doesn't exist yet.
* @return File output stream to append data to.
* @throws IgniteException In case of error.
- * @throws org.apache.ignite.igfs.IgfsPathNotFoundException If path doesn't exist and create flag is {@code false}.
+ * @throws IgfsPathNotFoundException If path doesn't exist and create flag is {@code false}.
*/
public IgfsOutputStream append(IgfsPath path, boolean create) throws IgniteException;
@@ -191,7 +192,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* @param props File properties to set only in case it file was just created.
* @return File output stream to append data to.
* @throws IgniteException In case of error.
- * @throws org.apache.ignite.igfs.IgfsPathNotFoundException If path doesn't exist and create flag is {@code false}.
+ * @throws IgfsPathNotFoundException If path doesn't exist and create flag is {@code false}.
*/
public IgfsOutputStream append(IgfsPath path, int bufSize, boolean create, @Nullable Map<String, String> props)
throws IgniteException;
@@ -204,7 +205,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* @param accessTime Optional last access time to set. Value {@code -1} does not update access time.
* @param modificationTime Optional last modification time to set. Value {@code -1} does not update
* modification time.
- * @throws org.apache.ignite.igfs.IgfsPathNotFoundException If target was not found.
+ * @throws IgfsPathNotFoundException If target was not found.
* @throws IgniteException If error occurred.
*/
public void setTimes(IgfsPath path, long accessTime, long modificationTime) throws IgniteException;
@@ -218,7 +219,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* @param len Size of data in the file to resolve affinity for.
* @return Affinity block locations.
* @throws IgniteException In case of error.
- * @throws org.apache.ignite.igfs.IgfsPathNotFoundException If path doesn't exist.
+ * @throws IgfsPathNotFoundException If path doesn't exist.
*/
public Collection<IgfsBlockLocation> affinity(IgfsPath path, long start, long len) throws IgniteException;
@@ -233,7 +234,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* @param maxLen Maximum length of a single returned block location length.
* @return Affinity block locations.
* @throws IgniteException In case of error.
- * @throws org.apache.ignite.igfs.IgfsPathNotFoundException If path doesn't exist.
+ * @throws IgfsPathNotFoundException If path doesn't exist.
*/
public Collection<IgfsBlockLocation> affinity(IgfsPath path, long start, long len, long maxLen)
throws IgniteException;
@@ -393,7 +394,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* @param dest Destination file path. If destination path is a directory, then source file will be placed
* into destination directory with original name.
* @throws IgniteException In case of error.
- * @throws org.apache.ignite.igfs.IgfsPathNotFoundException If source file doesn't exist.
+ * @throws IgfsPathNotFoundException If source file doesn't exist.
*/
public void rename(IgfsPath src, IgfsPath dest) throws IgniteException;
@@ -430,9 +431,9 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* Lists file paths under the specified path.
*
* @param path Path to list files under.
- * @return List of files under the specified path.
+ * @return List of paths under the specified path.
* @throws IgniteException In case of error.
- * @throws org.apache.ignite.igfs.IgfsPathNotFoundException If path doesn't exist.
+ * @throws IgfsPathNotFoundException If path doesn't exist.
*/
public Collection<IgfsPath> listPaths(IgfsPath path) throws IgniteException;
@@ -442,7 +443,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* @param path Path to list files under.
* @return List of files under the specified path.
* @throws IgniteException In case of error.
- * @throws org.apache.ignite.igfs.IgfsPathNotFoundException If path doesn't exist.
+ * @throws IgfsPathNotFoundException If path doesn't exist.
*/
public Collection<IgfsFile> listFiles(IgfsPath path) throws IgniteException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
index 4d9d255..47a0dbd 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
@@ -110,7 +110,7 @@ public interface IgfsSecondaryFileSystem {
* Lists file paths under the specified path.
*
* @param path Path to list files under.
- * @return List of files under the specified path.
+ * @return List of paths under the specified path.
* @throws IgniteException In case of error.
* @throws org.apache.ignite.igfs.IgfsPathNotFoundException If path doesn't exist.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java
new file mode 100644
index 0000000..3d3a350
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java
@@ -0,0 +1,396 @@
+/*
+ * 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.secondary.local;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.igfs.IgfsException;
+import org.apache.ignite.igfs.IgfsFile;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.igfs.IgfsPathAlreadyExistsException;
+import org.apache.ignite.igfs.IgfsPathIsNotDirectoryException;
+import org.apache.ignite.igfs.IgfsPathNotFoundException;
+import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
+import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadable;
+import org.apache.ignite.internal.processors.igfs.secondary.local.LocalFileSystemIgfsFile;
+import org.apache.ignite.internal.processors.igfs.secondary.local.LocalIgfsSecondaryFileSystemPositionedReadable;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lifecycle.LifecycleAware;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Secondary file system which delegates to local file system.
+ */
+public class LocalIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem, LifecycleAware {
+ /** Default buffer size. */
+ private static final int DFLT_BUF_SIZE = 8 * 1024;
+
+ /** Path that will be added to each passed path. */
+ private String workDir;
+
+ /**
+ * Heuristically checks if exception was caused by invalid HDFS version and returns appropriate exception.
+ *
+ * @param e Exception to check.
+ * @param msg Detailed error message.
+ * @return Appropriate exception.
+ */
+ private IgfsException handleSecondaryFsError(IOException e, String msg) {
+ if (e instanceof FileNotFoundException)
+ return new IgfsPathNotFoundException(e);
+ else
+ return new IgfsException(msg, e);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean exists(IgfsPath path) {
+ return fileForPath(path).exists();
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public IgfsFile update(IgfsPath path, Map<String, String> props) {
+ throw new UnsupportedOperationException("Update operation is not yet supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void rename(IgfsPath src, IgfsPath dest) {
+ File srcFile = fileForPath(src);
+ File destFile = fileForPath(dest);
+
+ if (!srcFile.exists())
+ throw new IgfsPathNotFoundException("Failed to perform rename because source path not found: " + src);
+
+ if (srcFile.isDirectory() && destFile.isFile())
+ throw new IgfsPathIsNotDirectoryException("Failed to perform rename because destination path is " +
+ "directory and source path is file [src=" + src + ", dest=" + dest + ']');
+
+ try {
+ if (destFile.isDirectory())
+ Files.move(srcFile.toPath(), destFile.toPath().resolve(srcFile.getName()));
+ else if(!srcFile.renameTo(destFile))
+ throw new IgfsException("Failed to perform rename (underlying file system returned false) " +
+ "[src=" + src + ", dest=" + dest + ']');
+ }
+ catch (IOException e) {
+ throw handleSecondaryFsError(e, "Failed to rename [src=" + src + ", dest=" + dest + ']');
+ }
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("ConstantConditions")
+ @Override public boolean delete(IgfsPath path, boolean recursive) {
+ File f = fileForPath(path);
+
+ if (!recursive || !f.isDirectory())
+ return f.delete();
+ else
+ return deleteDirectory(f);
+ }
+
+ /**
+ * Delete directory recursively.
+ *
+ * @param dir Directory.
+ * @return {@code true} if successful.
+ */
+ private boolean deleteDirectory(File dir) {
+ File[] entries = dir.listFiles();
+
+ if (entries != null) {
+ for (File entry : entries) {
+ if (entry.isDirectory())
+ deleteDirectory(entry);
+ else if (entry.isFile()) {
+ if (!entry.delete())
+ return false;
+ }
+ else
+ throw new UnsupportedOperationException("Symlink deletion is not yet supported: " + entry);
+ }
+ }
+
+ return dir.delete();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void mkdirs(IgfsPath path) {
+ if (!mkdirs0(fileForPath(path)))
+ throw new IgniteException("Failed to make directories (underlying file system returned false): " + path);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void mkdirs(IgfsPath path, @Nullable Map<String, String> props) {
+ mkdirs(path);
+ }
+
+ /**
+ * Create directories.
+ *
+ * @param dir Directory.
+ * @return Result.
+ */
+ private boolean mkdirs0(@Nullable File dir) {
+ if (dir == null)
+ return true; // Nothing to create.
+
+ if (dir.exists())
+ // Already exists, so no-op.
+ return dir.isDirectory();
+ else {
+ File parentDir = dir.getParentFile();
+
+ if (!mkdirs0(parentDir)) // Create parent first.
+ return false;
+
+ boolean res = dir.mkdir();
+
+ if (!res)
+ res = dir.exists(); // Tolerate concurrent creation.
+
+ return res;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<IgfsPath> listPaths(IgfsPath path) {
+ File[] entries = listFiles0(path);
+
+ if (F.isEmpty(entries))
+ return Collections.emptySet();
+ else {
+ Collection<IgfsPath> res = U.newHashSet(entries.length);
+
+ for (File entry : entries)
+ res.add(igfsPath(entry));
+
+ return res;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<IgfsFile> listFiles(IgfsPath path) {
+ File[] entries = listFiles0(path);
+
+ if (F.isEmpty(entries))
+ return Collections.emptySet();
+ else {
+ Collection<IgfsFile> res = U.newHashSet(entries.length);
+
+ for (File entry : entries) {
+ IgfsFile info = info(igfsPath(entry));
+
+ if (info != null)
+ res.add(info);
+ }
+
+ return res;
+ }
+ }
+
+ /**
+ * Returns an array of File object. Under the specific path.
+ *
+ * @param path IGFS path.
+ * @return Array of File objects.
+ */
+ @Nullable private File[] listFiles0(IgfsPath path) {
+ File f = fileForPath(path);
+
+ if (!f.exists())
+ throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
+ else
+ return f.listFiles();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsSecondaryFileSystemPositionedReadable open(IgfsPath path, int bufSize) {
+ try {
+ FileInputStream in = new FileInputStream(fileForPath(path));
+
+ return new LocalIgfsSecondaryFileSystemPositionedReadable(in, bufSize);
+ }
+ catch (IOException e) {
+ throw handleSecondaryFsError(e, "Failed to open file for read: " + path);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public OutputStream create(IgfsPath path, boolean overwrite) {
+ return create0(path, overwrite, DFLT_BUF_SIZE);
+ }
+
+ /** {@inheritDoc} */
+ @Override public OutputStream create(IgfsPath path, int bufSize, boolean overwrite, int replication,
+ long blockSize, @Nullable Map<String, String> props) {
+ return create0(path, overwrite, bufSize);
+ }
+
+ /** {@inheritDoc} */
+ @Override public OutputStream append(IgfsPath path, int bufSize, boolean create,
+ @Nullable Map<String, String> props) {
+ try {
+ File file = fileForPath(path);
+
+ boolean exists = file.exists();
+
+ if (exists)
+ return new BufferedOutputStream(new FileOutputStream(file, true), bufSize);
+ else {
+ if (create)
+ return create0(path, false, bufSize);
+ else
+ throw new IgfsPathNotFoundException("Failed to append to file because it doesn't exist: " + path);
+ }
+ }
+ catch (IOException e) {
+ throw handleSecondaryFsError(e, "Failed to append to file because it doesn't exist: " + path);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsFile info(final IgfsPath path) {
+ File f = fileForPath(path);
+
+ if (!f.exists())
+ return null;
+
+ boolean isDir = f.isDirectory();
+
+ if (isDir)
+ return new LocalFileSystemIgfsFile(path, false, true, 0, f.lastModified(), 0, null);
+ else
+ return new LocalFileSystemIgfsFile(path, f.isFile(), false, 0, f.lastModified(), f.length(), null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public long usedSpaceSize() {
+ throw new UnsupportedOperationException("usedSpaceSize operation is not yet supported.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void start() throws IgniteException {
+ if (workDir != null)
+ workDir = new File(workDir).getAbsolutePath();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop() throws IgniteException {
+ // No-op.
+ }
+
+ /**
+ * Get work directory.
+ *
+ * @return Work directory.
+ */
+ @Nullable public String getWorkDirectory() {
+ return workDir;
+ }
+
+ /**
+ * Set work directory.
+ *
+ * @param workDir Work directory.
+ */
+ public void setWorkDirectory(@Nullable String workDir) {
+ this.workDir = workDir;
+ }
+
+ /**
+ * Create file for IGFS path.
+ *
+ * @param path IGFS path.
+ * @return File object.
+ */
+ private File fileForPath(IgfsPath path) {
+ if (workDir == null)
+ return new File(path.toString());
+ else {
+ if ("/".equals(path.toString()))
+ return new File(workDir);
+ else
+ return new File(workDir, path.toString());
+ }
+ }
+
+ /**
+ * Create IGFS path for file.
+ *
+ * @param f File object.
+ * @return IFGS path.
+ * @throws IgfsException If failed.
+ */
+ private IgfsPath igfsPath(File f) throws IgfsException {
+ String path = f.getAbsolutePath();
+
+ if (workDir != null) {
+ if (!path.startsWith(workDir))
+ throw new IgfsException("Path is not located in the work directory [workDir=" + workDir +
+ ", path=" + path + ']');
+
+ path = path.substring(workDir.length(), path.length());
+ }
+
+ return new IgfsPath(path);
+ }
+
+ /**
+ * Internal create routine.
+ *
+ * @param path Path.
+ * @param overwrite Overwirte flag.
+ * @param bufSize Buffer size.
+ * @return Output stream.
+ */
+ private OutputStream create0(IgfsPath path, boolean overwrite, int bufSize) {
+ File file = fileForPath(path);
+
+ boolean exists = file.exists();
+
+ if (exists) {
+ if (!overwrite)
+ throw new IgfsPathAlreadyExistsException("Failed to create a file because it already exists: " + path);
+ }
+ else {
+ File parent = file.getParentFile();
+
+ if (!mkdirs0(parent))
+ throw new IgfsException("Failed to create parent directory for file (underlying file system " +
+ "returned false): " + path);
+ }
+
+ try {
+ return new BufferedOutputStream(new FileOutputStream(file), bufSize);
+ }
+ catch (IOException e) {
+ throw handleSecondaryFsError(e, "Failed to create file [path=" + path + ", overwrite=" + overwrite + ']');
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/package-info.java b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/package-info.java
new file mode 100644
index 0000000..80bdce2
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains APIs for IGFS secondary file system.
+ */
+package org.apache.ignite.igfs.secondary.local;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/main/java/org/apache/ignite/igfs/secondary/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/package-info.java b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/package-info.java
index 4914c47..471651f 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/package-info.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/package-info.java
@@ -17,6 +17,6 @@
/**
* <!-- Package description. -->
- * Contains APIs for IGFS secondary file system.
+ * Contains APIs for IGFS secondary file system base on local file system.
*/
package org.apache.ignite.igfs.secondary;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
index 9f79f42..984c8f5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
@@ -66,6 +66,9 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable, Binarylizab
/** Last modification time. */
private long modificationTime;
+ /** Flags. */
+ private byte flags;
+
/** Properties. */
private Map<String, String> props;
@@ -81,6 +84,7 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable, Binarylizab
* which is specified separately.
*
* @param igfsFile The file to copy.
+ * @param grpBlockSize Group block size.
*/
public IgfsFileImpl(IgfsFile igfsFile, long grpBlockSize) {
A.notNull(igfsFile, "igfsFile");
@@ -97,25 +101,29 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable, Binarylizab
this.accessTime = igfsFile.accessTime();
this.modificationTime = igfsFile.modificationTime();
+ this.flags = IgfsUtils.flags(igfsFile.isDirectory(), igfsFile.isFile());
}
/**
* Constructs directory info.
*
* @param path Path.
+ * @param info Entry info.
+ * @param globalGrpBlockSize Global group block size.
*/
public IgfsFileImpl(IgfsPath path, IgfsEntryInfo info, long globalGrpBlockSize) {
A.notNull(path, "path");
A.notNull(info, "info");
this.path = path;
+
fileId = info.id();
+ flags = IgfsUtils.flags(info.isDirectory(), info.isFile());
+
if (info.isFile()) {
blockSize = info.blockSize();
- assert blockSize > 0; // By contract file must have blockSize > 0, while directory's blockSize == 0.
-
len = info.length();
grpBlockSize = info.affinityKey() == null ? globalGrpBlockSize :
@@ -145,12 +153,12 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable, Binarylizab
/** {@inheritDoc} */
@Override public boolean isFile() {
- return blockSize > 0;
+ return IgfsUtils.isFile(flags);
}
/** {@inheritDoc} */
@Override public boolean isDirectory() {
- return blockSize == 0;
+ return IgfsUtils.isDirectory(flags);
}
/** {@inheritDoc} */
@@ -214,6 +222,7 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable, Binarylizab
U.writeStringMap(out, props);
out.writeLong(accessTime);
out.writeLong(modificationTime);
+ out.writeByte(flags);
}
/**
@@ -232,6 +241,7 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable, Binarylizab
props = U.readStringMap(in);
accessTime = in.readLong();
modificationTime = in.readLong();
+ flags = in.readByte();
}
/** {@inheritDoc} */
@@ -245,6 +255,7 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable, Binarylizab
IgfsUtils.writeProperties(rawWriter, props);
rawWriter.writeLong(accessTime);
rawWriter.writeLong(modificationTime);
+ rawWriter.writeByte(flags);
}
/** {@inheritDoc} */
@@ -258,6 +269,7 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable, Binarylizab
props = IgfsUtils.readProperties(rawReader);
accessTime = rawReader.readLong();
modificationTime = rawReader.readLong();
+ flags = rawReader.readByte();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/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 1364491..89cadce 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
@@ -1919,7 +1919,7 @@ public class IgfsMetaManager extends IgfsManager {
IgfsEntryInfo newInfo = IgfsUtils.createFile(
IgniteUuid.randomUuid(),
- status.blockSize(),
+ igfsCtx.configuration().getBlockSize(),
status.length(),
affKey,
createFileLockId(false),
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/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 a79d965..2e79a98 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
@@ -120,6 +120,12 @@ public class IgfsUtils {
/** Separator between id and name parts in the trash name. */
private static final char TRASH_NAME_SEPARATOR = '|';
+ /** Flag: this is a directory. */
+ private static final byte FLAG_DIR = 0x1;
+
+ /** Flag: this is a file. */
+ private static final byte FLAG_FILE = 0x2;
+
/**
* Static initializer.
*/
@@ -907,4 +913,51 @@ public class IgfsUtils {
return resModes;
}
+
+ /**
+ * Create flags value.
+ *
+ * @param isDir Directory flag.
+ * @param isFile File flag.
+ * @return Result.
+ */
+ public static byte flags(boolean isDir, boolean isFile) {
+ byte res = isDir ? FLAG_DIR : 0;
+
+ if (isFile)
+ res |= FLAG_FILE;
+
+ return res;
+ }
+
+ /**
+ * Check whether passed flags represent directory.
+ *
+ * @param flags Flags.
+ * @return {@code True} if this is directory.
+ */
+ public static boolean isDirectory(byte flags) {
+ return hasFlag(flags, FLAG_DIR);
+ }
+
+ /**
+ * Check whether passed flags represent file.
+ *
+ * @param flags Flags.
+ * @return {@code True} if this is file.
+ */
+ public static boolean isFile(byte flags) {
+ return hasFlag(flags, FLAG_FILE);
+ }
+
+ /**
+ * Check whether certain flag is set.
+ *
+ * @param flags Flags.
+ * @param flag Flag to check.
+ * @return {@code True} if flag is set.
+ */
+ private static boolean hasFlag(byte flags, byte flag) {
+ return (flags & flag) == flag;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemIgfsFile.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemIgfsFile.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemIgfsFile.java
new file mode 100644
index 0000000..5abe4eb
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemIgfsFile.java
@@ -0,0 +1,134 @@
+/*
+ * 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.secondary.local;
+
+import org.apache.ignite.igfs.IgfsFile;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Implementation of the IgfsFile interface for the local filesystem.
+ */
+public class LocalFileSystemIgfsFile implements IgfsFile {
+ /** Path. */
+ private final IgfsPath path;
+
+ /** Flags. */
+ private final byte flags;
+
+ /** Block size. */
+ private final int blockSize;
+
+ /** Modification time. */
+ private final long modTime;
+
+ /** Length. */
+ private final long len;
+
+ /** Properties. */
+ private final Map<String, String> props;
+
+ /**
+ * @param path IGFS path.
+ * @param isFile Path is a file.
+ * @param isDir Path is a directory.
+ * @param blockSize Block size in bytes.
+ * @param modTime Modification time in millis.
+ * @param len File length in bytes.
+ * @param props Properties.
+ */
+ public LocalFileSystemIgfsFile(IgfsPath path, boolean isFile, boolean isDir, int blockSize,
+ long modTime, long len, Map<String, String> props) {
+
+ assert !isDir || blockSize == 0 : "blockSize must be 0 for dirs. [blockSize=" + blockSize + ']';
+ assert !isDir || len == 0 : "length must be 0 for dirs. [length=" + len + ']';
+
+ this.path = path;
+ this.flags = IgfsUtils.flags(isDir, isFile);
+ this.blockSize = blockSize;
+ this.modTime = modTime;
+ this.len = len;
+ this.props = props;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsPath path() {
+ return path;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isFile() {
+ return IgfsUtils.isFile(flags);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isDirectory() {
+ return IgfsUtils.isDirectory(flags);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int blockSize() {
+ return blockSize;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long groupBlockSize() {
+ return blockSize();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long accessTime() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long modificationTime() {
+ return modTime;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String property(String name) throws IllegalArgumentException {
+ return property(name, null);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public String property(String name, @Nullable String dfltVal) {
+ if (props != null) {
+ String res = props.get(name);
+
+ if (res != null)
+ return res;
+ }
+
+ return dfltVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<String, String> properties() {
+ return props != null ? props : Collections.<String, String>emptyMap();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long length() {
+ return len;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalIgfsSecondaryFileSystemPositionedReadable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalIgfsSecondaryFileSystemPositionedReadable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalIgfsSecondaryFileSystemPositionedReadable.java
new file mode 100644
index 0000000..ebf56ad
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalIgfsSecondaryFileSystemPositionedReadable.java
@@ -0,0 +1,65 @@
+/*
+ * 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.secondary.local;
+
+import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadable;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+/**
+ * Positioned readable interface for local secondary file system.
+ */
+public class LocalIgfsSecondaryFileSystemPositionedReadable extends BufferedInputStream
+ implements IgfsSecondaryFileSystemPositionedReadable {
+ /** Last read position. */
+ private long lastReadPos;
+
+ /**
+ * Constructor.
+ *
+ * @param in Input stream.
+ * @param bufSize Buffer size.
+ */
+ public LocalIgfsSecondaryFileSystemPositionedReadable(FileInputStream in, int bufSize) {
+ super(in, bufSize);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int read(long readPos, byte[] buf, int off, int len) throws IOException {
+ if (in == null)
+ throw new IOException("Stream is closed.");
+
+ if (readPos < lastReadPos || readPos + len > lastReadPos + this.buf.length) {
+ ((FileInputStream)in).getChannel().position(readPos);
+
+ pos = 0;
+ count = 0;
+ }
+
+ int bytesRead = read(buf, off, len);
+
+ if (bytesRead != -1) {
+ // Advance last read position only if we really read some bytes from the stream.
+ lastReadPos = readPos + bytesRead;
+ }
+
+ return bytesRead;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/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
[21/28] ignite git commit: IGNITE-3694
IgfsLocalSecondaryFileSystemDualAsyncSelfTest.testAppendConsistencyMultithreaded
hangs
Posted by ak...@apache.org.
IGNITE-3694 IgfsLocalSecondaryFileSystemDualAsyncSelfTest.testAppendConsistencyMultithreaded hangs
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/97d1a6f6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/97d1a6f6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/97d1a6f6
Branch: refs/heads/master
Commit: 97d1a6f6f1d30507ad93122eb9ea63285cdffde7
Parents: 476081b
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Thu Aug 18 15:06:04 2016 +0300
Committer: tledkov-gridgain <tl...@gridgain.com>
Committed: Thu Aug 18 17:59:25 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/processors/igfs/IgfsOutputStreamImpl.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/97d1a6f6/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
index f6b1104..bbff93b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
@@ -315,6 +315,11 @@ class IgfsOutputStreamImpl extends IgfsOutputStream {
", fileInfo=" + fileInfo + ']', e);
}
+ // Finish batch before file unlocking to support the assertion that unlocked file batch,
+ // if any, must be in finishing state (e.g. append see more IgfsImpl.newBatch)
+ if (batch != null)
+ batch.finish();
+
// Unlock the file after data is flushed.
try {
if (flushSuccess && space > 0)
@@ -332,8 +337,6 @@ class IgfsOutputStreamImpl extends IgfsOutputStream {
// Finally, await secondary file system flush.
if (batch != null) {
- batch.finish();
-
if (mode == DUAL_SYNC) {
try {
batch.await();
[19/28] ignite git commit: IGNITE-3692: IGFS: Test fixes.
Posted by ak...@apache.org.
IGNITE-3692: IGFS: Test fixes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/09a3922d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/09a3922d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/09a3922d
Branch: refs/heads/master
Commit: 09a3922d57f9a4c8fbe6c1056f3ea128869c250e
Parents: 278633e
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Aug 16 12:52:09 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Aug 16 12:52:09 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsAsyncImpl.java | 5 ++
.../ignite/internal/processors/igfs/IgfsEx.java | 7 ++
.../internal/processors/igfs/IgfsImpl.java | 8 +-
.../processors/igfs/IgfsAbstractSelfTest.java | 86 ++++++++++----------
.../igfs/IgfsBackupFailoverSelfTest.java | 2 +-
.../igfs/IgfsDualAbstractSelfTest.java | 86 +-------------------
.../internal/processors/igfs/IgfsMock.java | 5 ++
.../igfs/HadoopIgfsDualAbstractSelfTest.java | 2 +-
8 files changed, 66 insertions(+), 135 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a3922d/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
index bf3d22b..07b070e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
@@ -322,4 +322,9 @@ public class IgfsAsyncImpl extends AsyncSupportAdapter<IgniteFileSystem> impleme
@Override public IgfsSecondaryFileSystem asSecondary() {
return igfs.asSecondary();
}
+
+ /** {@inheritDoc} */
+ @Override public void await(IgfsPath... paths) {
+ igfs.await(paths);
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a3922d/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
index 4c64bc9..9760f43 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
@@ -142,4 +142,11 @@ public interface IgfsEx extends IgniteFileSystem {
* @return Secondary file system wrapper.
*/
public IgfsSecondaryFileSystem asSecondary();
+
+ /**
+ * Await for any pending finished writes on the children paths.
+ *
+ * @param paths Paths to check.
+ */
+ public void await(IgfsPath... paths);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a3922d/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 e1f8e61..6707acc 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
@@ -374,12 +374,8 @@ public final class IgfsImpl implements IgfsEx {
return busyLock.enterBusy();
}
- /**
- * Await for any pending finished writes on the children paths.
- *
- * @param paths Paths to check.
- */
- void await(IgfsPath... paths) {
+ /** {@inheritDoc} */
+ @Override public void await(IgfsPath... paths) {
assert paths != null;
for (Map.Entry<IgfsPath, IgfsFileWorkerBatch> workerEntry : workerMap.entrySet()) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a3922d/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 08cb929..236a589 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
@@ -489,7 +489,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testExists() throws Exception {
- create(igfs.asSecondary(), paths(DIR), null);
+ create(igfs, paths(DIR), null);
checkExist(igfs, igfsSecondary, DIR);
}
@@ -600,7 +600,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
IgfsPath file1 = new IgfsPath("/file1");
IgfsPath file2 = new IgfsPath("/file2");
- create(igfs.asSecondary(), null, paths(file1));
+ create(igfs, null, paths(file1));
igfs.rename(file1, file2);
@@ -632,7 +632,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
IgfsPath dir1 = new IgfsPath("/dir1");
IgfsPath dir2 = new IgfsPath("/dir2");
- create(igfs.asSecondary(), paths(dir1), null);
+ create(igfs, paths(dir1), null);
igfs.rename(dir1, dir2);
@@ -661,7 +661,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testMoveFileDestinationRoot() throws Exception {
- create(igfs.asSecondary(), paths(DIR, SUBDIR), paths(FILE));
+ create(igfs, paths(DIR, SUBDIR), paths(FILE));
igfs.rename(FILE, new IgfsPath());
@@ -753,7 +753,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testMoveDirectoryDestinationRoot() throws Exception {
- create(igfs.asSecondary(), paths(DIR, SUBDIR, SUBSUBDIR), null);
+ create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), null);
igfs.rename(SUBSUBDIR, new IgfsPath());
@@ -769,7 +769,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
public void testMoveDirectorySourceParentRoot() throws Exception {
IgfsPath dir = new IgfsPath("/" + SUBSUBDIR.name());
- create(igfs.asSecondary(), paths(DIR_NEW, SUBDIR_NEW, dir), null);
+ create(igfs, paths(DIR_NEW, SUBDIR_NEW, dir), null);
igfs.rename(dir, SUBDIR_NEW);
@@ -1163,7 +1163,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
public void testOpen() throws Exception {
create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, true, chunk);
+ createFile(igfs, FILE, true, chunk);
checkFileContent(igfs, FILE, chunk);
@@ -1200,7 +1200,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testSetTimes() throws Exception {
- createFile(igfs.asSecondary(), FILE, true, chunk);
+ createFile(igfs, FILE, true, chunk);
checkExist(igfs, igfsSecondary, DIR);
checkExist(igfs, igfsSecondary, SUBDIR);
@@ -1312,7 +1312,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
public void testCreate() throws Exception {
create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, true, chunk);
+ createFile(igfs, FILE, true, chunk);
checkFile(igfs, igfsSecondary, FILE, chunk);
@@ -1396,7 +1396,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
public void testCreateParentRoot() throws Exception {
IgfsPath file = new IgfsPath("/" + FILE.name());
- createFile(igfs.asSecondary(), file, true, chunk);
+ createFile(igfs, file, true, chunk);
checkFile(igfs, igfsSecondary, file, chunk);
}
@@ -1681,7 +1681,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
assert igfs.exists(path);
}
- awaitFileClose(igfs.asSecondary(), path);
+ awaitFileClose(igfs, path);
checkFileContent(igfs, path, chunk);
}
@@ -1806,7 +1806,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
} finally {
U.closeQuiet(os);
- awaitFileClose(igfs.asSecondary(), path2);
+ awaitFileClose(igfs, path2);
}
try {
@@ -1816,7 +1816,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
} finally {
U.closeQuiet(os);
- awaitFileClose(igfs.asSecondary(), path2);
+ awaitFileClose(igfs, path2);
}
checkFile(igfs, igfsSecondary, path2, chunk, chunk);
@@ -1944,7 +1944,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
if (appendSupported()) {
create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, false);
+ createFile(igfs, FILE, false);
GridTestUtils.assertThrowsInherited(log(), new Callable<Object>() {
@Override
@@ -1978,7 +1978,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
if (appendSupported()) {
create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, false);
+ createFile(igfs, FILE, false);
IgfsOutputStream os = null;
@@ -2004,9 +2004,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
return;
if (appendSupported()) {
- create(igfs.asSecondary(), paths(DIR, SUBDIR), null);
+ create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, false);
+ createFile(igfs, FILE, false);
IgfsOutputStream os = null;
@@ -2034,7 +2034,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
if (appendSupported()) {
create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, false);
+ createFile(igfs, FILE, false);
IgfsOutputStream os = null;
IgniteUuid id = null;
@@ -2089,7 +2089,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
if (appendSupported()) {
create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, false);
+ createFile(igfs, FILE, false);
IgfsOutputStream os = null;
IgniteUuid id = null;
@@ -2146,7 +2146,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
create(igfs, paths(DIR, SUBDIR), null);
- createFile(igfs.asSecondary(), FILE, false);
+ createFile(igfs, FILE, false);
IgfsOutputStream os = null;
@@ -2176,7 +2176,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
int threadCnt = 10;
for (int i = 0; i < threadCnt; i++)
- createFile(igfs.asSecondary(), new IgfsPath("/file" + i), false);
+ createFile(igfs, new IgfsPath("/file" + i), false);
multithreaded(new Runnable() {
@Override
@@ -2200,7 +2200,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
assert igfs.exists(path);
}
- awaitFileClose(igfs.asSecondary(), path);
+ awaitFileClose(igfs, path);
checkFileContent(igfs, path, chunks);
} catch (IOException | IgniteCheckedException e) {
@@ -2271,7 +2271,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
fut.get();
- awaitFileClose(igfs.asSecondary(), FILE);
+ awaitFileClose(igfs, FILE);
if (err.get() != null) {
X.println("Test failed: rethrowing first error: " + err.get());
@@ -2952,20 +2952,8 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param files Files.
* @throws Exception If failed.
*/
+ @SuppressWarnings("EmptyTryBlock")
public static void create(IgfsImpl igfs, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files) throws Exception {
- create(igfs.asSecondary(), dirs, files);
- }
-
- /**
- * Create the given directories and files in the given IGFS.
- *
- * @param igfs IGFS.
- * @param dirs Directories.
- * @param files Files.
- * @throws Exception If failed.
- */
- public static void create(IgfsSecondaryFileSystem igfs, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files)
- throws Exception {
if (dirs != null) {
for (IgfsPath dir : dirs)
igfs.mkdirs(dir);
@@ -2973,9 +2961,11 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
if (files != null) {
for (IgfsPath file : files) {
- OutputStream os = igfs.create(file, true);
+ try (OutputStream os = igfs.create(file, true)) {
+ // No-op.
+ }
- os.close();
+ igfs.await(file);
}
}
}
@@ -3013,8 +3003,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(IgfsEx igfs, IgfsPath file, boolean overwrite, @Nullable byte[]... chunks)
+ throws IOException {
OutputStream os = null;
try {
@@ -3051,7 +3041,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
IgfsEx igfsEx = uni.igfs();
if (igfsEx != null)
- awaitFileClose(igfsEx.asSecondary(), file);
+ awaitFileClose(igfsEx, file);
}
}
@@ -3077,7 +3067,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
finally {
U.closeQuiet(os);
- awaitFileClose(igfs.asSecondary(), file);
+ awaitFileClose(igfs, file);
}
}
@@ -3101,7 +3091,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
finally {
U.closeQuiet(os);
- awaitFileClose(igfs.asSecondary(), file);
+ awaitFileClose(igfs, file);
}
}
@@ -3135,6 +3125,16 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
}
/**
+ * Await for previously opened output stream to close.
+ *
+ * @param igfs IGFS.
+ * @param file File.
+ */
+ public static void awaitFileClose(@Nullable IgfsEx igfs, IgfsPath file) {
+ igfs.await(file);
+ }
+
+ /**
* Ensure that the given paths exist in the given IGFSs.
*
* @param igfs First IGFS.
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a3922d/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java
index 5be9c09..187aeeb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java
@@ -563,7 +563,7 @@ public class IgfsBackupFailoverSelfTest extends IgfsCommonAbstractTest {
U.closeQuiet(ios);
- awaitFileClose(igfs0.asSecondary(), filePath(fileIdx));
+ awaitFileClose(igfs0, filePath(fileIdx));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a3922d/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 b4ca0ca..02027d6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
@@ -17,10 +17,8 @@
package org.apache.ignite.internal.processors.igfs;
-import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
import org.apache.ignite.igfs.IgfsFile;
-import org.apache.ignite.igfs.IgfsInputStream;
import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
@@ -28,7 +26,6 @@ import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.U;
-import java.io.OutputStream;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
@@ -1164,85 +1161,6 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
}
/**
- * Ensure that prefetch occurs in case several blocks are read sequentially.
- *
- * @throws Exception If failed.
- */
- @SuppressWarnings("ResultOfMethodCallIgnored")
- public void testOpenPrefetch() throws Exception {
- create(igfsSecondary, paths(DIR, SUBDIR), paths(FILE));
-
- // Write enough data to the secondary file system.
- int blockSize0 = igfs.info(FILE).blockSize();
- final int blockSize = blockSize0 != 0 ? blockSize0 : 8 * 1024;
-
- int totalWritten = 0;
- try (OutputStream out = igfsSecondary.openOutputStream(FILE.toString(), false)) {
- while (totalWritten < blockSize * 2 + chunk.length) {
- out.write(chunk);
-
- totalWritten += chunk.length;
- }
- }
-
- if (propertiesSupported())
- awaitFileClose(igfsSecondaryFileSystem, FILE);
- else
- Thread.sleep(1000);
-
- // Read the first two blocks.
- int totalRead = 0;
-
- IgfsInputStream in = igfs.open(FILE, blockSize);
-
- final byte[] readBuf = new byte[1024];
-
- while (totalRead + readBuf.length <= blockSize * 2) {
- in.read(readBuf);
-
- totalRead += readBuf.length;
- }
-
- // Wait for a while for prefetch to finish.
- IgfsMetaManager meta = igfs.context().meta();
-
- IgfsEntryInfo info = meta.info(meta.fileId(FILE));
-
- assert info != null;
-
- IgfsBlockKey key = new IgfsBlockKey(info.id(), info.affinityKey(), info.evictExclude(), 2);
-
- IgniteCache<IgfsBlockKey, byte[]> dataCache = igfs.context().kernalContext().cache().jcache(
- igfs.configuration().getDataCacheName());
-
- for (int i = 0; i < 10; i++) {
- if (dataCache.containsKey(key))
- break;
- else
- U.sleep(100);
- }
-
- // Remove the file from the secondary file system.
- igfsSecondary.delete(FILE.toString(), false);
-
- // Let's wait for file will be deleted.
- U.sleep(300);
-
- // Read the third block.
- totalRead = 0;
-
- in.seek(blockSize * 2);
-
- while (totalRead + readBuf.length <= blockSize) {
- in.read(readBuf);
-
- totalRead += readBuf.length;
- }
-
- in.close();
- }
-
- /**
* Test create when parent directory is partially missing locally.
*
* @throws Exception If failed.
@@ -1251,7 +1169,7 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
create(igfsSecondary, paths(DIR, SUBDIR), null);
create(igfs, paths(DIR), null);
- createFile(igfs.asSecondary(), FILE, true, chunk);
+ createFile(igfs, FILE, true, chunk);
// Ensure that directory structure was created.
checkExist(igfs, igfsSecondary, SUBDIR);
@@ -1287,7 +1205,7 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
create(igfsSecondary, paths(DIR, SUBDIR), null);
create(igfs, null, null);
- createFile(igfs.asSecondary(), FILE, true, chunk);
+ createFile(igfs, FILE, true, chunk);
checkExist(igfs, igfsSecondary, SUBDIR);
checkFile(igfs, igfsSecondary, FILE, chunk);
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a3922d/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
index a2bd9ca..0138907 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
@@ -376,6 +376,11 @@ public class IgfsMock implements IgfsEx {
}
/** {@inheritDoc} */
+ @Override public void await(IgfsPath... paths) {
+ throwUnsupported();
+ }
+
+ /** {@inheritDoc} */
@Override public IgniteFileSystem withAsync() {
throwUnsupported();
http://git-wip-us.apache.org/repos/asf/ignite/blob/09a3922d/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
index 40cf493..bb155b4 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
@@ -252,7 +252,7 @@ public abstract class HadoopIgfsDualAbstractSelfTest extends IgfsCommonAbstractT
out.close();
- awaitFileClose(igfsSecondary.asSecondary(), FILE);
+ awaitFileClose(igfsSecondary, FILE);
// Instantiate file system with overridden "seq reads before prefetch" property.
Configuration cfg = new Configuration();
[23/28] ignite git commit: ignite-3547 Do not try to re-send message
using the same client. Remove disconnected client from 'onDisconnected'
callback.
Posted by ak...@apache.org.
ignite-3547 Do not try to re-send message using the same client. Remove disconnected client from 'onDisconnected' callback.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a20ca351
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a20ca351
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a20ca351
Branch: refs/heads/master
Commit: a20ca351b33efb07b83c6f5967fa7a3cef154c83
Parents: 8aa534a
Author: sboikov <sb...@gridgain.com>
Authored: Fri Aug 19 10:37:59 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Aug 19 10:37:59 2016 +0300
----------------------------------------------------------------------
.../util/nio/GridTcpNioCommunicationClient.java | 5 +-
.../communication/tcp/TcpCommunicationSpi.java | 49 +++--
.../CacheSerializableTransactionsTest.java | 5 +
.../IgniteCacheConnectionRecoveryTest.java | 205 +++++++++++++++++++
.../IgniteCacheMessageRecoveryAbstractTest.java | 14 +-
...gniteCacheMessageRecoveryIdleConnection.java | 154 --------------
...eCacheMessageRecoveryIdleConnectionTest.java | 157 ++++++++++++++
.../ignite/testsuites/IgniteCacheTestSuite.java | 6 +-
8 files changed, 407 insertions(+), 188 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a20ca351/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
index 4022bc5..5fe521d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
@@ -125,8 +125,11 @@ public class GridTcpNioCommunicationClient extends GridAbstractCommunicationClie
if (log.isDebugEnabled())
log.debug("Failed to send message [client=" + this + ", err=" + e + ']');
- if (e.getCause() instanceof IOException)
+ if (e.getCause() instanceof IOException) {
+ ses.close();
+
return true;
+ }
else
throw new IgniteCheckedException("Failed to send message [client=" + this + ']', e);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a20ca351/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 2c03b2d..d81b9f3 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -353,6 +353,15 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
UUID id = ses.meta(NODE_ID_META);
if (id != null) {
+ GridCommunicationClient client = clients.get(id);
+
+ if (client instanceof GridTcpNioCommunicationClient &&
+ ((GridTcpNioCommunicationClient) client).session() == ses) {
+ client.close();
+
+ clients.remove(id, client);
+ }
+
if (!stopping) {
boolean reconnect = false;
@@ -372,9 +381,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
recoveryData.onNodeLeft();
}
- DisconnectedSessionInfo disconnectData = new DisconnectedSessionInfo(id,
- ses,
- recoveryData,
+ DisconnectedSessionInfo disconnectData = new DisconnectedSessionInfo(recoveryData,
reconnect);
commWorker.addProcessDisconnectRequest(disconnectData);
@@ -1400,6 +1407,14 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
.append(']').append(U.nl());
}
+ sb.append("Communication SPI clients: ").append(U.nl());
+
+ for (Map.Entry<UUID, GridCommunicationClient> entry : clients.entrySet()) {
+ sb.append(" [node=").append(entry.getKey())
+ .append(", client=").append(entry.getValue())
+ .append(']').append(U.nl());
+ }
+
U.warn(log, sb.toString());
}
@@ -1978,17 +1993,19 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
client.release();
- client = null;
-
if (!retry)
sentMsgsCnt.increment();
else {
+ clients.remove(node.id(), client);
+
ClusterNode node0 = getSpiContext().node(node.id());
if (node0 == null)
throw new IgniteCheckedException("Failed to send message to remote node " +
"(node has left the grid): " + node.id());
}
+
+ client = null;
}
while (retry);
}
@@ -3187,12 +3204,6 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
* @param sesInfo Disconnected session information.
*/
private void processDisconnect(DisconnectedSessionInfo sesInfo) {
- GridCommunicationClient client = clients.get(sesInfo.nodeId);
-
- if (client instanceof GridTcpNioCommunicationClient &&
- ((GridTcpNioCommunicationClient) client).session() == sesInfo.ses)
- clients.remove(sesInfo.nodeId, client);
-
if (sesInfo.reconnect) {
GridNioRecoveryDescriptor recoveryDesc = sesInfo.recoveryDesc;
@@ -3205,7 +3216,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
if (log.isDebugEnabled())
log.debug("Recovery reconnect [rmtNode=" + recoveryDesc.node().id() + ']');
- client = reserveClient(node);
+ GridCommunicationClient client = reserveClient(node);
client.release();
}
@@ -3756,29 +3767,17 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
*/
private static class DisconnectedSessionInfo {
/** */
- private final UUID nodeId;
-
- /** */
- private final GridNioSession ses;
-
- /** */
private final GridNioRecoveryDescriptor recoveryDesc;
/** */
private final boolean reconnect;
/**
- * @param nodeId Node ID.
- * @param ses Session.
* @param recoveryDesc Recovery descriptor.
* @param reconnect Reconnect flag.
*/
- public DisconnectedSessionInfo(UUID nodeId,
- GridNioSession ses,
- @Nullable GridNioRecoveryDescriptor recoveryDesc,
+ DisconnectedSessionInfo(@Nullable GridNioRecoveryDescriptor recoveryDesc,
boolean reconnect) {
- this.nodeId = nodeId;
- this.ses = ses;
this.recoveryDesc = recoveryDesc;
this.reconnect = reconnect;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a20ca351/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
index 4baef66..3d4f850 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
@@ -3311,6 +3311,8 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
private void getRemoveTx(boolean nearCache, boolean store) throws Exception {
+ long stopTime = U.currentTimeMillis() + getTestTimeout() - 30_000;
+
final Ignite ignite0 = ignite(0);
CacheConfiguration<Integer, Integer> ccfg = cacheConfiguration(PARTITIONED, FULL_SYNC, 0, store, false);
@@ -3330,6 +3332,9 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
for (int i = 0; i < 100; i++) {
+ if (U.currentTimeMillis() > stopTime)
+ break;
+
final AtomicInteger cntr = new AtomicInteger();
final Integer key = i;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a20ca351/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
new file mode 100644
index 0000000..7195c37
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed;
+
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.IgnitionEx;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class IgniteCacheConnectionRecoveryTest extends GridCommonAbstractTest {
+ /** */
+ private static TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private boolean client;
+
+ /** */
+ private static final int SRVS = 5;
+
+ /** */
+ private static final int CLIENTS = 5;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
+ cfg.setClientMode(client);
+
+ cfg.setCacheConfiguration(
+ cacheConfiguration("cache1", TRANSACTIONAL),
+ cacheConfiguration("cache2", ATOMIC));
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGridsMultiThreaded(SRVS);
+
+ client = true;
+
+ startGridsMultiThreaded(SRVS, CLIENTS);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testConnectionRecovery() throws Exception {
+ final Map<Integer, Integer> data = new TreeMap<>();
+
+ for (int i = 0; i < 500; i++)
+ data.put(i, i);
+
+ final AtomicInteger idx = new AtomicInteger();
+
+ final long stopTime = U.currentTimeMillis() + 30_000;
+
+ final AtomicReference<CyclicBarrier> barrierRef = new AtomicReference<>();
+
+ final int TEST_THREADS = (CLIENTS + SRVS) * 2;
+
+ IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ int idx0 = idx.getAndIncrement();
+ Ignite node = ignite(idx0 % (SRVS + CLIENTS));
+
+ Thread.currentThread().setName("test-thread-" + idx0 + "-" + node.name());
+
+ IgniteCache cache1 = node.cache("cache1").withAsync();
+ IgniteCache cache2 = node.cache("cache2").withAsync();
+
+ int iter = 0;
+
+ while (U.currentTimeMillis() < stopTime) {
+ try {
+ cache1.putAll(data);
+ cache1.future().get(15, SECONDS);
+
+ cache2.putAll(data);
+ cache2.future().get(15, SECONDS);
+
+ CyclicBarrier b = barrierRef.get();
+
+ if (b != null)
+ b.await(15, SECONDS);
+ }
+ catch (Exception e) {
+ synchronized (IgniteCacheConnectionRecoveryTest.class) {
+ log.error("Failed to execute update, will dump debug information" +
+ " [err=" + e+ ", iter=" + iter + ']', e);
+
+ List<Ignite> nodes = IgnitionEx.allGridsx();
+
+ for (Ignite node0 : nodes)
+ ((IgniteKernal)node0).dumpDebugInfo();
+
+ U.dumpThreads(log);
+ }
+
+ throw e;
+ }
+ }
+
+ return null;
+ }
+ }, TEST_THREADS, "test-thread");
+
+ while (System.currentTimeMillis() < stopTime) {
+ boolean closed = false;
+
+ for (Ignite node : G.allGrids()) {
+ if (IgniteCacheMessageRecoveryAbstractTest.closeSessions(node))
+ closed = true;
+ }
+
+ if (closed) {
+ CyclicBarrier b = new CyclicBarrier(TEST_THREADS + 1, new Runnable() {
+ @Override public void run() {
+ barrierRef.set(null);
+ }
+ });
+
+ barrierRef.set(b);
+
+ b.await();
+ }
+
+ U.sleep(50);
+ }
+
+ fut.get();
+ }
+
+ /**
+ * @param name Cache name.
+ * @param atomicityMode Cache atomicity mode.
+ * @return Configuration.
+ */
+ private CacheConfiguration cacheConfiguration(String name, CacheAtomicityMode atomicityMode) {
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ ccfg.setName(name);
+ ccfg.setAtomicityMode(atomicityMode);
+ ccfg.setCacheMode(REPLICATED);
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ return ccfg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a20ca351/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java
index 16d7e5d..0460a8f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java
@@ -150,7 +150,11 @@ public abstract class IgniteCacheMessageRecoveryAbstractTest extends GridCommonA
for (int i = 0; i < 30; i++) {
Thread.sleep(1000);
- closed |= closeSessions();
+ Ignite node0 = ignite(ThreadLocalRandom.current().nextInt(0, GRID_CNT));
+
+ log.info("Close sessions for: " + ignite.name());
+
+ closed |= closeSessions(node0);
}
assertTrue(closed);
@@ -163,13 +167,11 @@ public abstract class IgniteCacheMessageRecoveryAbstractTest extends GridCommonA
}
/**
+ * @param ignite Node.
* @throws Exception If failed.
+ * @return {@code True} if closed at least one session.
*/
- private boolean closeSessions() throws Exception {
- Ignite ignite = ignite(ThreadLocalRandom.current().nextInt(0, GRID_CNT));
-
- log.info("Close sessions for: " + ignite.name());
-
+ static boolean closeSessions(Ignite ignite) throws Exception {
TcpCommunicationSpi commSpi = (TcpCommunicationSpi)ignite.configuration().getCommunicationSpi();
Map<UUID, GridCommunicationClient> clients = U.field(commSpi, "clients");
http://git-wip-us.apache.org/repos/asf/ignite/blob/a20ca351/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnection.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnection.java
deleted file mode 100644
index 618fe2a..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnection.java
+++ /dev/null
@@ -1,154 +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.cache.distributed;
-
-import java.util.List;
-import java.util.concurrent.ThreadLocalRandom;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.IgnitionEx;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheMode.REPLICATED;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-
-/**
- *
- */
-public class IgniteCacheMessageRecoveryIdleConnection extends GridCommonAbstractTest {
- /** */
- private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
- /** */
- private static final int NODES = 3;
-
- /** */
- private static final long IDLE_TIMEOUT = 50;
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
-
- TcpCommunicationSpi commSpi = new TcpCommunicationSpi();
-
- commSpi.setIdleConnectionTimeout(IDLE_TIMEOUT);
- commSpi.setSharedMemoryPort(-1);
-
- cfg.setCommunicationSpi(commSpi);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected long getTestTimeout() {
- return 2 * 60_000;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
-
- startGridsMultiThreaded(NODES);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- super.afterTestsStopped();
-
- stopAllGrids();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheOperationsIdleConnectionCloseTx() throws Exception {
- cacheOperationsIdleConnectionClose(TRANSACTIONAL);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheOperationsIdleConnectionCloseAtomic() throws Exception {
- cacheOperationsIdleConnectionClose(ATOMIC);
- }
-
- /**
- * @param atomicityMode Cache atomicity mode.
- * @throws Exception If failed.
- */
- private void cacheOperationsIdleConnectionClose(CacheAtomicityMode atomicityMode) throws Exception {
- CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>();
-
- ccfg.setAtomicityMode(atomicityMode);
- ccfg.setCacheMode(REPLICATED);
- ccfg.setWriteSynchronizationMode(FULL_SYNC);
-
- IgniteCache<Object, Object> cache = ignite(0).createCache(ccfg).withAsync();
-
- try {
- ThreadLocalRandom rnd = ThreadLocalRandom.current();
-
- int iter = 0;
-
- long stopTime = System.currentTimeMillis() + 90_000;
-
- while (System.currentTimeMillis() < stopTime) {
- if (iter++ % 10 == 0)
- log.info("Iteration: " + iter);
-
- cache.put(iter, 1);
-
- IgniteFuture<?> fut = cache.future();
-
- try {
- fut.get(10_000);
- }
- catch (IgniteException e) {
- List<Ignite> nodes = IgnitionEx.allGridsx();
-
- for (Ignite node : nodes)
- ((IgniteKernal)node).dumpDebugInfo();
-
- U.dumpThreads(log);
-
- throw e;
- }
-
- U.sleep(rnd.nextLong(IDLE_TIMEOUT - 10, IDLE_TIMEOUT + 10));
- }
- }
- finally {
- ignite(0).destroyCache(ccfg.getName());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a20ca351/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java
new file mode 100644
index 0000000..b9003cd
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed;
+
+import java.util.List;
+import java.util.concurrent.ThreadLocalRandom;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.IgnitionEx;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class IgniteCacheMessageRecoveryIdleConnectionTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final int NODES = 3;
+
+ /** */
+ private static final long IDLE_TIMEOUT = 50;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+ TcpCommunicationSpi commSpi = new TcpCommunicationSpi();
+
+ commSpi.setIdleConnectionTimeout(IDLE_TIMEOUT);
+ commSpi.setSharedMemoryPort(-1);
+
+ cfg.setCommunicationSpi(commSpi);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return 2 * 60_000;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGridsMultiThreaded(NODES);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCacheOperationsIdleConnectionCloseTx() throws Exception {
+ cacheOperationsIdleConnectionClose(TRANSACTIONAL);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCacheOperationsIdleConnectionCloseAtomic() throws Exception {
+ cacheOperationsIdleConnectionClose(ATOMIC);
+ }
+
+ /**
+ * @param atomicityMode Cache atomicity mode.
+ * @throws Exception If failed.
+ */
+ private void cacheOperationsIdleConnectionClose(CacheAtomicityMode atomicityMode) throws Exception {
+ CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>();
+
+ ccfg.setAtomicityMode(atomicityMode);
+ ccfg.setCacheMode(REPLICATED);
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ IgniteCache<Object, Object> cache = ignite(0).createCache(ccfg).withAsync();
+
+ try {
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ int iter = 0;
+
+ long stopTime = System.currentTimeMillis() + 90_000;
+
+ while (System.currentTimeMillis() < stopTime) {
+ if (iter++ % 50 == 0)
+ log.info("Iteration: " + iter);
+
+ cache.put(iter, 1);
+
+ IgniteFuture<?> fut = cache.future();
+
+ try {
+ fut.get(10_000);
+ }
+ catch (IgniteException e) {
+ log.error("Failed to execute update, will dump debug information" +
+ " [err=" + e+ ", iter=" + iter + ']', e);
+
+ List<Ignite> nodes = IgnitionEx.allGridsx();
+
+ for (Ignite node : nodes)
+ ((IgniteKernal)node).dumpDebugInfo();
+
+ U.dumpThreads(log);
+
+ throw e;
+ }
+
+ U.sleep(rnd.nextLong(IDLE_TIMEOUT - 10, IDLE_TIMEOUT + 10));
+ }
+ }
+ finally {
+ ignite(0).destroyCache(ccfg.getName());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a20ca351/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 84e1502..9240ef5 100755
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -125,7 +125,8 @@ import org.apache.ignite.internal.processors.cache.distributed.CacheAtomicNearUp
import org.apache.ignite.internal.processors.cache.distributed.CacheTxNearUpdateTopologyChangeTest;
import org.apache.ignite.internal.processors.cache.distributed.GridCacheEntrySetIterationPreloadingSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheAtomicMessageRecoveryTest;
-import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheMessageRecoveryIdleConnection;
+import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheConnectionRecoveryTest;
+import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheMessageRecoveryIdleConnectionTest;
import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheMessageWriteTimeoutTest;
import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheSystemTransactionsSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheTxMessageRecoveryTest;
@@ -283,7 +284,8 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(IgniteCacheAtomicMessageRecoveryTest.class);
suite.addTestSuite(IgniteCacheTxMessageRecoveryTest.class);
suite.addTestSuite(IgniteCacheMessageWriteTimeoutTest.class);
- suite.addTestSuite(IgniteCacheMessageRecoveryIdleConnection.class);
+ suite.addTestSuite(IgniteCacheMessageRecoveryIdleConnectionTest.class);
+ suite.addTestSuite(IgniteCacheConnectionRecoveryTest.class);
GridTestUtils.addTestIfNeeded(suite, GridCacheOffHeapTieredEvictionAtomicSelfTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, GridCacheOffHeapTieredEvictionSelfTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, GridCacheOffHeapTieredAtomicSelfTest.class, ignoredTests);
[28/28] ignite git commit: Merge branches 'ignite-1.7.2' and 'master'.
Posted by ak...@apache.org.
Merge branches 'ignite-1.7.2' and 'master'.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2d436070
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2d436070
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2d436070
Branch: refs/heads/master
Commit: 2d4360707d9ec242db2733b5dd34fd20d7799a3c
Parents: f0c3b34 fa374fb
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Aug 22 10:26:45 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Aug 22 10:26:45 2016 +0700
----------------------------------------------------------------------
.../hibernate/HibernateL2CacheExample.java | 2 +-
.../org/apache/ignite/IgniteFileSystem.java | 27 +-
.../apache/ignite/IgniteSystemProperties.java | 10 +
.../igfs/secondary/IgfsSecondaryFileSystem.java | 2 +-
.../local/LocalIgfsSecondaryFileSystem.java | 396 +++++++
.../igfs/secondary/local/package-info.java | 22 +
.../ignite/igfs/secondary/package-info.java | 2 +-
.../internal/binary/BinaryClassDescriptor.java | 43 +-
.../ignite/internal/binary/BinaryContext.java | 21 +-
.../binary/BinaryMethodWriteReplacer.java | 59 +
.../ignite/internal/binary/BinaryTreeMap.java | 96 ++
.../binary/BinaryTreeMapWriteReplacer.java | 34 +
.../ignite/internal/binary/BinaryTreeSet.java | 93 ++
.../binary/BinaryTreeSetWriteReplacer.java | 34 +
.../ignite/internal/binary/BinaryUtils.java | 37 +-
.../internal/binary/BinaryWriteReplacer.java | 33 +
.../internal/binary/BinaryWriterExImpl.java | 35 +-
.../processors/cache/GridCacheIoManager.java | 24 +-
.../processors/cache/GridCacheMessage.java | 2 +-
.../binary/CacheObjectBinaryProcessorImpl.java | 19 +
.../dht/atomic/GridDhtAtomicCache.java | 176 ++-
.../GridNearPessimisticTxPrepareFuture.java | 2 +
.../near/GridNearTransactionalCache.java | 2 +-
.../near/GridNearTxFinishFuture.java | 28 +-
.../cache/distributed/near/GridNearTxLocal.java | 14 +-
.../cache/transactions/IgniteTxHandler.java | 1 -
.../internal/processors/igfs/IgfsAsyncImpl.java | 5 +
.../ignite/internal/processors/igfs/IgfsEx.java | 7 +
.../internal/processors/igfs/IgfsFileImpl.java | 20 +-
.../internal/processors/igfs/IgfsImpl.java | 8 +-
.../processors/igfs/IgfsMetaManager.java | 2 +-
.../processors/igfs/IgfsOutputStreamImpl.java | 7 +-
.../internal/processors/igfs/IgfsUtils.java | 53 +
.../local/LocalFileSystemIgfsFile.java | 134 +++
...fsSecondaryFileSystemPositionedReadable.java | 65 ++
.../util/nio/GridTcpNioCommunicationClient.java | 5 +-
.../visor/cache/VisorCacheTypeMetadata.java | 20 +-
.../communication/tcp/TcpCommunicationSpi.java | 49 +-
.../internal/binary/BinaryTreeSelfTest.java | 341 ++++++
.../CacheSerializableTransactionsTest.java | 5 +
.../CacheTxNotAllowReadFromBackupTest.java | 297 +++++
.../IgniteCacheConnectionRecoveryTest.java | 205 ++++
.../IgniteCacheMessageRecoveryAbstractTest.java | 14 +-
...gniteCacheMessageRecoveryIdleConnection.java | 154 ---
...eCacheMessageRecoveryIdleConnectionTest.java | 157 +++
.../CacheEntryProcessorNonSerializableTest.java | 410 +++++++
...faultIgfsSecondaryFileSystemTestAdapter.java | 117 ++
.../processors/igfs/IgfsAbstractSelfTest.java | 1057 ++++++++++--------
.../igfs/IgfsBackupFailoverSelfTest.java | 2 +-
.../igfs/IgfsDualAbstractSelfTest.java | 252 +----
.../igfs/IgfsExUniversalFileSystemAdapter.java | 116 --
...SecondaryFileSystemDualAbstractSelfTest.java | 76 ++
...ondaryFileSystemDualAsyncClientSelfTest.java | 28 +
...calSecondaryFileSystemDualAsyncSelfTest.java | 32 +
...condaryFileSystemDualSyncClientSelfTest.java | 28 +
...ocalSecondaryFileSystemDualSyncSelfTest.java | 32 +
...IgfsLocalSecondaryFileSystemTestAdapter.java | 141 +++
.../internal/processors/igfs/IgfsMock.java | 5 +
.../IgfsSecondaryFileSystemTestAdapter.java | 118 ++
.../igfs/UniversalFileSystemAdapter.java | 109 --
.../IgniteBinaryObjectsTestSuite.java | 2 +
.../ignite/testsuites/IgniteCacheTestSuite.java | 8 +-
.../testsuites/IgniteCacheTestSuite4.java | 2 +
.../ignite/testsuites/IgniteIgfsTestSuite.java | 9 +
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 2 +-
.../ignite/igfs/Hadoop1DualAbstractTest.java | 3 +-
...oopFileSystemUniversalFileSystemAdapter.java | 139 ---
.../igfs/HadoopIgfsDualAbstractSelfTest.java | 2 +-
...adoopIgfsSecondaryFileSystemTestAdapter.java | 149 +++
.../ClientReconnectAfterClusterRestartTest.java | 225 ++++
...eLockPartitionOnAffinityRunAbstractTest.java | 17 +
.../IgniteCacheWithIndexingTestSuite.java | 5 +-
.../parser/dialect/DatabaseMetadataDialect.java | 18 +
.../parser/dialect/JdbcMetadataDialect.java | 5 +-
.../parser/dialect/OracleMetadataDialect.java | 5 +-
.../ignite/schema/generator/CodeGenerator.java | 7 +-
.../schema/parser/DatabaseMetadataParser.java | 4 +-
.../ignite/schema/ui/SchemaImportApp.java | 3 +-
.../schema/test/AbstractSchemaImportTest.java | 27 +-
.../test/generator/CodeGeneratorTest.java | 28 +-
.../schema/test/generator/XmlGeneratorTest.java | 22 +-
.../ignite/schema/test/model/CacheConfig.txt | 409 +++++++
.../schema/test/model/ignite-type-metadata.xml | 50 +-
.../test/parser/DbMetadataParserTest.java | 6 +-
84 files changed, 5023 insertions(+), 1409 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2d436070/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2d436070/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
----------------------------------------------------------------------
[04/28] ignite git commit: IGNITE-3021: IGFS: Fixed failiing
IgfsStreamsSelfTest.testCreateFileColocated() test. Failure as caused by
misconfiguration.
Posted by ak...@apache.org.
IGNITE-3021: IGFS: Fixed failiing IgfsStreamsSelfTest.testCreateFileColocated() test. Failure as caused by misconfiguration.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/89bce0fc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/89bce0fc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/89bce0fc
Branch: refs/heads/master
Commit: 89bce0fc5cb3dba56626c7088e607d0b25c3353c
Parents: 0b4ffdb
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Jun 30 13:14:16 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 12:27:38 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/processors/igfs/IgfsStreamsSelfTest.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/89bce0fc/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
index 724e80a..2af8c5c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.igfs;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteFileSystem;
+import org.apache.ignite.cache.CacheRebalanceMode;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.FileSystemConfiguration;
@@ -123,6 +124,7 @@ public class IgfsStreamsSelfTest extends IgfsCommonAbstractTest {
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
+ cfg.setLateAffinityAssignment(false);
cfg.setCacheConfiguration(cacheConfiguration(META_CACHE_NAME), cacheConfiguration(DATA_CACHE_NAME));
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
@@ -155,13 +157,13 @@ public class IgfsStreamsSelfTest extends IgfsCommonAbstractTest {
else {
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setNearConfiguration(null);
-
cacheCfg.setBackups(0);
cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(CFG_GRP_SIZE));
}
cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheCfg.setAtomicityMode(TRANSACTIONAL);
+ cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
return cacheCfg;
}
@@ -232,6 +234,7 @@ public class IgfsStreamsSelfTest extends IgfsCommonAbstractTest {
Collection<IgfsBlockLocation> affNodes = fs.affinity(path, 0, info.length());
assertEquals(1, affNodes.size());
+
Collection<UUID> nodeIds = F.first(affNodes).nodeIds();
assertEquals(1, nodeIds.size());
[27/28] ignite git commit: Merge branches 'ignite-1.6.6' and
'ignite-1.7.2' of https://github.com/gridgain/apache-ignite into ignite-1.7.2
Posted by ak...@apache.org.
Merge branches 'ignite-1.6.6' and 'ignite-1.7.2' of https://github.com/gridgain/apache-ignite into ignite-1.7.2
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fa374fb5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fa374fb5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fa374fb5
Branch: refs/heads/master
Commit: fa374fb50e8efce0b180d147d3ffebd9bb20fecd
Parents: 3029108 974467a
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Aug 22 10:21:58 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Aug 22 10:21:58 2016 +0700
----------------------------------------------------------------------
.../hibernate/HibernateL2CacheExample.java | 2 +-
.../processors/cache/GridCacheIoManager.java | 24 +-
.../processors/cache/GridCacheMessage.java | 2 +-
.../dht/atomic/GridDhtAtomicCache.java | 176 ++++++--
.../GridNearPessimisticTxPrepareFuture.java | 2 +
.../near/GridNearTransactionalCache.java | 2 +-
.../near/GridNearTxFinishFuture.java | 28 +-
.../cache/distributed/near/GridNearTxLocal.java | 14 +-
.../cache/transactions/IgniteTxHandler.java | 1 -
.../internal/processors/igfs/IgfsAsyncImpl.java | 5 +
.../ignite/internal/processors/igfs/IgfsEx.java | 7 +
.../internal/processors/igfs/IgfsImpl.java | 8 +-
.../processors/igfs/IgfsOutputStreamImpl.java | 7 +-
.../util/nio/GridTcpNioCommunicationClient.java | 5 +-
.../visor/cache/VisorCacheTypeMetadata.java | 20 +-
.../communication/tcp/TcpCommunicationSpi.java | 49 ++-
.../CacheSerializableTransactionsTest.java | 5 +
.../CacheTxNotAllowReadFromBackupTest.java | 297 ++++++++++++++
.../IgniteCacheConnectionRecoveryTest.java | 205 ++++++++++
.../IgniteCacheMessageRecoveryAbstractTest.java | 14 +-
...gniteCacheMessageRecoveryIdleConnection.java | 154 -------
...eCacheMessageRecoveryIdleConnectionTest.java | 157 +++++++
.../CacheEntryProcessorNonSerializableTest.java | 410 +++++++++++++++++++
.../processors/igfs/IgfsAbstractSelfTest.java | 86 ++--
.../igfs/IgfsBackupFailoverSelfTest.java | 2 +-
.../igfs/IgfsDualAbstractSelfTest.java | 86 +---
.../internal/processors/igfs/IgfsMock.java | 5 +
.../ignite/testsuites/IgniteCacheTestSuite.java | 8 +-
.../testsuites/IgniteCacheTestSuite4.java | 2 +
.../igfs/HadoopIgfsDualAbstractSelfTest.java | 2 +-
.../parser/dialect/DatabaseMetadataDialect.java | 18 +
.../parser/dialect/JdbcMetadataDialect.java | 5 +-
.../parser/dialect/OracleMetadataDialect.java | 5 +-
.../ignite/schema/generator/CodeGenerator.java | 7 +-
.../schema/parser/DatabaseMetadataParser.java | 4 +-
.../ignite/schema/ui/SchemaImportApp.java | 3 +-
.../schema/test/AbstractSchemaImportTest.java | 27 +-
.../test/generator/CodeGeneratorTest.java | 28 +-
.../schema/test/generator/XmlGeneratorTest.java | 22 +-
.../ignite/schema/test/model/CacheConfig.txt | 409 ++++++++++++++++++
.../schema/test/model/ignite-type-metadata.xml | 50 ++-
.../test/parser/DbMetadataParserTest.java | 6 +-
42 files changed, 1923 insertions(+), 446 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fa374fb5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fa374fb5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fa374fb5/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
[15/28] ignite git commit: IGNITE-1926: IGFS: Implemented local
secondary file system.
Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/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..08cb929 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]);
}
@@ -1080,6 +1120,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testRootPropertiesPersistAfterFormat() throws Exception {
+ if(!propertiesSupported())
+ return;
+
if (dual && !(igfsSecondaryFileSystem instanceof IgfsSecondaryFileSystemImpl)) {
// In case of Hadoop dual mode only user name, group name, and permission properties are updated,
// an arbitrary named property is just ignored:
@@ -1183,77 +1226,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());
- // Change only modification time.
- igfs.setTimes(path, -1, info.modificationTime() + 1);
+ assertEquals(newInfo.accessTime(), (long) newSecondaryTimes.get1());
+ assertEquals(secondaryTimes.get2(), newSecondaryTimes.get2());
+ }
- newInfo = igfs.info(path);
+ // Change only modification time.
+ igfs.setTimes(path, -1, info.modificationTime() + 1);
- assert newInfo != null;
+ newInfo = igfs.info(path);
- assertEquals(info.accessTime() + 1, newInfo.accessTime());
- assertEquals(info.modificationTime() + 1, newInfo.modificationTime());
+ assert newInfo != null;
- if (dual) {
- T2<Long, Long> newSecondaryTimes = igfsSecondary.times(path.toString());
+ assertEquals(info.accessTime() + 1, newInfo.accessTime());
+ assertEquals(info.modificationTime() + 1, newInfo.modificationTime());
- assertEquals(newInfo.accessTime(), (long)newSecondaryTimes.get1());
- assertEquals(newInfo.modificationTime(), (long)newSecondaryTimes.get2());
- }
+ if (dual) {
+ T2<Long, Long> newSecondaryTimes = igfsSecondary.times(path.toString());
- // Change both.
- igfs.setTimes(path, info.accessTime() + 2, info.modificationTime() + 2);
+ assertEquals(newInfo.accessTime(), (long) newSecondaryTimes.get1());
+ assertEquals(newInfo.modificationTime(), (long) newSecondaryTimes.get2());
+ }
- newInfo = igfs.info(path);
+ // Change both.
+ igfs.setTimes(path, info.accessTime() + 2, info.modificationTime() + 2);
- assert newInfo != null;
+ newInfo = igfs.info(path);
- assertEquals(info.accessTime() + 2, newInfo.accessTime());
- assertEquals(info.modificationTime() + 2, newInfo.modificationTime());
+ assert newInfo != null;
- if (dual) {
- T2<Long, Long> newSecondaryTimes = igfsSecondary.times(path.toString());
+ assertEquals(info.accessTime() + 2, newInfo.accessTime());
+ assertEquals(info.modificationTime() + 2, newInfo.modificationTime());
+
+ 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());
+ }
}
}
@@ -1361,6 +1407,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCreateNoClose() throws Exception {
+ if (dual)
+ return;
+
create(igfs, paths(DIR, SUBDIR), null);
GridTestUtils.assertThrows(log(), new Callable<Object>() {
@@ -1387,6 +1436,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCreateRenameNoClose() throws Exception {
+ if (dual)
+ return;
+
create(igfs, paths(DIR, SUBDIR), null);
IgfsOutputStream os = null;
@@ -1409,6 +1461,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCreateRenameParentNoClose() throws Exception {
+ if (dual)
+ return;
+
create(igfs, paths(DIR, SUBDIR), null);
IgfsOutputStream os = null;
@@ -1431,6 +1486,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCreateDeleteNoClose() throws Exception {
+ if (dual)
+ return;
+
create(igfs, paths(DIR, SUBDIR), null);
IgfsOutputStream os = null;
@@ -1482,6 +1540,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCreateDeleteParentNoClose() throws Exception {
+ if (dual)
+ return;
+
create(igfs, paths(DIR, SUBDIR), null);
IgfsOutputStream os = null;
@@ -1533,6 +1594,12 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCreateUpdateNoClose() throws Exception {
+ if (dual)
+ return;
+
+ if(!propertiesSupported())
+ return;
+
Map<String, String> props = properties("owner", "group", "0555");
create(igfs, paths(DIR, SUBDIR), null);
@@ -1634,75 +1701,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 +1779,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 +1921,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 +1938,32 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendNoClose() throws Exception {
- create(igfs, paths(DIR, SUBDIR), null);
+ if (dual)
+ return;
- createFile(igfs.asSecondary(), FILE, false);
+ if (appendSupported()) {
+ create(igfs, paths(DIR, SUBDIR), null);
- GridTestUtils.assertThrowsInherited(log(), new Callable<Object>() {
- @Override public Object call() throws Exception {
- IgfsOutputStream os1 = null;
- IgfsOutputStream os2 = null;
+ createFile(igfs.asSecondary(), FILE, false);
- try {
- os1 = igfs.append(FILE, false);
- os2 = igfs.append(FILE, false);
- }
- finally {
- U.closeQuiet(os1);
- U.closeQuiet(os2);
- }
+ GridTestUtils.assertThrowsInherited(log(), new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ IgfsOutputStream os1 = null;
+ IgfsOutputStream os2 = null;
- return null;
- }
- }, IgniteException.class, null);
+ try {
+ os1 = igfs.append(FILE, false);
+ os2 = igfs.append(FILE, false);
+ } finally {
+ U.closeQuiet(os1);
+ U.closeQuiet(os2);
+ }
+
+ return null;
+ }
+ }, IgniteException.class, null);
+ }
}
/**
@@ -1885,21 +1972,25 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendRenameNoClose() throws Exception {
- create(igfs, paths(DIR, SUBDIR), null);
+ if (dual)
+ return;
- createFile(igfs.asSecondary(), FILE, false);
+ if (appendSupported()) {
+ create(igfs, paths(DIR, SUBDIR), null);
- IgfsOutputStream os = null;
+ createFile(igfs.asSecondary(), FILE, false);
- try {
- os = igfs.append(FILE, false);
+ IgfsOutputStream os = null;
- igfs.rename(FILE, FILE2);
+ try {
+ os = igfs.append(FILE, false);
- os.close();
- }
- finally {
- U.closeQuiet(os);
+ igfs.rename(FILE, FILE2);
+
+ os.close();
+ } finally {
+ U.closeQuiet(os);
+ }
}
}
@@ -1909,21 +2000,25 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendRenameParentNoClose() throws Exception {
- create(igfs.asSecondary(), paths(DIR, SUBDIR), null);
+ if (dual)
+ return;
- createFile(igfs.asSecondary(), FILE, false);
+ if (appendSupported()) {
+ create(igfs.asSecondary(), paths(DIR, SUBDIR), null);
- IgfsOutputStream os = null;
+ createFile(igfs.asSecondary(), FILE, false);
- try {
- os = igfs.append(FILE, false);
+ IgfsOutputStream os = null;
- igfs.rename(SUBDIR, SUBDIR2);
+ try {
+ os = igfs.append(FILE, false);
- os.close();
- }
- finally {
- U.closeQuiet(os);
+ igfs.rename(SUBDIR, SUBDIR2);
+
+ os.close();
+ } finally {
+ U.closeQuiet(os);
+ }
}
}
@@ -1933,48 +2028,53 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendDeleteNoClose() throws Exception {
- create(igfs, paths(DIR, SUBDIR), null);
+ if (dual)
+ return;
- createFile(igfs.asSecondary(), FILE, false);
+ if (appendSupported()) {
+ create(igfs, paths(DIR, SUBDIR), null);
- IgfsOutputStream os = null;
- IgniteUuid id = null;
+ createFile(igfs.asSecondary(), FILE, false);
- try {
- id = igfs.context().meta().fileId(FILE);
+ IgfsOutputStream os = null;
+ IgniteUuid id = null;
- os = igfs.append(FILE, false);
+ try {
+ id = igfs.context().meta().fileId(FILE);
- boolean del = igfs.delete(FILE, false);
+ os = igfs.append(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.
+ boolean del = igfs.delete(FILE, false);
- os.write(chunk);
+ 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.close();
- }
- finally {
- U.closeQuiet(os);
- }
+ os.write(chunk);
- assert id != null;
+ os.close();
+ } finally {
+ U.closeQuiet(os);
+ }
- final IgniteUuid id0 = id;
+ assert id != null;
- // 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);
+ 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);
+ }
}
- }
- }, 5_000L);
+ }, 5_000L);
+ }
}
/**
@@ -1983,48 +2083,53 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendDeleteParentNoClose() throws Exception {
- create(igfs, paths(DIR, SUBDIR), null);
+ if (dual)
+ return;
- createFile(igfs.asSecondary(), FILE, false);
+ if (appendSupported()) {
+ create(igfs, paths(DIR, SUBDIR), null);
- IgfsOutputStream os = null;
- IgniteUuid id = null;
+ createFile(igfs.asSecondary(), FILE, false);
- try {
- id = igfs.context().meta().fileId(FILE);
+ IgfsOutputStream os = null;
+ IgniteUuid id = null;
- os = igfs.append(FILE, false);
+ try {
+ id = igfs.context().meta().fileId(FILE);
- boolean del = igfs.delete(SUBDIR, true); // Since GG-4911 we allow deletes in this case.
+ os = igfs.append(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.
+ boolean del = igfs.delete(SUBDIR, true); // Since GG-4911 we allow deletes in this case.
- os.write(chunk);
+ 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.close();
- }
- finally {
- U.closeQuiet(os);
- }
+ os.write(chunk);
- assert id != null;
+ os.close();
+ } finally {
+ U.closeQuiet(os);
+ }
- final IgniteUuid id0 = id;
+ assert id != null;
- // 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);
+ 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);
+ }
}
- }
- }, 5_000L);
+ }, 5_000L);
+ }
}
/**
@@ -2033,23 +2138,28 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testAppendUpdateNoClose() throws Exception {
- Map<String, String> props = properties("owner", "group", "0555");
+ if (dual)
+ return;
- create(igfs, paths(DIR, SUBDIR), null);
+ if (appendSupported()) {
+ Map<String, String> props = properties("owner", "group", "0555");
- createFile(igfs.asSecondary(), FILE, false);
+ create(igfs, paths(DIR, SUBDIR), null);
- IgfsOutputStream os = null;
+ createFile(igfs.asSecondary(), FILE, false);
- try {
- os = igfs.append(FILE, false);
+ IgfsOutputStream os = null;
- igfs.update(FILE, props);
+ try {
+ os = igfs.append(FILE, false);
- os.close();
- }
- finally {
- U.closeQuiet(os);
+ if (permissionsSupported())
+ igfs.update(FILE, props);
+
+ os.close();
+ } finally {
+ U.closeQuiet(os);
+ }
}
}
@@ -2059,47 +2169,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 +2220,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<>();
-
- igfs.create(FILE, false).close();
+ final AtomicInteger chunksCtr = new AtomicInteger(); // How many chunks were written.
+ final AtomicReference<Exception> err = new AtomicReference<>();
- int threadCnt = 50;
+ igfs.create(FILE, false).close();
- IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
- @Override public void run() {
- while (!stop.get() && err.get() == null) {
- IgfsOutputStream os = null;
+ int threadCnt = 50;
- 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 +2685,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 +2989,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 +3036,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 +3048,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 +3142,8 @@ 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 +3169,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 +3179,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 +3194,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 +3221,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 +3242,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 +3304,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 +3386,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 +3528,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/5cf3bea3/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..b4ca0ca 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
@@ -27,9 +27,7 @@ import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.testframework.GridTestUtils;
-import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Iterator;
@@ -43,6 +41,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 +983,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 +1011,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 +1071,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 +1102,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 +1133,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);
@@ -1154,85 +1164,6 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
}
/**
- * Ensure that no prefetch occurs in case not enough block are read sequentially.
- *
- * @throws Exception If failed.
- */
- @SuppressWarnings({"ResultOfMethodCallIgnored", "ThrowableResultOfMethodCallIgnored"})
- public void testOpenNoPrefetch() throws Exception {
- create(igfsSecondary, paths(DIR, SUBDIR), paths(FILE));
-
- // Write enough data to the secondary file system.
- final int blockSize = IGFS_BLOCK_SIZE;
-
- int totalWritten = 0;
- try (OutputStream out = igfsSecondary.openOutputStream(FILE.toString(), false)) {
-
- while (totalWritten < blockSize * 2 + chunk.length) {
- out.write(chunk);
-
- totalWritten += chunk.length;
- }
- }
-
- awaitFileClose(igfsSecondaryFileSystem, FILE);
-
- // Read the first block.
- int totalRead = 0;
-
- IgfsInputStream in = igfs.open(FILE, blockSize);
-
- final byte[] readBuf = new byte[1024];
-
- while (totalRead + readBuf.length <= blockSize) {
- in.read(readBuf);
-
- totalRead += readBuf.length;
- }
-
- // Now perform seek.
- in.seek(blockSize * 2);
-
- // Read the third block.
- totalRead = 0;
-
- while (totalRead < totalWritten - blockSize * 2) {
- in.read(readBuf);
-
- totalRead += readBuf.length;
- }
-
- // Let's wait for a while because prefetch occurs asynchronously.
- U.sleep(300);
-
- // Remove the file from the secondary file system.
- igfsSecondary.delete(FILE.toString(), false);
-
- // Let's wait for file will be deleted.
- U.sleep(300);
-
- final IgfsInputStream in0 = in;
-
- // Try reading the second block. Should fail.
- GridTestUtils.assertThrows(log, new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- in0.seek(blockSize);
-
- try {
- in0.read(readBuf);
- }
- finally {
- U.closeQuiet(in0);
- }
-
- 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");
- }
-
- /**
* Ensure that prefetch occurs in case several blocks are read sequentially.
*
* @throws Exception If failed.
@@ -1242,7 +1173,8 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
create(igfsSecondary, paths(DIR, SUBDIR), paths(FILE));
// Write enough data to the secondary file system.
- final int blockSize = igfs.info(FILE).blockSize();
+ int blockSize0 = igfs.info(FILE).blockSize();
+ final int blockSize = blockSize0 != 0 ? blockSize0 : 8 * 1024;
int totalWritten = 0;
try (OutputStream out = igfsSecondary.openOutputStream(FILE.toString(), false)) {
@@ -1253,7 +1185,10 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
}
}
- awaitFileClose(igfsSecondaryFileSystem, FILE);
+ if (propertiesSupported())
+ awaitFileClose(igfsSecondaryFileSystem, FILE);
+ else
+ Thread.sleep(1000);
// Read the first two blocks.
int totalRead = 0;
@@ -1313,18 +1248,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 +1284,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 +1311,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 +1322,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 +1335,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 +1343,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 +1652,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 +1670,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/5cf3bea3/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/5cf3bea3/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java
new file mode 100644
index 0000000..c2f5633
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.igfs;
+
+import org.apache.ignite.igfs.IgfsMode;
+import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
+import org.apache.ignite.igfs.secondary.local.LocalIgfsSecondaryFileSystem;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+import java.io.File;
+
+/**
+ * Abstract test for Hadoop 1.0 file system stack.
+ */
+public abstract class IgfsLocalSecondaryFileSystemDualAbstractSelfTest extends IgfsDualAbstractSelfTest {
+ /** */
+ private static final String FS_WORK_DIR = U.getIgniteHome() + File.separatorChar + "work"
+ + File.separatorChar + "fs";
+
+ /** Constructor.
+ * @param mode IGFS mode.
+ */
+ public IgfsLocalSecondaryFileSystemDualAbstractSelfTest(IgfsMode mode) {
+ super(mode);
+ }
+
+ /**
+ * Creates secondary filesystems.
+ * @return IgfsSecondaryFileSystem
+ * @throws Exception On failure.
+ */
+ @Override protected IgfsSecondaryFileSystem createSecondaryFileSystemStack() throws Exception {
+ final File workDir = new File(FS_WORK_DIR);
+
+ if (!workDir.exists())
+ assert workDir.mkdirs();
+
+ LocalIgfsSecondaryFileSystem second = new LocalIgfsSecondaryFileSystem();
+
+ second.setWorkDirectory(workDir.getAbsolutePath());
+
+ igfsSecondary = new IgfsLocalSecondaryFileSystemTestAdapter(workDir);
+
+ return second;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean permissionsSupported() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean propertiesSupported() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean timesSupported() {
+ return false;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAsyncClientSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAsyncClientSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAsyncClientSelfTest.java
new file mode 100644
index 0000000..fd9e10c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAsyncClientSelfTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+/**
+ * DUAL_ASYNC mode.
+ */
+public class IgfsLocalSecondaryFileSystemDualAsyncClientSelfTest extends IgfsLocalSecondaryFileSystemDualAsyncSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean client() {
+ return true;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAsyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAsyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAsyncSelfTest.java
new file mode 100644
index 0000000..65a2064
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAsyncSelfTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.igfs;
+
+import org.apache.ignite.igfs.IgfsMode;
+
+/**
+ * DUAL_ASYNC mode test.
+ */
+public class IgfsLocalSecondaryFileSystemDualAsyncSelfTest extends IgfsLocalSecondaryFileSystemDualAbstractSelfTest {
+ /**
+ * Constructor.
+ */
+ public IgfsLocalSecondaryFileSystemDualAsyncSelfTest() {
+ super(IgfsMode.DUAL_ASYNC);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualSyncClientSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualSyncClientSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualSyncClientSelfTest.java
new file mode 100644
index 0000000..9358850
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualSyncClientSelfTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+/**
+ * DUAL_SYNC mode.
+ */
+public class IgfsLocalSecondaryFileSystemDualSyncClientSelfTest extends IgfsLocalSecondaryFileSystemDualSyncSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean client() {
+ return true;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualSyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualSyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualSyncSelfTest.java
new file mode 100644
index 0000000..fef4f7c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualSyncSelfTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.igfs;
+
+import org.apache.ignite.igfs.IgfsMode;
+
+/**
+ * DUAL_SYNC mode.
+ */
+public class IgfsLocalSecondaryFileSystemDualSyncSelfTest extends IgfsLocalSecondaryFileSystemDualAbstractSelfTest {
+ /**
+ * Constructor.
+ */
+ public IgfsLocalSecondaryFileSystemDualSyncSelfTest() {
+ super(IgfsMode.DUAL_SYNC);
+ }
+}
\ No newline at end of file
[07/28] ignite git commit: IGNITE-466: IGFS: Added "IgfsMode
mode(IgfsPath)" method.
Posted by ak...@apache.org.
IGNITE-466: IGFS: Added "IgfsMode mode(IgfsPath)" method.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9ddf9d84
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9ddf9d84
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9ddf9d84
Branch: refs/heads/master
Commit: 9ddf9d846f52a4e8fc433643409993884c70ce37
Parents: f87ca48
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Jul 21 16:00:45 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 12:30:15 2016 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/IgniteFileSystem.java | 9 +++++++++
.../ignite/internal/processors/igfs/IgfsAsyncImpl.java | 6 ++++++
.../apache/ignite/internal/processors/igfs/IgfsImpl.java | 7 +++++++
.../apache/ignite/internal/processors/igfs/IgfsMock.java | 8 ++++++++
4 files changed, 30 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ddf9d84/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
index def2965..bbc5bea 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
@@ -24,6 +24,7 @@ import org.apache.ignite.igfs.IgfsBlockLocation;
import org.apache.ignite.igfs.IgfsFile;
import org.apache.ignite.igfs.IgfsInputStream;
import org.apache.ignite.igfs.IgfsMetrics;
+import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.IgfsOutputStream;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.igfs.IgfsPathSummary;
@@ -456,6 +457,14 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
@Nullable public IgfsFile info(IgfsPath path) throws IgniteException;
/**
+ * Get mode for the given path.
+ *
+ * @param path Path.
+ * @return Mode used for this path.
+ */
+ public IgfsMode mode(IgfsPath path);
+
+ /**
* Gets used space in bytes.
*
* @return Used space in bytes.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ddf9d84/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
index 7530557..bf3d22b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
@@ -26,6 +26,7 @@ import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.igfs.IgfsBlockLocation;
import org.apache.ignite.igfs.IgfsFile;
import org.apache.ignite.igfs.IgfsMetrics;
+import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.IgfsOutputStream;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.igfs.IgfsPathSummary;
@@ -308,6 +309,11 @@ public class IgfsAsyncImpl extends AsyncSupportAdapter<IgniteFileSystem> impleme
}
/** {@inheritDoc} */
+ @Override public IgfsMode mode(IgfsPath path) {
+ return igfs.mode(path);
+ }
+
+ /** {@inheritDoc} */
@Override public long usedSpaceSize() {
return igfs.usedSpaceSize();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ddf9d84/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 df7dfb5..0d1ffc1 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
@@ -577,6 +577,13 @@ public final class IgfsImpl implements IgfsEx {
}
/** {@inheritDoc} */
+ @Override public IgfsMode mode(IgfsPath path) {
+ A.notNull(path, "path");
+
+ return modeRslvr.resolveMode(path);
+ }
+
+ /** {@inheritDoc} */
@Override public IgfsPathSummary summary(final IgfsPath path) {
A.notNull(path, "path");
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ddf9d84/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
index dccab4a..a2bd9ca 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
@@ -24,6 +24,7 @@ import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.igfs.IgfsBlockLocation;
import org.apache.ignite.igfs.IgfsFile;
import org.apache.ignite.igfs.IgfsMetrics;
+import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.IgfsOutputStream;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.igfs.IgfsPathSummary;
@@ -361,6 +362,13 @@ public class IgfsMock implements IgfsEx {
}
/** {@inheritDoc} */
+ @Override public IgfsMode mode(IgfsPath path) {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public long usedSpaceSize() throws IgniteException {
throwUnsupported();
[12/28] ignite git commit: IGNITE-3332: IGFS: Optimized file unlock
routine with help of a client callable. This closes #916.
Posted by ak...@apache.org.
IGNITE-3332: IGFS: Optimized file unlock routine with help of a client callable. This closes #916.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f5a040a0
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f5a040a0
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f5a040a0
Branch: refs/heads/master
Commit: f5a040a01280c654df1fc4789cc39ff1ac2d32a4
Parents: 4d876a7
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Tue Aug 9 10:01:56 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 12:31:34 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/binary/BinaryContext.java | 2 +
.../processors/igfs/IgfsFileAffinityRange.java | 40 ++++--
.../processors/igfs/IgfsMetaManager.java | 9 ++
.../internal/processors/igfs/IgfsUtils.java | 34 +++++
.../meta/IgfsClientMetaUnlockCallable.java | 123 +++++++++++++++++++
5 files changed, 197 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f5a040a0/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 8517acf..97afef1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -60,6 +60,7 @@ import org.apache.ignite.internal.processors.igfs.client.IgfsClientSummaryCallab
import org.apache.ignite.internal.processors.igfs.client.IgfsClientUpdateCallable;
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.client.meta.IgfsClientMetaUnlockCallable;
import org.apache.ignite.internal.processors.igfs.data.IgfsDataPutProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryCreateProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingAddProcessor;
@@ -162,6 +163,7 @@ public class BinaryContext {
sysClss.add(IgfsClientMetaIdsForPathCallable.class.getName());
sysClss.add(IgfsClientMetaInfoForPathCallable.class.getName());
+ sysClss.add(IgfsClientMetaUnlockCallable.class.getName());
sysClss.add(IgfsClientAffinityCallable.class.getName());
sysClss.add(IgfsClientDeleteCallable.class.getName());
http://git-wip-us.apache.org/repos/asf/ignite/blob/f5a040a0/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
index 953461c..194869e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
@@ -266,22 +266,40 @@ public class IgfsFileAffinityRange implements Message, Externalizable, Binaryliz
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
- BinaryRawWriter out = writer.rawWriter();
-
- BinaryUtils.writeIgniteUuid(out, affKey);
- out.writeInt(status);
- out.writeLong(startOff);
- out.writeLong(endOff);
+ writeRawBinary(writer.rawWriter());
}
/** {@inheritDoc} */
@Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
- BinaryRawReader in = reader.rawReader();
+ readRawBinary(reader.rawReader());
+ }
- affKey = BinaryUtils.readIgniteUuid(in);
- status = in.readInt();
- startOff = in.readLong();
- endOff = in.readLong();
+ /**
+ * Writes fields to provided writer.
+ *
+ * @param writer Writer.
+ * @throws BinaryObjectException If fails.
+ */
+ public void writeRawBinary(BinaryRawWriter writer) throws BinaryObjectException {
+ BinaryUtils.writeIgniteUuid(writer, affKey);
+
+ writer.writeInt(status);
+ writer.writeLong(startOff);
+ writer.writeLong(endOff);
+ }
+
+ /**
+ * Reads fields from provided reader.
+ *
+ * @param reader Reader.
+ * @throws BinaryObjectException If fails.
+ */
+ public void readRawBinary(BinaryRawReader reader) throws BinaryObjectException {
+ affKey = BinaryUtils.readIgniteUuid(reader);
+
+ status = reader.readInt();
+ startOff = reader.readLong();
+ endOff = reader.readLong();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/f5a040a0/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 d1151c5..1364491 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
@@ -50,6 +50,7 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx
import org.apache.ignite.internal.processors.igfs.client.IgfsClientAbstractCallable;
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.client.meta.IgfsClientMetaUnlockCallable;
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;
@@ -664,6 +665,14 @@ public class IgfsMetaManager extends IgfsManager {
public void unlock(final IgniteUuid fileId, final IgniteUuid lockId, final long modificationTime,
final boolean updateSpace, final long space, @Nullable final IgfsFileAffinityRange affRange)
throws IgniteCheckedException {
+
+ if(client) {
+ runClientTask(new IgfsClientMetaUnlockCallable(cfg.getName(), fileId, lockId, modificationTime,
+ updateSpace, space, affRange));
+
+ return;
+ }
+
validTxState(false);
if (busyLock.enterBusy()) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/f5a040a0/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 3d86fbb..a79d965 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
@@ -744,6 +744,40 @@ public class IgfsUtils {
}
/**
+ * Write IgfsFileAffinityRange.
+ *
+ * @param writer Writer
+ * @param affRange affinity range.
+ */
+ public static void writeFileAffinityRange(BinaryRawWriter writer, @Nullable IgfsFileAffinityRange affRange) {
+ if (affRange != null) {
+ writer.writeBoolean(true);
+
+ affRange.writeRawBinary(writer);
+ }
+ else
+ writer.writeBoolean(false);
+ }
+
+ /**
+ * Read IgfsFileAffinityRange.
+ *
+ * @param reader Reader.
+ * @return File affinity range.
+ */
+ public static IgfsFileAffinityRange readFileAffinityRange(BinaryRawReader reader) {
+ if (reader.readBoolean()) {
+ IgfsFileAffinityRange affRange = new IgfsFileAffinityRange();
+
+ affRange.readRawBinary(reader);
+
+ return affRange;
+ }
+ else
+ return null;
+ }
+
+ /**
* Parses the TRASH file name to extract the original path.
*
* @param name The TRASH short (entry) name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f5a040a0/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaUnlockCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaUnlockCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaUnlockCallable.java
new file mode 100644
index 0000000..a2f4ab7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaUnlockCallable.java
@@ -0,0 +1,123 @@
+/*
+ * 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.client.meta;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.processors.igfs.IgfsContext;
+import org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
+import org.apache.ignite.internal.processors.igfs.client.IgfsClientAbstractCallable;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * IGFS client unlock callable.
+ */
+public class IgfsClientMetaUnlockCallable extends IgfsClientAbstractCallable<Void> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** File id. */
+ private IgniteUuid fileId;
+
+ /** Lock id. */
+ private IgniteUuid lockId;
+
+ /** Modification time. */
+ private long modificationTime;
+
+ /** Update space. */
+ private boolean updateSpace;
+
+ /** Space. */
+ private long space;
+
+ /** Aff range. */
+ private IgfsFileAffinityRange affRange;
+ /**
+ * Default constructor.
+ */
+ public IgfsClientMetaUnlockCallable() {
+ // NO-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param igfsName IGFS name.
+ * @param fileId File ID.
+ * @param lockId Lock ID.
+ * @param modificationTime Modification time to write to file info.
+ * @param updateSpace Whether to update space.
+ * @param space Space.
+ * @param affRange Affinity range.
+ */
+ public IgfsClientMetaUnlockCallable(@Nullable String igfsName, IgniteUuid fileId, IgniteUuid lockId,
+ long modificationTime, boolean updateSpace, long space, final IgfsFileAffinityRange affRange) {
+ super(igfsName, null);
+
+ this.fileId = fileId;
+ this.lockId = lockId;
+ this.modificationTime = modificationTime;
+ this.updateSpace = updateSpace;
+ this.space = space;
+ this.affRange = affRange;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected Void call0(IgfsContext ctx) throws Exception {
+ ctx.meta().unlock(fileId, lockId, modificationTime, updateSpace, space, affRange);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary0(BinaryRawWriter writer) throws BinaryObjectException {
+ BinaryUtils.writeIgniteUuid(writer, fileId);
+ BinaryUtils.writeIgniteUuid(writer, lockId);
+ writer.writeLong(modificationTime);
+ writer.writeBoolean(updateSpace);
+
+ if (updateSpace)
+ writer.writeLong(space);
+
+ IgfsUtils.writeFileAffinityRange(writer, affRange);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary0(BinaryRawReader reader) throws BinaryObjectException {
+ fileId = BinaryUtils.readIgniteUuid(reader);
+ lockId = BinaryUtils.readIgniteUuid(reader);
+ modificationTime = reader.readLong();
+ updateSpace = reader.readBoolean();
+
+ if (updateSpace)
+ space = reader.readLong();
+
+ affRange = IgfsUtils.readFileAffinityRange(reader);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsClientMetaUnlockCallable.class, this);
+ }
+}
[02/28] ignite git commit: Added missing license.
Posted by ak...@apache.org.
Added missing license.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1139a9f7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1139a9f7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1139a9f7
Branch: refs/heads/master
Commit: 1139a9f76b5d37073261d729a15b1fbec674d48d
Parents: 1d0cbb4
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Aug 11 08:47:48 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Aug 11 08:47:48 2016 +0300
----------------------------------------------------------------------
...acheLockPartitionOnAffinityRunAbstractTest.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1139a9f7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunAbstractTest.java
index 11dc6c5..f3cef96 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunAbstractTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunAbstractTest.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.apache.ignite.internal.processors.cache;
import java.io.Serializable;
[25/28] ignite git commit: IGNITE-473 - Fixed HibernateL2CacheExample
output
Posted by ak...@apache.org.
IGNITE-473 - Fixed HibernateL2CacheExample output
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7422195f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7422195f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7422195f
Branch: refs/heads/master
Commit: 7422195f17df2c69a98eeed202f14eea80ad70b4
Parents: 9db16d1
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Fri Aug 19 16:53:40 2016 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Fri Aug 19 16:53:40 2016 -0700
----------------------------------------------------------------------
.../examples/datagrid/hibernate/HibernateL2CacheExample.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7422195f/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
index 4f399fb..a31d394 100644
--- a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
+++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
@@ -251,7 +251,7 @@ public class HibernateL2CacheExample {
SecondLevelCacheStatistics stats =
sesFactory.getStatistics().getSecondLevelCacheStatistics(entityName);
- System.out.println("\t\tL2 cache entries: " + stats.getEntries());
+ System.out.println("\t\tPuts: " + stats.getPutCount());
System.out.println("\t\tHits: " + stats.getHitCount());
System.out.println("\t\tMisses: " + stats.getMissCount());
}
[05/28] ignite git commit: IGNITE-826: Removed
HadoopHashMapSelfTest.testAllocation() as it tested nothing.
Posted by ak...@apache.org.
IGNITE-826: Removed HadoopHashMapSelfTest.testAllocation() as it tested nothing.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/78aa065b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/78aa065b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/78aa065b
Branch: refs/heads/master
Commit: 78aa065b4c7b05381b1fa31159b74969ec4a2bfe
Parents: 89bce0f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Jul 21 13:15:35 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 12:29:52 2016 +0300
----------------------------------------------------------------------
.../collections/HadoopHashMapSelfTest.java | 56 ++------------------
1 file changed, 5 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/78aa065b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopHashMapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopHashMapSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopHashMapSelfTest.java
index 2e1f66e..c0f8325 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopHashMapSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopHashMapSelfTest.java
@@ -36,60 +36,14 @@ import org.apache.ignite.internal.util.typedef.X;
*
*/
public class HadoopHashMapSelfTest extends HadoopAbstractMapTest {
-
- public void testAllocation() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-826");
-
- final GridUnsafeMemory mem = new GridUnsafeMemory(0);
-
- long size = 3L * 1024 * 1024 * 1024;
-
- final long chunk = 16;// * 1024;
-
- final int page = 4 * 1024;
-
- final int writes = chunk < page ? 1 : (int)(chunk / page);
-
- final long cnt = size / chunk;
-
- assert cnt < Integer.MAX_VALUE;
-
- final int threads = 4;
-
- long start = System.currentTimeMillis();
-
- multithreaded(new Callable<Object>() {
- @Override public Object call() throws Exception {
- int cnt0 = (int)(cnt / threads);
-
- for (int i = 0; i < cnt0; i++) {
- long ptr = mem.allocate(chunk);
-
- for (int j = 0; j < writes; j++)
- mem.writeInt(ptr + j * page, 100500);
- }
-
- return null;
- }
- }, threads);
-
- X.println("End: " + (System.currentTimeMillis() - start) + " mem: " + mem.allocatedSize() + " cnt: " + cnt);
-
- Thread.sleep(30000);
- }
-
-
- /** */
+ /**
+ * Test simple map.
+ *
+ * @throws Exception If failed.
+ */
public void testMapSimple() throws Exception {
GridUnsafeMemory mem = new GridUnsafeMemory(0);
-// mem.listen(new GridOffHeapEventListener() {
-// @Override public void onEvent(GridOffHeapEvent evt) {
-// if (evt == GridOffHeapEvent.ALLOCATE)
-// U.dumpStack();
-// }
-// });
-
Random rnd = new Random();
int mapSize = 16 << rnd.nextInt(3);
[22/28] ignite git commit: IGNITE-2559 Fixed Transaction hangs if
entry processor is not serializable. This closes #951.
Posted by ak...@apache.org.
IGNITE-2559 Fixed Transaction hangs if entry processor is not serializable. This closes #951.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8aa534a6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8aa534a6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8aa534a6
Branch: refs/heads/master
Commit: 8aa534a6124c066801e6627f36179934653fe59f
Parents: 97d1a6f
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Thu Aug 18 18:21:22 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Thu Aug 18 18:21:22 2016 +0300
----------------------------------------------------------------------
.../GridNearPessimisticTxPrepareFuture.java | 2 +
.../near/GridNearTxFinishFuture.java | 28 +-
.../cache/distributed/near/GridNearTxLocal.java | 10 +-
.../cache/transactions/IgniteTxHandler.java | 1 -
.../CacheEntryProcessorNonSerializableTest.java | 410 +++++++++++++++++++
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +
6 files changed, 437 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aa534a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
index 5d347d7..ef2edc9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
@@ -291,6 +291,8 @@ public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureA
}
fut.onError(e);
+
+ break;
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aa534a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
index 39f3ff3..adde63c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
@@ -97,7 +97,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
@GridToStringInclude
private GridNearTxLocal tx;
- /** Commit flag. */
+ /** Commit flag. This flag used only for one-phase commit transaction. */
private boolean commit;
/** Node mappings. */
@@ -313,6 +313,9 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
}
}
+ if (commit && tx.commitError() != null)
+ err = tx.commitError();
+
if (initialized() || err != null) {
if (tx.needCheckBackup()) {
assert tx.onePhaseCommit();
@@ -386,9 +389,11 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
/**
* Initializes future.
+ *
+ * @param commit Commit flag.
*/
@SuppressWarnings("ForLoopReplaceableByForEach")
- void finish() {
+ void finish(boolean commit) {
if (tx.onNeedCheckBackup()) {
assert tx.onePhaseCommit();
@@ -403,15 +408,15 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
try {
if (tx.finish(commit) || (!commit && tx.state() == UNKNOWN)) {
- if ((tx.onePhaseCommit() && needFinishOnePhase()) || (!tx.onePhaseCommit() && mappings != null)) {
+ if ((tx.onePhaseCommit() && needFinishOnePhase(commit)) || (!tx.onePhaseCommit() && mappings != null)) {
if (mappings.single()) {
GridDistributedTxMapping mapping = mappings.singleMapping();
if (mapping != null)
- finish(mapping);
+ finish(mapping, commit);
}
else
- finish(mappings.mappings());
+ finish(mappings.mappings(), commit);
}
markInitialized();
@@ -543,13 +548,14 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
}
/**
+ * @param commit Commit flag.
* @return {@code True} if need to send finish request for one phase commit transaction.
*/
- private boolean needFinishOnePhase() {
+ private boolean needFinishOnePhase(boolean commit) {
if (tx.mappings().empty())
return false;
- boolean finish = tx.txState().hasNearCache(cctx);
+ boolean finish = tx.txState().hasNearCache(cctx) || !commit;
if (finish) {
GridDistributedTxMapping mapping = tx.mappings().singleMapping();
@@ -605,17 +611,19 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
/**
* @param mappings Mappings.
+ * @param commit Commit flag.
*/
- private void finish(Iterable<GridDistributedTxMapping> mappings) {
+ private void finish(Iterable<GridDistributedTxMapping> mappings, boolean commit) {
// Create mini futures.
for (GridDistributedTxMapping m : mappings)
- finish(m);
+ finish(m, commit);
}
/**
* @param m Mapping.
+ * @param commit Commit flag.
*/
- private void finish(GridDistributedTxMapping m) {
+ private void finish(GridDistributedTxMapping m, boolean commit) {
ClusterNode n = m.node();
assert !m.empty();
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aa534a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index 62cf74b..28c60d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -857,19 +857,19 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
// Make sure that here are no exceptions.
prepareFut.get();
- fut0.finish();
+ fut0.finish(true);
}
catch (Error | RuntimeException e) {
COMMIT_ERR_UPD.compareAndSet(GridNearTxLocal.this, null, e);
- fut0.onDone(e);
+ fut0.finish(false);
throw e;
}
catch (IgniteCheckedException e) {
COMMIT_ERR_UPD.compareAndSet(GridNearTxLocal.this, null, e);
- fut0.onDone(e);
+ fut0.finish(false);
}
}
});
@@ -917,7 +917,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
log.debug("Got optimistic tx failure [tx=" + this + ", err=" + e + ']');
}
- fut.finish();
+ fut.finish(false);
}
else {
prepFut.listen(new CI1<IgniteInternalFuture<?>>() {
@@ -933,7 +933,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
GridNearTxFinishFuture fut0 = rollbackFut;
- fut0.finish();
+ fut0.finish(false);
}
});
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aa534a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index ba30e10..7c3c206 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@ -639,7 +639,6 @@ public class IgniteTxHandler {
", node=" + nodeId + ']');
}
-
fut.onResult(nodeId, res);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aa534a6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorNonSerializableTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorNonSerializableTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorNonSerializableTest.java
new file mode 100644
index 0000000..79aa34f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorNonSerializableTest.java
@@ -0,0 +1,410 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.query.continuous;
+
+import java.io.NotSerializableException;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ThreadLocalRandom;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC;
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
+
+/**
+ *
+ */
+public class CacheEntryProcessorNonSerializableTest extends GridCommonAbstractTest {
+ /** */
+ private static final int EXPECTED_VALUE = 42;
+
+ /** */
+ private static final int WRONG_VALUE = -1;
+
+ /** */
+ private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final int NODES = 3;
+
+ /** */
+ public static final int ITERATION_CNT = 1;
+
+ /** */
+ public static final int KEYS = 10;
+
+ /** */
+ private boolean client;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
+ cfg.setClientMode(client);
+ cfg.setMarshaller(new OptimizedMarshaller());
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGridsMultiThreaded(getServerNodeCount());
+
+ client = true;
+
+ startGrid(getServerNodeCount());
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @return Server nodes.
+ */
+ private int getServerNodeCount() {
+ return NODES;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPessimisticOnePhaseCommit() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPessimisticOnePhaseCommitWithNearCache() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1)
+ .setNearConfiguration(new NearCacheConfiguration());
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPessimisticOnePhaseCommitFullSync() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPessimisticOnePhaseCommitFullSyncWithNearCache() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1)
+ .setNearConfiguration(new NearCacheConfiguration());
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPessimistic() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPessimisticWithNearCache() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2)
+ .setNearConfiguration(new NearCacheConfiguration());
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPessimisticFullSync() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOptimisticOnePhaseCommit() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOptimisticOnePhaseCommitFullSync() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOptimisticOnePhaseCommitFullSyncWithNearCache() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1)
+ .setNearConfiguration(new NearCacheConfiguration());
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOptimistic() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOptimisticFullSync() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOptimisticFullSyncWithNearCache() throws Exception {
+ CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+
+ doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+ }
+
+ /**
+ * @param ccfg Cache configuration.
+ * @throws Exception If failed.
+ */
+ private void doTestInvokeTest(CacheConfiguration ccfg, TransactionConcurrency txConcurrency,
+ TransactionIsolation txIsolation) throws Exception {
+ IgniteEx cln = grid(getServerNodeCount());
+
+ grid(0).createCache(ccfg);
+
+ IgniteCache clnCache;
+
+ if (ccfg.getNearConfiguration() != null)
+ clnCache = cln.createNearCache(ccfg.getName(), ccfg.getNearConfiguration());
+ else
+ clnCache = cln.cache(ccfg.getName());
+
+ putKeys(clnCache, EXPECTED_VALUE);
+
+ try {
+ // Explicit tx.
+ for (int i = 0; i < ITERATION_CNT; i++) {
+ try (final Transaction tx = cln.transactions().txStart(txConcurrency, txIsolation)) {
+ putKeys(clnCache, WRONG_VALUE);
+
+ clnCache.invoke(KEYS, new NonSerialazibleEntryProcessor());
+
+ GridTestUtils.assertThrowsWithCause(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ tx.commit();
+
+ return null;
+ }
+ }, NotSerializableException.class);
+ }
+
+ checkKeys(clnCache, EXPECTED_VALUE);
+ }
+
+ // From affinity node.
+ Ignite grid = grid(ThreadLocalRandom.current().nextInt(NODES));
+
+ final IgniteCache cache = grid.cache(ccfg.getName());
+
+ // Explicit tx.
+ for (int i = 0; i < ITERATION_CNT; i++) {
+ try (final Transaction tx = grid.transactions().txStart(txConcurrency, txIsolation)) {
+ putKeys(cache, WRONG_VALUE);
+
+ cache.invoke(KEYS, new NonSerialazibleEntryProcessor());
+
+ GridTestUtils.assertThrowsWithCause(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ tx.commit();
+
+ return null;
+ }
+ }, NotSerializableException.class);
+ }
+
+ checkKeys(cache, EXPECTED_VALUE);
+ }
+
+ final IgniteCache clnCache0 = clnCache;
+
+ // Implicit tx.
+ for (int i = 0; i < ITERATION_CNT; i++) {
+ GridTestUtils.assertThrowsWithCause(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ clnCache0.invoke(KEYS, new NonSerialazibleEntryProcessor());
+
+ return null;
+ }
+ }, NotSerializableException.class);
+ }
+
+ checkKeys(clnCache, EXPECTED_VALUE);
+ }
+ finally {
+ grid(0).destroyCache(ccfg.getName());
+ }
+ }
+
+ /**
+ * @param cache Cache.
+ * @param val Value.
+ */
+ private void putKeys(IgniteCache cache, int val) {
+ cache.put(KEYS, val);
+ }
+
+ /**
+ * @param cache Cache.
+ * @param expVal Expected value.
+ */
+ private void checkKeys(IgniteCache cache, int expVal) {
+ assertEquals(expVal, cache.get(KEYS));
+ }
+
+ /**
+ * @return Cache configuration.
+ */
+ private CacheConfiguration cacheConfiguration(CacheWriteSynchronizationMode wrMode, int backup) {
+ return new CacheConfiguration("test-cache-" + wrMode + "-" + backup)
+ .setAtomicityMode(TRANSACTIONAL)
+ .setWriteSynchronizationMode(FULL_SYNC)
+ .setBackups(backup);
+ }
+
+ /**
+ *
+ */
+ private static class NonSerialazibleEntryProcessor implements EntryProcessor<Integer, Integer, Integer> {
+ /** {@inheritDoc} */
+ @Override public Integer process(MutableEntry<Integer, Integer> entry, Object... arguments)
+ throws EntryProcessorException {
+ entry.setValue(42);
+
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aa534a6/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 8c3f4de..84e1502 100755
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -137,6 +137,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheGet
import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearTxExceptionSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxExceptionSelfTest;
import org.apache.ignite.internal.processors.cache.local.GridCacheLocalTxExceptionSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheEntryProcessorNonSerializableTest;
import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorSelfTest;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerImplSelfTest;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerMultiThreadedSelfTest;
@@ -186,6 +187,7 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(IgniteCacheAtomicLocalInvokeTest.class);
suite.addTestSuite(IgniteCacheAtomicLocalWithStoreInvokeTest.class);
suite.addTestSuite(IgniteCacheTxInvokeTest.class);
+ suite.addTestSuite(CacheEntryProcessorNonSerializableTest.class);
suite.addTestSuite(IgniteCacheEntryProcessorCallTest.class);
GridTestUtils.addTestIfNeeded(suite, CacheEntryProcessorCopySelfTest.class, ignoredTests);
suite.addTestSuite(IgniteCacheTxNearEnabledInvokeTest.class);
[18/28] ignite git commit: IGNITE-3688: Fixed visiblity issue in
GridCacheIoManager.idxClsHandlers.
Posted by ak...@apache.org.
IGNITE-3688: Fixed visiblity issue in GridCacheIoManager.idxClsHandlers.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/278633ec
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/278633ec
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/278633ec
Branch: refs/heads/master
Commit: 278633eced6d8039b5be4a18eefe6c65650aba4f
Parents: 5cf3bea
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Mon Aug 15 14:27:22 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 14:27:22 2016 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheIoManager.java | 24 ++-
.../processors/cache/GridCacheMessage.java | 2 +-
.../dht/atomic/GridDhtAtomicCache.java | 176 ++++++++++++++-----
3 files changed, 155 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/278633ec/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index 488a22c..78dddd3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.processors.cache;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@@ -97,7 +98,7 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
private int retryCnt;
/** Indexed class handlers. */
- private Map<Integer, IgniteBiInClosure[]> idxClsHandlers = new HashMap<>();
+ private volatile Map<Integer, IgniteBiInClosure[]> idxClsHandlers = new HashMap<>();
/** Handler registry. */
private ConcurrentMap<ListenerKey, IgniteBiInClosure<UUID, GridCacheMessage>>
@@ -241,7 +242,9 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
IgniteBiInClosure<UUID, GridCacheMessage> c = null;
if (msgIdx >= 0) {
- IgniteBiInClosure[] cacheClsHandlers = idxClsHandlers.get(cacheMsg.cacheId());
+ Map<Integer, IgniteBiInClosure[]> idxClsHandlers0 = idxClsHandlers;
+
+ IgniteBiInClosure[] cacheClsHandlers = idxClsHandlers0.get(cacheMsg.cacheId());
if (cacheClsHandlers != null)
c = cacheClsHandlers[msgIdx];
@@ -262,12 +265,19 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
append(", cacheDesc=").append(cctx.cache().cacheDescriptor(cacheMsg.cacheId())).
append(']');
+ msg0.append(U.nl()).append("Registered listeners:");
+
+ Map<Integer, IgniteBiInClosure[]> idxClsHandlers0 = idxClsHandlers;
+
+ for (Map.Entry<Integer, IgniteBiInClosure[]> e : idxClsHandlers0.entrySet())
+ msg0.append(U.nl()).append(e.getKey()).append("=").append(Arrays.toString(e.getValue()));
+
if (cctx.kernalContext().isStopping()) {
if (log.isDebugEnabled())
log.debug(msg0.toString());
}
else
- U.warn(log, msg0.toString());
+ U.error(log, msg0.toString());
return;
}
@@ -1062,12 +1072,14 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
int msgIdx = messageIndex(type);
if (msgIdx != -1) {
- IgniteBiInClosure[] cacheClsHandlers = idxClsHandlers.get(cacheId);
+ Map<Integer, IgniteBiInClosure[]> idxClsHandlers0 = idxClsHandlers;
+
+ IgniteBiInClosure[] cacheClsHandlers = idxClsHandlers0.get(cacheId);
if (cacheClsHandlers == null) {
cacheClsHandlers = new IgniteBiInClosure[GridCacheMessage.MAX_CACHE_MSG_LOOKUP_INDEX];
- idxClsHandlers.put(cacheId, cacheClsHandlers);
+ idxClsHandlers0.put(cacheId, cacheClsHandlers);
}
if (cacheClsHandlers[msgIdx] != null)
@@ -1076,6 +1088,8 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
cacheClsHandlers[msgIdx] = c;
+ idxClsHandlers = idxClsHandlers0;
+
return;
}
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/278633ec/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
index f99d2cd..c5407b8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
@@ -50,7 +50,7 @@ public abstract class GridCacheMessage implements Message {
private static final long serialVersionUID = 0L;
/** Maximum number of cache lookup indexes. */
- public static final int MAX_CACHE_MSG_LOOKUP_INDEX = 256;
+ public static final int MAX_CACHE_MSG_LOOKUP_INDEX = 5;
/** Cache message index field name. */
public static final String CACHE_MSG_INDEX_FIELD_NAME = "CACHE_MSG_IDX";
http://git-wip-us.apache.org/repos/asf/ignite/blob/278633ec/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 3616082..1e45fa7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -251,61 +251,155 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
preldr.start();
- ctx.io().addHandler(ctx.cacheId(), GridNearGetRequest.class, new CI2<UUID, GridNearGetRequest>() {
- @Override public void apply(UUID nodeId, GridNearGetRequest req) {
- processNearGetRequest(nodeId, req);
- }
- });
+ ctx.io().addHandler(
+ ctx.cacheId(),
+ GridNearGetRequest.class,
+ new CI2<UUID, GridNearGetRequest>() {
+ @Override public void apply(
+ UUID nodeId,
+ GridNearGetRequest req
+ ) {
+ processNearGetRequest(
+ nodeId,
+ req);
+ }
+ });
- ctx.io().addHandler(ctx.cacheId(), GridNearSingleGetRequest.class, new CI2<UUID, GridNearSingleGetRequest>() {
- @Override public void apply(UUID nodeId, GridNearSingleGetRequest req) {
- processNearSingleGetRequest(nodeId, req);
- }
- });
+ ctx.io().addHandler(
+ ctx.cacheId(),
+ GridNearSingleGetRequest.class,
+ new CI2<UUID, GridNearSingleGetRequest>() {
+ @Override public void apply(
+ UUID nodeId,
+ GridNearSingleGetRequest req
+ ) {
+ processNearSingleGetRequest(
+ nodeId,
+ req);
+ }
+ });
- ctx.io().addHandler(ctx.cacheId(), GridNearAtomicUpdateRequest.class, new CI2<UUID, GridNearAtomicUpdateRequest>() {
- @Override public void apply(UUID nodeId, GridNearAtomicUpdateRequest req) {
- processNearAtomicUpdateRequest(nodeId, req);
- }
- });
+ ctx.io().addHandler(
+ ctx.cacheId(),
+ GridNearAtomicUpdateRequest.class,
+ new CI2<UUID, GridNearAtomicUpdateRequest>() {
+ @Override public void apply(
+ UUID nodeId,
+ GridNearAtomicUpdateRequest req
+ ) {
+ processNearAtomicUpdateRequest(
+ nodeId,
+ req);
+ }
- ctx.io().addHandler(ctx.cacheId(), GridNearAtomicUpdateResponse.class, new CI2<UUID, GridNearAtomicUpdateResponse>() {
- @Override public void apply(UUID nodeId, GridNearAtomicUpdateResponse res) {
- processNearAtomicUpdateResponse(nodeId, res);
- }
- });
+ @Override public String toString() {
+ return "GridNearAtomicUpdateRequest handler " +
+ "[msgIdx=" + GridNearAtomicUpdateRequest.CACHE_MSG_IDX + ']';
+ }
+ });
- ctx.io().addHandler(ctx.cacheId(), GridDhtAtomicUpdateRequest.class, new CI2<UUID, GridDhtAtomicUpdateRequest>() {
- @Override public void apply(UUID nodeId, GridDhtAtomicUpdateRequest req) {
- processDhtAtomicUpdateRequest(nodeId, req);
- }
- });
+ ctx.io().addHandler(ctx.cacheId(),
+ GridNearAtomicUpdateResponse.class,
+ new CI2<UUID, GridNearAtomicUpdateResponse>() {
+ @Override public void apply(
+ UUID nodeId,
+ GridNearAtomicUpdateResponse res
+ ) {
+ processNearAtomicUpdateResponse(
+ nodeId,
+ res);
+ }
- ctx.io().addHandler(ctx.cacheId(), GridDhtAtomicUpdateResponse.class, new CI2<UUID, GridDhtAtomicUpdateResponse>() {
- @Override public void apply(UUID nodeId, GridDhtAtomicUpdateResponse res) {
- processDhtAtomicUpdateResponse(nodeId, res);
- }
- });
+ @Override public String toString() {
+ return "GridNearAtomicUpdateResponse handler " +
+ "[msgIdx=" + GridNearAtomicUpdateResponse.CACHE_MSG_IDX + ']';
+ }
+ });
- ctx.io().addHandler(ctx.cacheId(), GridDhtAtomicDeferredUpdateResponse.class,
- new CI2<UUID, GridDhtAtomicDeferredUpdateResponse>() {
- @Override public void apply(UUID nodeId, GridDhtAtomicDeferredUpdateResponse res) {
- processDhtAtomicDeferredUpdateResponse(nodeId, res);
+ ctx.io().addHandler(
+ ctx.cacheId(),
+ GridDhtAtomicUpdateRequest.class,
+ new CI2<UUID, GridDhtAtomicUpdateRequest>() {
+ @Override public void apply(
+ UUID nodeId,
+ GridDhtAtomicUpdateRequest req
+ ) {
+ processDhtAtomicUpdateRequest(
+ nodeId,
+ req);
+ }
+
+ @Override public String toString() {
+ return "GridDhtAtomicUpdateRequest handler " +
+ "[msgIdx=" + GridDhtAtomicUpdateRequest.CACHE_MSG_IDX + ']';
}
});
- if (near == null) {
- ctx.io().addHandler(ctx.cacheId(), GridNearGetResponse.class, new CI2<UUID, GridNearGetResponse>() {
- @Override public void apply(UUID nodeId, GridNearGetResponse res) {
- processNearGetResponse(nodeId, res);
+ ctx.io().addHandler(
+ ctx.cacheId(),
+ GridDhtAtomicUpdateResponse.class,
+ new CI2<UUID, GridDhtAtomicUpdateResponse>() {
+ @Override public void apply(
+ UUID nodeId,
+ GridDhtAtomicUpdateResponse res
+ ) {
+ processDhtAtomicUpdateResponse(
+ nodeId,
+ res);
+ }
+
+ @Override public String toString() {
+ return "GridDhtAtomicUpdateResponse handler " +
+ "[msgIdx=" + GridDhtAtomicUpdateResponse.CACHE_MSG_IDX + ']';
}
});
- ctx.io().addHandler(ctx.cacheId(), GridNearSingleGetResponse.class, new CI2<UUID, GridNearSingleGetResponse>() {
- @Override public void apply(UUID nodeId, GridNearSingleGetResponse res) {
- processNearSingleGetResponse(nodeId, res);
+ ctx.io().addHandler(ctx.cacheId(),
+ GridDhtAtomicDeferredUpdateResponse.class,
+ new CI2<UUID, GridDhtAtomicDeferredUpdateResponse>() {
+ @Override public void apply(
+ UUID nodeId,
+ GridDhtAtomicDeferredUpdateResponse res
+ ) {
+ processDhtAtomicDeferredUpdateResponse(
+ nodeId,
+ res);
+ }
+
+ @Override public String toString() {
+ return "GridDhtAtomicDeferredUpdateResponse handler " +
+ "[msgIdx=" + GridDhtAtomicDeferredUpdateResponse.CACHE_MSG_IDX + ']';
}
});
+
+ if (near == null) {
+ ctx.io().addHandler(
+ ctx.cacheId(),
+ GridNearGetResponse.class,
+ new CI2<UUID, GridNearGetResponse>() {
+ @Override public void apply(
+ UUID nodeId,
+ GridNearGetResponse res
+ ) {
+ processNearGetResponse(
+ nodeId,
+ res);
+ }
+ });
+
+ ctx.io().addHandler(
+ ctx.cacheId(),
+ GridNearSingleGetResponse.class,
+ new CI2<UUID, GridNearSingleGetResponse>() {
+ @Override public void apply(
+ UUID nodeId,
+ GridNearSingleGetResponse res
+ ) {
+ processNearSingleGetResponse(
+ nodeId,
+ res);
+ }
+ });
}
}
[13/28] ignite git commit: Merge branch 'ignite-1.6.5' into
ignite-1.7.2
Posted by ak...@apache.org.
Merge branch 'ignite-1.6.5' into ignite-1.7.2
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1de9c0f4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1de9c0f4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1de9c0f4
Branch: refs/heads/master
Commit: 1de9c0f43c238cb0dc150a0aea0500fdf6396d68
Parents: 7307d8d f5a040a
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Aug 15 13:38:21 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 13:38:21 2016 +0300
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 10 +
.../internal/binary/BinaryClassDescriptor.java | 43 ++-
.../ignite/internal/binary/BinaryContext.java | 21 +-
.../binary/BinaryMethodWriteReplacer.java | 59 ++++
.../ignite/internal/binary/BinaryTreeMap.java | 96 ++++++
.../binary/BinaryTreeMapWriteReplacer.java | 34 ++
.../ignite/internal/binary/BinaryTreeSet.java | 93 +++++
.../binary/BinaryTreeSetWriteReplacer.java | 34 ++
.../ignite/internal/binary/BinaryUtils.java | 37 +-
.../internal/binary/BinaryWriteReplacer.java | 33 ++
.../internal/binary/BinaryWriterExImpl.java | 35 +-
.../binary/CacheObjectBinaryProcessorImpl.java | 19 ++
.../internal/binary/BinaryTreeSelfTest.java | 341 +++++++++++++++++++
.../IgniteBinaryObjectsTestSuite.java | 2 +
.../ClientReconnectAfterClusterRestartTest.java | 225 ++++++++++++
...eLockPartitionOnAffinityRunAbstractTest.java | 17 +
.../IgniteCacheWithIndexingTestSuite.java | 5 +-
17 files changed, 1062 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1de9c0f4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1de9c0f4/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunAbstractTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1de9c0f4/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
----------------------------------------------------------------------
diff --cc modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
index a264a2f,4528b30..7949214
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
@@@ -21,9 -21,9 +21,10 @@@ import junit.framework.TestSuite
import org.apache.ignite.internal.processors.cache.CacheBinaryKeyConcurrentQueryTest;
import org.apache.ignite.internal.processors.cache.CacheConfigurationP2PTest;
import org.apache.ignite.internal.processors.cache.CacheIndexStreamerTest;
+import org.apache.ignite.internal.processors.cache.CacheIndexingOffheapCleanupTest;
import org.apache.ignite.internal.processors.cache.CacheOperationsWithExpirationTest;
import org.apache.ignite.internal.processors.cache.CacheRandomOperationsMultithreadedTest;
+ import org.apache.ignite.internal.processors.cache.ClientReconnectAfterClusterRestartTest;
import org.apache.ignite.internal.processors.cache.GridCacheOffHeapAndSwapSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheOffHeapSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheOffheapIndexEntryEvictTest;
@@@ -79,8 -79,9 +80,10 @@@ public class IgniteCacheWithIndexingTes
suite.addTestSuite(IgniteCacheStarvationOnRebalanceTest.class);
suite.addTestSuite(CacheOperationsWithExpirationTest.class);
suite.addTestSuite(CacheBinaryKeyConcurrentQueryTest.class);
+ suite.addTestSuite(CacheIndexingOffheapCleanupTest.class);
+ suite.addTestSuite(ClientReconnectAfterClusterRestartTest.class);
+
return suite;
}
- }
+ }
[06/28] ignite git commit: IGNITE-826: Removed
HadoopHashMapSelfTest.testAllocation() as it tested nothing.
Posted by ak...@apache.org.
IGNITE-826: Removed HadoopHashMapSelfTest.testAllocation() as it tested nothing.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f87ca482
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f87ca482
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f87ca482
Branch: refs/heads/master
Commit: f87ca482420fc1e6ffcb000a227717142d24e270
Parents: 78aa065
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Jul 21 13:15:41 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 12:30:01 2016 +0300
----------------------------------------------------------------------
.../shuffle/collections/HadoopHashMapSelfTest.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f87ca482/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopHashMapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopHashMapSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopHashMapSelfTest.java
index c0f8325..04585ec 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopHashMapSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopHashMapSelfTest.java
@@ -19,12 +19,6 @@ package org.apache.ignite.internal.processors.hadoop.shuffle.collections;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.Callable;
import org.apache.hadoop.io.IntWritable;
import org.apache.ignite.internal.processors.hadoop.HadoopTaskContext;
import org.apache.ignite.internal.processors.hadoop.HadoopTaskInput;
@@ -32,6 +26,12 @@ import org.apache.ignite.internal.util.GridLongList;
import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
import org.apache.ignite.internal.util.typedef.X;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Random;
+
/**
*
*/
[14/28] ignite git commit: IGNITE-1926: IGFS: Implemented local
secondary file system.
Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemTestAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemTestAdapter.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemTestAdapter.java
new file mode 100644
index 0000000..12714c4
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemTestAdapter.java
@@ -0,0 +1,141 @@
+/*
+ * 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.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.util.Map;
+
+/**
+ * Adapter for local secondary file system.
+ */
+public class IgfsLocalSecondaryFileSystemTestAdapter implements IgfsSecondaryFileSystemTestAdapter {
+ /** */
+ private final String workDir;
+
+ /**
+ * @param workDir Work dir.
+ */
+ public IgfsLocalSecondaryFileSystemTestAdapter(final File workDir) {
+ this.workDir = workDir.getAbsolutePath();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() throws IOException {
+ return "local";
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean exists(final String path) throws IOException {
+ return Files.exists(path(path));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean delete(final String path, final boolean recursive) throws IOException {
+ if (recursive)
+ return deleteRecursively(path(path));
+ else
+ return path(path).toFile().delete();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void mkdirs(final String path) throws IOException {
+ Files.createDirectory(path(path));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void format() throws IOException {
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(workDir))) {
+ for (Path innerPath : stream)
+ deleteRecursively(innerPath);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<String, String> properties(final String path) throws IOException {
+ throw new UnsupportedOperationException("properties");
+ }
+
+ /** {@inheritDoc} */
+ @Override public String permissions(String path) throws IOException {
+ throw new UnsupportedOperationException("permissions");
+ }
+
+ /** {@inheritDoc} */
+ @Override public InputStream openInputStream(final String path) throws IOException {
+ return Files.newInputStream(path(path));
+ }
+
+ /** {@inheritDoc} */
+ @Override public OutputStream openOutputStream(final String path, final boolean append) throws IOException {
+ if (append)
+ return Files.newOutputStream(path(path), StandardOpenOption.APPEND);
+ else
+ return Files.newOutputStream(path(path));
+ }
+
+ /** {@inheritDoc} */
+ @Override public T2<Long, Long> times(String path) throws IOException {
+ throw new UnsupportedOperationException("times");
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEx igfs() {
+ return null;
+ }
+
+ /**
+ * Convert path.
+ *
+ * @param path String path.
+ * @return Java File API path.
+ */
+ private Path path(String path) {
+ return Paths.get(workDir + path);
+ }
+
+ /**
+ * Delete recursively.
+ *
+ * @param path Path.
+ * @throws IOException If failed.
+ */
+ private boolean deleteRecursively(Path path) throws IOException {
+ if (Files.isDirectory(path)) {
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
+ for (Path innerPath : stream) {
+ boolean res = deleteRecursively(innerPath);
+
+ if (!res)
+ return false;
+ }
+ }
+ }
+
+ return path.toFile().delete();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/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..fe913df
--- /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 On failure.
+ */
+ 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/5cf3bea3/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/5cf3bea3/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
index dc1379f..44199d4 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
@@ -56,6 +56,10 @@ import org.apache.ignite.internal.processors.igfs.IgfsSizeSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsStartCacheTest;
import org.apache.ignite.internal.processors.igfs.IgfsStreamsSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsTaskSelfTest;
+import org.apache.ignite.internal.processors.igfs.IgfsLocalSecondaryFileSystemDualAsyncClientSelfTest;
+import org.apache.ignite.internal.processors.igfs.IgfsLocalSecondaryFileSystemDualAsyncSelfTest;
+import org.apache.ignite.internal.processors.igfs.IgfsLocalSecondaryFileSystemDualSyncClientSelfTest;
+import org.apache.ignite.internal.processors.igfs.IgfsLocalSecondaryFileSystemDualSyncSelfTest;
import org.apache.ignite.internal.processors.igfs.split.IgfsByteDelimiterRecordResolverSelfTest;
import org.apache.ignite.internal.processors.igfs.split.IgfsFixedLengthRecordResolverSelfTest;
import org.apache.ignite.internal.processors.igfs.split.IgfsNewLineDelimiterRecordResolverSelfTest;
@@ -88,6 +92,11 @@ public class IgniteIgfsTestSuite extends TestSuite {
suite.addTest(new TestSuite(IgfsDualSyncSelfTest.class));
suite.addTest(new TestSuite(IgfsDualAsyncSelfTest.class));
+ suite.addTest(new TestSuite(IgfsLocalSecondaryFileSystemDualSyncSelfTest.class));
+ suite.addTest(new TestSuite(IgfsLocalSecondaryFileSystemDualAsyncSelfTest.class));
+ suite.addTest(new TestSuite(IgfsLocalSecondaryFileSystemDualSyncClientSelfTest.class));
+ suite.addTest(new TestSuite(IgfsLocalSecondaryFileSystemDualAsyncClientSelfTest.class));
+
suite.addTest(new TestSuite(IgfsSizeSelfTest.class));
suite.addTest(new TestSuite(IgfsAttributesSelfTest.class));
suite.addTest(new TestSuite(IgfsFileInfoSelfTest.class));
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/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} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
index 6b83a3e..2c25a06 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
@@ -27,7 +27,6 @@ import org.apache.ignite.hadoop.util.KerberosUserNameMapper;
import org.apache.ignite.hadoop.util.UserNameMapper;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
import org.apache.ignite.internal.processors.igfs.IgfsDualAbstractSelfTest;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.lifecycle.LifecycleAware;
import org.jetbrains.annotations.Nullable;
@@ -101,7 +100,7 @@ public abstract class Hadoop1DualAbstractTest extends IgfsDualAbstractSelfTest {
second.setFileSystemFactory(factory);
- igfsSecondary = new HadoopFileSystemUniversalFileSystemAdapter(factory);
+ igfsSecondary = new HadoopIgfsSecondaryFileSystemTestAdapter(factory);
return second;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/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
deleted file mode 100644
index 5239054..0000000
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
+++ /dev/null
@@ -1,139 +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.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.permission.FsPermission;
-import org.apache.ignite.configuration.FileSystemConfiguration;
-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.
- */
-public class HadoopFileSystemUniversalFileSystemAdapter implements UniversalFileSystemAdapter {
- /** File system factory. */
- private final HadoopFileSystemFactory factory;
-
- /**
- * Constructor.
- * @param factory File system factory.
- */
- public HadoopFileSystemUniversalFileSystemAdapter(HadoopFileSystemFactory factory) {
- assert factory != null;
-
- this.factory = factory;
- }
-
- /** {@inheritDoc} */
- @Override public String name() throws IOException {
- return get().getUri().toString();
- }
-
- /** {@inheritDoc} */
- @Override public boolean exists(String path) throws IOException {
- return get().exists(new Path(path));
- }
-
- /** {@inheritDoc} */
- @Override public boolean delete(String path, boolean recursive) throws IOException {
- return get().delete(new Path(path), recursive);
- }
-
- /** {@inheritDoc} */
- @Override public void mkdirs(String path) throws IOException {
- boolean ok = get().mkdirs(new Path(path));
- if (!ok)
- throw new IOException("Failed to mkdirs: " + path);
- }
-
- /** {@inheritDoc} */
- @Override public void format() throws IOException {
- HadoopIgfsUtils.clear(get());
- }
-
- /** {@inheritDoc} */
- @Override public Map<String, String> properties(String path) throws IOException {
- Path p = new Path(path);
-
- FileStatus status = get().getFileStatus(p);
-
- Map<String,String> m = new HashMap<>(3); // max size == 4
-
- m.put(IgfsUtils.PROP_USER_NAME, status.getOwner());
- m.put(IgfsUtils.PROP_GROUP_NAME, status.getGroup());
-
- FsPermission perm = status.getPermission();
-
- m.put(IgfsUtils.PROP_PERMISSION, "0" + perm.getUserAction().ordinal() + perm.getGroupAction().ordinal() +
- perm.getOtherAction().ordinal());
-
- return m;
- }
-
- /** {@inheritDoc} */
- @Override public InputStream openInputStream(String path) throws IOException {
- return get().open(new Path(path));
- }
-
- /** {@inheritDoc} */
- @Override public OutputStream openOutputStream(String path, boolean append) throws IOException {
- Path p = new Path(path);
-
- if (append)
- return get().append(p);
- else
- return get().create(p, true/*overwrite*/);
- }
-
- /** {@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))
- return (T)factory;
-
- return null;
- }
-
- /**
- * Create file system.
- *
- * @return File system.
- * @throws IOException If failed.
- */
- private FileSystem get() throws IOException {
- return factory.get(FileSystemConfiguration.DFLT_USER_NAME);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5cf3bea3/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsSecondaryFileSystemTestAdapter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsSecondaryFileSystemTestAdapter.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsSecondaryFileSystemTestAdapter.java
new file mode 100644
index 0000000..f7af6f0
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsSecondaryFileSystemTestAdapter.java
@@ -0,0 +1,149 @@
+/*
+ * 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.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.ignite.configuration.FileSystemConfiguration;
+import org.apache.ignite.hadoop.fs.HadoopFileSystemFactory;
+import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsUtils;
+import org.apache.ignite.internal.processors.igfs.IgfsEx;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
+import org.apache.ignite.internal.processors.igfs.IgfsSecondaryFileSystemTestAdapter;
+import org.apache.ignite.internal.util.typedef.T2;
+
+/**
+ * Universal adapter wrapping {@link org.apache.hadoop.fs.FileSystem} instance.
+ */
+public class HadoopIgfsSecondaryFileSystemTestAdapter implements IgfsSecondaryFileSystemTestAdapter {
+ /** File system factory. */
+ private final HadoopFileSystemFactory factory;
+
+ /**
+ * Constructor.
+ * @param factory File system factory.
+ */
+ public HadoopIgfsSecondaryFileSystemTestAdapter(HadoopFileSystemFactory factory) {
+ assert factory != null;
+
+ this.factory = factory;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() throws IOException {
+ return get().getUri().toString();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean exists(String path) throws IOException {
+ return get().exists(new Path(path));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean delete(String path, boolean recursive) throws IOException {
+ return get().delete(new Path(path), recursive);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void mkdirs(String path) throws IOException {
+ boolean ok = get().mkdirs(new Path(path));
+ if (!ok)
+ throw new IOException("Failed to mkdirs: " + path);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void format() throws IOException {
+ HadoopIgfsUtils.clear(get());
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<String, String> properties(String path) throws IOException {
+ Path p = new Path(path);
+
+ FileStatus status = get().getFileStatus(p);
+
+ Map<String,String> m = new HashMap<>(3);
+
+ m.put(IgfsUtils.PROP_USER_NAME, status.getOwner());
+ m.put(IgfsUtils.PROP_GROUP_NAME, status.getGroup());
+ m.put(IgfsUtils.PROP_PERMISSION, permission(status));
+
+ return m;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String permissions(String path) throws IOException {
+ return permission(get().getFileStatus(new Path(path)));
+ }
+
+ /**
+ * Get permission for file status.
+ *
+ * @param status Status.
+ * @return Permission.
+ */
+ private String permission(FileStatus status) {
+ FsPermission perm = status.getPermission();
+
+ return "0" + perm.getUserAction().ordinal() + perm.getGroupAction().ordinal() + perm.getOtherAction().ordinal();
+ }
+
+ /** {@inheritDoc} */
+ @Override public InputStream openInputStream(String path) throws IOException {
+ return get().open(new Path(path));
+ }
+
+ /** {@inheritDoc} */
+ @Override public OutputStream openOutputStream(String path, boolean append) throws IOException {
+ Path p = new Path(path);
+
+ if (append)
+ return get().append(p);
+ else
+ return get().create(p, true/*overwrite*/);
+ }
+
+ /** {@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} */
+ @Override public IgfsEx igfs() {
+ return null;
+ }
+
+ /**
+ * Create file system.
+ *
+ * @return File system.
+ * @throws IOException If failed.
+ */
+ protected FileSystem get() throws IOException {
+ return factory.get(FileSystemConfiguration.DFLT_USER_NAME);
+ }
+}
\ No newline at end of file
[24/28] ignite git commit: Fixed NPE in special case.
Posted by ak...@apache.org.
Fixed NPE in special case.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9db16d1b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9db16d1b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9db16d1b
Branch: refs/heads/master
Commit: 9db16d1b2a23e703546c472676620139e82e747f
Parents: a20ca35
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Fri Aug 19 17:40:30 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Aug 19 17:40:30 2016 +0700
----------------------------------------------------------------------
.../visor/cache/VisorCacheTypeMetadata.java | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9db16d1b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
index 4e38d81..870e033 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
@@ -134,21 +134,25 @@ public class VisorCacheTypeMetadata implements Serializable, LessNamingBean {
JdbcTypeField[] keyFields = jdbcType.getKeyFields();
- meta.keyFields = new ArrayList<>(keyFields.length);
+ if (keyFields != null) {
+ meta.keyFields = new ArrayList<>(keyFields.length);
- for (JdbcTypeField fld : keyFields)
- meta.keyFields.add(new VisorCacheTypeFieldMetadata(
- fld.getDatabaseFieldName(), fld.getDatabaseFieldType(),
- fld.getDatabaseFieldName(), U.compact(fld.getJavaFieldType().getName())));
+ for (JdbcTypeField fld : keyFields)
+ meta.keyFields.add(new VisorCacheTypeFieldMetadata(
+ fld.getDatabaseFieldName(), fld.getDatabaseFieldType(),
+ fld.getDatabaseFieldName(), U.compact(fld.getJavaFieldType().getName())));
+ }
JdbcTypeField[] valFields = jdbcType.getValueFields();
- meta.valFields = new ArrayList<>(valFields.length);
+ if (valFields != null) {
+ meta.valFields = new ArrayList<>(valFields.length);
- for (JdbcTypeField fld : valFields)
- meta.valFields.add(new VisorCacheTypeFieldMetadata(
+ for (JdbcTypeField fld : valFields)
+ meta.valFields.add(new VisorCacheTypeFieldMetadata(
fld.getDatabaseFieldName(), fld.getDatabaseFieldType(),
fld.getDatabaseFieldName(), U.compact(fld.getJavaFieldType().getName())));
+ }
if (notFound)
metas.add(meta);
[11/28] ignite git commit: IGNITE-3631: IGFS: Now metadata
co-location is used for PARTITIONED cache as well.
Posted by ak...@apache.org.
IGNITE-3631: IGFS: Now metadata co-location is used for PARTITIONED cache as well.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4d876a75
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4d876a75
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4d876a75
Branch: refs/heads/master
Commit: 4d876a7560060c892908da447178e97bfe12ca9c
Parents: 970137b
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Aug 5 15:05:43 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 12:31:24 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/processors/igfs/IgfsUtils.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4d876a75/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 3a313ad..3d86fbb 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
@@ -17,13 +17,11 @@
package org.apache.ignite.internal.processors.igfs;
-import java.util.Set;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.binary.BinaryRawReader;
import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.cluster.ClusterTopologyException;
@@ -32,8 +30,8 @@ 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.IgfsMode;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.binary.BinaryUtils;
@@ -61,6 +59,7 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
[09/28] ignite git commit: IGNITE-3331 IGFS: Route client tasks to
primary node when metadata co-location is enabled. This closes #921.
Posted by ak...@apache.org.
IGNITE-3331 IGFS: Route client tasks to primary node when metadata co-location is enabled. This closes #921.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ae54e36f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ae54e36f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ae54e36f
Branch: refs/heads/master
Commit: ae54e36f27719f46d1d276f62a977c3f8d053b44
Parents: dc81069
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Thu Aug 4 17:04:41 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 12:31:06 2016 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsMetaManager.java | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ae54e36f/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 0d14a3a..d1151c5 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
@@ -248,7 +248,25 @@ public class IgfsMetaManager extends IgfsManager {
*/
<T> T runClientTask(IgfsClientAbstractCallable<T> task) {
try {
- return clientCompute().call(task);
+ return runClientTask(IgfsUtils.ROOT_ID, task);
+ }
+ catch (ClusterTopologyException e) {
+ throw new IgfsException("Failed to execute operation because there are no IGFS metadata nodes." , e);
+ }
+ }
+
+ /**
+ * Run client task.
+ *
+ * @param affinityFileId Affinity fileId.
+ * @param task Task.
+ * @return Result.
+ */
+ <T> T runClientTask(IgniteUuid affinityFileId, IgfsClientAbstractCallable<T> task) {
+ try {
+ return (cfg.isColocateMetadata()) ?
+ clientCompute().affinityCall(cfg.getMetaCacheName(), affinityFileId, task) :
+ clientCompute().call(task);
}
catch (ClusterTopologyException e) {
throw new IgfsException("Failed to execute operation because there are no IGFS metadata nodes." , e);
[10/28] ignite git commit: IGNITE-3631: IGFS: Now metadata
co-location is used for PARTITIONED cache as well.
Posted by ak...@apache.org.
IGNITE-3631: IGFS: Now metadata co-location is used for PARTITIONED cache as well.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/970137b1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/970137b1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/970137b1
Branch: refs/heads/master
Commit: 970137b1db7dc6c5e546581e22e428ae15c86513
Parents: ae54e36
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Aug 5 15:05:32 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 15 12:31:14 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/processors/igfs/IgfsUtils.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/970137b1/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 b9788f8..3a313ad 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
@@ -376,8 +376,7 @@ public class IgfsUtils {
ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
// Set co-located affinity mapper if needed.
- if (igfsCfg.isColocateMetadata() && ccfg.getCacheMode() == CacheMode.REPLICATED &&
- ccfg.getAffinityMapper() == null)
+ if (igfsCfg.isColocateMetadata() && ccfg.getAffinityMapper() == null)
ccfg.setAffinityMapper(new IgfsColocatedMetadataAffinityKeyMapper());
return;