You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by nt...@apache.org on 2016/02/26 10:22:02 UTC
[01/13] ignite git commit: Fixed assertion in optimized marshaller
Repository: ignite
Updated Branches:
refs/heads/ignite-1186 c2b381ffe -> 2537d797f
Fixed assertion in optimized marshaller
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/91177201
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/91177201
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/91177201
Branch: refs/heads/ignite-1186
Commit: 91177201c808c6e48b94e8ad81a77b50db7e1298
Parents: faa77e2
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Feb 24 16:06:03 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Feb 24 16:06:03 2016 -0800
----------------------------------------------------------------------
.../marshaller/optimized/OptimizedObjectStreamRegistry.java | 8 ++------
.../optimized/OptimizedMarshallerPooledSelfTest.java | 8 ++++++++
2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/91177201/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java
index 8fde4c3..cf92d27 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java
@@ -92,9 +92,7 @@ class OptimizedObjectStreamRegistry {
StreamHolder holder = holders.get();
- assert holder != null;
-
- if (holder.releaseOut() && pool != null) {
+ if (holder != null && holder.releaseOut() && pool != null) {
holders.set(null);
boolean b = pool.offer(holder);
@@ -114,9 +112,7 @@ class OptimizedObjectStreamRegistry {
StreamHolder holder = holders.get();
- assert holder != null;
-
- if (holder.releaseIn() && pool != null) {
+ if (holder != null && holder.releaseIn() && pool != null) {
holders.set(null);
boolean b = pool.offer(holder);
http://git-wip-us.apache.org/repos/asf/ignite/blob/91177201/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java
index fc77029..c649787 100644
--- a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java
@@ -33,4 +33,12 @@ public class OptimizedMarshallerPooledSelfTest extends OptimizedMarshallerSelfTe
return m;
}
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ // Reset static registry.
+ new OptimizedMarshaller().setPoolSize(-1);
+ }
}
[12/13] ignite git commit: IGNITE-1186 Fixed test.
Posted by nt...@apache.org.
IGNITE-1186 Fixed test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b6b93908
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b6b93908
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b6b93908
Branch: refs/heads/ignite-1186
Commit: b6b939085d03acdc223c7e986954db1cf7e4f472
Parents: c2b381f
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Fri Feb 26 12:16:36 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Fri Feb 26 12:16:36 2016 +0300
----------------------------------------------------------------------
.../GridCacheReplicatedPreloadSelfTest.java | 40 +++++++++++++-------
1 file changed, 27 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b6b93908/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
index 7508e3d..ec4efbc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
@@ -30,6 +30,7 @@ import java.util.concurrent.CountDownLatch;
import javax.cache.configuration.CacheEntryListenerConfiguration;
import javax.cache.configuration.Factory;
import javax.cache.configuration.MutableCacheEntryListenerConfiguration;
+import javax.cache.event.CacheEntryEventFilter;
import javax.cache.event.CacheEntryListener;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
@@ -44,7 +45,6 @@ import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.Event;
-import org.apache.ignite.events.EventAdapter;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
@@ -393,18 +393,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
}
}
},
- new Factory<CacheEntryEventSerializableFilter<Integer, Object>>() {
- /** {@inheritDoc} */
- @Override public CacheEntryEventSerializableFilter<Integer, Object> create() {
- try {
-
- return cls2.newInstance();
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- },
+ new ClassFilterFactory(cls2),
true,
true
);
@@ -936,4 +925,29 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
return true;
}
}
+
+ /**
+ *
+ */
+ private static class ClassFilterFactory implements Factory<CacheEntryEventFilter<Integer, Object>> {
+ /** */
+ private Class<CacheEntryEventSerializableFilter> cls;
+
+ /**
+ * @param cls Class.
+ */
+ public ClassFilterFactory(Class<CacheEntryEventSerializableFilter> cls) {
+ this.cls = cls;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheEntryEventSerializableFilter<Integer, Object> create() {
+ try {
+ return cls.newInstance();
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
}
[10/13] ignite git commit: IGNITE-2450 - More fixes for Proxy
serialization
Posted by nt...@apache.org.
IGNITE-2450 - More fixes for Proxy serialization
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e1176fda
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e1176fda
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e1176fda
Branch: refs/heads/ignite-1186
Commit: e1176fda8c07e0839952f2b740c2327c125ec37d
Parents: 53fe993
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Thu Feb 25 16:34:03 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Thu Feb 25 16:34:03 2016 -0800
----------------------------------------------------------------------
.../ignite/internal/binary/BinaryUtils.java | 7 +-
...namicProxySerializationMultiJvmSelfTest.java | 106 +++++++++++++++----
2 files changed, 89 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1176fda/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 d5b0854..4a79f22 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
@@ -584,7 +584,9 @@ public class BinaryUtils {
public static boolean isBinaryType(Class<?> cls) {
assert cls != null;
- return BinaryObject.class.isAssignableFrom(cls) || BINARY_CLS.contains(cls);
+ return BinaryObject.class.isAssignableFrom(cls) ||
+ Proxy.class.isAssignableFrom(cls) ||
+ BINARY_CLS.contains(cls);
}
/**
@@ -1758,6 +1760,9 @@ public class BinaryUtils {
case GridBinaryMarshaller.CLASS:
return doReadClass(in, ctx, ldr);
+ case GridBinaryMarshaller.PROXY:
+ return doReadProxy(in, ctx, ldr, handles);
+
case GridBinaryMarshaller.OPTM_MARSH:
return doReadOptimized(in, ctx, ldr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e1176fda/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java
index d22aeac..0400de4 100644
--- a/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java
@@ -22,6 +22,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.concurrent.Callable;
import org.apache.ignite.Ignite;
+import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.lang.IgniteCallable;
@@ -49,68 +50,111 @@ public class DynamicProxySerializationMultiJvmSelfTest extends GridCommonAbstrac
return cfg;
}
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
/**
* @throws Exception If failed.
*/
- public void testOptimized() throws Exception {
+ public void testOptimizedMarshaller() throws Exception {
marshFactory = new Callable<Marshaller>() {
@Override public Marshaller call() throws Exception {
return new OptimizedMarshaller(false);
}
};
- doTest();
+ doTestMarshaller();
}
/**
* @throws Exception If failed.
*/
- public void testBinary() throws Exception {
+ public void testBinaryMarshaller() throws Exception {
marshFactory = new Callable<Marshaller>() {
@Override public Marshaller call() throws Exception {
return new BinaryMarshaller();
}
};
- doTest();
+ doTestMarshaller();
}
/**
* @throws Exception If failed.
*/
- private void doTest() throws Exception {
- try {
- Ignite ignite = startGrids(2);
+ public void testToBinary() throws Exception {
+ marshFactory = new Callable<Marshaller>() {
+ @Override public Marshaller call() throws Exception {
+ return new BinaryMarshaller();
+ }
+ };
- MyProxy p = (MyProxy)Proxy.newProxyInstance(getClass().getClassLoader(),
- new Class[] { MyProxy.class }, new InvocationHandler() {
- @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- if ("value".equals(method.getName()))
- return 42;
+ Ignite ignite = startGrid(0);
- throw new IllegalStateException();
- }
- });
+ MyProxy p = create();
- int val = ignite.compute(ignite.cluster().forRemotes()).call(new MyCallable(p));
+ MyProxy p0 = ignite.binary().toBinary(p);
- assertEquals(42, val);
- }
- finally {
- stopAllGrids();
- }
+ assertSame(p, p0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBinaryField() throws Exception {
+ marshFactory = new Callable<Marshaller>() {
+ @Override public Marshaller call() throws Exception {
+ return new BinaryMarshaller();
+ }
+ };
+
+ Ignite ignite = startGrids(2);
+
+ BinaryObject bo = ignite.binary().builder("ProxyWrapper").setField("proxy", create()).build();
+
+ int val = ignite.compute(ignite.cluster().forRemotes()).call(new FieldTestCallable(bo));
+
+ assertEquals(42, val);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void doTestMarshaller() throws Exception {
+ Ignite ignite = startGrids(2);
+
+ int val = ignite.compute(ignite.cluster().forRemotes()).call(new MarshallerTestCallable(create()));
+
+ assertEquals(42, val);
+ }
+
+ /**
+ * @return New proxy.
+ */
+ private static MyProxy create() {
+ return (MyProxy)Proxy.newProxyInstance(DynamicProxySerializationMultiJvmSelfTest.class.getClassLoader(),
+ new Class[] { MyProxy.class }, new InvocationHandler() {
+ @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if ("value".equals(method.getName()))
+ return 42;
+
+ throw new IllegalStateException();
+ }
+ });
}
/**
*/
- private static class MyCallable implements IgniteCallable<Integer> {
+ private static class MarshallerTestCallable implements IgniteCallable<Integer> {
/** */
private final MyProxy p;
/**
* @param p Proxy.
*/
- public MyCallable(MyProxy p) {
+ public MarshallerTestCallable(MyProxy p) {
this.p = p;
}
@@ -122,6 +166,22 @@ public class DynamicProxySerializationMultiJvmSelfTest extends GridCommonAbstrac
/**
*/
+ private static class FieldTestCallable implements IgniteCallable<Integer> {
+ /** */
+ private final BinaryObject bo;
+
+ public FieldTestCallable(BinaryObject bo) {
+ this.bo = bo;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer call() throws Exception {
+ return bo.<MyProxy>field("proxy").value();
+ }
+ }
+
+ /**
+ */
private static interface MyProxy {
/**
* @return Value.
[08/13] ignite git commit: IGNITE-2352: IGFS: Correct access time and
modification time propagation from secondary file system. This closes #501.
Posted by nt...@apache.org.
IGNITE-2352: IGFS: Correct access time and modification time propagation from secondary file system. This closes #501.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/52e178f6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/52e178f6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/52e178f6
Branch: refs/heads/ignite-1186
Commit: 52e178f6e0c3ca5930713c69b34364994ad0ccfe
Parents: dee6190
Author: iveselovskiy <iv...@gridgain.com>
Authored: Thu Feb 25 14:38:22 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Feb 25 14:38:22 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsFileImpl.java | 23 ++++++
.../internal/processors/igfs/IgfsFileInfo.java | 54 +++++++-------
.../internal/processors/igfs/IgfsImpl.java | 23 +++---
.../processors/igfs/IgfsMetaManager.java | 23 ++++--
.../igfs/IgfsDataManagerSelfTest.java | 24 +++++--
.../igfs/IgfsDualAbstractSelfTest.java | 74 +++++++++++++++++++-
.../processors/igfs/IgfsFileInfoSelfTest.java | 11 ++-
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 7 +-
8 files changed, 179 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/52e178f6/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 5d7389b..4a96e81 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
@@ -70,6 +70,29 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable {
}
/**
+ * A copy constructor. All the fields are copied from the copied {@code igfsFile}, but the {@code groupBlockSize}
+ * which is specified separately.
+ *
+ * @param igfsFile The file to copy.
+ */
+ public IgfsFileImpl(IgfsFile igfsFile, long grpBlockSize) {
+ A.notNull(igfsFile, "igfsFile");
+
+ this.path = igfsFile.path();
+ this.fileId = igfsFile instanceof IgfsFileImpl ? ((IgfsFileImpl)igfsFile).fileId : IgniteUuid.randomUuid();
+
+ this.blockSize = igfsFile.blockSize();
+ this.len = igfsFile.length();
+
+ this.grpBlockSize = igfsFile.isFile() ? grpBlockSize : 0L;
+
+ this.props = igfsFile.properties();
+
+ this.accessTime = igfsFile.accessTime();
+ this.modificationTime = igfsFile.modificationTime();
+ }
+
+ /**
* Constructs directory info.
*
* @param path Path.
http://git-wip-us.apache.org/repos/asf/ignite/blob/52e178f6/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
index fa79d80..a69920b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
@@ -47,6 +47,9 @@ public final class IgfsFileInfo implements Externalizable {
/** ID of the trash directory. */
public static final IgniteUuid TRASH_ID = new IgniteUuid(new UUID(0, 1), 0);
+ /** Special access time value, indicating that the modification time value should be taken. */
+ private static final long ACCESS_TIME_TAKE_MODIFICATION_TIME = -1L;
+
/** Info ID. */
private IgniteUuid id;
@@ -100,18 +103,22 @@ public final class IgfsFileInfo implements Externalizable {
* @param id ID.
*/
IgfsFileInfo(IgniteUuid id) {
- this(true, id, 0, 0, null, null, null, null, false, System.currentTimeMillis(), false);
+ this(true, id, 0, 0, null, null, null, null, false, ACCESS_TIME_TAKE_MODIFICATION_TIME,
+ System.currentTimeMillis(), false);
}
/**
- * Constructs directory or file info with {@link org.apache.ignite.configuration.FileSystemConfiguration#DFLT_BLOCK_SIZE default} block size.
+ * Constructs directory or file info with
+ * {@link org.apache.ignite.configuration.FileSystemConfiguration#DFLT_BLOCK_SIZE default} block size.
*
* @param isDir Constructs directory info if {@code true} or file info if {@code false}.
* @param props Meta properties to set.
+ * @param accessTime The access time.
+ * @param modificationTime The modification time.
*/
- public IgfsFileInfo(boolean isDir, @Nullable Map<String, String> props) {
+ public IgfsFileInfo(boolean isDir, @Nullable Map<String, String> props, long accessTime, long modificationTime) {
this(isDir, null, isDir ? 0 : FileSystemConfiguration.DFLT_BLOCK_SIZE, 0, null, null, props, null, false,
- System.currentTimeMillis(), false);
+ accessTime, modificationTime, false);
}
/**
@@ -120,7 +127,7 @@ public final class IgfsFileInfo implements Externalizable {
* @param listing Listing.
*/
IgfsFileInfo(Map<String, IgfsListingEntry> listing) {
- this(true, null, 0, 0, null, listing, null, null, false, System.currentTimeMillis(), false);
+ this(listing, (Map<String,String>)null);
}
/**
@@ -130,20 +137,8 @@ public final class IgfsFileInfo implements Externalizable {
* @param props The properties to set for the new directory.
*/
IgfsFileInfo(@Nullable Map<String, IgfsListingEntry> listing, @Nullable Map<String,String> props) {
- this(true/*dir*/, null, 0, 0, null, listing, props, null, false, System.currentTimeMillis(), false);
- }
-
- /**
- * Constructs file info.
- *
- * @param blockSize Block size.
- * @param affKey Affinity key.
- * @param evictExclude Eviction exclude flag.
- * @param props File properties.
- */
- IgfsFileInfo(int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude,
- @Nullable Map<String, String> props) {
- this(false, null, blockSize, 0, affKey, null, props, null, true, System.currentTimeMillis(), evictExclude);
+ this(true/*dir*/, null, 0, 0, null, listing, props, null, false, ACCESS_TIME_TAKE_MODIFICATION_TIME,
+ System.currentTimeMillis(), false);
}
/**
@@ -155,10 +150,13 @@ public final class IgfsFileInfo implements Externalizable {
* @param lockId Lock ID.
* @param props Properties.
* @param evictExclude Evict exclude flag.
+ * @param accessTime The access time.
+ * @param modificationTime The modification time.
*/
public IgfsFileInfo(int blockSize, long len, @Nullable IgniteUuid affKey, @Nullable IgniteUuid lockId,
- boolean evictExclude, @Nullable Map<String, String> props) {
- this(false, null, blockSize, len, affKey, null, props, lockId, true, System.currentTimeMillis(), evictExclude);
+ boolean evictExclude, @Nullable Map<String, String> props, long accessTime, long modificationTime) {
+ this(false, null, blockSize, len, affKey, null, props, lockId, true, accessTime, modificationTime,
+ evictExclude);
}
/**
@@ -202,10 +200,13 @@ public final class IgfsFileInfo implements Externalizable {
* @param len Size of a file.
* @param props File properties to set.
* @param evictExclude Evict exclude flag.
+ * @param accessTime The access time.
+ * @param modificationTime The modification time.
*/
- IgfsFileInfo(int blockSize, long len, boolean evictExclude, @Nullable Map<String, String> props) {
+ IgfsFileInfo(int blockSize, long len, boolean evictExclude, @Nullable Map<String, String> props,
+ long accessTime, long modificationTime) {
this(blockSize == 0, // NB The contract is: (blockSize == 0) <=> isDirectory()
- null, blockSize, len, null, null, props, null, true, System.currentTimeMillis(), evictExclude);
+ null, blockSize, len, null, null, props, null, true, accessTime, modificationTime, evictExclude);
}
/**
@@ -243,13 +244,14 @@ public final class IgfsFileInfo implements Externalizable {
* @param props File properties.
* @param lockId Lock ID.
* @param cpProps Flag to copy properties map.
+ * @param accessTime The access time.
* @param modificationTime Last modification time.
* @param evictExclude Evict exclude flag.
*/
private IgfsFileInfo(boolean isDir, @Nullable IgniteUuid id, int blockSize, long len, @Nullable IgniteUuid affKey,
@Nullable Map<String, IgfsListingEntry> listing, @Nullable Map<String, String> props,
- @Nullable IgniteUuid lockId, boolean cpProps, long modificationTime, boolean evictExclude) {
- this(isDir, id, blockSize, len, affKey, listing, props, null, lockId, cpProps, modificationTime,
+ @Nullable IgniteUuid lockId, boolean cpProps, long accessTime, long modificationTime, boolean evictExclude) {
+ this(isDir, id, blockSize, len, affKey, listing, props, null, lockId, cpProps, accessTime,
modificationTime, evictExclude);
}
@@ -295,7 +297,7 @@ public final class IgfsFileInfo implements Externalizable {
fileMap = new IgfsFileMap();
this.fileMap = fileMap;
- this.accessTime = accessTime;
+ this.accessTime = accessTime == ACCESS_TIME_TAKE_MODIFICATION_TIME ? modificationTime : accessTime;
this.modificationTime = modificationTime;
// Always make a copy of passed properties collection to escape concurrent modifications.
http://git-wip-us.apache.org/repos/asf/ignite/blob/52e178f6/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 38914ea..c1e47a8 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
@@ -576,12 +576,7 @@ public final class IgfsImpl implements IgfsEx {
IgfsMode mode = resolveMode(path);
- IgfsFileInfo info = resolveFileInfo(path, mode);
-
- if (info == null)
- return null;
-
- return new IgfsFileImpl(path, info, data.groupBlockSize());
+ return resolveFileInfo(path, mode);
}
});
}
@@ -856,10 +851,9 @@ public final class IgfsImpl implements IgfsEx {
Collection<IgfsFile> children = secondaryFs.listFiles(path);
for (IgfsFile child : children) {
- IgfsFileInfo fsInfo = new IgfsFileInfo(
- child.blockSize(), child.length(), evictExclude(path, false), child.properties());
+ IgfsFileImpl impl = new IgfsFileImpl(child, data.groupBlockSize());
- files.add(new IgfsFileImpl(child.path(), fsInfo, data.groupBlockSize()));
+ files.add(impl);
}
}
@@ -1557,7 +1551,7 @@ public final class IgfsImpl implements IgfsEx {
* @return File info or {@code null} in case file is not found.
* @throws IgniteCheckedException If failed.
*/
- private IgfsFileInfo resolveFileInfo(IgfsPath path, IgfsMode mode) throws IgniteCheckedException {
+ private IgfsFileImpl resolveFileInfo(IgfsPath path, IgfsMode mode) throws IgniteCheckedException {
assert path != null;
assert mode != null;
@@ -1577,9 +1571,7 @@ public final class IgfsImpl implements IgfsEx {
IgfsFile status = secondaryFs.info(path);
if (status != null)
- info = status.isDirectory() ? new IgfsFileInfo(true, status.properties()) :
- new IgfsFileInfo(status.blockSize(), status.length(), null, null, false,
- status.properties());
+ return new IgfsFileImpl(status, data.groupBlockSize());
}
break;
@@ -1588,7 +1580,10 @@ public final class IgfsImpl implements IgfsEx {
assert false : "Unknown mode: " + mode;
}
- return info;
+ if (info == null)
+ return null;
+
+ return new IgfsFileImpl(path, info, data.groupBlockSize());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/52e178f6/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 ab73e7d..a149b31 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
@@ -1669,7 +1669,7 @@ public class IgfsMetaManager extends IgfsManager {
assert validTxState(false);
- id2InfoPrj.invokeAsync(parentId, new UpdateListingEntry(fileId, fileName, lenDelta, 0,
+ id2InfoPrj.invokeAsync(parentId, new UpdateListingEntry(fileId, fileName, lenDelta, -1,
modificationTime));
}
finally {
@@ -1995,7 +1995,8 @@ public class IgfsMetaManager extends IgfsManager {
"the secondary file system because the path points to a directory: " + path);
IgfsFileInfo newInfo = new IgfsFileInfo(status.blockSize(), status.length(), affKey,
- composeLockId(false), igfsCtx.igfs().evictExclude(path, false), status.properties());
+ composeLockId(false), igfsCtx.igfs().evictExclude(path, false), status.properties(),
+ status.accessTime(), status.modificationTime());
// Add new file info to the listing optionally removing the previous one.
IgniteUuid oldId = putIfAbsentNonTx(parentInfo.id(), path.name(), newInfo);
@@ -2626,9 +2627,11 @@ public class IgfsMetaManager extends IgfsManager {
}
// Recreate the path locally.
- IgfsFileInfo curInfo = status.isDirectory() ? new IgfsFileInfo(true, status.properties()) :
+ IgfsFileInfo curInfo = status.isDirectory() ?
+ new IgfsFileInfo(true, status.properties(), status.accessTime(), status.modificationTime()) :
new IgfsFileInfo(igfsCtx.configuration().getBlockSize(), status.length(),
- igfsCtx.igfs().evictExclude(curPath, false), status.properties());
+ igfsCtx.igfs().evictExclude(curPath, false), status.properties(),
+ status.accessTime(), status.modificationTime());
IgniteUuid oldId = putIfAbsentNonTx(parentInfo.id(), components.get(i), curInfo);
@@ -3390,8 +3393,10 @@ public class IgfsMetaManager extends IgfsManager {
b = new DirectoryChainBuilder(path, dirProps, fileProps) {
/** {@inheritDoc} */
@Override protected IgfsFileInfo buildLeaf() {
+ long t = System.currentTimeMillis();
+
return new IgfsFileInfo(blockSize, 0L, affKey, composeLockId(false),
- evictExclude, leafProps);
+ evictExclude, leafProps, t, t);
}
};
@@ -3485,8 +3490,10 @@ public class IgfsMetaManager extends IgfsManager {
id2InfoPrj.invoke(lowermostExistingInfo.id(), new UpdatePath(path));
// Make a new locked info:
+ long t = System.currentTimeMillis();
+
final IgfsFileInfo newFileInfo = new IgfsFileInfo(cfg.getBlockSize(), 0L,
- affKey, composeLockId(false), evictExclude, fileProps);
+ affKey, composeLockId(false), evictExclude, fileProps, t, t);
assert newFileInfo.lockId() != null; // locked info should be created.
@@ -3657,7 +3664,9 @@ public class IgfsMetaManager extends IgfsManager {
* Builds leaf.
*/
protected IgfsFileInfo buildLeaf() {
- return new IgfsFileInfo(true, leafProps);
+ long t = System.currentTimeMillis();
+
+ return new IgfsFileInfo(true, leafProps, t, t);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/52e178f6/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
index 84462fd..8d5ae7a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
@@ -166,8 +166,10 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
for (int i = 0; i < 10; i++) {
IgfsPath path = new IgfsPath();
+ long t = System.currentTimeMillis();
+
IgfsFileInfo info = new IgfsFileInfo(200, 0L, null, IgfsMetaManager.DELETE_LOCK_ID,
- false, null);
+ false, null, t, t);
assertNull(mgr.dataBlock(info, path, 0, null).get());
@@ -249,8 +251,10 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
for (int i = 0; i < 10; i++) {
IgfsPath path = new IgfsPath();
+ long t = System.currentTimeMillis();
+
IgfsFileInfo info = new IgfsFileInfo(blockSize, 0L, null, IgfsMetaManager.DELETE_LOCK_ID,
- false, null);
+ false, null, t, t);
assertNull(mgr.dataBlock(info, path, 0, null).get());
@@ -338,9 +342,11 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
for (int i = 0; i < 10; i++) {
IgfsPath path = new IgfsPath();
+ long t = System.currentTimeMillis();
+
IgfsFileInfo info =
new IgfsFileInfo(blockSize, 0L, null, IgfsMetaManager.DELETE_LOCK_ID,
- false, null);
+ false, null, t, t);
IgfsFileAffinityRange range = new IgfsFileAffinityRange();
@@ -407,8 +413,10 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
final int blockSize = 10;
final int grpSize = blockSize * DATA_BLOCK_GROUP_CNT;
+ long t = System.currentTimeMillis();
+
//IgfsFileInfo info = new IgfsFileInfo(blockSize, 0);
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 1024 * 1024, null, null, false, null);
+ IgfsFileInfo info = new IgfsFileInfo(blockSize, 1024 * 1024, null, null, false, null, t, t);
for (int pos = 0; pos < 5 * grpSize; pos++) {
assertEquals("Expects no affinity for zero length.", Collections.<IgfsBlockLocation>emptyList(),
@@ -456,7 +464,9 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
public void testAffinity2() throws Exception {
int blockSize = BLOCK_SIZE;
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 1024 * 1024, null, null, false, null);
+ long t = System.currentTimeMillis();
+
+ IgfsFileInfo info = new IgfsFileInfo(blockSize, 1024 * 1024, null, null, false, null, t, t);
Collection<IgfsBlockLocation> affinity = mgr.affinity(info, 0, info.length());
@@ -487,7 +497,9 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
public void testAffinityFileMap() throws Exception {
int blockSize = BLOCK_SIZE;
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 1024 * 1024, null, null, false, null);
+ long t = System.currentTimeMillis();
+
+ IgfsFileInfo info = new IgfsFileInfo(blockSize, 1024 * 1024, null, null, false, null, t, t);
IgniteUuid affKey = IgniteUuid.randomUuid();
http://git-wip-us.apache.org/repos/asf/ignite/blob/52e178f6/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 683054b..0731436 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
@@ -30,7 +30,9 @@ 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;
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;
@@ -1202,7 +1204,8 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
try {
in0.read(readBuf);
- } finally {
+ }
+ finally {
U.closeQuiet(in0);
}
@@ -1606,4 +1609,73 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
clear(igfs, igfsSecondary);
}
}
+
+ /**
+ * Checks file access & modification time equality in the file itself and in the same file found through
+ * the listing of its parent.
+ *
+ * @param fs The file system.
+ * @param p The file path.
+ *
+ * @return Tuple of access and modification times of the file.
+ */
+ private T2<Long, Long> checkParentListingTime(IgfsSecondaryFileSystem fs, IgfsPath p) {
+ IgfsFile f0 = fs.info(p);
+
+ T2<Long, Long> t0 = new T2<>(f0.accessTime(), f0.modificationTime());
+
+ // Root cannot be seen through the parent listing:
+ if (!p.isSame(p.root())) {
+
+ assertNotNull(f0);
+
+ Collection<IgfsFile> listing = fs.listFiles(p.parent());
+
+ IgfsFile f1 = null;
+
+ for (IgfsFile fi : listing) {
+ if (fi.path().isSame(p)) {
+ f1 = fi;
+
+ break;
+ }
+ }
+
+ assertNotNull(f1); // file should be found in parent listing.
+
+ T2<Long, Long> t1 = new T2<>(f1.accessTime(), f1.modificationTime());
+
+ assertEquals(t0, t1);
+ }
+
+ return t0;
+ }
+
+ /**
+ * Test for file modification time upwards propagation when files are
+ * created on the secondary file system and initially
+ * unknown on the primary file system.
+ *
+ * @throws Exception On error.
+ */
+ public void testAccessAndModificationTimeUpwardsPropagation() throws Exception {
+ create(igfsSecondary, paths(DIR, SUBDIR), paths(FILE, FILE2));
+
+ T2<Long,Long> timesDir0 = checkParentListingTime(igfsSecondaryFileSystem, DIR);
+ T2<Long,Long> timesSubDir0 = checkParentListingTime(igfsSecondaryFileSystem, SUBDIR);
+ T2<Long,Long> timesFile0 = checkParentListingTime(igfsSecondaryFileSystem, FILE);
+ T2<Long,Long> timesFile20 = checkParentListingTime(igfsSecondaryFileSystem, FILE2);
+
+ Thread.sleep(500L);
+
+ T2<Long,Long> timesDir1 = checkParentListingTime(igfs.asSecondary(), DIR);
+ T2<Long,Long> timesSubDir1 = checkParentListingTime(igfs.asSecondary(), SUBDIR);
+ T2<Long,Long> timesFile1 = checkParentListingTime(igfs.asSecondary(), FILE);
+ T2<Long,Long> timesFile21 = checkParentListingTime(igfs.asSecondary(), FILE2);
+
+ assertEquals(timesDir0, timesDir1);
+ assertEquals(timesSubDir0, timesSubDir1);
+ assertEquals(timesFile0, timesFile1);
+ assertEquals(timesFile20, timesFile21);
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/52e178f6/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java
index 90ef404..feccdb5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java
@@ -52,10 +52,15 @@ public class IgfsFileInfoSelfTest extends IgfsCommonAbstractTest {
for (int i = 0; i < 10000; i++) {
testSerialization(new IgfsFileInfo());
testSerialization(new IgfsFileInfo());
- testSerialization(new IgfsFileInfo(true, null));
- testSerialization(new IgfsFileInfo(false, null));
- IgfsFileInfo rndInfo = new IgfsFileInfo(rnd.nextInt(max), null, false, null);
+ long a = System.currentTimeMillis();
+ long m = a + 1;
+
+ testSerialization(new IgfsFileInfo(true, null, a, m));
+ testSerialization(new IgfsFileInfo(false, null, a, m));
+
+ IgfsFileInfo rndInfo =
+ new IgfsFileInfo(rnd.nextInt(max), 0, false, null, a, m);
testSerialization(rndInfo);
testSerialization(new IgfsFileInfo(rndInfo, rnd.nextInt(max)));
http://git-wip-us.apache.org/repos/asf/ignite/blob/52e178f6/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 12cd2ac..672b912 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
@@ -351,9 +351,10 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
Collection<IgfsFile> res = new ArrayList<>(statuses.length);
for (FileStatus status : statuses) {
- IgfsFileInfo fsInfo = status.isDirectory() ? new IgfsFileInfo(true, properties(status)) :
- new IgfsFileInfo((int)status.getBlockSize(), status.getLen(), null, null, false,
- properties(status));
+ IgfsFileInfo fsInfo = status.isDirectory() ?
+ new IgfsFileInfo(true, properties(status), status.getAccessTime(), status.getModificationTime()) :
+ new IgfsFileInfo((int)status.getBlockSize(), status.getLen(), null, null, false, properties(status),
+ status.getAccessTime(), status.getModificationTime());
res.add(new IgfsFileImpl(new IgfsPath(path, status.getPath().getName()), fsInfo, 1));
}
[11/13] ignite git commit: Set serialVersionUID for
CacheEntryPredicateAdapter for backward compatibility.
Posted by nt...@apache.org.
Set serialVersionUID for CacheEntryPredicateAdapter for backward compatibility.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7d65ec93
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7d65ec93
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7d65ec93
Branch: refs/heads/ignite-1186
Commit: 7d65ec9334616a1789620c09724a64696519412a
Parents: e1176fd
Author: sboikov <sb...@gridgain.com>
Authored: Fri Feb 26 09:46:50 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Feb 26 09:46:50 2016 +0300
----------------------------------------------------------------------
.../internal/processors/cache/CacheEntryPredicateAdapter.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7d65ec93/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
index 292ff18..3d56ee3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
@@ -29,6 +29,9 @@ import org.jetbrains.annotations.Nullable;
*/
public abstract class CacheEntryPredicateAdapter implements CacheEntryPredicate {
/** */
+ private static final long serialVersionUID = 4647110502545358709L;
+
+ /** */
protected transient boolean locked;
/** {@inheritDoc} */
[09/13] ignite git commit: IGNITE-944: additional improvements for
HTTP REST log command
Posted by nt...@apache.org.
IGNITE-944: additional improvements for HTTP REST log command
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/53fe9937
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/53fe9937
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/53fe9937
Branch: refs/heads/ignite-1186
Commit: 53fe9937e72d3677e8dab67a8673d4d6905cfdba
Parents: 52e178f
Author: Saikat Maitra <sa...@gmail.com>
Authored: Thu Feb 25 23:39:30 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Feb 25 23:39:30 2016 +0300
----------------------------------------------------------------------
.../handlers/log/GridLogCommandHandler.java | 32 +++++--
.../handlers/log/GridLogCommandHandlerTest.java | 97 +++++++++++++++-----
.../testframework/junits/GridAbstractTest.java | 8 ++
.../junits/GridTestKernalContext.java | 34 ++++---
4 files changed, 126 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/53fe9937/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandler.java
index 603faf3..aac1fa7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandler.java
@@ -22,7 +22,6 @@ import java.io.FileReader;
import java.io.IOException;
import java.nio.file.InvalidPathException;
import java.util.Collection;
-
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInternalFuture;
@@ -93,7 +92,6 @@ public class GridLogCommandHandler extends GridRestCommandHandlerAdapter {
else
from = DEFAULT_FROM;
-
int to;
if (req0.to() != -1) {
@@ -113,12 +111,26 @@ public class GridLogCommandHandler extends GridRestCommandHandlerAdapter {
File logFile;
try {
- if (req0.path() != null)
- logFile = new File(req0.path());
+ if (req0.path() != null) {
+ if (log.fileName() != null) {
+ if (!req0.path().equals(log.fileName())) {
+ return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
+ "Request parameter 'path' must contain a path to valid log file."));
+ }
+ else
+ logFile = new File(req0.path());
+ }
+ else if (req0.path().startsWith(ctx.config().getIgniteHome()))
+ logFile = new File(req0.path());
+ else {
+ return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
+ "Request parameter 'path' must contain a path to valid log file."));
+ }
+ }
+ else if (log.fileName() == null)
+ logFile = new File(ctx.config().getIgniteHome() + "/work/log/ignite.log");
else
- logFile = new File(log.fileName() == null ?
- ctx.config().getIgniteHome() + "/" + "work/log/ignite.log" :
- log.fileName());
+ logFile = new File(log.fileName());
}
catch (InvalidPathException e) {
return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
@@ -150,7 +162,7 @@ public class GridLogCommandHandler extends GridRestCommandHandlerAdapter {
private String readLog(int from, int to, File logFile) throws IgniteCheckedException {
StringBuilder content = new StringBuilder();
- try (BufferedReader reader = new BufferedReader(new FileReader(logFile))) {
+ try (BufferedReader reader = new BufferedReader(new FileReader(logFile))) {
String line;
int start = 0;
@@ -161,6 +173,10 @@ public class GridLogCommandHandler extends GridRestCommandHandlerAdapter {
start++;
}
+
+ if (content.length() == 0)
+ throw new IgniteCheckedException("Request parameter 'from' and 'to' are for lines that " +
+ "do not exist in log file.");
}
catch (IOException e) {
throw new IgniteCheckedException(e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/53fe9937/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
index 572b267..7b0e950 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
@@ -24,6 +24,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.rest.GridRestCommand;
import org.apache.ignite.internal.processors.rest.GridRestResponse;
@@ -47,24 +48,20 @@ public class GridLogCommandHandlerTest extends GridCommonAbstractTest {
"[22:01:30,329][INFO ][grid-load-test-thread-18][GridDeploymentLocalStore] Task locally undeployed: \n"
);
- Path file = Paths.get("test.log");
- Files.write(file, lines, Charset.forName("UTF-8"));
-
- lines = Arrays.asList("[22:01:30,329][INFO ][grid-load-test-thread-12][GridDeploymentLocalStore] ",
- "[22:01:30,329][INFO ][grid-load-test-thread-18][GridDeploymentLocalStore] Removed undeployed class: \n",
- "[22:01:30,329][INFO ][grid-load-test-thread-18][GridDeploymentLocalStore] Task locally undeployed: \n"
- );
-
Path dir = Paths.get(igniteHome + "/work/log");
Files.createDirectories(dir);
- file = Paths.get(igniteHome + "/work/log/" + "ignite.log");
+ Path file = Paths.get(igniteHome + "/work/log/" + "ignite.log");
Files.write(file, lines, Charset.forName("UTF-8"));
+
+ file = Paths.get(igniteHome + "/work/log/" + "test.log");
+ Files.write(file, lines, Charset.forName("UTF-8"));
+
}
/** {@inheritDoc} */
@Override protected void afterTestsStopped() throws Exception {
- Path file = Paths.get("test.log");
+ Path file = Paths.get(igniteHome + "/work/log/" + "test.log");
Files.delete(file);
Files.delete(Paths.get(igniteHome + "/work/log/" + "ignite.log"));
@@ -102,13 +99,16 @@ public class GridLogCommandHandlerTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testHandleAsync() throws Exception {
- GridLogCommandHandler cmdHandler = new GridLogCommandHandler(newContext());
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ cfg.setIgniteHome(igniteHome);
+ GridTestKernalContext ctx = newContext(cfg);
+ GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
GridRestLogRequest req = new GridRestLogRequest();
req.to(5);
req.from(2);
- req.path("test.log");
+ req.path(igniteHome + "/work/log/" + "test.log");
IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
assertNull(resp.result().getError());
@@ -119,12 +119,35 @@ public class GridLogCommandHandlerTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
- public void testHandleAsyncFromAndToNotSet() throws Exception {
- GridLogCommandHandler cmdHandler = new GridLogCommandHandler(newContext());
+ public void testHandleAsyncForNonExistingLines() throws Exception {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ cfg.setIgniteHome(igniteHome);
+ GridTestKernalContext ctx = newContext(cfg);
+ GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
GridRestLogRequest req = new GridRestLogRequest();
- req.path("test.log");
+ req.to(50);
+ req.from(20);
+
+ req.path(igniteHome + "/work/log/" + "test.log");
+ IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
+
+ assertEquals("Request parameter 'from' and 'to' are for lines that do not exist in log file.", resp.result().getError());
+ assertEquals(GridRestResponse.STATUS_FAILED, resp.result().getSuccessStatus());
+ assertNull(resp.result().getResponse());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testHandleAsyncFromAndToNotSet() throws Exception {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ cfg.setIgniteHome(igniteHome);
+ GridTestKernalContext ctx = newContext(cfg);
+ GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
+ GridRestLogRequest req = new GridRestLogRequest();
+ req.path(igniteHome + "/work/log/" + "test.log");
IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
assertNull(resp.result().getError());
@@ -138,7 +161,6 @@ public class GridLogCommandHandlerTest extends GridCommonAbstractTest {
public void testHandleAsyncPathNotSet() throws Exception {
GridTestKernalContext ctx = newContext();
ctx.config().setIgniteHome(igniteHome);
-
GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
GridRestLogRequest req = new GridRestLogRequest();
@@ -155,14 +177,38 @@ public class GridLogCommandHandlerTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
+ public void testHandleAsyncPathIsOutsideIgniteHome() throws Exception {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ cfg.setIgniteHome(igniteHome);
+ GridTestKernalContext ctx = newContext(cfg);
+ GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
+ GridRestLogRequest req = new GridRestLogRequest();
+
+ req.to(5);
+ req.from(2);
+ req.path("/home/users/mytest.log");
+
+ IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
+
+ assertEquals("Request parameter 'path' must contain a path to valid log file.", resp.result().getError());
+ assertEquals(GridRestResponse.STATUS_FAILED, resp.result().getSuccessStatus());
+ assertNull(resp.result().getResponse());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testHandleAsyncFromGreaterThanTo() throws Exception {
- GridLogCommandHandler cmdHandler = new GridLogCommandHandler(newContext());
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ cfg.setIgniteHome(igniteHome);
+ GridTestKernalContext ctx = newContext(cfg);
+ GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
GridRestLogRequest req = new GridRestLogRequest();
- req.to(2);
- req.from(5);
- req.path("test.log");
+ req.to(5);
+ req.from(7);
+ req.path(igniteHome + "/work/log/" + "test.log");
IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
assertEquals("Request parameter 'from' must be less than 'to'.", resp.result().getError());
@@ -174,13 +220,16 @@ public class GridLogCommandHandlerTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testHandleAsyncFromEqualTo() throws Exception {
- GridLogCommandHandler cmdHandler = new GridLogCommandHandler(newContext());
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ cfg.setIgniteHome(igniteHome);
+ GridTestKernalContext ctx = newContext(cfg);
+ GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
GridRestLogRequest req = new GridRestLogRequest();
- req.to(2);
- req.from(2);
- req.path("test.log");
+ req.to(5);
+ req.from(5);
+ req.path(igniteHome + "/work/log/" + "test.log");
IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
assertEquals("Request parameter 'from' must be less than 'to'.", resp.result().getError());
http://git-wip-us.apache.org/repos/asf/ignite/blob/53fe9937/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 3c83d86..614e634 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -452,6 +452,14 @@ public abstract class GridAbstractTest extends TestCase {
}
/**
+ * @param cfg Configuration to use in Test
+ * @return Test kernal context.
+ */
+ protected GridTestKernalContext newContext(IgniteConfiguration cfg) throws IgniteCheckedException {
+ return new GridTestKernalContext(log(), cfg);
+ }
+
+ /**
* Called before execution of every test method in class.
*
* @throws Exception If failed. {@link #afterTest()} will be called in this case.
http://git-wip-us.apache.org/repos/asf/ignite/blob/53fe9937/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
index f318c38..b4c31be 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
@@ -40,19 +40,27 @@ public class GridTestKernalContext extends GridKernalContextImpl {
* @param log Logger to use in context config.
*/
public GridTestKernalContext(IgniteLogger log) throws IgniteCheckedException {
+ this(log, new IgniteConfiguration());
+ }
+
+ /**
+ * @param log Logger to use in context config.
+ * @param cfg Configuration to use in Test
+ */
+ public GridTestKernalContext(IgniteLogger log, IgniteConfiguration cfg) throws IgniteCheckedException {
super(new GridLoggerProxy(log, null, null, null),
- new IgniteKernal(null),
- new IgniteConfiguration(),
- new GridKernalGatewayImpl(null),
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- U.allPluginProviders());
+ new IgniteKernal(null),
+ cfg,
+ new GridKernalGatewayImpl(null),
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ U.allPluginProviders());
GridTestUtils.setFieldValue(grid(), "cfg", config());
@@ -108,4 +116,4 @@ public class GridTestKernalContext extends GridKernalContextImpl {
public void setExecutorService(ExecutorService execSvc){
this.execSvc = execSvc;
}
-}
\ No newline at end of file
+}
[04/13] ignite git commit: IGNITE-2709 - Fixed potential SOE on
high-contented cache locks - Fixes #509.
Posted by nt...@apache.org.
IGNITE-2709 - Fixed potential SOE on high-contented cache locks - Fixes #509.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a7b6ad36
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a7b6ad36
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a7b6ad36
Branch: refs/heads/ignite-1186
Commit: a7b6ad36dd9b8f91877c614ce6e72c83ec1ffdf6
Parents: 711fe37
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Feb 24 18:45:00 2016 -0800
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Feb 24 18:45:00 2016 -0800
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../processors/cache/GridCacheMvccManager.java | 142 ++++++++++++-------
.../IgniteCachePutStackOverflowSelfTest.java | 133 +++++++++++++++++
.../testsuites/IgniteCacheTestSuite5.java | 2 +
4 files changed, 230 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7b6ad36/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 6f07702..858cb71 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -367,6 +367,9 @@ public final class IgniteSystemProperties {
/** JDBC driver cursor remove delay. */
public static final String IGNITE_JDBC_DRIVER_CURSOR_REMOVE_DELAY = "IGNITE_JDBC_DRIVER_CURSOR_RMV_DELAY";
+ /** Maximum number of nested listener calls before listener notification becomes asynchronous. */
+ public static final String IGNITE_MAX_NESTED_LISTENER_CALLS = "IGNITE_MAX_NESTED_LISTENER_CALLS";
+
/**
* Manages {@link OptimizedMarshaller} behavior of {@code serialVersionUID} computation for
* {@link Serializable} classes.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7b6ad36/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index 9aeed95..afba4bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -31,6 +31,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
@@ -49,6 +50,7 @@ import org.apache.ignite.internal.util.GridConcurrentFactory;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.lang.GridPlainRunnable;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.CI1;
@@ -64,6 +66,8 @@ import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
import org.jsr166.ConcurrentLinkedDeque8;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_MAX_NESTED_LISTENER_CALLS;
+import static org.apache.ignite.IgniteSystemProperties.getInteger;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.internal.util.GridConcurrentFactory.newMap;
@@ -76,6 +80,9 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
/** Maxim number of removed locks. */
private static final int MAX_REMOVED_LOCKS = 10240;
+ /** */
+ private static final int MAX_NESTED_LSNR_CALLS = getInteger(IGNITE_MAX_NESTED_LISTENER_CALLS, 5);
+
/** Pending locks per thread. */
private final ThreadLocal<Deque<GridCacheMvccCandidate>> pending = new ThreadLocal<>();
@@ -111,6 +118,13 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
/** Finish futures. */
private final ConcurrentLinkedDeque8<FinishLockFuture> finishFuts = new ConcurrentLinkedDeque8<>();
+ /** Nested listener calls. */
+ private final ThreadLocal<Integer> nestedLsnrCalls = new ThreadLocal<Integer>() {
+ @Override protected Integer initialValue() {
+ return 0;
+ }
+ };
+
/** Logger. */
@SuppressWarnings( {"FieldAccessedSynchronizedAndUnsynchronized"})
private IgniteLogger exchLog;
@@ -123,60 +137,26 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
private final GridCacheMvccCallback cb = new GridCacheMvccCallback() {
/** {@inheritDoc} */
@SuppressWarnings({"unchecked"})
- @Override public void onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate prev,
- GridCacheMvccCandidate owner) {
- assert entry != null;
- assert owner != prev : "New and previous owner are identical instances: " + owner;
- assert owner == null || prev == null || !owner.version().equals(prev.version()) :
- "New and previous owners have identical versions [owner=" + owner + ", prev=" + prev + ']';
-
- if (log.isDebugEnabled())
- log.debug("Received owner changed callback [" + entry.key() + ", owner=" + owner + ", prev=" +
- prev + ']');
-
- if (owner != null && (owner.local() || owner.nearLocal())) {
- Collection<GridCacheMvccFuture<?>> futCol = mvccFuts.get(owner.version());
-
- if (futCol != null) {
- ArrayList<GridCacheMvccFuture<?>> futColCp;
+ @Override public void onOwnerChanged(final GridCacheEntryEx entry, final GridCacheMvccCandidate prev,
+ final GridCacheMvccCandidate owner) {
+ int nested = nestedLsnrCalls.get();
- synchronized (futCol) {
- futColCp = new ArrayList<>(futCol.size());
+ if (nested < MAX_NESTED_LSNR_CALLS) {
+ nestedLsnrCalls.set(nested + 1);
- futColCp.addAll(futCol);
- }
-
- // Must invoke onOwnerChanged outside of synchronization block.
- for (GridCacheMvccFuture<?> fut : futColCp) {
- if (!fut.isDone()) {
- GridCacheMvccFuture<Boolean> mvccFut = (GridCacheMvccFuture<Boolean>)fut;
-
- // Since this method is called outside of entry synchronization,
- // we can safely invoke any method on the future.
- // Also note that we don't remove future here if it is done.
- // The removal is initiated from within future itself.
- if (mvccFut.onOwnerChanged(entry, owner))
- return;
- }
- }
+ try {
+ notifyOwnerChanged(entry, prev, owner);
+ }
+ finally {
+ nestedLsnrCalls.set(nested);
}
}
-
- if (log.isDebugEnabled())
- log.debug("Lock future not found for owner change callback (will try transaction futures) [owner=" +
- owner + ", prev=" + prev + ", entry=" + entry + ']');
-
- // If no future was found, delegate to transaction manager.
- if (cctx.tm().onOwnerChanged(entry, owner)) {
- if (log.isDebugEnabled())
- log.debug("Found transaction for changed owner: " + owner);
- }
- else if (log.isDebugEnabled())
- log.debug("Failed to find transaction for changed owner: " + owner);
-
- if (!finishFuts.isEmptyx()) {
- for (FinishLockFuture f : finishFuts)
- f.recheck(entry);
+ else {
+ cctx.kernalContext().closure().runLocalSafe(new GridPlainRunnable() {
+ @Override public void run() {
+ notifyOwnerChanged(entry, prev, owner);
+ }
+ }, true);
}
}
@@ -197,6 +177,68 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
}
};
+ /**
+ * @param entry Entry to notify callback for.
+ * @param prev Previous lock owner.
+ * @param owner Current lock owner.
+ */
+ private void notifyOwnerChanged(final GridCacheEntryEx entry, final GridCacheMvccCandidate prev,
+ final GridCacheMvccCandidate owner) {
+ assert entry != null;
+ assert owner != prev : "New and previous owner are identical instances: " + owner;
+ assert owner == null || prev == null || !owner.version().equals(prev.version()) :
+ "New and previous owners have identical versions [owner=" + owner + ", prev=" + prev + ']';
+
+ if (log.isDebugEnabled())
+ log.debug("Received owner changed callback [" + entry.key() + ", owner=" + owner + ", prev=" +
+ prev + ']');
+
+ if (owner != null && (owner.local() || owner.nearLocal())) {
+ Collection<GridCacheMvccFuture<?>> futCol = mvccFuts.get(owner.version());
+
+ if (futCol != null) {
+ ArrayList<GridCacheMvccFuture<?>> futColCp;
+
+ synchronized (futCol) {
+ futColCp = new ArrayList<>(futCol.size());
+
+ futColCp.addAll(futCol);
+ }
+
+ // Must invoke onOwnerChanged outside of synchronization block.
+ for (GridCacheMvccFuture<?> fut : futColCp) {
+ if (!fut.isDone()) {
+ final GridCacheMvccFuture<Boolean> mvccFut = (GridCacheMvccFuture<Boolean>)fut;
+
+ // Since this method is called outside of entry synchronization,
+ // we can safely invoke any method on the future.
+ // Also note that we don't remove future here if it is done.
+ // The removal is initiated from within future itself.
+ if (mvccFut.onOwnerChanged(entry, owner))
+ return;
+ }
+ }
+ }
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Lock future not found for owner change callback (will try transaction futures) [owner=" +
+ owner + ", prev=" + prev + ", entry=" + entry + ']');
+
+ // If no future was found, delegate to transaction manager.
+ if (cctx.tm().onOwnerChanged(entry, owner)) {
+ if (log.isDebugEnabled())
+ log.debug("Found transaction for changed owner: " + owner);
+ }
+ else if (log.isDebugEnabled())
+ log.debug("Failed to find transaction for changed owner: " + owner);
+
+ if (!finishFuts.isEmptyx()) {
+ for (FinishLockFuture f : finishFuts)
+ f.recheck(entry);
+ }
+ }
+
/** Discovery listener. */
@GridToStringExclude private final GridLocalEventListener discoLsnr = new GridLocalEventListener() {
@Override public void onEvent(Event evt) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7b6ad36/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutStackOverflowSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutStackOverflowSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutStackOverflowSelfTest.java
new file mode 100644
index 0000000..55d7192
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutStackOverflowSelfTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.U;
+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 static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ *
+ */
+public class IgniteCachePutStackOverflowSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ discoSpi.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(discoSpi);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrid(0);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testStackLocal() throws Exception {
+ checkCache(CacheMode.LOCAL);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testStackPartitioned() throws Exception {
+ checkCache(CacheMode.PARTITIONED);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testStackReplicated() throws Exception {
+ checkCache(CacheMode.REPLICATED);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ private void checkCache(CacheMode mode) throws Exception {
+ final Ignite ignite = ignite(0);
+
+ final IgniteCache<Object, Object> cache = ignite.getOrCreateCache(new CacheConfiguration<>("cache")
+ .setCacheMode(mode)
+ .setAtomicityMode(TRANSACTIONAL));
+
+ try {
+ Thread[] threads = new Thread[256];
+
+ try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ // Lock the key.
+ final String key = "key";
+
+ cache.get(key);
+
+ // Simulate high contention.
+ for (int i = 0; i < threads.length; i++) {
+ threads[i] = new Thread() {
+ @Override public void run() {
+ cache.put(key, 1);
+ }
+ };
+
+ threads[i].start();
+ }
+
+ U.sleep(2_000);
+
+ cache.put(key, 1);
+
+ tx.commit();
+ }
+
+ System.out.println("Waiting for threads to finish...");
+
+ for (Thread thread : threads)
+ thread.join();
+ }
+ finally {
+ ignite.destroyCache("cache");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7b6ad36/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
index 34b12a9..3eb0b13 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
@@ -20,6 +20,7 @@ package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
import org.apache.ignite.internal.processors.cache.CacheNearReaderUpdateTest;
import org.apache.ignite.internal.processors.cache.CacheSerializableTransactionsTest;
+import org.apache.ignite.internal.processors.cache.IgniteCachePutStackOverflowSelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheStoreCollectionTest;
import org.apache.ignite.internal.processors.cache.store.IgniteCacheWriteBehindNoUpdateSelfTest;
@@ -38,6 +39,7 @@ public class IgniteCacheTestSuite5 extends TestSuite {
suite.addTestSuite(CacheNearReaderUpdateTest.class);
suite.addTestSuite(IgniteCacheStoreCollectionTest.class);
suite.addTestSuite(IgniteCacheWriteBehindNoUpdateSelfTest.class);
+ suite.addTestSuite(IgniteCachePutStackOverflowSelfTest.class);
return suite;
}
[05/13] ignite git commit: Do not print out binary format warning for
org.jsr166 classes
Posted by nt...@apache.org.
Do not print out binary format warning for org.jsr166 classes
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4124d338
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4124d338
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4124d338
Branch: refs/heads/ignite-1186
Commit: 4124d338d9d5c91c80c1bb9ce596c50a7764cab7
Parents: ff80f5d
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Feb 24 20:10:57 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Feb 24 20:10:57 2016 -0800
----------------------------------------------------------------------
.../main/java/org/apache/ignite/internal/util/IgniteUtils.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4124d338/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 103ea9e..db2960d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -5894,7 +5894,9 @@ public abstract class IgniteUtils {
* @return {@code True} if given class is of {@code Ignite} type.
*/
public static boolean isIgnite(Class<?> cls) {
- return cls.getName().startsWith("org.apache.ignite");
+ String name = cls.getName();
+
+ return name.startsWith("org.apache.ignite") || name.startsWith("org.jsr166");
}
/**
[07/13] ignite git commit: Continuous query compatibility fix (topVer
can be null for old CacheContinuousQueryEntry).
Posted by nt...@apache.org.
Continuous query compatibility fix (topVer can be null for old CacheContinuousQueryEntry).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/dee61900
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/dee61900
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/dee61900
Branch: refs/heads/ignite-1186
Commit: dee61900c26b1f2a0a84d5e400001fecad545ada
Parents: 10214cc
Author: sboikov <sb...@gridgain.com>
Authored: Thu Feb 25 12:54:11 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Feb 25 12:54:11 2016 +0300
----------------------------------------------------------------------
.../continuous/CacheContinuousQueryHandler.java | 43 +++++++++++---------
1 file changed, 23 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/dee61900/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index 4397f69..1938edb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -737,6 +737,12 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
public Collection<CacheContinuousQueryEntry> collectEntries(CacheContinuousQueryEntry entry) {
assert entry != null;
+ if (entry.topologyVersion() == null) { // Possible if entry is sent from old node.
+ assert entry.updateCounter() == 0L : entry;
+
+ return F.asList(entry);
+ }
+
List<CacheContinuousQueryEntry> entries;
synchronized (pendingEvts) {
@@ -991,28 +997,25 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
routineId,
t.get1());
- Collection<ClusterNode> nodes = new HashSet<>();
-
- for (AffinityTopologyVersion topVer : t.get2())
- nodes.addAll(ctx.discovery().cacheAffinityNodes(cctx.name(), topVer));
-
- for (ClusterNode node : nodes) {
- if (!node.isLocal() && node.version().compareTo(CacheContinuousQueryBatchAck.SINCE_VER) >= 0) {
- try {
- cctx.io().send(node, msg, GridIoPolicy.SYSTEM_POOL);
- }
- catch (ClusterTopologyCheckedException e) {
- IgniteLogger log = ctx.log(getClass());
+ for (AffinityTopologyVersion topVer : t.get2()) {
+ for (ClusterNode node : ctx.discovery().cacheAffinityNodes(cctx.name(), topVer)) {
+ if (!node.isLocal() && node.version().compareTo(CacheContinuousQueryBatchAck.SINCE_VER) >= 0) {
+ try {
+ cctx.io().send(node, msg, GridIoPolicy.SYSTEM_POOL);
+ }
+ catch (ClusterTopologyCheckedException e) {
+ IgniteLogger log = ctx.log(getClass());
- if (log.isDebugEnabled())
- log.debug("Failed to send acknowledge message, node left " +
- "[msg=" + msg + ", node=" + node + ']');
- }
- catch (IgniteCheckedException e) {
- IgniteLogger log = ctx.log(getClass());
+ if (log.isDebugEnabled())
+ log.debug("Failed to send acknowledge message, node left " +
+ "[msg=" + msg + ", node=" + node + ']');
+ }
+ catch (IgniteCheckedException e) {
+ IgniteLogger log = ctx.log(getClass());
- U.error(log, "Failed to send acknowledge message " +
- "[msg=" + msg + ", node=" + node + ']', e);
+ U.error(log, "Failed to send acknowledge message " +
+ "[msg=" + msg + ", node=" + node + ']', e);
+ }
}
}
}
[06/13] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by nt...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/10214ccd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/10214ccd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/10214ccd
Branch: refs/heads/ignite-1186
Commit: 10214ccd2ef5f173e4e5ae171ae2f88a967e0ec5
Parents: 4124d33 a7b6ad3
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Feb 24 20:11:14 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Feb 24 20:11:14 2016 -0800
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../processors/cache/GridCacheMvccManager.java | 142 ++++++++++++-------
.../distributed/dht/GridDhtLockFuture.java | 17 ++-
.../transactions/IgniteTxLocalAdapter.java | 4 +
.../cache/GridCacheAbstractFullApiSelfTest.java | 65 +++++++++
.../cache/GridCacheAbstractSelfTest.java | 19 +++
.../IgniteCachePutStackOverflowSelfTest.java | 133 +++++++++++++++++
.../GridCacheBinaryObjectsAbstractSelfTest.java | 40 ++++++
.../testsuites/IgniteCacheTestSuite5.java | 2 +
9 files changed, 373 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
[03/13] ignite git commit: IGNITE-2707 - Fixed skipStore flag
handling - Fixes #508.
Posted by nt...@apache.org.
IGNITE-2707 - Fixed skipStore flag handling - Fixes #508.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/711fe378
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/711fe378
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/711fe378
Branch: refs/heads/ignite-1186
Commit: 711fe3783cb622ae134df899397505d2813d50ac
Parents: ff80f5d
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Feb 24 18:43:35 2016 -0800
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Feb 24 18:43:35 2016 -0800
----------------------------------------------------------------------
.../distributed/dht/GridDhtLockFuture.java | 17 ++++-
.../transactions/IgniteTxLocalAdapter.java | 4 ++
.../cache/GridCacheAbstractFullApiSelfTest.java | 65 ++++++++++++++++++++
.../cache/GridCacheAbstractSelfTest.java | 19 ++++++
.../GridCacheBinaryObjectsAbstractSelfTest.java | 40 ++++++++++++
5 files changed, 143 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/711fe378/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
index 07755e0..a33f01f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
@@ -1021,8 +1021,21 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
final GridCacheVersion ver = version();
for (GridDhtCacheEntry entry : entries) {
- if (!entry.hasValue())
- loadMap.put(entry.key(), entry);
+ try {
+ entry.unswap(false);
+
+ if (!entry.hasValue())
+ loadMap.put(entry.key(), entry);
+ }
+ catch (GridCacheEntryRemovedException e) {
+ assert false : "Should not get removed exception while holding lock on entry " +
+ "[entry=" + entry + ", e=" + e + ']';
+ }
+ catch (IgniteCheckedException e) {
+ onDone(e);
+
+ return;
+ }
}
try {
http://git-wip-us.apache.org/repos/asf/ignite/blob/711fe378/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index f35e2e4..1d77da5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -3779,6 +3779,10 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
old.cached(entry);
old.filters(filter);
+ // Keep old skipStore and keepBinary flags.
+ old.skipStore(skipStore);
+ old.keepBinary(keepBinary);
+
// Update ttl if specified.
if (drTtl >= 0L) {
assert drExpireTime >= 0L;
http://git-wip-us.apache.org/repos/asf/ignite/blob/711fe378/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 3bd87cf..222a96b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -261,6 +261,71 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
info("Grid " + i + ": " + grid(i).localNode().id());
}
+ /**
+ * Checks that skipStore flag gets overriden inside a transaction.
+ *
+ * @throws Exception if failed.
+ */
+ public void testWriteThroughTx() {
+ if(isMultiJvm())
+ fail("https://issues.apache.org/jira/browse/IGNITE-1088");
+
+ String key = "writeThroughKey";
+
+ map.remove(key);
+
+ try (final Transaction transaction = grid(0).transactions().txStart()) {
+ IgniteCache<String, Integer> cache = jcache(0);
+
+ // retrieve market type from the grid
+ Integer old = cache.withSkipStore().get(key);
+
+ assertNull(old);
+
+ // update the grid
+ cache.put(key, 2);
+
+ // finally commit the transaction
+ transaction.commit();
+ }
+
+ assertEquals(2, map.get(key));
+ }
+
+ /**
+ * Checks that skipStore flag gets overriden inside a transaction.
+ *
+ * @throws Exception if failed.
+ */
+ public void testNoReadThroughTx() {
+ if(isMultiJvm())
+ fail("https://issues.apache.org/jira/browse/IGNITE-1088");
+
+ String key = "writeThroughKey";
+
+ IgniteCache<String, Integer> cache = jcache(0);
+
+ resetStore();
+
+ cache.put(key, 1);
+
+ putToStore(key, 2);
+
+ try (final Transaction transaction = grid(0).transactions().txStart()) {
+ Integer old = cache.get(key);
+
+ assertEquals((Integer)1, old);
+
+ // update the grid
+ cache.put(key, 2);
+
+ // finally commit the transaction
+ transaction.commit();
+ }
+
+ assertEquals(0, reads.get());
+ }
+
/** {@inheritDoc} */
@Override protected Ignite startGrid(String gridName, GridSpringResourceContext ctx) throws Exception {
if (cacheCfgMap == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/711fe378/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
index b3d1384..b918f28 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
@@ -69,6 +69,15 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
/** Store map. */
protected static final Map<Object, Object> map = new ConcurrentHashMap8<>();
+ /** Reads counter. */
+ protected static final AtomicInteger reads = new AtomicInteger();
+
+ /** Writes counter. */
+ protected static final AtomicInteger writes = new AtomicInteger();
+
+ /** Removes counter. */
+ protected static final AtomicInteger removes = new AtomicInteger();
+
/** VM ip finder for TCP discovery. */
protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
@@ -187,6 +196,10 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
*/
protected void resetStore() {
map.clear();
+
+ reads.set(0);
+ writes.set(0);
+ removes.set(0);
}
/**
@@ -301,14 +314,20 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
}
@Override public Object load(Object key) {
+ reads.incrementAndGet();
+
return map.get(key);
}
@Override public void write(javax.cache.Cache.Entry<? extends Object, ? extends Object> e) {
+ writes.incrementAndGet();
+
map.put(e.getKey(), e.getValue());
}
@Override public void delete(Object key) {
+ removes.incrementAndGet();
+
map.remove(key);
}
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/711fe378/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
index 271e3b5..36a9450 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set;
import javax.cache.Cache;
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;
@@ -60,6 +61,8 @@ 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.Nullable;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
@@ -732,6 +735,30 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
}
/**
+ * @throws Exception if failed.
+ */
+ public void testKeepBinaryTxOverwrite() throws Exception {
+ if (atomicityMode() != TRANSACTIONAL)
+ return;
+
+ IgniteCache<Integer, TestObject> cache = ignite(0).cache(null);
+
+ cache.put(0, new TestObject(1));
+
+ for (TransactionConcurrency conc : TransactionConcurrency.values()) {
+ for (TransactionIsolation iso : TransactionIsolation.values()) {
+ try (Transaction tx = ignite(0).transactions().txStart(conc, iso)) {
+ cache.withKeepBinary().get(0);
+
+ cache.invoke(0, new ObjectEntryProcessor());
+
+ tx.commit();
+ }
+ }
+ }
+ }
+
+ /**
* @throws Exception If failed.
*/
public void testLoadCache() throws Exception {
@@ -936,6 +963,19 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
}
/**
+ * No-op entry processor.
+ */
+ private static class ObjectEntryProcessor implements EntryProcessor<Integer, TestObject, Boolean> {
+ @Override public Boolean process(MutableEntry<Integer, TestObject> entry, Object... args) throws EntryProcessorException {
+ TestObject obj = entry.getValue();
+
+ entry.setValue(new TestObject(obj.val));
+
+ return true;
+ }
+ }
+
+ /**
*
*/
private static class TestReferenceObject implements Binarylizable {
[02/13] ignite git commit: Fixed assertion in optimized marshaller
Posted by nt...@apache.org.
Fixed assertion in optimized marshaller
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ff80f5da
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ff80f5da
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ff80f5da
Branch: refs/heads/ignite-1186
Commit: ff80f5da911b4fedc5407d6cc22fcea5e4dd34bc
Parents: 9117720
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Feb 24 18:39:26 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Feb 24 18:39:26 2016 -0800
----------------------------------------------------------------------
.../OptimizedObjectStreamRegistry.java | 147 +++++++++++--------
.../OptimizedMarshallerPooledSelfTest.java | 2 +-
2 files changed, 86 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff80f5da/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java
index cf92d27..fd1b917 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamRegistry.java
@@ -33,8 +33,11 @@ class OptimizedObjectStreamRegistry {
/** Holders. */
private static final ThreadLocal<StreamHolder> holders = new ThreadLocal<>();
- /** Holders pool. */
- private static BlockingQueue<StreamHolder> pool;
+ /** Output streams pool. */
+ private static BlockingQueue<OptimizedObjectOutputStream> outPool;
+
+ /** Input streams pool. */
+ private static BlockingQueue<OptimizedObjectInputStream> inPool;
/**
* Ensures singleton.
@@ -50,16 +53,18 @@ class OptimizedObjectStreamRegistry {
*/
static void poolSize(int size) {
if (size > 0) {
- pool = new LinkedBlockingQueue<>(size);
+ outPool = new LinkedBlockingQueue<>(size);
+ inPool = new LinkedBlockingQueue<>(size);
for (int i = 0; i < size; i++) {
- boolean b = pool.offer(new StreamHolder());
-
- assert b;
+ outPool.offer(createOut());
+ inPool.offer(createIn());
}
}
- else
- pool = null;
+ else {
+ outPool = null;
+ inPool = null;
+ }
}
/**
@@ -69,7 +74,17 @@ class OptimizedObjectStreamRegistry {
* @throws org.apache.ignite.internal.IgniteInterruptedCheckedException If thread is interrupted while trying to take holder from pool.
*/
static OptimizedObjectOutputStream out() throws IgniteInterruptedCheckedException {
- return holder().acquireOut();
+ if (outPool != null) {
+ try {
+ return outPool.take();
+ }
+ catch (InterruptedException e) {
+ throw new IgniteInterruptedCheckedException(
+ "Failed to take output object stream from pool (thread interrupted).", e);
+ }
+ }
+ else
+ return holder().acquireOut();
}
/**
@@ -79,7 +94,17 @@ class OptimizedObjectStreamRegistry {
* @throws org.apache.ignite.internal.IgniteInterruptedCheckedException If thread is interrupted while trying to take holder from pool.
*/
static OptimizedObjectInputStream in() throws IgniteInterruptedCheckedException {
- return holder().acquireIn();
+ if (inPool != null) {
+ try {
+ return inPool.take();
+ }
+ catch (InterruptedException e) {
+ throw new IgniteInterruptedCheckedException(
+ "Failed to take input object stream from pool (thread interrupted).", e);
+ }
+ }
+ else
+ return holder().acquireIn();
}
/**
@@ -90,15 +115,17 @@ class OptimizedObjectStreamRegistry {
static void closeOut(OptimizedObjectOutputStream out) {
U.close(out, null);
- StreamHolder holder = holders.get();
-
- if (holder != null && holder.releaseOut() && pool != null) {
- holders.set(null);
-
- boolean b = pool.offer(holder);
+ if (outPool != null) {
+ boolean b = outPool.offer(out);
assert b;
}
+ else {
+ StreamHolder holder = holders.get();
+
+ if (holder != null)
+ holder.releaseOut();
+ }
}
/**
@@ -110,15 +137,17 @@ class OptimizedObjectStreamRegistry {
static void closeIn(OptimizedObjectInputStream in) {
U.close(in, null);
- StreamHolder holder = holders.get();
-
- if (holder != null && holder.releaseIn() && pool != null) {
- holders.set(null);
-
- boolean b = pool.offer(holder);
+ if (inPool != null) {
+ boolean b = inPool.offer(in);
assert b;
}
+ else {
+ StreamHolder holder = holders.get();
+
+ if (holder != null)
+ holder.releaseIn();
+ }
}
/**
@@ -130,19 +159,41 @@ class OptimizedObjectStreamRegistry {
private static StreamHolder holder() throws IgniteInterruptedCheckedException {
StreamHolder holder = holders.get();
- if (holder == null) {
- try {
- holders.set(holder = pool != null ? pool.take() : new StreamHolder());
- }
- catch (InterruptedException e) {
- throw new IgniteInterruptedCheckedException("Failed to take object stream from pool (thread interrupted).", e);
- }
- }
+ if (holder == null)
+ holders.set(holder = new StreamHolder());
return holder;
}
/**
+ * Creates output stream.
+ *
+ * @return Object output stream.
+ */
+ private static OptimizedObjectOutputStream createOut() {
+ try {
+ return new OptimizedObjectOutputStream(new GridUnsafeDataOutput(4 * 1024));
+ }
+ catch (IOException e) {
+ throw new IgniteException("Failed to create object output stream.", e);
+ }
+ }
+
+ /**
+ * Creates input stream.
+ *
+ * @return Object input stream.
+ */
+ private static OptimizedObjectInputStream createIn() {
+ try {
+ return new OptimizedObjectInputStream(new GridUnsafeDataInput());
+ }
+ catch (IOException e) {
+ throw new IgniteException("Failed to create object input stream.", e);
+ }
+ }
+
+ /**
* Streams holder.
*/
private static class StreamHolder {
@@ -179,43 +230,15 @@ class OptimizedObjectStreamRegistry {
/**
* Releases output stream.
*/
- boolean releaseOut() {
- return --outAcquireCnt == 0;
+ void releaseOut() {
+ outAcquireCnt--;
}
/**
* Releases input stream.
*/
- boolean releaseIn() {
- return --inAcquireCnt == 0;
- }
-
- /**
- * Creates output stream.
- *
- * @return Object output stream.
- */
- private OptimizedObjectOutputStream createOut() {
- try {
- return new OptimizedObjectOutputStream(new GridUnsafeDataOutput(4 * 1024));
- }
- catch (IOException e) {
- throw new IgniteException("Failed to create object output stream.", e);
- }
- }
-
- /**
- * Creates input stream.
- *
- * @return Object input stream.
- */
- private OptimizedObjectInputStream createIn() {
- try {
- return new OptimizedObjectInputStream(new GridUnsafeDataInput());
- }
- catch (IOException e) {
- throw new IgniteException("Failed to create object input stream.", e);
- }
+ void releaseIn() {
+ inAcquireCnt--;
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff80f5da/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java
index c649787..a883270 100644
--- a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerPooledSelfTest.java
@@ -39,6 +39,6 @@ public class OptimizedMarshallerPooledSelfTest extends OptimizedMarshallerSelfTe
super.afterTestsStopped();
// Reset static registry.
- new OptimizedMarshaller().setPoolSize(-1);
+ new OptimizedMarshaller().setPoolSize(0);
}
}
[13/13] ignite git commit: Merge branch 'master' into ignite-1186
Posted by nt...@apache.org.
Merge branch 'master' into ignite-1186
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2537d797
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2537d797
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2537d797
Branch: refs/heads/ignite-1186
Commit: 2537d797f9b83769a090286aba7ae820d55277d8
Parents: b6b9390 7d65ec9
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Fri Feb 26 12:16:50 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Fri Feb 26 12:16:50 2016 +0300
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../ignite/internal/binary/BinaryUtils.java | 7 +-
.../cache/CacheEntryPredicateAdapter.java | 3 +
.../processors/cache/GridCacheMvccManager.java | 142 +++++++++++------
.../distributed/dht/GridDhtLockFuture.java | 17 ++-
.../continuous/CacheContinuousQueryHandler.java | 43 +++---
.../transactions/IgniteTxLocalAdapter.java | 4 +
.../internal/processors/igfs/IgfsFileImpl.java | 23 +++
.../internal/processors/igfs/IgfsFileInfo.java | 54 +++----
.../internal/processors/igfs/IgfsImpl.java | 23 ++-
.../processors/igfs/IgfsMetaManager.java | 23 ++-
.../handlers/log/GridLogCommandHandler.java | 32 +++-
.../ignite/internal/util/IgniteUtils.java | 4 +-
.../OptimizedObjectStreamRegistry.java | 151 +++++++++++--------
.../cache/GridCacheAbstractFullApiSelfTest.java | 65 ++++++++
.../cache/GridCacheAbstractSelfTest.java | 19 +++
.../IgniteCachePutStackOverflowSelfTest.java | 133 ++++++++++++++++
.../GridCacheBinaryObjectsAbstractSelfTest.java | 40 +++++
.../igfs/IgfsDataManagerSelfTest.java | 24 ++-
.../igfs/IgfsDualAbstractSelfTest.java | 74 ++++++++-
.../processors/igfs/IgfsFileInfoSelfTest.java | 11 +-
.../handlers/log/GridLogCommandHandlerTest.java | 97 +++++++++---
...namicProxySerializationMultiJvmSelfTest.java | 106 ++++++++++---
.../OptimizedMarshallerPooledSelfTest.java | 8 +
.../testframework/junits/GridAbstractTest.java | 8 +
.../junits/GridTestKernalContext.java | 34 +++--
.../testsuites/IgniteCacheTestSuite5.java | 2 +
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 7 +-
28 files changed, 889 insertions(+), 268 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2537d797/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------