You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by av...@apache.org on 2018/08/15 22:03:48 UTC
[01/19] ignite git commit: IGNITE-9219 Uncomment 13 test classes in
IgniteCacheTestSuite4 (Cache 4). - Fixes #4504.
Repository: ignite
Updated Branches:
refs/heads/ignite-9053 3540e1c44 -> da3b7a0ab
IGNITE-9219 Uncomment 13 test classes in IgniteCacheTestSuite4 (Cache 4). - Fixes #4504.
Signed-off-by: Dmitriy Pavlov <dp...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cd5b32bb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cd5b32bb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cd5b32bb
Branch: refs/heads/ignite-9053
Commit: cd5b32bb064b1aafcb287783c00b607c407780ca
Parents: d04d764
Author: Ilya Kasnacheev <il...@gmail.com>
Authored: Mon Aug 13 20:39:43 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Mon Aug 13 20:39:43 2018 +0300
----------------------------------------------------------------------
...heStoreSessionListenerLifecycleSelfTest.java | 5 ++-
...niteCacheCopyOnReadDisabledAbstractTest.java | 10 ++++--
.../IgniteCacheStoreValueAbstractTest.java | 13 ++++++--
.../testsuites/IgniteCacheTestSuite4.java | 34 ++++++++++----------
4 files changed, 40 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/cd5b32bb/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerLifecycleSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerLifecycleSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerLifecycleSelfTest.java
index 5327e19..ff176c5 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerLifecycleSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerLifecycleSelfTest.java
@@ -252,6 +252,9 @@ public class CacheStoreSessionListenerLifecycleSelfTest extends GridCommonAbstra
tx.commit();
}
+
+ // Force cache shutdown order
+ ignite.cache("cache-0").destroy();
}
finally {
stopGrid();
@@ -396,4 +399,4 @@ public class CacheStoreSessionListenerLifecycleSelfTest extends GridCommonAbstra
// No-op.
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cd5b32bb/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java
index bba779f..61f8136 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java
@@ -43,6 +43,11 @@ public abstract class IgniteCacheCopyOnReadDisabledAbstractTest extends GridCach
return ccfg;
}
+ /** {@inheritDoc} */
+ @Override protected boolean onheapCacheEnabled() {
+ return true;
+ }
+
/**
* @throws Exception If failed.
*/
@@ -64,6 +69,7 @@ public abstract class IgniteCacheCopyOnReadDisabledAbstractTest extends GridCach
assertSame(val0, cache.localPeek(key));
}
+ /* Does not seem to work anymore since main storage mechanism is always off-heap.
TestKey key = new TestKey(0);
TestValue val0 = cache.get(key);
@@ -74,7 +80,7 @@ public abstract class IgniteCacheCopyOnReadDisabledAbstractTest extends GridCach
}
});
- assertSame(val0, invokeVal);
+ assertSame(val0, invokeVal);*/
}
/**
@@ -122,4 +128,4 @@ public abstract class IgniteCacheCopyOnReadDisabledAbstractTest extends GridCach
this.val = val;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cd5b32bb/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
index eceb9d2..4af0a15 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
@@ -65,6 +65,11 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
}
/** {@inheritDoc} */
+ @Override protected boolean onheapCacheEnabled() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);
@@ -189,6 +194,8 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
assertNull(cache.localPeek(key, CachePeekMode.ONHEAP));
+ cache.get(key);
+
assertNotNull(cache.localPeek(key, CachePeekMode.ONHEAP));
checkNoValue(aff, key);
@@ -239,7 +246,7 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
for (int g = 0; g < gridCount(); g++) {
IgniteEx ig = grid(g);
- GridCacheAdapter cache0 = internalCache(ig, null);
+ GridCacheAdapter cache0 = internalCache(ig, DEFAULT_CACHE_NAME);
GridCacheEntryEx e = cache0.peekEx(key);
@@ -354,6 +361,8 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
assertNull(cache.localPeek(key, CachePeekMode.ONHEAP));
+ cache.get(key);
+
assertNotNull(cache.localPeek(key, CachePeekMode.ONHEAP));
checkHasValue(aff, key);
@@ -369,7 +378,7 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
for (int g = 0; g < gridCount(); g++) {
IgniteEx ig = grid(g);
- GridCacheAdapter cache0 = internalCache(ig, null);
+ GridCacheAdapter cache0 = internalCache(ig, DEFAULT_CACHE_NAME);
GridCacheEntryEx e = cache0.peekEx(key);
http://git-wip-us.apache.org/repos/asf/ignite/blob/cd5b32bb/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index 2cc5f0b..2ba81f3 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -57,10 +57,14 @@ import org.apache.ignite.internal.processors.cache.GridCacheMultinodeUpdateSelfT
import org.apache.ignite.internal.processors.cache.GridCacheStoreManagerDeserializationTest;
import org.apache.ignite.internal.processors.cache.GridCacheVersionMultinodeTest;
import org.apache.ignite.internal.processors.cache.GridLocalCacheStoreManagerDeserializationTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicCopyOnReadDisabledTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicLocalPeekModesTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicLocalStoreValueTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicNearEnabledStoreValueTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicNearPeekModesTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicPeekModesTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicReplicatedPeekModesTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicStoreValueTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheConfigurationDefaultTemplateTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheConfigurationTemplateTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheContainsKeyAtomicTest;
@@ -71,11 +75,15 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheInvokeReadThroughT
import org.apache.ignite.internal.processors.cache.IgniteCacheLoadRebalanceEvictionSelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheReadThroughStoreCallTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheStartTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheTxCopyOnReadDisabledTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheTxLocalPeekModesTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheTxLocalStoreValueTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheTxNearEnabledStoreValueTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheTxNearPeekModesTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheTxPeekModesTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheTxPreloadNoWriteTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheTxReplicatedPeekModesTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheTxStoreValueTest;
import org.apache.ignite.internal.processors.cache.IgniteClientCacheInitializationFailTest;
import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheFilterTest;
import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheMultinodeTest;
@@ -223,9 +231,8 @@ public class IgniteCacheTestSuite4 extends TestSuite {
suite.addTestSuite(GridCacheVersionMultinodeTest.class);
suite.addTestSuite(IgniteCacheNearReadCommittedTest.class);
- // TODO GG-11148 need decide if CopyOnRead flag makes sense.
-// suite.addTestSuite(IgniteCacheAtomicCopyOnReadDisabledTest.class);
-// suite.addTestSuite(IgniteCacheTxCopyOnReadDisabledTest.class);
+ suite.addTestSuite(IgniteCacheAtomicCopyOnReadDisabledTest.class);
+ suite.addTestSuite(IgniteCacheTxCopyOnReadDisabledTest.class);
suite.addTestSuite(IgniteCacheTxPreloadNoWriteTest.class);
@@ -255,15 +262,12 @@ public class IgniteCacheTestSuite4 extends TestSuite {
suite.addTestSuite(IgniteCacheJdbcBlobStoreNodeRestartTest.class);
- // TODO GG-11148 need decide if CopyOnRead flag makes sense.
-// suite.addTestSuite(IgniteCacheAtomicLocalStoreValueTest.class);
-// suite.addTestSuite(IgniteCacheAtomicStoreValueTest.class);
-// suite.addTestSuite(IgniteCacheAtomicNearEnabledStoreValueTest.class);
-// suite.addTestSuite(IgniteCacheAtomicPrimaryWriteOrderStoreValueTest.class);
-// suite.addTestSuite(IgniteCacheAtomicPrimaryWriteOrderNearEnabledStoreValueTest.class);
-// suite.addTestSuite(IgniteCacheTxLocalStoreValueTest.class);
-// suite.addTestSuite(IgniteCacheTxStoreValueTest.class);
-// suite.addTestSuite(IgniteCacheTxNearEnabledStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheAtomicLocalStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheAtomicStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheAtomicNearEnabledStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheTxLocalStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheTxStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheTxNearEnabledStoreValueTest.class);
suite.addTestSuite(IgniteCacheLockFailoverSelfTest.class);
suite.addTestSuite(IgniteCacheMultiTxLockSelfTest.class);
@@ -289,7 +293,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
suite.addTestSuite(CacheOffheapMapEntrySelfTest.class);
suite.addTestSuite(CacheJdbcStoreSessionListenerSelfTest.class);
- //suite.addTestSuite(CacheStoreSessionListenerLifecycleSelfTest.class);
+ suite.addTestSuite(CacheStoreSessionListenerLifecycleSelfTest.class);
suite.addTestSuite(CacheStoreListenerRWThroughDisabledAtomicCacheTest.class);
suite.addTestSuite(CacheStoreListenerRWThroughDisabledTransactionalCacheTest.class);
suite.addTestSuite(CacheStoreSessionListenerWriteBehindEnabledTest.class);
@@ -322,10 +326,6 @@ public class IgniteCacheTestSuite4 extends TestSuite {
suite.addTestSuite(CacheVersionedEntryReplicatedAtomicSelfTest.class);
suite.addTestSuite(CacheVersionedEntryReplicatedTransactionalSelfTest.class);
- // TODO GG-11148.
- // suite.addTestSuite(CacheSwapUnswapGetTest.class);
- // suite.addTestSuite(CacheSwapUnswapGetTestSmallQueueSize.class);
-
suite.addTestSuite(GridCacheDhtTxPreloadSelfTest.class);
suite.addTestSuite(GridCacheNearTxPreloadSelfTest.class);
suite.addTestSuite(GridReplicatedTxPreloadTest.class);
[11/19] ignite git commit: IGNITE-1905 Fixed assertion when
CacheLockImpl is contented - Fixes #4490.
Posted by av...@apache.org.
IGNITE-1905 Fixed assertion when CacheLockImpl is contented - Fixes #4490.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/18356a87
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/18356a87
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/18356a87
Branch: refs/heads/ignite-9053
Commit: 18356a876c9ed633c74b855b66b70d777e92cbd6
Parents: 3e0f04e
Author: Vitaliy Biryukov <Bi...@gmail.com>
Authored: Wed Aug 15 17:16:17 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Aug 15 17:16:17 2018 +0300
----------------------------------------------------------------------
.../dht/GridDhtTransactionalCacheAdapter.java | 12 +--
.../colocated/GridDhtColocatedLockFuture.java | 76 +++++++++++++------
.../distributed/near/GridNearLockFuture.java | 80 ++++++++++++++------
.../testsuites/IgniteCacheTestSuite6.java | 2 +
4 files changed, 117 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/18356a87/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index 46d7579..30b066f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -44,7 +44,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedExceptio
import org.apache.ignite.internal.processors.cache.GridCacheLockTimeoutException;
import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate;
import org.apache.ignite.internal.processors.cache.GridCacheReturn;
-import org.apache.ignite.internal.processors.cache.GridCacheVersionedFuture;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheEntry;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockCancelledException;
@@ -77,7 +76,6 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.thread.IgniteThread;
import org.apache.ignite.transactions.TransactionIsolation;
import org.jetbrains.annotations.Nullable;
@@ -1528,15 +1526,14 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
* @param readers Readers for this entry.
* @param dhtMap DHT map.
* @param nearMap Near map.
- * @throws IgniteCheckedException If failed.
*/
private void map(UUID nodeId,
AffinityTopologyVersion topVer,
GridCacheEntryEx cached,
Collection<UUID> readers,
Map<ClusterNode, List<KeyCacheObject>> dhtMap,
- Map<ClusterNode, List<KeyCacheObject>> nearMap)
- throws IgniteCheckedException {
+ Map<ClusterNode, List<KeyCacheObject>> nearMap
+ ) {
List<ClusterNode> dhtNodes = ctx.dht().topology().nodes(cached.partition(), topVer);
ClusterNode primary = dhtNodes.get(0);
@@ -1609,6 +1606,8 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
// Remove mapped versions.
GridCacheVersion dhtVer = unmap ? ctx.mvcc().unmapVersion(ver) : ver;
+ ctx.mvcc().addRemoved(ctx, ver);
+
Map<ClusterNode, List<KeyCacheObject>> dhtMap = new HashMap<>();
Map<ClusterNode, List<KeyCacheObject>> nearMap = new HashMap<>();
@@ -1690,9 +1689,6 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
if (log.isDebugEnabled())
log.debug("Received remove lock request for removed entry (will retry): " + entry);
}
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to remove locks for keys: " + keys, e);
- }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/18356a87/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index da0858f..a5ff2f3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -134,7 +134,7 @@ public final class GridDhtColocatedLockFuture extends GridCacheCompoundIdentityF
/** Timeout object. */
@GridToStringExclude
- private LockTimeoutObject timeoutObj;
+ private volatile LockTimeoutObject timeoutObj;
/** Lock timeout. */
private final long timeout;
@@ -444,32 +444,59 @@ public final class GridDhtColocatedLockFuture extends GridCacheCompoundIdentityF
* @param nodeId Sender.
* @param res Result.
*/
+ @SuppressWarnings("SynchronizeOnNonFinalField")
void onResult(UUID nodeId, GridNearLockResponse res) {
- if (!isDone()) {
- MiniFuture mini = miniFuture(res.miniId());
-
- if (mini != null) {
- assert mini.node().id().equals(nodeId);
+ boolean done = isDone();
- mini.onResult(res);
+ if (!done) {
+ // onResult is always called after map() and timeoutObj is never reset to null, so this is
+ // a race-free null check.
+ if (timeoutObj == null) {
+ onResult0(nodeId, res);
return;
}
- // This warning can be triggered by deadlock detection code which clears pending futures.
- U.warn(msgLog, "Collocated lock fut, failed to find mini future [txId=" + lockVer +
- ", tx=" + (inTx() ? CU.txString(tx) : "N/A") +
- ", node=" + nodeId +
- ", res=" + res +
- ", fut=" + this + ']');
- }
- else {
- if (msgLog.isDebugEnabled()) {
- msgLog.debug("Collocated lock fut, response for finished future [txId=" + lockVer +
- ", inTx=" + inTx() +
- ", node=" + nodeId + ']');
+ synchronized (timeoutObj) {
+ if (!isDone()) {
+ if (onResult0(nodeId, res))
+ return;
+ }
+ else
+ done = true;
}
}
+
+ if (done && msgLog.isDebugEnabled()) {
+ msgLog.debug("Collocated lock fut, response for finished future [txId=" + lockVer +
+ ", inTx=" + inTx() +
+ ", node=" + nodeId + ']');
+ }
+ }
+
+ /**
+ * @param nodeId Sender.
+ * @param res Result.
+ */
+ private boolean onResult0(UUID nodeId, GridNearLockResponse res) {
+ MiniFuture mini = miniFuture(res.miniId());
+
+ if (mini != null) {
+ assert mini.node().id().equals(nodeId);
+
+ mini.onResult(res);
+
+ return true;
+ }
+
+ // This warning can be triggered by deadlock detection code which clears pending futures.
+ U.warn(msgLog, "Collocated lock fut, failed to find mini future [txId=" + lockVer +
+ ", tx=" + (inTx() ? CU.txString(tx) : "N/A") +
+ ", node=" + nodeId +
+ ", res=" + res +
+ ", fut=" + this + ']');
+
+ return false;
}
/**
@@ -1452,15 +1479,20 @@ public final class GridDhtColocatedLockFuture extends GridCacheCompoundIdentityF
U.warn(log, "Failed to detect deadlock.", e);
}
- onComplete(false, true);
+ synchronized (LockTimeoutObject.this) {
+ onComplete(false, true);
+ }
}
});
}
else
err = tx.timeoutException();
}
- else
- onComplete(false, true);
+ else {
+ synchronized (this) {
+ onComplete(false, true);
+ }
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/18356a87/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
index 4b46bda..6cd4514 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
@@ -129,7 +129,7 @@ public final class GridNearLockFuture extends GridCacheCompoundIdentityFuture<Bo
/** Timeout object. */
@GridToStringExclude
- private LockTimeoutObject timeoutObj;
+ private volatile LockTimeoutObject timeoutObj;
/** Lock timeout. */
private final long timeout;
@@ -481,37 +481,66 @@ public final class GridNearLockFuture extends GridCacheCompoundIdentityFuture<Bo
* @param nodeId Sender.
* @param res Result.
*/
+ @SuppressWarnings("SynchronizeOnNonFinalField")
void onResult(UUID nodeId, GridNearLockResponse res) {
- if (!isDone()) {
- if (log.isDebugEnabled())
- log.debug("Received lock response from node [nodeId=" + nodeId + ", res=" + res + ", fut=" + this + ']');
-
- MiniFuture mini = miniFuture(res.miniId());
-
- if (mini != null) {
- assert mini.node().id().equals(nodeId);
-
- if (log.isDebugEnabled())
- log.debug("Found mini future for response [mini=" + mini + ", res=" + res + ']');
+ boolean done = isDone();
- mini.onResult(res);
-
- if (log.isDebugEnabled())
- log.debug("Future after processed lock response [fut=" + this + ", mini=" + mini +
- ", res=" + res + ']');
+ if (!done) {
+ // onResult is always called after map() and timeoutObj is never reset to null, so this is
+ // a race-free null check.
+ if (timeoutObj == null) {
+ onResult0(nodeId, res);
return;
}
- U.warn(log, "Failed to find mini future for response (perhaps due to stale message) [res=" + res +
- ", fut=" + this + ']');
+ synchronized (timeoutObj) {
+ if (!isDone()) {
+ if (onResult0(nodeId, res))
+ return;
+ }
+ else
+ done = true;
+ }
}
- else if (log.isDebugEnabled())
+
+ if (done && log.isDebugEnabled())
log.debug("Ignoring lock response from node (future is done) [nodeId=" + nodeId + ", res=" + res +
", fut=" + this + ']');
}
/**
+ * @param nodeId Sender.
+ * @param res Result.
+ */
+ private boolean onResult0(UUID nodeId, GridNearLockResponse res) {
+ if (log.isDebugEnabled())
+ log.debug("Received lock response from node [nodeId=" + nodeId + ", res=" + res + ", fut=" + this + ']');
+
+ MiniFuture mini = miniFuture(res.miniId());
+
+ if (mini != null) {
+ assert mini.node().id().equals(nodeId);
+
+ if (log.isDebugEnabled())
+ log.debug("Found mini future for response [mini=" + mini + ", res=" + res + ']');
+
+ mini.onResult(res);
+
+ if (log.isDebugEnabled())
+ log.debug("Future after processed lock response [fut=" + this + ", mini=" + mini +
+ ", res=" + res + ']');
+
+ return true;
+ }
+
+ U.warn(log, "Failed to find mini future for response (perhaps due to stale message) [res=" + res +
+ ", fut=" + this + ']');
+
+ return false;
+ }
+
+ /**
* @return Keys for which locks requested from remote nodes but response isn't received.
*/
public synchronized Set<IgniteTxKey> requestedKeys() {
@@ -1496,15 +1525,20 @@ public final class GridNearLockFuture extends GridCacheCompoundIdentityFuture<Bo
U.warn(log, "Failed to detect deadlock.", e);
}
- onComplete(false, true);
+ synchronized (LockTimeoutObject.this) {
+ onComplete(false, true);
+ }
}
});
}
else
err = tx.timeoutException();
}
- else
- onComplete(false, true);
+ else {
+ synchronized (this) {
+ onComplete(false, true);
+ }
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/18356a87/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java
index 6f3df0b..b52e339 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java
@@ -109,6 +109,8 @@ public class IgniteCacheTestSuite6 extends TestSuite {
suite.addTestSuite(IgniteExchangeLatchManagerCoordinatorFailTest.class);
+ suite.addTestSuite(CacheTryLockMultithreadedTest.class);
+
//suite.addTestSuite(CacheClientsConcurrentStartTest.class);
//suite.addTestSuite(CacheTryLockMultithreadedTest.class);
//suite.addTestSuite(GridCacheRebalancingOrderingTest.class);
[10/19] ignite git commit: Add initial version of inspections profile
to Apache Ignite Code Base
Posted by av...@apache.org.
Add initial version of inspections profile to Apache Ignite Code Base
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3e0f04ed
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3e0f04ed
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3e0f04ed
Branch: refs/heads/ignite-9053
Commit: 3e0f04edf7cc0aa1631fbd1b9af1e9b87b697eb1
Parents: fd921a2
Author: Alexey Goncharuk <ag...@apache.org>
Authored: Wed Aug 15 16:42:24 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Wed Aug 15 16:42:24 2018 +0300
----------------------------------------------------------------------
idea/ignite_inspections.xml | 772 +++++++++++++++++++++++++++++++++++++++
1 file changed, 772 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3e0f04ed/idea/ignite_inspections.xml
----------------------------------------------------------------------
diff --git a/idea/ignite_inspections.xml b/idea/ignite_inspections.xml
new file mode 100644
index 0000000..7ce5af8
--- /dev/null
+++ b/idea/ignite_inspections.xml
@@ -0,0 +1,772 @@
+<profile version="1.0">
+ <option name="myName" value="ignite_inspections" />
+ <inspection_tool class="AbstractMethodCallInConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="AccessorLikeMethodIsEmptyParen" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AccessorLikeMethodIsUnit" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintAddJavascriptInterface" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintAllowAllHostnameVerifier" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintAlwaysShowAction" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintAppCompatMethod" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintAuthLeak" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintBadHostnameVerifier" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintBatteryLife" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintCommitPrefEdits" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintCommitTransaction" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintCustomViewStyleable" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintCutPasteId" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintDefaultLocale" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintDrawAllocation" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintExportedContentProvider" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintExportedPreferenceActivity" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintExportedReceiver" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintExportedService" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintFloatMath" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintGetInstance" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintGifUsage" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintGoogleAppIndexingUrlError" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintGoogleAppIndexingWarning" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintGrantAllUris" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintHandlerLeak" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintIconColors" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintIconDensities" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintIconDipSize" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintIconDuplicates" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintIconDuplicatesConfig" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintIconExtension" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintIconLauncherShape" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintIconLocation" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintIconMissingDensityFolder" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintIconMixedNinePatch" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintIconNoDpi" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintIconXmlAndPng" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintInconsistentLayout" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintInflateParams" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintInlinedApi" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintInvalidUsesTagAttribute" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintJavascriptInterface" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintLocalSuppress" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintLogTagMismatch" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintLongLogTag" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintMergeRootFrame" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintMissingIntentFilterForMediaSearch" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintMissingMediaBrowserServiceIntentFilter" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintMissingOnPlayFromSearch" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintMissingSuperCall" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintNewApi" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintOverdraw" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintOverride" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintOverrideAbstract" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintPackageManagerGetSignatures" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintParcelClassLoader" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintParcelCreator" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintPendingBindings" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintPluralsCandidate" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintPrivateResource" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintRecycle" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintRecyclerView" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintRegistered" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintRequiredSize" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintRtlCompat" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintRtlEnabled" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintRtlHardcoded" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintRtlSymmetry" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSQLiteString" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSSLCertificateSocketFactoryCreateSocket" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSSLCertificateSocketFactoryGetInsecure" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSdCardPath" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSecureRandom" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintServiceCast" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSetJavaScriptEnabled" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSetTextI18n" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSetWorldReadable" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSetWorldWritable" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintShiftFlags" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintShortAlarm" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintShowToast" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSimpleDateFormat" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintStringFormatCount" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintStringFormatInvalid" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintStringFormatMatches" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSupportAnnotationUsage" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSuspiciousImport" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintSwitchIntDef" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintTrustAllX509TrustManager" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintUniqueConstants" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintUnlocalizedSms" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintUnprotectedSMSBroadcastReceiver" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintUnsafeDynamicallyLoadedCode" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintUnsafeNativeCodeLocation" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintUnsafeProtectedBroadcastReceiver" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintUnusedAttribute" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintUseSparseArrays" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintUseValueOf" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintValidFragment" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintViewConstructor" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintViewHolder" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintViewTag" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintWorldReadableFiles" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintWorldWriteableFiles" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintWrongCall" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidKLintWrongViewCast" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintAaptCrash" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintAccidentalOctal" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintAdapterViewChildren" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintAddJavascriptInterface" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintAllowAllHostnameVerifier" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintAllowBackup" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintAlwaysShowAction" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintAppCompatMethod" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintAppCompatResource" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintAssert" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintAuthLeak" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintBadHostnameVerifier" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintBatteryLife" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintButtonCase" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintButtonOrder" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintButtonStyle" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintByteOrderMark" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintCommitPrefEdits" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintCommitTransaction" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintContentDescription" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintCustomViewStyleable" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintCutPasteId" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintDefaultLocale" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintDeprecated" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintDeviceAdmin" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintDisableBaselineAlignment" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintDrawAllocation" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintDuplicateActivity" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintDuplicateDefinition" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintDuplicateIds" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintDuplicateIncludedIds" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintDuplicateUsesFeature" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintEnforceUTF8" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintExportedContentProvider" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintExportedPreferenceActivity" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintExportedReceiver" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintExportedService" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintExtraText" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintExtraTranslation" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintFloatMath" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintFullBackupContent" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGetInstance" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGifUsage" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGoogleAppIndexingUrlError" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGoogleAppIndexingWarning" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGradleCompatible" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGradleDependency" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGradleDeprecated" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGradleDynamicVersion" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGradleGetter" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGradleIdeError" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGradleOverrides" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGradlePath" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGradlePluginVersion" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGrantAllUris" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintGridLayout" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintHandlerLeak" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintHardcodedDebugMode" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintHardcodedText" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintHardwareIds" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIconColors" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIconDensities" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIconDipSize" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIconDuplicates" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIconDuplicatesConfig" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIconExtension" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIconLauncherShape" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIconLocation" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIconMissingDensityFolder" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIconMixedNinePatch" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIconNoDpi" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIconXmlAndPng" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIllegalResourceRef" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintImpliedQuantity" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintInOrMmUsage" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintIncludeLayoutParam" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintInconsistentArrays" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintInconsistentLayout" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintInefficientWeight" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintInflateParams" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintInlinedApi" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintInnerclassSeparator" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintInvalidId" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintInvalidResourceFolder" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintInvalidUsesTagAttribute" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintJavascriptInterface" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintLabelFor" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintLibraryCustomView" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintLocalSuppress" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintLocaleFolder" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintLogTagMismatch" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintLongLogTag" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintManifestOrder" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintManifestResource" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMenuTitle" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMergeRootFrame" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMipmapIcons" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingApplicationIcon" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingConstraints" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingId" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingIntentFilterForMediaSearch" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingLeanbackLauncher" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingLeanbackSupport" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingMediaBrowserServiceIntentFilter" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingOnPlayFromSearch" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingPrefix" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingQuantity" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingSuperCall" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingTranslation" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingTvBanner" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMissingVersion" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMockLocation" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintMultipleUsesSdk" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintNestedScrolling" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintNestedWeights" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintNewApi" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintNfcTechWhitespace" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintNotInterpolated" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintNotSibling" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintObsoleteLayoutParam" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintOldTargetApi" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintOrientation" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintOverdraw" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintOverride" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintOverrideAbstract" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintPackageManagerGetSignatures" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintPackagedPrivateKey" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintParcelClassLoader" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintParcelCreator" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintPendingBindings" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintPermissionImpliesUnsupportedHardware" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintPluralsCandidate" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintPrivateResource" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintProguard" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintProguardSplit" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintPropertyEscape" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintProtectedPermissions" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintPxUsage" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintRecycle" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintRecyclerView" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintReferenceType" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintRegistered" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintRelativeOverlap" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintRequiredSize" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintResAuto" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintResourceCycle" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintResourceName" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintRtlCompat" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintRtlEnabled" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintRtlHardcoded" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintRtlSymmetry" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSQLiteString" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSSLCertificateSocketFactoryCreateSocket" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSSLCertificateSocketFactoryGetInsecure" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintScrollViewCount" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintScrollViewSize" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSdCardPath" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSecureRandom" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintServiceCast" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSetJavaScriptEnabled" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSetTextI18n" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSetWorldReadable" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSetWorldWritable" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintShiftFlags" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintShortAlarm" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintShowToast" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSignatureOrSystemPermissions" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSimpleDateFormat" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSmallSp" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSpUsage" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintStateListReachable" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintStaticFieldLeak" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintStringFormatCount" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintStringFormatInvalid" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintStringFormatMatches" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintStringShouldBeInt" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSupportAnnotationUsage" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSuspicious0dp" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSuspiciousImport" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintSwitchIntDef" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintTextFields" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintTextViewEdits" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintTooDeepLayout" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintTooManyViews" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintTrustAllX509TrustManager" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintTypographyDashes" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintTypographyEllipsis" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintTypographyFractions" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintTypographyOther" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintTypos" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUniqueConstants" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUniquePermission" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUnknownId" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUnknownIdInLayout" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUnlocalizedSms" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUnprotectedSMSBroadcastReceiver" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUnsafeDynamicallyLoadedCode" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUnsafeNativeCodeLocation" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUnsafeProtectedBroadcastReceiver" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUnsupportedTvHardware" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUnusedAttribute" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUnusedQuantity" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUnusedResources" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUseAlpha2" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUseCompoundDrawables" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUseSparseArrays" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUseValueOf" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUselessLeaf" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUselessParent" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUsesMinSdkAttributes" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintUsingHttp" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintValidFragment" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintValidRestrictions" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintVectorDrawableCompat" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintVectorRaster" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintViewConstructor" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintViewHolder" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintViewTag" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintWearableBindListener" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintWebViewLayout" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintWorldReadableFiles" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintWorldWriteableFiles" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintWrongCall" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintWrongCase" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintWrongFolder" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintWrongRegion" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AndroidLintWrongViewCast" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AntDuplicateTargetsInspection" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AntMissingPropertiesFileInspection" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="AntResolveInspection" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="ApparentRefinementOfResultType" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="AppliedTypeLambdaCanBeSimplified" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ArrayCreationWithoutNewKeyword" enabled="false" level="INFORMATION" enabled_by_default="false" />
+ <inspection_tool class="AssertAsName" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="AssignmentToCatchBlockParameter" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="AssignmentToDateFieldFromParameter" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="ignorePrivateMethods" value="true" />
+ </inspection_tool>
+ <inspection_tool class="BadOddness" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="BigDecimalEquals" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="BooleanMethodIsAlwaysInverted" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="BreakStatementWithLabel" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="BusyWait" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="CStyleArrayDeclaration" enabled="false" level="INFORMATION" enabled_by_default="false" />
+ <inspection_tool class="CallToStringConcatCanBeReplacedByOperator" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="CaseClassParam" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ChainedPackage" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ClassMayBeInterface" enabled="false" level="INFORMATION" enabled_by_default="false" />
+ <inspection_tool class="ClassNameDiffersFromFileName" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ClassNameSameAsAncestorName" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="CloneCallsConstructors" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="CloneInNonCloneableClass" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="CloneableImplementsClone" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="m_ignoreCloneableDueToInheritance" value="true" />
+ </inspection_tool>
+ <inspection_tool class="CollectionContainsUrl" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="CollectionsFieldAccessReplaceableByMethodCall" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ComparableImplementedButEqualsNotOverridden" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ComparatorNotSerializable" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ComparingDiffCollectionKinds" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ComparingUnrelatedTypes" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ComparisonOfShortAndChar" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ComparisonToNaN" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ConditionSignal" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ConstantConditions" enabled="false" level="WARNING" enabled_by_default="false">
+ <option name="SUGGEST_NULLABLE_ANNOTATIONS" value="true" />
+ <option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="true" />
+ </inspection_tool>
+ <inspection_tool class="ConstantValueVariableUse" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ContinueStatementWithLabel" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ControlFlowStatementWithoutBraces" enabled="false" level="INFORMATION" enabled_by_default="false" />
+ <inspection_tool class="Convert2Lambda" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ConvertExpressionToSAM" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ConvertNullInitializerToUnderscore" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ConvertibleToMethodValue" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="CorrespondsUnsorted" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="CovariantCompareTo" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="CovariantEquals" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="DangerousCatchAll" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="DanglingJavadoc" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="DefaultNotLastCaseInSwitch" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="DeprecatedIsStillUsed" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="DeprecatedViewBound" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="DialogTitleCapitalization" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="DivideByZero" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="DollarSignInName" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="DottyDeprecatedWith" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="DropTakeToSlice" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="DuplicateBooleanBranch" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="DuplicateCondition" enabled="false" level="WARNING" enabled_by_default="false">
+ <option name="ignoreMethodCalls" value="false" />
+ </inspection_tool>
+ <inspection_tool class="DuplicateThrows" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="EmptyCheck" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="EmptyInitializer" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="EmptyParenMethodAccessedAsParameterless" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="EmptyParenMethodOverridenAsParameterless" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="EmptySynchronizedStatement" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="EnumAsName" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="EnumSwitchStatementWhichMissesCases" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="ignoreSwitchStatementsWithDefault" value="true" />
+ </inspection_tool>
+ <inspection_tool class="EqualityToSameElements" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="EqualsCalledOnEnumConstant" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="EqualsHashCodeCalledOnUrl" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="EqualsWhichDoesntCheckParameterClass" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ErrorRethrown" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ExceptionNameDoesntEndWithException" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ExistsEquals" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ExtendsUtilityClass" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ExternalizableWithSerializationMethods" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="FieldAccessedSynchronizedAndUnsynchronized" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="countGettersAndSetters" value="false" />
+ </inspection_tool>
+ <inspection_tool class="FieldCanBeLocal" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="FieldFromDelayedInit" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="FieldMayBeStatic" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="FilterEmptyCheck" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="FilterHeadOption" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="FilterOtherContains" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="FilterSize" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="FinalizeNotProtected" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="FindAndMapToApply" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="FindEmptyCheck" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="FloatLiteralEndingWithDecimalPoint" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="FloatingPointEquality" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="FoldTrueAnd" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ForCanBeForeach" enabled="false" level="WARNING" enabled_by_default="false">
+ <option name="REPORT_INDEXED_LOOP" value="true" />
+ <option name="ignoreUntypedCollections" value="false" />
+ </inspection_tool>
+ <inspection_tool class="ForwardReference" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="FunctionTupleSyntacticSugar" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="GetGetOrElse" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="GetOrElseNull" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="HashCodeUsesVar" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
+ <inspection_tool class="HeadOrLastOption" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="HoconIncludeResolution" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="HtmlPresentationalElement" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="IfElseToOption" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="IfMayBeConditional" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="IfStatementWithIdenticalBranches" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="IgnoreResultOfCall" enabled="false" level="WARNING" enabled_by_default="false">
+ <option name="m_reportAllNonLibraryCalls" value="false" />
+ <option name="callCheckString" value="java.io.InputStream,read,java.io.InputStream,skip,java.lang.StringBuffer,toString,java.lang.StringBuilder,toString,java.lang.String,.*,java.math.BigInteger,.*,java.math.BigDecimal,.*,java.net.InetAddress,.*,java.io.File,.*,java.lang.Object,equals|hashCode" />
+ </inspection_tool>
+ <inspection_tool class="InjectionNotApplicable" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="InnerClassMayBeStatic" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="InstanceofThis" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="IntLiteralMayBeLongLiteral" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="IntegerDivisionInFloatingPointContext" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="IteratorHasNextCallsIteratorNext" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="IteratorNextDoesNotThrowNoSuchElementException" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="JavaAccessorMethodCalledAsEmptyParen" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="JavaAccessorMethodOverridenAsEmptyParen" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="JavaFxColorRgb" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="JavaFxDefaultTag" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="JavaFxEventHandler" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="JavaFxRedundantPropertyValue" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="JavaFxResourcePropertyValue" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="JavaFxUnresolvedFxIdReference" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="JavaFxUnusedImports" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="JavaLangImport" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="JavaMutatorMethodAccessedAsParameterless" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="JavaMutatorMethodOverridenAsParameterless" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="JsonDuplicatePropertyKeys" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="JsonStandardCompliance" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="KindProjectorSimplifyTypeProjection" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="KindProjectorUseCorrectLambdaKeyword" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="LabeledStatement" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="LanguageFeature" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="LanguageMismatch" enabled="false" level="WARNING" enabled_by_default="false">
+ <option name="CHECK_NON_ANNOTATED_REFERENCES" value="true" />
+ </inspection_tool>
+ <inspection_tool class="LastIndexToLast" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="LengthOneStringInIndexOf" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ListIndexOfReplaceableByContains" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="LiteralAsArgToStringEquals" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="LoopVariableNotUpdated" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="LossyEncoding" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="MapFlatten" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="MapGetGet" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="MapGetOrElseBoolean" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="MapKeys" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="MapReplaceableByEnumMap" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="MapToBooleanContains" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="MapValues" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="MatchToPartialFunction" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="MethodNameSameAsParentName" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="MethodNamesDifferOnlyByCase" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="MethodOverridesPackageLocalMethod" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="MethodOverridesPrivateMethod" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="MethodOverridesStaticMethod" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="MismatchedCollectionQueryUpdate" enabled="false" level="WEAK WARNING" enabled_by_default="false">
+ <option name="queryNames">
+ <value />
+ </option>
+ <option name="updateNames">
+ <value />
+ </option>
+ <option name="ignoredClasses">
+ <value />
+ </option>
+ </inspection_tool>
+ <inspection_tool class="MissingDeprecatedAnnotation" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="MissingOverrideAnnotation" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="ignoreObjectMethods" value="true" />
+ <option name="ignoreAnonymousClassMethods" value="false" />
+ </inspection_tool>
+ <inspection_tool class="MissortedModifiers" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="m_requireAnnotationsFirst" value="true" />
+ </inspection_tool>
+ <inspection_tool class="MisspelledCompareTo" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="MisspelledEquals" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="MisspelledHashcode" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="MisspelledToString" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="MultipleArgListsInAnnotation" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="MultipleRepositoryUrls" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="MutatorLikeMethodIsParameterless" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="NakedNotify" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="NameBooleanParameters" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="NoReturnTypeForImplicitDef" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="NonExceptionNameEndsWithException" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="NonFinalStaticVariableUsedInClassInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="NonProtectedConstructorInAbstractClass" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="m_ignoreNonPublicClasses" value="false" />
+ </inspection_tool>
+ <inspection_tool class="NonSerializableObjectBoundToHttpSession" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="NonSerializableWithSerialVersionUIDField" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="NonSerializableWithSerializationMethods" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="NonSynchronizedMethodOverridesSynchronizedMethod" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="NonThreadSafeLazyInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="NotImplementedCode" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="NotifyCalledOnCondition" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="NotifyNotInSynchronizedContext" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="NotifyWithoutCorrespondingWait" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="NullableProblems" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="REPORT_NULLABLE_METHOD_OVERRIDES_NOTNULL" value="true" />
+ <option name="REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL" value="false" />
+ <option name="REPORT_NOTNULL_PARAMETER_OVERRIDES_NULLABLE" value="true" />
+ <option name="REPORT_NOT_ANNOTATED_PARAMETER_OVERRIDES_NOTNULL" value="true" />
+ <option name="REPORT_NOT_ANNOTATED_GETTER" value="true" />
+ <option name="REPORT_NOT_ANNOTATED_SETTER_PARAMETER" value="true" />
+ <option name="REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS" value="false" />
+ <option name="REPORT_NULLS_PASSED_TO_NON_ANNOTATED_METHOD" value="true" />
+ </inspection_tool>
+ <inspection_tool class="ObjectNotify" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ObsoleteCollection" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="ignoreRequiredObsoleteCollectionTypes" value="false" />
+ </inspection_tool>
+ <inspection_tool class="OptionEqualsSome" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="OverlyStrongTypeCast" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="ignoreInMatchingInstanceof" value="false" />
+ </inspection_tool>
+ <inspection_tool class="OverriddenMethodCallDuringObjectConstruction" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="PackageVisibleInnerClass" enabled="true" level="WARNING" enabled_by_default="false">
+ <scope name="Production" level="WARNING" enabled="true">
+ <option name="ignoreEnums" value="false" />
+ <option name="ignoreInterfaces" value="false" />
+ </scope>
+ <option name="ignoreEnums" value="false" />
+ <option name="ignoreInterfaces" value="false" />
+ </inspection_tool>
+ <inspection_tool class="ParameterNameDiffersFromOverriddenParameter" enabled="false" level="WARNING" enabled_by_default="false">
+ <option name="m_ignoreSingleCharacterNames" value="false" />
+ <option name="m_ignoreOverridesOfLibraryMethods" value="true" />
+ </inspection_tool>
+ <inspection_tool class="ParameterlessMemberOverridenAsEmptyParen" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="PointlessIndexOfComparison" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ProtectedMemberInFinalClass" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="PublicField" enabled="true" level="WARNING" enabled_by_default="false">
+ <scope name="Production" level="WARNING" enabled="true">
+ <option name="ignoreEnums" value="false" />
+ <option name="ignorableAnnotations">
+ <value />
+ </option>
+ </scope>
+ <option name="ignoreEnums" value="false" />
+ <option name="ignorableAnnotations">
+ <value />
+ </option>
+ </inspection_tool>
+ <inspection_tool class="PublicFieldAccessedInSynchronizedContext" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="PublicInnerClass" enabled="true" level="WARNING" enabled_by_default="false">
+ <scope name="Production" level="WARNING" enabled="true">
+ <option name="ignoreEnums" value="false" />
+ <option name="ignoreInterfaces" value="false" />
+ </scope>
+ <option name="ignoreEnums" value="false" />
+ <option name="ignoreInterfaces" value="false" />
+ </inspection_tool>
+ <inspection_tool class="RangeToIndices" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ReadObjectAndWriteObjectPrivate" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ReadObjectInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ReadResolveAndWriteReplaceProtected" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="RedundantBlock" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="RedundantCollectionConversion" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="RedundantDefaultArgument" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="RedundantFieldInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="RedundantHeadOrLastOption" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="RedundantImplements" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="ignoreSerializable" value="false" />
+ <option name="ignoreCloneable" value="false" />
+ </inspection_tool>
+ <inspection_tool class="RedundantImport" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="RedundantMethodOverride" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="RedundantNewCaseClass" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="RedundantSuppression" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="RedundantThrowsDeclaration" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ReferenceMustBePrefixed" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="RemoveRedundantReturn" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ReplaceAssignmentWithOperatorAssignment" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="ignoreLazyOperators" value="true" />
+ <option name="ignoreObscureOperators" value="false" />
+ </inspection_tool>
+ <inspection_tool class="ReplaceToWithUntil" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ReplaceWithFlatten" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="RequiredAttributes" enabled="false" level="WARNING" enabled_by_default="false">
+ <option name="myAdditionalRequiredHtmlAttributes" value="" />
+ </inspection_tool>
+ <inspection_tool class="ResultOfObjectAllocationIgnored" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ResultSetIndexZero" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ReturnOfDateField" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ReverseIterator" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ReverseMap" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ReverseTakeReverse" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="SafeLock" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="SafeVarargsDetector" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="SameElementsToEquals" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="SamePackageImport" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="SameParameterValue" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaDefaultFileTemplate" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaDefaultFileTemplateUsage" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaDeprecatedIdentifier" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaDeprecation" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaDocInlinedTag" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaDocMissingParameterDescription" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaDocUnbalancedHeader" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaDocUnclosedTagWithoutParser" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaDocUnknownParameter" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaDocUnknownTag" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaFileName" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaMalformedFormatString" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaPackageName" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaRedundantCast" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaRedundantConversion" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaStyle" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaUnnecessaryParentheses" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaUnnecessarySemicolon" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaUnreachableCode" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaUnusedSymbol" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaUselessExpression" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
+ <inspection_tool class="ScalaXmlUnmatchedTag" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="SerialPersistentFieldsWithWrongSignature" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="SerialVersionUIDNotStaticFinal" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="SignalWithoutCorrespondingAwait" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="SimplifiableFoldOrReduce" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="SimplifiableIfStatement" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="SimplifyBoolean" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="SimplifyBooleanMatch" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="SingleImport" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="SizeReplaceableByIsEmpty" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="SizeToLength" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="SleepWhileHoldingLock" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="SortFilter" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="SpellCheckingInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false">
+ <option name="processCode" value="true" />
+ <option name="processLiterals" value="true" />
+ <option name="processComments" value="true" />
+ </inspection_tool>
+ <inspection_tool class="StringBufferToStringInConcatenation" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="StringEqualsEmptyString" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="SubtractionInCompareTo" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="SynchronizeOnLock" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="SynchronizedOnLiteralObject" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="SystemRunFinalizersOnExit" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="TextLabelInSwitchStatement" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ThreadDeathRethrown" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ThreadRun" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ThreadStartInConstruction" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ThreadStopSuspendResume" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ThreadYield" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ThrowableInstanceNeverThrown" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ThrowableResultOfMethodCallIgnored" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ToSetAndBack" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="TransientFieldInNonSerializableClass" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="TransientFieldNotInitialized" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="TrivialStringConcatenation" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="TypeAnnotation" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="TypeCheckCanBeMatch" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="TypeParameterExtendsFinalClass" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="TypeParameterShadow" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="UNCHECKED_WARNING" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="IGNORE_UNCHECKED_ASSIGNMENT" value="false" />
+ <option name="IGNORE_UNCHECKED_GENERICS_ARRAY_CREATION" value="true" />
+ <option name="IGNORE_UNCHECKED_CALL" value="false" />
+ <option name="IGNORE_UNCHECKED_CAST" value="true" />
+ <option name="IGNORE_UNCHECKED_OVERRIDING" value="false" />
+ </inspection_tool>
+ <inspection_tool class="UNUSED_SYMBOL" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="LOCAL_VARIABLE" value="true" />
+ <option name="FIELD" value="true" />
+ <option name="METHOD" value="false" />
+ <option name="CLASS" value="false" />
+ <option name="PARAMETER" value="true" />
+ <option name="REPORT_PARAMETER_FOR_PUBLIC_METHODS" value="false" />
+ </inspection_tool>
+ <inspection_tool class="UnaryPlus" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="UnconditionalWait" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="UnitInMap" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="UnitMethodIsParameterless" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="UnknownLanguage" enabled="false" level="ERROR" enabled_by_default="false" />
+ <inspection_tool class="UnnecessarilyQualifiedStaticUsage" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="m_ignoreStaticFieldAccesses" value="false" />
+ <option name="m_ignoreStaticMethodCalls" value="false" />
+ <option name="m_ignoreStaticAccessFromStaticContext" value="false" />
+ </inspection_tool>
+ <inspection_tool class="UnnecessaryAnnotationParentheses" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="UnnecessaryCallToStringValueOf" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="UnnecessaryConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="UnnecessaryFinalOnLocalVariable" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="UnnecessaryFinalOnParameter" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="onlyWarnOnAbstractMethods" value="false" />
+ </inspection_tool>
+ <inspection_tool class="UnnecessaryFullyQualifiedName" enabled="false" level="WARNING" enabled_by_default="false">
+ <option name="m_ignoreJavadoc" value="true" />
+ <option name="ignoreInModuleStatements" value="true" />
+ </inspection_tool>
+ <inspection_tool class="UnnecessaryInterfaceModifier" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="UnnecessaryJavaDocLink" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="ignoreInlineLinkToSuper" value="false" />
+ </inspection_tool>
+ <inspection_tool class="UnnecessaryPartialFunction" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="UnnecessaryQualifierForThis" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="UnnecessarySuperConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="UnnecessarySuperQualifier" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="UnnecessaryThis" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="UnnecessaryUnaryMinus" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="UnusedCatchParameter" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="m_ignoreCatchBlocksWithComments" value="false" />
+ <option name="m_ignoreTestCases" value="false" />
+ </inspection_tool>
+ <inspection_tool class="UnusedLibrary" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="UnusedReturnValue" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="UpperCaseFieldNameNotConstant" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="Use of postfix method call" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="VarCouldBeVal" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
+ <inspection_tool class="VariablePatternShadow" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="WaitCalledOnCondition" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="WaitNotInLoop" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="WaitNotInSynchronizedContext" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="WaitWhileHoldingTwoLocks" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="WaitWithoutCorrespondingNotify" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="WeakerAccess" enabled="false" level="WARNING" enabled_by_default="false">
+ <option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="true" />
+ <option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="true" />
+ <option name="SUGGEST_PRIVATE_FOR_INNERS" value="false" />
+ </inspection_tool>
+ <inspection_tool class="ZeroIndexToHead" enabled="false" level="WARNING" enabled_by_default="false" />
+ <inspection_tool class="ZeroLengthArrayInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="ZipWithIndex" enabled="false" level="WARNING" enabled_by_default="false" />
+</profile>
\ No newline at end of file
[08/19] ignite git commit: IGNITE-8761 WAL fsync at rollover should
be asynchronous in LOG_ONLY and BACKGROUND modes - Fixes #4356.
Posted by av...@apache.org.
IGNITE-8761 WAL fsync at rollover should be asynchronous in LOG_ONLY and BACKGROUND modes - Fixes #4356.
Signed-off-by: Ivan Rakov <ir...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3e75f910
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3e75f910
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3e75f910
Branch: refs/heads/ignite-9053
Commit: 3e75f9101411f0a6bf72aee1e52b2fc3507792ab
Parents: a14ee5c
Author: vd-pyatkov <vp...@gridgain.com>
Authored: Wed Aug 15 14:42:42 2018 +0300
Committer: Ivan Rakov <ir...@apache.org>
Committed: Wed Aug 15 14:42:42 2018 +0300
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../wal/FileWriteAheadLogManager.java | 62 +++++++++++++++++++-
2 files changed, 63 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3e75f910/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 21f6c5f..02c8b30 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -783,6 +783,9 @@ public final class IgniteSystemProperties {
*/
public static final String IGNITE_WAL_SERIALIZER_VERSION = "IGNITE_WAL_SERIALIZER_VERSION";
+ /** Property for setup Ignite WAL segment sync timeout. */
+ public static final String IGNITE_WAL_SEGMENT_SYNC_TIMEOUT = "IGNITE_WAL_SEGMENT_SYNC_TIMEOUT";
+
/**
* If the property is set Ignite will use legacy node comparator (based on node order) inste
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/3e75f910/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
index 712dca0..ed79e11 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
@@ -124,6 +124,7 @@ import static java.nio.file.StandardOpenOption.CREATE;
import static java.nio.file.StandardOpenOption.READ;
import static java.nio.file.StandardOpenOption.WRITE;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_MMAP;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_SEGMENT_SYNC_TIMEOUT;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_SERIALIZER_VERSION;
import static org.apache.ignite.configuration.WALMode.LOG_ONLY;
import static org.apache.ignite.events.EventType.EVT_WAL_SEGMENT_ARCHIVED;
@@ -135,12 +136,15 @@ import static org.apache.ignite.internal.processors.cache.persistence.wal.serial
import static org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.readSegmentHeader;
import static org.apache.ignite.internal.util.IgniteUtils.findField;
import static org.apache.ignite.internal.util.IgniteUtils.findNonPublicMethod;
+import static org.apache.ignite.internal.util.IgniteUtils.sleep;
/**
* File WAL manager.
*/
@SuppressWarnings("IfMayBeConditional")
public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter implements IgniteWriteAheadLogManager {
+ /** Dfault wal segment sync timeout. */
+ public static final long DFLT_WAL_SEGMENT_SYNC_TIMEOUT = 500L;
/** {@link MappedByteBuffer#force0(java.io.FileDescriptor, long, long)}. */
private static final Method force0 = findNonPublicMethod(
MappedByteBuffer.class, "force0",
@@ -351,6 +355,9 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
*/
@Nullable private volatile IgniteInClosure<FileIO> createWalFileListener;
+ /** Wal segment sync worker. */
+ private WalSegmentSyncer walSegmentSyncWorker;
+
/**
* @param ctx Kernal context.
*/
@@ -453,7 +460,10 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
walDisableContext = cctx.walState().walDisableContext();
- if (mode != WALMode.NONE) {
+ if (mode != WALMode.NONE && mode != WALMode.FSYNC) {
+ walSegmentSyncWorker = new WalSegmentSyncer(igCfg.getIgniteInstanceName(),
+ cctx.kernalContext().log(WalSegmentSyncer.class));
+
if (log.isInfoEnabled())
log.info("Started write-ahead log manager [mode=" + mode + ']');
}
@@ -562,6 +572,9 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
if (decompressor != null)
decompressor.shutdown();
+
+ if (walSegmentSyncWorker != null)
+ walSegmentSyncWorker.shutdown();
}
catch (Exception e) {
U.error(log, "Failed to gracefully close WAL segment: " + this.currHnd.fileIO, e);
@@ -583,6 +596,9 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
new IgniteThread(archiver).start();
}
+ if (walSegmentSyncWorker != null)
+ new IgniteThread(walSegmentSyncWorker).start();
+
if (compressor != null)
compressor.start();
}
@@ -3320,7 +3336,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
writeBuffer(seg.position(), seg.buffer());
}
catch (Throwable e) {
- log.error("Exception in WAL writer thread: ", e);
+ log.error("Exception in WAL writer thread:", e);
err = e;
}
@@ -3505,6 +3521,48 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
}
/**
+ * Syncs WAL segment file.
+ */
+ private class WalSegmentSyncer extends GridWorker {
+ /** Sync timeout. */
+ long syncTimeout;
+
+ /**
+ * @param igniteInstanceName Ignite instance name.
+ * @param log Logger.
+ */
+ public WalSegmentSyncer(String igniteInstanceName, IgniteLogger log) {
+ super(igniteInstanceName, "wal-segment-syncer", log);
+
+ syncTimeout = Math.max(IgniteSystemProperties.getLong(IGNITE_WAL_SEGMENT_SYNC_TIMEOUT,
+ DFLT_WAL_SEGMENT_SYNC_TIMEOUT), 100L);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException {
+ while (!isCancelled()) {
+ sleep(syncTimeout);
+
+ try {
+ flush(null, true);
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Exception when flushing WAL.", e);
+ }
+ }
+ }
+
+ /** Shutted down the worker. */
+ private void shutdown() {
+ synchronized (this) {
+ U.cancel(this);
+ }
+
+ U.join(this, log);
+ }
+ }
+
+ /**
* Scans provided folder for a WAL segment files
* @param walFilesDir directory to scan
* @return found WAL file descriptors
[18/19] ignite git commit: IGNITE-8493 GridToStringBuilder
arrayToString refactoring. - Fixes #4501.
Posted by av...@apache.org.
IGNITE-8493 GridToStringBuilder arrayToString refactoring. - Fixes #4501.
Signed-off-by: Dmitriy Pavlov <dp...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/dd8c933f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/dd8c933f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/dd8c933f
Branch: refs/heads/ignite-9053
Commit: dd8c933fd44e4ad9b315daccce8e2327606867b0
Parents: 82131d2
Author: Evgeny Stanilovskiy <es...@gridgain.com>
Authored: Wed Aug 15 20:28:48 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Wed Aug 15 20:35:08 2018 +0300
----------------------------------------------------------------------
.../util/tostring/GridToStringBuilder.java | 129 ++++++++-----------
.../tostring/GridToStringBuilderSelfTest.java | 97 +++++++++-----
...niteHadoopFileSystemClientBasedOpenTest.java | 2 +-
3 files changed, 116 insertions(+), 112 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/dd8c933f/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
index 67b9af1..329682f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
@@ -21,6 +21,7 @@ import java.io.Externalizable;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
+import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
@@ -853,7 +854,7 @@ public class GridToStringBuilder {
*/
private static void addArray(SBLimitedLength buf, Class arrType, Object obj) {
if (arrType.getComponentType().isPrimitive()) {
- buf.a(arrayToString(arrType, obj));
+ buf.a(arrayToString(obj));
return;
}
@@ -1075,95 +1076,40 @@ public class GridToStringBuilder {
}
/**
- * @param arrType Type of the array.
- * @param arr Array object.
+ * Returns limited string representation of array.
+ *
+ * @param arr Array object. Each value is automatically wrapped if it has a primitive type.
* @return String representation of an array.
*/
- @SuppressWarnings({"ConstantConditions", "unchecked"})
- public static <T> String arrayToString(Class arrType, Object arr) {
+ public static String arrayToString(Object arr) {
if (arr == null)
return "null";
String res;
- int more = 0;
- if (arrType.equals(byte[].class)) {
- byte[] byteArr = (byte[])arr;
- if (byteArr.length > COLLECTION_LIMIT) {
- more = byteArr.length - COLLECTION_LIMIT;
- byteArr = Arrays.copyOf(byteArr, COLLECTION_LIMIT);
- }
- res = Arrays.toString(byteArr);
- }
- else if (arrType.equals(boolean[].class)) {
- boolean[] boolArr = (boolean[])arr;
- if (boolArr.length > COLLECTION_LIMIT) {
- more = boolArr.length - COLLECTION_LIMIT;
- boolArr = Arrays.copyOf(boolArr, COLLECTION_LIMIT);
- }
- res = Arrays.toString(boolArr);
- }
- else if (arrType.equals(short[].class)) {
- short[] shortArr = (short[])arr;
- if (shortArr.length > COLLECTION_LIMIT) {
- more = shortArr.length - COLLECTION_LIMIT;
- shortArr = Arrays.copyOf(shortArr, COLLECTION_LIMIT);
- }
- res = Arrays.toString(shortArr);
- }
- else if (arrType.equals(int[].class)) {
- int[] intArr = (int[])arr;
- if (intArr.length > COLLECTION_LIMIT) {
- more = intArr.length - COLLECTION_LIMIT;
- intArr = Arrays.copyOf(intArr, COLLECTION_LIMIT);
- }
- res = Arrays.toString(intArr);
- }
- else if (arrType.equals(long[].class)) {
- long[] longArr = (long[])arr;
- if (longArr.length > COLLECTION_LIMIT) {
- more = longArr.length - COLLECTION_LIMIT;
- longArr = Arrays.copyOf(longArr, COLLECTION_LIMIT);
- }
- res = Arrays.toString(longArr);
- }
- else if (arrType.equals(float[].class)) {
- float[] floatArr = (float[])arr;
- if (floatArr.length > COLLECTION_LIMIT) {
- more = floatArr.length - COLLECTION_LIMIT;
- floatArr = Arrays.copyOf(floatArr, COLLECTION_LIMIT);
- }
- res = Arrays.toString(floatArr);
- }
- else if (arrType.equals(double[].class)) {
- double[] doubleArr = (double[])arr;
- if (doubleArr.length > COLLECTION_LIMIT) {
- more = doubleArr.length - COLLECTION_LIMIT;
- doubleArr = Arrays.copyOf(doubleArr, COLLECTION_LIMIT);
- }
- res = Arrays.toString(doubleArr);
- }
- else if (arrType.equals(char[].class)) {
- char[] charArr = (char[])arr;
- if (charArr.length > COLLECTION_LIMIT) {
- more = charArr.length - COLLECTION_LIMIT;
- charArr = Arrays.copyOf(charArr, COLLECTION_LIMIT);
- }
- res = Arrays.toString(charArr);
- }
- else {
+ int arrLen;
+
+ if (arr instanceof Object[]) {
Object[] objArr = (Object[])arr;
- if (objArr.length > COLLECTION_LIMIT) {
- more = objArr.length - COLLECTION_LIMIT;
+
+ arrLen = objArr.length;
+
+ if (arrLen > COLLECTION_LIMIT)
objArr = Arrays.copyOf(objArr, COLLECTION_LIMIT);
- }
+
res = Arrays.toString(objArr);
+ } else {
+ res = toStringWithLimit(arr, COLLECTION_LIMIT);
+
+ arrLen = Array.getLength(arr);
}
- if (more > 0) {
+
+ if (arrLen > COLLECTION_LIMIT) {
StringBuilder resSB = new StringBuilder(res);
resSB.deleteCharAt(resSB.length() - 1);
- resSB.append("... and ").append(more).append(" more]");
+
+ resSB.append("... and ").append(arrLen - COLLECTION_LIMIT).append(" more]");
res = resSB.toString();
}
@@ -1172,6 +1118,37 @@ public class GridToStringBuilder {
}
/**
+ * Returns limited string representation of array.
+ *
+ * @param arr Input array. Each value is automatically wrapped if it has a primitive type.
+ * @param limit max array items to string limit.
+ * @return String representation of an array.
+ */
+ private static String toStringWithLimit(Object arr, int limit) {
+ int arrIdxMax = Array.getLength(arr) - 1;
+
+ if (arrIdxMax == -1)
+ return "[]";
+
+ int idxMax = Math.min(arrIdxMax, limit);
+
+ StringBuilder b = new StringBuilder();
+
+ b.append('[');
+
+ for (int i = 0; i <= idxMax; ++i) {
+ b.append(Array.get(arr, i));
+
+ if (i == idxMax)
+ return b.append(']').toString();
+
+ b.append(", ");
+ }
+
+ return b.toString();
+ }
+
+ /**
* Produces uniformed output of string with context properties
*
* @param str Output prefix or {@code null} if empty.
http://git-wip-us.apache.org/repos/asf/ignite/blob/dd8c933f/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java
index 9a9e67e..d249914 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java
@@ -304,8 +304,8 @@ public class GridToStringBuilderSelfTest extends GridCommonAbstractTest {
* @param limit Array limit.
*/
private void checkArrayOverflow(Object[] arrOf, Object[] arr, int limit) {
- String arrStr = GridToStringBuilder.arrayToString(arr.getClass(), arr);
- String arrOfStr = GridToStringBuilder.arrayToString(arrOf.getClass(), arrOf);
+ String arrStr = GridToStringBuilder.arrayToString(arr);
+ String arrOfStr = GridToStringBuilder.arrayToString(arrOf);
// Simulate overflow
StringBuilder resultSB = new StringBuilder(arrStr);
@@ -332,75 +332,97 @@ public class GridToStringBuilderSelfTest extends GridCommonAbstractTest {
for (Object val : vals)
testArr(val, limit);
+ int[] intArr1 = new int[0];
+
+ assertEquals("[]", GridToStringBuilder.arrayToString(intArr1));
+ assertEquals("null", GridToStringBuilder.arrayToString(null));
+
+ int[] intArr2 = {1, 2, 3};
+
+ assertEquals("[1, 2, 3]", GridToStringBuilder.arrayToString(intArr2));
+
+ Object[] intArr3 = {2, 3, 4};
+
+ assertEquals("[2, 3, 4]", GridToStringBuilder.arrayToString(intArr3));
+
byte[] byteArr = new byte[1];
+
byteArr[0] = 1;
- assertEquals(Arrays.toString(byteArr), GridToStringBuilder.arrayToString(byteArr.getClass(), byteArr));
+ assertEquals(Arrays.toString(byteArr), GridToStringBuilder.arrayToString(byteArr));
byteArr = Arrays.copyOf(byteArr, 101);
assertTrue("Can't find \"... and 1 more\" in overflowed array string!",
- GridToStringBuilder.arrayToString(byteArr.getClass(), byteArr).contains("... and 1 more"));
+ GridToStringBuilder.arrayToString(byteArr).contains("... and 1 more"));
boolean[] boolArr = new boolean[1];
+
boolArr[0] = true;
- assertEquals(Arrays.toString(boolArr), GridToStringBuilder.arrayToString(boolArr.getClass(), boolArr));
+ assertEquals(Arrays.toString(boolArr), GridToStringBuilder.arrayToString(boolArr));
boolArr = Arrays.copyOf(boolArr, 101);
assertTrue("Can't find \"... and 1 more\" in overflowed array string!",
- GridToStringBuilder.arrayToString(boolArr.getClass(), boolArr).contains("... and 1 more"));
+ GridToStringBuilder.arrayToString(boolArr).contains("... and 1 more"));
short[] shortArr = new short[1];
+
shortArr[0] = 100;
- assertEquals(Arrays.toString(shortArr), GridToStringBuilder.arrayToString(shortArr.getClass(), shortArr));
+ assertEquals(Arrays.toString(shortArr), GridToStringBuilder.arrayToString(shortArr));
shortArr = Arrays.copyOf(shortArr, 101);
assertTrue("Can't find \"... and 1 more\" in overflowed array string!",
- GridToStringBuilder.arrayToString(shortArr.getClass(), shortArr).contains("... and 1 more"));
+ GridToStringBuilder.arrayToString(shortArr).contains("... and 1 more"));
int[] intArr = new int[1];
+
intArr[0] = 10000;
- assertEquals(Arrays.toString(intArr), GridToStringBuilder.arrayToString(intArr.getClass(), intArr));
+ assertEquals(Arrays.toString(intArr), GridToStringBuilder.arrayToString(intArr));
intArr = Arrays.copyOf(intArr, 101);
assertTrue("Can't find \"... and 1 more\" in overflowed array string!",
- GridToStringBuilder.arrayToString(intArr.getClass(), intArr).contains("... and 1 more"));
+ GridToStringBuilder.arrayToString(intArr).contains("... and 1 more"));
long[] longArr = new long[1];
+
longArr[0] = 10000000;
- assertEquals(Arrays.toString(longArr), GridToStringBuilder.arrayToString(longArr.getClass(), longArr));
+ assertEquals(Arrays.toString(longArr), GridToStringBuilder.arrayToString(longArr));
longArr = Arrays.copyOf(longArr, 101);
assertTrue("Can't find \"... and 1 more\" in overflowed array string!",
- GridToStringBuilder.arrayToString(longArr.getClass(), longArr).contains("... and 1 more"));
+ GridToStringBuilder.arrayToString(longArr).contains("... and 1 more"));
float[] floatArr = new float[1];
+
floatArr[0] = 1.f;
- assertEquals(Arrays.toString(floatArr), GridToStringBuilder.arrayToString(floatArr.getClass(), floatArr));
+ assertEquals(Arrays.toString(floatArr), GridToStringBuilder.arrayToString(floatArr));
floatArr = Arrays.copyOf(floatArr, 101);
assertTrue("Can't find \"... and 1 more\" in overflowed array string!",
- GridToStringBuilder.arrayToString(floatArr.getClass(), floatArr).contains("... and 1 more"));
+ GridToStringBuilder.arrayToString(floatArr).contains("... and 1 more"));
double[] doubleArr = new double[1];
+
doubleArr[0] = 1.;
- assertEquals(Arrays.toString(doubleArr), GridToStringBuilder.arrayToString(doubleArr.getClass(), doubleArr));
+ assertEquals(Arrays.toString(doubleArr), GridToStringBuilder.arrayToString(doubleArr));
doubleArr = Arrays.copyOf(doubleArr, 101);
assertTrue("Can't find \"... and 1 more\" in overflowed array string!",
- GridToStringBuilder.arrayToString(doubleArr.getClass(), doubleArr).contains("... and 1 more"));
+ GridToStringBuilder.arrayToString(doubleArr).contains("... and 1 more"));
+
+ char[] cArr = new char[1];
- char[] charArr = new char[1];
- charArr[0] = 'a';
- assertEquals(Arrays.toString(charArr), GridToStringBuilder.arrayToString(charArr.getClass(), charArr));
- charArr = Arrays.copyOf(charArr, 101);
+ cArr[0] = 'a';
+ assertEquals(Arrays.toString(cArr), GridToStringBuilder.arrayToString(cArr));
+ cArr = Arrays.copyOf(cArr, 101);
assertTrue("Can't find \"... and 1 more\" in overflowed array string!",
- GridToStringBuilder.arrayToString(charArr.getClass(), charArr).contains("... and 1 more"));
+ GridToStringBuilder.arrayToString(cArr).contains("... and 1 more"));
Map<String, String> strMap = new TreeMap<>();
List<String> strList = new ArrayList<>(limit+1);
- TestClass1 testClass = new TestClass1();
- testClass.strMap = strMap;
- testClass.strListIncl = strList;
+ TestClass1 testCls = new TestClass1();
+
+ testCls.strMap = strMap;
+ testCls.strListIncl = strList;
for (int i = 0; i < limit; i++) {
strMap.put("k" + i, "v");
strList.add("e");
}
- checkColAndMap(testClass);
+ checkColAndMap(testCls);
}
/**
@@ -459,21 +481,26 @@ public class GridToStringBuilderSelfTest extends GridCommonAbstractTest {
public void testToStringSizeLimits() throws Exception {
int limit = IgniteSystemProperties.getInteger(IGNITE_TO_STRING_MAX_LENGTH, 10_000);
int tailLen = limit / 10 * 2;
+
StringBuilder sb = new StringBuilder(limit + 10);
- for (int i = 0; i < limit - 100; i++) {
+
+ for (int i = 0; i < limit - 100; i++)
sb.append('a');
- }
+
String actual = GridToStringBuilder.toString(TestClass2.class, new TestClass2(sb.toString()));
- String expected = "TestClass2 [str=" + sb.toString() + ", nullArr=null]";
- assertEquals(expected, actual);
+ String exp = "TestClass2 [str=" + sb + ", nullArr=null]";
- for (int i = 0; i < 110; i++) {
+ assertEquals(exp, actual);
+
+ for (int i = 0; i < 110; i++)
sb.append('b');
- }
+
actual = GridToStringBuilder.toString(TestClass2.class, new TestClass2(sb.toString()));
- expected = "TestClass2 [str=" + sb.toString() + ", nullArr=null]";
- assertEquals(expected.substring(0, limit - tailLen), actual.substring(0, limit - tailLen));
- assertEquals(expected.substring(expected.length() - tailLen), actual.substring(actual.length() - tailLen));
+ exp = "TestClass2 [str=" + sb + ", nullArr=null]";
+
+ assertEquals(exp.substring(0, limit - tailLen), actual.substring(0, limit - tailLen));
+ assertEquals(exp.substring(exp.length() - tailLen), actual.substring(actual.length() - tailLen));
+
assertTrue(actual.contains("... and"));
assertTrue(actual.contains("skipped ..."));
}
@@ -620,7 +647,7 @@ public class GridToStringBuilderSelfTest extends GridCommonAbstractTest {
/**
* @param str String.
*/
- public TestClass2(String str) {
+ TestClass2(String str) {
this.str = str;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/dd8c933f/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedOpenTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedOpenTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedOpenTest.java
index 289e63d..932f4d8 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedOpenTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedOpenTest.java
@@ -176,7 +176,7 @@ public class IgniteHadoopFileSystemClientBasedOpenTest extends GridCommonAbstrac
*/
private void checkFsOpenWithAllNodesTypes() throws Exception {
for (int i = 0; i < nodesTypes.length; ++i) {
- log.info("Begin test case for nodes: " + S.arrayToString(NodeType.class, nodesTypes[i]));
+ log.info("Begin test case for nodes: " + S.arrayToString(nodesTypes[i]));
startNodes(nodesTypes[i]);
[06/19] ignite git commit: IGNITE-9131 Upgrade guava version in
Apache Ignite.
Posted by av...@apache.org.
IGNITE-9131 Upgrade guava version in Apache Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0a9d7f07
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0a9d7f07
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0a9d7f07
Branch: refs/heads/ignite-9053
Commit: 0a9d7f07f0b3e0cf13c9f096cf986ef03c206172
Parents: 9bb9c04
Author: Dmitriy Pavlov <dp...@apache.org>
Authored: Tue Aug 14 20:53:46 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Tue Aug 14 20:53:46 2018 +0300
----------------------------------------------------------------------
modules/camel/pom.xml | 1 -
modules/cassandra/store/pom.xml | 1 -
parent/pom.xml | 2 +-
3 files changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a9d7f07/modules/camel/pom.xml
----------------------------------------------------------------------
diff --git a/modules/camel/pom.xml b/modules/camel/pom.xml
index cc2872c..3942c9b 100644
--- a/modules/camel/pom.xml
+++ b/modules/camel/pom.xml
@@ -35,7 +35,6 @@
<url>http://ignite.apache.org</url>
<properties>
- <guava.version>18.0</guava.version>
<okhttp.version>2.5.0</okhttp.version>
</properties>
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a9d7f07/modules/cassandra/store/pom.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/pom.xml b/modules/cassandra/store/pom.xml
index df20518..df92156 100644
--- a/modules/cassandra/store/pom.xml
+++ b/modules/cassandra/store/pom.xml
@@ -39,7 +39,6 @@
<cassandra-driver.version>3.0.0</cassandra-driver.version>
<cassandra-all.version>3.3</cassandra-all.version>
<netty.version>4.1.27.Final</netty.version>
- <guava.version>19.0</guava.version>
<metrics-core.version>3.0.2</metrics-core.version>
</properties>
http://git-wip-us.apache.org/repos/asf/ignite/blob/0a9d7f07/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 4d925a0..5f486cb 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -66,7 +66,7 @@
<ezmorph.version>1.0.6</ezmorph.version>
<flume.ng.version>1.7.0</flume.ng.version>
<guava.retrying.version>2.0.0</guava.retrying.version>
- <guava.version>18.0</guava.version>
+ <guava.version>25.1-jre</guava.version>
<guava14.version>14.0.1</guava14.version>
<guava16.version>16.0.1</guava16.version>
<h2.version>1.4.195</h2.version>
[13/19] ignite git commit: IGNITE-6284 Add
IgniteCompute.withTaskNoResultCache() with similar effect as
@ComputeTaskNoResultCache - Fixes #2644.
Posted by av...@apache.org.
IGNITE-6284 Add IgniteCompute.withTaskNoResultCache() with similar effect as @ComputeTaskNoResultCache - Fixes #2644.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2e9ca8f1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2e9ca8f1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2e9ca8f1
Branch: refs/heads/ignite-9053
Commit: 2e9ca8f144c949faf799f2f338a0e63ed12f5483
Parents: 5342789
Author: Mikhail Lipkovich <li...@gmail.com>
Authored: Wed Aug 15 18:14:29 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Wed Aug 15 18:14:29 2018 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/IgniteCompute.java | 14 +++++++++++
.../ignite/internal/IgniteComputeImpl.java | 15 +++++++++++
.../task/GridTaskThreadContextKey.java | 3 +++
.../processors/task/GridTaskWorker.java | 7 +++++-
.../internal/GridTaskResultCacheSelfTest.java | 26 +++++++++++++++++---
5 files changed, 60 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2e9ca8f1/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java b/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
index 98a9eb6..2522121 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
@@ -702,6 +702,20 @@ public interface IgniteCompute extends IgniteAsyncSupport {
*/
public IgniteCompute withNoFailover();
+
+ /**
+ * Disables caching for the next executed task in the <b>current thread</b>.
+ * Has the same behaviour as annotation {@link org.apache.ignite.compute.ComputeTaskNoResultCache}.
+ *
+ * <p>
+ * Here is an example.
+ * <pre name="code" class="java">
+ * ignite.compute().withNoResultCache().run(new IgniteRunnable() {...});
+ * </pre>
+ * @return This {@code IgniteCompute} instance for chaining calls.
+ */
+ public IgniteCompute withNoResultCache();
+
/**
* Explicitly deploys a task with given class loader on the local node. Upon completion of this method,
* a task can immediately be executed on the grid, considering that all participating
http://git-wip-us.apache.org/repos/asf/ignite/blob/2e9ca8f1/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java
index 8d473e6..762d9a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java
@@ -52,6 +52,7 @@ import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.internal.GridClosureCallMode.BALANCE;
import static org.apache.ignite.internal.GridClosureCallMode.BROADCAST;
import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_NO_FAILOVER;
+import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_NO_RESULT_CACHE;
import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_SUBGRID_PREDICATE;
import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_SUBJ_ID;
import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_TASK_NAME;
@@ -1024,6 +1025,20 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
}
/** {@inheritDoc} */
+ @Override public IgniteCompute withNoResultCache() {
+ guard();
+
+ try {
+ ctx.task().setThreadContext(TC_NO_RESULT_CACHE, true);
+ }
+ finally {
+ unguard();
+ }
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
@Override public void localDeployTask(Class<? extends ComputeTask> taskCls, ClassLoader clsLdr) {
A.notNull(taskCls, "taskCls", clsLdr, "clsLdr");
http://git-wip-us.apache.org/repos/asf/ignite/blob/2e9ca8f1/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskThreadContextKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskThreadContextKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskThreadContextKey.java
index 92bcd41..bffcecd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskThreadContextKey.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskThreadContextKey.java
@@ -27,6 +27,9 @@ public enum GridTaskThreadContextKey {
/** No failover flag. */
TC_NO_FAILOVER,
+ /** No result cache flag. */
+ TC_NO_RESULT_CACHE,
+
/** Projection for the task. */
TC_SUBGRID,
http://git-wip-us.apache.org/repos/asf/ignite/blob/2e9ca8f1/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
index 78efd2d..82ad5d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
@@ -103,6 +103,7 @@ import static org.apache.ignite.internal.managers.communication.GridIoPolicy.MAN
import static org.apache.ignite.internal.managers.communication.GridIoPolicy.PUBLIC_POOL;
import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_IO_POLICY;
import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_NO_FAILOVER;
+import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_NO_RESULT_CACHE;
/**
* Grid task worker. Handles full task life cycle.
@@ -314,7 +315,11 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
marsh = ctx.config().getMarshaller();
- resCache = dep.annotation(taskCls, ComputeTaskNoResultCache.class) == null;
+ boolean noResCacheAnnotation = dep.annotation(taskCls, ComputeTaskNoResultCache.class) != null;
+
+ Boolean noResCacheCtxFlag = getThreadContext(TC_NO_RESULT_CACHE);
+
+ resCache = !(noResCacheAnnotation || (noResCacheCtxFlag != null && noResCacheCtxFlag));
Boolean noFailover = getThreadContext(TC_NO_FAILOVER);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2e9ca8f1/modules/core/src/test/java/org/apache/ignite/internal/GridTaskResultCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskResultCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskResultCacheSelfTest.java
index fb66652..c6bb43f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskResultCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskResultCacheSelfTest.java
@@ -47,10 +47,21 @@ public class GridTaskResultCacheSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
- public void testNoCacheResults() throws Exception {
+ public void testNoCacheResultAnnotationUsage() throws Exception {
Ignite ignite = G.ignite(getTestIgniteInstanceName());
- ignite.compute().execute(GridResultNoCacheTestTask.class, "Grid Result No Cache Test Argument");
+ ignite.compute()
+ .execute(GridResultNoCacheResultAnnotationTestTask.class, "Grid Result No Cache Annotation Test Argument");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNoCacheResultMethodUsage() throws Exception {
+ Ignite ignite = G.ignite(getTestIgniteInstanceName());
+
+ ignite.compute().withNoResultCache()
+ .execute(GridResultNoCacheResultMethodTestTask.class, "Grid Result No Cache Method Test Argument");
}
/**
@@ -65,8 +76,7 @@ public class GridTaskResultCacheSelfTest extends GridCommonAbstractTest {
/**
*
*/
- @ComputeTaskNoResultCache
- private static class GridResultNoCacheTestTask extends GridAbstractCacheTestTask {
+ private static class GridResultNoCacheResultMethodTestTask extends GridAbstractCacheTestTask {
/** {@inheritDoc} */
@Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) {
assert res.getData() != null;
@@ -86,6 +96,14 @@ public class GridTaskResultCacheSelfTest extends GridCommonAbstractTest {
/**
*
*/
+ @ComputeTaskNoResultCache
+ private static class GridResultNoCacheResultAnnotationTestTask extends GridResultNoCacheResultMethodTestTask {
+
+ }
+
+ /**
+ *
+ */
private static class GridResultCacheTestTask extends GridAbstractCacheTestTask {
/** {@inheritDoc} */
@Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) {
[07/19] ignite git commit: IGNITE-9195 Split PDS 2 TC configuration
into 3 suites. - Fixes #4496.
Posted by av...@apache.org.
IGNITE-9195 Split PDS 2 TC configuration into 3 suites. - Fixes #4496.
Signed-off-by: Dmitriy Pavlov <dp...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a14ee5cd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a14ee5cd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a14ee5cd
Branch: refs/heads/ignite-9053
Commit: a14ee5cd8a36a764fed8baa46de9c8abe3fcf14a
Parents: 0a9d7f0
Author: pereslegin-pa <xx...@gmail.com>
Authored: Tue Aug 14 21:20:50 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Tue Aug 14 21:20:50 2018 +0300
----------------------------------------------------------------------
.../testsuites/IgniteLostAndFoundTestSuite.java | 1 -
.../ignite/testsuites/IgnitePdsTestSuite.java | 2 +-
.../ignite/testsuites/IgnitePdsTestSuite2.java | 25 --------
.../ignite/testsuites/IgnitePdsTestSuite3.java | 49 +++++++++++++++
.../ignite/testsuites/IgnitePdsTestSuite4.java | 63 ++++++++++++++++++++
5 files changed, 113 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a14ee5cd/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLostAndFoundTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLostAndFoundTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLostAndFoundTestSuite.java
index 7fc40df..37bb2d6 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLostAndFoundTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLostAndFoundTestSuite.java
@@ -51,7 +51,6 @@ public class IgniteLostAndFoundTestSuite extends TestSuite {
public static TestSuite suite() {
TestSuite suite = new TestSuite("Ignite List And Found Test Suite");
- suite.addTestSuite(FileDownloaderTest.class);
suite.addTestSuite(FileIOTest.class);
suite.addTestSuite(FileLocksTest.class);
suite.addTestSuite(GridComputeJobExecutionErrorToLogManualTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a14ee5cd/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java
index 25315ea..0a995da 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java
@@ -104,7 +104,7 @@ public class IgnitePdsTestSuite extends TestSuite {
*
* @param suite suite to add tests into.
*/
- public static void addRealPageStoreTestsLongRunning(TestSuite suite) {
+ private static void addRealPageStoreTestsLongRunning(TestSuite suite) {
// Basic PageMemory tests.
suite.addTestSuite(IgnitePdsPageReplacementTest.class);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a14ee5cd/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
index a3905f1..2614f1d 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
@@ -19,15 +19,10 @@ package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
import org.apache.ignite.internal.processors.cache.persistence.IgniteDataStorageMetricsSelfTest;
-import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsContinuousRestartTest;
-import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsContinuousRestartTestWithExpiryPolicy;
-import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes;
import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsCorruptedStoreTest;
import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsExchangeDuringCheckpointTest;
import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsPageSizesTest;
import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsPartitionFilesDestroyTest;
-import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsRecoveryAfterFileCorruptionTest;
-import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsTaskCancelingTest;
import org.apache.ignite.internal.processors.cache.persistence.IgnitePersistentStoreDataStructuresTest;
import org.apache.ignite.internal.processors.cache.persistence.IgniteRebalanceScheduleResendPartitionsTest;
import org.apache.ignite.internal.processors.cache.persistence.LocalWacModeNoChangeDuringRebalanceOnNonNodeAssignTest;
@@ -37,9 +32,7 @@ import org.apache.ignite.internal.processors.cache.persistence.baseline.ClientAf
import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteAllBaselineNodesOnlineFullApiSelfTest;
import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteOfflineBaselineNodeFullApiSelfTest;
import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteOnlineNodeOutOfBaselineFullApiSelfTest;
-import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsPageEvictionDuringPartitionClearTest;
import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsRebalancingOnNotStableTopologyTest;
-import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsTransactionsHangTest;
import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsWholeClusterRestartTest;
import org.apache.ignite.internal.processors.cache.persistence.db.SlowHistoricalRebalanceSmallHistoryTest;
import org.apache.ignite.internal.processors.cache.persistence.db.checkpoint.IgniteCheckpointDirtyPagesForLowLoadTest;
@@ -64,7 +57,6 @@ import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalS
import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalCompactionTest;
import org.apache.ignite.internal.processors.cache.persistence.db.wal.crc.IgniteDataIntegrityTests;
import org.apache.ignite.internal.processors.cache.persistence.db.wal.reader.IgniteWalReaderTest;
-import org.apache.ignite.internal.processors.cache.persistence.file.FileDownloaderTest;
/**
*
@@ -90,10 +82,6 @@ public class IgnitePdsTestSuite2 extends TestSuite {
suite.addTestSuite(ClientAffinityAssignmentWithBaselineTest.class);
suite.addTestSuite(IgniteAbsentEvictionNodeOutOfBaselineTest.class);
- suite.addTestSuite(FileDownloaderTest.class);
-
- suite.addTestSuite(IgnitePdsTaskCancelingTest.class);
-
return suite;
}
@@ -103,19 +91,6 @@ public class IgnitePdsTestSuite2 extends TestSuite {
* @param suite suite to add tests into.
*/
private static void addRealPageStoreTestsNotForDirectIo(TestSuite suite) {
- suite.addTestSuite(IgnitePdsTransactionsHangTest.class);
-
- suite.addTestSuite(IgnitePdsPageEvictionDuringPartitionClearTest.class);
-
- // Rebalancing test
- suite.addTestSuite(IgnitePdsContinuousRestartTest.class);
- suite.addTestSuite(IgnitePdsContinuousRestartTestWithExpiryPolicy.class);
-
- suite.addTestSuite(IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes.class);
-
- // Integrity test.
- suite.addTestSuite(IgnitePdsRecoveryAfterFileCorruptionTest.class);
-
suite.addTestSuite(IgnitePdsPartitionFilesDestroyTest.class);
suite.addTestSuite(LocalWalModeChangeDuringRebalancingSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a14ee5cd/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite3.java
new file mode 100644
index 0000000..06ba9c0
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite3.java
@@ -0,0 +1,49 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsContinuousRestartTest;
+import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsContinuousRestartTestWithExpiryPolicy;
+
+/**
+ *
+ */
+public class IgnitePdsTestSuite3 extends TestSuite {
+ /**
+ * @return Suite.
+ */
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite("Ignite Persistent Store Test Suite 3");
+
+ addRealPageStoreTestsNotForDirectIo(suite);
+
+ return suite;
+ }
+
+ /**
+ * Fills {@code suite} with PDS test subset, which operates with real page store, but requires long time to execute.
+ *
+ * @param suite suite to add tests into.
+ */
+ private static void addRealPageStoreTestsNotForDirectIo(TestSuite suite) {
+ // Rebalancing test
+ suite.addTestSuite(IgnitePdsContinuousRestartTest.class);
+ suite.addTestSuite(IgnitePdsContinuousRestartTestWithExpiryPolicy.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a14ee5cd/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite4.java
new file mode 100644
index 0000000..2e6a439
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite4.java
@@ -0,0 +1,63 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes;
+import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsRecoveryAfterFileCorruptionTest;
+import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsTaskCancelingTest;
+import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsPageEvictionDuringPartitionClearTest;
+import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsTransactionsHangTest;
+import org.apache.ignite.internal.processors.cache.persistence.file.FileDownloaderTest;
+
+/**
+ *
+ */
+public class IgnitePdsTestSuite4 extends TestSuite {
+ /**
+ * @return Suite.
+ */
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite("Ignite Persistent Store Test Suite 4");
+
+ addRealPageStoreTestsNotForDirectIo(suite);
+
+ suite.addTestSuite(FileDownloaderTest.class);
+
+ suite.addTestSuite(IgnitePdsTaskCancelingTest.class);
+
+ return suite;
+ }
+
+ /**
+ * Fills {@code suite} with PDS test subset, which operates with real page store, but requires long time to execute.
+ *
+ * @param suite suite to add tests into.
+ */
+ private static void addRealPageStoreTestsNotForDirectIo(TestSuite suite) {
+ suite.addTestSuite(IgnitePdsTransactionsHangTest.class);
+
+ suite.addTestSuite(IgnitePdsPageEvictionDuringPartitionClearTest.class);
+
+ // Rebalancing test
+ suite.addTestSuite(IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes.class);
+
+ // Integrity test.
+ suite.addTestSuite(IgnitePdsRecoveryAfterFileCorruptionTest.class);
+ }
+}
[05/19] ignite git commit: IGNITE-9209 fix for
GridDistributedTxMapping.toString() returns broken string. - Fixes #4519.
Posted by av...@apache.org.
IGNITE-9209 fix for GridDistributedTxMapping.toString() returns broken string. - Fixes #4519.
Signed-off-by: Dmitriy Pavlov <dp...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9bb9c043
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9bb9c043
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9bb9c043
Branch: refs/heads/ignite-9053
Commit: 9bb9c043513c3cc6c6b70c6c3395e5bb76fad75e
Parents: 2fc9073
Author: Dmitrii Ryabov <So...@gmail.com>
Authored: Tue Aug 14 18:03:01 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Tue Aug 14 18:03:01 2018 +0300
----------------------------------------------------------------------
.../internal/util/tostring/GridToStringBuilder.java | 10 +++++++---
.../util/tostring/GridToStringBuilderSelfTest.java | 13 +++++++++++++
2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9bb9c043/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
index 86daf7c..67b9af1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
@@ -985,6 +985,7 @@ public class GridToStringBuilder {
if (newStr)
return s;
+ // Called from another GTSB.toString(), so this string is already in the buffer and shouldn't be returned.
return "";
}
finally {
@@ -1052,7 +1053,6 @@ public class GridToStringBuilder {
}
// Specifically catching all exceptions.
catch (Exception e) {
-
// Remove entry from cache to avoid potential memory leak
// in case new class loader got loaded under the same identity hash.
classCache.remove(cls.getName() + System.identityHashCode(cls.getClassLoader()));
@@ -1605,7 +1605,7 @@ public class GridToStringBuilder {
private static String toStringImpl(String str, SBLimitedLength buf, Object[] propNames, Object[] propVals,
boolean[] propSens, int propCnt) {
- buf.setLength(0);
+ boolean newStr = buf.length() == 0;
if (str != null)
buf.a(str).a(" ");
@@ -1616,7 +1616,11 @@ public class GridToStringBuilder {
buf.a(']');
- return buf.toString();
+ if (newStr)
+ return buf.toString();
+
+ // Called from another GTSB.toString(), so this string is already in the buffer and shouldn't be returned.
+ return "";
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/9bb9c043/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java
index eff3349..9a9e67e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java
@@ -31,6 +31,8 @@ import java.util.concurrent.locks.ReadWriteLock;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
@@ -477,6 +479,17 @@ public class GridToStringBuilderSelfTest extends GridCommonAbstractTest {
}
/**
+ *
+ */
+ public void testObjectPlusStringToString() {
+ IgniteTxKey k = new IgniteTxKey(new KeyCacheObjectImpl(1, null, 1), 123);
+
+ info(k.toString());
+
+ assertTrue("Wrong string: " + k, k.toString().startsWith("IgniteTxKey ["));
+ }
+
+ /**
* Test class.
*/
private static class TestClass1 {
[17/19] ignite git commit: IGNITE-9261: [ML] Add ANN algorithm based
on ACD concept
Posted by av...@apache.org.
IGNITE-9261: [ML] Add ANN algorithm based on ACD concept
this closes #4534
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/82131d23
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/82131d23
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/82131d23
Branch: refs/heads/ignite-9053
Commit: 82131d23a723ff74780ca2beab84a155a1f97789
Parents: d57c3d6
Author: zaleslaw <za...@gmail.com>
Authored: Wed Aug 15 19:09:26 2018 +0300
Committer: Yury Babak <yb...@gridgain.com>
Committed: Wed Aug 15 19:09:26 2018 +0300
----------------------------------------------------------------------
.../ml/knn/ANNClassificationExample.java | 307 +++++++++++++++++
.../ml/knn/KNNClassificationExample.java | 8 +-
.../examples/ml/knn/KNNRegressionExample.java | 4 +-
.../ignite/examples/ml/tutorial/Step_6_KNN.java | 8 +-
.../ml/clustering/kmeans/KMeansTrainer.java | 95 +++--
.../boosting/GDBBinaryClassifierTrainer.java | 4 +-
.../parallelism/ParallelismStrategy.java | 15 +-
.../java/org/apache/ignite/ml/knn/KNNUtils.java | 8 +-
.../ignite/ml/knn/NNClassificationModel.java | 217 ++++++++++++
.../ml/knn/ann/ANNClassificationModel.java | 197 +++++++++++
.../ml/knn/ann/ANNClassificationTrainer.java | 343 +++++++++++++++++++
.../ignite/ml/knn/ann/ANNModelFormat.java | 84 +++++
.../apache/ignite/ml/knn/ann/ProbableLabel.java | 39 +++
.../apache/ignite/ml/knn/ann/package-info.java | 22 ++
.../classification/KNNClassificationModel.java | 189 +---------
.../ml/knn/classification/KNNModelFormat.java | 14 +-
.../ml/knn/classification/KNNStrategy.java | 29 --
.../ml/knn/classification/NNStrategy.java | 29 ++
.../ml/knn/regression/KNNRegressionModel.java | 4 +-
.../ignite/ml/structures/LabeledDataset.java | 220 ------------
.../structures/LabeledDatasetTestTrainPair.java | 114 ------
.../ignite/ml/structures/LabeledVectorSet.java | 220 ++++++++++++
.../LabeledVectorSetTestTrainPair.java | 114 ++++++
...abeledDatasetPartitionDataBuilderOnHeap.java | 12 +-
.../preprocessing/LabeledDatasetLoader.java | 10 +-
.../SVMLinearBinaryClassificationTrainer.java | 12 +-
.../org/apache/ignite/ml/LocalModelsTest.java | 45 ++-
.../ignite/ml/common/CollectionsTest.java | 6 +-
.../ignite/ml/knn/ANNClassificationTest.java | 108 ++++++
.../ignite/ml/knn/KNNClassificationTest.java | 19 +-
.../apache/ignite/ml/knn/KNNRegressionTest.java | 16 +-
.../org/apache/ignite/ml/knn/KNNTestSuite.java | 3 +-
.../ignite/ml/knn/LabeledDatasetHelper.java | 4 +-
.../ignite/ml/knn/LabeledDatasetTest.java | 294 ----------------
.../ignite/ml/knn/LabeledVectorSetTest.java | 294 ++++++++++++++++
35 files changed, 2172 insertions(+), 935 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/examples/src/main/java/org/apache/ignite/examples/ml/knn/ANNClassificationExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/ANNClassificationExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/ANNClassificationExample.java
new file mode 100644
index 0000000..9a68207
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/knn/ANNClassificationExample.java
@@ -0,0 +1,307 @@
+/*
+ * 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.examples.ml.knn;
+
+import java.util.Arrays;
+import java.util.UUID;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.ml.knn.NNClassificationModel;
+import org.apache.ignite.ml.knn.ann.ANNClassificationTrainer;
+import org.apache.ignite.ml.knn.classification.KNNClassificationTrainer;
+import org.apache.ignite.ml.knn.classification.NNStrategy;
+import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.math.distances.ManhattanDistance;
+import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
+import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
+import org.apache.ignite.thread.IgniteThread;
+
+/**
+ * Run ANN multi-class classification trainer over distributed dataset.
+ *
+ * @see KNNClassificationTrainer
+ */
+public class ANNClassificationExample {
+ /** Run example. */
+ public static void main(String[] args) throws InterruptedException {
+ System.out.println();
+ System.out.println(">>> ANN multi-class classification algorithm over cached dataset usage example started.");
+ // Start ignite grid.
+ try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+ System.out.println(">>> Ignite grid started.");
+
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ ANNClassificationExample.class.getSimpleName(), () -> {
+ IgniteCache<Integer, double[]> dataCache = getTestCache(ignite);
+
+ ANNClassificationTrainer trainer = new ANNClassificationTrainer()
+ .withDistance(new ManhattanDistance())
+ .withK(50)
+ .withMaxIterations(1000)
+ .withSeed(1234L)
+ .withEpsilon(1e-2);
+
+ long startTrainingTime = System.currentTimeMillis();
+
+ NNClassificationModel knnMdl = trainer.fit(
+ ignite,
+ dataCache,
+ (k, v) -> VectorUtils.of(Arrays.copyOfRange(v, 1, v.length)),
+ (k, v) -> v[0]
+ ).withK(5)
+ .withDistanceMeasure(new EuclideanDistance())
+ .withStrategy(NNStrategy.WEIGHTED);
+
+ long endTrainingTime = System.currentTimeMillis();
+
+ System.out.println(">>> ---------------------------------");
+ System.out.println(">>> | Prediction\t| Ground Truth\t|");
+ System.out.println(">>> ---------------------------------");
+
+ int amountOfErrors = 0;
+ int totalAmount = 0;
+
+ long totalPredictionTime = 0L;
+
+ try (QueryCursor<Cache.Entry<Integer, double[]>> observations = dataCache.query(new ScanQuery<>())) {
+ for (Cache.Entry<Integer, double[]> observation : observations) {
+ double[] val = observation.getValue();
+ double[] inputs = Arrays.copyOfRange(val, 1, val.length);
+ double groundTruth = val[0];
+
+ long startPredictionTime = System.currentTimeMillis();
+ double prediction = knnMdl.apply(new DenseVector(inputs));
+ long endPredictionTime = System.currentTimeMillis();
+
+ totalPredictionTime += (endPredictionTime - startPredictionTime);
+
+ totalAmount++;
+ if (groundTruth != prediction)
+ amountOfErrors++;
+
+ System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", prediction, groundTruth);
+ }
+
+ System.out.println(">>> ---------------------------------");
+
+ System.out.println("Training costs = " + (endTrainingTime - startTrainingTime));
+ System.out.println("Prediction costs = " + totalPredictionTime);
+
+ System.out.println("\n>>> Absolute amount of errors " + amountOfErrors);
+ System.out.println("\n>>> Accuracy " + (1 - amountOfErrors / (double) totalAmount));
+ System.out.println(totalAmount);
+ }
+ });
+
+ igniteThread.start();
+ igniteThread.join();
+ }
+ }
+
+ /**
+ * Fills cache with data and returns it.
+ *
+ * @param ignite Ignite instance.
+ * @return Filled Ignite Cache.
+ */
+ private static IgniteCache<Integer, double[]> getTestCache(Ignite ignite) {
+ CacheConfiguration<Integer, double[]> cacheConfiguration = new CacheConfiguration<>();
+ cacheConfiguration.setName("TEST_" + UUID.randomUUID());
+ cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 10));
+
+ IgniteCache<Integer, double[]> cache = ignite.createCache(cacheConfiguration);
+
+ for (int k = 0; k < 10; k++) { // multiplies the Iris dataset k times.
+ for (int i = 0; i < data.length; i++)
+ cache.put(k * 10000 + i, mutate(data[i], k));
+ }
+
+ return cache;
+ }
+
+ /**
+ * Tiny changing of data depending on k parameter.
+ * @param datum The vector data.
+ * @param k The passed parameter.
+ * @return The changed vector data.
+ */
+ private static double[] mutate(double[] datum, int k) {
+ for (int i = 0; i < datum.length; i++) datum[i] += k / 100000;
+ return datum;
+ }
+
+ /** The Iris dataset. */
+ private static final double[][] data = {
+ {1, 5.1, 3.5, 1.4, 0.2},
+ {1, 4.9, 3, 1.4, 0.2},
+ {1, 4.7, 3.2, 1.3, 0.2},
+ {1, 4.6, 3.1, 1.5, 0.2},
+ {1, 5, 3.6, 1.4, 0.2},
+ {1, 5.4, 3.9, 1.7, 0.4},
+ {1, 4.6, 3.4, 1.4, 0.3},
+ {1, 5, 3.4, 1.5, 0.2},
+ {1, 4.4, 2.9, 1.4, 0.2},
+ {1, 4.9, 3.1, 1.5, 0.1},
+ {1, 5.4, 3.7, 1.5, 0.2},
+ {1, 4.8, 3.4, 1.6, 0.2},
+ {1, 4.8, 3, 1.4, 0.1},
+ {1, 4.3, 3, 1.1, 0.1},
+ {1, 5.8, 4, 1.2, 0.2},
+ {1, 5.7, 4.4, 1.5, 0.4},
+ {1, 5.4, 3.9, 1.3, 0.4},
+ {1, 5.1, 3.5, 1.4, 0.3},
+ {1, 5.7, 3.8, 1.7, 0.3},
+ {1, 5.1, 3.8, 1.5, 0.3},
+ {1, 5.4, 3.4, 1.7, 0.2},
+ {1, 5.1, 3.7, 1.5, 0.4},
+ {1, 4.6, 3.6, 1, 0.2},
+ {1, 5.1, 3.3, 1.7, 0.5},
+ {1, 4.8, 3.4, 1.9, 0.2},
+ {1, 5, 3, 1.6, 0.2},
+ {1, 5, 3.4, 1.6, 0.4},
+ {1, 5.2, 3.5, 1.5, 0.2},
+ {1, 5.2, 3.4, 1.4, 0.2},
+ {1, 4.7, 3.2, 1.6, 0.2},
+ {1, 4.8, 3.1, 1.6, 0.2},
+ {1, 5.4, 3.4, 1.5, 0.4},
+ {1, 5.2, 4.1, 1.5, 0.1},
+ {1, 5.5, 4.2, 1.4, 0.2},
+ {1, 4.9, 3.1, 1.5, 0.1},
+ {1, 5, 3.2, 1.2, 0.2},
+ {1, 5.5, 3.5, 1.3, 0.2},
+ {1, 4.9, 3.1, 1.5, 0.1},
+ {1, 4.4, 3, 1.3, 0.2},
+ {1, 5.1, 3.4, 1.5, 0.2},
+ {1, 5, 3.5, 1.3, 0.3},
+ {1, 4.5, 2.3, 1.3, 0.3},
+ {1, 4.4, 3.2, 1.3, 0.2},
+ {1, 5, 3.5, 1.6, 0.6},
+ {1, 5.1, 3.8, 1.9, 0.4},
+ {1, 4.8, 3, 1.4, 0.3},
+ {1, 5.1, 3.8, 1.6, 0.2},
+ {1, 4.6, 3.2, 1.4, 0.2},
+ {1, 5.3, 3.7, 1.5, 0.2},
+ {1, 5, 3.3, 1.4, 0.2},
+ {2, 7, 3.2, 4.7, 1.4},
+ {2, 6.4, 3.2, 4.5, 1.5},
+ {2, 6.9, 3.1, 4.9, 1.5},
+ {2, 5.5, 2.3, 4, 1.3},
+ {2, 6.5, 2.8, 4.6, 1.5},
+ {2, 5.7, 2.8, 4.5, 1.3},
+ {2, 6.3, 3.3, 4.7, 1.6},
+ {2, 4.9, 2.4, 3.3, 1},
+ {2, 6.6, 2.9, 4.6, 1.3},
+ {2, 5.2, 2.7, 3.9, 1.4},
+ {2, 5, 2, 3.5, 1},
+ {2, 5.9, 3, 4.2, 1.5},
+ {2, 6, 2.2, 4, 1},
+ {2, 6.1, 2.9, 4.7, 1.4},
+ {2, 5.6, 2.9, 3.6, 1.3},
+ {2, 6.7, 3.1, 4.4, 1.4},
+ {2, 5.6, 3, 4.5, 1.5},
+ {2, 5.8, 2.7, 4.1, 1},
+ {2, 6.2, 2.2, 4.5, 1.5},
+ {2, 5.6, 2.5, 3.9, 1.1},
+ {2, 5.9, 3.2, 4.8, 1.8},
+ {2, 6.1, 2.8, 4, 1.3},
+ {2, 6.3, 2.5, 4.9, 1.5},
+ {2, 6.1, 2.8, 4.7, 1.2},
+ {2, 6.4, 2.9, 4.3, 1.3},
+ {2, 6.6, 3, 4.4, 1.4},
+ {2, 6.8, 2.8, 4.8, 1.4},
+ {2, 6.7, 3, 5, 1.7},
+ {2, 6, 2.9, 4.5, 1.5},
+ {2, 5.7, 2.6, 3.5, 1},
+ {2, 5.5, 2.4, 3.8, 1.1},
+ {2, 5.5, 2.4, 3.7, 1},
+ {2, 5.8, 2.7, 3.9, 1.2},
+ {2, 6, 2.7, 5.1, 1.6},
+ {2, 5.4, 3, 4.5, 1.5},
+ {2, 6, 3.4, 4.5, 1.6},
+ {2, 6.7, 3.1, 4.7, 1.5},
+ {2, 6.3, 2.3, 4.4, 1.3},
+ {2, 5.6, 3, 4.1, 1.3},
+ {2, 5.5, 2.5, 4, 1.3},
+ {2, 5.5, 2.6, 4.4, 1.2},
+ {2, 6.1, 3, 4.6, 1.4},
+ {2, 5.8, 2.6, 4, 1.2},
+ {2, 5, 2.3, 3.3, 1},
+ {2, 5.6, 2.7, 4.2, 1.3},
+ {2, 5.7, 3, 4.2, 1.2},
+ {2, 5.7, 2.9, 4.2, 1.3},
+ {2, 6.2, 2.9, 4.3, 1.3},
+ {2, 5.1, 2.5, 3, 1.1},
+ {2, 5.7, 2.8, 4.1, 1.3},
+ {3, 6.3, 3.3, 6, 2.5},
+ {3, 5.8, 2.7, 5.1, 1.9},
+ {3, 7.1, 3, 5.9, 2.1},
+ {3, 6.3, 2.9, 5.6, 1.8},
+ {3, 6.5, 3, 5.8, 2.2},
+ {3, 7.6, 3, 6.6, 2.1},
+ {3, 4.9, 2.5, 4.5, 1.7},
+ {3, 7.3, 2.9, 6.3, 1.8},
+ {3, 6.7, 2.5, 5.8, 1.8},
+ {3, 7.2, 3.6, 6.1, 2.5},
+ {3, 6.5, 3.2, 5.1, 2},
+ {3, 6.4, 2.7, 5.3, 1.9},
+ {3, 6.8, 3, 5.5, 2.1},
+ {3, 5.7, 2.5, 5, 2},
+ {3, 5.8, 2.8, 5.1, 2.4},
+ {3, 6.4, 3.2, 5.3, 2.3},
+ {3, 6.5, 3, 5.5, 1.8},
+ {3, 7.7, 3.8, 6.7, 2.2},
+ {3, 7.7, 2.6, 6.9, 2.3},
+ {3, 6, 2.2, 5, 1.5},
+ {3, 6.9, 3.2, 5.7, 2.3},
+ {3, 5.6, 2.8, 4.9, 2},
+ {3, 7.7, 2.8, 6.7, 2},
+ {3, 6.3, 2.7, 4.9, 1.8},
+ {3, 6.7, 3.3, 5.7, 2.1},
+ {3, 7.2, 3.2, 6, 1.8},
+ {3, 6.2, 2.8, 4.8, 1.8},
+ {3, 6.1, 3, 4.9, 1.8},
+ {3, 6.4, 2.8, 5.6, 2.1},
+ {3, 7.2, 3, 5.8, 1.6},
+ {3, 7.4, 2.8, 6.1, 1.9},
+ {3, 7.9, 3.8, 6.4, 2},
+ {3, 6.4, 2.8, 5.6, 2.2},
+ {3, 6.3, 2.8, 5.1, 1.5},
+ {3, 6.1, 2.6, 5.6, 1.4},
+ {3, 7.7, 3, 6.1, 2.3},
+ {3, 6.3, 3.4, 5.6, 2.4},
+ {3, 6.4, 3.1, 5.5, 1.8},
+ {3, 6, 3, 4.8, 1.8},
+ {3, 6.9, 3.1, 5.4, 2.1},
+ {3, 6.7, 3.1, 5.6, 2.4},
+ {3, 6.9, 3.1, 5.1, 2.3},
+ {3, 5.8, 2.7, 5.1, 1.9},
+ {3, 6.8, 3.2, 5.9, 2.3},
+ {3, 6.7, 3.3, 5.7, 2.5},
+ {3, 6.7, 3, 5.2, 2.3},
+ {3, 6.3, 2.5, 5, 1.9},
+ {3, 6.5, 3, 5.2, 2},
+ {3, 6.2, 3.4, 5.4, 2.3},
+ {3, 5.9, 3, 5.1, 1.8}
+ };
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNClassificationExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNClassificationExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNClassificationExample.java
index d12fc1d..b4602cc 100644
--- a/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNClassificationExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNClassificationExample.java
@@ -27,9 +27,9 @@ import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.ml.knn.classification.KNNClassificationModel;
+import org.apache.ignite.ml.knn.NNClassificationModel;
import org.apache.ignite.ml.knn.classification.KNNClassificationTrainer;
-import org.apache.ignite.ml.knn.classification.KNNStrategy;
+import org.apache.ignite.ml.knn.classification.NNStrategy;
import org.apache.ignite.ml.math.distances.EuclideanDistance;
import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
@@ -55,14 +55,14 @@ public class KNNClassificationExample {
KNNClassificationTrainer trainer = new KNNClassificationTrainer();
- KNNClassificationModel knnMdl = trainer.fit(
+ NNClassificationModel knnMdl = trainer.fit(
ignite,
dataCache,
(k, v) -> VectorUtils.of(Arrays.copyOfRange(v, 1, v.length)),
(k, v) -> v[0]
).withK(3)
.withDistanceMeasure(new EuclideanDistance())
- .withStrategy(KNNStrategy.WEIGHTED);
+ .withStrategy(NNStrategy.WEIGHTED);
System.out.println(">>> ---------------------------------");
System.out.println(">>> | Prediction\t| Ground Truth\t|");
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNRegressionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNRegressionExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNRegressionExample.java
index d1e5055..7c84949 100644
--- a/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNRegressionExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNRegressionExample.java
@@ -28,7 +28,7 @@ import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.ml.knn.classification.KNNClassificationTrainer;
-import org.apache.ignite.ml.knn.classification.KNNStrategy;
+import org.apache.ignite.ml.knn.classification.NNStrategy;
import org.apache.ignite.ml.knn.regression.KNNRegressionModel;
import org.apache.ignite.ml.knn.regression.KNNRegressionTrainer;
import org.apache.ignite.ml.math.distances.ManhattanDistance;
@@ -63,7 +63,7 @@ public class KNNRegressionExample {
(k, v) -> v[0]
).withK(5)
.withDistanceMeasure(new ManhattanDistance())
- .withStrategy(KNNStrategy.WEIGHTED);
+ .withStrategy(NNStrategy.WEIGHTED);
int totalAmount = 0;
// Calculate mean squared error (MSE)
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/examples/src/main/java/org/apache/ignite/examples/ml/tutorial/Step_6_KNN.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/tutorial/Step_6_KNN.java b/examples/src/main/java/org/apache/ignite/examples/ml/tutorial/Step_6_KNN.java
index e07e9f8..56e70f1 100644
--- a/examples/src/main/java/org/apache/ignite/examples/ml/tutorial/Step_6_KNN.java
+++ b/examples/src/main/java/org/apache/ignite/examples/ml/tutorial/Step_6_KNN.java
@@ -21,9 +21,9 @@ import java.io.FileNotFoundException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
-import org.apache.ignite.ml.knn.classification.KNNClassificationModel;
+import org.apache.ignite.ml.knn.NNClassificationModel;
import org.apache.ignite.ml.knn.classification.KNNClassificationTrainer;
-import org.apache.ignite.ml.knn.classification.KNNStrategy;
+import org.apache.ignite.ml.knn.classification.NNStrategy;
import org.apache.ignite.ml.math.functions.IgniteBiFunction;
import org.apache.ignite.ml.math.primitives.vector.Vector;
import org.apache.ignite.ml.preprocessing.encoding.EncoderTrainer;
@@ -88,12 +88,12 @@ public class Step_6_KNN {
KNNClassificationTrainer trainer = new KNNClassificationTrainer();
// Train decision tree model.
- KNNClassificationModel mdl = trainer.fit(
+ NNClassificationModel mdl = trainer.fit(
ignite,
dataCache,
normalizationPreprocessor,
lbExtractor
- ).withK(1).withStrategy(KNNStrategy.WEIGHTED);
+ ).withK(1).withStrategy(NNStrategy.WEIGHTED);
double accuracy = Evaluator.evaluate(
dataCache,
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/clustering/kmeans/KMeansTrainer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/clustering/kmeans/KMeansTrainer.java b/modules/ml/src/main/java/org/apache/ignite/ml/clustering/kmeans/KMeansTrainer.java
index 7dbc78a..c005312 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/clustering/kmeans/KMeansTrainer.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/clustering/kmeans/KMeansTrainer.java
@@ -18,8 +18,11 @@
package org.apache.ignite.ml.clustering.kmeans;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Random;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -35,8 +38,8 @@ import org.apache.ignite.ml.math.primitives.vector.Vector;
import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
import org.apache.ignite.ml.math.util.MapUtil;
-import org.apache.ignite.ml.structures.LabeledDataset;
import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
import org.apache.ignite.ml.structures.partition.LabeledDatasetPartitionDataBuilderOnHeap;
import org.apache.ignite.ml.trainers.SingleLabelDatasetTrainer;
@@ -62,23 +65,23 @@ public class KMeansTrainer extends SingleLabelDatasetTrainer<KMeansModel> {
/**
* Trains model based on the specified data.
*
- * @param datasetBuilder Dataset builder.
+ * @param datasetBuilder Dataset builder.
* @param featureExtractor Feature extractor.
- * @param lbExtractor Label extractor.
+ * @param lbExtractor Label extractor.
* @return Model.
*/
@Override public <K, V> KMeansModel fit(DatasetBuilder<K, V> datasetBuilder,
- IgniteBiFunction<K, V, Vector> featureExtractor, IgniteBiFunction<K, V, Double> lbExtractor) {
+ IgniteBiFunction<K, V, Vector> featureExtractor, IgniteBiFunction<K, V, Double> lbExtractor) {
assert datasetBuilder != null;
- PartitionDataBuilder<K, V, EmptyContext, LabeledDataset<Double, LabeledVector>> partDataBuilder = new LabeledDatasetPartitionDataBuilderOnHeap<>(
+ PartitionDataBuilder<K, V, EmptyContext, LabeledVectorSet<Double, LabeledVector>> partDataBuilder = new LabeledDatasetPartitionDataBuilderOnHeap<>(
featureExtractor,
lbExtractor
);
Vector[] centers;
- try (Dataset<EmptyContext, LabeledDataset<Double, LabeledVector>> dataset = datasetBuilder.build(
+ try (Dataset<EmptyContext, LabeledVectorSet<Double, LabeledVector>> dataset = datasetBuilder.build(
(upstream, upstreamSize) -> new EmptyContext(),
partDataBuilder
)) {
@@ -105,10 +108,12 @@ public class KMeansTrainer extends SingleLabelDatasetTrainer<KMeansModel> {
}
iteration++;
- centers = newCentroids;
+ for (int i = 0; i < centers.length; i++) {
+ if (newCentroids[i] != null)
+ centers[i] = newCentroids[i];
+ }
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new RuntimeException(e);
}
return new KMeansModel(centers, distance);
@@ -119,11 +124,11 @@ public class KMeansTrainer extends SingleLabelDatasetTrainer<KMeansModel> {
*
* @param centers Current centers on the current iteration.
* @param dataset Dataset.
- * @param cols Amount of columns.
+ * @param cols Amount of columns.
* @return Helper data to calculate the new centroids.
*/
private TotalCostAndCounts calcDataForNewCentroids(Vector[] centers,
- Dataset<EmptyContext, LabeledDataset<Double, LabeledVector>> dataset, int cols) {
+ Dataset<EmptyContext, LabeledVectorSet<Double, LabeledVector>> dataset, int cols) {
final Vector[] finalCenters = centers;
return dataset.compute(data -> {
@@ -142,10 +147,10 @@ public class KMeansTrainer extends SingleLabelDatasetTrainer<KMeansModel> {
int finalI = i;
res.sums.compute(centroidIdx,
- (IgniteBiFunction<Integer, Vector, Vector>)(ind, v) -> v.plus(data.getRow(finalI).features()));
+ (IgniteBiFunction<Integer, Vector, Vector>) (ind, v) -> v.plus(data.getRow(finalI).features()));
res.counts.merge(centroidIdx, 1,
- (IgniteBiFunction<Integer, Integer, Integer>)(i1, i2) -> i1 + i2);
+ (IgniteBiFunction<Integer, Integer, Integer>) (i1, i2) -> i1 + i2);
}
return res;
}, (a, b) -> a == null ? b : a.merge(b));
@@ -155,7 +160,7 @@ public class KMeansTrainer extends SingleLabelDatasetTrainer<KMeansModel> {
* Find the closest cluster center index and distance to it from a given point.
*
* @param centers Centers to look in.
- * @param pnt Point.
+ * @param pnt Point.
*/
private IgniteBiTuple<Integer, Double> findClosestCentroid(Vector[] centers, LabeledVector pnt) {
double bestDistance = Double.POSITIVE_INFINITY;
@@ -175,31 +180,62 @@ public class KMeansTrainer extends SingleLabelDatasetTrainer<KMeansModel> {
* K cluster centers are initialized randomly.
*
* @param dataset The dataset to pick up random centers.
- * @param k Amount of clusters.
+ * @param k Amount of clusters.
* @return K cluster centers.
*/
- private Vector[] initClusterCentersRandomly(Dataset<EmptyContext, LabeledDataset<Double, LabeledVector>> dataset,
- int k) {
+ private Vector[] initClusterCentersRandomly(Dataset<EmptyContext, LabeledVectorSet<Double, LabeledVector>> dataset,
+ int k) {
Vector[] initCenters = new DenseVector[k];
+ // Gets k or less vectors from each partition.
List<LabeledVector> rndPnts = dataset.compute(data -> {
List<LabeledVector> rndPnt = new ArrayList<>();
- rndPnt.add(data.getRow(new Random(seed).nextInt(data.rowSize())));
+
+ if (data.rowSize() != 0) {
+ if (data.rowSize() > k) { // If it's enough rows in partition to pick k vectors.
+ final Random random = new Random(seed);
+
+ for (int i = 0; i < k; i++) {
+ Set<Integer> uniqueIndices = new HashSet<>();
+ int nextIdx = random.nextInt(data.rowSize());
+ int maxRandomSearch = k; // It required to make the next cycle is finite.
+ int cntr = 0;
+
+ // Repeat nextIdx generation if it was picked earlier.
+ while (uniqueIndices.contains(nextIdx) && cntr < maxRandomSearch) {
+ nextIdx = random.nextInt(data.rowSize());
+ cntr++;
+ }
+ uniqueIndices.add(nextIdx);
+
+ rndPnt.add(data.getRow(nextIdx));
+ }
+ } else // If it's not enough vectors to pick k vectors.
+ for (int i = 0; i < data.rowSize(); i++)
+ rndPnt.add(data.getRow(i));
+ }
return rndPnt;
}, (a, b) -> a == null ? b : Stream.concat(a.stream(), b.stream()).collect(Collectors.toList()));
- for (int i = 0; i < k; i++) {
- final LabeledVector rndPnt = rndPnts.get(new Random(seed).nextInt(rndPnts.size()));
- rndPnts.remove(rndPnt);
- initCenters[i] = rndPnt.features();
- }
+ // Shuffle them.
+ Collections.shuffle(rndPnts);
+
+ // Pick k vectors randomly.
+ if (rndPnts.size() >= k) {
+ for (int i = 0; i < k; i++) {
+ final LabeledVector rndPnt = rndPnts.get(new Random(seed).nextInt(rndPnts.size()));
+ rndPnts.remove(rndPnt);
+ initCenters[i] = rndPnt.features();
+ }
+ } else
+ throw new RuntimeException("The KMeans Trainer required more than " + k + " vectors to find " + k + " clusters");
return initCenters;
}
/** Service class used for statistics. */
- private static class TotalCostAndCounts {
+ public static class TotalCostAndCounts {
/** */
double totalCost;
@@ -209,13 +245,24 @@ public class KMeansTrainer extends SingleLabelDatasetTrainer<KMeansModel> {
/** Count of points closest to the center with a given index. */
ConcurrentHashMap<Integer, Integer> counts = new ConcurrentHashMap<>();
+
+ /** Count of points closest to the center with a given index. */
+ ConcurrentHashMap<Integer, ConcurrentHashMap<Double, Integer>> centroidStat = new ConcurrentHashMap<>();
+
/** Merge current */
TotalCostAndCounts merge(TotalCostAndCounts other) {
this.totalCost += totalCost;
this.sums = MapUtil.mergeMaps(sums, other.sums, Vector::plus, ConcurrentHashMap::new);
this.counts = MapUtil.mergeMaps(counts, other.counts, (i1, i2) -> i1 + i2, ConcurrentHashMap::new);
+ this.centroidStat = MapUtil.mergeMaps(centroidStat, other.centroidStat, (m1, m2) ->
+ MapUtil.mergeMaps(m1, m2, (i1, i2) -> i1 + i2, ConcurrentHashMap::new), ConcurrentHashMap::new);
return this;
}
+
+ public ConcurrentHashMap<Integer, ConcurrentHashMap<Double, Integer>> getCentroidStat() {
+ return centroidStat;
+ }
+
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/composition/boosting/GDBBinaryClassifierTrainer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/composition/boosting/GDBBinaryClassifierTrainer.java b/modules/ml/src/main/java/org/apache/ignite/ml/composition/boosting/GDBBinaryClassifierTrainer.java
index 53a6219..3701557 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/composition/boosting/GDBBinaryClassifierTrainer.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/composition/boosting/GDBBinaryClassifierTrainer.java
@@ -29,8 +29,8 @@ import org.apache.ignite.ml.math.functions.IgniteBiFunction;
import org.apache.ignite.ml.math.functions.IgniteFunction;
import org.apache.ignite.ml.math.functions.IgniteTriFunction;
import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.structures.LabeledDataset;
import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
import org.apache.ignite.ml.structures.partition.LabeledDatasetPartitionDataBuilderOnHeap;
/**
@@ -76,7 +76,7 @@ public abstract class GDBBinaryClassifierTrainer extends GDBTrainer {
List<Double> uniqLabels = new ArrayList<Double>(
builder.build(new EmptyContextBuilder<>(), new LabeledDatasetPartitionDataBuilderOnHeap<>(featureExtractor, lExtractor))
- .compute((IgniteFunction<LabeledDataset<Double,LabeledVector>, Set<Double>>) x ->
+ .compute((IgniteFunction<LabeledVectorSet<Double,LabeledVector>, Set<Double>>) x ->
Arrays.stream(x.labels()).boxed().collect(Collectors.toSet()), (a, b) -> {
if (a == null)
return b;
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/environment/parallelism/ParallelismStrategy.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/environment/parallelism/ParallelismStrategy.java b/modules/ml/src/main/java/org/apache/ignite/ml/environment/parallelism/ParallelismStrategy.java
index cdf2d50..e7228f8 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/environment/parallelism/ParallelismStrategy.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/environment/parallelism/ParallelismStrategy.java
@@ -26,9 +26,13 @@ import org.apache.ignite.ml.math.functions.IgniteSupplier;
* bagging, learning submodels for One-vs-All model, Cross-Validation etc.
*/
public interface ParallelismStrategy {
+
+ /**
+ * The type of parallelism.
+ */
public enum Type {
- NO_PARALLELISM,
- ON_DEFAULT_POOL
+ /** No parallelism. */NO_PARALLELISM,
+ /** On default pool. */ON_DEFAULT_POOL
}
/**
@@ -38,6 +42,13 @@ public interface ParallelismStrategy {
*/
public <T> Promise<T> submit(IgniteSupplier<T> task);
+ /**
+ * Submit the list of tasks.
+ *
+ * @param tasks The task list.
+ * @param <T> The type of return value.
+ * @return The result of submit operation.
+ */
public default <T> List<Promise<T>> submit(List<IgniteSupplier<T>> tasks) {
List<Promise<T>> results = new ArrayList<>();
for(IgniteSupplier<T> task : tasks)
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/knn/KNNUtils.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/knn/KNNUtils.java b/modules/ml/src/main/java/org/apache/ignite/ml/knn/KNNUtils.java
index b5a0cdb..d7bccd8 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/knn/KNNUtils.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/knn/KNNUtils.java
@@ -23,8 +23,8 @@ import org.apache.ignite.ml.dataset.PartitionDataBuilder;
import org.apache.ignite.ml.dataset.primitive.context.EmptyContext;
import org.apache.ignite.ml.math.functions.IgniteBiFunction;
import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.structures.LabeledDataset;
import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
import org.apache.ignite.ml.structures.partition.LabeledDatasetPartitionDataBuilderOnHeap;
import org.jetbrains.annotations.Nullable;
@@ -40,14 +40,14 @@ public class KNNUtils {
* @param lbExtractor Label extractor.
* @return Dataset.
*/
- @Nullable public static <K, V> Dataset<EmptyContext, LabeledDataset<Double, LabeledVector>> buildDataset(DatasetBuilder<K, V> datasetBuilder, IgniteBiFunction<K, V, Vector> featureExtractor, IgniteBiFunction<K, V, Double> lbExtractor) {
- PartitionDataBuilder<K, V, EmptyContext, LabeledDataset<Double, LabeledVector>> partDataBuilder
+ @Nullable public static <K, V> Dataset<EmptyContext, LabeledVectorSet<Double, LabeledVector>> buildDataset(DatasetBuilder<K, V> datasetBuilder, IgniteBiFunction<K, V, Vector> featureExtractor, IgniteBiFunction<K, V, Double> lbExtractor) {
+ PartitionDataBuilder<K, V, EmptyContext, LabeledVectorSet<Double, LabeledVector>> partDataBuilder
= new LabeledDatasetPartitionDataBuilderOnHeap<>(
featureExtractor,
lbExtractor
);
- Dataset<EmptyContext, LabeledDataset<Double, LabeledVector>> dataset = null;
+ Dataset<EmptyContext, LabeledVectorSet<Double, LabeledVector>> dataset = null;
if (datasetBuilder != null) {
dataset = datasetBuilder.build(
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/knn/NNClassificationModel.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/knn/NNClassificationModel.java b/modules/ml/src/main/java/org/apache/ignite/ml/knn/NNClassificationModel.java
new file mode 100644
index 0000000..b7a57f5
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/knn/NNClassificationModel.java
@@ -0,0 +1,217 @@
+/*
+ * 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.ml.knn;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import org.apache.ignite.ml.Exportable;
+import org.apache.ignite.ml.Exporter;
+import org.apache.ignite.ml.Model;
+import org.apache.ignite.ml.knn.classification.KNNModelFormat;
+import org.apache.ignite.ml.knn.classification.NNStrategy;
+import org.apache.ignite.ml.math.distances.DistanceMeasure;
+import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.math.primitives.vector.Vector;
+import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
+import org.apache.ignite.ml.util.ModelTrace;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Common methods and fields for all kNN and aNN models
+ * to predict label based on neighbours' labels.
+ */
+public abstract class NNClassificationModel implements Model<Vector, Double>, Exportable<KNNModelFormat> {
+ /** Amount of nearest neighbors. */
+ protected int k = 5;
+
+ /** Distance measure. */
+ protected DistanceMeasure distanceMeasure = new EuclideanDistance();
+
+ /** kNN strategy. */
+ protected NNStrategy stgy = NNStrategy.SIMPLE;
+
+ /**
+ * Set up parameter of the NN model.
+ * @param k Amount of nearest neighbors.
+ * @return Model.
+ */
+ public NNClassificationModel withK(int k) {
+ this.k = k;
+ return this;
+ }
+
+ /**
+ * Set up parameter of the NN model.
+ * @param stgy Strategy of calculations.
+ * @return Model.
+ */
+ public NNClassificationModel withStrategy(NNStrategy stgy) {
+ this.stgy = stgy;
+ return this;
+ }
+
+ /**
+ * Set up parameter of the NN model.
+ * @param distanceMeasure Distance measure.
+ * @return Model.
+ */
+ public NNClassificationModel withDistanceMeasure(DistanceMeasure distanceMeasure) {
+ this.distanceMeasure = distanceMeasure;
+ return this;
+ }
+
+ /** */
+ protected LabeledVectorSet<Double, LabeledVector> buildLabeledDatasetOnListOfVectors(
+ List<LabeledVector> neighborsFromPartitions) {
+ LabeledVector[] arr = new LabeledVector[neighborsFromPartitions.size()];
+ for (int i = 0; i < arr.length; i++)
+ arr[i] = neighborsFromPartitions.get(i);
+
+ return new LabeledVectorSet<Double, LabeledVector>(arr);
+ }
+
+ /**
+ * Iterates along entries in distance map and fill the resulting k-element array.
+ *
+ * @param trainingData The training data.
+ * @param distanceIdxPairs The distance map.
+ * @return K-nearest neighbors.
+ */
+ @NotNull protected LabeledVector[] getKClosestVectors(LabeledVectorSet<Double, LabeledVector> trainingData,
+ TreeMap<Double, Set<Integer>> distanceIdxPairs) {
+ LabeledVector[] res;
+
+ if (trainingData.rowSize() <= k) {
+ res = new LabeledVector[trainingData.rowSize()];
+ for (int i = 0; i < trainingData.rowSize(); i++)
+ res[i] = trainingData.getRow(i);
+ }
+ else {
+ res = new LabeledVector[k];
+ int i = 0;
+ final Iterator<Double> iter = distanceIdxPairs.keySet().iterator();
+ while (i < k) {
+ double key = iter.next();
+ Set<Integer> idxs = distanceIdxPairs.get(key);
+ for (Integer idx : idxs) {
+ res[i] = trainingData.getRow(idx);
+ i++;
+ if (i >= k)
+ break; // go to next while-loop iteration
+ }
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * Computes distances between given vector and each vector in training dataset.
+ *
+ * @param v The given vector.
+ * @param trainingData The training dataset.
+ * @return Key - distanceMeasure from given features before features with idx stored in value. Value is presented
+ * with Set because there can be a few vectors with the same distance.
+ */
+ @NotNull protected TreeMap<Double, Set<Integer>> getDistances(Vector v, LabeledVectorSet<Double, LabeledVector> trainingData) {
+ TreeMap<Double, Set<Integer>> distanceIdxPairs = new TreeMap<>();
+
+ for (int i = 0; i < trainingData.rowSize(); i++) {
+
+ LabeledVector labeledVector = trainingData.getRow(i);
+ if (labeledVector != null) {
+ double distance = distanceMeasure.compute(v, labeledVector.features());
+ putDistanceIdxPair(distanceIdxPairs, i, distance);
+ }
+ }
+ return distanceIdxPairs;
+ }
+
+ /** */
+ protected void putDistanceIdxPair(Map<Double, Set<Integer>> distanceIdxPairs, int i, double distance) {
+ if (distanceIdxPairs.containsKey(distance)) {
+ Set<Integer> idxs = distanceIdxPairs.get(distance);
+ idxs.add(i);
+ }
+ else {
+ Set<Integer> idxs = new HashSet<>();
+ idxs.add(i);
+ distanceIdxPairs.put(distance, idxs);
+ }
+ }
+
+ /** */
+ protected double getClassWithMaxVotes(Map<Double, Double> clsVotes) {
+ return Collections.max(clsVotes.entrySet(), Map.Entry.comparingByValue()).getKey();
+ }
+
+ /** */
+ protected double getClassVoteForVector(NNStrategy stgy, double distance) {
+ if (stgy.equals(NNStrategy.WEIGHTED))
+ return 1 / distance; // strategy.WEIGHTED
+ else
+ return 1.0; // strategy.SIMPLE
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = 1;
+
+ res = res * 37 + k;
+ res = res * 37 + distanceMeasure.hashCode();
+ res = res * 37 + stgy.hashCode();
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+
+ NNClassificationModel that = (NNClassificationModel)obj;
+
+ return k == that.k && distanceMeasure.equals(that.distanceMeasure) && stgy.equals(that.stgy);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return toString(false);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString(boolean pretty) {
+ return ModelTrace.builder("KNNClassificationModel", pretty)
+ .addField("k", String.valueOf(k))
+ .addField("measure", distanceMeasure.getClass().getSimpleName())
+ .addField("strategy", stgy.name())
+ .toString();
+ }
+
+ /** */
+ public abstract <P> void saveModel(Exporter<KNNModelFormat, P> exporter, P path);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ANNClassificationModel.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ANNClassificationModel.java b/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ANNClassificationModel.java
new file mode 100644
index 0000000..e8c0b4a
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ANNClassificationModel.java
@@ -0,0 +1,197 @@
+/*
+ * 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.ml.knn.ann;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import org.apache.ignite.ml.Exporter;
+import org.apache.ignite.ml.knn.NNClassificationModel;
+import org.apache.ignite.ml.knn.classification.KNNModelFormat;
+import org.apache.ignite.ml.knn.classification.NNStrategy;
+import org.apache.ignite.ml.math.primitives.vector.Vector;
+import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
+import org.apache.ignite.ml.util.ModelTrace;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * ANN model to predict labels in multi-class classification task.
+ */
+public class ANNClassificationModel extends NNClassificationModel {
+ /** */
+ private static final long serialVersionUID = -127312378991350345L;
+
+ /** The labeled set of candidates. */
+ private final LabeledVectorSet<ProbableLabel, LabeledVector> candidates;
+
+ /**
+ * Build the model based on a candidates set.
+ * @param centers The candidates set.
+ */
+ public ANNClassificationModel(LabeledVectorSet<ProbableLabel, LabeledVector> centers) {
+ this.candidates = centers;
+ }
+
+ /** */
+ public LabeledVectorSet<ProbableLabel, LabeledVector> getCandidates() {
+ return candidates;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Double apply(Vector v) {
+ List<LabeledVector> neighbors = findKNearestNeighbors(v);
+ return classify(neighbors, v, stgy);
+ }
+
+ /** */
+ @Override public <P> void saveModel(Exporter<KNNModelFormat, P> exporter, P path) {
+ ANNModelFormat mdlData = new ANNModelFormat(k, distanceMeasure, stgy, candidates);
+ exporter.save(mdlData, path);
+ }
+
+ /**
+ * The main idea is calculation all distance pairs between given vector and all centroids in candidates set, sorting
+ * them and finding k vectors with min distance with the given vector.
+ *
+ * @param v The given vector.
+ * @return K-nearest neighbors.
+ */
+ private List<LabeledVector> findKNearestNeighbors(Vector v) {
+ return Arrays.asList(getKClosestVectors(getDistances(v)));
+ }
+
+ /**
+ * Iterates along entries in distance map and fill the resulting k-element array.
+ * @param distanceIdxPairs The distance map.
+ * @return K-nearest neighbors.
+ */
+ @NotNull private LabeledVector[] getKClosestVectors(
+ TreeMap<Double, Set<Integer>> distanceIdxPairs) {
+ LabeledVector[] res;
+
+ if (candidates.rowSize() <= k) {
+ res = new LabeledVector[candidates.rowSize()];
+ for (int i = 0; i < candidates.rowSize(); i++)
+ res[i] = candidates.getRow(i);
+ }
+ else {
+ res = new LabeledVector[k];
+ int i = 0;
+ final Iterator<Double> iter = distanceIdxPairs.keySet().iterator();
+ while (i < k) {
+ double key = iter.next();
+ Set<Integer> idxs = distanceIdxPairs.get(key);
+ for (Integer idx : idxs) {
+ res[i] = candidates.getRow(idx);
+ i++;
+ if (i >= k)
+ break; // go to next while-loop iteration
+ }
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * Computes distances between given vector and each vector in training dataset.
+ *
+ * @param v The given vector.
+ * @return Key - distanceMeasure from given features before features with idx stored in value. Value is presented
+ * with Set because there can be a few vectors with the same distance.
+ */
+ @NotNull private TreeMap<Double, Set<Integer>> getDistances(Vector v) {
+ TreeMap<Double, Set<Integer>> distanceIdxPairs = new TreeMap<>();
+
+ for (int i = 0; i < candidates.rowSize(); i++) {
+
+ LabeledVector labeledVector = candidates.getRow(i);
+ if (labeledVector != null) {
+ double distance = distanceMeasure.compute(v, labeledVector.features());
+ putDistanceIdxPair(distanceIdxPairs, i, distance);
+ }
+ }
+ return distanceIdxPairs;
+ }
+
+ /** */
+ private double classify(List<LabeledVector> neighbors, Vector v, NNStrategy stgy) {
+ Map<Double, Double> clsVotes = new HashMap<>();
+
+ for (LabeledVector neighbor : neighbors) {
+ TreeMap<Double, Double> probableClsLb = ((ProbableLabel)neighbor.label()).clsLbls;
+
+ double distance = distanceMeasure.compute(v, neighbor.features());
+
+ // we predict class label, not the probability vector (it need here another math with counting of votes)
+ probableClsLb.forEach((label, probability) -> {
+ double cnt = clsVotes.containsKey(label) ? clsVotes.get(label) : 0;
+ clsVotes.put(label, cnt + probability * getClassVoteForVector(stgy, distance));
+ });
+ }
+ return getClassWithMaxVotes(clsVotes);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = 1;
+
+ res = res * 37 + k;
+ res = res * 37 + distanceMeasure.hashCode();
+ res = res * 37 + stgy.hashCode();
+ res = res * 37 + candidates.hashCode();
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+
+ ANNClassificationModel that = (ANNClassificationModel)obj;
+
+ return k == that.k
+ && distanceMeasure.equals(that.distanceMeasure)
+ && stgy.equals(that.stgy)
+ && candidates.equals(that.candidates);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return toString(false);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString(boolean pretty) {
+ return ModelTrace.builder("KNNClassificationModel", pretty)
+ .addField("k", String.valueOf(k))
+ .addField("measure", distanceMeasure.getClass().getSimpleName())
+ .addField("strategy", stgy.name())
+ .addField("amount of candidates", String.valueOf(candidates.rowSize()))
+ .toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ANNClassificationTrainer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ANNClassificationTrainer.java b/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ANNClassificationTrainer.java
new file mode 100644
index 0000000..282be3c
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ANNClassificationTrainer.java
@@ -0,0 +1,343 @@
+/*
+ * 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.ml.knn.ann;
+
+import java.util.TreeMap;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentSkipListSet;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.ml.clustering.kmeans.KMeansModel;
+import org.apache.ignite.ml.clustering.kmeans.KMeansTrainer;
+import org.apache.ignite.ml.dataset.Dataset;
+import org.apache.ignite.ml.dataset.DatasetBuilder;
+import org.apache.ignite.ml.dataset.PartitionDataBuilder;
+import org.apache.ignite.ml.dataset.primitive.context.EmptyContext;
+import org.apache.ignite.ml.math.distances.DistanceMeasure;
+import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.math.functions.IgniteBiFunction;
+import org.apache.ignite.ml.math.primitives.vector.Vector;
+import org.apache.ignite.ml.math.util.MapUtil;
+import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
+import org.apache.ignite.ml.structures.partition.LabeledDatasetPartitionDataBuilderOnHeap;
+import org.apache.ignite.ml.trainers.SingleLabelDatasetTrainer;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * ANN algorithm trainer to solve multi-class classification task.
+ * This trainer is based on ACD strategy and KMeans clustering algorithm to find centroids.
+ */
+public class ANNClassificationTrainer extends SingleLabelDatasetTrainer<ANNClassificationModel> {
+ /** Amount of clusters. */
+ private int k = 2;
+
+ /** Amount of iterations. */
+ private int maxIterations = 10;
+
+ /** Delta of convergence. */
+ private double epsilon = 1e-4;
+
+ /** Distance measure. */
+ private DistanceMeasure distance = new EuclideanDistance();
+
+ /** KMeans initializer. */
+ private long seed;
+
+ /**
+ * Trains model based on the specified data.
+ *
+ * @param datasetBuilder Dataset builder.
+ * @param featureExtractor Feature extractor.
+ * @param lbExtractor Label extractor.
+ * @return Model.
+ */
+ @Override public <K, V> ANNClassificationModel fit(DatasetBuilder<K, V> datasetBuilder, IgniteBiFunction<K, V, Vector> featureExtractor, IgniteBiFunction<K, V, Double> lbExtractor) {
+ final Vector[] centers = getCentroids(featureExtractor, lbExtractor, datasetBuilder);
+
+ final CentroidStat centroidStat = getCentroidStat(datasetBuilder, featureExtractor, lbExtractor, centers);
+
+ final LabeledVectorSet<ProbableLabel, LabeledVector> dataset = buildLabelsForCandidates(centers, centroidStat);
+
+ return new ANNClassificationModel(dataset);
+ }
+
+ /** */
+ @NotNull private LabeledVectorSet<ProbableLabel, LabeledVector> buildLabelsForCandidates(Vector[] centers, CentroidStat centroidStat) {
+ // init
+ final LabeledVector<Vector, ProbableLabel>[] arr = new LabeledVector[centers.length];
+
+ // fill label for each centroid
+ for (int i = 0; i < centers.length; i++)
+ arr[i] = new LabeledVector<>(centers[i], fillProbableLabel(i, centroidStat));
+
+ return new LabeledVectorSet<>(arr);
+ }
+
+ /**
+ * Perform KMeans clusterization algorithm to find centroids.
+ *
+ * @param featureExtractor Feature extractor.
+ * @param lbExtractor Label extractor.
+ * @param datasetBuilder The dataset builder.
+ * @param <K> Type of a key in {@code upstream} data.
+ * @param <V> Type of a value in {@code upstream} data.
+ * @return The arrays of vectors.
+ */
+ private <K, V> Vector[] getCentroids(IgniteBiFunction<K, V, Vector> featureExtractor, IgniteBiFunction<K, V, Double> lbExtractor, DatasetBuilder<K, V> datasetBuilder) {
+ KMeansTrainer trainer = new KMeansTrainer()
+ .withK(k)
+ .withMaxIterations(maxIterations)
+ .withSeed(seed)
+ .withDistance(distance)
+ .withEpsilon(epsilon);
+
+ KMeansModel mdl = trainer.fit(
+ datasetBuilder,
+ featureExtractor,
+ lbExtractor
+ );
+
+ return mdl.centers();
+ }
+
+ /** */
+ private ProbableLabel fillProbableLabel(int centroidIdx, CentroidStat centroidStat) {
+ TreeMap<Double, Double> clsLbls = new TreeMap<>();
+
+ // add all class labels as keys
+ centroidStat.clsLblsSet.forEach(t -> clsLbls.put(t, 0.0));
+
+ ConcurrentHashMap<Double, Integer> centroidLbDistribution
+ = centroidStat.centroidStat().get(centroidIdx);
+
+ if(centroidStat.counts.containsKey(centroidIdx)){
+
+ int clusterSize = centroidStat
+ .counts
+ .get(centroidIdx);
+
+ clsLbls.keySet().forEach(
+ (label) -> clsLbls.put(label, centroidLbDistribution.containsKey(label) ? ((double) (centroidLbDistribution.get(label)) / clusterSize) : 0.0)
+ );
+ }
+ return new ProbableLabel(clsLbls);
+ }
+
+ /** */
+ private <K, V> CentroidStat getCentroidStat(DatasetBuilder<K, V> datasetBuilder, IgniteBiFunction<K, V, Vector> featureExtractor, IgniteBiFunction<K, V, Double> lbExtractor, Vector[] centers) {
+ PartitionDataBuilder<K, V, EmptyContext, LabeledVectorSet<Double, LabeledVector>> partDataBuilder = new LabeledDatasetPartitionDataBuilderOnHeap<>(
+ featureExtractor,
+ lbExtractor
+ );
+
+ try (Dataset<EmptyContext, LabeledVectorSet<Double, LabeledVector>> dataset = datasetBuilder.build(
+ (upstream, upstreamSize) -> new EmptyContext(),
+ partDataBuilder
+ )) {
+
+ return dataset.compute(data -> {
+
+ CentroidStat res = new CentroidStat();
+
+ for (int i = 0; i < data.rowSize(); i++) {
+ final IgniteBiTuple<Integer, Double> closestCentroid = findClosestCentroid(centers, data.getRow(i));
+
+ int centroidIdx = closestCentroid.get1();
+
+ double lb = data.label(i);
+
+ // add new label to label set
+ res.labels().add(lb);
+
+ ConcurrentHashMap<Double, Integer> centroidStat = res.centroidStat.get(centroidIdx);
+
+ if (centroidStat == null) {
+ centroidStat = new ConcurrentHashMap<>();
+ centroidStat.put(lb, 1);
+ res.centroidStat.put(centroidIdx, centroidStat);
+ } else {
+ int cnt = centroidStat.containsKey(lb) ? centroidStat.get(lb) : 0;
+ centroidStat.put(lb, cnt + 1);
+ }
+
+ res.counts.merge(centroidIdx, 1,
+ (IgniteBiFunction<Integer, Integer, Integer>) (i1, i2) -> i1 + i2);
+ }
+ return res;
+ }, (a, b) -> a == null ? b : a.merge(b));
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Find the closest cluster center index and distance to it from a given point.
+ *
+ * @param centers Centers to look in.
+ * @param pnt Point.
+ */
+ private IgniteBiTuple<Integer, Double> findClosestCentroid(Vector[] centers, LabeledVector pnt) {
+ double bestDistance = Double.POSITIVE_INFINITY;
+ int bestInd = 0;
+
+ for (int i = 0; i < centers.length; i++) {
+ if (centers[i] != null) {
+ double dist = distance.compute(centers[i], pnt.features());
+ if (dist < bestDistance) {
+ bestDistance = dist;
+ bestInd = i;
+ }
+ }
+ }
+ return new IgniteBiTuple<>(bestInd, bestDistance);
+ }
+
+
+ /**
+ * Gets the amount of clusters.
+ *
+ * @return The parameter value.
+ */
+ public int getK() {
+ return k;
+ }
+
+ /**
+ * Set up the amount of clusters.
+ *
+ * @param k The parameter value.
+ * @return Model with new amount of clusters parameter value.
+ */
+ public ANNClassificationTrainer withK(int k) {
+ this.k = k;
+ return this;
+ }
+
+ /**
+ * Gets the max number of iterations before convergence.
+ *
+ * @return The parameter value.
+ */
+ public int getMaxIterations() {
+ return maxIterations;
+ }
+
+ /**
+ * Set up the max number of iterations before convergence.
+ *
+ * @param maxIterations The parameter value.
+ * @return Model with new max number of iterations before convergence parameter value.
+ */
+ public ANNClassificationTrainer withMaxIterations(int maxIterations) {
+ this.maxIterations = maxIterations;
+ return this;
+ }
+
+ /**
+ * Gets the epsilon.
+ *
+ * @return The parameter value.
+ */
+ public double getEpsilon() {
+ return epsilon;
+ }
+
+ /**
+ * Set up the epsilon.
+ *
+ * @param epsilon The parameter value.
+ * @return Model with new epsilon parameter value.
+ */
+ public ANNClassificationTrainer withEpsilon(double epsilon) {
+ this.epsilon = epsilon;
+ return this;
+ }
+
+ /**
+ * Gets the distance.
+ *
+ * @return The parameter value.
+ */
+ public DistanceMeasure getDistance() {
+ return distance;
+ }
+
+ /**
+ * Set up the distance.
+ *
+ * @param distance The parameter value.
+ * @return Model with new distance parameter value.
+ */
+ public ANNClassificationTrainer withDistance(DistanceMeasure distance) {
+ this.distance = distance;
+ return this;
+ }
+
+ /**
+ * Gets the seed number.
+ *
+ * @return The parameter value.
+ */
+ public long getSeed() {
+ return seed;
+ }
+
+ /**
+ * Set up the seed.
+ *
+ * @param seed The parameter value.
+ * @return Model with new seed parameter value.
+ */
+ public ANNClassificationTrainer withSeed(long seed) {
+ this.seed = seed;
+ return this;
+ }
+
+ /** Service class used for statistics. */
+ public static class CentroidStat {
+
+ /** Count of points closest to the center with a given index. */
+ ConcurrentHashMap<Integer, ConcurrentHashMap<Double, Integer>> centroidStat = new ConcurrentHashMap<>();
+
+ /** Count of points closest to the center with a given index. */
+ ConcurrentHashMap<Integer, Integer> counts = new ConcurrentHashMap<>();
+
+ /** Set of unique labels. */
+ ConcurrentSkipListSet<Double> clsLblsSet = new ConcurrentSkipListSet<>();
+
+ /** Merge current */
+ CentroidStat merge(CentroidStat other) {
+ this.counts = MapUtil.mergeMaps(counts, other.counts, (i1, i2) -> i1 + i2, ConcurrentHashMap::new);
+ this.centroidStat = MapUtil.mergeMaps(centroidStat, other.centroidStat, (m1, m2) ->
+ MapUtil.mergeMaps(m1, m2, (i1, i2) -> i1 + i2, ConcurrentHashMap::new), ConcurrentHashMap::new);
+ this.clsLblsSet.addAll(other.clsLblsSet);
+ return this;
+ }
+
+ /** */
+ public ConcurrentSkipListSet<Double> labels() {
+ return clsLblsSet;
+ }
+
+ /** */
+ ConcurrentHashMap<Integer, ConcurrentHashMap<Double, Integer>> centroidStat() {
+ return centroidStat;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ANNModelFormat.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ANNModelFormat.java b/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ANNModelFormat.java
new file mode 100644
index 0000000..e10f3b2
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ANNModelFormat.java
@@ -0,0 +1,84 @@
+/*
+ * 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.ml.knn.ann;
+
+import java.io.Serializable;
+import org.apache.ignite.ml.knn.classification.KNNModelFormat;
+import org.apache.ignite.ml.knn.classification.NNStrategy;
+import org.apache.ignite.ml.math.distances.DistanceMeasure;
+import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
+
+/**
+ * ANN model representation.
+ *
+ * @see ANNClassificationModel
+ */
+public class ANNModelFormat extends KNNModelFormat implements Serializable {
+ /** The labeled set of candidates. */
+ private LabeledVectorSet<ProbableLabel, LabeledVector> candidates;
+
+ /**
+ * Creates an instance.
+ * @param k Amount of nearest neighbors.
+ * @param measure Distance measure.
+ * @param stgy kNN strategy.
+ */
+ public ANNModelFormat(int k,
+ DistanceMeasure measure,
+ NNStrategy stgy,
+ LabeledVectorSet<ProbableLabel, LabeledVector> candidates) {
+ this.k = k;
+ this.distanceMeasure = measure;
+ this.stgy = stgy;
+ this.candidates = candidates;
+ }
+
+ /** */
+ public LabeledVectorSet<ProbableLabel, LabeledVector> getCandidates() {
+ return candidates;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = 1;
+
+ res = res * 37 + k;
+ res = res * 37 + distanceMeasure.hashCode();
+ res = res * 37 + stgy.hashCode();
+ res = res * 37 + candidates.hashCode();
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+
+ ANNModelFormat that = (ANNModelFormat)obj;
+
+ return k == that.k
+ && distanceMeasure.equals(that.distanceMeasure)
+ && stgy.equals(that.stgy)
+ && candidates.equals(that.candidates);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ProbableLabel.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ProbableLabel.java b/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ProbableLabel.java
new file mode 100644
index 0000000..1fee123
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/ProbableLabel.java
@@ -0,0 +1,39 @@
+/*
+ * 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.ml.knn.ann;
+
+import java.util.TreeMap;
+
+/**
+ * The special class for fuzzy labels presenting the probability distribution
+ * over the class labels.
+ */
+public class ProbableLabel {
+ /** Key is label, value is probability to be this class */
+ TreeMap<Double, Double> clsLbls;
+
+ /**
+ * The key is class label,
+ * the value is the probability to be an item of this class.
+ *
+ * @param clsLbls Class labels.
+ */
+ public ProbableLabel(TreeMap<Double, Double> clsLbls) {
+ this.clsLbls = clsLbls;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/package-info.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/package-info.java b/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/package-info.java
new file mode 100644
index 0000000..c18867e
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/knn/ann/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Contains main APIs for ANN classification algorithms.
+ */
+package org.apache.ignite.ml.knn.ann;
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNClassificationModel.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNClassificationModel.java b/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNClassificationModel.java
index c2c1c43..3404ae8 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNClassificationModel.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNClassificationModel.java
@@ -18,10 +18,7 @@
package org.apache.ignite.ml.knn.classification;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -30,41 +27,28 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.ignite.ml.Exportable;
import org.apache.ignite.ml.Exporter;
-import org.apache.ignite.ml.Model;
import org.apache.ignite.ml.dataset.Dataset;
import org.apache.ignite.ml.dataset.primitive.context.EmptyContext;
-import org.apache.ignite.ml.math.distances.DistanceMeasure;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.knn.NNClassificationModel;
import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.structures.LabeledDataset;
import org.apache.ignite.ml.structures.LabeledVector;
-import org.apache.ignite.ml.util.ModelTrace;
-import org.jetbrains.annotations.NotNull;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
/**
* kNN algorithm model to solve multi-class classification task.
*/
-public class KNNClassificationModel implements Model<Vector, Double>, Exportable<KNNModelFormat> {
+public class KNNClassificationModel extends NNClassificationModel implements Exportable<KNNModelFormat> {
/** */
private static final long serialVersionUID = -127386523291350345L;
- /** Amount of nearest neighbors. */
- protected int k = 5;
-
- /** Distance measure. */
- protected DistanceMeasure distanceMeasure = new EuclideanDistance();
-
- /** kNN strategy. */
- protected KNNStrategy stgy = KNNStrategy.SIMPLE;
-
/** Dataset. */
- private Dataset<EmptyContext, LabeledDataset<Double, LabeledVector>> dataset;
+ private Dataset<EmptyContext, LabeledVectorSet<Double, LabeledVector>> dataset;
/**
* Builds the model via prepared dataset.
* @param dataset Specially prepared object to run algorithm over it.
*/
- public KNNClassificationModel(Dataset<EmptyContext, LabeledDataset<Double, LabeledVector>> dataset) {
+ public KNNClassificationModel(Dataset<EmptyContext, LabeledVectorSet<Double, LabeledVector>> dataset) {
this.dataset = dataset;
}
@@ -85,36 +69,6 @@ public class KNNClassificationModel implements Model<Vector, Double>, Exportable
}
/**
- * Set up parameter of the kNN model.
- * @param k Amount of nearest neighbors.
- * @return Model.
- */
- public KNNClassificationModel withK(int k) {
- this.k = k;
- return this;
- }
-
- /**
- * Set up parameter of the kNN model.
- * @param stgy Strategy of calculations.
- * @return Model.
- */
- public KNNClassificationModel withStrategy(KNNStrategy stgy) {
- this.stgy = stgy;
- return this;
- }
-
- /**
- * Set up parameter of the kNN model.
- * @param distanceMeasure Distance measure.
- * @return Model.
- */
- public KNNClassificationModel withDistanceMeasure(DistanceMeasure distanceMeasure) {
- this.distanceMeasure = distanceMeasure;
- return this;
- }
-
- /**
* The main idea is calculation all distance pairs between given vector and all vectors in training set, sorting
* them and finding k vectors with min distance with the given vector.
*
@@ -127,94 +81,14 @@ public class KNNClassificationModel implements Model<Vector, Double>, Exportable
return Arrays.asList(getKClosestVectors(data, distanceIdxPairs));
}, (a, b) -> a == null ? b : Stream.concat(a.stream(), b.stream()).collect(Collectors.toList()));
- LabeledDataset<Double, LabeledVector> neighborsToFilter = buildLabeledDatasetOnListOfVectors(neighborsFromPartitions);
+ LabeledVectorSet<Double, LabeledVector> neighborsToFilter = buildLabeledDatasetOnListOfVectors(neighborsFromPartitions);
return Arrays.asList(getKClosestVectors(neighborsToFilter, getDistances(v, neighborsToFilter)));
}
/** */
- private LabeledDataset<Double, LabeledVector> buildLabeledDatasetOnListOfVectors(
- List<LabeledVector> neighborsFromPartitions) {
- LabeledVector[] arr = new LabeledVector[neighborsFromPartitions.size()];
- for (int i = 0; i < arr.length; i++)
- arr[i] = neighborsFromPartitions.get(i);
-
- return new LabeledDataset<Double, LabeledVector>(arr);
- }
-
- /**
- * Iterates along entries in distance map and fill the resulting k-element array.
- *
- * @param trainingData The training data.
- * @param distanceIdxPairs The distance map.
- * @return K-nearest neighbors.
- */
- @NotNull private LabeledVector[] getKClosestVectors(LabeledDataset<Double, LabeledVector> trainingData,
- TreeMap<Double, Set<Integer>> distanceIdxPairs) {
- LabeledVector[] res;
-
- if (trainingData.rowSize() <= k) {
- res = new LabeledVector[trainingData.rowSize()];
- for (int i = 0; i < trainingData.rowSize(); i++)
- res[i] = trainingData.getRow(i);
- }
- else {
- res = new LabeledVector[k];
- int i = 0;
- final Iterator<Double> iter = distanceIdxPairs.keySet().iterator();
- while (i < k) {
- double key = iter.next();
- Set<Integer> idxs = distanceIdxPairs.get(key);
- for (Integer idx : idxs) {
- res[i] = trainingData.getRow(idx);
- i++;
- if (i >= k)
- break; // go to next while-loop iteration
- }
- }
- }
-
- return res;
- }
-
- /**
- * Computes distances between given vector and each vector in training dataset.
- *
- * @param v The given vector.
- * @param trainingData The training dataset.
- * @return Key - distanceMeasure from given features before features with idx stored in value. Value is presented
- * with Set because there can be a few vectors with the same distance.
- */
- @NotNull private TreeMap<Double, Set<Integer>> getDistances(Vector v, LabeledDataset<Double, LabeledVector> trainingData) {
- TreeMap<Double, Set<Integer>> distanceIdxPairs = new TreeMap<>();
-
- for (int i = 0; i < trainingData.rowSize(); i++) {
-
- LabeledVector labeledVector = trainingData.getRow(i);
- if (labeledVector != null) {
- double distance = distanceMeasure.compute(v, labeledVector.features());
- putDistanceIdxPair(distanceIdxPairs, i, distance);
- }
- }
- return distanceIdxPairs;
- }
-
- /** */
- private void putDistanceIdxPair(Map<Double, Set<Integer>> distanceIdxPairs, int i, double distance) {
- if (distanceIdxPairs.containsKey(distance)) {
- Set<Integer> idxs = distanceIdxPairs.get(distance);
- idxs.add(i);
- }
- else {
- Set<Integer> idxs = new HashSet<>();
- idxs.add(i);
- distanceIdxPairs.put(distance, idxs);
- }
- }
-
- /** */
- private double classify(List<LabeledVector> neighbors, Vector v, KNNStrategy stgy) {
+ private double classify(List<LabeledVector> neighbors, Vector v, NNStrategy stgy) {
Map<Double, Double> clsVotes = new HashMap<>();
for (LabeledVector neighbor : neighbors) {
@@ -235,54 +109,5 @@ public class KNNClassificationModel implements Model<Vector, Double>, Exportable
return getClassWithMaxVotes(clsVotes);
}
- /** */
- private double getClassWithMaxVotes(Map<Double, Double> clsVotes) {
- return Collections.max(clsVotes.entrySet(), Map.Entry.comparingByValue()).getKey();
- }
-
- /** */
- private double getClassVoteForVector(KNNStrategy stgy, double distance) {
- if (stgy.equals(KNNStrategy.WEIGHTED))
- return 1 / distance; // strategy.WEIGHTED
- else
- return 1.0; // strategy.SIMPLE
- }
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int res = 1;
-
- res = res * 37 + k;
- res = res * 37 + distanceMeasure.hashCode();
- res = res * 37 + stgy.hashCode();
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object obj) {
- if (this == obj)
- return true;
-
- if (obj == null || getClass() != obj.getClass())
- return false;
-
- KNNClassificationModel that = (KNNClassificationModel)obj;
-
- return k == that.k && distanceMeasure.equals(that.distanceMeasure) && stgy.equals(that.stgy);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return toString(false);
- }
-
- /** {@inheritDoc} */
- @Override public String toString(boolean pretty) {
- return ModelTrace.builder("KNNClassificationModel", pretty)
- .addField("k", String.valueOf(k))
- .addField("measure", distanceMeasure.getClass().getSimpleName())
- .addField("strategy", stgy.name())
- .toString();
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNModelFormat.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNModelFormat.java b/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNModelFormat.java
index a2efe7f..a588b6e 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNModelFormat.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNModelFormat.java
@@ -27,13 +27,13 @@ import org.apache.ignite.ml.math.distances.DistanceMeasure;
*/
public class KNNModelFormat implements Serializable {
/** Amount of nearest neighbors. */
- private int k;
+ protected int k;
/** Distance measure. */
- private DistanceMeasure distanceMeasure;
+ protected DistanceMeasure distanceMeasure;
/** kNN strategy. */
- private KNNStrategy stgy;
+ protected NNStrategy stgy;
/** Gets amount of nearest neighbors.*/
public int getK() {
@@ -46,17 +46,21 @@ public class KNNModelFormat implements Serializable {
}
/** Gets kNN strategy.*/
- public KNNStrategy getStgy() {
+ public NNStrategy getStgy() {
return stgy;
}
+ /** */
+ public KNNModelFormat() {
+ }
+
/**
* Creates an instance.
* @param k Amount of nearest neighbors.
* @param measure Distance measure.
* @param stgy kNN strategy.
*/
- public KNNModelFormat(int k, DistanceMeasure measure, KNNStrategy stgy) {
+ public KNNModelFormat(int k, DistanceMeasure measure, NNStrategy stgy) {
this.k = k;
this.distanceMeasure = measure;
this.stgy = stgy;
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNStrategy.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNStrategy.java b/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNStrategy.java
deleted file mode 100644
index 9a117de..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/KNNStrategy.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.ml.knn.classification;
-
-/** This enum contains settings for kNN algorithm. */
-public enum KNNStrategy {
- /** The default strategy. All k neighbors have the same weight which is independent
- * on their distance to the query point.*/
- SIMPLE,
-
- /** A refinement of the k-NN classification algorithm is to weigh the contribution of each of the k neighbors
- * according to their distance to the query point, giving greater weight to closer neighbors. */
- WEIGHTED
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/NNStrategy.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/NNStrategy.java b/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/NNStrategy.java
new file mode 100644
index 0000000..bd43e8d
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/knn/classification/NNStrategy.java
@@ -0,0 +1,29 @@
+/*
+ * 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.ml.knn.classification;
+
+/** This enum contains settings for kNN algorithm. */
+public enum NNStrategy {
+ /** The default strategy. All k neighbors have the same weight which is independent
+ * on their distance to the query point.*/
+ SIMPLE,
+
+ /** A refinement of the k-NN classification algorithm is to weigh the contribution of each of the k neighbors
+ * according to their distance to the query point, giving greater weight to closer neighbors. */
+ WEIGHTED
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/knn/regression/KNNRegressionModel.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/knn/regression/KNNRegressionModel.java b/modules/ml/src/main/java/org/apache/ignite/ml/knn/regression/KNNRegressionModel.java
index 16dcd8a..c0d6680 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/knn/regression/KNNRegressionModel.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/knn/regression/KNNRegressionModel.java
@@ -22,8 +22,8 @@ import org.apache.ignite.ml.dataset.primitive.context.EmptyContext;
import org.apache.ignite.ml.knn.classification.KNNClassificationModel;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.structures.LabeledDataset;
import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
import org.apache.ignite.ml.util.ModelTrace;
/**
@@ -45,7 +45,7 @@ public class KNNRegressionModel extends KNNClassificationModel {
* Builds the model via prepared dataset.
* @param dataset Specially prepared object to run algorithm over it.
*/
- public KNNRegressionModel(Dataset<EmptyContext, LabeledDataset<Double, LabeledVector>> dataset) {
+ public KNNRegressionModel(Dataset<EmptyContext, LabeledVectorSet<Double, LabeledVector>> dataset) {
super(dataset);
}
[16/19] ignite git commit: IGNITE-9261: [ML] Add ANN algorithm based
on ACD concept
Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledDataset.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledDataset.java b/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledDataset.java
deleted file mode 100644
index 2440587..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledDataset.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.ml.structures;
-
-import org.apache.ignite.ml.math.exceptions.CardinalityException;
-import org.apache.ignite.ml.math.exceptions.NoDataException;
-import org.apache.ignite.ml.math.exceptions.knn.NoLabelVectorException;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-
-/**
- * Class for set of labeled vectors.
- */
-public class LabeledDataset<L, Row extends LabeledVector> extends Dataset<Row> implements AutoCloseable {
- /**
- * Default constructor (required by Externalizable).
- */
- public LabeledDataset() {
- super();
- }
-
- /**
- * Creates new Labeled Dataset and initialized with empty data structure.
- *
- * @param rowSize Amount of instances. Should be > 0.
- * @param colSize Amount of attributes. Should be > 0.
- * @param isDistributed Use distributed data structures to keep data.
- */
- public LabeledDataset(int rowSize, int colSize, boolean isDistributed){
- this(rowSize, colSize, null, isDistributed);
- }
-
- /**
- * Creates new local Labeled Dataset and initialized with empty data structure.
- *
- * @param rowSize Amount of instances. Should be > 0.
- * @param colSize Amount of attributes. Should be > 0.
- */
- public LabeledDataset(int rowSize, int colSize){
- this(rowSize, colSize, null, false);
- }
-
- /**
- * Creates new Labeled Dataset and initialized with empty data structure.
- *
- * @param rowSize Amount of instances. Should be > 0.
- * @param colSize Amount of attributes. Should be > 0
- * @param featureNames Column names.
- * @param isDistributed Use distributed data structures to keep data.
- */
- public LabeledDataset(int rowSize, int colSize, String[] featureNames, boolean isDistributed){
- super(rowSize, colSize, featureNames, isDistributed);
-
- initializeDataWithLabeledVectors();
- }
-
- /**
- * Creates new Labeled Dataset by given data.
- *
- * @param data Should be initialized with one vector at least.
- */
- public LabeledDataset(Row[] data) {
- super(data);
- }
-
- /** */
- private void initializeDataWithLabeledVectors() {
- data = (Row[])new LabeledVector[rowSize];
- for (int i = 0; i < rowSize; i++)
- data[i] = (Row)new LabeledVector(emptyVector(colSize, isDistributed), null);
- }
-
- /**
- * Creates new Labeled Dataset by given data.
- *
- * @param data Should be initialized with one vector at least.
- * @param colSize Amount of observed attributes in each vector.
- */
- public LabeledDataset(Row[] data, int colSize) {
- super(data, colSize);
- }
-
-
- /**
- * Creates new local Labeled Dataset by matrix and vector of labels.
- *
- * @param mtx Given matrix with rows as observations.
- * @param lbs Labels of observations.
- */
- public LabeledDataset(double[][] mtx, double[] lbs) {
- this(mtx, lbs, null, false);
- }
-
- /**
- * Creates new Labeled Dataset by matrix and vector of labels.
- *
- * @param mtx Given matrix with rows as observations.
- * @param lbs Labels of observations.
- * @param featureNames Column names.
- * @param isDistributed Use distributed data structures to keep data.
- */
- public LabeledDataset(double[][] mtx, double[] lbs, String[] featureNames, boolean isDistributed) {
- super();
- assert mtx != null;
- assert lbs != null;
-
- if(mtx.length != lbs.length)
- throw new CardinalityException(lbs.length, mtx.length);
-
- if(mtx[0] == null)
- throw new NoDataException("Pass filled array, the first vector is empty");
-
- this.rowSize = lbs.length;
- this.colSize = mtx[0].length;
-
- if(featureNames == null)
- generateFeatureNames();
- else {
- assert colSize == featureNames.length;
- convertStringNamesToFeatureMetadata(featureNames);
- }
-
- data = (Row[])new LabeledVector[rowSize];
- for (int i = 0; i < rowSize; i++){
-
- data[i] = (Row)new LabeledVector(emptyVector(colSize, isDistributed), lbs[i]);
- for (int j = 0; j < colSize; j++) {
- try {
- data[i].features().set(j, mtx[i][j]);
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new NoDataException("No data in given matrix by coordinates (" + i + "," + j + ")");
- }
- }
- }
- }
-
- /**
- * Returns label if label is attached or null if label is missed.
- *
- * @param idx Index of observation.
- * @return Label.
- */
- public double label(int idx) {
- LabeledVector labeledVector = data[idx];
-
- if(labeledVector!=null)
- return (double)labeledVector.label();
- else
- return Double.NaN;
- }
-
- /**
- * Returns new copy of labels of all labeled vectors NOTE: This method is useful for copying labels from test
- * dataset.
- *
- * @return Copy of labels.
- */
- public double[] labels() {
- assert data != null;
- assert data.length > 0;
-
- double[] labels = new double[data.length];
-
- for (int i = 0; i < data.length; i++)
- labels[i] = (double)data[i].label();
-
- return labels;
- }
-
- /**
- * Fill the label with given value.
- *
- * @param idx Index of observation.
- * @param lb The given label.
- */
- public void setLabel(int idx, double lb) {
- LabeledVector<Vector, Double> labeledVector = data[idx];
-
- if(labeledVector != null)
- labeledVector.setLabel(lb);
- else
- throw new NoLabelVectorException(idx);
- }
-
- /** */
- public static Vector emptyVector(int size, boolean isDistributed) {
- return new DenseVector(size);
- }
-
- /** Makes copy with new Label objects and old features and Metadata objects. */
- public LabeledDataset copy(){
- LabeledDataset res = new LabeledDataset(this.data, this.colSize);
- res.isDistributed = this.isDistributed;
- res.meta = this.meta;
- for (int i = 0; i < rowSize; i++)
- res.setLabel(i, this.label(i));
-
- return res;
- }
-
- /** Closes LabeledDataset. */
- @Override public void close() throws Exception {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledDatasetTestTrainPair.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledDatasetTestTrainPair.java b/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledDatasetTestTrainPair.java
deleted file mode 100644
index f362fbc..0000000
--- a/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledDatasetTestTrainPair.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.ml.structures;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Random;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Class for splitting Labeled Dataset on train and test sets.
- */
-public class LabeledDatasetTestTrainPair implements Serializable {
- /** Data to keep train set. */
- private LabeledDataset train;
-
- /** Data to keep test set. */
- private LabeledDataset test;
-
- /**
- * Creates two subsets of given dataset.
- * <p>
- * NOTE: This method uses next algorithm with O(n log n) by calculations and O(n) by memory.
- * </p>
- * @param dataset The dataset to split on train and test subsets.
- * @param testPercentage The percentage of the test subset.
- */
- public LabeledDatasetTestTrainPair(LabeledDataset dataset, double testPercentage) {
- assert testPercentage > 0.0;
- assert testPercentage < 1.0;
- final int datasetSize = dataset.rowSize();
- assert datasetSize > 2;
-
- final int testSize = (int)Math.floor(datasetSize * testPercentage);
- final int trainSize = datasetSize - testSize;
-
- final TreeSet<Integer> sortedTestIndices = getSortedIndices(datasetSize, testSize);
-
- LabeledVector[] testVectors = new LabeledVector[testSize];
- LabeledVector[] trainVectors = new LabeledVector[trainSize];
-
- int datasetCntr = 0;
- int trainCntr = 0;
- int testCntr = 0;
-
- for (Integer idx: sortedTestIndices){ // guarantee order as iterator
- testVectors[testCntr] = (LabeledVector)dataset.getRow(idx);
- testCntr++;
-
- for (int i = datasetCntr; i < idx; i++) {
- trainVectors[trainCntr] = (LabeledVector)dataset.getRow(i);
- trainCntr++;
- }
-
- datasetCntr = idx + 1;
- }
- if(datasetCntr < datasetSize){
- for (int i = datasetCntr; i < datasetSize; i++) {
- trainVectors[trainCntr] = (LabeledVector)dataset.getRow(i);
- trainCntr++;
- }
- }
-
- test = new LabeledDataset(testVectors, dataset.colSize());
- train = new LabeledDataset(trainVectors, dataset.colSize());
- }
-
- /** This method generates "random double, integer" pairs, sort them, gets first "testSize" elements and returns appropriate indices */
- @NotNull private TreeSet<Integer> getSortedIndices(int datasetSize, int testSize) {
- Random rnd = new Random();
- TreeMap<Double, Integer> randomIdxPairs = new TreeMap<>();
- for (int i = 0; i < datasetSize; i++)
- randomIdxPairs.put(rnd.nextDouble(), i);
-
- final TreeMap<Double, Integer> testIdxPairs = randomIdxPairs.entrySet().stream()
- .limit(testSize)
- .collect(TreeMap::new, (m, e) -> m.put(e.getKey(), e.getValue()), Map::putAll);
-
- return new TreeSet<>(testIdxPairs.values());
- }
-
- /**
- * Train subset of the whole dataset.
- * @return Train subset.
- */
- public LabeledDataset train() {
- return train;
- }
-
- /**
- * Test subset of the whole dataset.
- * @return Test subset.
- */
- public LabeledDataset test() {
- return test;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledVectorSet.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledVectorSet.java b/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledVectorSet.java
new file mode 100644
index 0000000..e98d793
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledVectorSet.java
@@ -0,0 +1,220 @@
+/*
+ * 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.ml.structures;
+
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.apache.ignite.ml.math.exceptions.NoDataException;
+import org.apache.ignite.ml.math.exceptions.knn.NoLabelVectorException;
+import org.apache.ignite.ml.math.primitives.vector.Vector;
+import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
+
+/**
+ * The set of labeled vectors used in local partition calculations.
+ */
+public class LabeledVectorSet<L, Row extends LabeledVector> extends Dataset<Row> implements AutoCloseable {
+ /**
+ * Default constructor (required by Externalizable).
+ */
+ public LabeledVectorSet() {
+ super();
+ }
+
+ /**
+ * Creates new Labeled Dataset and initialized with empty data structure.
+ *
+ * @param rowSize Amount of instances. Should be > 0.
+ * @param colSize Amount of attributes. Should be > 0.
+ * @param isDistributed Use distributed data structures to keep data.
+ */
+ public LabeledVectorSet(int rowSize, int colSize, boolean isDistributed){
+ this(rowSize, colSize, null, isDistributed);
+ }
+
+ /**
+ * Creates new local Labeled Dataset and initialized with empty data structure.
+ *
+ * @param rowSize Amount of instances. Should be > 0.
+ * @param colSize Amount of attributes. Should be > 0.
+ */
+ public LabeledVectorSet(int rowSize, int colSize){
+ this(rowSize, colSize, null, false);
+ }
+
+ /**
+ * Creates new Labeled Dataset and initialized with empty data structure.
+ *
+ * @param rowSize Amount of instances. Should be > 0.
+ * @param colSize Amount of attributes. Should be > 0
+ * @param featureNames Column names.
+ * @param isDistributed Use distributed data structures to keep data.
+ */
+ public LabeledVectorSet(int rowSize, int colSize, String[] featureNames, boolean isDistributed){
+ super(rowSize, colSize, featureNames, isDistributed);
+
+ initializeDataWithLabeledVectors();
+ }
+
+ /**
+ * Creates new Labeled Dataset by given data.
+ *
+ * @param data Should be initialized with one vector at least.
+ */
+ public LabeledVectorSet(Row[] data) {
+ super(data);
+ }
+
+ /** */
+ private void initializeDataWithLabeledVectors() {
+ data = (Row[])new LabeledVector[rowSize];
+ for (int i = 0; i < rowSize; i++)
+ data[i] = (Row)new LabeledVector(emptyVector(colSize, isDistributed), null);
+ }
+
+ /**
+ * Creates new Labeled Dataset by given data.
+ *
+ * @param data Should be initialized with one vector at least.
+ * @param colSize Amount of observed attributes in each vector.
+ */
+ public LabeledVectorSet(Row[] data, int colSize) {
+ super(data, colSize);
+ }
+
+
+ /**
+ * Creates new local Labeled Dataset by matrix and vector of labels.
+ *
+ * @param mtx Given matrix with rows as observations.
+ * @param lbs Labels of observations.
+ */
+ public LabeledVectorSet(double[][] mtx, double[] lbs) {
+ this(mtx, lbs, null, false);
+ }
+
+ /**
+ * Creates new Labeled Dataset by matrix and vector of labels.
+ *
+ * @param mtx Given matrix with rows as observations.
+ * @param lbs Labels of observations.
+ * @param featureNames Column names.
+ * @param isDistributed Use distributed data structures to keep data.
+ */
+ public LabeledVectorSet(double[][] mtx, double[] lbs, String[] featureNames, boolean isDistributed) {
+ super();
+ assert mtx != null;
+ assert lbs != null;
+
+ if(mtx.length != lbs.length)
+ throw new CardinalityException(lbs.length, mtx.length);
+
+ if(mtx[0] == null)
+ throw new NoDataException("Pass filled array, the first vector is empty");
+
+ this.rowSize = lbs.length;
+ this.colSize = mtx[0].length;
+
+ if(featureNames == null)
+ generateFeatureNames();
+ else {
+ assert colSize == featureNames.length;
+ convertStringNamesToFeatureMetadata(featureNames);
+ }
+
+ data = (Row[])new LabeledVector[rowSize];
+ for (int i = 0; i < rowSize; i++){
+
+ data[i] = (Row)new LabeledVector(emptyVector(colSize, isDistributed), lbs[i]);
+ for (int j = 0; j < colSize; j++) {
+ try {
+ data[i].features().set(j, mtx[i][j]);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ throw new NoDataException("No data in given matrix by coordinates (" + i + "," + j + ")");
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns label if label is attached or null if label is missed.
+ *
+ * @param idx Index of observation.
+ * @return Label.
+ */
+ public double label(int idx) {
+ LabeledVector labeledVector = data[idx];
+
+ if(labeledVector!=null)
+ return (double)labeledVector.label();
+ else
+ return Double.NaN;
+ }
+
+ /**
+ * Returns new copy of labels of all labeled vectors NOTE: This method is useful for copying labels from test
+ * dataset.
+ *
+ * @return Copy of labels.
+ */
+ public double[] labels() {
+ assert data != null;
+ assert data.length > 0;
+
+ double[] labels = new double[data.length];
+
+ for (int i = 0; i < data.length; i++)
+ labels[i] = (double)data[i].label();
+
+ return labels;
+ }
+
+ /**
+ * Fill the label with given value.
+ *
+ * @param idx Index of observation.
+ * @param lb The given label.
+ */
+ public void setLabel(int idx, double lb) {
+ LabeledVector<Vector, Double> labeledVector = data[idx];
+
+ if(labeledVector != null)
+ labeledVector.setLabel(lb);
+ else
+ throw new NoLabelVectorException(idx);
+ }
+
+ /** */
+ public static Vector emptyVector(int size, boolean isDistributed) {
+ return new DenseVector(size);
+ }
+
+ /** Makes copy with new Label objects and old features and Metadata objects. */
+ public LabeledVectorSet copy(){
+ LabeledVectorSet res = new LabeledVectorSet(this.data, this.colSize);
+ res.isDistributed = this.isDistributed;
+ res.meta = this.meta;
+ for (int i = 0; i < rowSize; i++)
+ res.setLabel(i, this.label(i));
+
+ return res;
+ }
+
+ /** Closes LabeledDataset. */
+ @Override public void close() throws Exception {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledVectorSetTestTrainPair.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledVectorSetTestTrainPair.java b/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledVectorSetTestTrainPair.java
new file mode 100644
index 0000000..d06dfd0
--- /dev/null
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledVectorSetTestTrainPair.java
@@ -0,0 +1,114 @@
+/*
+ * 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.ml.structures;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Random;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Class for splitting Labeled Dataset on train and test sets.
+ */
+public class LabeledVectorSetTestTrainPair implements Serializable {
+ /** Data to keep train set. */
+ private LabeledVectorSet train;
+
+ /** Data to keep test set. */
+ private LabeledVectorSet test;
+
+ /**
+ * Creates two subsets of given dataset.
+ * <p>
+ * NOTE: This method uses next algorithm with O(n log n) by calculations and O(n) by memory.
+ * </p>
+ * @param dataset The dataset to split on train and test subsets.
+ * @param testPercentage The percentage of the test subset.
+ */
+ public LabeledVectorSetTestTrainPair(LabeledVectorSet dataset, double testPercentage) {
+ assert testPercentage > 0.0;
+ assert testPercentage < 1.0;
+ final int datasetSize = dataset.rowSize();
+ assert datasetSize > 2;
+
+ final int testSize = (int)Math.floor(datasetSize * testPercentage);
+ final int trainSize = datasetSize - testSize;
+
+ final TreeSet<Integer> sortedTestIndices = getSortedIndices(datasetSize, testSize);
+
+ LabeledVector[] testVectors = new LabeledVector[testSize];
+ LabeledVector[] trainVectors = new LabeledVector[trainSize];
+
+ int datasetCntr = 0;
+ int trainCntr = 0;
+ int testCntr = 0;
+
+ for (Integer idx: sortedTestIndices){ // guarantee order as iterator
+ testVectors[testCntr] = (LabeledVector)dataset.getRow(idx);
+ testCntr++;
+
+ for (int i = datasetCntr; i < idx; i++) {
+ trainVectors[trainCntr] = (LabeledVector)dataset.getRow(i);
+ trainCntr++;
+ }
+
+ datasetCntr = idx + 1;
+ }
+ if(datasetCntr < datasetSize){
+ for (int i = datasetCntr; i < datasetSize; i++) {
+ trainVectors[trainCntr] = (LabeledVector)dataset.getRow(i);
+ trainCntr++;
+ }
+ }
+
+ test = new LabeledVectorSet(testVectors, dataset.colSize());
+ train = new LabeledVectorSet(trainVectors, dataset.colSize());
+ }
+
+ /** This method generates "random double, integer" pairs, sort them, gets first "testSize" elements and returns appropriate indices */
+ @NotNull private TreeSet<Integer> getSortedIndices(int datasetSize, int testSize) {
+ Random rnd = new Random();
+ TreeMap<Double, Integer> randomIdxPairs = new TreeMap<>();
+ for (int i = 0; i < datasetSize; i++)
+ randomIdxPairs.put(rnd.nextDouble(), i);
+
+ final TreeMap<Double, Integer> testIdxPairs = randomIdxPairs.entrySet().stream()
+ .limit(testSize)
+ .collect(TreeMap::new, (m, e) -> m.put(e.getKey(), e.getValue()), Map::putAll);
+
+ return new TreeSet<>(testIdxPairs.values());
+ }
+
+ /**
+ * Train subset of the whole dataset.
+ * @return Train subset.
+ */
+ public LabeledVectorSet train() {
+ return train;
+ }
+
+ /**
+ * Test subset of the whole dataset.
+ * @return Test subset.
+ */
+ public LabeledVectorSet test() {
+ return test;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/structures/partition/LabeledDatasetPartitionDataBuilderOnHeap.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/structures/partition/LabeledDatasetPartitionDataBuilderOnHeap.java b/modules/ml/src/main/java/org/apache/ignite/ml/structures/partition/LabeledDatasetPartitionDataBuilderOnHeap.java
index b4e552b..0351037 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/structures/partition/LabeledDatasetPartitionDataBuilderOnHeap.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/structures/partition/LabeledDatasetPartitionDataBuilderOnHeap.java
@@ -23,18 +23,18 @@ import org.apache.ignite.ml.dataset.PartitionDataBuilder;
import org.apache.ignite.ml.dataset.UpstreamEntry;
import org.apache.ignite.ml.math.functions.IgniteBiFunction;
import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.structures.LabeledDataset;
import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
/**
- * Partition data builder that builds {@link LabeledDataset}.
+ * Partition data builder that builds {@link LabeledVectorSet}.
*
* @param <K> Type of a key in <tt>upstream</tt> data.
* @param <V> Type of a value in <tt>upstream</tt> data.
* @param <C> Type of a partition <tt>context</tt>.
*/
public class LabeledDatasetPartitionDataBuilderOnHeap<K, V, C extends Serializable>
- implements PartitionDataBuilder<K, V, C, LabeledDataset<Double, LabeledVector>> {
+ implements PartitionDataBuilder<K, V, C, LabeledVectorSet<Double, LabeledVector>> {
/** */
private static final long serialVersionUID = -7820760153954269227L;
@@ -57,8 +57,8 @@ public class LabeledDatasetPartitionDataBuilderOnHeap<K, V, C extends Serializab
}
/** {@inheritDoc} */
- @Override public LabeledDataset<Double, LabeledVector> build(Iterator<UpstreamEntry<K, V>> upstreamData,
- long upstreamDataSize, C ctx) {
+ @Override public LabeledVectorSet<Double, LabeledVector> build(Iterator<UpstreamEntry<K, V>> upstreamData,
+ long upstreamDataSize, C ctx) {
int xCols = -1;
double[][] x = null;
double[] y = new double[Math.toIntExact(upstreamDataSize)];
@@ -82,6 +82,6 @@ public class LabeledDatasetPartitionDataBuilderOnHeap<K, V, C extends Serializab
ptr++;
}
- return new LabeledDataset<>(x, y);
+ return new LabeledVectorSet<>(x, y);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/structures/preprocessing/LabeledDatasetLoader.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/structures/preprocessing/LabeledDatasetLoader.java b/modules/ml/src/main/java/org/apache/ignite/ml/structures/preprocessing/LabeledDatasetLoader.java
index 5c20d9c..f370cbd 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/structures/preprocessing/LabeledDatasetLoader.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/structures/preprocessing/LabeledDatasetLoader.java
@@ -28,8 +28,8 @@ import org.apache.ignite.ml.math.exceptions.NoDataException;
import org.apache.ignite.ml.math.exceptions.knn.EmptyFileException;
import org.apache.ignite.ml.math.exceptions.knn.FileParsingException;
import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.structures.LabeledDataset;
import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
import org.jetbrains.annotations.NotNull;
/** Data pre-processing step which loads data from different file types. */
@@ -43,8 +43,8 @@ public class LabeledDatasetLoader {
* @param isFallOnBadData Fall on incorrect data if true.
* @return Labeled Dataset parsed from file.
*/
- public static LabeledDataset loadFromTxtFile(Path pathToFile, String separator, boolean isDistributed,
- boolean isFallOnBadData) throws IOException {
+ public static LabeledVectorSet loadFromTxtFile(Path pathToFile, String separator, boolean isDistributed,
+ boolean isFallOnBadData) throws IOException {
Stream<String> stream = Files.lines(pathToFile);
List<String> list = new ArrayList<>();
stream.forEach(list::add);
@@ -81,7 +81,7 @@ public class LabeledDatasetLoader {
for (int i = 0; i < vectors.size(); i++)
data[i] = new LabeledVector(vectors.get(i), labels.get(i));
- return new LabeledDataset(data, colSize);
+ return new LabeledVectorSet(data, colSize);
}
else
throw new NoDataException("File should contain first row with data");
@@ -93,7 +93,7 @@ public class LabeledDatasetLoader {
/** */
@NotNull private static Vector parseFeatures(Path pathToFile, boolean isDistributed, boolean isFallOnBadData,
int colSize, int rowIdx, String[] rowData) {
- final Vector vec = LabeledDataset.emptyVector(colSize, isDistributed);
+ final Vector vec = LabeledVectorSet.emptyVector(colSize, isDistributed);
if (isFallOnBadData && rowData.length != colSize + 1)
throw new CardinalityException(colSize + 1, rowData.length);
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/main/java/org/apache/ignite/ml/svm/SVMLinearBinaryClassificationTrainer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/svm/SVMLinearBinaryClassificationTrainer.java b/modules/ml/src/main/java/org/apache/ignite/ml/svm/SVMLinearBinaryClassificationTrainer.java
index 1ae896f..4f11318 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/svm/SVMLinearBinaryClassificationTrainer.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/svm/SVMLinearBinaryClassificationTrainer.java
@@ -25,8 +25,8 @@ import org.apache.ignite.ml.dataset.primitive.context.EmptyContext;
import org.apache.ignite.ml.math.functions.IgniteBiFunction;
import org.apache.ignite.ml.math.primitives.vector.Vector;
import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-import org.apache.ignite.ml.structures.LabeledDataset;
import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
import org.apache.ignite.ml.structures.partition.LabeledDatasetPartitionDataBuilderOnHeap;
import org.apache.ignite.ml.trainers.SingleLabelDatasetTrainer;
import org.jetbrains.annotations.NotNull;
@@ -60,14 +60,14 @@ public class SVMLinearBinaryClassificationTrainer extends SingleLabelDatasetTrai
assert datasetBuilder != null;
- PartitionDataBuilder<K, V, EmptyContext, LabeledDataset<Double, LabeledVector>> partDataBuilder = new LabeledDatasetPartitionDataBuilderOnHeap<>(
+ PartitionDataBuilder<K, V, EmptyContext, LabeledVectorSet<Double, LabeledVector>> partDataBuilder = new LabeledDatasetPartitionDataBuilderOnHeap<>(
featureExtractor,
lbExtractor
);
Vector weights;
- try(Dataset<EmptyContext, LabeledDataset<Double, LabeledVector>> dataset = datasetBuilder.build(
+ try(Dataset<EmptyContext, LabeledVectorSet<Double, LabeledVector>> dataset = datasetBuilder.build(
(upstream, upstreamSize) -> new EmptyContext(),
partDataBuilder
)) {
@@ -91,7 +91,7 @@ public class SVMLinearBinaryClassificationTrainer extends SingleLabelDatasetTrai
}
/** */
- private Vector calculateUpdates(Vector weights, Dataset<EmptyContext, LabeledDataset<Double, LabeledVector>> dataset) {
+ private Vector calculateUpdates(Vector weights, Dataset<EmptyContext, LabeledVectorSet<Double, LabeledVector>> dataset) {
return dataset.compute(data -> {
Vector copiedWeights = weights.copy();
Vector deltaWeights = initializeWeightsWithZeros(weights.size());
@@ -116,8 +116,8 @@ public class SVMLinearBinaryClassificationTrainer extends SingleLabelDatasetTrai
}
/** */
- private Deltas getDeltas(LabeledDataset data, Vector copiedWeights, int amountOfObservation, Vector tmpAlphas,
- int randomIdx) {
+ private Deltas getDeltas(LabeledVectorSet data, Vector copiedWeights, int amountOfObservation, Vector tmpAlphas,
+ int randomIdx) {
LabeledVector row = (LabeledVector)data.getRow(randomIdx);
Double lb = (Double)row.label();
Vector v = makeVectorWithInterceptElement(row);
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/test/java/org/apache/ignite/ml/LocalModelsTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/LocalModelsTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/LocalModelsTest.java
index 3e3bab5..42f5dec 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/LocalModelsTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/LocalModelsTest.java
@@ -28,13 +28,20 @@ import org.apache.ignite.ml.clustering.kmeans.KMeansModel;
import org.apache.ignite.ml.clustering.kmeans.KMeansModelFormat;
import org.apache.ignite.ml.clustering.kmeans.KMeansTrainer;
import org.apache.ignite.ml.dataset.impl.local.LocalDatasetBuilder;
+import org.apache.ignite.ml.knn.NNClassificationModel;
+import org.apache.ignite.ml.knn.ann.ANNClassificationModel;
+import org.apache.ignite.ml.knn.ann.ANNModelFormat;
+import org.apache.ignite.ml.knn.ann.ProbableLabel;
import org.apache.ignite.ml.knn.classification.KNNClassificationModel;
import org.apache.ignite.ml.knn.classification.KNNModelFormat;
-import org.apache.ignite.ml.knn.classification.KNNStrategy;
+import org.apache.ignite.ml.knn.classification.NNStrategy;
import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.math.distances.ManhattanDistance;
import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
+import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
import org.apache.ignite.ml.svm.SVMLinearBinaryClassificationModel;
import org.apache.ignite.ml.svm.SVMLinearMultiClassClassificationModel;
import org.junit.Assert;
@@ -165,10 +172,10 @@ public class LocalModelsTest {
@Test
public void importExportKNNModelTest() throws IOException {
executeModelTest(mdlFilePath -> {
- KNNClassificationModel mdl = new KNNClassificationModel(null)
+ NNClassificationModel mdl = new KNNClassificationModel(null)
.withK(3)
.withDistanceMeasure(new EuclideanDistance())
- .withStrategy(KNNStrategy.SIMPLE);
+ .withStrategy(NNStrategy.SIMPLE);
Exporter<KNNModelFormat, String> exporter = new FileExporter<>();
mdl.saveModel(exporter, mdlFilePath);
@@ -177,7 +184,37 @@ public class LocalModelsTest {
Assert.assertNotNull(load);
- KNNClassificationModel importedMdl = new KNNClassificationModel(null)
+ NNClassificationModel importedMdl = new KNNClassificationModel(null)
+ .withK(load.getK())
+ .withDistanceMeasure(load.getDistanceMeasure())
+ .withStrategy(load.getStgy());
+
+ Assert.assertTrue("", mdl.equals(importedMdl));
+
+ return null;
+ });
+ }
+
+ /** */
+ @Test
+ public void importExportANNModelTest() throws IOException {
+ executeModelTest(mdlFilePath -> {
+ final LabeledVectorSet<ProbableLabel, LabeledVector> centers = new LabeledVectorSet<>();
+
+ NNClassificationModel mdl = new ANNClassificationModel(centers)
+ .withK(4)
+ .withDistanceMeasure(new ManhattanDistance())
+ .withStrategy(NNStrategy.WEIGHTED);
+
+ Exporter<KNNModelFormat, String> exporter = new FileExporter<>();
+ mdl.saveModel(exporter, mdlFilePath);
+
+ ANNModelFormat load = (ANNModelFormat) exporter.load(mdlFilePath);
+
+ Assert.assertNotNull(load);
+
+
+ NNClassificationModel importedMdl = new ANNClassificationModel(load.getCandidates())
.withK(load.getK())
.withDistanceMeasure(load.getDistanceMeasure())
.withStrategy(load.getStgy());
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/test/java/org/apache/ignite/ml/common/CollectionsTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/common/CollectionsTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/common/CollectionsTest.java
index c4d896c..552c478 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/common/CollectionsTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/common/CollectionsTest.java
@@ -23,7 +23,7 @@ import org.apache.ignite.ml.clustering.kmeans.KMeansModel;
import org.apache.ignite.ml.clustering.kmeans.KMeansModelFormat;
import org.apache.ignite.ml.knn.classification.KNNClassificationModel;
import org.apache.ignite.ml.knn.classification.KNNModelFormat;
-import org.apache.ignite.ml.knn.classification.KNNStrategy;
+import org.apache.ignite.ml.knn.classification.NNStrategy;
import org.apache.ignite.ml.math.distances.EuclideanDistance;
import org.apache.ignite.ml.math.distances.HammingDistance;
import org.apache.ignite.ml.math.distances.ManhattanDistance;
@@ -83,8 +83,8 @@ public class CollectionsTest {
test(new KMeansModel(new Vector[] {}, new ManhattanDistance()),
new KMeansModel(new Vector[] {}, new HammingDistance()));
- test(new KNNModelFormat(1, new ManhattanDistance(), KNNStrategy.SIMPLE),
- new KNNModelFormat(2, new ManhattanDistance(), KNNStrategy.SIMPLE));
+ test(new KNNModelFormat(1, new ManhattanDistance(), NNStrategy.SIMPLE),
+ new KNNModelFormat(2, new ManhattanDistance(), NNStrategy.SIMPLE));
test(new KNNClassificationModel(null).withK(1), new KNNClassificationModel(null).withK(2));
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/test/java/org/apache/ignite/ml/knn/ANNClassificationTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/knn/ANNClassificationTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/knn/ANNClassificationTest.java
new file mode 100644
index 0000000..ea602cd
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/knn/ANNClassificationTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.ml.knn;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ThreadLocalRandom;
+import org.apache.ignite.ml.TestUtils;
+import org.apache.ignite.ml.knn.ann.ANNClassificationTrainer;
+import org.apache.ignite.ml.knn.classification.NNStrategy;
+import org.apache.ignite.ml.math.distances.EuclideanDistance;
+import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/** Tests behaviour of ANNClassificationTest. */
+@RunWith(Parameterized.class)
+public class ANNClassificationTest {
+ /** Number of parts to be tested. */
+ private static final int[] partsToBeTested = new int[]{1, 2, 3, 4, 5, 7, 100};
+
+ /** Fixed size of Dataset. */
+ private static final int AMOUNT_OF_OBSERVATIONS = 1000;
+
+ /** Fixed size of columns in Dataset. */
+ private static final int AMOUNT_OF_FEATURES = 2;
+
+ /** Precision in test checks. */
+ private static final double PRECISION = 1e-2;
+
+ /** Number of partitions. */
+ @Parameterized.Parameter
+ public int parts;
+
+ /** Parameters. */
+ @Parameterized.Parameters(name = "Data divided on {0} partitions, training with batch size {1}")
+ public static Iterable<Integer[]> data() {
+ List<Integer[]> res = new ArrayList<>();
+
+ for (int part : partsToBeTested)
+ res.add(new Integer[]{part});
+
+ return res;
+ }
+
+ /** */
+ @Test
+ public void testBinaryClassificationTest() {
+ Map<Integer, double[]> data = new HashMap<>();
+
+ ThreadLocalRandom rndX = ThreadLocalRandom.current();
+ ThreadLocalRandom rndY = ThreadLocalRandom.current();
+
+ for (int i = 0; i < AMOUNT_OF_OBSERVATIONS; i++) {
+ double x = rndX.nextDouble(500, 600);
+ double y = rndY.nextDouble(500, 600);
+ double[] vec = new double[AMOUNT_OF_FEATURES + 1];
+ vec[0] = 0; // assign label.
+ vec[1] = x;
+ vec[2] = y;
+ data.put(i, vec);
+ }
+
+ for (int i = AMOUNT_OF_OBSERVATIONS; i < AMOUNT_OF_OBSERVATIONS * 2; i++) {
+ double x = rndX.nextDouble(-600, -500);
+ double y = rndY.nextDouble(-600, -500);
+ double[] vec = new double[AMOUNT_OF_FEATURES + 1];
+ vec[0] = 1; // assign label.
+ vec[1] = x;
+ vec[2] = y;
+ data.put(i, vec);
+ }
+
+ ANNClassificationTrainer trainer = new ANNClassificationTrainer()
+ .withK(10);
+
+ NNClassificationModel mdl = trainer.fit(
+ data,
+ parts,
+ (k, v) -> VectorUtils.of(Arrays.copyOfRange(v, 1, v.length)),
+ (k, v) -> v[0]
+ ).withK(3)
+ .withDistanceMeasure(new EuclideanDistance())
+ .withStrategy(NNStrategy.SIMPLE);
+
+ TestUtils.assertEquals(0, mdl.apply(VectorUtils.of(550, 550)), PRECISION);
+ TestUtils.assertEquals(1, mdl.apply(VectorUtils.of(-550, -550)), PRECISION);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNClassificationTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNClassificationTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNClassificationTest.java
index aeb2414..c176682 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNClassificationTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNClassificationTest.java
@@ -22,9 +22,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.ignite.ml.knn.classification.KNNClassificationModel;
import org.apache.ignite.ml.knn.classification.KNNClassificationTrainer;
-import org.apache.ignite.ml.knn.classification.KNNStrategy;
+import org.apache.ignite.ml.knn.classification.NNStrategy;
import org.apache.ignite.ml.math.distances.EuclideanDistance;
import org.apache.ignite.ml.math.primitives.vector.Vector;
import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
@@ -70,14 +69,14 @@ public class KNNClassificationTest {
KNNClassificationTrainer trainer = new KNNClassificationTrainer();
- KNNClassificationModel knnMdl = trainer.fit(
+ NNClassificationModel knnMdl = trainer.fit(
data,
parts,
(k, v) -> VectorUtils.of(Arrays.copyOfRange(v, 0, v.length - 1)),
(k, v) -> v[2]
).withK(3)
.withDistanceMeasure(new EuclideanDistance())
- .withStrategy(KNNStrategy.SIMPLE);
+ .withStrategy(NNStrategy.SIMPLE);
assertTrue(knnMdl.toString().length() > 0);
assertTrue(knnMdl.toString(true).length() > 0);
@@ -102,14 +101,14 @@ public class KNNClassificationTest {
KNNClassificationTrainer trainer = new KNNClassificationTrainer();
- KNNClassificationModel knnMdl = trainer.fit(
+ NNClassificationModel knnMdl = trainer.fit(
data,
parts,
(k, v) -> VectorUtils.of(Arrays.copyOfRange(v, 0, v.length - 1)),
(k, v) -> v[2]
).withK(1)
.withDistanceMeasure(new EuclideanDistance())
- .withStrategy(KNNStrategy.SIMPLE);
+ .withStrategy(NNStrategy.SIMPLE);
Vector firstVector = new DenseVector(new double[] {2.0, 2.0});
assertEquals(knnMdl.apply(firstVector), 1.0);
@@ -130,14 +129,14 @@ public class KNNClassificationTest {
KNNClassificationTrainer trainer = new KNNClassificationTrainer();
- KNNClassificationModel knnMdl = trainer.fit(
+ NNClassificationModel knnMdl = trainer.fit(
data,
parts,
(k, v) -> VectorUtils.of(Arrays.copyOfRange(v, 0, v.length - 1)),
(k, v) -> v[2]
).withK(3)
.withDistanceMeasure(new EuclideanDistance())
- .withStrategy(KNNStrategy.SIMPLE);
+ .withStrategy(NNStrategy.SIMPLE);
Vector vector = new DenseVector(new double[] {-1.01, -1.01});
assertEquals(knnMdl.apply(vector), 2.0);
@@ -156,14 +155,14 @@ public class KNNClassificationTest {
KNNClassificationTrainer trainer = new KNNClassificationTrainer();
- KNNClassificationModel knnMdl = trainer.fit(
+ NNClassificationModel knnMdl = trainer.fit(
data,
parts,
(k, v) -> VectorUtils.of(Arrays.copyOfRange(v, 0, v.length - 1)),
(k, v) -> v[2]
).withK(3)
.withDistanceMeasure(new EuclideanDistance())
- .withStrategy(KNNStrategy.WEIGHTED);
+ .withStrategy(NNStrategy.WEIGHTED);
Vector vector = new DenseVector(new double[] {-1.01, -1.01});
assertEquals(knnMdl.apply(vector), 1.0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNRegressionTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNRegressionTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNRegressionTest.java
index 7d57ec9..e05903e 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNRegressionTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNRegressionTest.java
@@ -23,7 +23,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.ignite.ml.dataset.impl.local.LocalDatasetBuilder;
-import org.apache.ignite.ml.knn.classification.KNNStrategy;
+import org.apache.ignite.ml.knn.classification.NNStrategy;
import org.apache.ignite.ml.knn.regression.KNNRegressionModel;
import org.apache.ignite.ml.knn.regression.KNNRegressionTrainer;
import org.apache.ignite.ml.math.distances.EuclideanDistance;
@@ -77,7 +77,7 @@ public class KNNRegressionTest {
(k, v) -> v[0]
).withK(1)
.withDistanceMeasure(new EuclideanDistance())
- .withStrategy(KNNStrategy.SIMPLE);
+ .withStrategy(NNStrategy.SIMPLE);
Vector vector = new DenseVector(new double[] {0, 0, 0, 5.0, 0.0});
System.out.println(knnMdl.apply(vector));
@@ -87,17 +87,17 @@ public class KNNRegressionTest {
/** */
@Test
public void testLongly() {
- testLongly(KNNStrategy.SIMPLE);
+ testLongly(NNStrategy.SIMPLE);
}
/** */
@Test
public void testLonglyWithWeightedStrategy() {
- testLongly(KNNStrategy.WEIGHTED);
+ testLongly(NNStrategy.WEIGHTED);
}
/** */
- private void testLongly(KNNStrategy stgy) {
+ private void testLongly(NNStrategy stgy) {
Map<Integer, double[]> data = new HashMap<>();
data.put(0, new double[] {60323, 83.0, 234289, 2356, 1590, 107608, 1947});
data.put(1, new double[] {61122, 88.5, 259426, 2325, 1456, 108632, 1948});
@@ -123,16 +123,12 @@ public class KNNRegressionTest {
(k, v) -> v[0]
).withK(3)
.withDistanceMeasure(new EuclideanDistance())
- .withStrategy(stgy);
+ .withStrategy(NNStrategy.SIMPLE);
Vector vector = new DenseVector(new double[] {104.6, 419180, 2822, 2857, 118734, 1956});
Assert.assertNotNull(knnMdl.apply(vector));
Assert.assertEquals(67857, knnMdl.apply(vector), 2000);
-
- Assert.assertTrue(knnMdl.toString().contains(stgy.name()));
- Assert.assertTrue(knnMdl.toString(true).contains(stgy.name()));
- Assert.assertTrue(knnMdl.toString(false).contains(stgy.name()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNTestSuite.java b/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNTestSuite.java
index 55ef24e..0303d26 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNTestSuite.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/knn/KNNTestSuite.java
@@ -25,9 +25,10 @@ import org.junit.runners.Suite;
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
+ ANNClassificationTest.class,
KNNClassificationTest.class,
KNNRegressionTest.class,
- LabeledDatasetTest.class
+ LabeledVectorSetTest.class
})
public class KNNTestSuite {
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledDatasetHelper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledDatasetHelper.java b/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledDatasetHelper.java
index dbcdb99..f3b8b3a 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledDatasetHelper.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledDatasetHelper.java
@@ -21,7 +21,7 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
-import org.apache.ignite.ml.structures.LabeledDataset;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
import org.apache.ignite.ml.structures.preprocessing.LabeledDatasetLoader;
/**
@@ -37,7 +37,7 @@ public class LabeledDatasetHelper {
* @param rsrcPath path to dataset.
* @return null if path is incorrect.
*/
- public static LabeledDataset loadDatasetFromTxt(String rsrcPath, boolean isFallOnBadData) {
+ public static LabeledVectorSet loadDatasetFromTxt(String rsrcPath, boolean isFallOnBadData) {
try {
Path path = Paths.get(LabeledDatasetHelper.class.getClassLoader().getResource(rsrcPath).toURI());
try {
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledDatasetTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledDatasetTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledDatasetTest.java
deleted file mode 100644
index 9867fbe..0000000
--- a/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledDatasetTest.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.ml.knn;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Objects;
-import org.apache.ignite.ml.math.ExternalizableTest;
-import org.apache.ignite.ml.math.exceptions.CardinalityException;
-import org.apache.ignite.ml.math.exceptions.NoDataException;
-import org.apache.ignite.ml.math.exceptions.knn.EmptyFileException;
-import org.apache.ignite.ml.math.exceptions.knn.FileParsingException;
-import org.apache.ignite.ml.math.exceptions.knn.NoLabelVectorException;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.structures.LabeledDataset;
-import org.apache.ignite.ml.structures.LabeledDatasetTestTrainPair;
-import org.apache.ignite.ml.structures.LabeledVector;
-import org.apache.ignite.ml.structures.preprocessing.LabeledDatasetLoader;
-import org.junit.Test;
-
-import static junit.framework.TestCase.assertEquals;
-import static junit.framework.TestCase.fail;
-
-/** Tests behaviour of LabeledDataset. */
-public class LabeledDatasetTest implements ExternalizableTest<LabeledDataset> {
- /** */
- private static final String KNN_IRIS_TXT = "datasets/knn/iris.txt";
-
- /** */
- private static final String NO_DATA_TXT = "datasets/knn/no_data.txt";
-
- /** */
- private static final String EMPTY_TXT = "datasets/knn/empty.txt";
-
- /** */
- private static final String IRIS_INCORRECT_TXT = "datasets/knn/iris_incorrect.txt";
-
- /** */
- private static final String IRIS_MISSED_DATA = "datasets/knn/missed_data.txt";
-
- /** */
- @Test
- public void testFeatureNames() {
- double[][] mtx =
- new double[][] {
- {1.0, 1.0},
- {1.0, 2.0},
- {2.0, 1.0},
- {-1.0, -1.0},
- {-1.0, -2.0},
- {-2.0, -1.0}};
- double[] lbs = new double[] {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
-
- String[] featureNames = new String[] {"x", "y"};
- final LabeledDataset dataset = new LabeledDataset(mtx, lbs, featureNames, false);
-
- assertEquals(dataset.getFeatureName(0), "x");
- }
-
- /** */
- @Test
- public void testAccessMethods() {
- double[][] mtx =
- new double[][] {
- {1.0, 1.0},
- {1.0, 2.0},
- {2.0, 1.0},
- {-1.0, -1.0},
- {-1.0, -2.0},
- {-2.0, -1.0}};
- double[] lbs = new double[] {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
-
- final LabeledDataset dataset = new LabeledDataset(mtx, lbs, null, false);
-
- assertEquals(dataset.colSize(), 2);
- assertEquals(dataset.rowSize(), 6);
-
- assertEquals(dataset.label(0), lbs[0], 0);
-
- assertEquals(dataset.copy().colSize(), 2);
-
- @SuppressWarnings("unchecked")
- final LabeledVector<Vector, Double> row = (LabeledVector<Vector, Double>)dataset.getRow(0);
-
- assertEquals(row.features().get(0), 1.0);
- assertEquals(row.label(), 1.0);
- dataset.setLabel(0, 2.0);
- assertEquals(row.label(), 2.0);
-
- assertEquals(0, new LabeledDataset().rowSize());
- assertEquals(1, new LabeledDataset(1, 2).rowSize());
- assertEquals(1, new LabeledDataset(1, 2, true).rowSize());
- assertEquals(1, new LabeledDataset(1, 2, null, true).rowSize());
- }
-
- /** */
- @Test
- public void testFailOnYNull() {
- double[][] mtx =
- new double[][] {
- {1.0, 1.0},
- {1.0, 2.0},
- {2.0, 1.0},
- {-1.0, -1.0},
- {-1.0, -2.0},
- {-2.0, -1.0}};
- double[] lbs = new double[] {};
-
- try {
- new LabeledDataset(mtx, lbs);
- fail("CardinalityException");
- }
- catch (CardinalityException e) {
- return;
- }
- fail("CardinalityException");
- }
-
- /** */
- @Test
- public void testFailOnXNull() {
- double[][] mtx =
- new double[][] {};
- double[] lbs = new double[] {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
-
- try {
- new LabeledDataset(mtx, lbs);
- fail("CardinalityException");
- }
- catch (CardinalityException e) {
- return;
- }
- fail("CardinalityException");
- }
-
- /** */
- @Test
- public void testLoadingCorrectTxtFile() {
- LabeledDataset training = LabeledDatasetHelper.loadDatasetFromTxt(KNN_IRIS_TXT, false);
- assertEquals(Objects.requireNonNull(training).rowSize(), 150);
- }
-
- /** */
- @Test
- public void testLoadingEmptyFile() {
- try {
- LabeledDatasetHelper.loadDatasetFromTxt(EMPTY_TXT, false);
- fail("EmptyFileException");
- }
- catch (EmptyFileException e) {
- return;
- }
- fail("EmptyFileException");
- }
-
- /** */
- @Test
- public void testLoadingFileWithFirstEmptyRow() {
- try {
- LabeledDatasetHelper.loadDatasetFromTxt(NO_DATA_TXT, false);
- fail("NoDataException");
- }
- catch (NoDataException e) {
- return;
- }
- fail("NoDataException");
- }
-
- /** */
- @Test
- public void testLoadingFileWithIncorrectData() {
- LabeledDataset training = LabeledDatasetHelper.loadDatasetFromTxt(IRIS_INCORRECT_TXT, false);
- assertEquals(149, Objects.requireNonNull(training).rowSize());
- }
-
- /** */
- @Test
- public void testFailOnLoadingFileWithIncorrectData() {
- try {
- LabeledDatasetHelper.loadDatasetFromTxt(IRIS_INCORRECT_TXT, true);
- fail("FileParsingException");
- }
- catch (FileParsingException e) {
- return;
- }
- fail("FileParsingException");
-
- }
-
- /** */
- @Test
- public void testLoadingFileWithMissedData() throws URISyntaxException, IOException {
- Path path = Paths.get(Objects.requireNonNull(this.getClass().getClassLoader().getResource(IRIS_MISSED_DATA)).toURI());
-
- LabeledDataset training = LabeledDatasetLoader.loadFromTxtFile(path, ",", false, false);
-
- assertEquals(training.features(2).get(1), 0.0);
- }
-
- /** */
- @Test
- public void testSplitting() {
- double[][] mtx =
- new double[][] {
- {1.0, 1.0},
- {1.0, 2.0},
- {2.0, 1.0},
- {-1.0, -1.0},
- {-1.0, -2.0},
- {-2.0, -1.0}};
- double[] lbs = new double[] {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
-
- LabeledDataset training = new LabeledDataset(mtx, lbs);
-
- LabeledDatasetTestTrainPair split1 = new LabeledDatasetTestTrainPair(training, 0.67);
-
- assertEquals(4, split1.test().rowSize());
- assertEquals(2, split1.train().rowSize());
-
- LabeledDatasetTestTrainPair split2 = new LabeledDatasetTestTrainPair(training, 0.65);
-
- assertEquals(3, split2.test().rowSize());
- assertEquals(3, split2.train().rowSize());
-
- LabeledDatasetTestTrainPair split3 = new LabeledDatasetTestTrainPair(training, 0.4);
-
- assertEquals(2, split3.test().rowSize());
- assertEquals(4, split3.train().rowSize());
-
- LabeledDatasetTestTrainPair split4 = new LabeledDatasetTestTrainPair(training, 0.3);
-
- assertEquals(1, split4.test().rowSize());
- assertEquals(5, split4.train().rowSize());
- }
-
- /** */
- @Test
- public void testLabels() {
- double[][] mtx =
- new double[][] {
- {1.0, 1.0},
- {1.0, 2.0},
- {2.0, 1.0},
- {-1.0, -1.0},
- {-1.0, -2.0},
- {-2.0, -1.0}};
- double[] lbs = new double[] {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
-
- LabeledDataset dataset = new LabeledDataset(mtx, lbs);
- final double[] labels = dataset.labels();
- for (int i = 0; i < lbs.length; i++)
- assertEquals(lbs[i], labels[i]);
- }
-
- /** */
- @Test(expected = NoLabelVectorException.class)
- @SuppressWarnings("unchecked")
- public void testSetLabelInvalid() {
- new LabeledDataset(new LabeledVector[1]).setLabel(0, 2.0);
- }
-
- /** */
- @Override public void testExternalization() {
- double[][] mtx =
- new double[][] {
- {1.0, 1.0},
- {1.0, 2.0},
- {2.0, 1.0},
- {-1.0, -1.0},
- {-1.0, -2.0},
- {-2.0, -1.0}};
- double[] lbs = new double[] {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
-
- LabeledDataset dataset = new LabeledDataset(mtx, lbs);
- this.externalizeTest(dataset);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/82131d23/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledVectorSetTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledVectorSetTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledVectorSetTest.java
new file mode 100644
index 0000000..2303e96
--- /dev/null
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledVectorSetTest.java
@@ -0,0 +1,294 @@
+/*
+ * 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.ml.knn;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Objects;
+import org.apache.ignite.ml.math.ExternalizableTest;
+import org.apache.ignite.ml.math.exceptions.CardinalityException;
+import org.apache.ignite.ml.math.exceptions.NoDataException;
+import org.apache.ignite.ml.math.exceptions.knn.EmptyFileException;
+import org.apache.ignite.ml.math.exceptions.knn.FileParsingException;
+import org.apache.ignite.ml.math.exceptions.knn.NoLabelVectorException;
+import org.apache.ignite.ml.math.primitives.vector.Vector;
+import org.apache.ignite.ml.structures.LabeledVector;
+import org.apache.ignite.ml.structures.LabeledVectorSet;
+import org.apache.ignite.ml.structures.LabeledVectorSetTestTrainPair;
+import org.apache.ignite.ml.structures.preprocessing.LabeledDatasetLoader;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.fail;
+
+/** Tests behaviour of KNNClassificationTest. */
+public class LabeledVectorSetTest implements ExternalizableTest<LabeledVectorSet> {
+ /** */
+ private static final String KNN_IRIS_TXT = "datasets/knn/iris.txt";
+
+ /** */
+ private static final String NO_DATA_TXT = "datasets/knn/no_data.txt";
+
+ /** */
+ private static final String EMPTY_TXT = "datasets/knn/empty.txt";
+
+ /** */
+ private static final String IRIS_INCORRECT_TXT = "datasets/knn/iris_incorrect.txt";
+
+ /** */
+ private static final String IRIS_MISSED_DATA = "datasets/knn/missed_data.txt";
+
+ /** */
+ @Test
+ public void testFeatureNames() {
+ double[][] mtx =
+ new double[][] {
+ {1.0, 1.0},
+ {1.0, 2.0},
+ {2.0, 1.0},
+ {-1.0, -1.0},
+ {-1.0, -2.0},
+ {-2.0, -1.0}};
+ double[] lbs = new double[] {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
+
+ String[] featureNames = new String[] {"x", "y"};
+ final LabeledVectorSet dataset = new LabeledVectorSet(mtx, lbs, featureNames, false);
+
+ assertEquals(dataset.getFeatureName(0), "x");
+ }
+
+ /** */
+ @Test
+ public void testAccessMethods() {
+ double[][] mtx =
+ new double[][] {
+ {1.0, 1.0},
+ {1.0, 2.0},
+ {2.0, 1.0},
+ {-1.0, -1.0},
+ {-1.0, -2.0},
+ {-2.0, -1.0}};
+ double[] lbs = new double[] {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
+
+ final LabeledVectorSet dataset = new LabeledVectorSet(mtx, lbs, null, false);
+
+ assertEquals(dataset.colSize(), 2);
+ assertEquals(dataset.rowSize(), 6);
+
+ assertEquals(dataset.label(0), lbs[0], 0);
+
+ assertEquals(dataset.copy().colSize(), 2);
+
+ @SuppressWarnings("unchecked")
+ final LabeledVector<Vector, Double> row = (LabeledVector<Vector, Double>)dataset.getRow(0);
+
+ assertEquals(row.features().get(0), 1.0);
+ assertEquals(row.label(), 1.0);
+ dataset.setLabel(0, 2.0);
+ assertEquals(row.label(), 2.0);
+
+ assertEquals(0, new LabeledVectorSet().rowSize());
+ assertEquals(1, new LabeledVectorSet(1, 2).rowSize());
+ assertEquals(1, new LabeledVectorSet(1, 2, true).rowSize());
+ assertEquals(1, new LabeledVectorSet(1, 2, null, true).rowSize());
+ }
+
+ /** */
+ @Test
+ public void testFailOnYNull() {
+ double[][] mtx =
+ new double[][] {
+ {1.0, 1.0},
+ {1.0, 2.0},
+ {2.0, 1.0},
+ {-1.0, -1.0},
+ {-1.0, -2.0},
+ {-2.0, -1.0}};
+ double[] lbs = new double[] {};
+
+ try {
+ new LabeledVectorSet(mtx, lbs);
+ fail("CardinalityException");
+ }
+ catch (CardinalityException e) {
+ return;
+ }
+ fail("CardinalityException");
+ }
+
+ /** */
+ @Test
+ public void testFailOnXNull() {
+ double[][] mtx =
+ new double[][] {};
+ double[] lbs = new double[] {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
+
+ try {
+ new LabeledVectorSet(mtx, lbs);
+ fail("CardinalityException");
+ }
+ catch (CardinalityException e) {
+ return;
+ }
+ fail("CardinalityException");
+ }
+
+ /** */
+ @Test
+ public void testLoadingCorrectTxtFile() {
+ LabeledVectorSet training = LabeledDatasetHelper.loadDatasetFromTxt(KNN_IRIS_TXT, false);
+ assertEquals(training.rowSize(), 150);
+ }
+
+ /** */
+ @Test
+ public void testLoadingEmptyFile() {
+ try {
+ LabeledDatasetHelper.loadDatasetFromTxt(EMPTY_TXT, false);
+ fail("EmptyFileException");
+ }
+ catch (EmptyFileException e) {
+ return;
+ }
+ fail("EmptyFileException");
+ }
+
+ /** */
+ @Test
+ public void testLoadingFileWithFirstEmptyRow() {
+ try {
+ LabeledDatasetHelper.loadDatasetFromTxt(NO_DATA_TXT, false);
+ fail("NoDataException");
+ }
+ catch (NoDataException e) {
+ return;
+ }
+ fail("NoDataException");
+ }
+
+ /** */
+ @Test
+ public void testLoadingFileWithIncorrectData() {
+ LabeledVectorSet training = LabeledDatasetHelper.loadDatasetFromTxt(IRIS_INCORRECT_TXT, false);
+ assertEquals(149, training.rowSize());
+ }
+
+ /** */
+ @Test
+ public void testFailOnLoadingFileWithIncorrectData() {
+ try {
+ LabeledDatasetHelper.loadDatasetFromTxt(IRIS_INCORRECT_TXT, true);
+ fail("FileParsingException");
+ }
+ catch (FileParsingException e) {
+ return;
+ }
+ fail("FileParsingException");
+
+ }
+
+ /** */
+ @Test
+ public void testLoadingFileWithMissedData() throws URISyntaxException, IOException {
+ Path path = Paths.get(Objects.requireNonNull(this.getClass().getClassLoader().getResource(IRIS_MISSED_DATA)).toURI());
+
+ LabeledVectorSet training = LabeledDatasetLoader.loadFromTxtFile(path, ",", false, false);
+
+ assertEquals(training.features(2).get(1), 0.0);
+ }
+
+ /** */
+ @Test
+ public void testSplitting() {
+ double[][] mtx =
+ new double[][] {
+ {1.0, 1.0},
+ {1.0, 2.0},
+ {2.0, 1.0},
+ {-1.0, -1.0},
+ {-1.0, -2.0},
+ {-2.0, -1.0}};
+ double[] lbs = new double[] {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
+
+ LabeledVectorSet training = new LabeledVectorSet(mtx, lbs);
+
+ LabeledVectorSetTestTrainPair split1 = new LabeledVectorSetTestTrainPair(training, 0.67);
+
+ assertEquals(4, split1.test().rowSize());
+ assertEquals(2, split1.train().rowSize());
+
+ LabeledVectorSetTestTrainPair split2 = new LabeledVectorSetTestTrainPair(training, 0.65);
+
+ assertEquals(3, split2.test().rowSize());
+ assertEquals(3, split2.train().rowSize());
+
+ LabeledVectorSetTestTrainPair split3 = new LabeledVectorSetTestTrainPair(training, 0.4);
+
+ assertEquals(2, split3.test().rowSize());
+ assertEquals(4, split3.train().rowSize());
+
+ LabeledVectorSetTestTrainPair split4 = new LabeledVectorSetTestTrainPair(training, 0.3);
+
+ assertEquals(1, split4.test().rowSize());
+ assertEquals(5, split4.train().rowSize());
+ }
+
+ /** */
+ @Test
+ public void testLabels() {
+ double[][] mtx =
+ new double[][] {
+ {1.0, 1.0},
+ {1.0, 2.0},
+ {2.0, 1.0},
+ {-1.0, -1.0},
+ {-1.0, -2.0},
+ {-2.0, -1.0}};
+ double[] lbs = new double[] {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
+
+ LabeledVectorSet dataset = new LabeledVectorSet(mtx, lbs);
+ final double[] labels = dataset.labels();
+ for (int i = 0; i < lbs.length; i++)
+ assertEquals(lbs[i], labels[i]);
+ }
+
+ /** */
+ @Test(expected = NoLabelVectorException.class)
+ @SuppressWarnings("unchecked")
+ public void testSetLabelInvalid() {
+ new LabeledVectorSet(new LabeledVector[1]).setLabel(0, 2.0);
+ }
+
+ /** */
+ @Override public void testExternalization() {
+ double[][] mtx =
+ new double[][] {
+ {1.0, 1.0},
+ {1.0, 2.0},
+ {2.0, 1.0},
+ {-1.0, -1.0},
+ {-1.0, -2.0},
+ {-2.0, -1.0}};
+ double[] lbs = new double[] {1.0, 1.0, 1.0, 2.0, 2.0, 2.0};
+
+ LabeledVectorSet dataset = new LabeledVectorSet(mtx, lbs);
+ this.externalizeTest(dataset);
+ }
+}
[12/19] ignite git commit: IGNITE-8919 Wrong documentation of exec
methods in StartNodeCallableImpl class - Fixes #4535.
Posted by av...@apache.org.
IGNITE-8919 Wrong documentation of exec methods in StartNodeCallableImpl class - Fixes #4535.
Signed-off-by: Dmitriy Pavlov <dp...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/53427894
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/53427894
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/53427894
Branch: refs/heads/ignite-9053
Commit: 534278946dd6f55809e9dc6b19633b6a67051d21
Parents: 18356a8
Author: Fedotov <va...@gmail.com>
Authored: Wed Aug 15 17:16:06 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Wed Aug 15 17:17:51 2018 +0300
----------------------------------------------------------------------
.../internal/util/nodestart/StartNodeCallableImpl.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/53427894/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/StartNodeCallableImpl.java
----------------------------------------------------------------------
diff --git a/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/StartNodeCallableImpl.java b/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/StartNodeCallableImpl.java
index 1bf23b3..98c54c4 100644
--- a/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/StartNodeCallableImpl.java
+++ b/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/StartNodeCallableImpl.java
@@ -382,11 +382,11 @@ public class StartNodeCallableImpl implements StartNodeCallable {
}
/**
- * Gets the value of the specified environment variable.
+ * Executes command using {@code exec} channel.
*
* @param ses SSH session.
- * @param cmd environment variable name.
- * @return environment variable value.
+ * @param cmd Command.
+ * @return Output result.
* @throws JSchException In case of SSH error.
* @throws IOException If failed.
*/
@@ -395,12 +395,12 @@ public class StartNodeCallableImpl implements StartNodeCallable {
}
/**
- * Gets the value of the specified environment variable.
+ * Executes command using {@code exec} channel with setting encoding.
*
* @param ses SSH session.
- * @param cmd environment variable name.
+ * @param cmd Command.
* @param encoding Process output encoding, {@code null} for default charset encoding.
- * @return environment variable value.
+ * @return Output result.
* @throws JSchException In case of SSH error.
* @throws IOException If failed.
*/
[02/19] ignite git commit: IGNITE-9260 Fixed failing test (omit check
in standalone WAL iterator) - Fixes #4533.
Posted by av...@apache.org.
IGNITE-9260 Fixed failing test (omit check in standalone WAL iterator) - Fixes #4533.
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/237a99ed
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/237a99ed
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/237a99ed
Branch: refs/heads/ignite-9053
Commit: 237a99ed7c42e1b98d14fe4945d9a0b7faa9be70
Parents: cd5b32b
Author: Dmitriy Govorukhin <dm...@gmail.com>
Authored: Tue Aug 14 15:03:21 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Aug 14 15:03:21 2018 +0300
----------------------------------------------------------------------
.../wal/AbstractWalRecordsIterator.java | 23 ++++++++++++++++----
.../reader/StandaloneWalRecordsIterator.java | 20 +++++++++++++++++
...IsReachedDuringIterationOverArchiveTest.java | 3 ++-
3 files changed, 41 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/237a99ed/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java
index ac68ea9..27f0102 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java
@@ -164,10 +164,10 @@ public abstract class AbstractWalRecordsIterator
catch (WalSegmentTailReachedException e) {
AbstractReadFileHandle currWalSegment = this.currWalSegment;
- if (!currWalSegment.workDir())
- throw new IgniteCheckedException(
- "WAL tail reached in archive directory, " +
- "WAL segment file is corrupted.", e);
+ IgniteCheckedException e0 = validateTailReachedException(e, currWalSegment);
+
+ if (e0 != null)
+ throw e0;
log.warning(e.getMessage());
@@ -179,6 +179,21 @@ public abstract class AbstractWalRecordsIterator
}
/**
+ *
+ * @param tailReachedException Tail reached exception.
+ * @param currWalSegment Current WAL segment read handler.
+ * @return If need to throw exception after validation.
+ */
+ protected IgniteCheckedException validateTailReachedException(
+ WalSegmentTailReachedException tailReachedException,
+ AbstractReadFileHandle currWalSegment
+ ) {
+ return !currWalSegment.workDir() ? new IgniteCheckedException(
+ "WAL tail reached in archive directory, " +
+ "WAL segment file is corrupted.", tailReachedException) : null;
+ }
+
+ /**
* Closes and returns WAL segment (if any)
*
* @return closed handle
http://git-wip-us.apache.org/repos/asf/ignite/blob/237a99ed/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
index 9df4468..d92c0e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
@@ -44,6 +44,7 @@ import org.apache.ignite.internal.processors.cache.persistence.wal.FileInput;
import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer;
import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager.FileDescriptor;
import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager.ReadFileHandle;
+import org.apache.ignite.internal.processors.cache.persistence.wal.WalSegmentTailReachedException;
import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializer;
import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactoryImpl;
import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
@@ -129,6 +130,25 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator {
}
/** {@inheritDoc} */
+ @Override protected IgniteCheckedException validateTailReachedException(
+ WalSegmentTailReachedException tailReachedException,
+ AbstractReadFileHandle currWalSegment
+ ) {
+ FileDescriptor lastWALSegmentDesc = walFileDescriptors.get(walFileDescriptors.size() - 1);
+
+ // Iterator can not be empty.
+ assert lastWALSegmentDesc != null;
+
+ return lastWALSegmentDesc.idx() != currWalSegment.idx() ?
+ new IgniteCheckedException(
+ "WAL tail reached not in the last available segment, " +
+ "potentially corrupted segment, last available segment idx=" + lastWALSegmentDesc.idx() +
+ ", path=" + lastWALSegmentDesc.file().getPath() +
+ ", last read segment idx=" + currWalSegment.idx(), tailReachedException
+ ) : null;
+ }
+
+ /** {@inheritDoc} */
@Override protected AbstractReadFileHandle advanceSegment(
@Nullable final AbstractReadFileHandle curWalSegment
) throws IgniteCheckedException {
http://git-wip-us.apache.org/repos/asf/ignite/blob/237a99ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWALTailIsReachedDuringIterationOverArchiveTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWALTailIsReachedDuringIterationOverArchiveTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWALTailIsReachedDuringIterationOverArchiveTest.java
index a7c4081..5fd5a1b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWALTailIsReachedDuringIterationOverArchiveTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWALTailIsReachedDuringIterationOverArchiveTest.java
@@ -185,7 +185,8 @@ public class IgniteWALTailIsReachedDuringIterationOverArchiveTest extends GridCo
}
}
catch (IgniteCheckedException e) {
- if (e.getMessage().contains("WAL tail reached in archive directory, WAL segment file is corrupted."))
+ if (e.getMessage().contains("WAL tail reached in archive directory, WAL segment file is corrupted")
+ || e.getMessage().contains("WAL tail reached not in the last available segment"))
exception = true;
}
[19/19] ignite git commit: Merge remote-tracking branch
'remotes/origin/master' into ignite-9053
Posted by av...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-9053
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/da3b7a0a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/da3b7a0a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/da3b7a0a
Branch: refs/heads/ignite-9053
Commit: da3b7a0ab52b2cb451a8cb2adbabbef7c0d46086
Parents: 3540e1c dd8c933
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Aug 16 01:03:25 2018 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Aug 16 01:03:25 2018 +0300
----------------------------------------------------------------------
.../ml/knn/ANNClassificationExample.java | 307 ++++++++
.../ml/knn/KNNClassificationExample.java | 8 +-
.../examples/ml/knn/KNNRegressionExample.java | 4 +-
.../ignite/examples/ml/tutorial/Step_6_KNN.java | 8 +-
idea/ignite_inspections.xml | 772 +++++++++++++++++++
modules/camel/pom.xml | 1 -
modules/cassandra/store/pom.xml | 1 -
.../java/org/apache/ignite/IgniteCompute.java | 14 +
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../main/java/org/apache/ignite/Ignition.java | 8 +-
.../org/apache/ignite/cluster/ClusterNode.java | 12 +-
.../DefaultCommunicationFailureResolver.java | 10 +-
.../ignite/internal/IgniteComputeImpl.java | 15 +
.../apache/ignite/internal/IgniteKernal.java | 2 +-
.../discovery/GridDiscoveryManager.java | 13 +-
.../managers/discovery/IgniteClusterNode.java | 7 -
.../cache/CacheAffinitySharedManager.java | 2 +-
.../cache/ExchangeDiscoveryEvents.java | 9 +-
.../processors/cache/GridCacheAdapter.java | 1 -
.../GridCachePartitionExchangeManager.java | 6 +-
.../processors/cache/GridCacheProcessor.java | 2 +-
.../processors/cache/GridCacheUtils.java | 26 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 14 +-
.../colocated/GridDhtColocatedLockFuture.java | 76 +-
.../GridDhtPartitionsExchangeFuture.java | 14 +-
.../preloader/latch/ExchangeLatchManager.java | 2 +-
.../distributed/near/GridNearLockFuture.java | 80 +-
.../wal/AbstractWalRecordsIterator.java | 23 +-
.../wal/FileWriteAheadLogManager.java | 62 +-
.../reader/StandaloneWalRecordsIterator.java | 20 +
.../cache/transactions/IgniteTxHandler.java | 2 +-
.../task/GridTaskThreadContextKey.java | 3 +
.../processors/task/GridTaskWorker.java | 7 +-
.../util/tostring/GridToStringBuilder.java | 139 ++--
.../org/apache/ignite/spi/IgniteSpiAdapter.java | 2 +-
.../communication/tcp/TcpCommunicationSpi.java | 2 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 22 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 8 +-
.../tcp/internal/TcpDiscoveryNode.java | 24 +-
.../tcp/internal/TcpDiscoveryNodesRing.java | 8 +-
...heStoreSessionListenerLifecycleSelfTest.java | 5 +-
.../internal/GridTaskResultCacheSelfTest.java | 26 +-
.../GridDiscoveryManagerAttributesSelfTest.java | 53 +-
...niteCacheCopyOnReadDisabledAbstractTest.java | 10 +-
.../IgniteCacheStoreValueAbstractTest.java | 13 +-
...gniteTopologyValidatorAbstractCacheTest.java | 2 +-
.../CacheLateAffinityAssignmentTest.java | 2 +-
...IsReachedDuringIterationOverArchiveTest.java | 3 +-
.../tostring/GridToStringBuilderSelfTest.java | 110 ++-
.../mapper/GridContinuousMapperLoadTest1.java | 51 --
.../mapper/GridContinuousMapperLoadTest2.java | 92 ---
.../mapper/GridContinuousMapperTask1.java | 157 ----
.../mapper/GridContinuousMapperTask2.java | 93 ---
.../ignite/loadtests/mapper/TestObject.java | 57 --
.../testframework/junits/GridAbstractTest.java | 3 +
.../testsuites/IgniteCacheTestSuite4.java | 34 +-
.../testsuites/IgniteCacheTestSuite6.java | 2 +
.../testsuites/IgniteLostAndFoundTestSuite.java | 1 -
.../ignite/testsuites/IgnitePdsTestSuite.java | 2 +-
.../ignite/testsuites/IgnitePdsTestSuite2.java | 25 -
.../ignite/testsuites/IgnitePdsTestSuite3.java | 49 ++
.../ignite/testsuites/IgnitePdsTestSuite4.java | 63 ++
...niteHadoopFileSystemClientBasedOpenTest.java | 2 +-
.../processors/query/h2/IgniteH2Indexing.java | 2 +-
.../ml/clustering/kmeans/KMeansTrainer.java | 95 ++-
.../boosting/GDBBinaryClassifierTrainer.java | 4 +-
.../parallelism/ParallelismStrategy.java | 15 +-
.../java/org/apache/ignite/ml/knn/KNNUtils.java | 8 +-
.../ignite/ml/knn/NNClassificationModel.java | 217 ++++++
.../ml/knn/ann/ANNClassificationModel.java | 197 +++++
.../ml/knn/ann/ANNClassificationTrainer.java | 343 ++++++++
.../ignite/ml/knn/ann/ANNModelFormat.java | 84 ++
.../apache/ignite/ml/knn/ann/ProbableLabel.java | 39 +
.../apache/ignite/ml/knn/ann/package-info.java | 22 +
.../classification/KNNClassificationModel.java | 189 +----
.../ml/knn/classification/KNNModelFormat.java | 14 +-
.../ml/knn/classification/KNNStrategy.java | 29 -
.../ml/knn/classification/NNStrategy.java | 29 +
.../ml/knn/regression/KNNRegressionModel.java | 4 +-
.../ignite/ml/structures/LabeledDataset.java | 220 ------
.../structures/LabeledDatasetTestTrainPair.java | 114 ---
.../ignite/ml/structures/LabeledVectorSet.java | 220 ++++++
.../LabeledVectorSetTestTrainPair.java | 114 +++
...abeledDatasetPartitionDataBuilderOnHeap.java | 12 +-
.../preprocessing/LabeledDatasetLoader.java | 10 +-
.../SVMLinearBinaryClassificationTrainer.java | 12 +-
.../org/apache/ignite/ml/LocalModelsTest.java | 45 +-
.../ignite/ml/common/CollectionsTest.java | 6 +-
.../ignite/ml/knn/ANNClassificationTest.java | 108 +++
.../ignite/ml/knn/KNNClassificationTest.java | 19 +-
.../apache/ignite/ml/knn/KNNRegressionTest.java | 16 +-
.../org/apache/ignite/ml/knn/KNNTestSuite.java | 3 +-
.../ignite/ml/knn/LabeledDatasetHelper.java | 4 +-
.../ignite/ml/knn/LabeledDatasetTest.java | 294 -------
.../ignite/ml/knn/LabeledVectorSetTest.java | 294 +++++++
.../osgi-karaf/src/main/resources/features.xml | 4 +-
.../util/nodestart/StartNodeCallableImpl.java | 12 +-
.../zk/internal/ZookeeperClusterNode.java | 5 -
parent/pom.xml | 11 +-
99 files changed, 3652 insertions(+), 1756 deletions(-)
----------------------------------------------------------------------
[09/19] ignite git commit: IGNITE-9044 Update scala dependency
version in Apache Ignite. - Fixes #4421.
Posted by av...@apache.org.
IGNITE-9044 Update scala dependency version in Apache Ignite. - Fixes #4421.
Signed-off-by: Dmitriy Pavlov <dp...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fd921a23
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fd921a23
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fd921a23
Branch: refs/heads/ignite-9053
Commit: fd921a233d35408883695419b6f9979ac674d1b9
Parents: 3e75f91
Author: Nikolai Kulagin <31...@users.noreply.github.com>
Authored: Wed Aug 15 14:56:57 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Wed Aug 15 14:56:57 2018 +0300
----------------------------------------------------------------------
modules/osgi-karaf/src/main/resources/features.xml | 4 ++--
parent/pom.xml | 9 ++++-----
2 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fd921a23/modules/osgi-karaf/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/modules/osgi-karaf/src/main/resources/features.xml b/modules/osgi-karaf/src/main/resources/features.xml
index 3e3989e..b9af29f 100644
--- a/modules/osgi-karaf/src/main/resources/features.xml
+++ b/modules/osgi-karaf/src/main/resources/features.xml
@@ -164,7 +164,7 @@
<![CDATA[The Apache Ignite Kafka module + dependencies. This module installs the Scala 2.11 library bundle.]]>
</details>
<feature prerequisite="true">wrap</feature>
- <bundle start="true" dependency="true">mvn:org.scala-lang/scala-library/${scala211.library.version}</bundle>
+ <bundle start="true" dependency="true">mvn:org.scala-lang/scala-library/${scala.library.version}</bundle>
<bundle start="true" dependency="true">wrap:mvn:com.yammer.metrics/metrics-core/${yammer.metrics.core.version}$Bundle-SymbolicName=yammer-metrics-core&Bundle-Version=2.2.0&Export-Package=*;-noimport:=true;version=${yammer.metrics.core.version}</bundle>
<bundle start="true" dependency="true">wrap:mvn:com.yammer.metrics/metrics-annotation/${yammer.metrics.annotation.version}$Bundle-SymbolicName=yammer-metrics-annotation&Bundle-Version=2.2.0&Export-Package=*;-noimport:=true;version=${yammer.metrics.annotation.version}</bundle>
<bundle start="true" dependency="true">wrap:mvn:org.apache.kafka/connect-api/${kafka.version}$Bundle-SymbolicName=connect-api&Bundle-Version=${kafka.version}</bundle>
@@ -228,7 +228,7 @@
<details>
<![CDATA[The Apache Ignite Scala 2.11 integration module + dependencies. This module installs the Scala 2.11 library bundle.]]>
</details>
- <bundle start="true" dependency="true">mvn:org.scala-lang/scala-library/${scala211.library.version}</bundle>
+ <bundle start="true" dependency="true">mvn:org.scala-lang/scala-library/${scala.library.version}</bundle>
<bundle start="true">mvn:org.apache.ignite/ignite-scalar/${project.version}</bundle>
</feature>
http://git-wip-us.apache.org/repos/asf/ignite/blob/fd921a23/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 5f486cb..d984fc5 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -103,10 +103,9 @@
<paho.version>1.0.2</paho.version>
<postgres.connector.version>9.4.1208.jre7</postgres.connector.version>
<rocketmq.version>4.3.0</rocketmq.version>
- <scala210.jline.version>2.10.4</scala210.jline.version>
- <scala210.library.version>2.10.6</scala210.library.version>
- <scala211.library.version>2.11.8</scala211.library.version>
- <scala.library.version>2.11.8</scala.library.version>
+ <scala210.jline.version>2.10.7</scala210.jline.version>
+ <scala210.library.version>2.10.7</scala210.library.version>
+ <scala.library.version>2.11.12</scala.library.version>
<slf4j.version>1.7.7</slf4j.version>
<slf4j16.version>1.6.4</slf4j16.version>
<spark.hadoop.version>2.6.5</spark.hadoop.version>
@@ -982,7 +981,7 @@
<properties>
<maven.compiler.source>9</maven.compiler.source>
<maven.compiler.target>9</maven.compiler.target>
- <scala.library.version>2.12.4</scala.library.version>
+ <scala.library.version>2.12.6</scala.library.version>
</properties>
<dependencies/>
<build>
[04/19] ignite git commit: IGNITE-8673 Fixed ClusterNode#isClient
method. Fixes #4104
Posted by av...@apache.org.
IGNITE-8673 Fixed ClusterNode#isClient method. Fixes #4104
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2fc90731
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2fc90731
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2fc90731
Branch: refs/heads/ignite-9053
Commit: 2fc90731acb183b1505cff7e878134e88b9161da
Parents: a145603
Author: Eduard Shangareev <es...@gridgain.com>
Authored: Tue Aug 14 16:14:08 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Aug 14 16:14:08 2018 +0300
----------------------------------------------------------------------
.../main/java/org/apache/ignite/Ignition.java | 8 +--
.../org/apache/ignite/cluster/ClusterNode.java | 12 ++---
.../DefaultCommunicationFailureResolver.java | 10 ++--
.../apache/ignite/internal/IgniteKernal.java | 2 +-
.../discovery/GridDiscoveryManager.java | 13 +++--
.../managers/discovery/IgniteClusterNode.java | 7 ---
.../cache/CacheAffinitySharedManager.java | 2 +-
.../cache/ExchangeDiscoveryEvents.java | 9 ++--
.../GridCachePartitionExchangeManager.java | 6 +--
.../processors/cache/GridCacheProcessor.java | 2 +-
.../processors/cache/GridCacheUtils.java | 26 +---------
.../dht/GridDhtTransactionalCacheAdapter.java | 2 +-
.../GridDhtPartitionsExchangeFuture.java | 14 +++---
.../preloader/latch/ExchangeLatchManager.java | 2 +-
.../cache/transactions/IgniteTxHandler.java | 2 +-
.../org/apache/ignite/spi/IgniteSpiAdapter.java | 2 +-
.../communication/tcp/TcpCommunicationSpi.java | 2 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 22 ++++----
.../spi/discovery/tcp/TcpDiscoverySpi.java | 8 ++-
.../tcp/internal/TcpDiscoveryNode.java | 24 ++++-----
.../tcp/internal/TcpDiscoveryNodesRing.java | 8 +--
.../GridDiscoveryManagerAttributesSelfTest.java | 53 +++++++++++++++++---
...gniteTopologyValidatorAbstractCacheTest.java | 2 +-
.../CacheLateAffinityAssignmentTest.java | 2 +-
.../processors/query/h2/IgniteH2Indexing.java | 2 +-
.../zk/internal/ZookeeperClusterNode.java | 5 --
26 files changed, 122 insertions(+), 125 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/Ignition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/Ignition.java b/modules/core/src/main/java/org/apache/ignite/Ignition.java
index 835896e..64e855a 100644
--- a/modules/core/src/main/java/org/apache/ignite/Ignition.java
+++ b/modules/core/src/main/java/org/apache/ignite/Ignition.java
@@ -141,30 +141,26 @@ public class Ignition {
}
/**
- * Sets client mode static flag.
+ * Sets client mode thread-local flag.
* <p>
* This flag used when node is started if {@link IgniteConfiguration#isClientMode()}
* is {@code null}. When {@link IgniteConfiguration#isClientMode()} is set this flag is ignored.
- * It is recommended to use {@link DiscoverySpi} in client mode too.
*
* @param clientMode Client mode flag.
* @see IgniteConfiguration#isClientMode()
- * @see TcpDiscoverySpi#setForceServerMode(boolean)
*/
public static void setClientMode(boolean clientMode) {
IgnitionEx.setClientMode(clientMode);
}
/**
- * Gets client mode static flag.
+ * Gets client mode thread-local flag.
* <p>
* This flag used when node is started if {@link IgniteConfiguration#isClientMode()}
* is {@code null}. When {@link IgniteConfiguration#isClientMode()} is set this flag is ignored.
- * It is recommended to use {@link DiscoverySpi} in client mode too.
*
* @return Client mode flag.
* @see IgniteConfiguration#isClientMode()
- * @see TcpDiscoverySpi#setForceServerMode(boolean)
*/
public static boolean isClientMode() {
return IgnitionEx.isClientMode();
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
index 97b3165..bfc6c18 100644
--- a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
+++ b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
@@ -245,17 +245,11 @@ public interface ClusterNode extends BaselineNode {
public boolean isDaemon();
/**
- * Tests whether or not this node is connected to cluster as a client.
- * <p>
- * Do not confuse client in terms of
- * discovery {@link DiscoverySpi#isClientMode()} and client in terms of cache
- * {@link IgniteConfiguration#isClientMode()}. Cache clients cannot carry data,
- * while topology clients connect to topology in a different way.
+ * Whether this node is cache client (see {@link IgniteConfiguration#isClientMode()}).
+ *
+ * @return {@code True if client}.
*
- * @return {@code True} if this node is a client node, {@code false} otherwise.
* @see IgniteConfiguration#isClientMode()
- * @see Ignition#isClientMode()
- * @see DiscoverySpi#isClientMode()
*/
public boolean isClient();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/configuration/DefaultCommunicationFailureResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/DefaultCommunicationFailureResolver.java b/modules/core/src/main/java/org/apache/ignite/configuration/DefaultCommunicationFailureResolver.java
index 9ccadf3..d2a5081 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/DefaultCommunicationFailureResolver.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/DefaultCommunicationFailureResolver.java
@@ -67,11 +67,11 @@ public class DefaultCommunicationFailureResolver implements CommunicationFailure
@Nullable private ClusterPart findLargestConnectedCluster(CommunicationFailureContext ctx) {
List<ClusterNode> srvNodes = ctx.topologySnapshot()
.stream()
- .filter(node -> !CU.clientNode(node))
+ .filter(node -> !node.isClient())
.collect(Collectors.toList());
// Exclude client nodes from analysis.
- ClusterGraph graph = new ClusterGraph(ctx, CU::clientNode);
+ ClusterGraph graph = new ClusterGraph(ctx, ClusterNode::isClient);
List<BitSet> components = graph.findConnectedComponents();
@@ -153,7 +153,7 @@ public class DefaultCommunicationFailureResolver implements CommunicationFailure
ClusterNode node = allNodes.get(idx);
// Client nodes will be processed separately.
- if (CU.clientNode(node))
+ if (node.isClient())
continue;
if (!clusterPart.srvNodesSet.get(idx))
@@ -164,7 +164,7 @@ public class DefaultCommunicationFailureResolver implements CommunicationFailure
for (int idx = 0; idx < allNodes.size(); idx++) {
ClusterNode node = allNodes.get(idx);
- if (CU.clientNode(node) && !clusterPart.connectedClients.contains(node))
+ if (node.isClient() && !clusterPart.connectedClients.contains(node))
ctx.killNode(node);
}
}
@@ -182,7 +182,7 @@ public class DefaultCommunicationFailureResolver implements CommunicationFailure
List<ClusterNode> allNodes = ctx.topologySnapshot();
for (ClusterNode node : allNodes) {
- if (!CU.clientNode(node))
+ if (!node.isClient())
continue;
boolean hasConnections = true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index ff0e4ee..2f99937 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -1110,7 +1110,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
catch (IgniteNeedReconnectException e) {
ClusterNode locNode = ctx.discovery().localNode();
- assert CU.clientNode(locNode);
+ assert locNode.isClient();
if (!locNode.isClient())
throw new IgniteCheckedException("Client node in forceServerMode " +
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 82abdf5..2fbeda9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -130,6 +130,7 @@ import org.apache.ignite.spi.discovery.DiscoverySpiMutableCustomMessageSupport;
import org.apache.ignite.spi.discovery.DiscoverySpiNodeAuthenticator;
import org.apache.ignite.spi.discovery.DiscoverySpiOrderSupport;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
import org.apache.ignite.thread.IgniteThread;
import org.apache.ignite.thread.OomExceptionHandler;
import org.jetbrains.annotations.NotNull;
@@ -207,7 +208,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
/** Predicate filtering client nodes. */
private static final IgnitePredicate<ClusterNode> FILTER_CLI = new P1<ClusterNode>() {
@Override public boolean apply(ClusterNode n) {
- return CU.clientNode(n);
+ return n.isClient();
}
};
@@ -2313,8 +2314,12 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
public boolean reconnectSupported() {
DiscoverySpi spi = getSpi();
- return ctx.discovery().localNode().isClient() &&
- (spi instanceof IgniteDiscoverySpi) &&
+ ClusterNode clusterNode = ctx.discovery().localNode();
+
+ boolean client = (clusterNode instanceof TcpDiscoveryNode) ?
+ (((TcpDiscoveryNode) clusterNode).clientRouterNodeId() != null) : clusterNode.isClient();
+
+ return client && (spi instanceof IgniteDiscoverySpi) &&
((IgniteDiscoverySpi)spi).clientReconnectSupported();
}
@@ -2374,7 +2379,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
if (!node.isLocal())
rmtNodes.add(node);
- if (!CU.clientNode(node)) {
+ if (!node.isClient()) {
srvNodes.add(node);
if (minSrvVer == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/IgniteClusterNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/IgniteClusterNode.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/IgniteClusterNode.java
index cbc706a..a143122 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/IgniteClusterNode.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/IgniteClusterNode.java
@@ -59,11 +59,4 @@ public interface IgniteClusterNode extends ClusterNode {
* @param cacheMetrics Cache metrics.
*/
public void setCacheMetrics(Map<Integer, CacheMetrics> cacheMetrics);
-
- /**
- * Whether this node is cache client (see {@link IgniteConfiguration#isClientMode()}).
- *
- * @return {@code True if client}.
- */
- public boolean isCacheClient();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
index 2871e82..3862523 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
@@ -168,7 +168,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
!DiscoveryCustomEvent.requiresCentralizedAffinityAssignment(customMsg))
return;
- if ((!CU.clientNode(node) && (type == EVT_NODE_FAILED || type == EVT_NODE_JOINED || type == EVT_NODE_LEFT)) ||
+ if ((!node.isClient() && (type == EVT_NODE_FAILED || type == EVT_NODE_JOINED || type == EVT_NODE_LEFT)) ||
DiscoveryCustomEvent.requiresCentralizedAffinityAssignment(customMsg)) {
synchronized (mux) {
assert lastAffVer == null || topVer.compareTo(lastAffVer) > 0 :
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java
index 0e7e01c..2f7753b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java
@@ -29,7 +29,6 @@ import org.apache.ignite.events.EventType;
import org.apache.ignite.internal.managers.discovery.DiscoCache;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
-import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -127,7 +126,7 @@ public class ExchangeDiscoveryEvents {
ClusterNode node = evt.eventNode();
- if (!CU.clientNode(node)) {
+ if (!node.isClient()) {
lastSrvEvt = evt;
srvEvtTopVer = new AffinityTopologyVersion(evt.topologyVersion(), 0);
@@ -135,7 +134,7 @@ public class ExchangeDiscoveryEvents {
if (evt.type()== EVT_NODE_JOINED)
srvJoin = true;
else if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED)
- srvLeft = !CU.clientNode(node);
+ srvLeft = !node.isClient();
}
}
@@ -151,7 +150,7 @@ public class ExchangeDiscoveryEvents {
* @return {@code True} if given event is {@link EventType#EVT_NODE_FAILED} or {@link EventType#EVT_NODE_LEFT}.
*/
public static boolean serverLeftEvent(DiscoveryEvent evt) {
- return ((evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT) && !CU.clientNode(evt.eventNode()));
+ return ((evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT) && !evt.eventNode().isClient());
}
/**
@@ -159,7 +158,7 @@ public class ExchangeDiscoveryEvents {
* @return {@code True} if given event is {@link EventType#EVT_NODE_JOINED}.
*/
public static boolean serverJoinEvent(DiscoveryEvent evt) {
- return (evt.type() == EVT_NODE_JOINED && !CU.clientNode(evt.eventNode()));
+ return (evt.type() == EVT_NODE_JOINED && !evt.eventNode().isClient());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 4ec7774..f65d338 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -1969,7 +1969,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
", mergedFut=" + fut.initialVersion() +
", evt=" + IgniteUtils.gridEventName(fut.firstEvent().type()) +
", evtNode=" + fut.firstEvent().eventNode().id()+
- ", evtNodeClient=" + CU.clientNode(fut.firstEvent().eventNode())+ ']');
+ ", evtNodeClient=" + fut.firstEvent().eventNode().isClient() + ']');
}
DiscoveryEvent evt = fut.firstEvent();
@@ -2060,7 +2060,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
", mergedFut=" + fut.initialVersion() +
", evt=" + IgniteUtils.gridEventName(fut.firstEvent().type()) +
", evtNode=" + fut.firstEvent().eventNode().id() +
- ", evtNodeClient=" + CU.clientNode(fut.firstEvent().eventNode())+ ']');
+ ", evtNodeClient=" + fut.firstEvent().eventNode().isClient() + ']');
}
addDiscoEvtForTest(fut.firstEvent());
@@ -2342,7 +2342,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
// because only current exchange future can have multiple discovery events (exchange merge).
ClusterNode triggeredBy = ((GridDhtPartitionsExchangeFuture) task).firstEvent().eventNode();
- if (!CU.clientNode(triggeredBy))
+ if (!triggeredBy.isClient())
return true;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index ed97982..6818e50 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -3630,7 +3630,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* @return Validation result or {@code null} in case of success.
*/
@Nullable private IgniteNodeValidationResult validateHashIdResolvers(ClusterNode node) {
- if (!CU.clientNode(node)) {
+ if (!node.isClient()) {
for (DynamicCacheDescriptor desc : cacheDescriptors().values()) {
CacheConfiguration cfg = desc.cacheConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 6b1e42d..eed9627 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -1353,35 +1353,11 @@ public class GridCacheUtils {
/**
* @param node Node.
- * @return {@code True} if given node is client node (has flag {@link IgniteConfiguration#isClientMode()} set).
- */
- public static boolean clientNode(ClusterNode node) {
- if (node instanceof IgniteClusterNode)
- return ((IgniteClusterNode)node).isCacheClient();
- else
- return clientNodeDirect(node);
- }
-
- /**
- * @param node Node.
- * @return {@code True} if given node is client node (has flag {@link IgniteConfiguration#isClientMode()} set).
- */
- @SuppressWarnings("ConstantConditions")
- public static boolean clientNodeDirect(ClusterNode node) {
- Boolean clientModeAttr = node.attribute(IgniteNodeAttributes.ATTR_CLIENT_MODE);
-
- assert clientModeAttr != null : node;
-
- return clientModeAttr != null && clientModeAttr;
- }
-
- /**
- * @param node Node.
* @param filter Node filter.
* @return {@code True} if node is not client node and pass given filter.
*/
public static boolean affinityNode(ClusterNode node, IgnitePredicate<ClusterNode> filter) {
- return !node.isDaemon() && !clientNode(node) && filter.apply(node);
+ return !node.isDaemon() && !node.isClient() && filter.apply(node);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index 161c542..46d7579 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -920,7 +920,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
GridDhtPartitionTopology top = null;
if (req.firstClientRequest()) {
- assert CU.clientNode(nearNode);
+ assert nearNode.isClient();
top = topology();
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index 4d0b583..28dc8f3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -727,7 +727,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
}
}
else {
- if (CU.clientNode(firstDiscoEvt.eventNode()))
+ if (firstDiscoEvt.eventNode().isClient())
exchange = onClientNodeEvent(crdNode);
else
exchange = cctx.kernalContext().clientNode() ? ExchangeType.CLIENT : ExchangeType.ALL;
@@ -737,7 +737,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
onLeft();
}
else {
- exchange = CU.clientNode(firstDiscoEvt.eventNode()) ? onClientNodeEvent(crdNode) :
+ exchange = firstDiscoEvt.eventNode().isClient() ? onClientNodeEvent(crdNode) :
onServerNodeEvent(crdNode);
}
}
@@ -1113,7 +1113,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
* @return Exchange type.
*/
private ExchangeType onClientNodeEvent(boolean crd) throws IgniteCheckedException {
- assert CU.clientNode(firstDiscoEvt.eventNode()) : this;
+ assert firstDiscoEvt.eventNode().isClient() : this;
if (firstDiscoEvt.type() == EVT_NODE_LEFT || firstDiscoEvt.type() == EVT_NODE_FAILED) {
onLeft();
@@ -1134,7 +1134,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
* @return Exchange type.
*/
private ExchangeType onServerNodeEvent(boolean crd) throws IgniteCheckedException {
- assert !CU.clientNode(firstDiscoEvt.eventNode()) : this;
+ assert !firstDiscoEvt.eventNode().isClient() : this;
if (firstDiscoEvt.type() == EVT_NODE_LEFT || firstDiscoEvt.type() == EVT_NODE_FAILED) {
onLeft();
@@ -1965,7 +1965,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
boolean wait = false;
- if (CU.clientNode(node)) {
+ if (node.isClient()) {
if (msg != null)
waitAndReplyToNode(nodeId, msg);
}
@@ -2237,7 +2237,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
}
if (finishState0 == null) {
- assert firstDiscoEvt.type() == EVT_NODE_JOINED && CU.clientNode(firstDiscoEvt.eventNode()) : this;
+ assert firstDiscoEvt.type() == EVT_NODE_JOINED && firstDiscoEvt.eventNode().isClient() : this;
ClusterNode node = cctx.node(nodeId);
@@ -3170,7 +3170,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
*/
public void onReceivePartitionRequest(final ClusterNode node, final GridDhtPartitionsSingleRequest msg) {
assert !cctx.kernalContext().clientNode() || msg.restoreState();
- assert !node.isDaemon() && !CU.clientNode(node) : node;
+ assert !node.isDaemon() && !node.isClient() : node;
initFut.listen(new CI1<IgniteInternalFuture<Boolean>>() {
@Override public void apply(IgniteInternalFuture<Boolean> fut) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/ExchangeLatchManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/ExchangeLatchManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/ExchangeLatchManager.java
index 0798d33..1ffe5af 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/ExchangeLatchManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/ExchangeLatchManager.java
@@ -231,7 +231,7 @@ public class ExchangeLatchManager {
Collection<ClusterNode> histNodes = discovery.topology(topVer.topologyVersion());
if (histNodes != null)
- return histNodes.stream().filter(n -> !CU.clientNode(n) && !n.isDaemon() && discovery.alive(n))
+ return histNodes.stream().filter(n -> !n.isClient() && !n.isDaemon() && discovery.alive(n))
.collect(Collectors.toList());
else
throw new IgniteException("Topology " + topVer + " not found in discovery history "
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index 5b82333..bf2c729 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@ -362,7 +362,7 @@ public class IgniteTxHandler {
if (req.firstClientRequest()) {
assert req.concurrency() == OPTIMISTIC : req;
- assert CU.clientNode(nearNode) : nearNode;
+ assert nearNode.isClient() : nearNode;
top = firstEntry.context().topology();
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
index e8c27d2..bad0186 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
@@ -519,7 +519,7 @@ public abstract class IgniteSpiAdapter implements IgniteSpi {
if (!enabled)
return;
- if (!checkClient && (CU.clientNode(getLocalNode()) || CU.clientNode(node)))
+ if (!checkClient && (getLocalNode().isClient() || node.isClient()))
return;
String clsAttr = createSpiAttributeName(IgniteNodeAttributes.ATTR_SPI_CLASS);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 6617568..77e85c1 100755
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -3513,7 +3513,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
if (!commErrResolve && enableForcibleNodeKill) {
if (ctx.node(node.id()) != null
- && (CU.clientNode(node) || !CU.clientNode(getLocalNode())) &&
+ && (node.isClient() || !getLocalNode().isClient()) &&
connectionError(errs)) {
String msg = "TcpCommunicationSpi failed to establish connection to node, node will be dropped from " +
"cluster [" + "rmtNode=" + node + ']';
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 15b941f..4ac27f6 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -577,7 +577,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (log.isInfoEnabled())
log.info("Finished node ping [nodeId=" + nodeId + ", res=" + res + ", time=" + (end - start) + "ms]");
- if (!res && !node.isClient() && nodeAlive(nodeId)) {
+ if (!res && node.clientRouterNodeId() == null && nodeAlive(nodeId)) {
LT.warn(log, "Failed to ping node (status check will be initiated): " + nodeId);
msgWorker.addMessage(new TcpDiscoveryStatusCheckMessage(locNode, node.id()));
@@ -600,7 +600,7 @@ class ServerImpl extends TcpDiscoveryImpl {
UUID clientNodeId = null;
- if (node.isClient()) {
+ if (node.clientRouterNodeId() != null) {
clientNodeId = node.id();
node = ring.node(node.clientRouterNodeId());
@@ -1985,7 +1985,7 @@ class ServerImpl extends TcpDiscoveryImpl {
ring.allNodes(),
new C1<TcpDiscoveryNode, Collection<InetSocketAddress>>() {
@Override public Collection<InetSocketAddress> apply(TcpDiscoveryNode node) {
- return !node.isClient() ? spi.getNodeAddresses(node) :
+ return node.clientRouterNodeId() == null ? spi.getNodeAddresses(node) :
Collections.<InetSocketAddress>emptyList();
}
}
@@ -2174,7 +2174,7 @@ class ServerImpl extends TcpDiscoveryImpl {
TcpDiscoveryNode node = addedMsg.node();
- if (node.isClient() && !msgs.contains(msg)) {
+ if (node.clientRouterNodeId() != null && !msgs.contains(msg)) {
Collection<TcpDiscoveryNode> allNodes = ring.allNodes();
Collection<TcpDiscoveryNode> top = new ArrayList<>(allNodes.size());
@@ -2263,7 +2263,7 @@ class ServerImpl extends TcpDiscoveryImpl {
@Nullable Collection<TcpDiscoveryAbstractMessage> messages(@Nullable IgniteUuid lastMsgId,
TcpDiscoveryNode node)
{
- assert node != null && node.isClient() : node;
+ assert node != null && node.clientRouterNodeId() != null : node;
if (lastMsgId == null) {
// Client connection failed before it received TcpDiscoveryNodeAddedMessage.
@@ -3714,7 +3714,7 @@ class ServerImpl extends TcpDiscoveryImpl {
authFailedMsg = "Authentication subject is not serializable";
}
- else if (!node.isClient() &&
+ else if (node.clientRouterNodeId() == null &&
!subj.systemOperationAllowed(SecurityPermission.JOIN_AS_SERVER))
authFailedMsg = "Node is not authorised to join as a server node";
@@ -4123,13 +4123,13 @@ class ServerImpl extends TcpDiscoveryImpl {
*/
private void trySendMessageDirectly(TcpDiscoveryNode node, TcpDiscoveryAbstractMessage msg)
throws IgniteSpiException {
- if (node.isClient()) {
+ if (node.clientRouterNodeId() != null) {
TcpDiscoveryNode routerNode = ring.node(node.clientRouterNodeId());
if (routerNode == null)
throw new IgniteSpiException("Router node for client does not exist: " + node);
- if (routerNode.isClient())
+ if (routerNode.clientRouterNodeId() != null)
throw new IgniteSpiException("Router node is a client node: " + node);
if (routerNode.id().equals(getLocalNodeId())) {
@@ -4211,7 +4211,7 @@ class ServerImpl extends TcpDiscoveryImpl {
TcpDiscoveryNodeAddFinishedMessage addFinishMsg = new TcpDiscoveryNodeAddFinishedMessage(locNodeId,
node.id());
- if (node.isClient()) {
+ if (node.clientRouterNodeId() != null) {
addFinishMsg.clientDiscoData(msg.gridDiscoveryData());
addFinishMsg.clientNodeAttributes(node.attributes());
@@ -4600,7 +4600,7 @@ class ServerImpl extends TcpDiscoveryImpl {
notifyDiscovery(EVT_NODE_JOINED, topVer, node);
try {
- if (spi.ipFinder.isShared() && locNodeCoord && !node.isClient())
+ if (spi.ipFinder.isShared() && locNodeCoord && node.clientRouterNodeId() == null)
spi.ipFinder.registerAddresses(node.socketAddresses());
}
catch (IgniteSpiException e) {
@@ -6546,7 +6546,7 @@ class ServerImpl extends TcpDiscoveryImpl {
TcpDiscoveryNode node = ring.node(nodeId);
- assert node == null || node.isClient();
+ assert node == null || node.clientRouterNodeId() != null;
if (node != null) {
node.clientRouterNodeId(msg.routerNodeId());
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index c81c482..1c4bf54 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -522,7 +522,9 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements IgniteDiscovery
* of {@link IgniteConfiguration#isClientMode()}
*
* @return forceServerMode flag.
+ * @deprecated Will be removed at 3.0.
*/
+ @Deprecated
public boolean isForceServerMode() {
return forceSrvMode;
}
@@ -535,8 +537,10 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements IgniteDiscovery
*
* @param forceSrvMode forceServerMode flag.
* @return {@code this} for chaining.
+ * @deprecated Will be removed at 3.0.
*/
@IgniteSpiConfiguration(optional = true)
+ @Deprecated
public TcpDiscoverySpi setForceServerMode(boolean forceSrvMode) {
this.forceSrvMode = forceSrvMode;
@@ -1985,9 +1989,9 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements IgniteDiscovery
DiscoveryDataBag dataBag;
if (dataPacket.joiningNodeId().equals(locNode.id()))
- dataBag = dataPacket.unmarshalGridData(marshaller(), clsLdr, locNode.isClient(), log);
+ dataBag = dataPacket.unmarshalGridData(marshaller(), clsLdr, locNode.clientRouterNodeId() != null, log);
else
- dataBag = dataPacket.unmarshalJoiningNodeData(marshaller(), clsLdr, locNode.isClient(), log);
+ dataBag = dataPacket.unmarshalJoiningNodeData(marshaller(), clsLdr, locNode.clientRouterNodeId() != null, log);
exchange.onExchange(dataBag);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
index 55fe4e6..6c7d8e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
@@ -40,7 +40,6 @@ import org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
@@ -467,7 +466,15 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Ignite
/** {@inheritDoc} */
@Override public boolean isClient() {
- return clientRouterNodeId != null;
+ if (!cacheCliInit) {
+ Boolean clientModeAttr = ((ClusterNode) this).attribute(IgniteNodeAttributes.ATTR_CLIENT_MODE);
+
+ cacheCli = clientModeAttr != null && clientModeAttr;
+
+ cacheCliInit = true;
+ }
+
+ return cacheCli;
}
/**
@@ -529,17 +536,6 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Ignite
}
/** {@inheritDoc} */
- public boolean isCacheClient() {
- if (!cacheCliInit) {
- cacheCli = CU.clientNodeDirect(this);
-
- cacheCliInit = true;
- }
-
- return cacheCli;
- }
-
- /** {@inheritDoc} */
@Override public int compareTo(@Nullable TcpDiscoveryNode node) {
if (node == null)
return 1;
@@ -627,7 +623,7 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Ignite
ver = (IgniteProductVersion)in.readObject();
clientRouterNodeId = U.readUuid(in);
- if (isClient())
+ if (clientRouterNodeId() != null)
consistentId = consistentIdAttr != null ? consistentIdAttr : id;
else
consistentId = consistentIdAttr != null ? consistentIdAttr : U.consistentId(addrs, discPort);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNodesRing.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNodesRing.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNodesRing.java
index 7fc394b..3a8ded7 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNodesRing.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNodesRing.java
@@ -60,7 +60,9 @@ public class TcpDiscoveryNodesRing {
/** Client nodes filter. */
private static final PN CLIENT_NODES = new PN() {
@Override public boolean apply(ClusterNode node) {
- return node.isClient();
+ assert node instanceof TcpDiscoveryNode : node;
+
+ return ((TcpDiscoveryNode) node).clientRouterNodeId() != null;
}
};
@@ -199,7 +201,7 @@ public class TcpDiscoveryNodesRing {
return false;
for (TcpDiscoveryNode node : nodes)
- if (!node.isClient() && !node.id().equals(locNode.id()))
+ if (node.clientRouterNodeId() == null && !node.id().equals(locNode.id()))
return true;
return false;
@@ -642,7 +644,7 @@ public class TcpDiscoveryNodesRing {
return F.view(nodes, new P1<TcpDiscoveryNode>() {
@Override public boolean apply(TcpDiscoveryNode node) {
- return !node.isClient() && (excludedEmpty || !excluded.contains(node));
+ return node.clientRouterNodeId() == null && (excludedEmpty || !excluded.contains(node));
}
});
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
index 6ec8046..69f95e8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
@@ -123,11 +123,15 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
Ignite g = startGrid(i);
assert "true".equals(g.cluster().localNode().attribute(PREFER_IPV4));
+
+ checkIsClientFlag((IgniteEx) g);
}
System.setProperty(PREFER_IPV4, "false");
- startGrid(2);
+ IgniteEx g = startGrid(2);
+
+ checkIsClientFlag(g);
}
/**
@@ -154,12 +158,18 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
try {
System.setProperty(IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID, first);
- startGrid(0);
+ {
+ IgniteEx g = startGrid(0);
+
+ checkIsClientFlag(g);
+ }
System.setProperty(IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID, second);
try {
- startGrid(1);
+ IgniteEx g = startGrid(1);
+
+ checkIsClientFlag(g);
if (fail)
fail("Node should not join");
@@ -206,7 +216,11 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
else
System.clearProperty(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2);
- startGrid(0);
+ {
+ IgniteEx g = startGrid(0);
+
+ checkIsClientFlag(g);
+ }
if (second != null)
System.setProperty(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2, second);
@@ -214,7 +228,9 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
System.clearProperty(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2);
try {
- startGrid(1);
+ IgniteEx g = startGrid(1);
+
+ checkIsClientFlag(g);
if (fail)
fail("Node should not join");
@@ -317,6 +333,8 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
IgniteEx ignite = startGrid(0);
+ checkIsClientFlag(ignite);
+
// Ignore if disabled security plugin used.
if (IGNITE_SECURITY_COMPATIBILITY_MODE.equals(prop) && !ignite.context().security().enabled())
return;
@@ -327,7 +345,9 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
System.clearProperty(prop);
try {
- startGrid(1);
+ IgniteEx g = startGrid(1);
+
+ checkIsClientFlag(g);
if (fail)
fail("Node must not join");
@@ -351,7 +371,9 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
* @throws Exception If failed.
*/
public void testDifferentDeploymentModes() throws Exception {
- startGrid(0);
+ IgniteEx g = startGrid(0);
+
+ checkIsClientFlag(g);
mode = CONTINUOUS;
@@ -370,7 +392,9 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
* @throws Exception If failed.
*/
public void testDifferentPeerClassLoadingEnabledFlag() throws Exception {
- startGrid(0);
+ IgniteEx g = startGrid(0);
+
+ checkIsClientFlag(g);
p2pEnabled = true;
@@ -398,11 +422,24 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
Ignite g = startGrid(i);
assert val.equals(g.cluster().localNode().attribute(PREFER_IPV4));
+
+ checkIsClientFlag((IgniteEx) g);
}
}
/**
*
+ * @param g
+ */
+ protected void checkIsClientFlag(IgniteEx g) {
+ boolean isClientDiscovery = g.context().discovery().localNode().isClient();
+ boolean isClientConfig = g.configuration().isClientMode() == null ? false : g.configuration().isClientMode();
+
+ assertEquals(isClientConfig, isClientDiscovery);
+ }
+
+ /**
+ *
*/
public static class RegularDiscovery extends GridDiscoveryManagerAttributesSelfTest {
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java
index 9860199..e2a4a08 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java
@@ -98,7 +98,7 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
int c = 0;
for (ClusterNode node : nodes) {
- if (!CU.clientNode(node))
+ if (!node.isClient())
c++;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
index 0cbe67a..db4a0da 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
@@ -2843,7 +2843,7 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest {
IgnitePredicate<ClusterNode> filter = cacheDesc.cacheConfiguration().getNodeFilter();
for (ClusterNode n : allNodes) {
- if (!CU.clientNode(n) && (filter == null || filter.apply(n)))
+ if (!n.isClient() && (filter == null || filter.apply(n)))
affNodes.add(n);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index e70dd42..cff2525 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -2982,7 +2982,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
AffinityTopologyVersion initVer = fut.initialVersion();
- return initVer.compareTo(readyVer) > 0 && !CU.clientNode(fut.firstEvent().node());
+ return initVer.compareTo(readyVer) > 0 && !fut.firstEvent().node().isClient();
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/2fc90731/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClusterNode.java
----------------------------------------------------------------------
diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClusterNode.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClusterNode.java
index 1c2a589..f90bc01 100644
--- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClusterNode.java
+++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClusterNode.java
@@ -169,11 +169,6 @@ public class ZookeeperClusterNode implements IgniteClusterNode, Externalizable,
}
/** {@inheritDoc} */
- @Override public boolean isCacheClient() {
- return isClient();
- }
-
- /** {@inheritDoc} */
@Nullable @Override public <T> T attribute(String name) {
// Even though discovery SPI removes this attribute after authentication, keep this check for safety.
if (IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS.equals(name))
[15/19] ignite git commit: IGNITE-9263 replace weird commit code. -
Fixes #4542.
Posted by av...@apache.org.
IGNITE-9263 replace weird commit code. - Fixes #4542.
Signed-off-by: Dmitriy Pavlov <dp...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d57c3d6e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d57c3d6e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d57c3d6e
Branch: refs/heads/ignite-9053
Commit: d57c3d6e04603693d93c7fce0b5d44f5de0950c9
Parents: 1691af8
Author: Evgeny Stanilovskiy <es...@gridgain.com>
Authored: Wed Aug 15 18:42:13 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Wed Aug 15 18:42:13 2018 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/processors/cache/GridCacheAdapter.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d57c3d6e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index eeed4fa..4a64de6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -171,7 +171,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
IgniteSystemProperties.IGNITE_CACHE_START_SIZE, 4096);
/** Size of keys batch to removeAll. */
- // TODO GG-11231 (workaround for GG-11231).
private static final int REMOVE_ALL_KEYS_BATCH = 10000;
/** Maximum number of retries when topology changes. */
[03/19] ignite git commit: IGNITE-9249 Configured node join timeout
for all tests - Fixes #4515.
Posted by av...@apache.org.
IGNITE-9249 Configured node join timeout for all tests - Fixes #4515.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a1456032
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a1456032
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a1456032
Branch: refs/heads/ignite-9053
Commit: a1456032964e10fc7ac9967f8f0dca54e24beb5e
Parents: 237a99e
Author: Ilya Lantukh <il...@gridgain.com>
Authored: Tue Aug 14 16:07:55 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Aug 14 16:07:55 2018 +0300
----------------------------------------------------------------------
.../org/apache/ignite/testframework/junits/GridAbstractTest.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1456032/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 45833fb..341f7be 100755
--- 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
@@ -1528,6 +1528,9 @@ public abstract class GridAbstractTest extends TestCase {
}
}
+ if (cfg.getDiscoverySpi() instanceof TcpDiscoverySpi)
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setJoinTimeout(getTestTimeout());
+
if (isMultiJvm())
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(LOCAL_IP_FINDER);
[14/19] ignite git commit: IGNITE-6284 Add
IgniteCompute.withTaskNoResultCache() with similar effect as
@ComputeTaskNoResultCache - Fixes #4075.
Posted by av...@apache.org.
IGNITE-6284 Add IgniteCompute.withTaskNoResultCache() with similar effect as @ComputeTaskNoResultCache - Fixes #4075.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1691af8d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1691af8d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1691af8d
Branch: refs/heads/ignite-9053
Commit: 1691af8dd165c049258673e14771de36c2feaaec
Parents: 2e9ca8f
Author: EdShangGG <es...@gridgain.com>
Authored: Wed Aug 15 18:14:55 2018 +0300
Committer: Dmitriy Pavlov <dp...@apache.org>
Committed: Wed Aug 15 18:14:55 2018 +0300
----------------------------------------------------------------------
.../mapper/GridContinuousMapperLoadTest1.java | 51 ------
.../mapper/GridContinuousMapperLoadTest2.java | 92 -----------
.../mapper/GridContinuousMapperTask1.java | 157 -------------------
.../mapper/GridContinuousMapperTask2.java | 93 -----------
.../ignite/loadtests/mapper/TestObject.java | 57 -------
5 files changed, 450 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1691af8d/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperLoadTest1.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperLoadTest1.java b/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperLoadTest1.java
deleted file mode 100644
index e7f63dd..0000000
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperLoadTest1.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.loadtests.mapper;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.X;
-
-/**
- * Continuous mapper load test.
- */
-public class GridContinuousMapperLoadTest1 {
- /**
- * Main method.
- *
- * @param args Parameters.
- */
- public static void main(String[] args) {
- try (Ignite g = G.start("examples/config/example-cache.xml")) {
- int max = 30000;
-
- IgniteDataStreamer<Integer, TestObject> ldr = g.dataStreamer("replicated");
-
- for (int i = 0; i < max; i++)
- ldr.addData(i, new TestObject(i, "Test object: " + i));
-
- // Wait for loader to complete.
- ldr.close(false);
-
- X.println("Populated replicated cache.");
-
- g.compute().execute(new GridContinuousMapperTask1(), max);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1691af8d/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperLoadTest2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperLoadTest2.java b/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperLoadTest2.java
deleted file mode 100644
index 68c36ce..0000000
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperLoadTest2.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.loadtests.mapper;
-
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.X;
-
-/**
- * Continuous mapper load test.
- */
-public class GridContinuousMapperLoadTest2 {
- /**
- * Main method.
- *
- * @param args Parameters.
- * @throws Exception If failed.
- */
- public static void main(String[] args) throws Exception {
- final AtomicInteger jobIdGen = new AtomicInteger();
- final AtomicInteger sentJobs = new AtomicInteger();
-
- final LinkedBlockingQueue<Integer> queue = new LinkedBlockingQueue<>(10);
-
- /** Worker thread. */
- Thread t = new Thread("mapper-worker") {
- @Override public void run() {
- try {
- while (!Thread.currentThread().isInterrupted())
- queue.put(jobIdGen.incrementAndGet());
- }
- catch (InterruptedException ignore) {
- // No-op.
- }
- }
- };
-
- Ignite g = G.start("examples/config/example-cache.xml");
-
- try {
- int max = 20000;
-
- IgniteDataStreamer<Integer, TestObject> ldr = g.dataStreamer("replicated");
-
- for (int i = 0; i < max; i++)
- ldr.addData(i, new TestObject(i, "Test object: " + i));
-
- // Wait for loader to complete.
- ldr.close(false);
-
- X.println("Populated replicated cache.");
-
- t.start();
-
- while (sentJobs.get() < max) {
- int[] jobIds = new int[10];
-
- for (int i = 0; i < jobIds.length; i++)
- jobIds[i] = queue.take();
-
- sentJobs.addAndGet(10);
-
- g.compute().execute(new GridContinuousMapperTask2(), jobIds);
- }
- }
- finally {
- t.interrupt();
-
- t.join();
-
- G.stopAll(false);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1691af8d/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask1.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask1.java b/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask1.java
deleted file mode 100644
index 4577806..0000000
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask1.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.loadtests.mapper;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.compute.ComputeJob;
-import org.apache.ignite.compute.ComputeJobAdapter;
-import org.apache.ignite.compute.ComputeJobResult;
-import org.apache.ignite.compute.ComputeJobResultPolicy;
-import org.apache.ignite.compute.ComputeTaskAdapter;
-import org.apache.ignite.compute.ComputeTaskContinuousMapper;
-import org.apache.ignite.compute.ComputeTaskNoResultCache;
-import org.apache.ignite.internal.util.typedef.X;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.resources.TaskContinuousMapperResource;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Test task.
- */
-@SuppressWarnings("TransientFieldNotInitialized")
-@ComputeTaskNoResultCache
-public class GridContinuousMapperTask1 extends ComputeTaskAdapter<Integer, Integer> {
- /** Job ID generator. */
- private final transient AtomicInteger jobIdGen = new AtomicInteger();
-
- /** Mapper. */
- @TaskContinuousMapperResource
- private ComputeTaskContinuousMapper mapper;
-
- /** Grid. */
- @IgniteInstanceResource
- private Ignite g;
-
- /** Blocking queue. */
- private final transient LinkedBlockingQueue<Integer> queue = new LinkedBlockingQueue<>(10);
-
- /** Sent jobs count. */
- private final transient AtomicInteger sentJobs = new AtomicInteger();
-
- /** Maximum number of executions. */
- private transient int maxExecs;
-
- /** Worker thread. */
- private transient Thread t = new Thread("mapper-worker") {
- @Override public void run() {
- try {
- while (!Thread.currentThread().isInterrupted())
- queue.put(jobIdGen.getAndIncrement());
- }
- catch (InterruptedException ignore) {
- // No-op.
- }
- }
- };
-
- /**
- * Sends job to node.
- *
- * @param n Node.
- * @throws IgniteException If failed.
- */
- private void sendJob(ClusterNode n) {
- try {
- int jobId = queue.take();
-
- sentJobs.incrementAndGet();
-
- mapper.send(new ComputeJobAdapter(jobId) {
- @IgniteInstanceResource
- private Ignite g;
-
- @Override public Object execute() {
- Integer jobId = argument(0);
-
- X.println(">>> Received job for ID: " + jobId);
-
- return g.cache("replicated").localPeek(jobId, CachePeekMode.ONHEAP);
- }
- }, n);
- }
- catch (InterruptedException e) {
- throw new IgniteException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Integer arg) {
- maxExecs = arg;
-
- // Start worker thread.
- t.start();
-
- if (g.cluster().nodes().size() == 1)
- sendJob(g.cluster().localNode());
- else
- for (ClusterNode n : g.cluster().forRemotes().nodes())
- sendJob(n);
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) {
- if (res.getException() != null)
- throw new IgniteException(res.getException());
-
- TestObject o = res.getData();
-
- assert o != null;
-
- X.println("Received job result from node [resId=" + o.getId() + ", node=" + res.getNode().id() + ']');
-
- if (sentJobs.get() < maxExecs)
- sendJob(res.getNode());
-
- return ComputeJobResultPolicy.WAIT;
- }
-
- /** {@inheritDoc} */
- @Override public Integer reduce(List<ComputeJobResult> results) {
- X.println(">>> Reducing task...");
-
- t.interrupt();
-
- try {
- t.join();
- }
- catch (InterruptedException e) {
- throw new IgniteException(e);
- }
-
- return null;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1691af8d/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask2.java b/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask2.java
deleted file mode 100644
index 9a795c4..0000000
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask2.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.loadtests.mapper;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.compute.ComputeJob;
-import org.apache.ignite.compute.ComputeJobAdapter;
-import org.apache.ignite.compute.ComputeJobResult;
-import org.apache.ignite.compute.ComputeJobResultPolicy;
-import org.apache.ignite.compute.ComputeTaskAdapter;
-import org.apache.ignite.internal.util.typedef.X;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Test task.
- */
-public class GridContinuousMapperTask2 extends ComputeTaskAdapter<int[], Integer> {
- /** Grid. */
- @IgniteInstanceResource
- private Ignite g;
-
- /** {@inheritDoc} */
- @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable int[] jobIds) {
- Map<ComputeJob, ClusterNode> mappings = new HashMap<>(jobIds.length);
-
- Iterator<ClusterNode> nodeIter = g.cluster().forRemotes().nodes().iterator();
-
- for (int jobId : jobIds) {
- ComputeJob job = new ComputeJobAdapter(jobId) {
- @IgniteInstanceResource
- private Ignite g;
-
- @Override public Object execute() {
- Integer jobId = argument(0);
-
- X.println(">>> Received job for ID: " + jobId);
-
- return g.cache("replicated").localPeek(jobId, CachePeekMode.ONHEAP);
- }
- };
-
- // If only local node in the grid.
- if (g.cluster().nodes().size() == 1)
- mappings.put(job, g.cluster().localNode());
- else {
- ClusterNode n = nodeIter.hasNext() ? nodeIter.next() :
- (nodeIter = g.cluster().forRemotes().nodes().iterator()).next();
-
- mappings.put(job, n);
- }
- }
-
- return mappings;
- }
-
- /** {@inheritDoc} */
- @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) {
- TestObject o = res.getData();
-
- X.println("Received job result from node [resId=" + o.getId() + ", node=" + res.getNode().id() + ']');
-
- return super.result(res, rcvd);
- }
-
- /** {@inheritDoc} */
- @Override public Integer reduce(List<ComputeJobResult> results) {
- X.println(">>> Reducing task...");
-
- return null;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1691af8d/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/TestObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/TestObject.java b/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/TestObject.java
deleted file mode 100644
index 9a17e0e..0000000
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/TestObject.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.loadtests.mapper;
-
-import java.io.Serializable;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-
-/**
- * Test object.
- */
-public class TestObject implements Serializable {
- /** ID. */
- @QuerySqlField(index = true)
- private int id;
-
- /** Text. */
- @QuerySqlField
- private String txt;
-
- /**
- * @param id ID.
- * @param txt Text.
- */
- public TestObject(int id, String txt) {
- this.id = id;
- this.txt = txt;
- }
-
- /**
- * @return ID.
- */
- public int getId() {
- return id;
- }
-
- /**
- * @return Text.
- */
- public String getText() {
- return txt;
- }
-}
\ No newline at end of file