You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/08/28 14:49:19 UTC
[01/41] ignite git commit: IGNITE-1281 Fixed direct marshalling logic
for last-removed field. Closes #32
Repository: ignite
Updated Branches:
refs/heads/ignite-1093 4ddb96944 -> d89f1b0af
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
index 77bbe39..c0db018 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
@@ -55,6 +55,9 @@ public class GridCacheSqlQuery implements Message {
@GridDirectTransient
private LinkedHashMap<String, ?> cols;
+ /** Field kept for backward compatibility. */
+ private String alias;
+
/**
* For {@link Message}.
*/
@@ -149,7 +152,7 @@ public class GridCacheSqlQuery implements Message {
switch (writer.state()) {
case 0:
- if (!writer.writeString("alias", null))
+ if (!writer.writeString("alias", alias))
return false;
writer.incrementState();
@@ -180,7 +183,7 @@ public class GridCacheSqlQuery implements Message {
switch (reader.state()) {
case 0:
- reader.readString("alias");
+ alias = reader.readString("alias");
if (!reader.isLastRead())
return false;
@@ -205,7 +208,7 @@ public class GridCacheSqlQuery implements Message {
}
- return true;
+ return reader.afterMessageRead(GridCacheSqlQuery.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java
index 060afb9..02ec7ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java
@@ -279,7 +279,7 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
}
- return true;
+ return reader.afterMessageRead(CacheContinuousQueryEntry.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index e9070a5..e7a11d0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -987,7 +987,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
}
- return true;
+ return reader.afterMessageRead(IgniteTxEntry.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java
index f80f960..bbb7559 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java
@@ -167,7 +167,7 @@ public class IgniteTxKey implements Message {
}
- return true;
+ return reader.afterMessageRead(IgniteTxKey.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
index 0bd3d52..4c41e21 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
@@ -222,7 +222,7 @@ public class TxEntryValueHolder implements Message {
}
- return true;
+ return reader.afterMessageRead(TxEntryValueHolder.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
index 87fe976..86a9b1b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
@@ -307,7 +307,7 @@ public class GridCacheRawVersionedEntry<K, V> extends DataStreamerEntry implemen
assert key != null;
assert !(val != null && valBytes != null);
- return true;
+ return reader.afterMessageRead(GridCacheRawVersionedEntry.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java
index 8df54c8..a72c5c2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java
@@ -326,7 +326,7 @@ public class GridCacheVersion implements Message, Comparable<GridCacheVersion>,
}
- return true;
+ return reader.afterMessageRead(GridCacheVersion.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionEx.java
index 812d656..5e848d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionEx.java
@@ -137,7 +137,7 @@ public class GridCacheVersionEx extends GridCacheVersion {
}
- return true;
+ return reader.afterMessageRead(GridCacheVersionEx.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java
index dc015b7..23bc179 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java
@@ -126,7 +126,7 @@ public class GridClockDeltaSnapshotMessage implements Message {
}
- return true;
+ return reader.afterMessageRead(GridClockDeltaSnapshotMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java
index ffb02f7..941a1fa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java
@@ -165,7 +165,7 @@ public class GridClockDeltaVersion implements Message, Comparable<GridClockDelta
}
- return true;
+ return reader.afterMessageRead(GridClockDeltaVersion.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java
index fe50fd8..e521a0c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java
@@ -248,7 +248,7 @@ public class GridContinuousMessage implements Message {
}
- return true;
+ return reader.afterMessageRead(GridContinuousMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerEntry.java
index 88fda8f..7eadb04 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerEntry.java
@@ -150,7 +150,7 @@ public class DataStreamerEntry implements Map.Entry<KeyCacheObject, CacheObject>
}
- return true;
+ return reader.afterMessageRead(DataStreamerEntry.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java
index 0d24ee0..fa08b7b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java
@@ -466,7 +466,7 @@ public class DataStreamerRequest implements Message {
}
- return true;
+ return reader.afterMessageRead(DataStreamerRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerResponse.java
index 8aee0d5..e753e32 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerResponse.java
@@ -151,7 +151,7 @@ public class DataStreamerResponse implements Message {
}
- return true;
+ return reader.afterMessageRead(DataStreamerResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
index f52c6de..b551b7b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
@@ -177,7 +177,7 @@ public class IgfsAckMessage extends IgfsCommunicationMessage {
}
- return true;
+ return reader.afterMessageRead(IgfsAckMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java
index b86eb29..efb84d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java
@@ -240,7 +240,7 @@ public final class IgfsBlockKey implements Message, Externalizable, Comparable<I
}
- return true;
+ return reader.afterMessageRead(IgfsBlockKey.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlocksMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlocksMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlocksMessage.java
index fbf2796..120745c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlocksMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlocksMessage.java
@@ -158,7 +158,7 @@ public class IgfsBlocksMessage extends IgfsCommunicationMessage {
}
- return true;
+ return reader.afterMessageRead(IgfsBlocksMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java
index 309daf1..c2c24ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java
@@ -69,7 +69,7 @@ public abstract class IgfsCommunicationMessage implements Message {
if (!reader.beforeMessageRead())
return false;
- return true;
+ return reader.afterMessageRead(IgfsCommunicationMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
index 2196525..8656745 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
@@ -167,7 +167,7 @@ public class IgfsDeleteMessage extends IgfsCommunicationMessage {
}
- return true;
+ return reader.afterMessageRead(IgfsDeleteMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
index 9736f10..d18ea82 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
@@ -56,6 +56,9 @@ public class IgfsFileAffinityRange implements Message, Externalizable {
/** Range end offset (endOff + 1 divisible by block size). */
private long endOff;
+ /** Field kept for backward compatibility. */
+ private boolean done;
+
/**
* Empty constructor required by {@link Externalizable}.
*/
@@ -265,7 +268,7 @@ public class IgfsFileAffinityRange implements Message, Externalizable {
case 1:
// The field 'done' was removed, but its writing preserved for compatibility reasons.
- if (!writer.writeBoolean("done", false))
+ if (!writer.writeBoolean("done", done))
return false;
writer.incrementState();
@@ -311,7 +314,7 @@ public class IgfsFileAffinityRange implements Message, Externalizable {
case 1:
// field 'done' was removed, but reading preserved for compatibility reasons.
- reader.readBoolean("done");
+ done = reader.readBoolean("done");
if (!reader.isLastRead())
return false;
@@ -344,7 +347,7 @@ public class IgfsFileAffinityRange implements Message, Externalizable {
}
- return true;
+ return reader.afterMessageRead(IgfsFileAffinityRange.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerRequest.java
index 9223009..cf657e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerRequest.java
@@ -139,7 +139,7 @@ public class IgfsFragmentizerRequest extends IgfsCommunicationMessage {
}
- return true;
+ return reader.afterMessageRead(IgfsFragmentizerRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerResponse.java
index 9ba6920..6dd7534 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerResponse.java
@@ -101,7 +101,7 @@ public class IgfsFragmentizerResponse extends IgfsCommunicationMessage {
}
- return true;
+ return reader.afterMessageRead(IgfsFragmentizerResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSyncMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSyncMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSyncMessage.java
index 0fb683c..60b56ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSyncMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSyncMessage.java
@@ -132,7 +132,7 @@ public class IgfsSyncMessage extends IgfsCommunicationMessage {
}
- return true;
+ return reader.afterMessageRead(IgfsSyncMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryCancelRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryCancelRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryCancelRequest.java
index c1daa6e..e679ed4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryCancelRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryCancelRequest.java
@@ -99,7 +99,7 @@ public class GridQueryCancelRequest implements Message {
}
- return true;
+ return reader.afterMessageRead(GridQueryCancelRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java
index a959193..6fd607c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java
@@ -125,7 +125,7 @@ public class GridQueryFailResponse implements Message {
}
- return true;
+ return reader.afterMessageRead(GridQueryFailResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageRequest.java
index 474cd55..8e95ab8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageRequest.java
@@ -152,7 +152,7 @@ public class GridQueryNextPageRequest implements Message {
}
- return true;
+ return reader.afterMessageRead(GridQueryNextPageRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java
index 0f62ae9..d06e118 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java
@@ -29,6 +29,7 @@ import java.util.*;
/**
* Next page response.
*/
+@IgniteCodeGeneratingFail
public class GridQueryNextPageResponse implements Message {
/** */
private static final long serialVersionUID = 0L;
@@ -268,7 +269,7 @@ public class GridQueryNextPageResponse implements Message {
}
- return true;
+ return reader.afterMessageRead(GridQueryNextPageResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryRequest.java
index 47d1f44..2b04c52 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryRequest.java
@@ -31,6 +31,7 @@ import java.util.*;
/**
* Query request.
*/
+@IgniteCodeGeneratingFail
public class GridQueryRequest implements Message {
/** */
private static final long serialVersionUID = 0L;
@@ -222,6 +223,7 @@ public class GridQueryRequest implements Message {
return false;
writer.incrementState();
+
}
return true;
@@ -290,9 +292,10 @@ public class GridQueryRequest implements Message {
return false;
reader.incrementState();
+
}
- return true;
+ return reader.afterMessageRead(GridQueryRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java
index 3802222..951b1e0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java
@@ -153,7 +153,7 @@ public class GridTaskResultRequest implements Message {
}
- return true;
+ return reader.afterMessageRead(GridTaskResultRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java
index 66421a1..d29c525 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java
@@ -199,7 +199,7 @@ public class GridTaskResultResponse implements Message {
}
- return true;
+ return reader.afterMessageRead(GridTaskResultResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java
index de5dd47..83939c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java
@@ -461,7 +461,7 @@ public class GridByteArrayList implements Message, Externalizable {
}
- return true;
+ return reader.afterMessageRead(GridByteArrayList.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java
index f056f37..1711f03 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java
@@ -559,7 +559,7 @@ public class GridLongList implements Message, Externalizable {
}
- return true;
+ return reader.afterMessageRead(GridLongList.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
index d632cac..939ad0a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
@@ -62,7 +62,7 @@ public class GridDirectParser implements GridNioParser {
if (msg == null && buf.hasRemaining()) {
msg = msgFactory.create(buf.get());
- ses.addMeta(READER_META_KEY, reader = formatter.reader(msgFactory));
+ ses.addMeta(READER_META_KEY, reader = formatter.reader(msgFactory, msg.getClass()));
}
boolean finished = false;
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFormatter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFormatter.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFormatter.java
index 6176561..85f6045 100644
--- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFormatter.java
+++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFormatter.java
@@ -41,7 +41,8 @@ public interface MessageFormatter extends Extension {
* Creates new message reader instance.
*
* @param factory Message factory.
+ * @param msgCls Message class to read.
* @return Message reader.
*/
- public MessageReader reader(MessageFactory factory);
+ public MessageReader reader(MessageFactory factory, Class<? extends Message> msgCls);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java
index 833e851..11ea97d 100644
--- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java
@@ -35,9 +35,22 @@ public interface MessageReader {
*/
public void setBuffer(ByteBuffer buf);
+ /**
+ * Callback that must be invoked by a message implementation before message body started decoding.
+ *
+ * @return {@code True} if reading can proceed, {@code false} otherwise.
+ */
public boolean beforeMessageRead();
/**
+ * Callback that must be invoked by a message implementation after message body finished decoding.
+ *
+ * @param msgCls Message class finishing read stage.
+ * @return {@code True} if reading can proceed, {@code false} otherwise.
+ */
+ public boolean afterMessageRead(Class<? extends Message> msgCls);
+
+ /**
* Reads {@code byte} value.
*
* @param name Field name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/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 f809d82..0d08171 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
@@ -684,7 +684,7 @@ public abstract class IgniteSpiAdapter implements IgniteSpi, IgniteSpiManagement
throw new IgniteException("Failed to write message, node is not started.");
}
- @Override public MessageReader reader(MessageFactory factory) {
+ @Override public MessageReader reader(MessageFactory factory, Class<? extends Message> msgCls) {
throw new IgniteException("Failed to read message, node is not started.");
}
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java
index 9d9c222..8b95149 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java
@@ -95,7 +95,7 @@ public class JobStealingRequest implements Message {
}
- return true;
+ return reader.afterMessageRead(JobStealingRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/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 b706edf..4022cf6 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -1510,13 +1510,13 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
return impl.writer();
}
- @Override public MessageReader reader(MessageFactory factory) {
+ @Override public MessageReader reader(MessageFactory factory, Class<? extends Message> msgCls) {
if (impl == null)
impl = getSpiContext().messageFormatter();
assert impl != null;
- return impl.reader(factory);
+ return impl.reader(factory, msgCls);
}
};
@@ -2845,13 +2845,13 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
return impl.writer();
}
- @Override public MessageReader reader(MessageFactory factory) {
+ @Override public MessageReader reader(MessageFactory factory, Class<? extends Message> msgCls) {
if (impl == null)
impl = getSpiContext().messageFormatter();
assert impl != null;
- return impl.reader(factory);
+ return impl.reader(factory, msgCls);
}
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
index 08268af..038af02 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
@@ -474,7 +474,7 @@ public class GridSpiTestContext implements IgniteSpiContext {
return new DirectMessageWriter();
}
- @Override public MessageReader reader(MessageFactory factory) {
+ @Override public MessageReader reader(MessageFactory factory, Class<? extends Message> msgCls) {
return new DirectMessageReader(factory, this);
}
};
[41/41] ignite git commit: ignite-1093
Posted by sb...@apache.org.
ignite-1093
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d89f1b0a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d89f1b0a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d89f1b0a
Branch: refs/heads/ignite-1093
Commit: d89f1b0af5ed23bc0f6e68fa9f0d377e6be41fcc
Parents: a7ddb62
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Aug 28 15:37:14 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Aug 28 15:37:14 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/IgniteKernal.java | 1 +
.../ignite/internal/IgniteNodeAttributes.java | 3 +
.../GridCachePartitionExchangeManager.java | 3 +-
.../dht/preloader/GridDhtPartitionDemander.java | 709 ++++++++++++++++---
.../dht/preloader/GridDhtPartitionSupplier.java | 290 +++++++-
.../dht/preloader/GridDhtPreloader.java | 10 +-
...ridCacheMassiveRebalancingAsyncSelfTest.java | 91 ---
...GridCacheMassiveRebalancingSyncSelfTest.java | 392 ----------
.../GridCacheRebalancingAsyncSelfTest.java | 85 +++
.../GridCacheRebalancingSyncSelfTest.java | 269 +++++++
10 files changed, 1267 insertions(+), 586 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d89f1b0a/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 1db73bf..03110c9 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
@@ -1170,6 +1170,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
add(ATTR_MARSHALLER, cfg.getMarshaller().getClass().getName());
add(ATTR_USER_NAME, System.getProperty("user.name"));
add(ATTR_GRID_NAME, gridName);
+ add(REBALANCING_VERSION, 1);
add(ATTR_PEER_CLASSLOADING, cfg.isPeerClassLoadingEnabled());
add(ATTR_DEPLOYMENT_MODE, cfg.getDeploymentMode());
http://git-wip-us.apache.org/repos/asf/ignite/blob/d89f1b0a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
index 10b8df0..c04c69b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
@@ -135,6 +135,9 @@ public final class IgniteNodeAttributes {
/** Node consistent id. */
public static final String ATTR_NODE_CONSISTENT_ID = ATTR_PREFIX + ".consistent.id";
+ /** Rebalancing version id. */
+ public static final String REBALANCING_VERSION = ATTR_PREFIX + ".rebalancing.version";
+
/**
* Enforces singleton.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/d89f1b0a/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 003e8db..bf77d1e 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
@@ -282,7 +282,8 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
cctx.io().addOrderedHandler(demanderTopic(cnt), new CI2<UUID, GridDhtPartitionSupplyMessageV2>() {
@Override public void apply(final UUID id, final GridDhtPartitionSupplyMessageV2 m) {
- enterBusy();
+ if (!enterBusy())
+ return;
try {
http://git-wip-us.apache.org/repos/asf/ignite/blob/d89f1b0a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 0474bf9..0aa30b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -36,12 +36,17 @@ import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.thread.*;
+import org.jetbrains.annotations.*;
import org.jsr166.*;
import java.util.*;
+import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
+import java.util.concurrent.locks.*;
+import static java.util.concurrent.TimeUnit.*;
import static org.apache.ignite.events.EventType.*;
+import static org.apache.ignite.internal.GridTopic.*;
import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.*;
import static org.apache.ignite.internal.processors.dr.GridDrType.*;
@@ -69,13 +74,17 @@ public class GridDhtPartitionDemander {
/** Last exchange future. */
private volatile GridDhtPartitionsExchangeFuture lastExchangeFut;
+ /** Demand lock. */
+ private final ReadWriteLock demandLock;
+
/**
* @param cctx Cache context.
*/
- public GridDhtPartitionDemander(GridCacheContext<?, ?> cctx) {
+ public GridDhtPartitionDemander(GridCacheContext<?, ?> cctx, ReadWriteLock demandLock) {
assert cctx != null;
this.cctx = cctx;
+ this.demandLock = demandLock;
log = cctx.logger(getClass());
@@ -199,7 +208,13 @@ public class GridDhtPartitionDemander {
else
fut.init(assigns);
- if (assigns.isEmpty() || topologyChanged(topVer)) {
+ if (assigns.isEmpty()) {
+ fut.onDone();
+
+ return;
+ }
+
+ if (topologyChanged(topVer)) {
fut.onCancel();
return;
@@ -225,13 +240,17 @@ public class GridDhtPartitionDemander {
}
}
catch (IgniteInterruptedCheckedException ignored) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Failed to wait for marshaller cache preload future (grid is stopping): " +
"[cacheName=" + cctx.name() + ']');
+ cSF.onCancel();
- return;
+ return;
+ }
}
catch (IgniteCheckedException e) {
+ cSF.onCancel();
+
throw new Error("Ordered preload future should never fail: " + e.getMessage(), e);
}
}
@@ -257,18 +276,22 @@ public class GridDhtPartitionDemander {
}
}
catch (IgniteInterruptedCheckedException ignored) {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Failed to wait for ordered rebalance future (grid is stopping): " +
"[cacheName=" + cctx.name() + ", rebalanceOrder=" + rebalanceOrder + ']');
+ cSF.onCancel();
- return;
+ return;
+ }
}
catch (IgniteCheckedException e) {
+ cSF.onCancel();
+
throw new Error("Ordered rebalance future should never fail: " + e.getMessage(), e);
}
}
- requestPartitions(assigns, topVer, cSF);
+ requestPartitions(cSF);
}
}).start();
@@ -300,12 +323,13 @@ public class GridDhtPartitionDemander {
}
/**
- * @param assigns Assigns.
+ * @param fut Future.
*/
- private void requestPartitions(
- final GridDhtPreloaderAssignments assigns,
- AffinityTopologyVersion topVer,
- SyncFuture fut) {
+ private void requestPartitions(SyncFuture fut) {
+ final GridDhtPreloaderAssignments assigns = fut.assigns;
+
+ AffinityTopologyVersion topVer = fut.topologyVersion();
+
for (Map.Entry<ClusterNode, GridDhtPartitionDemandMessage> e : assigns.entrySet()) {
if (topologyChanged(topVer)) {
fut.onCancel();
@@ -313,73 +337,77 @@ public class GridDhtPartitionDemander {
return;
}
+ final ClusterNode node = e.getKey();
+
GridDhtPartitionDemandMessage d = e.getValue();
d.timeout(cctx.config().getRebalanceTimeout());
d.workerId(0);//old api support.
- final ClusterNode node = e.getKey();
+ final CacheConfiguration cfg = cctx.config();
final long start = U.currentTimeMillis();
- final CacheConfiguration cfg = cctx.config();
+ fut.logStart(node.id(), start);
- final AffinityTopologyVersion top = d.topologyVersion();
+ U.log(log, "Starting rebalancing [cache=" + cctx.name() + ", mode=" + cfg.getRebalanceMode() +
+ ", from node=" + node.id() + ", partitions count=" + d.partitions().size() + ", topology=" + d.topologyVersion() + "]");
- if (cfg.getRebalanceDelay() >= 0 && !cctx.kernalContext().clientNode()) {
- U.log(log, "Starting rebalancing [cache=" + cctx.name() + ", mode=" + cfg.getRebalanceMode() +
- ", from node=" + node.id() + ", partitions count=" + d.partitions().size() + ", topology=" + d.topologyVersion() + "]");
+ //Check remote node rebalancing API version.
+ if (new Integer(1).equals(node.attribute(IgniteNodeAttributes.REBALANCING_VERSION))) {
+ GridConcurrentHashSet<Integer> remainings = new GridConcurrentHashSet<>();
- fut.listen(new CI1<IgniteInternalFuture<Boolean>>() {
- @Override public void apply(IgniteInternalFuture<Boolean> t) {
- Boolean completed = ((SyncFuture)t).isCompleted();
- U.log(log, (!completed ? "Cancelled" : "Completed") + " rebalancing [cache=" + cctx.name() + ", mode="
- + cfg.getRebalanceMode() + ", from node=" + node.id() + ", topology=" + top +
- ", time=" + (U.currentTimeMillis() - start) + " ms]");
- }
- });
- }
+ remainings.addAll(d.partitions());
- GridConcurrentHashSet<Integer> remainings = new GridConcurrentHashSet<>();
+ fut.append(node.id(), remainings);
- remainings.addAll(d.partitions());
+ int lsnrCnt = Math.max(1, cctx.gridConfig().getRebalanceThreadPoolSize() / 2);
- fut.append(node.id(), remainings);
+ List<Set<Integer>> sParts = new ArrayList<>(lsnrCnt);
- int lsnrCnt = Math.max(1, cctx.gridConfig().getRebalanceThreadPoolSize() / 2);
+ for (int cnt = 0; cnt < lsnrCnt; cnt++)
+ sParts.add(new HashSet<Integer>());
- List<Set<Integer>> sParts = new ArrayList<>(lsnrCnt);
+ Iterator<Integer> it = d.partitions().iterator();
- for (int cnt = 0; cnt < lsnrCnt; cnt++)
- sParts.add(new HashSet<Integer>());
+ int cnt = 0;
- Iterator<Integer> it = d.partitions().iterator();
+ while (it.hasNext())
+ sParts.get(cnt++ % lsnrCnt).add(it.next());
- int cnt = 0;
+ for (cnt = 0; cnt < lsnrCnt; cnt++) {
- while (it.hasNext())
- sParts.get(cnt++ % lsnrCnt).add(it.next());
+ if (!sParts.get(cnt).isEmpty()) {
- for (cnt = 0; cnt < lsnrCnt; cnt++) {
+ // Create copy.
+ GridDhtPartitionDemandMessage initD = new GridDhtPartitionDemandMessage(d, sParts.get(cnt));
- if (!sParts.get(cnt).isEmpty()) {
+ initD.topic(GridCachePartitionExchangeManager.demanderTopic(cnt));
- // Create copy.
- GridDhtPartitionDemandMessage initD = new GridDhtPartitionDemandMessage(d, sParts.get(cnt));
+ try {
+ if (!topologyChanged(topVer))
+ cctx.io().sendOrderedMessage(node, GridCachePartitionExchangeManager.supplierTopic(cnt), initD, cctx.ioPolicy(), d.timeout());
+ else
+ fut.onCancel();
+ }
+ catch (IgniteCheckedException ex) {
+ fut.onCancel();
- initD.topic(GridCachePartitionExchangeManager.demanderTopic(cnt));
+ U.error(log, "Failed to send partition demand message to node", ex);
+ }
- try {
- cctx.io().sendOrderedMessage(node, GridCachePartitionExchangeManager.supplierTopic(cnt), initD, cctx.ioPolicy(), d.timeout());
- }
- catch (IgniteCheckedException ex) {
- U.error(log, "Failed to send partition demand message to local node", ex);
+ if (log.isDebugEnabled())
+ log.debug("Requested rebalancing [from node=" + node.id() + ", listener index=" + cnt + ", partitions count=" + sParts.get(cnt).size() + " (" + partitionsList(sParts.get(cnt)) + ")]");
}
-
- if (log.isDebugEnabled())
- log.debug("Requested rebalancing [from node=" + node.id() + ", listener index=" + cnt + ", partitions count=" + sParts.get(cnt).size() + " (" + partitionsList(sParts.get(cnt)) + ")]");
}
}
+ else {
+ DemandWorker dw = new DemandWorker(dmIdx.incrementAndGet(), fut);
+
+ fut.append(node.id(), d.partitions());
+
+ dw.run(node, d);
+ }
}
}
@@ -445,7 +473,7 @@ public class GridDhtPartitionDemander {
final SyncFuture fut = syncFut;
if (topologyChanged(topVer)) {
- fut.onCancel(id, topVer);
+ fut.onCancel();
return;
}
@@ -462,7 +490,7 @@ public class GridDhtPartitionDemander {
if (log.isDebugEnabled())
log.debug("Class got undeployed during preloading: " + supply.classError());
- fut.onCancel(id, topVer);
+ fut.onCancel(id);
return;
}
@@ -515,7 +543,7 @@ public class GridDhtPartitionDemander {
if (last) {
top.own(part);
- fut.onPartitionDone(id, p, topVer);
+ fut.onPartitionDone(id, p);
if (log.isDebugEnabled())
log.debug("Finished rebalancing partition: " + part);
@@ -527,14 +555,14 @@ public class GridDhtPartitionDemander {
}
}
else {
- fut.onPartitionDone(id, p, topVer);
+ fut.onPartitionDone(id, p);
if (log.isDebugEnabled())
log.debug("Skipping rebalancing partition (state is not MOVING): " + part);
}
}
else {
- fut.onPartitionDone(id, p, topVer);
+ fut.onPartitionDone(id, p);
if (log.isDebugEnabled())
log.debug("Skipping rebalancing partition (it does not belong on current node): " + p);
@@ -544,10 +572,10 @@ public class GridDhtPartitionDemander {
// Only request partitions based on latest topology version.
for (Integer miss : supply.missed())
if (cctx.affinity().localNode(miss, topVer))
- fut.onMissedPartition(id, miss, topVer);
+ fut.onMissedPartition(id, miss);
for (Integer miss : supply.missed())
- fut.onPartitionDone(id, miss, topVer);
+ fut.onPartitionDone(id, miss);
if (!fut.isDone()) {
@@ -569,15 +597,15 @@ public class GridDhtPartitionDemander {
}
catch (ClusterTopologyCheckedException e) {
if (log.isDebugEnabled())
- log.debug("Node left during rebalancing (will retry) [node=" + node.id() +
+ log.debug("Node left during rebalancing [node=" + node.id() +
", msg=" + e.getMessage() + ']');
- fut.onCancel(id, topVer);
+ fut.onCancel();
}
catch (IgniteCheckedException ex) {
U.error(log, "Failed to receive partitions from node (rebalancing will not " +
"fully finish) [node=" + node.id() + ", msg=" + supply + ']', ex);
- fut.onCancel(id, topVer);
+ fut.onCancel(node.id());
}
}
@@ -687,6 +715,10 @@ public class GridDhtPartitionDemander {
private ConcurrentHashMap8<UUID, Collection<Integer>> missed = new ConcurrentHashMap8<>();
+ private ConcurrentHashMap8<UUID, Long> started = new ConcurrentHashMap8<>();
+
+ private Lock lock = new ReentrantLock();
+
private volatile GridLocalEventListener lsnr;
/** Assignments. */
@@ -694,14 +726,23 @@ public class GridDhtPartitionDemander {
private volatile boolean completed = true;
+ /**
+ * @param assigns Assigns.
+ */
SyncFuture(GridDhtPreloaderAssignments assigns) {
this.assigns = assigns;
}
+ /**
+ *
+ */
public AffinityTopologyVersion topologyVersion() {
return assigns != null ? assigns.topologyVersion() : null;
}
+ /**
+ * @param assigns Assigns.
+ */
void init(GridDhtPreloaderAssignments assigns) {
final SyncFuture fut = this;
@@ -716,80 +757,157 @@ public class GridDhtPartitionDemander {
this.assigns = assigns;
}
+ /**
+ *
+ */
boolean isInited() {
return assigns != null;
}
+ /**
+ * @param nodeId Node id.
+ * @param parts Parts.
+ */
void append(UUID nodeId, Collection<Integer> parts) {
remaining.put(nodeId, parts);
missed.put(nodeId, new GridConcurrentHashSet<Integer>());
}
+ /**
+ * @param nodeId Node id.
+ * @param time Time.
+ */
+ void logStart(UUID nodeId, long time) {
+ started.put(nodeId, time);
+ }
+
+ /**
+ * @param topVer Topology version.
+ * @param node Node.
+ */
GridDhtPartitionDemandMessage getDemandMessage(AffinityTopologyVersion topVer, ClusterNode node) {
- if (!topVer.equals(assigns.topologyVersion()))
+ if (isDone() || !topVer.equals(assigns.topologyVersion()))
return null;
return assigns.get(node);
}
+ /**
+ *
+ */
void onCancel() {
- remaining.clear();
+ lock.lock();
+ try {
+ if (isDone())
+ return;
+
+ remaining.clear();
- completed = false;
+ completed = false;
- checkIsDone();
+ U.log(log, (!completed ? "Cancelled" : "Completed") + " rebalancing from all nodes [cache=" + cctx.name()
+ + ", topology=" + topologyVersion() +
+ ", time=" +
+ (started.isEmpty() ? 0 : (U.currentTimeMillis() - Collections.min(started.values()))) + " ms]");
+
+ checkIsDone();
+ }
+ finally {
+ lock.unlock();
+ }
}
- void onCancel(UUID nodeId, AffinityTopologyVersion topVer) {
- if (isDone() || !topVer.equals(assigns.topologyVersion()))
- return;
+ /**
+ * @param nodeId Node id.
+ */
+ void onCancel(UUID nodeId) {
+ lock.lock();
+ try {
+ if (isDone())
+ return;
- remaining.remove(nodeId);
+ remaining.remove(nodeId);
- completed = false;
+ completed = false;
+
+ U.log(log, ("Cancelled rebalancing [cache=" + cctx.name() +
+ ", from node=" + nodeId + ", topology=" + topologyVersion() +
+ ", time=" + (U.currentTimeMillis() - started.get(nodeId)) + " ms]"));
+
+ checkIsDone();
+ }
+ finally {
+ lock.unlock();
+ }
- checkIsDone();
}
+ /**
+ * @return Is completed.
+ */
boolean isCompleted() {
return completed;
}
- void onMissedPartition(UUID nodeId, int p, AffinityTopologyVersion topVer) {
- if (isDone() || !topVer.equals(assigns.topologyVersion()))
- return;
+ /**
+ * @param nodeId Node id.
+ * @param p P.
+ */
+ void onMissedPartition(UUID nodeId, int p) {
+ lock.lock();
+ try {
+ if (isDone())
+ return;
- if (missed.get(nodeId) == null)
- missed.put(nodeId, new GridConcurrentHashSet<Integer>());
+ if (missed.get(nodeId) == null)
+ missed.put(nodeId, new GridConcurrentHashSet<Integer>());
- missed.get(nodeId).add(p);
+ missed.get(nodeId).add(p);
+ }
+ finally {
+ lock.unlock();
+ }
}
- void onPartitionDone(UUID nodeId, int p, AffinityTopologyVersion topVer) {
- if (isDone() || !topVer.equals(assigns.topologyVersion()))
- return;
+ /**
+ * @param nodeId Node id.
+ * @param p P.
+ */
+ void onPartitionDone(UUID nodeId, int p) {
+ lock.lock();
+ try {
+ if (isDone())
+ return;
- if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_PART_LOADED))
- preloadEvent(p, EVT_CACHE_REBALANCE_PART_LOADED,
- assigns.exchangeFuture().discoveryEvent());
+ if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_PART_LOADED))
+ preloadEvent(p, EVT_CACHE_REBALANCE_PART_LOADED,
+ assigns.exchangeFuture().discoveryEvent());
- Collection<Integer> parts = remaining.get(nodeId);
+ Collection<Integer> parts = remaining.get(nodeId);
- if (parts != null) {
- parts.remove(p);
+ if (parts != null) {
+ parts.remove(p);
- if (parts.isEmpty()) {
- remaining.remove(nodeId);
+ if (parts.isEmpty()) {
+ remaining.remove(nodeId);
- if (log.isDebugEnabled())
- log.debug("Completed full partition iteration for node [nodeId=" + nodeId + ']');
+ U.log(log, ("Completed rebalancing [cache=" + cctx.name() +
+ ", from node=" + nodeId + ", topology=" + topologyVersion() +
+ ", time=" + (U.currentTimeMillis() - started.get(nodeId)) + " ms]"));
+ }
}
- }
- checkIsDone();
+ checkIsDone();
+ }
+ finally {
+ lock.unlock();
+ }
}
+ /**
+ *
+ */
private void checkIsDone() {
if (remaining.isEmpty()) {
if (log.isDebugEnabled())
@@ -809,8 +927,6 @@ public class GridDhtPartitionDemander {
cctx.shared().exchange().forceDummyExchange(true, assigns.exchangeFuture());
}
- missed.clear();
-
cctx.shared().exchange().scheduleResendPartitions();
if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_STOPPED))
@@ -820,7 +936,412 @@ public class GridDhtPartitionDemander {
cctx.events().removeListener(lsnr);
onDone(completed);
+
+ missed.clear();
+ remaining.clear();
+ started.clear();
+ assigns.clear();
+ }
+ }
+ }
+
+ /**
+ * Supply message wrapper.
+ */
+ @Deprecated//Backward compatibility. To be removed in future.
+ private static class SupplyMessage {
+ /** Sender ID. */
+ private UUID sndId;
+
+ /** Supply message. */
+ private GridDhtPartitionSupplyMessage supply;
+
+ /**
+ * Dummy constructor.
+ */
+ private SupplyMessage() {
+ // No-op.
+ }
+
+ /**
+ * @param sndId Sender ID.
+ * @param supply Supply message.
+ */
+ SupplyMessage(UUID sndId, GridDhtPartitionSupplyMessage supply) {
+ this.sndId = sndId;
+ this.supply = supply;
+ }
+
+ /**
+ * @return Sender ID.
+ */
+ UUID senderId() {
+ return sndId;
+ }
+
+ /**
+ * @return Message.
+ */
+ GridDhtPartitionSupplyMessage supply() {
+ return supply;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(SupplyMessage.class, this);
+ }
+ }
+
+ /** DemandWorker index. */
+ @Deprecated//Backward compatibility. To be removed in future.
+ private final AtomicInteger dmIdx = new AtomicInteger();
+
+ /**
+ *
+ */
+ @Deprecated//Backward compatibility. To be removed in future.
+ private class DemandWorker {
+ /** Worker ID. */
+ private int id;
+
+ /** Partition-to-node assignments. */
+ private final LinkedBlockingDeque<GridDhtPreloaderAssignments> assignQ = new LinkedBlockingDeque<>();
+
+ /** Message queue. */
+ private final LinkedBlockingDeque<SupplyMessage> msgQ =
+ new LinkedBlockingDeque<>();
+
+ /** Counter. */
+ private long cntr;
+
+ /** Hide worker logger and use cache logger instead. */
+ private IgniteLogger log = GridDhtPartitionDemander.this.log;
+
+ private volatile SyncFuture fut;
+
+ /**
+ * @param id Worker ID.
+ */
+ private DemandWorker(int id, SyncFuture fut) {
+ assert id >= 0;
+
+ this.id = id;
+ this.fut = fut;
+ }
+
+ /**
+ * @param msg Message.
+ */
+ private void addMessage(SupplyMessage msg) {
+ msgQ.offer(msg);
+ }
+
+ /**
+ * @param deque Deque to poll from.
+ * @param time Time to wait.
+ * @return Polled item.
+ * @throws InterruptedException If interrupted.
+ */
+ @Nullable private <T> T poll(BlockingQueue<T> deque, long time) throws InterruptedException {
+ return deque.poll(time, MILLISECONDS);
+ }
+
+ /**
+ * @param idx Unique index for this topic.
+ * @return Topic for partition.
+ */
+ public Object topic(long idx) {
+ return TOPIC_CACHE.topic(cctx.namexx(), cctx.nodeId(), id, idx);
+ }
+
+ /**
+ * @param node Node to demand from.
+ * @param topVer Topology version.
+ * @param d Demand message.
+ * @param exchFut Exchange future.
+ * @return Missed partitions.
+ * @throws InterruptedException If interrupted.
+ * @throws ClusterTopologyCheckedException If node left.
+ * @throws IgniteCheckedException If failed to send message.
+ */
+ private Set<Integer> demandFromNode(
+ ClusterNode node,
+ final AffinityTopologyVersion topVer,
+ GridDhtPartitionDemandMessage d,
+ GridDhtPartitionsExchangeFuture exchFut
+ ) throws InterruptedException, IgniteCheckedException {
+ GridDhtPartitionTopology top = cctx.dht().topology();
+
+ cntr++;
+
+ d.topic(topic(cntr));
+ d.workerId(id);
+
+ Set<Integer> missed = new HashSet<>();
+
+ // Get the same collection that will be sent in the message.
+ Collection<Integer> remaining = d.partitions();
+
+ if (topologyChanged(topVer))
+ return missed;
+
+ cctx.io().addOrderedHandler(d.topic(), new CI2<UUID, GridDhtPartitionSupplyMessage>() {
+ @Override public void apply(UUID nodeId, GridDhtPartitionSupplyMessage msg) {
+ addMessage(new SupplyMessage(nodeId, msg));
+ }
+ });
+
+ try {
+ boolean retry;
+
+ // DoWhile.
+ // =======
+ do {
+ retry = false;
+
+ // Create copy.
+ d = new GridDhtPartitionDemandMessage(d, remaining);
+
+ long timeout = cctx.config().getRebalanceTimeout();
+
+ d.timeout(timeout);
+
+ if (log.isDebugEnabled())
+ log.debug("Sending demand message [node=" + node.id() + ", demand=" + d + ']');
+
+ // Send demand message.
+ cctx.io().send(node, d, cctx.ioPolicy());
+
+ // While.
+ // =====
+ while (!topologyChanged(topVer)) {
+ SupplyMessage s = poll(msgQ, timeout);
+
+ // If timed out.
+ if (s == null) {
+ if (msgQ.isEmpty()) { // Safety check.
+ U.warn(log, "Timed out waiting for partitions to load, will retry in " + timeout +
+ " ms (you may need to increase 'networkTimeout' or 'rebalanceBatchSize'" +
+ " configuration properties).");
+
+ // Ordered listener was removed if timeout expired.
+ cctx.io().removeOrderedHandler(d.topic());
+
+ // Must create copy to be able to work with IO manager thread local caches.
+ d = new GridDhtPartitionDemandMessage(d, remaining);
+
+ // Create new topic.
+ d.topic(topic(++cntr));
+
+ // Create new ordered listener.
+ cctx.io().addOrderedHandler(d.topic(),
+ new CI2<UUID, GridDhtPartitionSupplyMessage>() {
+ @Override public void apply(UUID nodeId,
+ GridDhtPartitionSupplyMessage msg) {
+ addMessage(new SupplyMessage(nodeId, msg));
+ }
+ });
+
+ // Resend message with larger timeout.
+ retry = true;
+
+ break; // While.
+ }
+ else
+ continue; // While.
+ }
+
+ // Check that message was received from expected node.
+ if (!s.senderId().equals(node.id())) {
+ U.warn(log, "Received supply message from unexpected node [expectedId=" + node.id() +
+ ", rcvdId=" + s.senderId() + ", msg=" + s + ']');
+
+ continue; // While.
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Received supply message: " + s);
+
+ GridDhtPartitionSupplyMessage supply = s.supply();
+
+ // Check whether there were class loading errors on unmarshal
+ if (supply.classError() != null) {
+ if (log.isDebugEnabled())
+ log.debug("Class got undeployed during preloading: " + supply.classError());
+
+ retry = true;
+
+ // Quit preloading.
+ break;
+ }
+
+ // Preload.
+ for (Map.Entry<Integer, CacheEntryInfoCollection> e : supply.infos().entrySet()) {
+ int p = e.getKey();
+
+ if (cctx.affinity().localNode(p, topVer)) {
+ GridDhtLocalPartition part = top.localPartition(p, topVer, true);
+
+ assert part != null;
+
+ if (part.state() == MOVING) {
+ boolean reserved = part.reserve();
+
+ assert reserved : "Failed to reserve partition [gridName=" +
+ cctx.gridName() + ", cacheName=" + cctx.namex() + ", part=" + part + ']';
+
+ part.lock();
+
+ try {
+ Collection<Integer> invalidParts = new GridLeanSet<>();
+
+ // Loop through all received entries and try to preload them.
+ for (GridCacheEntryInfo entry : e.getValue().infos()) {
+ if (!invalidParts.contains(p)) {
+ if (!part.preloadingPermitted(entry.key(), entry.version())) {
+ if (log.isDebugEnabled())
+ log.debug("Preloading is not permitted for entry due to " +
+ "evictions [key=" + entry.key() +
+ ", ver=" + entry.version() + ']');
+
+ continue;
+ }
+
+ if (!preloadEntry(node, p, entry, topVer)) {
+ invalidParts.add(p);
+
+ if (log.isDebugEnabled())
+ log.debug("Got entries for invalid partition during " +
+ "preloading (will skip) [p=" + p + ", entry=" + entry + ']');
+ }
+ }
+ }
+
+ boolean last = supply.last().contains(p);
+
+ // If message was last for this partition,
+ // then we take ownership.
+ if (last) {
+ remaining.remove(p);
+ fut.onPartitionDone(node.id(), p);
+
+ top.own(part);
+
+ if (log.isDebugEnabled())
+ log.debug("Finished rebalancing partition: " + part);
+
+ if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_PART_LOADED))
+ preloadEvent(p, EVT_CACHE_REBALANCE_PART_LOADED,
+ exchFut.discoveryEvent());
+ }
+ }
+ finally {
+ part.unlock();
+ part.release();
+ }
+ }
+ else {
+ remaining.remove(p);
+ fut.onPartitionDone(node.id(), p);
+
+ if (log.isDebugEnabled())
+ log.debug("Skipping rebalancing partition (state is not MOVING): " + part);
+ }
+ }
+ else {
+ remaining.remove(p);
+ fut.onPartitionDone(node.id(), p);
+
+ if (log.isDebugEnabled())
+ log.debug("Skipping rebalancing partition (it does not belong on current node): " + p);
+ }
+ }
+
+ remaining.removeAll(s.supply().missed());
+
+ // Only request partitions based on latest topology version.
+ for (Integer miss : s.supply().missed()) {
+ if (cctx.affinity().localNode(miss, topVer))
+ missed.add(miss);
+
+ fut.onMissedPartition(node.id(), miss);
+ }
+
+ if (remaining.isEmpty())
+ break; // While.
+
+ if (s.supply().ack()) {
+ retry = true;
+
+ break;
+ }
+ }
+ }
+ while (retry && !topologyChanged(topVer));
+
+ return missed;
+ }
+ finally {
+ cctx.io().removeOrderedHandler(d.topic());
+ }
+ }
+
+ /**
+ * @param node Node.
+ * @param d D.
+ */
+ public void run(ClusterNode node, GridDhtPartitionDemandMessage d) {
+ demandLock.readLock().lock();
+
+ try {
+ GridDhtPartitionsExchangeFuture exchFut = fut.assigns.exchangeFuture();
+
+ AffinityTopologyVersion topVer = fut.assigns.topologyVersion();
+
+ Collection<Integer> missed = new HashSet<>();
+
+ if (topologyChanged(topVer)) {
+ fut.onCancel();
+
+ return;
+ }
+
+ try {
+ Set<Integer> set = demandFromNode(node, topVer, d, exchFut);
+
+ if (!set.isEmpty()) {
+ if (log.isDebugEnabled())
+ log.debug("Missed partitions from node [nodeId=" + node.id() + ", missed=" +
+ set + ']');
+
+ missed.addAll(set);
+ }
+ }
+ catch (ClusterTopologyCheckedException e) {
+ if (log.isDebugEnabled())
+ log.debug("Node left during rebalancing (will retry) [node=" + node.id() +
+ ", msg=" + e.getMessage() + ']');
+
+ fut.onCancel();
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to receive partitions from node (rebalancing will not " +
+ "fully finish) [node=" + node.id() + ", msg=" + d + ']', e);
+
+ fut.onCancel(node.id());
+ }
+ catch (InterruptedException e) {
+ fut.onCancel();
+ }
}
+ finally {
+ demandLock.readLock().unlock();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(DemandWorker.class, this, "assignQ", assignQ, "msgQ", msgQ, "super", super.toString());
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d89f1b0a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
index 347a394..0686376 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
@@ -25,15 +25,12 @@ import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.processors.cache.distributed.dht.*;
import org.apache.ignite.internal.util.lang.*;
import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.lang.*;
import org.jsr166.*;
import java.util.*;
-import java.util.concurrent.locks.*;
-import static org.apache.ignite.internal.GridTopic.*;
import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.*;
/**
@@ -73,13 +70,14 @@ class GridDhtPartitionSupplier {
top = cctx.dht().topology();
- depEnabled = cctx.gridDeploy().enabled();
+ depEnabled = cctx.gridDeploy().enabled();
}
/**
*
*/
void start() {
+ startOldListeners();
}
/**
@@ -463,14 +461,14 @@ class GridDhtPartitionSupplier {
int phase,
Iterator<Integer> partIt,
int part,
- Iterator<?> entryIt, GridCacheEntryInfoCollectSwapListener swapLsnr){
+ Iterator<?> entryIt, GridCacheEntryInfoCollectSwapListener swapLsnr) {
scMap.put(t, new SupplyContext(phase, partIt, entryIt, swapLsnr, part));
}
/**
* Supply context.
*/
- private static class SupplyContext{
+ private static class SupplyContext {
/** Phase. */
private int phase;
@@ -502,4 +500,284 @@ class GridDhtPartitionSupplier {
this.part = part;
}
}
+
+ @Deprecated//Backward compatibility. To be removed in future.
+ public void startOldListeners() {
+ if (!cctx.kernalContext().clientNode()) {
+ int poolSize = cctx.rebalanceEnabled() ? cctx.config().getRebalanceThreadPoolSize() : 0;
+
+ cctx.io().addHandler(cctx.cacheId(), GridDhtPartitionDemandMessage.class, new CI2<UUID, GridDhtPartitionDemandMessage>() {
+ @Override public void apply(UUID id, GridDhtPartitionDemandMessage m) {
+ processOldDemandMessage(m, id);
+ }
+ });
+ }
+ }
+
+ /**
+ * @param d D.
+ * @param id Id.
+ */
+ @Deprecated//Backward compatibility. To be removed in future.
+ private void processOldDemandMessage(GridDhtPartitionDemandMessage d, UUID id) {
+ GridDhtPartitionSupplyMessage s = new GridDhtPartitionSupplyMessage(d.workerId(),
+ d.updateSequence(), cctx.cacheId());
+
+ ClusterNode node = cctx.node(id);
+
+ long preloadThrottle = cctx.config().getRebalanceThrottle();
+
+ boolean ack = false;
+
+ try {
+ for (int part : d.partitions()) {
+ GridDhtLocalPartition loc = top.localPartition(part, d.topologyVersion(), false);
+
+ if (loc == null || loc.state() != OWNING || !loc.reserve()) {
+ // Reply with partition of "-1" to let sender know that
+ // this node is no longer an owner.
+ s.missed(part);
+
+ if (log.isDebugEnabled())
+ log.debug("Requested partition is not owned by local node [part=" + part +
+ ", demander=" + id + ']');
+
+ continue;
+ }
+
+ GridCacheEntryInfoCollectSwapListener swapLsnr = null;
+
+ try {
+ if (cctx.isSwapOrOffheapEnabled()) {
+ swapLsnr = new GridCacheEntryInfoCollectSwapListener(log);
+
+ cctx.swap().addOffHeapListener(part, swapLsnr);
+ cctx.swap().addSwapListener(part, swapLsnr);
+ }
+
+ boolean partMissing = false;
+
+ for (GridCacheEntryEx e : loc.entries()) {
+ if (!cctx.affinity().belongs(node, part, d.topologyVersion())) {
+ // Demander no longer needs this partition, so we send '-1' partition and move on.
+ s.missed(part);
+
+ if (log.isDebugEnabled())
+ log.debug("Demanding node does not need requested partition [part=" + part +
+ ", nodeId=" + id + ']');
+
+ partMissing = true;
+
+ break;
+ }
+
+ if (s.messageSize() >= cctx.config().getRebalanceBatchSize()) {
+ ack = true;
+
+ if (!replyOld(node, d, s))
+ return;
+
+ // Throttle preloading.
+ if (preloadThrottle > 0)
+ U.sleep(preloadThrottle);
+
+ s = new GridDhtPartitionSupplyMessage(d.workerId(), d.updateSequence(),
+ cctx.cacheId());
+ }
+
+ GridCacheEntryInfo info = e.info();
+
+ if (info != null && !info.isNew()) {
+ if (preloadPred == null || preloadPred.apply(info))
+ s.addEntry(part, info, cctx);
+ else if (log.isDebugEnabled())
+ log.debug("Rebalance predicate evaluated to false (will not sender cache entry): " +
+ info);
+ }
+ }
+
+ if (partMissing)
+ continue;
+
+ if (cctx.isSwapOrOffheapEnabled()) {
+ GridCloseableIterator<Map.Entry<byte[], GridCacheSwapEntry>> iter =
+ cctx.swap().iterator(part);
+
+ // Iterator may be null if space does not exist.
+ if (iter != null) {
+ try {
+ boolean prepared = false;
+
+ for (Map.Entry<byte[], GridCacheSwapEntry> e : iter) {
+ if (!cctx.affinity().belongs(node, part, d.topologyVersion())) {
+ // Demander no longer needs this partition,
+ // so we send '-1' partition and move on.
+ s.missed(part);
+
+ if (log.isDebugEnabled())
+ log.debug("Demanding node does not need requested partition " +
+ "[part=" + part + ", nodeId=" + id + ']');
+
+ partMissing = true;
+
+ break; // For.
+ }
+
+ if (s.messageSize() >= cctx.config().getRebalanceBatchSize()) {
+ ack = true;
+
+ if (!replyOld(node, d, s))
+ return;
+
+ // Throttle preloading.
+ if (preloadThrottle > 0)
+ U.sleep(preloadThrottle);
+
+ s = new GridDhtPartitionSupplyMessage(d.workerId(),
+ d.updateSequence(), cctx.cacheId());
+ }
+
+ GridCacheSwapEntry swapEntry = e.getValue();
+
+ GridCacheEntryInfo info = new GridCacheEntryInfo();
+
+ info.keyBytes(e.getKey());
+ info.ttl(swapEntry.ttl());
+ info.expireTime(swapEntry.expireTime());
+ info.version(swapEntry.version());
+ info.value(swapEntry.value());
+
+ if (preloadPred == null || preloadPred.apply(info))
+ s.addEntry0(part, info, cctx);
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Rebalance predicate evaluated to false (will not send " +
+ "cache entry): " + info);
+
+ continue;
+ }
+
+ // Need to manually prepare cache message.
+ if (depEnabled && !prepared) {
+ ClassLoader ldr = swapEntry.keyClassLoaderId() != null ?
+ cctx.deploy().getClassLoader(swapEntry.keyClassLoaderId()) :
+ swapEntry.valueClassLoaderId() != null ?
+ cctx.deploy().getClassLoader(swapEntry.valueClassLoaderId()) :
+ null;
+
+ if (ldr == null)
+ continue;
+
+ if (ldr instanceof GridDeploymentInfo) {
+ s.prepare((GridDeploymentInfo)ldr);
+
+ prepared = true;
+ }
+ }
+ }
+
+ if (partMissing)
+ continue;
+ }
+ finally {
+ iter.close();
+ }
+ }
+ }
+
+ // Stop receiving promote notifications.
+ if (swapLsnr != null) {
+ cctx.swap().removeOffHeapListener(part, swapLsnr);
+ cctx.swap().removeSwapListener(part, swapLsnr);
+ }
+
+ if (swapLsnr != null) {
+ Collection<GridCacheEntryInfo> entries = swapLsnr.entries();
+
+ swapLsnr = null;
+
+ for (GridCacheEntryInfo info : entries) {
+ if (!cctx.affinity().belongs(node, part, d.topologyVersion())) {
+ // Demander no longer needs this partition,
+ // so we send '-1' partition and move on.
+ s.missed(part);
+
+ if (log.isDebugEnabled())
+ log.debug("Demanding node does not need requested partition " +
+ "[part=" + part + ", nodeId=" + id + ']');
+
+ // No need to continue iteration over swap entries.
+ break;
+ }
+
+ if (s.messageSize() >= cctx.config().getRebalanceBatchSize()) {
+ ack = true;
+
+ if (!replyOld(node, d, s))
+ return;
+
+ s = new GridDhtPartitionSupplyMessage(d.workerId(),
+ d.updateSequence(),
+ cctx.cacheId());
+ }
+
+ if (preloadPred == null || preloadPred.apply(info))
+ s.addEntry(part, info, cctx);
+ else if (log.isDebugEnabled())
+ log.debug("Rebalance predicate evaluated to false (will not sender cache entry): " +
+ info);
+ }
+ }
+
+ // Mark as last supply message.
+ s.last(part);
+
+ if (ack) {
+ s.markAck();
+
+ break; // Partition for loop.
+ }
+ }
+ finally {
+ loc.release();
+
+ if (swapLsnr != null) {
+ cctx.swap().removeOffHeapListener(part, swapLsnr);
+ cctx.swap().removeSwapListener(part, swapLsnr);
+ }
+ }
+ }
+
+ replyOld(node, d, s);
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to send partition supply message to node: " + node.id(), e);
+ }
+ }
+
+ /**
+ * @param n Node.
+ * @param d Demand message.
+ * @param s Supply message.
+ * @return {@code True} if message was sent, {@code false} if recipient left grid.
+ * @throws IgniteCheckedException If failed.
+ */
+ @Deprecated//Backward compatibility. To be removed in future.
+ private boolean replyOld(ClusterNode n, GridDhtPartitionDemandMessage d, GridDhtPartitionSupplyMessage s)
+ throws IgniteCheckedException {
+ try {
+ if (log.isDebugEnabled())
+ log.debug("Replying to partition demand [node=" + n.id() + ", demand=" + d + ", supply=" + s + ']');
+
+ cctx.io().sendOrderedMessage(n, d.topic(), s, cctx.ioPolicy(), d.timeout());
+
+ return true;
+ }
+ catch (ClusterTopologyCheckedException ignore) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to send partition supply message because node left grid: " + n.id());
+
+ return false;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d89f1b0a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
index 585566b..7a9deba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
@@ -163,7 +163,7 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
});
supplier = new GridDhtPartitionSupplier(cctx);
- demander = new GridDhtPartitionDemander(cctx);
+ demander = new GridDhtPartitionDemander(cctx, demandLock);
cctx.events().addListener(discoLsnr, EVT_NODE_JOINED, EVT_NODE_LEFT, EVT_NODE_FAILED);
}
@@ -350,7 +350,13 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
/** {@inheritDoc} */
public void handleSupplyMessage(int idx, UUID id, final GridDhtPartitionSupplyMessageV2 s) {
- demander.handleSupplyMessage(idx, id, s);
+ demandLock.readLock().lock();
+ try {
+ demander.handleSupplyMessage(idx, id, s);
+ }
+ finally {
+ demandLock.readLock().unlock();
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/d89f1b0a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingAsyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingAsyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingAsyncSelfTest.java
deleted file mode 100644
index ca564ed..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingAsyncSelfTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.distributed.rebalancing;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-
-/**
- *
- */
-public class GridCacheMassiveRebalancingAsyncSelfTest extends GridCacheMassiveRebalancingSyncSelfTest {
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration iCfg = super.getConfiguration(gridName);
-
- CacheConfiguration cacheCfg = iCfg.getCacheConfiguration()[0];
-
- cacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
-
- iCfg.setDiscoverySpi(new FailableTcpDiscoverySpi());
-
- ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setIpFinder(ipFinder);
- ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setForceServerMode(true);
-
- if (getTestGridName(20).equals(gridName))
- spi =(FailableTcpDiscoverySpi)iCfg.getDiscoverySpi();
-
- return iCfg;
- }
-
- public static class FailableTcpDiscoverySpi extends TcpDiscoverySpi{
- public void fail(){
- simulateNodeFailure();
- }
- }
-
- private volatile FailableTcpDiscoverySpi spi;
-
- /**
- * @throws Exception
- */
- public void testNodeFailedAtRebalancing() throws Exception {
- Ignite ignite = startGrid(0);
-
- generateData(ignite);
-
- log.info("Preloading started.");
-
- startGrid(1);
-
- IgniteInternalFuture f1 = ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
-
- f1.get();
-
- startGrid(20);
-
- U.sleep(500);
-
- spi.fail();
-
- U.sleep(500);
-
- f1 = ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
- IgniteInternalFuture f0 = ((GridCacheAdapter)grid(0).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
-
- f1.get();
- f0.get();
-
- stopAllGrids();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d89f1b0a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingSyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingSyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingSyncSelfTest.java
deleted file mode 100644
index f69b710..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingSyncSelfTest.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.distributed.rebalancing;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.affinity.*;
-import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import java.util.concurrent.atomic.*;
-
-/**
- *
- */
-public class GridCacheMassiveRebalancingSyncSelfTest extends GridCommonAbstractTest {
- /** */
- protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
- private static int TEST_SIZE = 1_000_000;
-
- /** cache name. */
- protected static String CACHE_NAME_DHT = "cache";
-
- /** cache 2 name. */
- protected static String CACHE_2_NAME_DHT = "cache2";
-
- /** {@inheritDoc} */
- @Override protected long getTestTimeout() {
- return Long.MAX_VALUE;
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration iCfg = super.getConfiguration(gridName);
-
- ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setIpFinder(ipFinder);
- ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setForceServerMode(true);
-
- if (getTestGridName(10).equals(gridName))
- iCfg.setClientMode(true);
-
- CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>();
-
- cacheCfg.setName(CACHE_NAME_DHT);
- cacheCfg.setCacheMode(CacheMode.PARTITIONED);
- //cacheCfg.setRebalanceBatchSize(1024);
- //cacheCfg.setRebalanceBatchesCount(1);
- cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
- cacheCfg.setBackups(1);
-
- CacheConfiguration<Integer, Integer> cacheCfg2 = new CacheConfiguration<>();
-
- cacheCfg2.setName(CACHE_2_NAME_DHT);
- cacheCfg2.setCacheMode(CacheMode.PARTITIONED);
- //cacheCfg2.setRebalanceBatchSize(1024);
- //cacheCfg2.setRebalanceBatchesCount(1);
- cacheCfg2.setRebalanceMode(CacheRebalanceMode.SYNC);
- cacheCfg2.setBackups(1);
-
- iCfg.setRebalanceThreadPoolSize(4);
- iCfg.setCacheConfiguration(cacheCfg, cacheCfg2);
- return iCfg;
- }
-
- /**
- * @param ignite Ignite.
- */
- protected void generateData(Ignite ignite) {
- try (IgniteDataStreamer<Integer, Integer> stmr = ignite.dataStreamer(CACHE_NAME_DHT)) {
- for (int i = 0; i < TEST_SIZE; i++) {
- if (i % 1_000_000 == 0)
- log.info("Prepared " + i / 1_000_000 + "m entries.");
-
- stmr.addData(i, i);
- }
- }
- try (IgniteDataStreamer<Integer, Integer> stmr = ignite.dataStreamer(CACHE_2_NAME_DHT)) {
- for (int i = 0; i < TEST_SIZE; i++) {
- if (i % 1_000_000 == 0)
- log.info("Prepared " + i / 1_000_000 + "m entries.");
-
- stmr.addData(i, i + 3);
- }
- }
- }
-
- /**
- * @param ignite Ignite.
- * @throws IgniteCheckedException
- */
- protected void checkData(Ignite ignite) throws IgniteCheckedException {
- for (int i = 0; i < TEST_SIZE; i++) {
- if (i % 1_000_000 == 0)
- log.info("Checked " + i / 1_000_000 + "m entries.");
-
- assert ignite.cache(CACHE_NAME_DHT).get(i) != null && ignite.cache(CACHE_NAME_DHT).get(i).equals(i) :
- "keys " + i + " does not match (" + ignite.cache(CACHE_NAME_DHT).get(i) + ")";
- }
- for (int i = 0; i < TEST_SIZE; i++) {
- if (i % 1_000_000 == 0)
- log.info("Checked " + i / 1_000_000 + "m entries.");
-
- assert ignite.cache(CACHE_2_NAME_DHT).get(i) != null && ignite.cache(CACHE_2_NAME_DHT).get(i).equals(i + 3) :
- "keys " + i + " does not match (" + ignite.cache(CACHE_2_NAME_DHT).get(i) + ")";
- }
- }
-
- /**
- * @throws Exception
- */
- public void testSimpleRebalancing() throws Exception {
- Ignite ignite = startGrid(0);
-
- generateData(ignite);
-
- log.info("Preloading started.");
-
- long start = System.currentTimeMillis();
-
- startGrid(1);
-
- IgniteInternalFuture f1 = ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
-
- f1.get();
-
- long spend = (System.currentTimeMillis() - start) / 1000;
-
- stopGrid(0);
-
- checkData(grid(1));
-
- log.info("Spend " + spend + " seconds to rebalance entries.");
-
- stopAllGrids();
- }
-
- /**
- * @throws Exception
- */
- public void testComplexRebalancing() throws Exception {
- Ignite ignite = startGrid(0);
-
- generateData(ignite);
-
- log.info("Preloading started.");
-
- long start = System.currentTimeMillis();
-
- //will be started simultaneously in case of ASYNC mode
- startGrid(1);
- startGrid(2);
- startGrid(3);
- startGrid(4);
-
- //wait until cache rebalanced in async mode
-
- GridCachePreloader p11 = ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader();
- GridCachePreloader p12 = ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader();
- GridCachePreloader p13 = ((GridCacheAdapter)grid(3).context().cache().internalCache(CACHE_NAME_DHT)).preloader();
- GridCachePreloader p14 = ((GridCacheAdapter)grid(4).context().cache().internalCache(CACHE_NAME_DHT)).preloader();
-
- GridCachePreloader p21 = ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_2_NAME_DHT)).preloader();
- GridCachePreloader p22 = ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_2_NAME_DHT)).preloader();
- GridCachePreloader p23 = ((GridCacheAdapter)grid(3).context().cache().internalCache(CACHE_2_NAME_DHT)).preloader();
- GridCachePreloader p24 = ((GridCacheAdapter)grid(4).context().cache().internalCache(CACHE_2_NAME_DHT)).preloader();
-
- IgniteInternalFuture f24 = p24.syncFuture();
- f24.get();
-
- IgniteInternalFuture f14 = p14.syncFuture();
- f14.get();
-
- AffinityTopologyVersion f4Top = ((GridDhtPartitionDemander.SyncFuture)f24).topologyVersion();
-
- IgniteInternalFuture f11 = p11.syncFuture();
- IgniteInternalFuture f12 = p12.syncFuture();
- IgniteInternalFuture f13 = p13.syncFuture();
-
- while (!((GridDhtPartitionDemander.SyncFuture)f11).topologyVersion().equals(f4Top) ||
- !((GridDhtPartitionDemander.SyncFuture)f12).topologyVersion().equals(f4Top) ||
- !((GridDhtPartitionDemander.SyncFuture)f13).topologyVersion().equals(f4Top)) {
- U.sleep(100);
-
- f11 = p11.syncFuture();
- f12 = p12.syncFuture();
- f13 = p13.syncFuture();
- }
- f11.get();
- f12.get();
- f13.get();
-
- IgniteInternalFuture f21 = p21.syncFuture();
- IgniteInternalFuture f22 = p22.syncFuture();
- IgniteInternalFuture f23 = p23.syncFuture();
-
- while (!((GridDhtPartitionDemander.SyncFuture)f21).topologyVersion().equals(f4Top) ||
- !((GridDhtPartitionDemander.SyncFuture)f22).topologyVersion().equals(f4Top) ||
- !((GridDhtPartitionDemander.SyncFuture)f23).topologyVersion().equals(f4Top)) {
- U.sleep(100);
-
- f21 = p21.syncFuture();
- f22 = p22.syncFuture();
- f23 = p23.syncFuture();
- }
- f21.get();
- f22.get();
- f23.get();
-
- //cache rebalanced in async node
-
- f11 = p11.syncFuture();
- f12 = p12.syncFuture();
- f13 = p13.syncFuture();
- f14 = p14.syncFuture();
-
- f21 = p21.syncFuture();
- f22 = p22.syncFuture();
- f23 = p23.syncFuture();
- f24 = p24.syncFuture();
-
- stopGrid(0);
-
- //wait until cache rebalanced
-
- while (f11 == p11.syncFuture() || f12 == p12.syncFuture() || f13 == p13.syncFuture() || f14 == p14.syncFuture())
- U.sleep(100);
-
- while (f21 == p21.syncFuture() || f22 == p22.syncFuture() || f23 == p23.syncFuture() || f24 == p24.syncFuture())
- U.sleep(100);
-
- p11.syncFuture().get();
- p12.syncFuture().get();
- p13.syncFuture().get();
- p14.syncFuture().get();
-
- p21.syncFuture().get();
- p22.syncFuture().get();
- p23.syncFuture().get();
- p24.syncFuture().get();
-
- //cache rebalanced
-
- f12 = p12.syncFuture();
- f13 = p13.syncFuture();
- f14 = p14.syncFuture();
-
- f22 = p22.syncFuture();
- f23 = p23.syncFuture();
- f24 = p24.syncFuture();
-
- stopGrid(1);
-
- //wait until cache rebalanced
-
- while (f12 == p12.syncFuture() || f13 == p13.syncFuture() || f14 == p14.syncFuture())
- U.sleep(100);
-
- while (f22 == p22.syncFuture() || f23 == p23.syncFuture() || f24 == p24.syncFuture())
- U.sleep(100);
-
- p12.syncFuture().get();
- p13.syncFuture().get();
- p14.syncFuture().get();
-
- p22.syncFuture().get();
- p23.syncFuture().get();
- p24.syncFuture().get();
-
- //cache rebalanced
-
- f13 = p13.syncFuture();
- f14 = p14.syncFuture();
-
- f23 = p23.syncFuture();
- f24 = p24.syncFuture();
-
- stopGrid(2);
-
- //wait until cache rebalanced
-
- while (f13 == p13.syncFuture() || f14 == p14.syncFuture())
- U.sleep(100);
-
- while (f23 == p23.syncFuture() || f24 == p24.syncFuture())
- U.sleep(100);
-
- p13.syncFuture().get();
- p14.syncFuture().get();
-
- p23.syncFuture().get();
- p24.syncFuture().get();
-
- //cache rebalanced
-
- stopGrid(3);
-
- long spend = (System.currentTimeMillis() - start) / 1000;
-
- checkData(grid(4));
-
- log.info("Spend " + spend + " seconds to rebalance entries.");
-
- stopAllGrids();
- }
-
- /**
- * @throws Exception
- */
- public void _testOpPerSecRebalancingTest() throws Exception {
- startGrid(0);
-
- final AtomicBoolean cancelled = new AtomicBoolean(false);
-
- generateData(grid(0));
-
- startGrid(1);
- startGrid(2);
- startGrid(10);
-
- Thread t = new Thread(new Runnable() {
- @Override public void run() {
-
- long spend = 0;
-
- long ops = 0;
-
- while (!cancelled.get()) {
- try {
- long start = System.currentTimeMillis();
-
- int size = 1000;
-
- for (int i = 0; i < size; i++)
- grid(10).cachex(CACHE_NAME_DHT).remove(i);
-
- for (int i = 0; i < size; i++)
- grid(10).cachex(CACHE_NAME_DHT).put(i, i);
-
- spend += System.currentTimeMillis() - start;
-
- ops += size * 2;
- }
- catch (IgniteCheckedException e) {
- e.printStackTrace();
- }
-
- log.info("Ops. per ms: " + ops / spend);
- }
- }
- });
- t.start();
-
- stopGrid(0);
- startGrid(0);
-
- stopGrid(0);
- startGrid(0);
-
- stopGrid(0);
- startGrid(0);
-
- cancelled.set(true);
- t.join();
-
- checkData(grid(10));
-
- //stopAllGrids();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d89f1b0a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAsyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAsyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAsyncSelfTest.java
new file mode 100644
index 0000000..a17fc7a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAsyncSelfTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.rebalancing;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+
+/**
+ *
+ */
+public class GridCacheRebalancingAsyncSelfTest extends GridCacheRebalancingSyncSelfTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration iCfg = super.getConfiguration(gridName);
+
+ CacheConfiguration cacheCfg = iCfg.getCacheConfiguration()[0];
+
+ cacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
+
+ cacheCfg = iCfg.getCacheConfiguration()[1];
+
+ cacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
+
+ iCfg.setDiscoverySpi(new FailableTcpDiscoverySpi());
+
+ ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setIpFinder(ipFinder);
+ ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setForceServerMode(true);
+
+ if (getTestGridName(20).equals(gridName))
+ spi = (FailableTcpDiscoverySpi)iCfg.getDiscoverySpi();
+
+ return iCfg;
+ }
+
+ public static class FailableTcpDiscoverySpi extends TcpDiscoverySpi {
+ public void fail() {
+ simulateNodeFailure();
+ }
+ }
+
+ private volatile FailableTcpDiscoverySpi spi;
+
+ /**
+ * @throws Exception
+ */
+ public void testNodeFailedAtRebalancing() throws Exception {
+ Ignite ignite = startGrid(0);
+
+ generateData(ignite);
+
+ log.info("Preloading started.");
+
+ startGrid(1);
+
+ waitForRebalancing(1, 2);
+
+ startGrid(20);
+
+ waitForRebalancing(20, 3);
+
+ spi.fail();
+
+ waitForRebalancing(0, 4);
+ waitForRebalancing(1, 4);
+
+ stopAllGrids();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d89f1b0a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
new file mode 100644
index 0000000..0cb6c7b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
@@ -0,0 +1,269 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.rebalancing;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.internal.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.*;
+
+/**
+ *
+ */
+public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
+ /** */
+ protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ private static int TEST_SIZE = 1_000_000;
+
+ /** cache name. */
+ protected static String CACHE_NAME_DHT = "cache";
+
+ /** cache 2 name. */
+ protected static String CACHE_2_NAME_DHT = "cache2";
+
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return Long.MAX_VALUE;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration iCfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setIpFinder(ipFinder);
+ ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setForceServerMode(true);
+
+ if (getTestGridName(10).equals(gridName))
+ iCfg.setClientMode(true);
+
+ CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>();
+
+ cacheCfg.setName(CACHE_NAME_DHT);
+ cacheCfg.setCacheMode(CacheMode.PARTITIONED);
+ //cacheCfg.setRebalanceBatchSize(1024);
+ //cacheCfg.setRebalanceBatchesCount(1);
+ cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+ cacheCfg.setBackups(1);
+
+ CacheConfiguration<Integer, Integer> cacheCfg2 = new CacheConfiguration<>();
+
+ cacheCfg2.setName(CACHE_2_NAME_DHT);
+ cacheCfg2.setCacheMode(CacheMode.PARTITIONED);
+ //cacheCfg2.setRebalanceBatchSize(1024);
+ //cacheCfg2.setRebalanceBatchesCount(1);
+ cacheCfg2.setRebalanceMode(CacheRebalanceMode.SYNC);
+ cacheCfg2.setBackups(1);
+
+ iCfg.setRebalanceThreadPoolSize(4);
+ iCfg.setCacheConfiguration(cacheCfg, cacheCfg2);
+ return iCfg;
+ }
+
+ /**
+ * @param ignite Ignite.
+ */
+ protected void generateData(Ignite ignite) {
+ try (IgniteDataStreamer<Integer, Integer> stmr = ignite.dataStreamer(CACHE_NAME_DHT)) {
+ for (int i = 0; i < TEST_SIZE; i++) {
+ if (i % 1_000_000 == 0)
+ log.info("Prepared " + i / 1_000_000 + "m entries.");
+
+ stmr.addData(i, i);
+ }
+ }
+ try (IgniteDataStreamer<Integer, Integer> stmr = ignite.dataStreamer(CACHE_2_NAME_DHT)) {
+ for (int i = 0; i < TEST_SIZE; i++) {
+ if (i % 1_000_000 == 0)
+ log.info("Prepared " + i / 1_000_000 + "m entries.");
+
+ stmr.addData(i, i + 3);
+ }
+ }
+ }
+
+ /**
+ * @param ignite Ignite.
+ * @throws IgniteCheckedException
+ */
+ protected void checkData(Ignite ignite) throws IgniteCheckedException {
+ for (int i = 0; i < TEST_SIZE; i++) {
+ if (i % 1_000_000 == 0)
+ log.info("Checked " + i / 1_000_000 + "m entries.");
+
+ assert ignite.cache(CACHE_NAME_DHT).get(i) != null && ignite.cache(CACHE_NAME_DHT).get(i).equals(i) :
+ "key " + i + " does not match (" + ignite.cache(CACHE_NAME_DHT).get(i) + ")";
+ }
+ for (int i = 0; i < TEST_SIZE; i++) {
+ if (i % 1_000_000 == 0)
+ log.info("Checked " + i / 1_000_000 + "m entries.");
+
+ assert ignite.cache(CACHE_2_NAME_DHT).get(i) != null && ignite.cache(CACHE_2_NAME_DHT).get(i).equals(i + 3) :
+ "key " + i + " does not match (" + ignite.cache(CACHE_2_NAME_DHT).get(i) + ")";
+ }
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testSimpleRebalancing() throws Exception {
+ Ignite ignite = startGrid(0);
+
+ generateData(ignite);
+
+ log.info("Preloading started.");
+
+ long start = System.currentTimeMillis();
+
+ startGrid(1);
+
+ IgniteInternalFuture f1 = ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
+
+ f1.get();
+
+ long spend = (System.currentTimeMillis() - start) / 1000;
+
+ stopGrid(0);
+
+ checkData(grid(1));
+
+ log.info("Spend " + spend + " seconds to rebalance entries.");
+
+ stopAllGrids();
+ }
+
+ /**
+ * @param id Id.
+ * @param top Topology.
+ */
+ protected void waitForRebalancing(int id, int top) throws IgniteCheckedException {
+ boolean finished = false;
+
+ while (!finished) {
+ finished = true;
+
+ for (GridCacheAdapter c : grid(id).context().cache().internalCaches()) {
+ GridDhtPartitionDemander.SyncFuture fut = (GridDhtPartitionDemander.SyncFuture)c.preloader().syncFuture();
+ if (fut.topologyVersion().topologyVersion() != top) {
+ finished = false;
+
+ break;
+ }
+ else
+ fut.get();
+ }
+ }
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testComplexRebalancing() throws Exception {
+ Ignite ignite = startGrid(0);
+
+ generateData(ignite);
+
+ log.info("Preloading started.");
+
+ long start = System.currentTimeMillis();
+
+ //will be started simultaneously in case of ASYNC mode
+ startGrid(1);
+ startGrid(2);
+ startGrid(3);
+ startGrid(4);
+
+ //wait until cache rebalanced in async mode
+ waitForRebalancing(1, 5);
+ waitForRebalancing(2, 5);
+ waitForRebalancing(3, 5);
+ waitForRebalancing(4, 5);
+
+ //cache rebalanced in async node
+
+ stopGrid(0);
+
+ //wait until cache rebalanced
+ waitForRebalancing(1, 6);
+ waitForRebalancing(2, 6);
+ waitForRebalancing(3, 6);
+ waitForRebalancing(4, 6);
+
+ //cache rebalanced
+
+ stopGrid(1);
+
+ //wait until cache rebalanced
+ waitForRebalancing(2, 7);
+ waitForRebalancing(3, 7);
+ waitForRebalancing(4, 7);
+
+ //cache rebalanced
+
+ stopGrid(2);
+
+ //wait until cache rebalanced
+ waitForRebalancing(3, 8);
+ waitForRebalancing(4, 8);
+
+ //cache rebalanced
+
+ stopGrid(3);
+
+ long spend = (System.currentTimeMillis() - start) / 1000;
+
+ checkData(grid(4));
+
+ log.info("Spend " + spend + " seconds to rebalance entries.");
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testBackwardCompatibility() throws Exception {
+ Ignite ignite = startGrid(0);
+
+ Map<String, Object> map = new HashMap<>(ignite.cluster().localNode().attributes());
+
+ map.put(IgniteNodeAttributes.REBALANCING_VERSION, 0);
+
+ ((TcpDiscoveryNode)ignite.cluster().localNode()).setAttributes(map);
+
+ generateData(ignite);
+
+ startGrid(1);
+
+ waitForRebalancing(1, 2);
+
+ stopGrid(0);
+
+ checkData(grid(1));
+
+ }
+}
\ No newline at end of file
[31/41] ignite git commit: IGNITE-1309: Moved platform affinity to
Ignite.
Posted by sb...@apache.org.
IGNITE-1309: Moved platform affinity to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/536af49b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/536af49b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/536af49b
Branch: refs/heads/ignite-1093
Commit: 536af49ba0a407fdbc5682f73a48aa07fa3daae0
Parents: d9a1397
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 17:03:39 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 17:03:39 2015 +0300
----------------------------------------------------------------------
.../cache/affinity/PlatformAffinity.java | 293 +++++++++++++++++++
1 file changed, 293 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/536af49b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java
new file mode 100644
index 0000000..d6dfcdb
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java
@@ -0,0 +1,293 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.cache.affinity;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.managers.discovery.*;
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.platform.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.jetbrains.annotations.*;
+
+import java.util.*;
+
+/**
+ * Native cache wrapper implementation.
+ */
+@SuppressWarnings({"unchecked", "UnusedDeclaration", "TryFinallyCanBeTryWithResources"})
+public class PlatformAffinity extends PlatformAbstractTarget {
+ /** */
+ public static final int OP_AFFINITY_KEY = 1;
+
+ /** */
+ public static final int OP_ALL_PARTITIONS = 2;
+
+ /** */
+ public static final int OP_BACKUP_PARTITIONS = 3;
+
+ /** */
+ public static final int OP_IS_BACKUP = 4;
+
+ /** */
+ public static final int OP_IS_PRIMARY = 5;
+
+ /** */
+ public static final int OP_IS_PRIMARY_OR_BACKUP = 6;
+
+ /** */
+ public static final int OP_MAP_KEY_TO_NODE = 7;
+
+ /** */
+ public static final int OP_MAP_KEY_TO_PRIMARY_AND_BACKUPS = 8;
+
+ /** */
+ public static final int OP_MAP_KEYS_TO_NODES = 9;
+
+ /** */
+ public static final int OP_MAP_PARTITION_TO_NODE = 10;
+
+ /** */
+ public static final int OP_MAP_PARTITION_TO_PRIMARY_AND_BACKUPS = 11;
+
+ /** */
+ public static final int OP_MAP_PARTITIONS_TO_NODES = 12;
+
+ /** */
+ public static final int OP_PARTITION = 13;
+
+ /** */
+ public static final int OP_PRIMARY_PARTITIONS = 14;
+
+ /** */
+ private static final C1<ClusterNode, UUID> TO_NODE_ID = new C1<ClusterNode, UUID>() {
+ @Nullable @Override public UUID apply(ClusterNode node) {
+ return node != null ? node.id() : null;
+ }
+ };
+
+ /** Underlying cache affinity. */
+ private final Affinity<Object> aff;
+
+ /** Discovery manager */
+ private final GridDiscoveryManager discovery;
+
+ /**
+ * Constructor.
+ *
+ * @param platformCtx Context.
+ * @param igniteCtx Ignite context.
+ * @param name Cache name.
+ */
+ public PlatformAffinity(PlatformContext platformCtx, GridKernalContext igniteCtx, @Nullable String name)
+ throws IgniteCheckedException {
+ super(platformCtx);
+
+ this.aff = igniteCtx.grid().affinity(name);
+
+ if (aff == null)
+ throw new IgniteCheckedException("Cache with the given name doesn't exist: " + name);
+
+ discovery = igniteCtx.discovery();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected int processInOp(int type, PortableRawReaderEx reader) throws IgniteCheckedException {
+ switch (type) {
+ case OP_PARTITION:
+ return aff.partition(reader.readObjectDetached());
+
+ case OP_IS_PRIMARY: {
+ UUID nodeId = reader.readUuid();
+
+ Object key = reader.readObjectDetached();
+
+ ClusterNode node = discovery.node(nodeId);
+
+ if (node == null)
+ return FALSE;
+
+ return aff.isPrimary(node, key) ? TRUE : FALSE;
+ }
+
+ case OP_IS_BACKUP: {
+ UUID nodeId = reader.readUuid();
+
+ Object key = reader.readObjectDetached();
+
+ ClusterNode node = discovery.node(nodeId);
+
+ if (node == null)
+ return FALSE;
+
+ return aff.isBackup(node, key) ? TRUE : FALSE;
+ }
+
+ case OP_IS_PRIMARY_OR_BACKUP: {
+ UUID nodeId = reader.readUuid();
+
+ Object key = reader.readObjectDetached();
+
+ ClusterNode node = discovery.node(nodeId);
+
+ if (node == null)
+ return FALSE;
+
+ return aff.isPrimaryOrBackup(node, key) ? TRUE : FALSE;
+ }
+
+ default:
+ return throwUnsupported(type);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings({"IfMayBeConditional", "ConstantConditions"})
+ @Override protected void processInOutOp(int type, PortableRawReaderEx reader, PortableRawWriterEx writer,
+ Object arg) throws IgniteCheckedException {
+ switch (type) {
+ case OP_PRIMARY_PARTITIONS: {
+ UUID nodeId = reader.readObject();
+
+ ClusterNode node = discovery.node(nodeId);
+
+ int[] parts = node != null ? aff.primaryPartitions(node) : U.EMPTY_INTS;
+
+ writer.writeIntArray(parts);
+
+ break;
+ }
+
+ case OP_BACKUP_PARTITIONS: {
+ UUID nodeId = reader.readObject();
+
+ ClusterNode node = discovery.node(nodeId);
+
+ int[] parts = node != null ? aff.backupPartitions(node) : U.EMPTY_INTS;
+
+ writer.writeIntArray(parts);
+
+ break;
+ }
+
+ case OP_ALL_PARTITIONS: {
+ UUID nodeId = reader.readObject();
+
+ ClusterNode node = discovery.node(nodeId);
+
+ int[] parts = node != null ? aff.allPartitions(node) : U.EMPTY_INTS;
+
+ writer.writeIntArray(parts);
+
+ break;
+ }
+
+ case OP_AFFINITY_KEY: {
+ Object key = reader.readObjectDetached();
+
+ writer.writeObject(aff.affinityKey(key));
+
+ break;
+ }
+
+ case OP_MAP_KEY_TO_NODE: {
+ Object key = reader.readObjectDetached();
+
+ ClusterNode node = aff.mapKeyToNode(key);
+
+ platformCtx.writeNode(writer, node);
+
+ break;
+ }
+
+ case OP_MAP_PARTITION_TO_NODE: {
+ int part = reader.readObject();
+
+ ClusterNode node = aff.mapPartitionToNode(part);
+
+ platformCtx.writeNode(writer, node);
+
+ break;
+ }
+
+ case OP_MAP_KEY_TO_PRIMARY_AND_BACKUPS: {
+ Object key = reader.readObjectDetached();
+
+ platformCtx.writeNodes(writer, aff.mapKeyToPrimaryAndBackups(key));
+
+ break;
+ }
+
+ case OP_MAP_PARTITION_TO_PRIMARY_AND_BACKUPS: {
+ int part = reader.readObject();
+
+ platformCtx.writeNodes(writer, aff.mapPartitionToPrimaryAndBackups(part));
+
+ break;
+ }
+
+ case OP_MAP_KEYS_TO_NODES: {
+ Collection<Object> keys = reader.readCollection();
+
+ Map<ClusterNode, Collection<Object>> map = aff.mapKeysToNodes(keys);
+
+ writer.writeInt(map.size());
+
+ for (Map.Entry<ClusterNode, Collection<Object>> e : map.entrySet()) {
+ platformCtx.addNode(e.getKey());
+
+ writer.writeUuid(e.getKey().id());
+ writer.writeObject(e.getValue());
+ }
+
+ break;
+ }
+
+ case OP_MAP_PARTITIONS_TO_NODES: {
+ Collection<Integer> parts = reader.readCollection();
+
+ Map<Integer, ClusterNode> map = aff.mapPartitionsToNodes(parts);
+
+ writer.writeInt(map.size());
+
+ for (Map.Entry<Integer, ClusterNode> e : map.entrySet()) {
+ platformCtx.addNode(e.getValue());
+
+ writer.writeInt(e.getKey());
+
+ writer.writeUuid(e.getValue().id());
+ }
+
+ break;
+ }
+
+ default:
+ throwUnsupported(type);
+ }
+ }
+
+ /**
+ * @return Gets number of partitions in cache.
+ */
+ public int partitions() {
+ return aff.partitions();
+ }
+}
[38/41] ignite git commit: Moved two platform utility methods to
Ignite.
Posted by sb...@apache.org.
Moved two platform utility methods to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/57184803
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/57184803
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/57184803
Branch: refs/heads/ignite-1093
Commit: 57184803fc64049e18d27d04777687e3f1f7e42d
Parents: 5877b30
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Aug 27 10:07:55 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Aug 27 10:07:55 2015 +0300
----------------------------------------------------------------------
.../platform/utils/PlatformUtils.java | 55 ++++++++++++++++++++
1 file changed, 55 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/57184803/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index f82fb0f..0777f9a 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -600,6 +600,61 @@ public class PlatformUtils {
}
/**
+ * Reallocate arbitrary memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @param cap Capacity.
+ */
+ public static void reallocate(long memPtr, int cap) {
+ PlatformMemoryUtils.reallocate(memPtr, cap);
+ }
+
+ /**
+ * Get error data.
+ *
+ * @param err Error.
+ * @return Error data.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ public static byte[] errorData(Throwable err) {
+ if (err instanceof PlatformExtendedException) {
+ PlatformContext ctx = ((PlatformExtendedException)err).context();
+
+ try (PlatformMemory mem = ctx.memory().allocate()) {
+ // Write error data.
+ PlatformOutputStream out = mem.output();
+
+ PortableRawWriterEx writer = ctx.writer(out);
+
+ try {
+ PlatformUtils.writeErrorData(err, writer, ctx.kernalContext().log(PlatformContext.class));
+ }
+ finally {
+ out.synchronize();
+ }
+
+ // Read error data into separate array.
+ PlatformInputStream in = mem.input();
+
+ in.synchronize();
+
+ int len = in.remaining();
+
+ assert len > 0;
+
+ byte[] arr = in.array();
+ byte[] res = new byte[len];
+
+ System.arraycopy(arr, 0, res, 0, len);
+
+ return res;
+ }
+ }
+ else
+ return null;
+ }
+
+ /**
* Private constructor.
*/
private PlatformUtils() {
[36/41] ignite git commit: Further refactorings necessary for
platforms move to Ignite.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
deleted file mode 100644
index 7e9587f..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.platform.callback;
-
-/**
- * Platform callback utility methods. Implemented in target platform. All methods in this class must be
- * package-visible and invoked only through {@link PlatformCallbackGateway}.
- */
-public class PlatformCallbackUtils {
- /**
- * Create cache store.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- static native long cacheStoreCreate(long envPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Object pointer.
- * @param memPtr Memory pointer.
- * @param cb Callback.
- * @return Result.
- */
- static native int cacheStoreInvoke(long envPtr, long objPtr, long memPtr, Object cb);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Object pointer.
- */
- static native void cacheStoreDestroy(long envPtr, long objPtr);
-
- /**
- * Creates cache store session.
- *
- * @param envPtr Environment pointer.
- * @param storePtr Store instance pointer.
- * @return Session instance pointer.
- */
- static native long cacheStoreSessionCreate(long envPtr, long storePtr);
-
- /**
- * Creates cache entry filter and returns a pointer.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- static native long cacheEntryFilterCreate(long envPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- static native int cacheEntryFilterApply(long envPtr, long objPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Pointer.
- */
- static native void cacheEntryFilterDestroy(long envPtr, long objPtr);
-
- /**
- * Invoke cache entry processor.
- *
- * @param envPtr Environment pointer.
- * @param outMemPtr Output memory pointer.
- * @param inMemPtr Input memory pointer.
- */
- static native void cacheInvoke(long envPtr, long outMemPtr, long inMemPtr);
-
- /**
- * Perform native task map. Do not throw exceptions, serializing them to the output stream instead.
- *
- * @param envPtr Environment pointer.
- * @param taskPtr Task pointer.
- * @param outMemPtr Output memory pointer (exists if topology changed, otherwise {@code 0}).
- * @param inMemPtr Input memory pointer.
- */
- static native void computeTaskMap(long envPtr, long taskPtr, long outMemPtr, long inMemPtr);
-
- /**
- * Perform native task job result notification.
- *
- * @param envPtr Environment pointer.
- * @param taskPtr Task pointer.
- * @param jobPtr Job pointer.
- * @param memPtr Memory pointer (always zero for local job execution).
- * @return Job result enum ordinal.
- */
- static native int computeTaskJobResult(long envPtr, long taskPtr, long jobPtr, long memPtr);
-
- /**
- * Perform native task reduce.
- *
- * @param envPtr Environment pointer.
- * @param taskPtr Task pointer.
- */
- static native void computeTaskReduce(long envPtr, long taskPtr);
-
- /**
- * Complete task with native error.
- *
- * @param envPtr Environment pointer.
- * @param taskPtr Task pointer.
- * @param memPtr Memory pointer with exception data or {@code 0} in case of success.
- */
- static native void computeTaskComplete(long envPtr, long taskPtr, long memPtr);
-
- /**
- * Serialize native job.
- *
- * @param envPtr Environment pointer.
- * @param jobPtr Job pointer.
- * @param memPtr Memory pointer.
- * @return {@code True} if serialization succeeded.
- */
- static native int computeJobSerialize(long envPtr, long jobPtr, long memPtr);
-
- /**
- * Create job in native platform.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- * @return Pointer to job.
- */
- static native long computeJobCreate(long envPtr, long memPtr);
-
- /**
- * Execute native job on a node other than where it was created.
- *
- * @param envPtr Environment pointer.
- * @param jobPtr Job pointer.
- * @param cancel Cancel flag.
- * @param memPtr Memory pointer to write result to for remote job execution or {@code 0} for local job execution.
- */
- static native void computeJobExecute(long envPtr, long jobPtr, int cancel, long memPtr);
-
- /**
- * Cancel the job.
- *
- * @param envPtr Environment pointer.
- * @param jobPtr Job pointer.
- */
- static native void computeJobCancel(long envPtr, long jobPtr);
-
- /**
- * Destroy the job.
- *
- * @param envPtr Environment pointer.
- * @param ptr Pointer.
- */
- static native void computeJobDestroy(long envPtr, long ptr);
-
- /**
- * Invoke local callback.
- *
- * @param envPtr Environment pointer.
- * @param cbPtr Callback pointer.
- * @param memPtr Memory pointer.
- */
- static native void continuousQueryListenerApply(long envPtr, long cbPtr, long memPtr);
-
- /**
- * Create filter in native platform.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- * @return Pointer to created filter.
- */
- static native long continuousQueryFilterCreate(long envPtr, long memPtr);
-
- /**
- * Invoke remote filter.
- *
- * @param envPtr Environment pointer.
- * @param filterPtr Filter pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- static native int continuousQueryFilterApply(long envPtr, long filterPtr, long memPtr);
-
- /**
- * Release remote filter.
- *
- * @param envPtr Environment pointer.
- * @param filterPtr Filter pointer.
- */
- static native void continuousQueryFilterRelease(long envPtr, long filterPtr);
-
- /**
- * Notify native data streamer about topology update.
- *
- * @param envPtr Environment pointer.
- * @param ptr Data streamer native pointer.
- * @param topVer Topology version.
- * @param topSize Topology size.
- */
- static native void dataStreamerTopologyUpdate(long envPtr, long ptr, long topVer, int topSize);
-
- /**
- * Invoke stream receiver.
- *
- * @param envPtr Environment pointer.
- * @param ptr Receiver native pointer.
- * @param cache Cache object.
- * @param memPtr Stream pointer.
- * @param keepPortable Portable flag.
- */
- static native void dataStreamerStreamReceiverInvoke(long envPtr, long ptr, Object cache, long memPtr,
- boolean keepPortable);
-
- /**
- * Notify future with byte result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureByteResult(long envPtr, long futPtr, int res);
-
- /**
- * Notify future with boolean result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureBoolResult(long envPtr, long futPtr, int res);
-
- /**
- * Notify future with short result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureShortResult(long envPtr, long futPtr, int res);
-
- /**
- * Notify future with byte result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureCharResult(long envPtr, long futPtr, int res);
-
- /**
- * Notify future with int result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureIntResult(long envPtr, long futPtr, int res);
-
- /**
- * Notify future with float result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureFloatResult(long envPtr, long futPtr, float res);
-
- /**
- * Notify future with long result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureLongResult(long envPtr, long futPtr, long res);
-
- /**
- * Notify future with double result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureDoubleResult(long envPtr, long futPtr, double res);
-
- /**
- * Notify future with object result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param memPtr Memory pointer.
- */
- static native void futureObjectResult(long envPtr, long futPtr, long memPtr);
-
- /**
- * Notify future with null result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- */
- static native void futureNullResult(long envPtr, long futPtr);
-
- /**
- * Notify future with error.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param memPtr Pointer to memory with error information.
- */
- static native void futureError(long envPtr, long futPtr, long memPtr);
-
- /**
- * Creates message filter and returns a pointer.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- static native long messagingFilterCreate(long envPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- static native int messagingFilterApply(long envPtr, long objPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Pointer.
- */
- static native void messagingFilterDestroy(long envPtr, long objPtr);
-
- /**
- * Creates event filter and returns a pointer.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- static native long eventFilterCreate(long envPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- static native int eventFilterApply(long envPtr, long objPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Pointer.
- */
- static native void eventFilterDestroy(long envPtr, long objPtr);
-
- /**
- * Sends node info to native target.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Ptr to a stream with serialized node.
- */
- static native void nodeInfo(long envPtr, long memPtr);
-
- /**
- * Kernal start callback.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- */
- static native void onStart(long envPtr, long memPtr);
-
- /*
- * Kernal stop callback.
- *
- * @param envPtr Environment pointer.
- */
- static native void onStop(long envPtr);
-
- /**
- * Lifecycle event callback.
- *
- * @param envPtr Environment pointer.
- * @param ptr Holder pointer.
- * @param evt Event.
- */
- static native void lifecycleEvent(long envPtr, long ptr, int evt);
-
- /**
- * Re-allocate external memory chunk.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Cross-platform pointer.
- * @param cap Capacity.
- */
- static native void memoryReallocate(long envPtr, long memPtr, int cap);
-
- /**
- * Initializes native service.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Stream pointer.
- * @return Pointer to the native platform service.
- */
- static native long serviceInit(long envPtr, long memPtr);
-
- /**
- * Executes native service.
- *
- * @param envPtr Environment pointer.
- * @param svcPtr Pointer to the service in the native platform.
- * @param memPtr Stream pointer.
- */
- static native void serviceExecute(long envPtr, long svcPtr, long memPtr);
-
- /**
- * Cancels native service.
- *
- * @param envPtr Environment pointer.
- * @param svcPtr Pointer to the service in the native platform.
- * @param memPtr Stream pointer.
- */
- static native void serviceCancel(long envPtr, long svcPtr, long memPtr);
-
- /**
- /**
- * Invokes service method.
- *
- * @param envPtr Environment pointer.
- * @param svcPtr Pointer to the service in the native platform.
- * @param outMemPtr Output memory pointer.
- * @param inMemPtr Input memory pointer.
- */
- static native void serviceInvokeMethod(long envPtr, long svcPtr, long outMemPtr, long inMemPtr);
-
- /**
- * Invokes cluster node filter.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Stream pointer.
- */
- static native int clusterNodeFilterApply(long envPtr, long memPtr);
-
- /**
- * Private constructor.
- */
- private PlatformCallbackUtils() {
- // No-op.
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
deleted file mode 100644
index 9273e29..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.platform.memory;
-
-import org.apache.ignite.internal.portable.streams.*;
-
-/**
- * Interop output stream,
- */
-public interface PlatformInputStream extends PortableInputStream {
- /**
- * Synchronize input. Must be called before start reading data from a memory changed by another platform.
- */
- public void synchronize();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemory.java
deleted file mode 100644
index 9d8f94e..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.platform.memory;
-
-/**
- * Interop memory chunk.
- */
-public interface PlatformMemory extends AutoCloseable {
- /**
- * Gets input stream.
- *
- * @return Input stream.
- */
- public PlatformInputStream input();
-
- /**
- * Gets output stream.
- *
- * @return Output stream.
- */
- public PlatformOutputStream output();
-
- /**
- * Gets pointer which can be passed between platforms.
- *
- * @return Pointer.
- */
- public long pointer();
-
- /**
- * Gets data pointer.
- *
- * @return Data pointer.
- */
- public long data();
-
- /**
- * Gets capacity.
- *
- * @return Capacity.
- */
- public int capacity();
-
- /**
- * Gets length.
- *
- * @return Length.
- */
- public int length();
-
- /**
- * Reallocate memory chunk.
- *
- * @param cap Minimum capacity.
- */
- public void reallocate(int cap);
-
- /**
- * Close memory releasing it.
- */
- @Override void close();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManager.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManager.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManager.java
deleted file mode 100644
index c2233a8..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManager.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.platform.memory;
-
-/**
- * Interop memory manager interface.
- */
-public interface PlatformMemoryManager {
- /**
- * Allocates memory.
- *
- * @return Memory.
- */
- public PlatformMemory allocate();
-
- /**
- * Allocates memory having at least the given capacity.
- *
- * @param cap Minimum capacity.
- * @return Memory.
- */
- public PlatformMemory allocate(int cap);
-
- /**
- * Gets memory from existing pointer.
- *
- * @param memPtr Cross-platform memory pointer.
- * @return Memory.
- */
- public PlatformMemory get(long memPtr);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
deleted file mode 100644
index eb2490a..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.platform.memory;
-
-import org.apache.ignite.internal.portable.streams.*;
-
-/**
- * Interop output stream.
- */
-public interface PlatformOutputStream extends PortableOutputStream {
- /**
- * Synchronize output stream with underlying memory
- */
- public void synchronize();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index 66e87e2..f82fb0f 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.platform.utils;
import org.apache.ignite.*;
import org.apache.ignite.cache.*;
+import org.apache.ignite.internal.*;
import org.apache.ignite.internal.portable.*;
import org.apache.ignite.internal.processors.platform.*;
import org.apache.ignite.internal.processors.platform.memory.*;
@@ -577,6 +578,28 @@ public class PlatformUtils {
}
/**
+ * Get GridGain platform processor.
+ *
+ * @param grid Ignite instance.
+ * @return Platform processor.
+ */
+ public static PlatformProcessor platformProcessor(Ignite grid) {
+ GridKernalContext ctx = ((IgniteKernal) grid).context();
+
+ return ctx.platform();
+ }
+
+ /**
+ * Gets interop context for the grid.
+ *
+ * @param grid Grid
+ * @return Context.
+ */
+ public static PlatformContext platformContext(Ignite grid) {
+ return platformProcessor(grid).context();
+ }
+
+ /**
* Private constructor.
*/
private PlatformUtils() {
[21/41] ignite git commit: Moved InteropTarget interface to Ignite.
Posted by sb...@apache.org.
Moved InteropTarget interface to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/93821183
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/93821183
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/93821183
Branch: refs/heads/ignite-1093
Commit: 93821183ae44cf1b1d0fd5c3ed30b65f611d2da6
Parents: a43e80a
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 13:19:25 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 13:19:25 2015 +0300
----------------------------------------------------------------------
.../processors/platform/PlatformTarget.java | 76 ++++++++++++++++++++
1 file changed, 76 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/93821183/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java
new file mode 100644
index 0000000..1d54b4e
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform;
+
+import org.jetbrains.annotations.*;
+
+/**
+ * Interop target abstraction.
+ */
+@SuppressWarnings("UnusedDeclaration")
+public interface PlatformTarget {
+ /**
+ * Synchronous IN operation.
+ *
+ * @param type Operation type.
+ * @param memPtr Memory pointer.
+ * @return Value specific for the given operation otherwise.
+ * @throws Exception If failed.
+ */
+ public int inOp(int type, long memPtr) throws Exception;
+
+ /**
+ * Synchronous IN operation which returns managed object as result.
+ *
+ * @param type Operation type.
+ * @param memPtr Memory pointer.
+ * @return Managed result.
+ * @throws Exception If case of failure.
+ */
+ public Object inOpObject(int type, long memPtr) throws Exception;
+
+ /**
+ * Synchronous OUT operation.
+ *
+ * @param type Operation type.
+ * @param memPtr Memory pointer.
+ * @throws Exception In case of failure.
+ */
+ public void outOp(int type, long memPtr) throws Exception;
+
+ /**
+ * Synchronous IN-OUT operation.
+ *
+ * @param type Operation type.
+ * @param inMemPtr Input memory pointer.
+ * @param outMemPtr Output memory pointer.
+ * @throws Exception In case of failure.
+ */
+ public void inOutOp(int type, long inMemPtr, long outMemPtr) throws Exception;
+
+ /**
+ * Synchronous IN-OUT operation with optional argument.
+ *
+ * @param type Operation type.
+ * @param inMemPtr Input memory pointer.
+ * @param outMemPtr Output memory pointer.
+ * @param arg Argument (optional).
+ * @throws Exception In case of failure.
+ */
+ public void inOutOp(int type, long inMemPtr, long outMemPtr, @Nullable Object arg) throws Exception;
+}
[28/41] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/824cfa4b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/824cfa4b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/824cfa4b
Branch: refs/heads/ignite-1093
Commit: 824cfa4b59d538eee5b3d53fb4af4c41e8412038
Parents: 8529e10 c9a5340
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 15:44:09 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 15:44:09 2015 +0300
----------------------------------------------------------------------
.../processors/cache/IgniteCacheManyAsyncOperationsTest.java | 2 +-
.../java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
[26/41] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c9a5340e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c9a5340e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c9a5340e
Branch: refs/heads/ignite-1093
Commit: c9a5340e0e6a261f68bf352dfce27853d6125239
Parents: 7ad43fc 975f47e
Author: sboikov <sb...@gridgain.com>
Authored: Wed Aug 26 15:41:48 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Aug 26 15:41:48 2015 +0300
----------------------------------------------------------------------
.../internal/portable/PortableContext.java | 1 -
.../internal/processors/igfs/IgfsProcessor.java | 8 -
.../processors/igfs/IgfsAbstractSelfTest.java | 34 +-
.../igfs/IgfsBackupFailoverSelfTest.java | 488 ++++++++++++++++
.../igfs/IgfsBackupsDualAsyncSelfTest.java | 40 ++
.../igfs/IgfsBackupsDualSyncSelfTest.java | 40 ++
.../igfs/IgfsBackupsPrimarySelfTest.java | 40 ++
.../ignite/testsuites/IgniteIgfsTestSuite.java | 7 +
.../Apache.Ignite.Core.csproj | 3 +
.../Apache.Ignite.Core/Impl/Handle/Handle.cs | 69 +++
.../Impl/Handle/HandleRegistry.cs | 340 +++++++++++
.../Apache.Ignite.Core/Impl/Handle/IHandle.cs | 35 ++
.../platform/PlatformAbstractBootstrap.java | 1 +
.../platform/PlatformAbstractTarget.java | 276 +++++++++
.../processors/platform/PlatformContext.java | 114 ++++
.../platform/PlatformExtendedException.java | 39 ++
.../processors/platform/PlatformTarget.java | 76 +++
.../lifecycle/PlatformLifecycleBean.java | 72 +++
.../transactions/PlatformTransactions.java | 255 ++++++++
.../platform/utils/PlatformFutureUtils.java | 326 +++++++++++
.../platform/utils/PlatformUtils.java | 585 +++++++++++++++++++
parent/pom.xml | 1 +
22 files changed, 2835 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
[16/41] ignite git commit: IGNITE-1303: Created PlatformContext
abstraction.
Posted by sb...@apache.org.
IGNITE-1303: Created PlatformContext abstraction.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/08be80ff
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/08be80ff
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/08be80ff
Branch: refs/heads/ignite-1093
Commit: 08be80ffee4b24506802cb22130903cb1e749873
Parents: ed974f3
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 12:05:51 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 12:05:51 2015 +0300
----------------------------------------------------------------------
.../processors/platform/PlatformContext.java | 107 +++++++++++++++++++
1 file changed, 107 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/08be80ff/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
new file mode 100644
index 0000000..0385f46
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform;
+
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.platform.callback.*;
+import org.apache.ignite.internal.processors.platform.memory.*;
+
+import java.util.*;
+
+/**
+ * Platform context. Acts as an entry point for platform operations.
+ */
+public interface PlatformContext {
+ /**
+ * Gets kernal context.
+ *
+ * @return Kernal context.
+ */
+ public GridKernalContext kernalContext();
+
+ /**
+ * Gets platform memory manager.
+ *
+ * @return Memory manager.
+ */
+ public PlatformMemoryManager memory();
+
+ /**
+ * Gets platform callback gateway.
+ *
+ * @return Callback gateway.
+ */
+ public PlatformCallbackGateway gateway();
+
+ /**
+ * Get memory reader.
+ *
+ * @param mem Memory.
+ * @return Reader.
+ */
+ public PortableRawReaderEx reader(PlatformMemory mem);
+
+ /**
+ * Get memory reader.
+ *
+ * @param in Input.
+ * @return Reader.
+ */
+ public PortableRawReaderEx reader(PlatformInputStream in);
+
+ /**
+ * Get memory writer.
+ *
+ * @param mem Memory.
+ * @return Writer.
+ */
+ public PortableRawWriterEx writer(PlatformMemory mem);
+
+ /**
+ * Get memory writer.
+ *
+ * @param out Output.
+ * @return Writer.
+ */
+ public PortableRawWriterEx writer(PlatformOutputStream out);
+
+ /**
+ * Sends node info to native platform, if necessary.
+ *
+ * @param node Node.
+ */
+ public void addNode(ClusterNode node);
+
+ /**
+ * Writes a node id to a stream and sends node info to native platform, if necessary.
+ *
+ * @param writer Writer.
+ * @param node Node.
+ */
+ public void writeNode(PortableRawWriterEx writer, ClusterNode node);
+
+ /**
+ * Writes multiple node ids to a stream and sends node info to native platform, if necessary.
+ *
+ * @param writer Writer.
+ * @param nodes Nodes.
+ */
+ public void writeNodes(PortableRawWriterEx writer, Collection<ClusterNode> nodes);
+}
[09/41] ignite git commit: Moving platform classes to
"...internal.processors..." package to follow Ignite common approach.
Posted by sb...@apache.org.
Moving platform classes to "...internal.processors..." package to follow Ignite common approach.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2225f8d2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2225f8d2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2225f8d2
Branch: refs/heads/ignite-1093
Commit: 2225f8d2aeb8836ad2bf0573584b3affd7b4aecc
Parents: c47a706
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 09:36:44 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 09:36:44 2015 +0300
----------------------------------------------------------------------
.../internal/platform/PlatformBootstrap.java | 36 -
.../platform/PlatformBootstrapFactory.java | 37 -
.../internal/platform/PlatformException.java | 71 --
.../internal/platform/PlatformIgnition.java | 187 ----
.../platform/PlatformNoCallbackException.java | 50 --
.../callback/PlatformCallbackGateway.java | 869 -------------------
.../callback/PlatformCallbackUtils.java | 468 ----------
.../platform/memory/PlatformAbstractMemory.java | 121 ---
.../PlatformBigEndianInputStreamImpl.java | 126 ---
.../PlatformBigEndianOutputStreamImpl.java | 162 ----
.../platform/memory/PlatformExternalMemory.java | 55 --
.../platform/memory/PlatformInputStream.java | 30 -
.../memory/PlatformInputStreamImpl.java | 323 -------
.../platform/memory/PlatformMemory.java | 77 --
.../platform/memory/PlatformMemoryManager.java | 46 -
.../memory/PlatformMemoryManagerImpl.java | 83 --
.../platform/memory/PlatformMemoryPool.java | 133 ---
.../platform/memory/PlatformMemoryUtils.java | 468 ----------
.../platform/memory/PlatformOutputStream.java | 30 -
.../memory/PlatformOutputStreamImpl.java | 259 ------
.../platform/memory/PlatformPooledMemory.java | 63 --
.../platform/memory/PlatformUnpooledMemory.java | 51 --
.../platform/utils/PlatformReaderBiClosure.java | 34 -
.../platform/utils/PlatformReaderClosure.java | 34 -
.../platform/utils/PlatformWriterBiClosure.java | 34 -
.../platform/utils/PlatformWriterClosure.java | 33 -
.../processors/platform/PlatformBootstrap.java | 36 +
.../platform/PlatformBootstrapFactory.java | 37 +
.../processors/platform/PlatformException.java | 71 ++
.../processors/platform/PlatformIgnition.java | 186 ++++
.../platform/PlatformNoCallbackException.java | 50 ++
.../callback/PlatformCallbackGateway.java | 869 +++++++++++++++++++
.../callback/PlatformCallbackUtils.java | 468 ++++++++++
.../platform/memory/PlatformAbstractMemory.java | 121 +++
.../PlatformBigEndianInputStreamImpl.java | 126 +++
.../PlatformBigEndianOutputStreamImpl.java | 162 ++++
.../platform/memory/PlatformExternalMemory.java | 55 ++
.../platform/memory/PlatformInputStream.java | 30 +
.../memory/PlatformInputStreamImpl.java | 323 +++++++
.../platform/memory/PlatformMemory.java | 77 ++
.../platform/memory/PlatformMemoryManager.java | 46 +
.../memory/PlatformMemoryManagerImpl.java | 83 ++
.../platform/memory/PlatformMemoryPool.java | 133 +++
.../platform/memory/PlatformMemoryUtils.java | 468 ++++++++++
.../platform/memory/PlatformOutputStream.java | 30 +
.../memory/PlatformOutputStreamImpl.java | 259 ++++++
.../platform/memory/PlatformPooledMemory.java | 63 ++
.../platform/memory/PlatformUnpooledMemory.java | 51 ++
.../platform/utils/PlatformReaderBiClosure.java | 34 +
.../platform/utils/PlatformReaderClosure.java | 34 +
.../platform/utils/PlatformWriterBiClosure.java | 34 +
.../platform/utils/PlatformWriterClosure.java | 33 +
52 files changed, 3879 insertions(+), 3880 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformBootstrap.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformBootstrap.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformBootstrap.java
deleted file mode 100644
index faee665..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformBootstrap.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform;
-
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.processors.platform.*;
-
-/**
- * Platform bootstrap. Responsible for starting Ignite node with non-Java platform.
- */
-public interface PlatformBootstrap {
- /**
- * Start Ignite node.
- *
- * @param cfg Configuration.
- * @param envPtr Environment pointer.
- * @param dataPtr Optional pointer to additional data required for startup.
- * @return Platform processor.
- */
- public PlatformProcessor start(IgniteConfiguration cfg, long envPtr, long dataPtr);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformBootstrapFactory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformBootstrapFactory.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformBootstrapFactory.java
deleted file mode 100644
index 31d1ca5..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformBootstrapFactory.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform;
-
-/**
- * Platform bootstrap factory.
- */
-public interface PlatformBootstrapFactory {
- /**
- * Get bootstrap factory ID.
- *
- * @return ID.
- */
- public int id();
-
- /**
- * Create bootstrap instance.
- *
- * @return Bootstrap instance.
- */
- public PlatformBootstrap create();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformException.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformException.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformException.java
deleted file mode 100644
index d0bf565..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformException.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
-
-/**
- * Interop checked exception.
- */
-public class PlatformException extends IgniteCheckedException {
- /** */
- private static final long serialVersionUID = 0L;
-
- /**
- * Create empty exception.
- */
- public PlatformException() {
- // No-op.
- }
-
- /**
- * Creates new exception with given error message.
- *
- * @param msg Error message.
- */
- public PlatformException(String msg) {
- super(msg);
- }
-
- /**
- * Creates new grid exception with given throwable as a cause and
- * source of error message.
- *
- * @param cause Non-null throwable cause.
- */
- public PlatformException(Throwable cause) {
- this(cause.getMessage(), cause);
- }
-
- /**
- * Creates new exception with given error message and optional nested exception.
- *
- * @param msg Error message.
- * @param cause Optional nested exception (can be {@code null}).
- */
- public PlatformException(String msg, @Nullable Throwable cause) {
- super(msg, cause);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(PlatformException.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformIgnition.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformIgnition.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformIgnition.java
deleted file mode 100644
index 2d31307..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformIgnition.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform;
-
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.platform.*;
-import org.apache.ignite.internal.processors.resource.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
-import org.jetbrains.annotations.*;
-
-import java.net.*;
-import java.security.*;
-import java.util.*;
-
-/**
- * Entry point for platform nodes.
- */
-@SuppressWarnings("UnusedDeclaration")
-public class PlatformIgnition {
- /** Map with active instances. */
- private static final HashMap<String, PlatformProcessor> instances = new HashMap<>();
-
- /**
- * Start Ignite node in platform mode.
- *
- * @param springCfgPath Spring configuration path.
- * @param gridName Grid name.
- * @param factoryId Factory ID.
- * @param envPtr Environment pointer.
- * @param dataPtr Optional pointer to additional data required for startup.
- * @return Ignite instance.
- */
- public static synchronized PlatformProcessor start(@Nullable String springCfgPath, @Nullable String gridName,
- int factoryId, long envPtr, long dataPtr) {
- if (envPtr <= 0)
- throw new IgniteException("Environment pointer must be positive.");
-
- ClassLoader oldClsLdr = Thread.currentThread().getContextClassLoader();
-
- Thread.currentThread().setContextClassLoader(PlatformProcessor.class.getClassLoader());
-
- try {
- IgniteConfiguration cfg = configuration(springCfgPath);
-
- if (gridName != null)
- cfg.setGridName(gridName);
- else
- gridName = cfg.getGridName();
-
- PlatformBootstrap bootstrap = bootstrap(factoryId);
-
- PlatformProcessor proc = bootstrap.start(cfg, envPtr, dataPtr);
-
- PlatformProcessor old = instances.put(gridName, proc);
-
- assert old == null;
-
- return proc;
- }
- finally {
- Thread.currentThread().setContextClassLoader(oldClsLdr);
- }
- }
-
- /**
- * Get instance by environment pointer.
- *
- * @param gridName Grid name.
- * @return Instance or {@code null} if it doesn't exist (never started or stopped).
- */
- @Nullable public static synchronized PlatformProcessor instance(@Nullable String gridName) {
- return instances.get(gridName);
- }
-
- /**
- * Get environment pointer of the given instance.
- *
- * @param gridName Grid name.
- * @return Environment pointer or {@code 0} in case grid with such name doesn't exist.
- */
- public static synchronized long environmentPointer(@Nullable String gridName) {
- PlatformProcessor proc = instance(gridName);
-
- return proc != null ? proc.environmentPointer() : 0;
- }
-
- /**
- * Stop single instance.
- *
- * @param gridName Grid name,
- * @param cancel Cancel flag.
- * @return {@code True} if instance was found and stopped.
- */
- public static synchronized boolean stop(@Nullable String gridName, boolean cancel) {
- if (Ignition.stop(gridName, cancel)) {
- PlatformProcessor old = instances.remove(gridName);
-
- assert old != null;
-
- return true;
- }
- else
- return false;
- }
-
- /**
- * Stop all instances.
- *
- * @param cancel Cancel flag.
- */
- public static synchronized void stopAll(boolean cancel) {
- for (PlatformProcessor proc : instances.values())
- Ignition.stop(proc.ignite().name(), cancel);
-
- instances.clear();
- }
-
- /**
- * Create configuration.
- *
- * @param springCfgPath Path to Spring XML.
- * @return Configuration.
- */
- private static IgniteConfiguration configuration(@Nullable String springCfgPath) {
- try {
- URL url = springCfgPath == null ? U.resolveIgniteUrl(IgnitionEx.DFLT_CFG) :
- U.resolveSpringUrl(springCfgPath);
-
- IgniteBiTuple<IgniteConfiguration, GridSpringResourceContext> t = IgnitionEx.loadConfiguration(url);
-
- return t.get1();
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to instantiate configuration from Spring XML: " + springCfgPath, e);
- }
- }
-
- /**
- * Create bootstrap for the given factory ID.
- *
- * @param factoryId Factory ID.
- * @return Bootstrap.
- */
- private static PlatformBootstrap bootstrap(final int factoryId) {
- PlatformBootstrapFactory factory = AccessController.doPrivileged(
- new PrivilegedAction<PlatformBootstrapFactory>() {
- @Override public PlatformBootstrapFactory run() {
- for (PlatformBootstrapFactory factory : ServiceLoader.load(PlatformBootstrapFactory.class)) {
- if (factory.id() == factoryId)
- return factory;
- }
-
- return null;
- }
- });
-
- if (factory == null)
- throw new IgniteException("Interop factory is not found (did you put into the classpath?): " + factoryId);
-
- return factory.create();
- }
-
- /**
- * Private constructor.
- */
- private PlatformIgnition() {
- // No-op.
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformNoCallbackException.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformNoCallbackException.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformNoCallbackException.java
deleted file mode 100644
index 893c332..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformNoCallbackException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform;
-
-import org.apache.ignite.internal.util.typedef.internal.*;
-
-/**
- * Exception raised when interop callback is not set in native platform.
- */
-@SuppressWarnings("UnusedDeclaration")
-public class PlatformNoCallbackException extends PlatformException {
- /** */
- private static final long serialVersionUID = 0L;
-
- /**
- * Constructor.
- */
- public PlatformNoCallbackException() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param msg Message.
- */
- public PlatformNoCallbackException(String msg) {
- super(msg);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(PlatformNoCallbackException.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/callback/PlatformCallbackGateway.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/callback/PlatformCallbackGateway.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/callback/PlatformCallbackGateway.java
deleted file mode 100644
index d565c00..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/callback/PlatformCallbackGateway.java
+++ /dev/null
@@ -1,869 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.callback;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.util.*;
-
-/**
- * Gateway to all platform-dependent callbacks. Implementers might extend this class and provide additional callbacks.
- */
-@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
-public class PlatformCallbackGateway {
- /** Environment pointer. */
- protected final long envPtr;
-
- /** Lock. */
- private final GridSpinReadWriteLock lock = new GridSpinReadWriteLock();
-
- /**
- * Native gateway.
- *
- * @param envPtr Environment pointer.
- */
- public PlatformCallbackGateway(long envPtr) {
- this.envPtr = envPtr;
- }
-
- /**
- * Get environment pointer.
- *
- * @return Environment pointer.
- */
- public long environmentPointer() {
- return envPtr;
- }
-
- /**
- * Create cache store.
- *
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- public long cacheStoreCreate(long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.cacheStoreCreate(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param objPtr Object pointer.
- * @param memPtr Memory pointer.
- * @param cb Callback.
- * @return Result.
- */
- public int cacheStoreInvoke(long objPtr, long memPtr, Object cb) {
- enter();
-
- try {
- return PlatformCallbackUtils.cacheStoreInvoke(envPtr, objPtr, memPtr, cb);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param objPtr Object pointer.
- */
- public void cacheStoreDestroy(long objPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.cacheStoreDestroy(envPtr, objPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Creates cache store session.
- *
- * @param storePtr Store instance pointer.
- * @return Session instance pointer.
- */
- public long cacheStoreSessionCreate(long storePtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.cacheStoreSessionCreate(envPtr, storePtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Creates cache entry filter and returns a pointer.
- *
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- public long cacheEntryFilterCreate(long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.cacheEntryFilterCreate(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param ptr Pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- public int cacheEntryFilterApply(long ptr, long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.cacheEntryFilterApply(envPtr, ptr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param ptr Pointer.
- */
- public void cacheEntryFilterDestroy(long ptr) {
- enter();
-
- try {
- PlatformCallbackUtils.cacheEntryFilterDestroy(envPtr, ptr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Invoke cache entry processor.
- *
- * @param outMemPtr Output memory pointer.
- * @param inMemPtr Input memory pointer.
- */
- public void cacheInvoke(long outMemPtr, long inMemPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.cacheInvoke(envPtr, outMemPtr, inMemPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Perform native task map. Do not throw exceptions, serializing them to the output stream instead.
- *
- * @param taskPtr Task pointer.
- * @param outMemPtr Output memory pointer (exists if topology changed, otherwise {@code 0}).
- * @param inMemPtr Input memory pointer.
- */
- public void computeTaskMap(long taskPtr, long outMemPtr, long inMemPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.computeTaskMap(envPtr, taskPtr, outMemPtr, inMemPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Perform native task job result notification.
- *
- * @param taskPtr Task pointer.
- * @param jobPtr Job pointer.
- * @param memPtr Memory pointer (always zero for local job execution).
- * @return Job result enum ordinal.
- */
- public int computeTaskJobResult(long taskPtr, long jobPtr, long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.computeTaskJobResult(envPtr, taskPtr, jobPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Perform native task reduce.
- *
- * @param taskPtr Task pointer.
- */
- public void computeTaskReduce(long taskPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.computeTaskReduce(envPtr, taskPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Complete task with native error.
- *
- * @param taskPtr Task pointer.
- * @param memPtr Memory pointer with exception data or {@code 0} in case of success.
- */
- public void computeTaskComplete(long taskPtr, long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.computeTaskComplete(envPtr, taskPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Serialize native job.
- *
- * @param jobPtr Job pointer.
- * @param memPtr Memory pointer.
- * @return {@code True} if serialization succeeded.
- */
- public int computeJobSerialize(long jobPtr, long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.computeJobSerialize(envPtr, jobPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Create job in native platform.
- *
- * @param memPtr Memory pointer.
- * @return Pointer to job.
- */
- public long computeJobCreate(long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.computeJobCreate(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Execute native job on a node other than where it was created.
- *
- * @param jobPtr Job pointer.
- * @param cancel Cancel flag.
- * @param memPtr Memory pointer to write result to for remote job execution or {@code 0} for local job execution.
- */
- public void computeJobExecute(long jobPtr, int cancel, long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.computeJobExecute(envPtr, jobPtr, cancel, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Cancel the job.
- *
- * @param jobPtr Job pointer.
- */
- public void computeJobCancel(long jobPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.computeJobCancel(envPtr, jobPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Destroy the job.
- *
- * @param ptr Pointer.
- */
- public void computeJobDestroy(long ptr) {
- enter();
-
- try {
- PlatformCallbackUtils.computeJobDestroy(envPtr, ptr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Invoke local callback.
- *
- * @param cbPtr Callback pointer.
- * @param memPtr Memory pointer.
- */
- public void continuousQueryListenerApply(long cbPtr, long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.continuousQueryListenerApply(envPtr, cbPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Create filter in native platform.
- *
- * @param memPtr Memory pointer.
- * @return Pointer to created filter.
- */
- public long continuousQueryFilterCreate(long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.continuousQueryFilterCreate(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Invoke remote filter.
- *
- * @param filterPtr Filter pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- public int continuousQueryFilterApply(long filterPtr, long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.continuousQueryFilterApply(envPtr, filterPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Release remote filter.
- *
- * @param filterPtr Filter pointer.
- */
- public void continuousQueryFilterRelease(long filterPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.continuousQueryFilterRelease(envPtr, filterPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify native data streamer about topology update.
- *
- * @param ptr Data streamer native pointer.
- * @param topVer Topology version.
- * @param topSize Topology size.
- */
- public void dataStreamerTopologyUpdate(long ptr, long topVer, int topSize) {
- enter();
-
- try {
- PlatformCallbackUtils.dataStreamerTopologyUpdate(envPtr, ptr, topVer, topSize);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Invoke stream receiver.
- *
- * @param ptr Receiver native pointer.
- * @param cache Cache object.
- * @param memPtr Stream pointer.
- * @param keepPortable Portable flag.
- */
- public void dataStreamerStreamReceiverInvoke(long ptr, Object cache, long memPtr, boolean keepPortable) {
- enter();
-
- try {
- PlatformCallbackUtils.dataStreamerStreamReceiverInvoke(envPtr, ptr, cache, memPtr, keepPortable);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with byte result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureByteResult(long futPtr, int res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureByteResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with boolean result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureBoolResult(long futPtr, int res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureBoolResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with short result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureShortResult(long futPtr, int res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureShortResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with byte result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureCharResult(long futPtr, int res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureCharResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with int result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureIntResult(long futPtr, int res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureIntResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with float result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureFloatResult(long futPtr, float res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureFloatResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with long result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureLongResult(long futPtr, long res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureLongResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with double result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureDoubleResult(long futPtr, double res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureDoubleResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with object result.
- *
- * @param futPtr Future pointer.
- * @param memPtr Memory pointer.
- */
- public void futureObjectResult(long futPtr, long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.futureObjectResult(envPtr, futPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with null result.
- *
- * @param futPtr Future pointer.
- */
- public void futureNullResult(long futPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.futureNullResult(envPtr, futPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with error.
- *
- * @param futPtr Future pointer.
- * @param memPtr Pointer to memory with error information.
- */
- public void futureError(long futPtr, long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.futureError(envPtr, futPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Creates message filter and returns a pointer.
- *
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- public long messagingFilterCreate(long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.messagingFilterCreate(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param ptr Pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- public int messagingFilterApply(long ptr, long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.messagingFilterApply(envPtr, ptr, memPtr);
- }
- finally {
- leave();
- }}
-
- /**
- * @param ptr Pointer.
- */
- public void messagingFilterDestroy(long ptr) {
- enter();
-
- try {
- PlatformCallbackUtils.messagingFilterDestroy(envPtr, ptr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Creates event filter and returns a pointer.
- *
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- public long eventFilterCreate(long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.eventFilterCreate(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param ptr Pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- public int eventFilterApply(long ptr, long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.eventFilterApply(envPtr, ptr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param ptr Pointer.
- */
- public void eventFilterDestroy(long ptr) {
- enter();
-
- try {
- PlatformCallbackUtils.eventFilterDestroy(envPtr, ptr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Sends node info to native target.
- *
- * @param memPtr Ptr to a stream with serialized node.
- */
- public void nodeInfo(long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.nodeInfo(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Kernal start callback.
- *
- * @param memPtr Memory pointer.
- */
- public void onStart(long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.onStart(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Lifecycle event callback.
- *
- * @param ptr Holder pointer.
- * @param evt Event.
- */
- public void lifecycleEvent(long ptr, int evt) {
- enter();
-
- try {
- PlatformCallbackUtils.lifecycleEvent(envPtr, ptr, evt);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Re-allocate external memory chunk.
- *
- * @param memPtr Cross-platform pointer.
- * @param cap Capacity.
- */
- public void memoryReallocate(long memPtr, int cap) {
- enter();
-
- try {
- PlatformCallbackUtils.memoryReallocate(envPtr, memPtr, cap);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Initializes native service.
- *
- * @param memPtr Pointer.
- * @throws org.apache.ignite.IgniteCheckedException In case of error.
- */
- public long serviceInit(long memPtr) throws IgniteCheckedException {
- return PlatformCallbackUtils.serviceInit(envPtr, memPtr);
- }
-
- /**
- * Executes native service.
- *
- * @param svcPtr Pointer to the service in the native platform.
- * @param memPtr Stream pointer.
- * @throws org.apache.ignite.IgniteCheckedException In case of error.
- */
- public void serviceExecute(long svcPtr, long memPtr) throws IgniteCheckedException {
- PlatformCallbackUtils.serviceExecute(envPtr, svcPtr, memPtr);
- }
-
- /**
- * Cancels native service.
- *
- * @param svcPtr Pointer to the service in the native platform.
- * @param memPtr Stream pointer.
- * @throws org.apache.ignite.IgniteCheckedException In case of error.
- */
- public void serviceCancel(long svcPtr, long memPtr) throws IgniteCheckedException {
- PlatformCallbackUtils.serviceCancel(envPtr, svcPtr, memPtr);
- }
-
- /**
- * Invokes service method.
- *
- * @param svcPtr Pointer to the service in the native platform.
- * @param outMemPtr Output memory pointer.
- * @param inMemPtr Input memory pointer.
- * @throws org.apache.ignite.IgniteCheckedException In case of error.
- */
- public void serviceInvokeMethod(long svcPtr, long outMemPtr, long inMemPtr) throws IgniteCheckedException {
- PlatformCallbackUtils.serviceInvokeMethod(envPtr, svcPtr, outMemPtr, inMemPtr);
- }
-
- /**
- * Invokes cluster node filter.
- *
- * @param memPtr Stream pointer.
- */
- public int clusterNodeFilterApply(long memPtr) {
- return PlatformCallbackUtils.clusterNodeFilterApply(envPtr, memPtr);
- }
-
- /**
- * Kernal stop callback.
- */
- public void onStop() {
- block();
-
- PlatformCallbackUtils.onStop(envPtr);
- }
-
- /**
- * Enter gateway.
- */
- protected void enter() {
- if (!lock.tryReadLock())
- throw new IgniteException("Failed to execute native callback because grid is stopping.");
- }
-
- /**
- * Leave gateway.
- */
- protected void leave() {
- lock.readUnlock();
- }
-
- /**
- * Block gateway.
- */
- protected void block() {
- lock.writeLock();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/callback/PlatformCallbackUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/callback/PlatformCallbackUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/callback/PlatformCallbackUtils.java
deleted file mode 100644
index d81ce68..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/callback/PlatformCallbackUtils.java
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.callback;
-
-/**
- * Platform callback utility methods. Implemented in target platform. All methods in this class must be
- * package-visible and invoked only through {@link PlatformCallbackGateway}.
- */
-public class PlatformCallbackUtils {
- /**
- * Create cache store.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- static native long cacheStoreCreate(long envPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Object pointer.
- * @param memPtr Memory pointer.
- * @param cb Callback.
- * @return Result.
- */
- static native int cacheStoreInvoke(long envPtr, long objPtr, long memPtr, Object cb);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Object pointer.
- */
- static native void cacheStoreDestroy(long envPtr, long objPtr);
-
- /**
- * Creates cache store session.
- *
- * @param envPtr Environment pointer.
- * @param storePtr Store instance pointer.
- * @return Session instance pointer.
- */
- static native long cacheStoreSessionCreate(long envPtr, long storePtr);
-
- /**
- * Creates cache entry filter and returns a pointer.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- static native long cacheEntryFilterCreate(long envPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- static native int cacheEntryFilterApply(long envPtr, long objPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Pointer.
- */
- static native void cacheEntryFilterDestroy(long envPtr, long objPtr);
-
- /**
- * Invoke cache entry processor.
- *
- * @param envPtr Environment pointer.
- * @param outMemPtr Output memory pointer.
- * @param inMemPtr Input memory pointer.
- */
- static native void cacheInvoke(long envPtr, long outMemPtr, long inMemPtr);
-
- /**
- * Perform native task map. Do not throw exceptions, serializing them to the output stream instead.
- *
- * @param envPtr Environment pointer.
- * @param taskPtr Task pointer.
- * @param outMemPtr Output memory pointer (exists if topology changed, otherwise {@code 0}).
- * @param inMemPtr Input memory pointer.
- */
- static native void computeTaskMap(long envPtr, long taskPtr, long outMemPtr, long inMemPtr);
-
- /**
- * Perform native task job result notification.
- *
- * @param envPtr Environment pointer.
- * @param taskPtr Task pointer.
- * @param jobPtr Job pointer.
- * @param memPtr Memory pointer (always zero for local job execution).
- * @return Job result enum ordinal.
- */
- static native int computeTaskJobResult(long envPtr, long taskPtr, long jobPtr, long memPtr);
-
- /**
- * Perform native task reduce.
- *
- * @param envPtr Environment pointer.
- * @param taskPtr Task pointer.
- */
- static native void computeTaskReduce(long envPtr, long taskPtr);
-
- /**
- * Complete task with native error.
- *
- * @param envPtr Environment pointer.
- * @param taskPtr Task pointer.
- * @param memPtr Memory pointer with exception data or {@code 0} in case of success.
- */
- static native void computeTaskComplete(long envPtr, long taskPtr, long memPtr);
-
- /**
- * Serialize native job.
- *
- * @param envPtr Environment pointer.
- * @param jobPtr Job pointer.
- * @param memPtr Memory pointer.
- * @return {@code True} if serialization succeeded.
- */
- static native int computeJobSerialize(long envPtr, long jobPtr, long memPtr);
-
- /**
- * Create job in native platform.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- * @return Pointer to job.
- */
- static native long computeJobCreate(long envPtr, long memPtr);
-
- /**
- * Execute native job on a node other than where it was created.
- *
- * @param envPtr Environment pointer.
- * @param jobPtr Job pointer.
- * @param cancel Cancel flag.
- * @param memPtr Memory pointer to write result to for remote job execution or {@code 0} for local job execution.
- */
- static native void computeJobExecute(long envPtr, long jobPtr, int cancel, long memPtr);
-
- /**
- * Cancel the job.
- *
- * @param envPtr Environment pointer.
- * @param jobPtr Job pointer.
- */
- static native void computeJobCancel(long envPtr, long jobPtr);
-
- /**
- * Destroy the job.
- *
- * @param envPtr Environment pointer.
- * @param ptr Pointer.
- */
- static native void computeJobDestroy(long envPtr, long ptr);
-
- /**
- * Invoke local callback.
- *
- * @param envPtr Environment pointer.
- * @param cbPtr Callback pointer.
- * @param memPtr Memory pointer.
- */
- static native void continuousQueryListenerApply(long envPtr, long cbPtr, long memPtr);
-
- /**
- * Create filter in native platform.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- * @return Pointer to created filter.
- */
- static native long continuousQueryFilterCreate(long envPtr, long memPtr);
-
- /**
- * Invoke remote filter.
- *
- * @param envPtr Environment pointer.
- * @param filterPtr Filter pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- static native int continuousQueryFilterApply(long envPtr, long filterPtr, long memPtr);
-
- /**
- * Release remote filter.
- *
- * @param envPtr Environment pointer.
- * @param filterPtr Filter pointer.
- */
- static native void continuousQueryFilterRelease(long envPtr, long filterPtr);
-
- /**
- * Notify native data streamer about topology update.
- *
- * @param envPtr Environment pointer.
- * @param ptr Data streamer native pointer.
- * @param topVer Topology version.
- * @param topSize Topology size.
- */
- static native void dataStreamerTopologyUpdate(long envPtr, long ptr, long topVer, int topSize);
-
- /**
- * Invoke stream receiver.
- *
- * @param envPtr Environment pointer.
- * @param ptr Receiver native pointer.
- * @param cache Cache object.
- * @param memPtr Stream pointer.
- * @param keepPortable Portable flag.
- */
- static native void dataStreamerStreamReceiverInvoke(long envPtr, long ptr, Object cache, long memPtr,
- boolean keepPortable);
-
- /**
- * Notify future with byte result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureByteResult(long envPtr, long futPtr, int res);
-
- /**
- * Notify future with boolean result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureBoolResult(long envPtr, long futPtr, int res);
-
- /**
- * Notify future with short result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureShortResult(long envPtr, long futPtr, int res);
-
- /**
- * Notify future with byte result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureCharResult(long envPtr, long futPtr, int res);
-
- /**
- * Notify future with int result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureIntResult(long envPtr, long futPtr, int res);
-
- /**
- * Notify future with float result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureFloatResult(long envPtr, long futPtr, float res);
-
- /**
- * Notify future with long result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureLongResult(long envPtr, long futPtr, long res);
-
- /**
- * Notify future with double result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param res Result.
- */
- static native void futureDoubleResult(long envPtr, long futPtr, double res);
-
- /**
- * Notify future with object result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param memPtr Memory pointer.
- */
- static native void futureObjectResult(long envPtr, long futPtr, long memPtr);
-
- /**
- * Notify future with null result.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- */
- static native void futureNullResult(long envPtr, long futPtr);
-
- /**
- * Notify future with error.
- *
- * @param envPtr Environment pointer.
- * @param futPtr Future pointer.
- * @param memPtr Pointer to memory with error information.
- */
- static native void futureError(long envPtr, long futPtr, long memPtr);
-
- /**
- * Creates message filter and returns a pointer.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- static native long messagingFilterCreate(long envPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- static native int messagingFilterApply(long envPtr, long objPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Pointer.
- */
- static native void messagingFilterDestroy(long envPtr, long objPtr);
-
- /**
- * Creates event filter and returns a pointer.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- static native long eventFilterCreate(long envPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- static native int eventFilterApply(long envPtr, long objPtr, long memPtr);
-
- /**
- * @param envPtr Environment pointer.
- * @param objPtr Pointer.
- */
- static native void eventFilterDestroy(long envPtr, long objPtr);
-
- /**
- * Sends node info to native target.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Ptr to a stream with serialized node.
- */
- static native void nodeInfo(long envPtr, long memPtr);
-
- /**
- * Kernal start callback.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Memory pointer.
- */
- static native void onStart(long envPtr, long memPtr);
-
- /*
- * Kernal stop callback.
- *
- * @param envPtr Environment pointer.
- */
- static native void onStop(long envPtr);
-
- /**
- * Lifecycle event callback.
- *
- * @param envPtr Environment pointer.
- * @param ptr Holder pointer.
- * @param evt Event.
- */
- static native void lifecycleEvent(long envPtr, long ptr, int evt);
-
- /**
- * Re-allocate external memory chunk.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Cross-platform pointer.
- * @param cap Capacity.
- */
- static native void memoryReallocate(long envPtr, long memPtr, int cap);
-
- /**
- * Initializes native service.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Stream pointer.
- * @return Pointer to the native platform service.
- */
- static native long serviceInit(long envPtr, long memPtr);
-
- /**
- * Executes native service.
- *
- * @param envPtr Environment pointer.
- * @param svcPtr Pointer to the service in the native platform.
- * @param memPtr Stream pointer.
- */
- static native void serviceExecute(long envPtr, long svcPtr, long memPtr);
-
- /**
- * Cancels native service.
- *
- * @param envPtr Environment pointer.
- * @param svcPtr Pointer to the service in the native platform.
- * @param memPtr Stream pointer.
- */
- static native void serviceCancel(long envPtr, long svcPtr, long memPtr);
-
- /**
- /**
- * Invokes service method.
- *
- * @param envPtr Environment pointer.
- * @param svcPtr Pointer to the service in the native platform.
- * @param outMemPtr Output memory pointer.
- * @param inMemPtr Input memory pointer.
- */
- static native void serviceInvokeMethod(long envPtr, long svcPtr, long outMemPtr, long inMemPtr);
-
- /**
- * Invokes cluster node filter.
- *
- * @param envPtr Environment pointer.
- * @param memPtr Stream pointer.
- */
- static native int clusterNodeFilterApply(long envPtr, long memPtr);
-
- /**
- * Private constructor.
- */
- private PlatformCallbackUtils() {
- // No-op.
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformAbstractMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformAbstractMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformAbstractMemory.java
deleted file mode 100644
index cf4c02a..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformAbstractMemory.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-/**
- * Interop memory chunk abstraction.
- */
-public abstract class PlatformAbstractMemory implements PlatformMemory {
- /** Stream factory. */
- private static final StreamFactory STREAM_FACTORY = PlatformMemoryUtils.LITTLE_ENDIAN ?
- new LittleEndianStreamFactory() : new BigEndianStreamFactory();
-
- /** Cross-platform memory pointer. */
- protected long memPtr;
-
- /**
- * Constructor.
- *
- * @param memPtr Cross-platform memory pointer.
- */
- protected PlatformAbstractMemory(long memPtr) {
- this.memPtr = memPtr;
- }
-
- /** {@inheritDoc} */
- @Override public PlatformInputStream input() {
- return STREAM_FACTORY.createInput(this);
- }
-
- /** {@inheritDoc} */
- @Override public PlatformOutputStream output() {
- return STREAM_FACTORY.createOutput(this);
- }
-
- /** {@inheritDoc} */
- @Override public long pointer() {
- return memPtr;
- }
-
- /** {@inheritDoc} */
- @Override public long data() {
- return PlatformMemoryUtils.data(memPtr);
- }
-
- /** {@inheritDoc} */
- @Override public int capacity() {
- return PlatformMemoryUtils.capacity(memPtr);
- }
-
- /** {@inheritDoc} */
- @Override public int length() {
- return PlatformMemoryUtils.length(memPtr);
- }
-
- /**
- * Stream factory.
- */
- private static interface StreamFactory {
- /**
- * Create input stream.
- *
- * @param mem Memory.
- * @return Input stream.
- */
- PlatformInputStreamImpl createInput(PlatformMemory mem);
-
- /**
- * Create output stream.
- *
- * @param mem Memory.
- * @return Output stream.
- */
- PlatformOutputStreamImpl createOutput(PlatformMemory mem);
- }
-
- /**
- * Stream factory for LITTLE ENDIAN architecture.
- */
- private static class LittleEndianStreamFactory implements StreamFactory {
- /** {@inheritDoc} */
- @Override public PlatformInputStreamImpl createInput(PlatformMemory mem) {
- return new PlatformInputStreamImpl(mem);
- }
-
- /** {@inheritDoc} */
- @Override public PlatformOutputStreamImpl createOutput(PlatformMemory mem) {
- return new PlatformOutputStreamImpl(mem);
- }
- }
-
- /**
- * Stream factory for BIG ENDIAN architecture.
- */
- private static class BigEndianStreamFactory implements StreamFactory {
- /** {@inheritDoc} */
- @Override public PlatformInputStreamImpl createInput(PlatformMemory mem) {
- return new PlatformBigEndianInputStreamImpl(mem);
- }
-
- /** {@inheritDoc} */
- @Override public PlatformOutputStreamImpl createOutput(PlatformMemory mem) {
- return new PlatformBigEndianOutputStreamImpl(mem);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformBigEndianInputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformBigEndianInputStreamImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformBigEndianInputStreamImpl.java
deleted file mode 100644
index fbf7f8e..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformBigEndianInputStreamImpl.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ignite.internal.platform.memory;
-
-/**
- * Interop input stream implementation working with BIG ENDIAN architecture.
- */
-public class PlatformBigEndianInputStreamImpl extends PlatformInputStreamImpl {
- /**
- * Constructor.
- *
- * @param mem Memory chunk.
- */
- public PlatformBigEndianInputStreamImpl(PlatformMemory mem) {
- super(mem);
- }
-
- /** {@inheritDoc} */
- @Override public short readShort() {
- return Short.reverseBytes(super.readShort());
- }
-
- /** {@inheritDoc} */
- @Override public short[] readShortArray(int cnt) {
- short[] res = super.readShortArray(cnt);
-
- for (int i = 0; i < cnt; i++)
- res[i] = Short.reverseBytes(res[i]);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public char readChar() {
- return Character.reverseBytes(super.readChar());
- }
-
- /** {@inheritDoc} */
- @Override public char[] readCharArray(int cnt) {
- char[] res = super.readCharArray(cnt);
-
- for (int i = 0; i < cnt; i++)
- res[i] = Character.reverseBytes(res[i]);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public int readInt() {
- return Integer.reverseBytes(super.readInt());
- }
-
- /** {@inheritDoc} */
- @Override public int readInt(int pos) {
- return Integer.reverseBytes(super.readInt(pos));
- }
-
- /** {@inheritDoc} */
- @Override public int[] readIntArray(int cnt) {
- int[] res = super.readIntArray(cnt);
-
- for (int i = 0; i < cnt; i++)
- res[i] = Integer.reverseBytes(res[i]);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public float readFloat() {
- return Float.intBitsToFloat(Integer.reverseBytes(Float.floatToIntBits(super.readFloat())));
- }
-
- /** {@inheritDoc} */
- @Override public float[] readFloatArray(int cnt) {
- float[] res = super.readFloatArray(cnt);
-
- for (int i = 0; i < cnt; i++)
- res[i] = Float.intBitsToFloat(Integer.reverseBytes(Float.floatToIntBits(res[i])));
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public long readLong() {
- return Long.reverseBytes(super.readLong());
- }
-
- /** {@inheritDoc} */
- @Override public long[] readLongArray(int cnt) {
- long[] res = super.readLongArray(cnt);
-
- for (int i = 0; i < cnt; i++)
- res[i] = Long.reverseBytes(res[i]);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public double readDouble() {
- return Double.longBitsToDouble(Long.reverseBytes(Double.doubleToLongBits(super.readDouble())));
- }
-
- /** {@inheritDoc} */
- @Override public double[] readDoubleArray(int cnt) {
- double[] res = super.readDoubleArray(cnt);
-
- for (int i = 0; i < cnt; i++)
- res[i] = Double.longBitsToDouble(Long.reverseBytes(Double.doubleToLongBits(res[i])));
-
- return res;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformBigEndianOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformBigEndianOutputStreamImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformBigEndianOutputStreamImpl.java
deleted file mode 100644
index 144e5dc..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformBigEndianOutputStreamImpl.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-import static org.apache.ignite.internal.platform.memory.PlatformMemoryUtils.*;
-
-/**
- * Interop output stream implementation working with BIG ENDIAN architecture.
- */
-public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl {
- /**
- * Constructor.
- *
- * @param mem Underlying memory chunk.
- */
- public PlatformBigEndianOutputStreamImpl(PlatformMemory mem) {
- super(mem);
- }
-
- /** {@inheritDoc} */
- @Override public void writeShort(short val) {
- super.writeShort(Short.reverseBytes(val));
- }
-
- /** {@inheritDoc} */
- @Override public void writeShortArray(short[] val) {
- int cnt = val.length << 1;
-
- ensureCapacity(pos + cnt);
-
- long startPos = data + pos;
-
- for (short item : val) {
- UNSAFE.putShort(startPos, Short.reverseBytes(item));
-
- startPos += 2;
- }
-
- shift(cnt);
- }
-
- /** {@inheritDoc} */
- @Override public void writeChar(char val) {
- super.writeChar(Character.reverseBytes(val));
- }
-
- /** {@inheritDoc} */
- @Override public void writeCharArray(char[] val) {
- int cnt = val.length << 1;
-
- ensureCapacity(pos + cnt);
-
- long startPos = data + pos;
-
- for (char item : val) {
- UNSAFE.putChar(startPos, Character.reverseBytes(item));
-
- startPos += 2;
- }
-
- shift(cnt);
- }
-
- /** {@inheritDoc} */
- @Override public void writeInt(int val) {
- super.writeInt(Integer.reverseBytes(val));
- }
-
- /** {@inheritDoc} */
- @Override public void writeIntArray(int[] val) {
- int cnt = val.length << 2;
-
- ensureCapacity(pos + cnt);
-
- long startPos = data + pos;
-
- for (int item : val) {
- UNSAFE.putInt(startPos, Integer.reverseBytes(item));
-
- startPos += 4;
- }
-
- shift(cnt);
- }
-
- /** {@inheritDoc} */
- @Override public void writeInt(int pos, int val) {
- super.writeInt(pos, Integer.reverseBytes(val));
- }
-
- /** {@inheritDoc} */
- @Override public void writeFloatArray(float[] val) {
- int cnt = val.length << 2;
-
- ensureCapacity(pos + cnt);
-
- long startPos = data + pos;
-
- for (float item : val) {
- UNSAFE.putInt(startPos, Integer.reverseBytes(Float.floatToIntBits(item)));
-
- startPos += 4;
- }
-
- shift(cnt);
- }
-
- /** {@inheritDoc} */
- @Override public void writeLong(long val) {
- super.writeLong(Long.reverseBytes(val));
- }
-
- /** {@inheritDoc} */
- @Override public void writeLongArray(long[] val) {
- int cnt = val.length << 3;
-
- ensureCapacity(pos + cnt);
-
- long startPos = data + pos;
-
- for (long item : val) {
- UNSAFE.putLong(startPos, Long.reverseBytes(item));
-
- startPos += 8;
- }
-
- shift(cnt);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDoubleArray(double[] val) {
- int cnt = val.length << 3;
-
- ensureCapacity(pos + cnt);
-
- long startPos = data + pos;
-
- for (double item : val) {
- UNSAFE.putLong(startPos, Long.reverseBytes(Double.doubleToLongBits(item)));
-
- startPos += 8;
- }
-
- shift(cnt);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformExternalMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformExternalMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformExternalMemory.java
deleted file mode 100644
index e04779d..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformExternalMemory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.platform.callback.*;
-import org.jetbrains.annotations.*;
-
-/**
- * Interop external memory chunk.
- */
-public class PlatformExternalMemory extends PlatformAbstractMemory {
- /** Native gateway. */
- private final PlatformCallbackGateway gate;
-
- /**
- * Constructor.
- *
- * @param gate Native gateway.
- * @param memPtr Memory pointer.
- */
- public PlatformExternalMemory(@Nullable PlatformCallbackGateway gate, long memPtr) {
- super(memPtr);
-
- this.gate = gate;
- }
-
- /** {@inheritDoc} */
- @Override public void reallocate(int cap) {
- if (gate == null)
- throw new IgniteException("Failed to re-allocate external memory chunk because it is read-only.");
-
- gate.memoryReallocate(memPtr, cap);
- }
-
- /** {@inheritDoc} */
- @Override public void close() {
- // Do nothing, memory must be released by native platform.
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformInputStream.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformInputStream.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformInputStream.java
deleted file mode 100644
index 6d0d107..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformInputStream.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-import org.apache.ignite.internal.portable.streams.*;
-
-/**
- * Interop output stream,
- */
-public interface PlatformInputStream extends PortableInputStream {
- /**
- * Synchronize input. Must be called before start reading data from a memory changed by another platform.
- */
- public void synchronize();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformInputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformInputStreamImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformInputStreamImpl.java
deleted file mode 100644
index e741c9e..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformInputStreamImpl.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-import org.apache.ignite.*;
-
-import static org.apache.ignite.internal.platform.memory.PlatformMemoryUtils.*;
-
-/**
- * Interop input stream implementation.
- */
-public class PlatformInputStreamImpl implements PlatformInputStream {
- /** Underlying memory. */
- private final PlatformMemory mem;
-
- /** Real data pointer */
- private long data;
-
- /** Amount of available data. */
- private int len;
-
- /** Current position. */
- private int pos;
-
- /** Heap-copied data. */
- private byte[] dataCopy;
-
- /**
- * Constructor.
- *
- * @param mem Underlying memory chunk.
- */
- public PlatformInputStreamImpl(PlatformMemory mem) {
- this.mem = mem;
-
- data = mem.data();
- len = mem.length();
- }
-
- /** {@inheritDoc} */
- @Override public byte readByte() {
- ensureEnoughData(1);
-
- return UNSAFE.getByte(data + pos++);
- }
-
- /** {@inheritDoc} */
- @Override public byte[] readByteArray(int cnt) {
- byte[] res = new byte[cnt];
-
- copyAndShift(res, BYTE_ARR_OFF, cnt);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public boolean readBoolean() {
- return readByte() == 1;
- }
-
- /** {@inheritDoc} */
- @Override public boolean[] readBooleanArray(int cnt) {
- boolean[] res = new boolean[cnt];
-
- copyAndShift(res, BOOLEAN_ARR_OFF, cnt);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public short readShort() {
- ensureEnoughData(2);
-
- short res = UNSAFE.getShort(data + pos);
-
- shift(2);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public short[] readShortArray(int cnt) {
- int len = cnt << 1;
-
- short[] res = new short[cnt];
-
- copyAndShift(res, SHORT_ARR_OFF, len);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public char readChar() {
- ensureEnoughData(2);
-
- char res = UNSAFE.getChar(data + pos);
-
- shift(2);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public char[] readCharArray(int cnt) {
- int len = cnt << 1;
-
- char[] res = new char[cnt];
-
- copyAndShift(res, CHAR_ARR_OFF, len);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public int readInt() {
- ensureEnoughData(4);
-
- int res = UNSAFE.getInt(data + pos);
-
- shift(4);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public int readInt(int pos) {
- int delta = pos + 4 - this.pos;
-
- if (delta > 0)
- ensureEnoughData(delta);
-
- return UNSAFE.getInt(data + pos);
- }
-
- /** {@inheritDoc} */
- @Override public int[] readIntArray(int cnt) {
- int len = cnt << 2;
-
- int[] res = new int[cnt];
-
- copyAndShift(res, INT_ARR_OFF, len);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public float readFloat() {
- ensureEnoughData(4);
-
- float res = UNSAFE.getFloat(data + pos);
-
- shift(4);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public float[] readFloatArray(int cnt) {
- int len = cnt << 2;
-
- float[] res = new float[cnt];
-
- copyAndShift(res, FLOAT_ARR_OFF, len);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public long readLong() {
- ensureEnoughData(8);
-
- long res = UNSAFE.getLong(data + pos);
-
- shift(8);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public long[] readLongArray(int cnt) {
- int len = cnt << 3;
-
- long[] res = new long[cnt];
-
- copyAndShift(res, LONG_ARR_OFF, len);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public double readDouble() {
- ensureEnoughData(8);
-
- double res = UNSAFE.getDouble(data + pos);
-
- shift(8);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public double[] readDoubleArray(int cnt) {
- int len = cnt << 3;
-
- double[] res = new double[cnt];
-
- copyAndShift(res, DOUBLE_ARR_OFF, len);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public int read(byte[] arr, int off, int len) {
- if (len > remaining())
- len = remaining();
-
- copyAndShift(arr, BYTE_ARR_OFF + off, len);
-
- return len;
- }
-
- /** {@inheritDoc} */
- @Override public int remaining() {
- return len - pos;
- }
-
- /** {@inheritDoc} */
- @Override public int position() {
- return pos;
- }
-
- /** {@inheritDoc} */
- @Override public void position(int pos) {
- if (pos > len)
- throw new IgniteException("Position is out of bounds: " + pos);
- else
- this.pos = pos;
- }
-
- /** {@inheritDoc} */
- @Override public byte[] array() {
- return arrayCopy();
- }
-
- /** {@inheritDoc} */
- @Override public byte[] arrayCopy() {
- if (dataCopy == null) {
- dataCopy = new byte[len];
-
- UNSAFE.copyMemory(null, data, dataCopy, BYTE_ARR_OFF, dataCopy.length);
- }
-
- return dataCopy;
- }
-
- /** {@inheritDoc} */
- @Override public long offheapPointer() {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override public boolean hasArray() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public void synchronize() {
- data = mem.data();
- len = mem.length();
- }
-
- /**
- * Ensure there is enough data in the stream.
- *
- * @param cnt Amount of byte expected to be available.
- */
- private void ensureEnoughData(int cnt) {
- if (remaining() < cnt)
- throw new IgniteException("Not enough data to read the value [position=" + pos +
- ", requiredBytes=" + cnt + ", remainingBytes=" + remaining() + ']');
- }
-
- /**
- * Copy required amount of data and shift position.
- *
- * @param target Target to copy data to.
- * @param off Offset.
- * @param cnt Count.
- */
- private void copyAndShift(Object target, long off, int cnt) {
- ensureEnoughData(cnt);
-
- UNSAFE.copyMemory(null, data + pos, target, off, cnt);
-
- shift(cnt);
- }
-
- /**
- * Shift position to the right.
- *
- * @param cnt Amount of bytes.
- */
- private void shift(int cnt) {
- pos += cnt;
-
- assert pos <= len;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemory.java
deleted file mode 100644
index 648827a..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-/**
- * Interop memory chunk.
- */
-public interface PlatformMemory extends AutoCloseable {
- /**
- * Gets input stream.
- *
- * @return Input stream.
- */
- public PlatformInputStream input();
-
- /**
- * Gets output stream.
- *
- * @return Output stream.
- */
- public PlatformOutputStream output();
-
- /**
- * Gets pointer which can be passed between platforms.
- *
- * @return Pointer.
- */
- public long pointer();
-
- /**
- * Gets data pointer.
- *
- * @return Data pointer.
- */
- public long data();
-
- /**
- * Gets capacity.
- *
- * @return Capacity.
- */
- public int capacity();
-
- /**
- * Gets length.
- *
- * @return Length.
- */
- public int length();
-
- /**
- * Reallocate memory chunk.
- *
- * @param cap Minimum capacity.
- */
- public void reallocate(int cap);
-
- /**
- * Close memory releasing it.
- */
- @Override void close();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryManager.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryManager.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryManager.java
deleted file mode 100644
index 73ec915..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryManager.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-/**
- * Interop memory manager interface.
- */
-public interface PlatformMemoryManager {
- /**
- * Allocates memory.
- *
- * @return Memory.
- */
- public PlatformMemory allocate();
-
- /**
- * Allocates memory having at least the given capacity.
- *
- * @param cap Minimum capacity.
- * @return Memory.
- */
- public PlatformMemory allocate(int cap);
-
- /**
- * Gets memory from existing pointer.
- *
- * @param memPtr Cross-platform memory pointer.
- * @return Memory.
- */
- public PlatformMemory get(long memPtr);
-}
[37/41] ignite git commit: Further refactorings necessary for
platforms move to Ignite.
Posted by sb...@apache.org.
Further refactorings necessary for platforms move to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5877b301
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5877b301
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5877b301
Branch: refs/heads/ignite-1093
Commit: 5877b301a89ed87531d503fe92474d8a8568134a
Parents: 136c099
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Aug 27 09:53:17 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Aug 27 09:53:17 2015 +0300
----------------------------------------------------------------------
.../processors/platform/PlatformContext.java | 114 +++
.../platform/PlatformNoopProcessor.java | 5 +
.../processors/platform/PlatformProcessor.java | 7 +
.../callback/PlatformCallbackGateway.java | 869 +++++++++++++++++++
.../callback/PlatformCallbackUtils.java | 468 ++++++++++
.../platform/memory/PlatformInputStream.java | 30 +
.../platform/memory/PlatformMemory.java | 77 ++
.../platform/memory/PlatformMemoryManager.java | 46 +
.../platform/memory/PlatformOutputStream.java | 30 +
.../processors/platform/PlatformContext.java | 114 ---
.../callback/PlatformCallbackGateway.java | 869 -------------------
.../callback/PlatformCallbackUtils.java | 468 ----------
.../platform/memory/PlatformInputStream.java | 30 -
.../platform/memory/PlatformMemory.java | 77 --
.../platform/memory/PlatformMemoryManager.java | 46 -
.../platform/memory/PlatformOutputStream.java | 30 -
.../platform/utils/PlatformUtils.java | 23 +
17 files changed, 1669 insertions(+), 1634 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
new file mode 100644
index 0000000..fb1eaa2
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.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.internal.processors.platform;
+
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.platform.callback.*;
+import org.apache.ignite.internal.processors.platform.memory.*;
+
+import java.util.*;
+
+/**
+ * Platform context. Acts as an entry point for platform operations.
+ */
+public interface PlatformContext {
+ /**
+ * Gets kernal context.
+ *
+ * @return Kernal context.
+ */
+ public GridKernalContext kernalContext();
+
+ /**
+ * Gets platform memory manager.
+ *
+ * @return Memory manager.
+ */
+ public PlatformMemoryManager memory();
+
+ /**
+ * Gets platform callback gateway.
+ *
+ * @return Callback gateway.
+ */
+ public PlatformCallbackGateway gateway();
+
+ /**
+ * Get memory reader.
+ *
+ * @param mem Memory.
+ * @return Reader.
+ */
+ public PortableRawReaderEx reader(PlatformMemory mem);
+
+ /**
+ * Get memory reader.
+ *
+ * @param in Input.
+ * @return Reader.
+ */
+ public PortableRawReaderEx reader(PlatformInputStream in);
+
+ /**
+ * Get memory writer.
+ *
+ * @param mem Memory.
+ * @return Writer.
+ */
+ public PortableRawWriterEx writer(PlatformMemory mem);
+
+ /**
+ * Get memory writer.
+ *
+ * @param out Output.
+ * @return Writer.
+ */
+ public PortableRawWriterEx writer(PlatformOutputStream out);
+
+ /**
+ * Sends node info to native platform, if necessary.
+ *
+ * @param node Node.
+ */
+ public void addNode(ClusterNode node);
+
+ /**
+ * Writes a node id to a stream and sends node info to native platform, if necessary.
+ *
+ * @param writer Writer.
+ * @param node Node.
+ */
+ public void writeNode(PortableRawWriterEx writer, ClusterNode node);
+
+ /**
+ * Writes multiple node ids to a stream and sends node info to native platform, if necessary.
+ *
+ * @param writer Writer.
+ * @param nodes Nodes.
+ */
+ public void writeNodes(PortableRawWriterEx writer, Collection<ClusterNode> nodes);
+
+ /**
+ * Process metadata from the platform.
+ *
+ * @param reader Reader.
+ */
+ public void processMetadata(PortableRawReaderEx reader);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
index 245d4d7..9bdc3be 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
@@ -38,4 +38,9 @@ public class PlatformNoopProcessor extends GridProcessorAdapter implements Platf
@Override public long environmentPointer() {
return 0;
}
+
+ /** {@inheritDoc} */
+ @Override public PlatformContext context() {
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
index 137c31b..782db4b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
@@ -37,4 +37,11 @@ public interface PlatformProcessor extends GridProcessor {
* @return Environment pointer.
*/
public long environmentPointer();
+
+ /**
+ * Gets platform context.
+ *
+ * @return Platform context.
+ */
+ public PlatformContext context();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
new file mode 100644
index 0000000..a8e7879
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
@@ -0,0 +1,869 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.callback;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.util.*;
+
+/**
+ * Gateway to all platform-dependent callbacks. Implementers might extend this class and provide additional callbacks.
+ */
+@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
+public class PlatformCallbackGateway {
+ /** Environment pointer. */
+ protected final long envPtr;
+
+ /** Lock. */
+ private final GridSpinReadWriteLock lock = new GridSpinReadWriteLock();
+
+ /**
+ * Native gateway.
+ *
+ * @param envPtr Environment pointer.
+ */
+ public PlatformCallbackGateway(long envPtr) {
+ this.envPtr = envPtr;
+ }
+
+ /**
+ * Get environment pointer.
+ *
+ * @return Environment pointer.
+ */
+ public long environmentPointer() {
+ return envPtr;
+ }
+
+ /**
+ * Create cache store.
+ *
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ public long cacheStoreCreate(long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.cacheStoreCreate(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param objPtr Object pointer.
+ * @param memPtr Memory pointer.
+ * @param cb Callback.
+ * @return Result.
+ */
+ public int cacheStoreInvoke(long objPtr, long memPtr, Object cb) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.cacheStoreInvoke(envPtr, objPtr, memPtr, cb);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param objPtr Object pointer.
+ */
+ public void cacheStoreDestroy(long objPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.cacheStoreDestroy(envPtr, objPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Creates cache store session.
+ *
+ * @param storePtr Store instance pointer.
+ * @return Session instance pointer.
+ */
+ public long cacheStoreSessionCreate(long storePtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.cacheStoreSessionCreate(envPtr, storePtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Creates cache entry filter and returns a pointer.
+ *
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ public long cacheEntryFilterCreate(long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.cacheEntryFilterCreate(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param ptr Pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ public int cacheEntryFilterApply(long ptr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.cacheEntryFilterApply(envPtr, ptr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param ptr Pointer.
+ */
+ public void cacheEntryFilterDestroy(long ptr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.cacheEntryFilterDestroy(envPtr, ptr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Invoke cache entry processor.
+ *
+ * @param outMemPtr Output memory pointer.
+ * @param inMemPtr Input memory pointer.
+ */
+ public void cacheInvoke(long outMemPtr, long inMemPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.cacheInvoke(envPtr, outMemPtr, inMemPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Perform native task map. Do not throw exceptions, serializing them to the output stream instead.
+ *
+ * @param taskPtr Task pointer.
+ * @param outMemPtr Output memory pointer (exists if topology changed, otherwise {@code 0}).
+ * @param inMemPtr Input memory pointer.
+ */
+ public void computeTaskMap(long taskPtr, long outMemPtr, long inMemPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.computeTaskMap(envPtr, taskPtr, outMemPtr, inMemPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Perform native task job result notification.
+ *
+ * @param taskPtr Task pointer.
+ * @param jobPtr Job pointer.
+ * @param memPtr Memory pointer (always zero for local job execution).
+ * @return Job result enum ordinal.
+ */
+ public int computeTaskJobResult(long taskPtr, long jobPtr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.computeTaskJobResult(envPtr, taskPtr, jobPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Perform native task reduce.
+ *
+ * @param taskPtr Task pointer.
+ */
+ public void computeTaskReduce(long taskPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.computeTaskReduce(envPtr, taskPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Complete task with native error.
+ *
+ * @param taskPtr Task pointer.
+ * @param memPtr Memory pointer with exception data or {@code 0} in case of success.
+ */
+ public void computeTaskComplete(long taskPtr, long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.computeTaskComplete(envPtr, taskPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Serialize native job.
+ *
+ * @param jobPtr Job pointer.
+ * @param memPtr Memory pointer.
+ * @return {@code True} if serialization succeeded.
+ */
+ public int computeJobSerialize(long jobPtr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.computeJobSerialize(envPtr, jobPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Create job in native platform.
+ *
+ * @param memPtr Memory pointer.
+ * @return Pointer to job.
+ */
+ public long computeJobCreate(long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.computeJobCreate(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Execute native job on a node other than where it was created.
+ *
+ * @param jobPtr Job pointer.
+ * @param cancel Cancel flag.
+ * @param memPtr Memory pointer to write result to for remote job execution or {@code 0} for local job execution.
+ */
+ public void computeJobExecute(long jobPtr, int cancel, long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.computeJobExecute(envPtr, jobPtr, cancel, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Cancel the job.
+ *
+ * @param jobPtr Job pointer.
+ */
+ public void computeJobCancel(long jobPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.computeJobCancel(envPtr, jobPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Destroy the job.
+ *
+ * @param ptr Pointer.
+ */
+ public void computeJobDestroy(long ptr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.computeJobDestroy(envPtr, ptr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Invoke local callback.
+ *
+ * @param cbPtr Callback pointer.
+ * @param memPtr Memory pointer.
+ */
+ public void continuousQueryListenerApply(long cbPtr, long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.continuousQueryListenerApply(envPtr, cbPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Create filter in native platform.
+ *
+ * @param memPtr Memory pointer.
+ * @return Pointer to created filter.
+ */
+ public long continuousQueryFilterCreate(long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.continuousQueryFilterCreate(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Invoke remote filter.
+ *
+ * @param filterPtr Filter pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ public int continuousQueryFilterApply(long filterPtr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.continuousQueryFilterApply(envPtr, filterPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Release remote filter.
+ *
+ * @param filterPtr Filter pointer.
+ */
+ public void continuousQueryFilterRelease(long filterPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.continuousQueryFilterRelease(envPtr, filterPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify native data streamer about topology update.
+ *
+ * @param ptr Data streamer native pointer.
+ * @param topVer Topology version.
+ * @param topSize Topology size.
+ */
+ public void dataStreamerTopologyUpdate(long ptr, long topVer, int topSize) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.dataStreamerTopologyUpdate(envPtr, ptr, topVer, topSize);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Invoke stream receiver.
+ *
+ * @param ptr Receiver native pointer.
+ * @param cache Cache object.
+ * @param memPtr Stream pointer.
+ * @param keepPortable Portable flag.
+ */
+ public void dataStreamerStreamReceiverInvoke(long ptr, Object cache, long memPtr, boolean keepPortable) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.dataStreamerStreamReceiverInvoke(envPtr, ptr, cache, memPtr, keepPortable);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with byte result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureByteResult(long futPtr, int res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureByteResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with boolean result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureBoolResult(long futPtr, int res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureBoolResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with short result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureShortResult(long futPtr, int res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureShortResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with byte result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureCharResult(long futPtr, int res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureCharResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with int result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureIntResult(long futPtr, int res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureIntResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with float result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureFloatResult(long futPtr, float res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureFloatResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with long result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureLongResult(long futPtr, long res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureLongResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with double result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureDoubleResult(long futPtr, double res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureDoubleResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with object result.
+ *
+ * @param futPtr Future pointer.
+ * @param memPtr Memory pointer.
+ */
+ public void futureObjectResult(long futPtr, long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureObjectResult(envPtr, futPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with null result.
+ *
+ * @param futPtr Future pointer.
+ */
+ public void futureNullResult(long futPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureNullResult(envPtr, futPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with error.
+ *
+ * @param futPtr Future pointer.
+ * @param memPtr Pointer to memory with error information.
+ */
+ public void futureError(long futPtr, long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureError(envPtr, futPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Creates message filter and returns a pointer.
+ *
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ public long messagingFilterCreate(long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.messagingFilterCreate(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param ptr Pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ public int messagingFilterApply(long ptr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.messagingFilterApply(envPtr, ptr, memPtr);
+ }
+ finally {
+ leave();
+ }}
+
+ /**
+ * @param ptr Pointer.
+ */
+ public void messagingFilterDestroy(long ptr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.messagingFilterDestroy(envPtr, ptr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Creates event filter and returns a pointer.
+ *
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ public long eventFilterCreate(long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.eventFilterCreate(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param ptr Pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ public int eventFilterApply(long ptr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.eventFilterApply(envPtr, ptr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param ptr Pointer.
+ */
+ public void eventFilterDestroy(long ptr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.eventFilterDestroy(envPtr, ptr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Sends node info to native target.
+ *
+ * @param memPtr Ptr to a stream with serialized node.
+ */
+ public void nodeInfo(long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.nodeInfo(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Kernal start callback.
+ *
+ * @param memPtr Memory pointer.
+ */
+ public void onStart(long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.onStart(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Lifecycle event callback.
+ *
+ * @param ptr Holder pointer.
+ * @param evt Event.
+ */
+ public void lifecycleEvent(long ptr, int evt) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.lifecycleEvent(envPtr, ptr, evt);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Re-allocate external memory chunk.
+ *
+ * @param memPtr Cross-platform pointer.
+ * @param cap Capacity.
+ */
+ public void memoryReallocate(long memPtr, int cap) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.memoryReallocate(envPtr, memPtr, cap);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Initializes native service.
+ *
+ * @param memPtr Pointer.
+ * @throws org.apache.ignite.IgniteCheckedException In case of error.
+ */
+ public long serviceInit(long memPtr) throws IgniteCheckedException {
+ return PlatformCallbackUtils.serviceInit(envPtr, memPtr);
+ }
+
+ /**
+ * Executes native service.
+ *
+ * @param svcPtr Pointer to the service in the native platform.
+ * @param memPtr Stream pointer.
+ * @throws org.apache.ignite.IgniteCheckedException In case of error.
+ */
+ public void serviceExecute(long svcPtr, long memPtr) throws IgniteCheckedException {
+ PlatformCallbackUtils.serviceExecute(envPtr, svcPtr, memPtr);
+ }
+
+ /**
+ * Cancels native service.
+ *
+ * @param svcPtr Pointer to the service in the native platform.
+ * @param memPtr Stream pointer.
+ * @throws org.apache.ignite.IgniteCheckedException In case of error.
+ */
+ public void serviceCancel(long svcPtr, long memPtr) throws IgniteCheckedException {
+ PlatformCallbackUtils.serviceCancel(envPtr, svcPtr, memPtr);
+ }
+
+ /**
+ * Invokes service method.
+ *
+ * @param svcPtr Pointer to the service in the native platform.
+ * @param outMemPtr Output memory pointer.
+ * @param inMemPtr Input memory pointer.
+ * @throws org.apache.ignite.IgniteCheckedException In case of error.
+ */
+ public void serviceInvokeMethod(long svcPtr, long outMemPtr, long inMemPtr) throws IgniteCheckedException {
+ PlatformCallbackUtils.serviceInvokeMethod(envPtr, svcPtr, outMemPtr, inMemPtr);
+ }
+
+ /**
+ * Invokes cluster node filter.
+ *
+ * @param memPtr Stream pointer.
+ */
+ public int clusterNodeFilterApply(long memPtr) {
+ return PlatformCallbackUtils.clusterNodeFilterApply(envPtr, memPtr);
+ }
+
+ /**
+ * Kernal stop callback.
+ */
+ public void onStop() {
+ block();
+
+ PlatformCallbackUtils.onStop(envPtr);
+ }
+
+ /**
+ * Enter gateway.
+ */
+ protected void enter() {
+ if (!lock.tryReadLock())
+ throw new IgniteException("Failed to execute native callback because grid is stopping.");
+ }
+
+ /**
+ * Leave gateway.
+ */
+ protected void leave() {
+ lock.readUnlock();
+ }
+
+ /**
+ * Block gateway.
+ */
+ protected void block() {
+ lock.writeLock();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
new file mode 100644
index 0000000..7e9587f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
@@ -0,0 +1,468 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.callback;
+
+/**
+ * Platform callback utility methods. Implemented in target platform. All methods in this class must be
+ * package-visible and invoked only through {@link PlatformCallbackGateway}.
+ */
+public class PlatformCallbackUtils {
+ /**
+ * Create cache store.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ static native long cacheStoreCreate(long envPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Object pointer.
+ * @param memPtr Memory pointer.
+ * @param cb Callback.
+ * @return Result.
+ */
+ static native int cacheStoreInvoke(long envPtr, long objPtr, long memPtr, Object cb);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Object pointer.
+ */
+ static native void cacheStoreDestroy(long envPtr, long objPtr);
+
+ /**
+ * Creates cache store session.
+ *
+ * @param envPtr Environment pointer.
+ * @param storePtr Store instance pointer.
+ * @return Session instance pointer.
+ */
+ static native long cacheStoreSessionCreate(long envPtr, long storePtr);
+
+ /**
+ * Creates cache entry filter and returns a pointer.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ static native long cacheEntryFilterCreate(long envPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ static native int cacheEntryFilterApply(long envPtr, long objPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Pointer.
+ */
+ static native void cacheEntryFilterDestroy(long envPtr, long objPtr);
+
+ /**
+ * Invoke cache entry processor.
+ *
+ * @param envPtr Environment pointer.
+ * @param outMemPtr Output memory pointer.
+ * @param inMemPtr Input memory pointer.
+ */
+ static native void cacheInvoke(long envPtr, long outMemPtr, long inMemPtr);
+
+ /**
+ * Perform native task map. Do not throw exceptions, serializing them to the output stream instead.
+ *
+ * @param envPtr Environment pointer.
+ * @param taskPtr Task pointer.
+ * @param outMemPtr Output memory pointer (exists if topology changed, otherwise {@code 0}).
+ * @param inMemPtr Input memory pointer.
+ */
+ static native void computeTaskMap(long envPtr, long taskPtr, long outMemPtr, long inMemPtr);
+
+ /**
+ * Perform native task job result notification.
+ *
+ * @param envPtr Environment pointer.
+ * @param taskPtr Task pointer.
+ * @param jobPtr Job pointer.
+ * @param memPtr Memory pointer (always zero for local job execution).
+ * @return Job result enum ordinal.
+ */
+ static native int computeTaskJobResult(long envPtr, long taskPtr, long jobPtr, long memPtr);
+
+ /**
+ * Perform native task reduce.
+ *
+ * @param envPtr Environment pointer.
+ * @param taskPtr Task pointer.
+ */
+ static native void computeTaskReduce(long envPtr, long taskPtr);
+
+ /**
+ * Complete task with native error.
+ *
+ * @param envPtr Environment pointer.
+ * @param taskPtr Task pointer.
+ * @param memPtr Memory pointer with exception data or {@code 0} in case of success.
+ */
+ static native void computeTaskComplete(long envPtr, long taskPtr, long memPtr);
+
+ /**
+ * Serialize native job.
+ *
+ * @param envPtr Environment pointer.
+ * @param jobPtr Job pointer.
+ * @param memPtr Memory pointer.
+ * @return {@code True} if serialization succeeded.
+ */
+ static native int computeJobSerialize(long envPtr, long jobPtr, long memPtr);
+
+ /**
+ * Create job in native platform.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ * @return Pointer to job.
+ */
+ static native long computeJobCreate(long envPtr, long memPtr);
+
+ /**
+ * Execute native job on a node other than where it was created.
+ *
+ * @param envPtr Environment pointer.
+ * @param jobPtr Job pointer.
+ * @param cancel Cancel flag.
+ * @param memPtr Memory pointer to write result to for remote job execution or {@code 0} for local job execution.
+ */
+ static native void computeJobExecute(long envPtr, long jobPtr, int cancel, long memPtr);
+
+ /**
+ * Cancel the job.
+ *
+ * @param envPtr Environment pointer.
+ * @param jobPtr Job pointer.
+ */
+ static native void computeJobCancel(long envPtr, long jobPtr);
+
+ /**
+ * Destroy the job.
+ *
+ * @param envPtr Environment pointer.
+ * @param ptr Pointer.
+ */
+ static native void computeJobDestroy(long envPtr, long ptr);
+
+ /**
+ * Invoke local callback.
+ *
+ * @param envPtr Environment pointer.
+ * @param cbPtr Callback pointer.
+ * @param memPtr Memory pointer.
+ */
+ static native void continuousQueryListenerApply(long envPtr, long cbPtr, long memPtr);
+
+ /**
+ * Create filter in native platform.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ * @return Pointer to created filter.
+ */
+ static native long continuousQueryFilterCreate(long envPtr, long memPtr);
+
+ /**
+ * Invoke remote filter.
+ *
+ * @param envPtr Environment pointer.
+ * @param filterPtr Filter pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ static native int continuousQueryFilterApply(long envPtr, long filterPtr, long memPtr);
+
+ /**
+ * Release remote filter.
+ *
+ * @param envPtr Environment pointer.
+ * @param filterPtr Filter pointer.
+ */
+ static native void continuousQueryFilterRelease(long envPtr, long filterPtr);
+
+ /**
+ * Notify native data streamer about topology update.
+ *
+ * @param envPtr Environment pointer.
+ * @param ptr Data streamer native pointer.
+ * @param topVer Topology version.
+ * @param topSize Topology size.
+ */
+ static native void dataStreamerTopologyUpdate(long envPtr, long ptr, long topVer, int topSize);
+
+ /**
+ * Invoke stream receiver.
+ *
+ * @param envPtr Environment pointer.
+ * @param ptr Receiver native pointer.
+ * @param cache Cache object.
+ * @param memPtr Stream pointer.
+ * @param keepPortable Portable flag.
+ */
+ static native void dataStreamerStreamReceiverInvoke(long envPtr, long ptr, Object cache, long memPtr,
+ boolean keepPortable);
+
+ /**
+ * Notify future with byte result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureByteResult(long envPtr, long futPtr, int res);
+
+ /**
+ * Notify future with boolean result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureBoolResult(long envPtr, long futPtr, int res);
+
+ /**
+ * Notify future with short result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureShortResult(long envPtr, long futPtr, int res);
+
+ /**
+ * Notify future with byte result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureCharResult(long envPtr, long futPtr, int res);
+
+ /**
+ * Notify future with int result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureIntResult(long envPtr, long futPtr, int res);
+
+ /**
+ * Notify future with float result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureFloatResult(long envPtr, long futPtr, float res);
+
+ /**
+ * Notify future with long result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureLongResult(long envPtr, long futPtr, long res);
+
+ /**
+ * Notify future with double result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureDoubleResult(long envPtr, long futPtr, double res);
+
+ /**
+ * Notify future with object result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param memPtr Memory pointer.
+ */
+ static native void futureObjectResult(long envPtr, long futPtr, long memPtr);
+
+ /**
+ * Notify future with null result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ */
+ static native void futureNullResult(long envPtr, long futPtr);
+
+ /**
+ * Notify future with error.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param memPtr Pointer to memory with error information.
+ */
+ static native void futureError(long envPtr, long futPtr, long memPtr);
+
+ /**
+ * Creates message filter and returns a pointer.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ static native long messagingFilterCreate(long envPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ static native int messagingFilterApply(long envPtr, long objPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Pointer.
+ */
+ static native void messagingFilterDestroy(long envPtr, long objPtr);
+
+ /**
+ * Creates event filter and returns a pointer.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ static native long eventFilterCreate(long envPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ static native int eventFilterApply(long envPtr, long objPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Pointer.
+ */
+ static native void eventFilterDestroy(long envPtr, long objPtr);
+
+ /**
+ * Sends node info to native target.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Ptr to a stream with serialized node.
+ */
+ static native void nodeInfo(long envPtr, long memPtr);
+
+ /**
+ * Kernal start callback.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ */
+ static native void onStart(long envPtr, long memPtr);
+
+ /*
+ * Kernal stop callback.
+ *
+ * @param envPtr Environment pointer.
+ */
+ static native void onStop(long envPtr);
+
+ /**
+ * Lifecycle event callback.
+ *
+ * @param envPtr Environment pointer.
+ * @param ptr Holder pointer.
+ * @param evt Event.
+ */
+ static native void lifecycleEvent(long envPtr, long ptr, int evt);
+
+ /**
+ * Re-allocate external memory chunk.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Cross-platform pointer.
+ * @param cap Capacity.
+ */
+ static native void memoryReallocate(long envPtr, long memPtr, int cap);
+
+ /**
+ * Initializes native service.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Stream pointer.
+ * @return Pointer to the native platform service.
+ */
+ static native long serviceInit(long envPtr, long memPtr);
+
+ /**
+ * Executes native service.
+ *
+ * @param envPtr Environment pointer.
+ * @param svcPtr Pointer to the service in the native platform.
+ * @param memPtr Stream pointer.
+ */
+ static native void serviceExecute(long envPtr, long svcPtr, long memPtr);
+
+ /**
+ * Cancels native service.
+ *
+ * @param envPtr Environment pointer.
+ * @param svcPtr Pointer to the service in the native platform.
+ * @param memPtr Stream pointer.
+ */
+ static native void serviceCancel(long envPtr, long svcPtr, long memPtr);
+
+ /**
+ /**
+ * Invokes service method.
+ *
+ * @param envPtr Environment pointer.
+ * @param svcPtr Pointer to the service in the native platform.
+ * @param outMemPtr Output memory pointer.
+ * @param inMemPtr Input memory pointer.
+ */
+ static native void serviceInvokeMethod(long envPtr, long svcPtr, long outMemPtr, long inMemPtr);
+
+ /**
+ * Invokes cluster node filter.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Stream pointer.
+ */
+ static native int clusterNodeFilterApply(long envPtr, long memPtr);
+
+ /**
+ * Private constructor.
+ */
+ private PlatformCallbackUtils() {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
new file mode 100644
index 0000000..9273e29
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+import org.apache.ignite.internal.portable.streams.*;
+
+/**
+ * Interop output stream,
+ */
+public interface PlatformInputStream extends PortableInputStream {
+ /**
+ * Synchronize input. Must be called before start reading data from a memory changed by another platform.
+ */
+ public void synchronize();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemory.java
new file mode 100644
index 0000000..9d8f94e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemory.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+/**
+ * Interop memory chunk.
+ */
+public interface PlatformMemory extends AutoCloseable {
+ /**
+ * Gets input stream.
+ *
+ * @return Input stream.
+ */
+ public PlatformInputStream input();
+
+ /**
+ * Gets output stream.
+ *
+ * @return Output stream.
+ */
+ public PlatformOutputStream output();
+
+ /**
+ * Gets pointer which can be passed between platforms.
+ *
+ * @return Pointer.
+ */
+ public long pointer();
+
+ /**
+ * Gets data pointer.
+ *
+ * @return Data pointer.
+ */
+ public long data();
+
+ /**
+ * Gets capacity.
+ *
+ * @return Capacity.
+ */
+ public int capacity();
+
+ /**
+ * Gets length.
+ *
+ * @return Length.
+ */
+ public int length();
+
+ /**
+ * Reallocate memory chunk.
+ *
+ * @param cap Minimum capacity.
+ */
+ public void reallocate(int cap);
+
+ /**
+ * Close memory releasing it.
+ */
+ @Override void close();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManager.java
new file mode 100644
index 0000000..c2233a8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManager.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+/**
+ * Interop memory manager interface.
+ */
+public interface PlatformMemoryManager {
+ /**
+ * Allocates memory.
+ *
+ * @return Memory.
+ */
+ public PlatformMemory allocate();
+
+ /**
+ * Allocates memory having at least the given capacity.
+ *
+ * @param cap Minimum capacity.
+ * @return Memory.
+ */
+ public PlatformMemory allocate(int cap);
+
+ /**
+ * Gets memory from existing pointer.
+ *
+ * @param memPtr Cross-platform memory pointer.
+ * @return Memory.
+ */
+ public PlatformMemory get(long memPtr);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
new file mode 100644
index 0000000..eb2490a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+import org.apache.ignite.internal.portable.streams.*;
+
+/**
+ * Interop output stream.
+ */
+public interface PlatformOutputStream extends PortableOutputStream {
+ /**
+ * Synchronize output stream with underlying memory
+ */
+ public void synchronize();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
deleted file mode 100644
index fb1eaa2..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.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.internal.processors.platform;
-
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.portable.*;
-import org.apache.ignite.internal.processors.platform.callback.*;
-import org.apache.ignite.internal.processors.platform.memory.*;
-
-import java.util.*;
-
-/**
- * Platform context. Acts as an entry point for platform operations.
- */
-public interface PlatformContext {
- /**
- * Gets kernal context.
- *
- * @return Kernal context.
- */
- public GridKernalContext kernalContext();
-
- /**
- * Gets platform memory manager.
- *
- * @return Memory manager.
- */
- public PlatformMemoryManager memory();
-
- /**
- * Gets platform callback gateway.
- *
- * @return Callback gateway.
- */
- public PlatformCallbackGateway gateway();
-
- /**
- * Get memory reader.
- *
- * @param mem Memory.
- * @return Reader.
- */
- public PortableRawReaderEx reader(PlatformMemory mem);
-
- /**
- * Get memory reader.
- *
- * @param in Input.
- * @return Reader.
- */
- public PortableRawReaderEx reader(PlatformInputStream in);
-
- /**
- * Get memory writer.
- *
- * @param mem Memory.
- * @return Writer.
- */
- public PortableRawWriterEx writer(PlatformMemory mem);
-
- /**
- * Get memory writer.
- *
- * @param out Output.
- * @return Writer.
- */
- public PortableRawWriterEx writer(PlatformOutputStream out);
-
- /**
- * Sends node info to native platform, if necessary.
- *
- * @param node Node.
- */
- public void addNode(ClusterNode node);
-
- /**
- * Writes a node id to a stream and sends node info to native platform, if necessary.
- *
- * @param writer Writer.
- * @param node Node.
- */
- public void writeNode(PortableRawWriterEx writer, ClusterNode node);
-
- /**
- * Writes multiple node ids to a stream and sends node info to native platform, if necessary.
- *
- * @param writer Writer.
- * @param nodes Nodes.
- */
- public void writeNodes(PortableRawWriterEx writer, Collection<ClusterNode> nodes);
-
- /**
- * Process metadata from the platform.
- *
- * @param reader Reader.
- */
- public void processMetadata(PortableRawReaderEx reader);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5877b301/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
deleted file mode 100644
index a8e7879..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
+++ /dev/null
@@ -1,869 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.platform.callback;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.util.*;
-
-/**
- * Gateway to all platform-dependent callbacks. Implementers might extend this class and provide additional callbacks.
- */
-@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
-public class PlatformCallbackGateway {
- /** Environment pointer. */
- protected final long envPtr;
-
- /** Lock. */
- private final GridSpinReadWriteLock lock = new GridSpinReadWriteLock();
-
- /**
- * Native gateway.
- *
- * @param envPtr Environment pointer.
- */
- public PlatformCallbackGateway(long envPtr) {
- this.envPtr = envPtr;
- }
-
- /**
- * Get environment pointer.
- *
- * @return Environment pointer.
- */
- public long environmentPointer() {
- return envPtr;
- }
-
- /**
- * Create cache store.
- *
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- public long cacheStoreCreate(long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.cacheStoreCreate(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param objPtr Object pointer.
- * @param memPtr Memory pointer.
- * @param cb Callback.
- * @return Result.
- */
- public int cacheStoreInvoke(long objPtr, long memPtr, Object cb) {
- enter();
-
- try {
- return PlatformCallbackUtils.cacheStoreInvoke(envPtr, objPtr, memPtr, cb);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param objPtr Object pointer.
- */
- public void cacheStoreDestroy(long objPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.cacheStoreDestroy(envPtr, objPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Creates cache store session.
- *
- * @param storePtr Store instance pointer.
- * @return Session instance pointer.
- */
- public long cacheStoreSessionCreate(long storePtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.cacheStoreSessionCreate(envPtr, storePtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Creates cache entry filter and returns a pointer.
- *
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- public long cacheEntryFilterCreate(long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.cacheEntryFilterCreate(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param ptr Pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- public int cacheEntryFilterApply(long ptr, long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.cacheEntryFilterApply(envPtr, ptr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param ptr Pointer.
- */
- public void cacheEntryFilterDestroy(long ptr) {
- enter();
-
- try {
- PlatformCallbackUtils.cacheEntryFilterDestroy(envPtr, ptr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Invoke cache entry processor.
- *
- * @param outMemPtr Output memory pointer.
- * @param inMemPtr Input memory pointer.
- */
- public void cacheInvoke(long outMemPtr, long inMemPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.cacheInvoke(envPtr, outMemPtr, inMemPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Perform native task map. Do not throw exceptions, serializing them to the output stream instead.
- *
- * @param taskPtr Task pointer.
- * @param outMemPtr Output memory pointer (exists if topology changed, otherwise {@code 0}).
- * @param inMemPtr Input memory pointer.
- */
- public void computeTaskMap(long taskPtr, long outMemPtr, long inMemPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.computeTaskMap(envPtr, taskPtr, outMemPtr, inMemPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Perform native task job result notification.
- *
- * @param taskPtr Task pointer.
- * @param jobPtr Job pointer.
- * @param memPtr Memory pointer (always zero for local job execution).
- * @return Job result enum ordinal.
- */
- public int computeTaskJobResult(long taskPtr, long jobPtr, long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.computeTaskJobResult(envPtr, taskPtr, jobPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Perform native task reduce.
- *
- * @param taskPtr Task pointer.
- */
- public void computeTaskReduce(long taskPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.computeTaskReduce(envPtr, taskPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Complete task with native error.
- *
- * @param taskPtr Task pointer.
- * @param memPtr Memory pointer with exception data or {@code 0} in case of success.
- */
- public void computeTaskComplete(long taskPtr, long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.computeTaskComplete(envPtr, taskPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Serialize native job.
- *
- * @param jobPtr Job pointer.
- * @param memPtr Memory pointer.
- * @return {@code True} if serialization succeeded.
- */
- public int computeJobSerialize(long jobPtr, long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.computeJobSerialize(envPtr, jobPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Create job in native platform.
- *
- * @param memPtr Memory pointer.
- * @return Pointer to job.
- */
- public long computeJobCreate(long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.computeJobCreate(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Execute native job on a node other than where it was created.
- *
- * @param jobPtr Job pointer.
- * @param cancel Cancel flag.
- * @param memPtr Memory pointer to write result to for remote job execution or {@code 0} for local job execution.
- */
- public void computeJobExecute(long jobPtr, int cancel, long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.computeJobExecute(envPtr, jobPtr, cancel, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Cancel the job.
- *
- * @param jobPtr Job pointer.
- */
- public void computeJobCancel(long jobPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.computeJobCancel(envPtr, jobPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Destroy the job.
- *
- * @param ptr Pointer.
- */
- public void computeJobDestroy(long ptr) {
- enter();
-
- try {
- PlatformCallbackUtils.computeJobDestroy(envPtr, ptr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Invoke local callback.
- *
- * @param cbPtr Callback pointer.
- * @param memPtr Memory pointer.
- */
- public void continuousQueryListenerApply(long cbPtr, long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.continuousQueryListenerApply(envPtr, cbPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Create filter in native platform.
- *
- * @param memPtr Memory pointer.
- * @return Pointer to created filter.
- */
- public long continuousQueryFilterCreate(long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.continuousQueryFilterCreate(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Invoke remote filter.
- *
- * @param filterPtr Filter pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- public int continuousQueryFilterApply(long filterPtr, long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.continuousQueryFilterApply(envPtr, filterPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Release remote filter.
- *
- * @param filterPtr Filter pointer.
- */
- public void continuousQueryFilterRelease(long filterPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.continuousQueryFilterRelease(envPtr, filterPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify native data streamer about topology update.
- *
- * @param ptr Data streamer native pointer.
- * @param topVer Topology version.
- * @param topSize Topology size.
- */
- public void dataStreamerTopologyUpdate(long ptr, long topVer, int topSize) {
- enter();
-
- try {
- PlatformCallbackUtils.dataStreamerTopologyUpdate(envPtr, ptr, topVer, topSize);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Invoke stream receiver.
- *
- * @param ptr Receiver native pointer.
- * @param cache Cache object.
- * @param memPtr Stream pointer.
- * @param keepPortable Portable flag.
- */
- public void dataStreamerStreamReceiverInvoke(long ptr, Object cache, long memPtr, boolean keepPortable) {
- enter();
-
- try {
- PlatformCallbackUtils.dataStreamerStreamReceiverInvoke(envPtr, ptr, cache, memPtr, keepPortable);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with byte result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureByteResult(long futPtr, int res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureByteResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with boolean result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureBoolResult(long futPtr, int res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureBoolResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with short result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureShortResult(long futPtr, int res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureShortResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with byte result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureCharResult(long futPtr, int res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureCharResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with int result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureIntResult(long futPtr, int res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureIntResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with float result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureFloatResult(long futPtr, float res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureFloatResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with long result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureLongResult(long futPtr, long res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureLongResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with double result.
- *
- * @param futPtr Future pointer.
- * @param res Result.
- */
- public void futureDoubleResult(long futPtr, double res) {
- enter();
-
- try {
- PlatformCallbackUtils.futureDoubleResult(envPtr, futPtr, res);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with object result.
- *
- * @param futPtr Future pointer.
- * @param memPtr Memory pointer.
- */
- public void futureObjectResult(long futPtr, long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.futureObjectResult(envPtr, futPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with null result.
- *
- * @param futPtr Future pointer.
- */
- public void futureNullResult(long futPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.futureNullResult(envPtr, futPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Notify future with error.
- *
- * @param futPtr Future pointer.
- * @param memPtr Pointer to memory with error information.
- */
- public void futureError(long futPtr, long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.futureError(envPtr, futPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Creates message filter and returns a pointer.
- *
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- public long messagingFilterCreate(long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.messagingFilterCreate(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param ptr Pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- public int messagingFilterApply(long ptr, long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.messagingFilterApply(envPtr, ptr, memPtr);
- }
- finally {
- leave();
- }}
-
- /**
- * @param ptr Pointer.
- */
- public void messagingFilterDestroy(long ptr) {
- enter();
-
- try {
- PlatformCallbackUtils.messagingFilterDestroy(envPtr, ptr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Creates event filter and returns a pointer.
- *
- * @param memPtr Memory pointer.
- * @return Pointer.
- */
- public long eventFilterCreate(long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.eventFilterCreate(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param ptr Pointer.
- * @param memPtr Memory pointer.
- * @return Result.
- */
- public int eventFilterApply(long ptr, long memPtr) {
- enter();
-
- try {
- return PlatformCallbackUtils.eventFilterApply(envPtr, ptr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * @param ptr Pointer.
- */
- public void eventFilterDestroy(long ptr) {
- enter();
-
- try {
- PlatformCallbackUtils.eventFilterDestroy(envPtr, ptr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Sends node info to native target.
- *
- * @param memPtr Ptr to a stream with serialized node.
- */
- public void nodeInfo(long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.nodeInfo(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Kernal start callback.
- *
- * @param memPtr Memory pointer.
- */
- public void onStart(long memPtr) {
- enter();
-
- try {
- PlatformCallbackUtils.onStart(envPtr, memPtr);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Lifecycle event callback.
- *
- * @param ptr Holder pointer.
- * @param evt Event.
- */
- public void lifecycleEvent(long ptr, int evt) {
- enter();
-
- try {
- PlatformCallbackUtils.lifecycleEvent(envPtr, ptr, evt);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Re-allocate external memory chunk.
- *
- * @param memPtr Cross-platform pointer.
- * @param cap Capacity.
- */
- public void memoryReallocate(long memPtr, int cap) {
- enter();
-
- try {
- PlatformCallbackUtils.memoryReallocate(envPtr, memPtr, cap);
- }
- finally {
- leave();
- }
- }
-
- /**
- * Initializes native service.
- *
- * @param memPtr Pointer.
- * @throws org.apache.ignite.IgniteCheckedException In case of error.
- */
- public long serviceInit(long memPtr) throws IgniteCheckedException {
- return PlatformCallbackUtils.serviceInit(envPtr, memPtr);
- }
-
- /**
- * Executes native service.
- *
- * @param svcPtr Pointer to the service in the native platform.
- * @param memPtr Stream pointer.
- * @throws org.apache.ignite.IgniteCheckedException In case of error.
- */
- public void serviceExecute(long svcPtr, long memPtr) throws IgniteCheckedException {
- PlatformCallbackUtils.serviceExecute(envPtr, svcPtr, memPtr);
- }
-
- /**
- * Cancels native service.
- *
- * @param svcPtr Pointer to the service in the native platform.
- * @param memPtr Stream pointer.
- * @throws org.apache.ignite.IgniteCheckedException In case of error.
- */
- public void serviceCancel(long svcPtr, long memPtr) throws IgniteCheckedException {
- PlatformCallbackUtils.serviceCancel(envPtr, svcPtr, memPtr);
- }
-
- /**
- * Invokes service method.
- *
- * @param svcPtr Pointer to the service in the native platform.
- * @param outMemPtr Output memory pointer.
- * @param inMemPtr Input memory pointer.
- * @throws org.apache.ignite.IgniteCheckedException In case of error.
- */
- public void serviceInvokeMethod(long svcPtr, long outMemPtr, long inMemPtr) throws IgniteCheckedException {
- PlatformCallbackUtils.serviceInvokeMethod(envPtr, svcPtr, outMemPtr, inMemPtr);
- }
-
- /**
- * Invokes cluster node filter.
- *
- * @param memPtr Stream pointer.
- */
- public int clusterNodeFilterApply(long memPtr) {
- return PlatformCallbackUtils.clusterNodeFilterApply(envPtr, memPtr);
- }
-
- /**
- * Kernal stop callback.
- */
- public void onStop() {
- block();
-
- PlatformCallbackUtils.onStop(envPtr);
- }
-
- /**
- * Enter gateway.
- */
- protected void enter() {
- if (!lock.tryReadLock())
- throw new IgniteException("Failed to execute native callback because grid is stopping.");
- }
-
- /**
- * Leave gateway.
- */
- protected void leave() {
- lock.readUnlock();
- }
-
- /**
- * Block gateway.
- */
- protected void block() {
- lock.writeLock();
- }
-}
[12/41] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/76bc7d61
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/76bc7d61
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/76bc7d61
Branch: refs/heads/ignite-1093
Commit: 76bc7d61352f68c3e1fe83652a747f234adcd0c1
Parents: 194df76 203f00c
Author: sboikov <sb...@gridgain.com>
Authored: Wed Aug 26 10:45:25 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Aug 26 10:45:25 2015 +0300
----------------------------------------------------------------------
.../internal/platform/PlatformBootstrap.java | 36 -
.../platform/PlatformBootstrapFactory.java | 37 -
.../internal/platform/PlatformException.java | 71 --
.../internal/platform/PlatformIgnition.java | 187 ----
.../platform/PlatformNoCallbackException.java | 50 --
.../callback/PlatformCallbackGateway.java | 869 -------------------
.../callback/PlatformCallbackUtils.java | 468 ----------
.../platform/memory/PlatformAbstractMemory.java | 121 ---
.../PlatformBigEndianInputStreamImpl.java | 126 ---
.../PlatformBigEndianOutputStreamImpl.java | 162 ----
.../platform/memory/PlatformExternalMemory.java | 55 --
.../platform/memory/PlatformInputStream.java | 30 -
.../memory/PlatformInputStreamImpl.java | 323 -------
.../platform/memory/PlatformMemory.java | 77 --
.../platform/memory/PlatformMemoryManager.java | 46 -
.../memory/PlatformMemoryManagerImpl.java | 83 --
.../platform/memory/PlatformMemoryPool.java | 133 ---
.../platform/memory/PlatformMemoryUtils.java | 468 ----------
.../platform/memory/PlatformOutputStream.java | 30 -
.../memory/PlatformOutputStreamImpl.java | 259 ------
.../platform/memory/PlatformPooledMemory.java | 63 --
.../platform/memory/PlatformUnpooledMemory.java | 51 --
.../platform/utils/PlatformReaderBiClosure.java | 34 -
.../platform/utils/PlatformReaderClosure.java | 34 -
.../platform/utils/PlatformWriterBiClosure.java | 34 -
.../platform/utils/PlatformWriterClosure.java | 33 -
.../platform/PlatformAbstractBootstrap.java | 47 +
.../processors/platform/PlatformBootstrap.java | 36 +
.../platform/PlatformBootstrapFactory.java | 37 +
.../processors/platform/PlatformException.java | 71 ++
.../processors/platform/PlatformIgnition.java | 186 ++++
.../platform/PlatformNoCallbackException.java | 50 ++
.../callback/PlatformCallbackGateway.java | 869 +++++++++++++++++++
.../callback/PlatformCallbackUtils.java | 468 ++++++++++
.../platform/memory/PlatformAbstractMemory.java | 121 +++
.../PlatformBigEndianInputStreamImpl.java | 126 +++
.../PlatformBigEndianOutputStreamImpl.java | 162 ++++
.../platform/memory/PlatformExternalMemory.java | 55 ++
.../platform/memory/PlatformInputStream.java | 30 +
.../memory/PlatformInputStreamImpl.java | 323 +++++++
.../platform/memory/PlatformMemory.java | 77 ++
.../platform/memory/PlatformMemoryManager.java | 46 +
.../memory/PlatformMemoryManagerImpl.java | 83 ++
.../platform/memory/PlatformMemoryPool.java | 133 +++
.../platform/memory/PlatformMemoryUtils.java | 468 ++++++++++
.../platform/memory/PlatformOutputStream.java | 30 +
.../memory/PlatformOutputStreamImpl.java | 259 ++++++
.../platform/memory/PlatformPooledMemory.java | 63 ++
.../platform/memory/PlatformUnpooledMemory.java | 51 ++
.../platform/utils/PlatformReaderBiClosure.java | 34 +
.../platform/utils/PlatformReaderClosure.java | 34 +
.../platform/utils/PlatformWriterBiClosure.java | 34 +
.../platform/utils/PlatformWriterClosure.java | 33 +
53 files changed, 3926 insertions(+), 3880 deletions(-)
----------------------------------------------------------------------
[13/41] ignite git commit: IGNITE-1277: Enabled backups in IGFS data
cache. Contributed by Ivan Veselovsky.
Posted by sb...@apache.org.
IGNITE-1277: Enabled backups in IGFS data cache.
Contributed by Ivan Veselovsky.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/28d64d53
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/28d64d53
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/28d64d53
Branch: refs/heads/ignite-1093
Commit: 28d64d53143119fe64e5b2e8499bb2a978800efc
Parents: 203f00c
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 10:59:54 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 10:59:54 2015 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsProcessor.java | 8 -
.../processors/igfs/IgfsAbstractSelfTest.java | 34 +-
.../igfs/IgfsBackupFailoverSelfTest.java | 488 +++++++++++++++++++
.../igfs/IgfsBackupsDualAsyncSelfTest.java | 40 ++
.../igfs/IgfsBackupsDualSyncSelfTest.java | 40 ++
.../igfs/IgfsBackupsPrimarySelfTest.java | 40 ++
.../ignite/testsuites/IgniteIgfsTestSuite.java | 7 +
7 files changed, 643 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d64d53/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
index af41ec4..f3522a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
@@ -311,14 +311,6 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
", maxIgfsSpaceSize=" + maxSpaceSize + ']');
}
- if (dataCacheCfg.getCacheMode() == PARTITIONED) {
- int backups = dataCacheCfg.getBackups();
-
- if (backups != 0)
- throw new IgniteCheckedException("IGFS data cache cannot be used with backups (set backup count " +
- "to 0 and restart the grid): " + cfg.getDataCacheName());
- }
-
if (cfg.getMaxSpaceSize() == 0 && dataCacheCfg.getMemoryMode() == OFFHEAP_VALUES)
U.warn(log, "IGFS max space size is not specified but data cache values are stored off-heap (max " +
"space will be limited to 80% of max JVM heap size): " + cfg.getName());
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d64d53/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
index a8a8957..85aaeb3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
@@ -146,6 +146,12 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
this(mode, ONHEAP_TIERED);
}
+ /**
+ * Constructor.
+ *
+ * @param mode
+ * @param memoryMode
+ */
protected IgfsAbstractSelfTest(IgfsMode mode, CacheMemoryMode memoryMode) {
assert mode != null && mode != PROXY;
@@ -155,7 +161,12 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
dual = mode != PRIMARY;
}
- private static byte[] createChunk(int length) {
+ /**
+ *
+ * @param length
+ * @return
+ */
+ static byte[] createChunk(int length) {
byte[] chunk = new byte[length];
for (int i = 0; i < chunk.length; i++)
@@ -246,6 +257,8 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
+ prepareCacheConfigurations(dataCacheCfg, metaCacheCfg);
+
cfg.setDiscoverySpi(discoSpi);
cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
cfg.setFileSystemConfiguration(igfsCfg);
@@ -257,6 +270,15 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
}
/**
+ *
+ * @param dataCacheCfg
+ * @param metaCacheCfg
+ */
+ protected void prepareCacheConfigurations(CacheConfiguration dataCacheCfg, CacheConfiguration metaCacheCfg) {
+ // Noop
+ }
+
+ /**
* Execute provided task in a separate thread.
*
* @param task Task to execute.
@@ -2263,7 +2285,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param chunks Data chunks.
* @throws Exception If failed.
*/
- protected void createFile(IgfsImpl igfs, IgfsPath file, boolean overwrite, long blockSize,
+ protected static void createFile(IgfsImpl igfs, IgfsPath file, boolean overwrite, long blockSize,
@Nullable byte[]... chunks) throws Exception {
IgfsOutputStream os = null;
@@ -2287,7 +2309,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param chunks Data chunks.
* @throws Exception If failed.
*/
- protected void appendFile(IgfsImpl igfs, IgfsPath file, @Nullable byte[]... chunks)
+ protected static void appendFile(IgfsImpl igfs, IgfsPath file, @Nullable byte[]... chunks)
throws Exception {
IgfsOutputStream os = null;
@@ -2354,7 +2376,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param paths Paths.
* @throws IgniteCheckedException If failed.
*/
- protected void checkExist(IgfsImpl igfs, IgfsPath... paths) throws IgniteCheckedException {
+ protected static void checkExist(IgfsImpl igfs, IgfsPath... paths) throws IgniteCheckedException {
for (IgfsPath path : paths) {
assert igfs.context().meta().fileId(path) != null : "Path doesn't exist [igfs=" + igfs.name() +
", path=" + path + ']';
@@ -2463,7 +2485,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @throws IOException In case of IO exception.
* @throws IgniteCheckedException In case of Grid exception.
*/
- protected void checkFileContent(IgfsImpl igfs, IgfsPath file, @Nullable byte[]... chunks)
+ protected static void checkFileContent(IgfsImpl igfs, IgfsPath file, @Nullable byte[]... chunks)
throws IOException, IgniteCheckedException {
if (chunks != null && chunks.length > 0) {
IgfsInputStream is = null;
@@ -2562,7 +2584,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param paths Paths to group.
* @return Paths as array.
*/
- protected IgfsPath[] paths(IgfsPath... paths) {
+ protected static IgfsPath[] paths(IgfsPath... paths) {
return paths;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d64d53/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java
new file mode 100644
index 0000000..0162121
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java
@@ -0,0 +1,488 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.igfs;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.igfs.*;
+import org.apache.ignite.igfs.secondary.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.testframework.*;
+import org.jetbrains.annotations.*;
+
+import java.io.*;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.internal.processors.igfs.IgfsAbstractSelfTest.*;
+
+/**
+ * Tests IGFS behavioral guarantees if some nodes on the cluster are synchronously or asynchronously stopped.
+ * The operations to check are read, write or both.
+ */
+public class IgfsBackupFailoverSelfTest extends IgfsCommonAbstractTest {
+ /** Directory. */
+ protected static final IgfsPath DIR = new IgfsPath("/dir");
+
+ /** Sub-directory. */
+ protected static final IgfsPath SUBDIR = new IgfsPath(DIR, "subdir");
+
+ /** Number of Ignite nodes used in failover tests. */
+ protected final int numIgfsNodes = 5;
+
+ /** Number of backup copies of data (aka replication). */
+ protected final int numBackups = numIgfsNodes - 1;
+
+ /** */
+ private final int fileSize = 16 * 1024;
+
+ /** */
+ private final int files = 500;
+
+ /** File block size. Use Very small blocks to ensure uniform data distribution among the nodes.. */
+ protected int igfsBlockSize = 31;
+
+ /** Affinity group size (see IgfsGroupDataBlocksKeyMapper). */
+ protected int affGrpSize = 1;
+
+ /** IGFS mode. */
+ protected IgfsMode igfsMode = IgfsMode.PRIMARY;
+
+ /** Node data structures. */
+ protected NodeFsData[] nodeDatas;
+
+ /**
+ * Structure to hold Ignite IGFS node data.
+ */
+ static class NodeFsData {
+ /** */
+ int idx;
+
+ /** */
+ Ignite ignite;
+
+ /** */
+ IgfsImpl igfsImpl;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ nodeDatas = new NodeFsData[numIgfsNodes];
+
+ for (int i = 0; i<numIgfsNodes; i++) {
+ NodeFsData data = new NodeFsData();
+
+ data.idx = i;
+
+ data.ignite = startGridWithIgfs(getTestGridName(i), igfsMode, null);
+
+ data.igfsImpl = (IgfsImpl) data.ignite.fileSystem("igfs");
+
+ nodeDatas[i] = data;
+ }
+
+ // Ensure all the nodes are started and discovered each other:
+ checkTopology(numIgfsNodes);
+ }
+
+ /**
+ * Creates IPC configuration.
+ *
+ * @param port The port to use.
+ * @return The endpoint configuration.
+ */
+ protected IgfsIpcEndpointConfiguration createIgfsRestConfig(int port) {
+ IgfsIpcEndpointConfiguration cfg = new IgfsIpcEndpointConfiguration();
+
+ cfg.setType(IgfsIpcEndpointType.TCP);
+ cfg.setPort(port);
+
+ return cfg;
+ }
+
+ /**
+ * Start grid with IGFS.
+ *
+ * @param gridName Grid name.
+ * @param mode IGFS mode.
+ * @param secondaryFs Secondary file system (optional).
+ * @return Started grid instance.
+ * @throws Exception If failed.
+ */
+ protected Ignite startGridWithIgfs(String gridName, IgfsMode mode, @Nullable IgfsSecondaryFileSystem secondaryFs)
+ throws Exception {
+ final FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
+
+ igfsCfg.setDataCacheName("dataCache");
+ igfsCfg.setMetaCacheName("metaCache");
+ igfsCfg.setName("igfs");
+ igfsCfg.setBlockSize(igfsBlockSize);
+ igfsCfg.setDefaultMode(mode);
+ igfsCfg.setSecondaryFileSystem(secondaryFs);
+
+ CacheConfiguration<?,?> dataCacheCfg = defaultCacheConfiguration();
+
+ dataCacheCfg.setName("dataCache");
+ dataCacheCfg.setCacheMode(PARTITIONED);
+ dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+ dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(affGrpSize));
+ dataCacheCfg.setBackups(numBackups);
+ dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
+
+ CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
+
+ metaCacheCfg.setName("metaCache");
+ metaCacheCfg.setCacheMode(REPLICATED);
+ metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+ metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setGridName(gridName);
+
+ cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
+ cfg.setFileSystemConfiguration(igfsCfg);
+
+ cfg.setLocalHost("127.0.0.1");
+
+ return startGrid(gridName, cfg);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ G.stopAll(false);
+
+ Arrays.fill(nodeDatas, null);
+ }
+
+ /**
+ * Creates a chunk of data.
+ *
+ * @param len The chunk length
+ * @param j index to scramble into the data.
+ * @return The chunk.
+ */
+ static byte[] createChunk(int len, int j) {
+ byte[] bb = new byte[len];
+
+ for (int i = 0; i < bb.length; i++)
+ bb[i] = (byte)(i ^ j);
+
+ return bb;
+ }
+
+ /**
+ * Composes the path of the file.
+ */
+ private IgfsPath filePath(int j) {
+ return new IgfsPath(SUBDIR, "file" + j);
+ }
+
+ /**
+ * Checks correct data read *after* N-1 nodes are stopped.
+ *
+ * @throws Exception On error.
+ */
+ public void testReadFailoverAfterStopMultipleNodes() throws Exception {
+ final IgfsImpl igfs0 = nodeDatas[0].igfsImpl;
+
+ clear(igfs0);
+
+ IgfsAbstractSelfTest.create(igfs0, paths(DIR, SUBDIR), null);
+
+ // Create files through the 0th node:
+ for (int f=0; f<files; f++) {
+ final byte[] data = createChunk(fileSize, f);
+
+ createFile(igfs0, filePath(f), true, -1/*block size unused*/, data);
+ }
+
+ // Check files:
+ for (int f=0; f<files; f++) {
+ IgfsPath path = filePath(f);
+ byte[] data = createChunk(fileSize, f);
+
+ // Check through 0th node:
+ checkExist(igfs0, path);
+
+ checkFileContent(igfs0, path, data);
+
+ // Check the same file through other nodes:
+ for (int n=1; n<numIgfsNodes; n++) {
+ checkExist(nodeDatas[n].igfsImpl, path);
+
+ checkFileContent(nodeDatas[n].igfsImpl, path, data);
+ }
+ }
+
+ // Now stop all the nodes but the 1st:
+ for (int n=1; n<numIgfsNodes; n++)
+ stopGrid(n);
+
+ // Check files again:
+ for (int f=0; f<files; f++) {
+ IgfsPath path = filePath(f);
+
+ byte[] data = createChunk(fileSize, f);
+
+ // Check through 0th node:
+ checkExist(igfs0, path);
+
+ checkFileContent(igfs0, path, data);
+ }
+ }
+
+ /**
+ * Checks correct data read *while* N-1 nodes are being concurrently stopped.
+ *
+ * @throws Exception On error.
+ */
+ public void testReadFailoverWhileStoppingMultipleNodes() throws Exception {
+ final IgfsImpl igfs0 = nodeDatas[0].igfsImpl;
+
+ clear(igfs0);
+
+ IgfsAbstractSelfTest.create(igfs0, paths(DIR, SUBDIR), null);
+
+ // Create files:
+ for (int f = 0; f < files; f++) {
+ final byte[] data = createChunk(fileSize, f);
+
+ createFile(igfs0, filePath(f), true, -1/*block size unused*/, data);
+ }
+
+ // Check files:
+ for (int f = 0; f < files; f++) {
+ IgfsPath path = filePath(f);
+ byte[] data = createChunk(fileSize, f);
+
+ // Check through 1st node:
+ checkExist(igfs0, path);
+
+ checkFileContent(igfs0, path, data);
+
+ // Check the same file through other nodes:
+ for (int n = 1; n < numIgfsNodes; n++) {
+ checkExist(nodeDatas[n].igfsImpl, path);
+
+ checkFileContent(nodeDatas[n].igfsImpl, path, data);
+ }
+ }
+
+ final AtomicBoolean stop = new AtomicBoolean();
+
+ GridTestUtils.runMultiThreadedAsync(new Callable() {
+ @Override
+ public Object call() throws Exception {
+ Thread.sleep(1_000); // Some delay to ensure read is in progress.
+
+ // Now stop all the nodes but the 1st:
+ for (int n = 1; n < numIgfsNodes; n++) {
+ stopGrid(n);
+
+ X.println("grid " + n + " stopped.");
+ }
+
+ Thread.sleep(1_000);
+
+ stop.set(true);
+
+ return null;
+ }
+ }, 1, "igfs-node-stopper");
+
+ // Read the files repeatedly, while the nodes are being stopped:
+ while (!stop.get()) {
+ // Check files while the nodes are being stopped:
+ for (int f = 0; f < files; f++) {
+ IgfsPath path = filePath(f);
+
+ byte[] data = createChunk(fileSize, f);
+
+ // Check through 1st node:
+ checkExist(igfs0, path);
+
+ checkFileContent(igfs0, path, data);
+ }
+ }
+ }
+
+ /**
+ * Checks possibility to append the data to files *after* N-1 nodes are stopped.
+ * First, some data written to files.
+ * After that N-1 nodes are stopped.
+ * Then data are attempted to append to the streams opened before the nodes stop.
+ * If failed, the streams are attempted to reopen and the files are attempted to append.
+ * After that the read operation is performed to check data correctness.
+ *
+ * The test is temporarily disabled due to issues .... .
+ *
+ * @throws Exception On error.
+ */
+ public void testWriteFailoverAfterStopMultipleNodes() throws Exception {
+ final IgfsImpl igfs0 = nodeDatas[0].igfsImpl;
+
+ clear(igfs0);
+
+ IgfsAbstractSelfTest.create(igfs0, paths(DIR, SUBDIR), null);
+
+ final IgfsOutputStream[] outStreams = new IgfsOutputStream[files];
+
+ // Create files:
+ for (int f = 0; f < files; f++) {
+ final byte[] data = createChunk(fileSize, f);
+
+ IgfsOutputStream os = null;
+
+ try {
+ os = igfs0.create(filePath(f), 256, true, null, 0, -1, null);
+
+ assert os != null;
+
+ writeFileChunks(os, data);
+ }
+ finally {
+ if (os != null)
+ os.flush();
+ }
+
+ outStreams[f] = os;
+
+ X.println("write #1 completed: " + f);
+ }
+
+ // Now stop all the nodes but the 1st:
+ for (int n = 1; n < numIgfsNodes; n++) {
+ stopGrid(n);
+
+ X.println("#### grid " + n + " stopped.");
+ }
+
+ // Create files:
+ for (int f0 = 0; f0 < files; f0++) {
+ final IgfsOutputStream os = outStreams[f0];
+
+ assert os != null;
+
+ final int f = f0;
+
+ int att = doWithRetries(2, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ IgfsOutputStream ios = os;
+
+ try {
+ writeChunks0(igfs0, ios, f);
+ }
+ catch (IOException ioe) {
+ log().warning("Attempt to append the data to existing stream failed: ", ioe);
+
+ ios = igfs0.append(filePath(f), false);
+
+ assert ios != null;
+
+ writeChunks0(igfs0, ios, f);
+ }
+
+ return null;
+ }
+ });
+
+ X.println("write #2 completed: " + f0 + " in " + att + " attempts.");
+ }
+
+ // Check files:
+ for (int f = 0; f < files; f++) {
+ IgfsPath path = filePath(f);
+
+ byte[] data = createChunk(fileSize, f);
+
+ // Check through 1st node:
+ checkExist(igfs0, path);
+
+ assertEquals("File length mismatch.", data.length * 2, igfs0.size(path));
+
+ checkFileContent(igfs0, path, data, data);
+
+ X.println("Read test completed: " + f);
+ }
+ }
+
+ /**
+ * Writes data to the file of the specified index and closes the output stream.
+ *
+ * @param igfs0 IGFS.
+ * @param ios The output stream
+ * @param fileIdx Th eindex of the file.
+ * @throws IOException On error.
+ */
+ void writeChunks0(IgfsEx igfs0, IgfsOutputStream ios, int fileIdx) throws IOException {
+ try {
+ byte[] data = createChunk(fileSize, fileIdx);
+
+ writeFileChunks(ios, data);
+ }
+ finally {
+ ios.flush();
+
+ U.closeQuiet(ios);
+
+ awaitFileClose(igfs0.asSecondary(), filePath(fileIdx));
+ }
+ }
+
+ /**
+ * Performs an operation with retries.
+ *
+ * @param attempts The maximum number of attempts.
+ * @param clo The closure to execute.
+ * @throws Exception On error.
+ */
+ protected static int doWithRetries(int attempts, Callable<Void> clo) throws Exception {
+ int attemptCnt = 0;
+
+ while (true) {
+ try {
+ attemptCnt++;
+
+ clo.call();
+
+ return attemptCnt;
+ }
+ catch (Exception e) {
+ if (attemptCnt >= attempts)
+ throw e;
+ else
+ X.println("Failed to execute closure in " + attempts + " attempts.");
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return 20 * 60 * 1000;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d64d53/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupsDualAsyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupsDualAsyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupsDualAsyncSelfTest.java
new file mode 100644
index 0000000..3c042d6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupsDualAsyncSelfTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.igfs;
+
+import org.apache.ignite.configuration.*;
+
+import static org.apache.ignite.igfs.IgfsMode.*;
+
+/**
+ * Tests for DUAL_ASYNC mode.
+ */
+public class IgfsBackupsDualAsyncSelfTest extends IgfsDualAbstractSelfTest {
+ /**
+ * Constructor.
+ */
+ public IgfsBackupsDualAsyncSelfTest() {
+ super(DUAL_ASYNC);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void prepareCacheConfigurations(CacheConfiguration dataCacheCfg,
+ CacheConfiguration metaCacheCfg) {
+ dataCacheCfg.setBackups(1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d64d53/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupsDualSyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupsDualSyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupsDualSyncSelfTest.java
new file mode 100644
index 0000000..5d7fdaf
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupsDualSyncSelfTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.igfs;
+
+import org.apache.ignite.configuration.*;
+
+import static org.apache.ignite.igfs.IgfsMode.*;
+
+/**
+ * Tests for DUAL_SYNC mode.
+ */
+public class IgfsBackupsDualSyncSelfTest extends IgfsDualAbstractSelfTest {
+ /**
+ * Constructor.
+ */
+ public IgfsBackupsDualSyncSelfTest() {
+ super(DUAL_SYNC);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void prepareCacheConfigurations(CacheConfiguration dataCacheCfg,
+ CacheConfiguration metaCacheCfg) {
+ dataCacheCfg.setBackups(1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d64d53/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupsPrimarySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupsPrimarySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupsPrimarySelfTest.java
new file mode 100644
index 0000000..c4958a8
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupsPrimarySelfTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.igfs;
+
+import org.apache.ignite.configuration.*;
+
+import static org.apache.ignite.igfs.IgfsMode.*;
+
+/**
+ * Tests for PRIMARY mode.
+ */
+public class IgfsBackupsPrimarySelfTest extends IgfsAbstractSelfTest {
+ /**
+ * Constructor.
+ */
+ public IgfsBackupsPrimarySelfTest() {
+ super(PRIMARY);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void prepareCacheConfigurations(CacheConfiguration dataCacheCfg,
+ CacheConfiguration metaCacheCfg) {
+ dataCacheCfg.setBackups(1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d64d53/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
index f8dac3d..73e6a03 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
@@ -79,6 +79,13 @@ public class IgniteIgfsTestSuite extends TestSuite {
suite.addTestSuite(IgfsStartCacheTest.class);
+ suite.addTestSuite(IgfsBackupsPrimarySelfTest.class);
+ suite.addTestSuite(IgfsBackupsDualSyncSelfTest.class);
+ suite.addTestSuite(IgfsBackupsDualAsyncSelfTest.class);
+
+ // TODO: Enable when IGFS failover is fixed.
+ //suite.addTestSuite(IgfsBackupFailoverSelfTest.class);
+
return suite;
}
}
[10/41] ignite git commit: Moved "AbstractBootstrap" class to Ignite.
Posted by sb...@apache.org.
Moved "AbstractBootstrap" class to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/203f00c7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/203f00c7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/203f00c7
Branch: refs/heads/ignite-1093
Commit: 203f00c774e6dd2eddf7a530b70c22e75feb3429
Parents: 2225f8d
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 09:41:32 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 09:41:32 2015 +0300
----------------------------------------------------------------------
.../platform/PlatformAbstractBootstrap.java | 47 ++++++++++++++++++++
1 file changed, 47 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/203f00c7/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java
new file mode 100644
index 0000000..4db3c1e
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.platform;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.platform.memory.*;
+import org.apache.ignite.lang.*;
+
+/**
+ * Base interop bootstrap implementation.
+ */
+public abstract class PlatformAbstractBootstrap implements PlatformBootstrap {
+ /** {@inheritDoc} */
+ @Override public PlatformProcessor start(IgniteConfiguration cfg, long envPtr, long dataPtr) {
+ Ignition.setClientMode(new PlatformExternalMemory(null, dataPtr).input().readBoolean());
+
+ IgniteConfiguration cfg0 = closure(envPtr).apply(cfg);
+
+ IgniteEx node = (IgniteEx) Ignition.start(cfg0);
+
+ return node.context().platform();
+ }
+
+ /**
+ * Get configuration transformer closure.
+ *
+ * @param envPtr Environment pointer.
+ * @return Closure.
+ */
+ protected abstract IgniteClosure<IgniteConfiguration, IgniteConfiguration> closure(long envPtr);
+}
[05/41] ignite git commit: Moving platform utility closures to Ignite.
Posted by sb...@apache.org.
Moving platform utility closures to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c47a7061
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c47a7061
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c47a7061
Branch: refs/heads/ignite-1093
Commit: c47a7061f042f60a73fd9014091e98b2c656bfb4
Parents: 2e6d915
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 09:13:45 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 09:13:45 2015 +0300
----------------------------------------------------------------------
.../platform/utils/PlatformReaderBiClosure.java | 34 ++++++++++++++++++++
.../platform/utils/PlatformReaderClosure.java | 34 ++++++++++++++++++++
.../platform/utils/PlatformWriterBiClosure.java | 34 ++++++++++++++++++++
.../platform/utils/PlatformWriterClosure.java | 33 +++++++++++++++++++
4 files changed, 135 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c47a7061/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderBiClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderBiClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderBiClosure.java
new file mode 100644
index 0000000..0280ba8
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderBiClosure.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.platform.utils;
+
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.lang.*;
+
+/**
+ * Reader bi-closure.
+ */
+public interface PlatformReaderBiClosure<T1, T2> {
+ /**
+ * Read object from reader.
+ *
+ * @param reader Reader.
+ * @return Object.
+ */
+ IgniteBiTuple<T1, T2> read(PortableRawReaderEx reader);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c47a7061/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderClosure.java
new file mode 100644
index 0000000..73a24d1
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderClosure.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.platform.utils;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ * Reader closure.
+ */
+public interface PlatformReaderClosure<T> {
+
+ /**
+ * Read object from reader.
+ *
+ * @param reader Reader.
+ * @return Object.
+ */
+ T read(PortableRawReaderEx reader);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c47a7061/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterBiClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterBiClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterBiClosure.java
new file mode 100644
index 0000000..cbd34fa
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterBiClosure.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.platform.utils;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ * Interop writer bi-closure.
+ */
+public interface PlatformWriterBiClosure<T1, T2> {
+ /**
+ * Write values.
+ *
+ * @param writer Writer.
+ * @param val1 Value 1.
+ * @param val2 Value 2.
+ */
+ public void write(PortableRawWriterEx writer, T1 val1, T2 val2);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c47a7061/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterClosure.java
new file mode 100644
index 0000000..d9953ca
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterClosure.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.platform.utils;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ * Interop writer closure.
+ */
+public interface PlatformWriterClosure<T> {
+ /**
+ * Write value.
+ *
+ * @param writer Writer.
+ * @param val Value.
+ */
+ public void write(PortableRawWriterEx writer, T val);
+}
[40/41] ignite git commit: Merge remote-tracking branch
'remotes/origin/master' into ignite-1093
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-1093
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a7ddb62c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a7ddb62c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a7ddb62c
Branch: refs/heads/ignite-1093
Commit: a7ddb62cc70e92704c8732617edac071aa891555
Parents: 4ddb969 e4ba2eb
Author: Anton Vinogradov <vi...@gmail.com>
Authored: Thu Aug 27 11:52:40 2015 +0300
Committer: Anton Vinogradov <vi...@gmail.com>
Committed: Thu Aug 27 11:52:40 2015 +0300
----------------------------------------------------------------------
assembly/dependencies-hadoop.xml | 1 +
.../ignite/codegen/MessageCodeGenerator.java | 30 +-
.../internal/GridEventConsumeHandler.java | 2 +-
.../ignite/internal/GridJobCancelRequest.java | 2 +-
.../ignite/internal/GridJobExecuteRequest.java | 2 +-
.../ignite/internal/GridJobExecuteResponse.java | 2 +-
.../ignite/internal/GridJobSiblingsRequest.java | 2 +-
.../internal/GridJobSiblingsResponse.java | 2 +-
.../ignite/internal/GridTaskCancelRequest.java | 2 +-
.../ignite/internal/GridTaskSessionRequest.java | 2 +-
.../internal/direct/DirectByteBufferStream.java | 2 +-
.../internal/direct/DirectMessageReader.java | 6 +
.../checkpoint/GridCheckpointRequest.java | 2 +-
.../managers/communication/GridIoManager.java | 2 +-
.../managers/communication/GridIoMessage.java | 8 +-
.../communication/GridIoUserMessage.java | 2 +-
.../deployment/GridDeploymentInfoBean.java | 2 +-
.../deployment/GridDeploymentRequest.java | 2 +-
.../deployment/GridDeploymentResponse.java | 2 +-
.../eventstorage/GridEventStorageManager.java | 2 +-
.../eventstorage/GridEventStorageMessage.java | 2 +-
.../platform/PlatformAwareEventFilter.java | 37 -
.../platform/PlatformLocalEventListener.java | 28 -
.../internal/portable/PortableContext.java | 4 -
.../affinity/AffinityTopologyVersion.java | 2 +-
.../cache/CacheEntryInfoCollection.java | 2 +-
.../cache/CacheEntryPredicateAdapter.java | 2 +-
.../cache/CacheEntryPredicateContainsValue.java | 2 +-
.../cache/CacheEntrySerializablePredicate.java | 2 +-
.../processors/cache/CacheEvictionEntry.java | 2 +-
.../cache/CacheInvokeDirectResult.java | 2 +-
.../processors/cache/CacheObjectAdapter.java | 2 +-
.../cache/CacheObjectByteArrayImpl.java | 2 +-
.../processors/cache/GridCacheEntryInfo.java | 2 +-
.../cache/GridCacheEvictionRequest.java | 2 +-
.../cache/GridCacheEvictionResponse.java | 2 +-
.../processors/cache/GridCacheMessage.java | 2 +-
.../processors/cache/GridCacheReturn.java | 2 +-
.../distributed/GridCacheTtlUpdateRequest.java | 3 +-
.../distributed/GridCacheTxRecoveryRequest.java | 2 +-
.../GridCacheTxRecoveryResponse.java | 2 +-
.../distributed/GridDistributedBaseMessage.java | 2 +-
.../distributed/GridDistributedLockRequest.java | 2 +-
.../GridDistributedLockResponse.java | 2 +-
.../GridDistributedTxFinishRequest.java | 8 +-
.../GridDistributedTxFinishResponse.java | 2 +-
.../GridDistributedTxPrepareRequest.java | 8 +-
.../GridDistributedTxPrepareResponse.java | 2 +-
.../GridDistributedUnlockRequest.java | 2 +-
.../dht/GridDhtAffinityAssignmentRequest.java | 2 +-
.../dht/GridDhtAffinityAssignmentResponse.java | 2 +-
.../distributed/dht/GridDhtLockRequest.java | 6 +-
.../distributed/dht/GridDhtLockResponse.java | 2 +-
.../distributed/dht/GridDhtTxFinishRequest.java | 2 +-
.../dht/GridDhtTxFinishResponse.java | 2 +-
.../dht/GridDhtTxPrepareRequest.java | 2 +-
.../dht/GridDhtTxPrepareResponse.java | 2 +-
.../distributed/dht/GridDhtUnlockRequest.java | 2 +-
.../GridDhtAtomicDeferredUpdateResponse.java | 2 +-
.../dht/atomic/GridDhtAtomicUpdateRequest.java | 2 +-
.../dht/atomic/GridDhtAtomicUpdateResponse.java | 2 +-
.../dht/atomic/GridNearAtomicUpdateRequest.java | 2 +-
.../atomic/GridNearAtomicUpdateResponse.java | 2 +-
.../dht/preloader/GridDhtForceKeysRequest.java | 3 +-
.../dht/preloader/GridDhtForceKeysResponse.java | 4 +-
.../GridDhtPartitionDemandMessage.java | 2 +-
.../preloader/GridDhtPartitionExchangeId.java | 2 +-
.../GridDhtPartitionSupplyMessage.java | 2 +-
.../GridDhtPartitionsAbstractMessage.java | 2 +-
.../preloader/GridDhtPartitionsFullMessage.java | 2 +-
.../GridDhtPartitionsSingleMessage.java | 2 +-
.../GridDhtPartitionsSingleRequest.java | 2 +-
.../distributed/near/CacheVersionedValue.java | 2 +-
.../distributed/near/GridNearGetRequest.java | 2 +-
.../distributed/near/GridNearGetResponse.java | 2 +-
.../distributed/near/GridNearLockRequest.java | 2 +-
.../distributed/near/GridNearLockResponse.java | 2 +-
.../near/GridNearTxFinishRequest.java | 2 +-
.../near/GridNearTxFinishResponse.java | 2 +-
.../near/GridNearTxPrepareRequest.java | 2 +-
.../near/GridNearTxPrepareResponse.java | 2 +-
.../distributed/near/GridNearUnlockRequest.java | 2 +-
.../CacheObjectPortableProcessorImpl.java | 3 +-
.../cache/query/GridCacheQueryRequest.java | 2 +-
.../cache/query/GridCacheQueryResponse.java | 2 +-
.../cache/query/GridCacheSqlQuery.java | 9 +-
.../continuous/CacheContinuousQueryEntry.java | 2 +-
.../cache/transactions/IgniteTxEntry.java | 2 +-
.../cache/transactions/IgniteTxKey.java | 2 +-
.../cache/transactions/TxEntryValueHolder.java | 2 +-
.../version/GridCacheRawVersionedEntry.java | 2 +-
.../cache/version/GridCacheVersion.java | 2 +-
.../cache/version/GridCacheVersionEx.java | 2 +-
.../cacheobject/IgniteCacheObjectProcessor.java | 2 +-
.../IgniteCacheObjectProcessorImpl.java | 2 +-
.../clock/GridClockDeltaSnapshotMessage.java | 2 +-
.../processors/clock/GridClockDeltaVersion.java | 2 +-
.../continuous/GridContinuousMessage.java | 2 +-
.../datastreamer/DataStreamerEntry.java | 2 +-
.../datastreamer/DataStreamerRequest.java | 2 +-
.../datastreamer/DataStreamerResponse.java | 2 +-
.../processors/igfs/IgfsAckMessage.java | 2 +-
.../internal/processors/igfs/IgfsBlockKey.java | 2 +-
.../processors/igfs/IgfsBlocksMessage.java | 2 +-
.../igfs/IgfsCommunicationMessage.java | 2 +-
.../processors/igfs/IgfsDeleteMessage.java | 2 +-
.../processors/igfs/IgfsFileAffinityRange.java | 9 +-
.../igfs/IgfsFragmentizerRequest.java | 2 +-
.../igfs/IgfsFragmentizerResponse.java | 2 +-
.../internal/processors/igfs/IgfsProcessor.java | 8 -
.../processors/igfs/IgfsSyncMessage.java | 2 +-
.../platform/PlatformAwareEventFilter.java | 37 +
.../processors/platform/PlatformContext.java | 123 +++
.../platform/PlatformLocalEventListener.java | 28 +
.../platform/PlatformNoopProcessor.java | 5 +
.../processors/platform/PlatformProcessor.java | 7 +
.../callback/PlatformCallbackGateway.java | 869 +++++++++++++++++++
.../callback/PlatformCallbackUtils.java | 468 ++++++++++
.../platform/memory/PlatformInputStream.java | 30 +
.../platform/memory/PlatformMemory.java | 77 ++
.../platform/memory/PlatformMemoryManager.java | 46 +
.../platform/memory/PlatformOutputStream.java | 30 +
.../processors/query/GridQueryProcessor.java | 2 +-
.../messages/GridQueryCancelRequest.java | 2 +-
.../twostep/messages/GridQueryFailResponse.java | 2 +-
.../messages/GridQueryNextPageRequest.java | 2 +-
.../messages/GridQueryNextPageResponse.java | 3 +-
.../h2/twostep/messages/GridQueryRequest.java | 5 +-
.../handlers/task/GridTaskResultRequest.java | 2 +-
.../handlers/task/GridTaskResultResponse.java | 2 +-
.../ignite/internal/util/GridByteArrayList.java | 2 +-
.../ignite/internal/util/GridLongList.java | 2 +-
.../internal/util/nio/GridDirectParser.java | 2 +-
.../communication/MessageFormatter.java | 3 +-
.../extensions/communication/MessageReader.java | 13 +
.../org/apache/ignite/spi/IgniteSpiAdapter.java | 2 +-
.../jobstealing/JobStealingRequest.java | 2 +-
.../communication/tcp/TcpCommunicationSpi.java | 8 +-
.../resources/META-INF/classnames.properties | 2 +-
.../IgniteCacheManyAsyncOperationsTest.java | 107 +++
.../processors/igfs/IgfsAbstractSelfTest.java | 34 +-
.../igfs/IgfsBackupFailoverSelfTest.java | 488 +++++++++++
.../igfs/IgfsBackupsDualAsyncSelfTest.java | 40 +
.../igfs/IgfsBackupsDualSyncSelfTest.java | 40 +
.../igfs/IgfsBackupsPrimarySelfTest.java | 40 +
.../testframework/GridSpiTestContext.java | 2 +-
.../ignite/testsuites/IgniteCacheTestSuite.java | 1 +
.../ignite/testsuites/IgniteIgfsTestSuite.java | 7 +
.../Apache.Ignite.Core.csproj | 25 +
.../Common/AsyncSupportedAttribute.cs | 33 +
.../Apache.Ignite.Core/Common/IAsyncSupport.cs | 52 ++
.../dotnet/Apache.Ignite.Core/Common/IFuture.cs | 115 +++
.../Common/IgniteException.cs | 66 ++
.../Impl/Collections/CollectionExtensions.cs | 45 +
.../Impl/Collections/MultiValueDictionary.cs | 143 +++
.../Impl/Collections/ReadOnlyCollection.cs | 102 +++
.../Impl/Collections/ReadOnlyDictionary.cs | 149 ++++
.../Impl/Common/AsyncResult.cs | 71 ++
.../Impl/Common/CompletedAsyncResult.cs | 70 ++
.../Common/CopyOnWriteConcurrentDictionary.cs | 70 ++
.../Impl/Common/DelegateConverter.cs | 253 ++++++
.../Apache.Ignite.Core/Impl/Common/Future.cs | 286 ++++++
.../Impl/Common/FutureType.cs | 52 ++
.../Impl/Common/GridArgumentCheck.cs | 76 ++
.../Impl/Common/IFutureConverter.cs | 32 +
.../Impl/Common/IFutureInternal.cs | 45 +
.../Impl/Common/LoadedAssembliesResolver.cs | 96 ++
.../Impl/Common/TypeCaster.cs | 72 ++
.../Apache.Ignite.Core/Impl/Handle/Handle.cs | 69 ++
.../Impl/Handle/HandleRegistry.cs | 340 ++++++++
.../Apache.Ignite.Core/Impl/Handle/IHandle.cs | 35 +
.../internal/platform/PlatformBootstrap.java | 36 -
.../platform/PlatformBootstrapFactory.java | 37 -
.../internal/platform/PlatformException.java | 71 --
.../internal/platform/PlatformIgnition.java | 187 ----
.../platform/PlatformNoCallbackException.java | 50 --
.../callback/PlatformCallbackGateway.java | 869 -------------------
.../callback/PlatformCallbackUtils.java | 468 ----------
.../platform/memory/PlatformAbstractMemory.java | 121 ---
.../PlatformBigEndianInputStreamImpl.java | 126 ---
.../PlatformBigEndianOutputStreamImpl.java | 162 ----
.../platform/memory/PlatformExternalMemory.java | 55 --
.../platform/memory/PlatformInputStream.java | 30 -
.../memory/PlatformInputStreamImpl.java | 323 -------
.../platform/memory/PlatformMemory.java | 77 --
.../platform/memory/PlatformMemoryManager.java | 46 -
.../memory/PlatformMemoryManagerImpl.java | 83 --
.../platform/memory/PlatformMemoryPool.java | 133 ---
.../platform/memory/PlatformMemoryUtils.java | 468 ----------
.../platform/memory/PlatformOutputStream.java | 30 -
.../memory/PlatformOutputStreamImpl.java | 259 ------
.../platform/memory/PlatformPooledMemory.java | 63 --
.../platform/memory/PlatformUnpooledMemory.java | 51 --
.../platform/PlatformAbstractBootstrap.java | 48 +
.../platform/PlatformAbstractTarget.java | 276 ++++++
.../processors/platform/PlatformBootstrap.java | 36 +
.../platform/PlatformBootstrapFactory.java | 37 +
.../processors/platform/PlatformException.java | 71 ++
.../platform/PlatformExtendedException.java | 39 +
.../processors/platform/PlatformIgnition.java | 186 ++++
.../platform/PlatformNoCallbackException.java | 50 ++
.../processors/platform/PlatformTarget.java | 76 ++
.../platform/cache/PlatformCacheIterator.java | 72 ++
.../cache/affinity/PlatformAffinity.java | 293 +++++++
.../query/PlatformAbstractQueryCursor.java | 192 ++++
.../cache/query/PlatformFieldsQueryCursor.java | 50 ++
.../cache/query/PlatformQueryCursor.java | 46 +
.../cache/store/PlatformCacheStore.java | 25 +
.../cache/store/PlatformCacheStoreCallback.java | 61 ++
.../lifecycle/PlatformLifecycleBean.java | 72 ++
.../platform/memory/PlatformAbstractMemory.java | 121 +++
.../PlatformBigEndianInputStreamImpl.java | 126 +++
.../PlatformBigEndianOutputStreamImpl.java | 162 ++++
.../platform/memory/PlatformExternalMemory.java | 55 ++
.../memory/PlatformInputStreamImpl.java | 323 +++++++
.../memory/PlatformMemoryManagerImpl.java | 83 ++
.../platform/memory/PlatformMemoryPool.java | 133 +++
.../platform/memory/PlatformMemoryUtils.java | 468 ++++++++++
.../memory/PlatformOutputStreamImpl.java | 259 ++++++
.../platform/memory/PlatformPooledMemory.java | 63 ++
.../platform/memory/PlatformUnpooledMemory.java | 51 ++
.../transactions/PlatformTransactions.java | 255 ++++++
.../platform/utils/PlatformFutureUtils.java | 326 +++++++
.../platform/utils/PlatformReaderBiClosure.java | 34 +
.../platform/utils/PlatformReaderClosure.java | 34 +
.../platform/utils/PlatformUtils.java | 663 ++++++++++++++
.../platform/utils/PlatformWriterBiClosure.java | 34 +
.../platform/utils/PlatformWriterClosure.java | 33 +
parent/pom.xml | 1 +
229 files changed, 9807 insertions(+), 3987 deletions(-)
----------------------------------------------------------------------
[15/41] ignite git commit: Fix to RAT.
Posted by sb...@apache.org.
Fix to RAT.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ed974f3f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ed974f3f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ed974f3f
Branch: refs/heads/ignite-1093
Commit: ed974f3f74dd66cb73645cafcc091f7793b5461d
Parents: 4f3c9a2
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 11:12:11 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 11:12:11 2015 +0300
----------------------------------------------------------------------
parent/pom.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ed974f3f/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 17fcea7..8d25cf2 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -736,6 +736,7 @@
<!--platform-->
<exclude>src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj</exclude>
<exclude>src/main/dotnet/Apache.Ignite.sln</exclude>
+ <exclude>src/main/dotnet/Apache.Ignite.sln.DotSettings</exclude>
<exclude>src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj</exclude>
</excludes>
</configuration>
[08/41] ignite git commit: Moving platform classes to
"...internal.processors..." package to follow Ignite common approach.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryManagerImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryManagerImpl.java
deleted file mode 100644
index 53a3e19..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryManagerImpl.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-import org.apache.ignite.internal.platform.callback.*;
-import org.jetbrains.annotations.*;
-
-import static org.apache.ignite.internal.platform.memory.PlatformMemoryUtils.*;
-
-/**
- * Interop memory manager implementation.
- */
-public class PlatformMemoryManagerImpl implements PlatformMemoryManager {
- /** Native gateway. */
- private final PlatformCallbackGateway gate;
-
- /** Default allocation capacity. */
- private final int dfltCap;
-
- /** Thread-local pool. */
- private final ThreadLocal<PlatformMemoryPool> threadLocPool = new ThreadLocal<>();
-
- /**
- * Constructor.
- *
- * @param gate Native gateway.
- * @param dfltCap Default memory chunk capacity.
- */
- public PlatformMemoryManagerImpl(@Nullable PlatformCallbackGateway gate, int dfltCap) {
- this.gate = gate;
- this.dfltCap = dfltCap;
- }
-
- /** {@inheritDoc} */
- @Override public PlatformMemory allocate() {
- return allocate(dfltCap);
- }
-
- /** {@inheritDoc} */
- @Override public PlatformMemory allocate(int cap) {
- return pool().allocate(cap);
- }
-
- /** {@inheritDoc} */
- @Override public PlatformMemory get(long memPtr) {
- int flags = flags(memPtr);
-
- return isExternal(flags) ? new PlatformExternalMemory(gate, memPtr) :
- isPooled(flags) ? pool().get(memPtr) : new PlatformUnpooledMemory(memPtr);
- }
-
- /**
- * Gets or creates thread-local memory pool.
- *
- * @return Memory pool.
- */
- private PlatformMemoryPool pool() {
- PlatformMemoryPool pool = threadLocPool.get();
-
- if (pool == null) {
- pool = new PlatformMemoryPool();
-
- threadLocPool.set(pool);
- }
-
- return pool;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryPool.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryPool.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryPool.java
deleted file mode 100644
index a012b5c..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryPool.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-import static org.apache.ignite.internal.platform.memory.PlatformMemoryUtils.*;
-
-/**
- * Memory pool associated with a thread.
- */
-public class PlatformMemoryPool {
- /** base pointer. */
- private final long poolPtr;
-
- /** First pooled memory chunk. */
- private PlatformPooledMemory mem1;
-
- /** Second pooled memory chunk. */
- private PlatformPooledMemory mem2;
-
- /** Third pooled memory chunk. */
- private PlatformPooledMemory mem3;
-
- /**
- * Constructor.
- */
- public PlatformMemoryPool() {
- poolPtr = allocatePool();
-
- sun.misc.Cleaner.create(this, new CleanerRunnable(poolPtr));
- }
-
- /**
- * Allocate memory chunk, optionally pooling it.
- *
- * @param cap Minimum capacity.
- * @return Memory chunk.
- */
- public PlatformMemory allocate(int cap) {
- long memPtr = allocatePooled(poolPtr, cap);
-
- // memPtr == 0 means that we failed to acquire thread-local memory chunk, so fallback to unpooled memory.
- return memPtr != 0 ? get(memPtr) : new PlatformUnpooledMemory(allocateUnpooled(cap));
- }
-
- /**
- * Re-allocate existing pool memory chunk.
- *
- * @param memPtr Memory pointer.
- * @param cap Minimum capacity.
- */
- void reallocate(long memPtr, int cap) {
- reallocatePooled(memPtr, cap);
- }
-
- /**
- * Release pooled memory chunk.
- *
- * @param memPtr Memory pointer.
- */
- void release(long memPtr) {
- releasePooled(memPtr);
- }
-
- /**
- * Get pooled memory chunk.
- *
- * @param memPtr Memory pointer.
- * @return Memory chunk.
- */
- public PlatformMemory get(long memPtr) {
- long delta = memPtr - poolPtr;
-
- if (delta == POOL_HDR_OFF_MEM_1) {
- if (mem1 == null)
- mem1 = new PlatformPooledMemory(this, memPtr);
-
- return mem1;
- }
- else if (delta == POOL_HDR_OFF_MEM_2) {
- if (mem2 == null)
- mem2 = new PlatformPooledMemory(this, memPtr);
-
- return mem2;
- }
- else {
- assert delta == POOL_HDR_OFF_MEM_3;
-
- if (mem3 == null)
- mem3 = new PlatformPooledMemory(this, memPtr);
-
- return mem3;
- }
- }
-
- /**
- * Cleaner runnable.
- */
- private static class CleanerRunnable implements Runnable {
- /** Pointer. */
- private final long poolPtr;
-
- /**
- * Constructor.
- *
- * @param poolPtr Pointer.
- */
- private CleanerRunnable(long poolPtr) {
- assert poolPtr != 0;
-
- this.poolPtr = poolPtr;
- }
-
- /** {@inheritDoc} */
- @Override public void run() {
- PlatformMemoryUtils.releasePool(poolPtr);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryUtils.java
deleted file mode 100644
index d820ca6..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformMemoryUtils.java
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-import org.apache.ignite.internal.util.*;
-import sun.misc.*;
-
-import java.nio.*;
-
-/**
- * Utility classes for memory management.
- */
-public class PlatformMemoryUtils {
- /** Unsafe instance. */
- public static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** Array offset: boolean. */
- public static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
-
- /** Array offset: byte. */
- public static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** Array offset: short. */
- public static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
-
- /** Array offset: char. */
- public static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
-
- /** Array offset: int. */
- public static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
-
- /** Array offset: float. */
- public static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
-
- /** Array offset: long. */
- public static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
-
- /** Array offset: double. */
- public static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
-
- /** Whether little endian is used on the platform. */
- public static final boolean LITTLE_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN;
-
- /** Header length. */
- public static final int POOL_HDR_LEN = 64;
-
- /** Pool header offset: first memory chunk. */
- public static final int POOL_HDR_OFF_MEM_1 = 0;
-
- /** Pool header offset: second memory chunk. */
- public static final int POOL_HDR_OFF_MEM_2 = 20;
-
- /** Pool header offset: third memory chunk. */
- public static final int POOL_HDR_OFF_MEM_3 = 40;
-
- /** Memory chunk header length. */
- public static final int MEM_HDR_LEN = 20;
-
- /** Offset: capacity. */
- public static final int MEM_HDR_OFF_CAP = 8;
-
- /** Offset: length. */
- public static final int MEM_HDR_OFF_LEN = 12;
-
- /** Offset: flags. */
- public static final int MEM_HDR_OFF_FLAGS = 16;
-
- /** Flag: external. */
- public static final int FLAG_EXT = 0x1;
-
- /** Flag: pooled. */
- public static final int FLAG_POOLED = 0x2;
-
- /** Flag: whether this pooled memory chunk is acquired. */
- public static final int FLAG_ACQUIRED = 0x4;
-
- /** --- COMMON METHODS. --- */
-
- /**
- * Gets data pointer for the given memory chunk.
- *
- * @param memPtr Memory pointer.
- * @return Data pointer.
- */
- public static long data(long memPtr) {
- return UNSAFE.getLong(memPtr);
- }
-
- /**
- * Gets capacity for the given memory chunk.
- *
- * @param memPtr Memory pointer.
- * @return Capacity.
- */
- public static int capacity(long memPtr) {
- return UNSAFE.getInt(memPtr + MEM_HDR_OFF_CAP);
- }
-
- /**
- * Sets capacity for the given memory chunk.
- *
- * @param memPtr Memory pointer.
- * @param cap Capacity.
- */
- public static void capacity(long memPtr, int cap) {
- assert !isExternal(memPtr) : "Attempt to update external memory chunk capacity: " + memPtr;
-
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
- }
-
- /**
- * Gets length for the given memory chunk.
- *
- * @param memPtr Memory pointer.
- * @return Length.
- */
- public static int length(long memPtr) {
- return UNSAFE.getInt(memPtr + MEM_HDR_OFF_LEN);
- }
-
- /**
- * Sets length for the given memory chunk.
- *
- * @param memPtr Memory pointer.
- * @param len Length.
- */
- public static void length(long memPtr, int len) {
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_LEN, len);
- }
-
- /**
- * Gets flags for the given memory chunk.
- *
- * @param memPtr Memory pointer.
- * @return Flags.
- */
- public static int flags(long memPtr) {
- return UNSAFE.getInt(memPtr + MEM_HDR_OFF_FLAGS);
- }
-
- /**
- * Sets flags for the given memory chunk.
- *
- * @param memPtr Memory pointer.
- * @param flags Flags.
- */
- public static void flags(long memPtr, int flags) {
- assert !isExternal(memPtr) : "Attempt to update external memory chunk flags: " + memPtr;
-
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_FLAGS, flags);
- }
-
- /**
- * Check whether this memory chunk is external.
- *
- * @param memPtr Memory pointer.
- * @return {@code True} if owned by native platform.
- */
- public static boolean isExternal(long memPtr) {
- return isExternal(flags(memPtr));
- }
-
- /**
- * Check whether flags denote that this memory chunk is external.
- *
- * @param flags Flags.
- * @return {@code True} if owned by native platform.
- */
- public static boolean isExternal(int flags) {
- return (flags & FLAG_EXT) == FLAG_EXT;
- }
-
- /**
- * Check whether this memory chunk is pooled.
- *
- * @param memPtr Memory pointer.
- * @return {@code True} if pooled.
- */
- public static boolean isPooled(long memPtr) {
- return isPooled(flags(memPtr));
- }
-
- /**
- * Check whether flags denote pooled memory chunk.
- *
- * @param flags Flags.
- * @return {@code True} if pooled.
- */
- public static boolean isPooled(int flags) {
- return (flags & FLAG_POOLED) != 0;
- }
-
- /**
- * Check whether this memory chunk is pooled and acquired.
- *
- * @param memPtr Memory pointer.
- * @return {@code True} if pooled and acquired.
- */
- public static boolean isAcquired(long memPtr) {
- return isAcquired(flags(memPtr));
- }
-
- /**
- * Check whether flags denote pooled and acquired memory chunk.
- *
- * @param flags Flags.
- * @return {@code True} if acquired.
- */
- public static boolean isAcquired(int flags) {
- assert isPooled(flags);
-
- return (flags & FLAG_ACQUIRED) != 0;
- }
-
- /** --- UNPOOLED MEMORY MANAGEMENT. --- */
-
- /**
- * Allocate unpooled memory chunk.
- *
- * @param cap Minimum capacity.
- * @return New memory pointer.
- */
- public static long allocateUnpooled(int cap) {
- assert cap > 0;
-
- long memPtr = UNSAFE.allocateMemory(MEM_HDR_LEN);
- long dataPtr = UNSAFE.allocateMemory(cap);
-
- UNSAFE.putLong(memPtr, dataPtr); // Write address.
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write capacity.
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_LEN, 0); // Write length.
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_FLAGS, 0); // Write flags.
-
- return memPtr;
- }
-
- /**
- * Reallocate unpooled memory chunk.
- *
- * @param memPtr Memory pointer.
- * @param cap Minimum capacity.
- */
- public static void reallocateUnpooled(long memPtr, int cap) {
- assert cap > 0;
-
- assert !isExternal(memPtr) : "Attempt to reallocate external memory chunk directly: " + memPtr;
- assert !isPooled(memPtr) : "Attempt to reallocate pooled memory chunk directly: " + memPtr;
-
- long dataPtr = data(memPtr);
-
- long newDataPtr = UNSAFE.reallocateMemory(dataPtr, cap);
-
- if (dataPtr != newDataPtr)
- UNSAFE.putLong(memPtr, newDataPtr); // Write new data address if needed.
-
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write new capacity.
- }
-
- /**
- * Release unpooled memory chunk.
- *
- * @param memPtr Memory pointer.
- */
- public static void releaseUnpooled(long memPtr) {
- assert !isExternal(memPtr) : "Attempt to release external memory chunk directly: " + memPtr;
- assert !isPooled(memPtr) : "Attempt to release pooled memory chunk directly: " + memPtr;
-
- UNSAFE.freeMemory(data(memPtr));
- UNSAFE.freeMemory(memPtr);
- }
-
- /** --- POOLED MEMORY MANAGEMENT. --- */
-
- /**
- * Allocate pool memory.
- *
- * @return Pool pointer.
- */
- public static long allocatePool() {
- long poolPtr = UNSAFE.allocateMemory(POOL_HDR_LEN);
-
- UNSAFE.setMemory(poolPtr, POOL_HDR_LEN, (byte)0);
-
- flags(poolPtr + POOL_HDR_OFF_MEM_1, FLAG_POOLED);
- flags(poolPtr + POOL_HDR_OFF_MEM_2, FLAG_POOLED);
- flags(poolPtr + POOL_HDR_OFF_MEM_3, FLAG_POOLED);
-
- return poolPtr;
- }
-
- /**
- * Release pool memory.
- *
- * @param poolPtr Pool pointer.
- */
- public static void releasePool(long poolPtr) {
- // Clean predefined memory chunks.
- long mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_1);
-
- if (mem != 0)
- UNSAFE.freeMemory(mem);
-
- mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_2);
-
- if (mem != 0)
- UNSAFE.freeMemory(mem);
-
- mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_3);
-
- if (mem != 0)
- UNSAFE.freeMemory(mem);
-
- // Clean pool chunk.
- UNSAFE.freeMemory(poolPtr);
- }
-
- /**
- * Allocate pooled memory chunk.
- *
- * @param poolPtr Pool pointer.
- * @param cap Capacity.
- * @return Cross-platform memory pointer or {@code 0} in case there are no free memory chunks in the pool.
- */
- public static long allocatePooled(long poolPtr, int cap) {
- long memPtr1 = poolPtr + POOL_HDR_OFF_MEM_1;
-
- if (isAcquired(memPtr1)) {
- long memPtr2 = poolPtr + POOL_HDR_OFF_MEM_2;
-
- if (isAcquired(memPtr2)) {
- long memPtr3 = poolPtr + POOL_HDR_OFF_MEM_3;
-
- if (isAcquired(memPtr3))
- return 0L;
- else {
- allocatePooled0(memPtr3, cap);
-
- return memPtr3;
- }
- }
- else {
- allocatePooled0(memPtr2, cap);
-
- return memPtr2;
- }
- }
- else {
- allocatePooled0(memPtr1, cap);
-
- return memPtr1;
- }
- }
-
- /**
- * Internal pooled memory chunk allocation routine.
- *
- * @param memPtr Memory pointer.
- * @param cap Capacity.
- */
- private static void allocatePooled0(long memPtr, int cap) {
- assert !isExternal(memPtr);
- assert isPooled(memPtr);
- assert !isAcquired(memPtr);
-
- long data = UNSAFE.getLong(memPtr);
-
- if (data == 0) {
- // First allocation of the chunk.
- data = UNSAFE.allocateMemory(cap);
-
- UNSAFE.putLong(memPtr, data);
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
- }
- else {
- // Ensure that we have enough capacity.
- int curCap = capacity(memPtr);
-
- if (cap > curCap) {
- data = UNSAFE.reallocateMemory(data, cap);
-
- UNSAFE.putLong(memPtr, data);
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
- }
- }
-
- flags(memPtr, FLAG_POOLED | FLAG_ACQUIRED);
- }
-
- /**
- * Reallocate pooled memory chunk.
- *
- * @param memPtr Memory pointer.
- * @param cap Minimum capacity.
- */
- public static void reallocatePooled(long memPtr, int cap) {
- assert !isExternal(memPtr);
- assert isPooled(memPtr);
- assert isAcquired(memPtr);
-
- long data = UNSAFE.getLong(memPtr);
-
- assert data != 0;
-
- int curCap = capacity(memPtr);
-
- if (cap > curCap) {
- data = UNSAFE.reallocateMemory(data, cap);
-
- UNSAFE.putLong(memPtr, data);
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
- }
- }
-
- /**
- * Release pooled memory chunk.
- *
- * @param memPtr Memory pointer.
- */
- public static void releasePooled(long memPtr) {
- assert !isExternal(memPtr);
- assert isPooled(memPtr);
- assert isAcquired(memPtr);
-
- flags(memPtr, flags(memPtr) ^ FLAG_ACQUIRED);
- }
-
- /** --- UTILITY STUFF. --- */
-
- /**
- * Reallocate arbitrary memory chunk.
- *
- * @param memPtr Memory pointer.
- * @param cap Capacity.
- */
- public static void reallocate(long memPtr, int cap) {
- int flags = flags(memPtr);
-
- if (isPooled(flags))
- reallocatePooled(memPtr, cap);
- else {
- assert !isExternal(flags);
-
- reallocateUnpooled(memPtr, cap);
- }
- }
-
- /**
- * Constructor.
- */
- private PlatformMemoryUtils() {
- // No-op.
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformOutputStream.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformOutputStream.java
deleted file mode 100644
index 89527ce..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformOutputStream.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-import org.apache.ignite.internal.portable.streams.*;
-
-/**
- * Interop output stream.
- */
-public interface PlatformOutputStream extends PortableOutputStream {
- /**
- * Synchronize output stream with underlying memory
- */
- public void synchronize();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformOutputStreamImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformOutputStreamImpl.java
deleted file mode 100644
index 13492eb..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformOutputStreamImpl.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-import static org.apache.ignite.internal.platform.memory.PlatformMemoryUtils.*;
-
-/**
- * Interop output stream implementation.
- */
-public class PlatformOutputStreamImpl implements PlatformOutputStream {
- /** Underlying memory chunk. */
- protected final PlatformMemory mem;
-
- /** Pointer. */
- protected long data;
-
- /** Maximum capacity. */
- protected int cap;
-
- /** Current position. */
- protected int pos;
-
- /**
- * Constructor.
- *
- * @param mem Underlying memory chunk.
- */
- public PlatformOutputStreamImpl(PlatformMemory mem) {
- this.mem = mem;
-
- data = mem.data();
- cap = mem.capacity();
- }
-
- /** {@inheritDoc} */
- @Override public void writeByte(byte val) {
- ensureCapacity(pos + 1);
-
- UNSAFE.putByte(data + pos++, val);
- }
-
- /** {@inheritDoc} */
- @Override public void writeByteArray(byte[] val) {
- copyAndShift(val, BYTE_ARR_OFF, val.length);
- }
-
- /** {@inheritDoc} */
- @Override public void writeBoolean(boolean val) {
- writeByte(val ? (byte) 1 : (byte) 0);
- }
-
- /** {@inheritDoc} */
- @Override public void writeBooleanArray(boolean[] val) {
- copyAndShift(val, BOOLEAN_ARR_OFF, val.length);
- }
-
- /** {@inheritDoc} */
- @Override public void writeShort(short val) {
- ensureCapacity(pos + 2);
-
- UNSAFE.putShort(data + pos, val);
-
- shift(2);
- }
-
- /** {@inheritDoc} */
- @Override public void writeShortArray(short[] val) {
- copyAndShift(val, SHORT_ARR_OFF, val.length << 1);
- }
-
- /** {@inheritDoc} */
- @Override public void writeChar(char val) {
- ensureCapacity(pos + 2);
-
- UNSAFE.putChar(data + pos, val);
-
- shift(2);
- }
-
- /** {@inheritDoc} */
- @Override public void writeCharArray(char[] val) {
- copyAndShift(val, CHAR_ARR_OFF, val.length << 1);
- }
-
- /** {@inheritDoc} */
- @Override public void writeInt(int val) {
- ensureCapacity(pos + 4);
-
- UNSAFE.putInt(data + pos, val);
-
- shift(4);
- }
-
- /** {@inheritDoc} */
- @Override public void writeIntArray(int[] val) {
- copyAndShift(val, INT_ARR_OFF, val.length << 2);
- }
-
- /** {@inheritDoc} */
- @Override public void writeInt(int pos, int val) {
- ensureCapacity(pos + 4);
-
- UNSAFE.putInt(data + pos, val);
- }
-
- /** {@inheritDoc} */
- @Override public void writeFloat(float val) {
- writeInt(Float.floatToIntBits(val));
- }
-
- /** {@inheritDoc} */
- @Override public void writeFloatArray(float[] val) {
- copyAndShift(val, FLOAT_ARR_OFF, val.length << 2);
- }
-
- /** {@inheritDoc} */
- @Override public void writeLong(long val) {
- ensureCapacity(pos + 8);
-
- UNSAFE.putLong(data + pos, val);
-
- shift(8);
- }
-
- /** {@inheritDoc} */
- @Override public void writeLongArray(long[] val) {
- copyAndShift(val, LONG_ARR_OFF, val.length << 3);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDouble(double val) {
- writeLong(Double.doubleToLongBits(val));
- }
-
- /** {@inheritDoc} */
- @Override public void writeDoubleArray(double[] val) {
- copyAndShift(val, DOUBLE_ARR_OFF, val.length << 3);
- }
-
- /** {@inheritDoc} */
- @Override public void write(byte[] arr, int off, int len) {
- copyAndShift(arr, BYTE_ARR_OFF + off, len);
- }
-
- /** {@inheritDoc} */
- @Override public void write(long addr, int cnt) {
- copyAndShift(null, addr, cnt);
- }
-
- /** {@inheritDoc} */
- @Override public int position() {
- return pos;
- }
-
- /** {@inheritDoc} */
- @Override public void position(int pos) {
- ensureCapacity(pos);
-
- this.pos = pos;
- }
-
- /** {@inheritDoc} */
- @Override public void close() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public byte[] array() {
- assert false;
-
- throw new UnsupportedOperationException("Should not be called.");
- }
-
- /** {@inheritDoc} */
- @Override public byte[] arrayCopy() {
- assert false;
-
- throw new UnsupportedOperationException("Should not be called.");
- }
-
- /** {@inheritDoc} */
- @Override public long offheapPointer() {
- assert false;
-
- throw new UnsupportedOperationException("Should not be called.");
- }
-
- /** {@inheritDoc} */
- @Override public boolean hasArray() {
- assert false;
-
- throw new UnsupportedOperationException("Should not be called.");
- }
-
- /** {@inheritDoc} */
- @Override public void synchronize() {
- PlatformMemoryUtils.length(mem.pointer(), pos);
- }
-
- /**
- * Ensure capacity.
- *
- * @param reqCap Required byte count.
- */
- protected void ensureCapacity(int reqCap) {
- if (reqCap > cap) {
- int newCap = cap << 1;
-
- if (newCap < reqCap)
- newCap = reqCap;
-
- mem.reallocate(newCap);
-
- assert mem.capacity() >= newCap;
-
- data = mem.data();
- cap = newCap;
- }
- }
-
- /**
- * Shift position.
- *
- * @param cnt Byte count.
- */
- protected void shift(int cnt) {
- pos += cnt;
- }
-
- /**
- * Copy source object to the stream shifting position afterwards.
- *
- * @param src Source.
- * @param off Offset.
- * @param len Length.
- */
- private void copyAndShift(Object src, long off, int len) {
- ensureCapacity(pos + len);
-
- UNSAFE.copyMemory(src, off, null, data + pos, len);
-
- shift(len);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformPooledMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformPooledMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformPooledMemory.java
deleted file mode 100644
index 5043fd1..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformPooledMemory.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.memory;
-
-import static org.apache.ignite.internal.platform.memory.PlatformMemoryUtils.*;
-
-/**
- * Interop pooled memory chunk.
- */
-public class PlatformPooledMemory extends PlatformAbstractMemory {
- /** Owning memory pool. */
- private final PlatformMemoryPool pool;
-
- /**
- * Constructor.
- *
- * @param pool Owning memory pool.
- * @param memPtr Cross-platform memory pointer.
- */
- public PlatformPooledMemory(PlatformMemoryPool pool, long memPtr) {
- super(memPtr);
-
- assert isPooled(memPtr);
- assert isAcquired(memPtr);
-
- this.pool = pool;
- }
-
- /** {@inheritDoc} */
- @Override public void reallocate(int cap) {
- assert isAcquired(memPtr);
-
- // Try doubling capacity to avoid excessive allocations.
- int doubledCap = PlatformMemoryUtils.capacity(memPtr) << 1;
-
- if (doubledCap > cap)
- cap = doubledCap;
-
- pool.reallocate(memPtr, cap);
- }
-
- /** {@inheritDoc} */
- @Override public void close() {
- assert isAcquired(memPtr);
-
- pool.release(memPtr); // Return to the pool.
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformUnpooledMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformUnpooledMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformUnpooledMemory.java
deleted file mode 100644
index f3fe227..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/memory/PlatformUnpooledMemory.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.internal.platform.memory;
-
-import static org.apache.ignite.internal.platform.memory.PlatformMemoryUtils.*;
-
-/**
- * Interop un-pooled memory chunk.
- */
-public class PlatformUnpooledMemory extends PlatformAbstractMemory {
- /**
- * Constructor.
- *
- * @param memPtr Cross-platform memory pointer.
- */
- public PlatformUnpooledMemory(long memPtr) {
- super(memPtr);
- }
-
- /** {@inheritDoc} */
- @Override public void reallocate(int cap) {
- // Try doubling capacity to avoid excessive allocations.
- int doubledCap = PlatformMemoryUtils.capacity(memPtr) << 1;
-
- if (doubledCap > cap)
- cap = doubledCap;
-
- reallocateUnpooled(memPtr, cap);
- }
-
- /** {@inheritDoc} */
- @Override public void close() {
- releaseUnpooled(memPtr);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderBiClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderBiClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderBiClosure.java
deleted file mode 100644
index 0280ba8..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderBiClosure.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.utils;
-
-import org.apache.ignite.internal.portable.*;
-import org.apache.ignite.lang.*;
-
-/**
- * Reader bi-closure.
- */
-public interface PlatformReaderBiClosure<T1, T2> {
- /**
- * Read object from reader.
- *
- * @param reader Reader.
- * @return Object.
- */
- IgniteBiTuple<T1, T2> read(PortableRawReaderEx reader);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderClosure.java
deleted file mode 100644
index 73a24d1..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformReaderClosure.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.utils;
-
-import org.apache.ignite.internal.portable.*;
-
-/**
- * Reader closure.
- */
-public interface PlatformReaderClosure<T> {
-
- /**
- * Read object from reader.
- *
- * @param reader Reader.
- * @return Object.
- */
- T read(PortableRawReaderEx reader);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterBiClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterBiClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterBiClosure.java
deleted file mode 100644
index cbd34fa..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterBiClosure.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.utils;
-
-import org.apache.ignite.internal.portable.*;
-
-/**
- * Interop writer bi-closure.
- */
-public interface PlatformWriterBiClosure<T1, T2> {
- /**
- * Write values.
- *
- * @param writer Writer.
- * @param val1 Value 1.
- * @param val2 Value 2.
- */
- public void write(PortableRawWriterEx writer, T1 val1, T2 val2);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterClosure.java
deleted file mode 100644
index d9953ca..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/platform/utils/PlatformWriterClosure.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform.utils;
-
-import org.apache.ignite.internal.portable.*;
-
-/**
- * Interop writer closure.
- */
-public interface PlatformWriterClosure<T> {
- /**
- * Write value.
- *
- * @param writer Writer.
- * @param val Value.
- */
- public void write(PortableRawWriterEx writer, T val);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrap.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrap.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrap.java
new file mode 100644
index 0000000..319c670
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrap.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform;
+
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.processors.platform.*;
+
+/**
+ * Platform bootstrap. Responsible for starting Ignite node with non-Java platform.
+ */
+public interface PlatformBootstrap {
+ /**
+ * Start Ignite node.
+ *
+ * @param cfg Configuration.
+ * @param envPtr Environment pointer.
+ * @param dataPtr Optional pointer to additional data required for startup.
+ * @return Platform processor.
+ */
+ public PlatformProcessor start(IgniteConfiguration cfg, long envPtr, long dataPtr);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrapFactory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrapFactory.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrapFactory.java
new file mode 100644
index 0000000..f5b3adf
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrapFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform;
+
+/**
+ * Platform bootstrap factory.
+ */
+public interface PlatformBootstrapFactory {
+ /**
+ * Get bootstrap factory ID.
+ *
+ * @return ID.
+ */
+ public int id();
+
+ /**
+ * Create bootstrap instance.
+ *
+ * @return Bootstrap instance.
+ */
+ public PlatformBootstrap create();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformException.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformException.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformException.java
new file mode 100644
index 0000000..479d533
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformException.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * Interop checked exception.
+ */
+public class PlatformException extends IgniteCheckedException {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * Create empty exception.
+ */
+ public PlatformException() {
+ // No-op.
+ }
+
+ /**
+ * Creates new exception with given error message.
+ *
+ * @param msg Error message.
+ */
+ public PlatformException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Creates new grid exception with given throwable as a cause and
+ * source of error message.
+ *
+ * @param cause Non-null throwable cause.
+ */
+ public PlatformException(Throwable cause) {
+ this(cause.getMessage(), cause);
+ }
+
+ /**
+ * Creates new exception with given error message and optional nested exception.
+ *
+ * @param msg Error message.
+ * @param cause Optional nested exception (can be {@code null}).
+ */
+ public PlatformException(String msg, @Nullable Throwable cause) {
+ super(msg, cause);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PlatformException.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
new file mode 100644
index 0000000..93cf8b4
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.resource.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+import org.jetbrains.annotations.*;
+
+import java.net.*;
+import java.security.*;
+import java.util.*;
+
+/**
+ * Entry point for platform nodes.
+ */
+@SuppressWarnings("UnusedDeclaration")
+public class PlatformIgnition {
+ /** Map with active instances. */
+ private static final HashMap<String, PlatformProcessor> instances = new HashMap<>();
+
+ /**
+ * Start Ignite node in platform mode.
+ *
+ * @param springCfgPath Spring configuration path.
+ * @param gridName Grid name.
+ * @param factoryId Factory ID.
+ * @param envPtr Environment pointer.
+ * @param dataPtr Optional pointer to additional data required for startup.
+ * @return Ignite instance.
+ */
+ public static synchronized PlatformProcessor start(@Nullable String springCfgPath, @Nullable String gridName,
+ int factoryId, long envPtr, long dataPtr) {
+ if (envPtr <= 0)
+ throw new IgniteException("Environment pointer must be positive.");
+
+ ClassLoader oldClsLdr = Thread.currentThread().getContextClassLoader();
+
+ Thread.currentThread().setContextClassLoader(PlatformProcessor.class.getClassLoader());
+
+ try {
+ IgniteConfiguration cfg = configuration(springCfgPath);
+
+ if (gridName != null)
+ cfg.setGridName(gridName);
+ else
+ gridName = cfg.getGridName();
+
+ PlatformBootstrap bootstrap = bootstrap(factoryId);
+
+ PlatformProcessor proc = bootstrap.start(cfg, envPtr, dataPtr);
+
+ PlatformProcessor old = instances.put(gridName, proc);
+
+ assert old == null;
+
+ return proc;
+ }
+ finally {
+ Thread.currentThread().setContextClassLoader(oldClsLdr);
+ }
+ }
+
+ /**
+ * Get instance by environment pointer.
+ *
+ * @param gridName Grid name.
+ * @return Instance or {@code null} if it doesn't exist (never started or stopped).
+ */
+ @Nullable public static synchronized PlatformProcessor instance(@Nullable String gridName) {
+ return instances.get(gridName);
+ }
+
+ /**
+ * Get environment pointer of the given instance.
+ *
+ * @param gridName Grid name.
+ * @return Environment pointer or {@code 0} in case grid with such name doesn't exist.
+ */
+ public static synchronized long environmentPointer(@Nullable String gridName) {
+ PlatformProcessor proc = instance(gridName);
+
+ return proc != null ? proc.environmentPointer() : 0;
+ }
+
+ /**
+ * Stop single instance.
+ *
+ * @param gridName Grid name,
+ * @param cancel Cancel flag.
+ * @return {@code True} if instance was found and stopped.
+ */
+ public static synchronized boolean stop(@Nullable String gridName, boolean cancel) {
+ if (Ignition.stop(gridName, cancel)) {
+ PlatformProcessor old = instances.remove(gridName);
+
+ assert old != null;
+
+ return true;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Stop all instances.
+ *
+ * @param cancel Cancel flag.
+ */
+ public static synchronized void stopAll(boolean cancel) {
+ for (PlatformProcessor proc : instances.values())
+ Ignition.stop(proc.ignite().name(), cancel);
+
+ instances.clear();
+ }
+
+ /**
+ * Create configuration.
+ *
+ * @param springCfgPath Path to Spring XML.
+ * @return Configuration.
+ */
+ private static IgniteConfiguration configuration(@Nullable String springCfgPath) {
+ try {
+ URL url = springCfgPath == null ? U.resolveIgniteUrl(IgnitionEx.DFLT_CFG) :
+ U.resolveSpringUrl(springCfgPath);
+
+ IgniteBiTuple<IgniteConfiguration, GridSpringResourceContext> t = IgnitionEx.loadConfiguration(url);
+
+ return t.get1();
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException("Failed to instantiate configuration from Spring XML: " + springCfgPath, e);
+ }
+ }
+
+ /**
+ * Create bootstrap for the given factory ID.
+ *
+ * @param factoryId Factory ID.
+ * @return Bootstrap.
+ */
+ private static PlatformBootstrap bootstrap(final int factoryId) {
+ PlatformBootstrapFactory factory = AccessController.doPrivileged(
+ new PrivilegedAction<PlatformBootstrapFactory>() {
+ @Override public PlatformBootstrapFactory run() {
+ for (PlatformBootstrapFactory factory : ServiceLoader.load(PlatformBootstrapFactory.class)) {
+ if (factory.id() == factoryId)
+ return factory;
+ }
+
+ return null;
+ }
+ });
+
+ if (factory == null)
+ throw new IgniteException("Interop factory is not found (did you put into the classpath?): " + factoryId);
+
+ return factory.create();
+ }
+
+ /**
+ * Private constructor.
+ */
+ private PlatformIgnition() {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoCallbackException.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoCallbackException.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoCallbackException.java
new file mode 100644
index 0000000..ad61719
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoCallbackException.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform;
+
+import org.apache.ignite.internal.util.typedef.internal.*;
+
+/**
+ * Exception raised when interop callback is not set in native platform.
+ */
+@SuppressWarnings("UnusedDeclaration")
+public class PlatformNoCallbackException extends PlatformException {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * Constructor.
+ */
+ public PlatformNoCallbackException() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param msg Message.
+ */
+ public PlatformNoCallbackException(String msg) {
+ super(msg);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PlatformNoCallbackException.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
new file mode 100644
index 0000000..a8e7879
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
@@ -0,0 +1,869 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.callback;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.util.*;
+
+/**
+ * Gateway to all platform-dependent callbacks. Implementers might extend this class and provide additional callbacks.
+ */
+@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
+public class PlatformCallbackGateway {
+ /** Environment pointer. */
+ protected final long envPtr;
+
+ /** Lock. */
+ private final GridSpinReadWriteLock lock = new GridSpinReadWriteLock();
+
+ /**
+ * Native gateway.
+ *
+ * @param envPtr Environment pointer.
+ */
+ public PlatformCallbackGateway(long envPtr) {
+ this.envPtr = envPtr;
+ }
+
+ /**
+ * Get environment pointer.
+ *
+ * @return Environment pointer.
+ */
+ public long environmentPointer() {
+ return envPtr;
+ }
+
+ /**
+ * Create cache store.
+ *
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ public long cacheStoreCreate(long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.cacheStoreCreate(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param objPtr Object pointer.
+ * @param memPtr Memory pointer.
+ * @param cb Callback.
+ * @return Result.
+ */
+ public int cacheStoreInvoke(long objPtr, long memPtr, Object cb) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.cacheStoreInvoke(envPtr, objPtr, memPtr, cb);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param objPtr Object pointer.
+ */
+ public void cacheStoreDestroy(long objPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.cacheStoreDestroy(envPtr, objPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Creates cache store session.
+ *
+ * @param storePtr Store instance pointer.
+ * @return Session instance pointer.
+ */
+ public long cacheStoreSessionCreate(long storePtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.cacheStoreSessionCreate(envPtr, storePtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Creates cache entry filter and returns a pointer.
+ *
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ public long cacheEntryFilterCreate(long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.cacheEntryFilterCreate(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param ptr Pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ public int cacheEntryFilterApply(long ptr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.cacheEntryFilterApply(envPtr, ptr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param ptr Pointer.
+ */
+ public void cacheEntryFilterDestroy(long ptr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.cacheEntryFilterDestroy(envPtr, ptr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Invoke cache entry processor.
+ *
+ * @param outMemPtr Output memory pointer.
+ * @param inMemPtr Input memory pointer.
+ */
+ public void cacheInvoke(long outMemPtr, long inMemPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.cacheInvoke(envPtr, outMemPtr, inMemPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Perform native task map. Do not throw exceptions, serializing them to the output stream instead.
+ *
+ * @param taskPtr Task pointer.
+ * @param outMemPtr Output memory pointer (exists if topology changed, otherwise {@code 0}).
+ * @param inMemPtr Input memory pointer.
+ */
+ public void computeTaskMap(long taskPtr, long outMemPtr, long inMemPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.computeTaskMap(envPtr, taskPtr, outMemPtr, inMemPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Perform native task job result notification.
+ *
+ * @param taskPtr Task pointer.
+ * @param jobPtr Job pointer.
+ * @param memPtr Memory pointer (always zero for local job execution).
+ * @return Job result enum ordinal.
+ */
+ public int computeTaskJobResult(long taskPtr, long jobPtr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.computeTaskJobResult(envPtr, taskPtr, jobPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Perform native task reduce.
+ *
+ * @param taskPtr Task pointer.
+ */
+ public void computeTaskReduce(long taskPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.computeTaskReduce(envPtr, taskPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Complete task with native error.
+ *
+ * @param taskPtr Task pointer.
+ * @param memPtr Memory pointer with exception data or {@code 0} in case of success.
+ */
+ public void computeTaskComplete(long taskPtr, long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.computeTaskComplete(envPtr, taskPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Serialize native job.
+ *
+ * @param jobPtr Job pointer.
+ * @param memPtr Memory pointer.
+ * @return {@code True} if serialization succeeded.
+ */
+ public int computeJobSerialize(long jobPtr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.computeJobSerialize(envPtr, jobPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Create job in native platform.
+ *
+ * @param memPtr Memory pointer.
+ * @return Pointer to job.
+ */
+ public long computeJobCreate(long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.computeJobCreate(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Execute native job on a node other than where it was created.
+ *
+ * @param jobPtr Job pointer.
+ * @param cancel Cancel flag.
+ * @param memPtr Memory pointer to write result to for remote job execution or {@code 0} for local job execution.
+ */
+ public void computeJobExecute(long jobPtr, int cancel, long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.computeJobExecute(envPtr, jobPtr, cancel, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Cancel the job.
+ *
+ * @param jobPtr Job pointer.
+ */
+ public void computeJobCancel(long jobPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.computeJobCancel(envPtr, jobPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Destroy the job.
+ *
+ * @param ptr Pointer.
+ */
+ public void computeJobDestroy(long ptr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.computeJobDestroy(envPtr, ptr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Invoke local callback.
+ *
+ * @param cbPtr Callback pointer.
+ * @param memPtr Memory pointer.
+ */
+ public void continuousQueryListenerApply(long cbPtr, long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.continuousQueryListenerApply(envPtr, cbPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Create filter in native platform.
+ *
+ * @param memPtr Memory pointer.
+ * @return Pointer to created filter.
+ */
+ public long continuousQueryFilterCreate(long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.continuousQueryFilterCreate(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Invoke remote filter.
+ *
+ * @param filterPtr Filter pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ public int continuousQueryFilterApply(long filterPtr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.continuousQueryFilterApply(envPtr, filterPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Release remote filter.
+ *
+ * @param filterPtr Filter pointer.
+ */
+ public void continuousQueryFilterRelease(long filterPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.continuousQueryFilterRelease(envPtr, filterPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify native data streamer about topology update.
+ *
+ * @param ptr Data streamer native pointer.
+ * @param topVer Topology version.
+ * @param topSize Topology size.
+ */
+ public void dataStreamerTopologyUpdate(long ptr, long topVer, int topSize) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.dataStreamerTopologyUpdate(envPtr, ptr, topVer, topSize);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Invoke stream receiver.
+ *
+ * @param ptr Receiver native pointer.
+ * @param cache Cache object.
+ * @param memPtr Stream pointer.
+ * @param keepPortable Portable flag.
+ */
+ public void dataStreamerStreamReceiverInvoke(long ptr, Object cache, long memPtr, boolean keepPortable) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.dataStreamerStreamReceiverInvoke(envPtr, ptr, cache, memPtr, keepPortable);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with byte result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureByteResult(long futPtr, int res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureByteResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with boolean result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureBoolResult(long futPtr, int res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureBoolResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with short result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureShortResult(long futPtr, int res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureShortResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with byte result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureCharResult(long futPtr, int res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureCharResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with int result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureIntResult(long futPtr, int res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureIntResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with float result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureFloatResult(long futPtr, float res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureFloatResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with long result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureLongResult(long futPtr, long res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureLongResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with double result.
+ *
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ public void futureDoubleResult(long futPtr, double res) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureDoubleResult(envPtr, futPtr, res);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with object result.
+ *
+ * @param futPtr Future pointer.
+ * @param memPtr Memory pointer.
+ */
+ public void futureObjectResult(long futPtr, long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureObjectResult(envPtr, futPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with null result.
+ *
+ * @param futPtr Future pointer.
+ */
+ public void futureNullResult(long futPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureNullResult(envPtr, futPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Notify future with error.
+ *
+ * @param futPtr Future pointer.
+ * @param memPtr Pointer to memory with error information.
+ */
+ public void futureError(long futPtr, long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.futureError(envPtr, futPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Creates message filter and returns a pointer.
+ *
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ public long messagingFilterCreate(long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.messagingFilterCreate(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param ptr Pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ public int messagingFilterApply(long ptr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.messagingFilterApply(envPtr, ptr, memPtr);
+ }
+ finally {
+ leave();
+ }}
+
+ /**
+ * @param ptr Pointer.
+ */
+ public void messagingFilterDestroy(long ptr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.messagingFilterDestroy(envPtr, ptr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Creates event filter and returns a pointer.
+ *
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ public long eventFilterCreate(long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.eventFilterCreate(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param ptr Pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ public int eventFilterApply(long ptr, long memPtr) {
+ enter();
+
+ try {
+ return PlatformCallbackUtils.eventFilterApply(envPtr, ptr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * @param ptr Pointer.
+ */
+ public void eventFilterDestroy(long ptr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.eventFilterDestroy(envPtr, ptr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Sends node info to native target.
+ *
+ * @param memPtr Ptr to a stream with serialized node.
+ */
+ public void nodeInfo(long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.nodeInfo(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Kernal start callback.
+ *
+ * @param memPtr Memory pointer.
+ */
+ public void onStart(long memPtr) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.onStart(envPtr, memPtr);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Lifecycle event callback.
+ *
+ * @param ptr Holder pointer.
+ * @param evt Event.
+ */
+ public void lifecycleEvent(long ptr, int evt) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.lifecycleEvent(envPtr, ptr, evt);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Re-allocate external memory chunk.
+ *
+ * @param memPtr Cross-platform pointer.
+ * @param cap Capacity.
+ */
+ public void memoryReallocate(long memPtr, int cap) {
+ enter();
+
+ try {
+ PlatformCallbackUtils.memoryReallocate(envPtr, memPtr, cap);
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /**
+ * Initializes native service.
+ *
+ * @param memPtr Pointer.
+ * @throws org.apache.ignite.IgniteCheckedException In case of error.
+ */
+ public long serviceInit(long memPtr) throws IgniteCheckedException {
+ return PlatformCallbackUtils.serviceInit(envPtr, memPtr);
+ }
+
+ /**
+ * Executes native service.
+ *
+ * @param svcPtr Pointer to the service in the native platform.
+ * @param memPtr Stream pointer.
+ * @throws org.apache.ignite.IgniteCheckedException In case of error.
+ */
+ public void serviceExecute(long svcPtr, long memPtr) throws IgniteCheckedException {
+ PlatformCallbackUtils.serviceExecute(envPtr, svcPtr, memPtr);
+ }
+
+ /**
+ * Cancels native service.
+ *
+ * @param svcPtr Pointer to the service in the native platform.
+ * @param memPtr Stream pointer.
+ * @throws org.apache.ignite.IgniteCheckedException In case of error.
+ */
+ public void serviceCancel(long svcPtr, long memPtr) throws IgniteCheckedException {
+ PlatformCallbackUtils.serviceCancel(envPtr, svcPtr, memPtr);
+ }
+
+ /**
+ * Invokes service method.
+ *
+ * @param svcPtr Pointer to the service in the native platform.
+ * @param outMemPtr Output memory pointer.
+ * @param inMemPtr Input memory pointer.
+ * @throws org.apache.ignite.IgniteCheckedException In case of error.
+ */
+ public void serviceInvokeMethod(long svcPtr, long outMemPtr, long inMemPtr) throws IgniteCheckedException {
+ PlatformCallbackUtils.serviceInvokeMethod(envPtr, svcPtr, outMemPtr, inMemPtr);
+ }
+
+ /**
+ * Invokes cluster node filter.
+ *
+ * @param memPtr Stream pointer.
+ */
+ public int clusterNodeFilterApply(long memPtr) {
+ return PlatformCallbackUtils.clusterNodeFilterApply(envPtr, memPtr);
+ }
+
+ /**
+ * Kernal stop callback.
+ */
+ public void onStop() {
+ block();
+
+ PlatformCallbackUtils.onStop(envPtr);
+ }
+
+ /**
+ * Enter gateway.
+ */
+ protected void enter() {
+ if (!lock.tryReadLock())
+ throw new IgniteException("Failed to execute native callback because grid is stopping.");
+ }
+
+ /**
+ * Leave gateway.
+ */
+ protected void leave() {
+ lock.readUnlock();
+ }
+
+ /**
+ * Block gateway.
+ */
+ protected void block() {
+ lock.writeLock();
+ }
+}
[11/41] ignite git commit: Added test.
Posted by sb...@apache.org.
Added test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/194df76c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/194df76c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/194df76c
Branch: refs/heads/ignite-1093
Commit: 194df76cbed6e0799f01819851bedabc00d39fab
Parents: c47a706
Author: sboikov <sb...@gridgain.com>
Authored: Wed Aug 26 10:44:49 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Aug 26 10:44:49 2015 +0300
----------------------------------------------------------------------
.../IgniteCacheManyAsyncOperationsTest.java | 107 +++++++++++++++++++
1 file changed, 107 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/194df76c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java
new file mode 100644
index 0000000..ab4f1b8
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.lang.*;
+
+import java.util.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ *
+ */
+public class IgniteCacheManyAsyncOperationsTest extends IgniteCacheAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return 2;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return PARTITIONED;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicityMode() {
+ return TRANSACTIONAL;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ if (gridName.equals(getTestGridName(2)))
+ cfg.setClientMode(true);
+
+ return cfg;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testManyAsyncOperations() throws Exception {
+ try (Ignite client = startGrid(gridCount())) {
+ assertTrue(client.configuration().isClientMode());
+
+ IgniteCache<Object, Object> cache = client.cache(null).withAsync();
+
+ final int ASYNC_OPS = cache.getConfiguration(CacheConfiguration.class).getMaxConcurrentAsyncOperations();
+
+ log.info("Number of async operations: " + ASYNC_OPS);
+
+ Map<Integer, byte[]> map = new HashMap<>();
+
+ for (int i = 0; i < 500; i++)
+ map.put(i, new byte[128]);
+
+ for (int iter = 0; iter < 3; iter++) {
+ log.info("Iteration: " + iter);
+
+ List<IgniteFuture<?>> futs = new ArrayList<>(ASYNC_OPS);
+
+ for (int i = 0; i < ASYNC_OPS; i++) {
+ cache.putAll(map);
+
+ futs.add(cache.future());
+
+ if (i % 50 == 0)
+ log.info("Created futures: " + (i + 1));
+ }
+
+ for (int i = 0; i < ASYNC_OPS; i++) {
+ IgniteFuture<?> fut = futs.get(i);
+
+ fut.get();
+
+ if (i % 50 == 0)
+ log.info("Done: " + (i + 1));
+ }
+ }
+ }
+ }
+}
[32/41] ignite git commit: Platforms: moved several cache store
classes to Ignite.
Posted by sb...@apache.org.
Platforms: moved several cache store classes to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2938a9b4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2938a9b4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2938a9b4
Branch: refs/heads/ignite-1093
Commit: 2938a9b4a06b0e0a9f19625ce1b168e4a4a2f87d
Parents: 536af49
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 17:11:46 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 17:11:46 2015 +0300
----------------------------------------------------------------------
.../cache/store/PlatformCacheStore.java | 25 ++++++++
.../cache/store/PlatformCacheStoreCallback.java | 61 ++++++++++++++++++++
2 files changed, 86 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2938a9b4/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStore.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStore.java
new file mode 100644
index 0000000..6e0c1d9
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStore.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.cache.store;
+
+/**
+ * Marker interface denoting that this instance is platform cache store.
+ */
+public interface PlatformCacheStore {
+ // No-op.
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2938a9b4/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStoreCallback.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStoreCallback.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStoreCallback.java
new file mode 100644
index 0000000..32e0ab7
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStoreCallback.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.cache.store;
+
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.platform.*;
+import org.apache.ignite.internal.processors.platform.memory.*;
+
+/**
+ * Platform cache store callback.
+ */
+public abstract class PlatformCacheStoreCallback {
+ /** Context. */
+ protected final PlatformContext ctx;
+
+ /**
+ * Constructor.
+ *
+ * @param ctx Context.
+ */
+ protected PlatformCacheStoreCallback(PlatformContext ctx) {
+ this.ctx = ctx;
+ }
+
+ /**
+ * Invoke the callback.
+ *
+ * @param memPtr Memory pointer.
+ */
+ public void invoke(long memPtr) {
+ if (memPtr > 0) {
+ try (PlatformMemory mem = ctx.memory().get(memPtr)) {
+ PortableRawReaderEx reader = ctx.reader(mem);
+
+ invoke0(reader);
+ }
+ }
+ }
+
+ /**
+ * Internal invoke routine.
+ *
+ * @param reader Reader.
+ */
+ protected abstract void invoke0(PortableRawReaderEx reader);
+}
[29/41] ignite git commit: IGNITE-1302: Moving some common .Net
classes to Ignite.
Posted by sb...@apache.org.
IGNITE-1302: Moving some common .Net classes to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8df6b935
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8df6b935
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8df6b935
Branch: refs/heads/ignite-1093
Commit: 8df6b935c32d8b801ead4deb0470f84df435ff5a
Parents: 824cfa4
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Wed Aug 26 15:55:24 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 15:55:24 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.csproj | 22 ++
.../Common/AsyncSupportedAttribute.cs | 33 +++
.../Apache.Ignite.Core/Common/IAsyncSupport.cs | 52 ++++
.../dotnet/Apache.Ignite.Core/Common/IFuture.cs | 115 ++++++++
.../Common/IgniteException.cs | 66 +++++
.../Impl/Collections/CollectionExtensions.cs | 45 +++
.../Impl/Collections/MultiValueDictionary.cs | 143 ++++++++++
.../Impl/Collections/ReadOnlyCollection.cs | 102 +++++++
.../Impl/Collections/ReadOnlyDictionary.cs | 149 ++++++++++
.../Impl/Common/AsyncResult.cs | 71 +++++
.../Impl/Common/CompletedAsyncResult.cs | 70 +++++
.../Common/CopyOnWriteConcurrentDictionary.cs | 70 +++++
.../Impl/Common/DelegateConverter.cs | 253 ++++++++++++++++
.../Apache.Ignite.Core/Impl/Common/Future.cs | 286 +++++++++++++++++++
.../Impl/Common/FutureType.cs | 52 ++++
.../Impl/Common/GridArgumentCheck.cs | 76 +++++
.../Impl/Common/IFutureConverter.cs | 32 +++
.../Impl/Common/IFutureInternal.cs | 45 +++
.../Impl/Common/LoadedAssembliesResolver.cs | 96 +++++++
.../Impl/Common/TypeCaster.cs | 72 +++++
20 files changed, 1850 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 658e5fb..12e335a 100644
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -16,6 +16,7 @@
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Debug\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <DefineConstants>DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
@@ -26,6 +27,7 @@
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Debug\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <DefineConstants>DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
@@ -47,7 +49,26 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Common\IgniteException.cs" />
+ <Compile Include="Common\IAsyncSupport.cs" />
+ <Compile Include="Common\IFuture.cs" />
<Compile Include="Ignition.cs" />
+ <Compile Include="Common\AsyncSupportedAttribute.cs" />
+ <Compile Include="Impl\Collections\CollectionExtensions.cs" />
+ <Compile Include="Impl\Collections\MultiValueDictionary.cs" />
+ <Compile Include="Impl\Collections\ReadOnlyCollection.cs" />
+ <Compile Include="Impl\Collections\ReadOnlyDictionary.cs" />
+ <Compile Include="Impl\Common\AsyncResult.cs" />
+ <Compile Include="Impl\Common\CompletedAsyncResult.cs" />
+ <Compile Include="Impl\Common\CopyOnWriteConcurrentDictionary.cs" />
+ <Compile Include="Impl\Common\DelegateConverter.cs" />
+ <Compile Include="Impl\Common\Future.cs" />
+ <Compile Include="Impl\Common\FutureType.cs" />
+ <Compile Include="Impl\Common\GridArgumentCheck.cs" />
+ <Compile Include="Impl\Common\IFutureConverter.cs" />
+ <Compile Include="Impl\Common\IFutureInternal.cs" />
+ <Compile Include="Impl\Common\LoadedAssembliesResolver.cs" />
+ <Compile Include="Impl\Common\TypeCaster.cs" />
<Compile Include="Impl\Handle\Handle.cs" />
<Compile Include="Impl\Handle\HandleRegistry.cs" />
<Compile Include="Impl\Handle\IHandle.cs" />
@@ -64,6 +85,7 @@
<Compile Include="Impl\Portable\IO\IPortableStream.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs
new file mode 100644
index 0000000..094a93c
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Common
+{
+ using System;
+
+ /// <summary>
+ /// Attribute to indicate that method can be executed asynchronously if async mode is enabled.
+ /// To enable async mode, invoke <see cref="IAsyncSupport{TWithAsync}.WithAsync"/> method on the API.
+ /// The future for the async method can be retrieved via
+ /// <see cref="IFuture{T}"/> right after the execution of an asynchronous method.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Method)]
+ public sealed class AsyncSupportedAttribute : Attribute
+ {
+ // No-op.
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs
new file mode 100644
index 0000000..f6b6551
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Common
+{
+ /// <summary>
+ /// Allows to enable asynchronous mode on Grid APIs.
+ /// </summary>
+ /// <typeparam name="TWithAsync">Type of WithAsync method result.</typeparam>
+ public interface IAsyncSupport<out TWithAsync> where TWithAsync : IAsyncSupport<TWithAsync>
+ {
+ /// <summary>
+ /// Gets component with asynchronous mode enabled.
+ /// </summary>
+ /// <returns>Component with asynchronous mode enabled.</returns>
+ TWithAsync WithAsync();
+
+ /// <summary>
+ /// Gets a value indicating whether this instance is in asynchronous mode.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if asynchronous mode is enabled.
+ /// </value>
+ bool IsAsync { get; }
+
+ /// <summary>
+ /// Gets and resets future for previous asynchronous operation.
+ /// </summary>
+ /// <returns>Future for previous asynchronous operation.</returns>
+ IFuture GetFuture();
+
+ /// <summary>
+ /// Gets and resets future for previous asynchronous operation.
+ /// </summary>
+ /// <returns>Future for previous asynchronous operation.</returns>
+ IFuture<TResult> GetFuture<TResult>();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IFuture.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IFuture.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IFuture.cs
new file mode 100644
index 0000000..2e94cd4
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IFuture.cs
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Common
+{
+ using System;
+ using System.Threading.Tasks;
+
+ /// <summary>
+ /// Non-generic Future. Represents an asynchronous operation that can return a value.
+ /// <para/>
+ /// All members are thread-safe and may be used concurrently from multiple threads.
+ /// </summary>
+ public interface IFuture
+ {
+ /// <summary>
+ /// Gets a value indicating whether this instance is done.
+ /// </summary>
+ bool IsDone
+ {
+ get;
+ }
+
+ /// <summary>
+ /// Gets the future result.
+ /// </summary>
+ /// <returns>Future result.</returns>
+ object Get();
+
+ /// <summary>
+ /// Gets the future result with a timeout.
+ /// </summary>
+ /// <param name="timeout">The timeout.</param>
+ /// <returns>
+ /// Future result, if it is obtained within specified timeout; otherwise, throws <see cref="TimeoutException"/>
+ /// </returns>
+ /// <exception cref="TimeoutException">Thrown if Get operation exceeded specified timeout.</exception>
+ object Get(TimeSpan timeout);
+
+ /// <summary>
+ /// Listens this instance and invokes callback upon future completion.
+ /// </summary>
+ /// <param name="callback">The callback to execute upon future completion.</param>
+ void Listen(Action callback);
+
+ /// <summary>
+ /// Listens this instance and invokes callback upon future completion.
+ /// </summary>
+ /// <param name="callback">The callback to execute upon future completion.</param>
+ void Listen(Action<IFuture> callback);
+
+ /// <summary>
+ /// Gets an IAsyncResult indicating the state of this Future.
+ /// </summary>
+ /// <returns>Future state representation in form of IAsyncResult.</returns>
+ IAsyncResult ToAsyncResult();
+
+ /// <summary>
+ /// Gets a Task that returns the result of this Future.
+ /// </summary>
+ /// <returns>Task that completes when this future gets done and returns the result.</returns>
+ Task<object> ToTask();
+ }
+
+ /// <summary>
+ /// Generic Future. Represents an asynchronous operation that can return a value.
+ /// <para/>
+ /// All members are thread-safe and may be used concurrently from multiple threads.
+ /// </summary>
+ /// <typeparam name="T">Future result type.</typeparam>
+ public interface IFuture<T> : IFuture
+ {
+ /// <summary>
+ /// Gets the future result.
+ /// </summary>
+ /// <returns>Future result.</returns>
+ new T Get();
+
+ /// <summary>
+ /// Gets the future result with a timeout.
+ /// </summary>
+ /// <param name="timeout">The timeout.</param>
+ /// <returns>
+ /// Future result, if it is obtained within specified timeout; otherwise, throws <see cref="TimeoutException"/>
+ /// </returns>
+ /// <exception cref="TimeoutException">Thrown if Get operation exceeded specified timeout.</exception>
+ new T Get(TimeSpan timeout);
+
+ /// <summary>
+ /// Gets a Task that returns the result of this Future.
+ /// </summary>
+ /// <returns>Task that completes when this future gets done and returns the result.</returns>
+ new Task<T> ToTask();
+
+ /// <summary>
+ /// Listens this instance and invokes callback upon future completion.
+ /// </summary>
+ /// <param name="callback">The callback to execute upon future completion.</param>
+ void Listen(Action<IFuture<T>> callback);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IgniteException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IgniteException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IgniteException.cs
new file mode 100644
index 0000000..4626407
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IgniteException.cs
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Common
+{
+ using System;
+ using System.Runtime.Serialization;
+
+ /// <summary>
+ /// General grid exception. Indicates any error condition within Grid.
+ /// </summary>
+ [Serializable]
+ public class IgniteException : Exception
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="IgniteException"/> class.
+ /// </summary>
+ public IgniteException()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="IgniteException" /> class.
+ /// </summary>
+ /// <param name="message">The message that describes the error.</param>
+ public IgniteException(string message) : base(message)
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="IgniteException" /> class.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="cause">The cause.</param>
+ public IgniteException(string message, Exception cause) : base(message, cause)
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="IgniteException"/> class.
+ /// </summary>
+ /// <param name="info">Serialization information.</param>
+ /// <param name="ctx">Streaming context.</param>
+ protected IgniteException(SerializationInfo info, StreamingContext ctx) : base(info, ctx)
+ {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/CollectionExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/CollectionExtensions.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/CollectionExtensions.cs
new file mode 100644
index 0000000..57295cb
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/CollectionExtensions.cs
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Collections
+{
+ using System.Collections.Generic;
+
+ /// <summary>
+ /// Collection extension methods.
+ /// </summary>
+ public static class CollectionExtensions
+ {
+ /// <summary>
+ /// Returns a read-only System.Collections.Generic.IDictionary{K, V} wrapper for the current collection.
+ /// </summary>
+ public static IDictionary<TKey, TValue> AsReadOnly<TKey, TValue>(this IDictionary<TKey, TValue> dict)
+ {
+ return new ReadOnlyDictionary<TKey, TValue>(dict);
+ }
+
+ /// <summary>
+ /// Returns a read-only System.Collections.Generic.ICollection{K, V} wrapper for the current collection.
+ /// </summary>
+ public static ICollection<T> AsReadOnly<T>(this ICollection<T> col)
+ {
+ var list = col as List<T>;
+
+ return list != null ? (ICollection<T>) list.AsReadOnly() : new ReadOnlyCollection<T>(col);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
new file mode 100644
index 0000000..bd7e895
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
@@ -0,0 +1,143 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Collections
+{
+ using System.Collections.Generic;
+
+ /// <summary>
+ /// Multiple-values-per-key dictionary.
+ /// </summary>
+ public class MultiValueDictionary<TKey, TValue>
+ {
+ /** Inner dictionary */
+ private readonly Dictionary<TKey, object> _dict = new Dictionary<TKey, object>();
+
+ /// <summary>
+ /// Adds a value.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="val">The value.</param>
+ public void Add(TKey key, TValue val)
+ {
+ object val0;
+
+ if (_dict.TryGetValue(key, out val0))
+ {
+ var list = val0 as List<TValue>;
+
+ if (list != null)
+ list.Add(val);
+ else
+ _dict[key] = new List<TValue> {(TValue) val0, val};
+ }
+ else
+ _dict[key] = val;
+ }
+
+ /// <summary>
+ /// Tries the get a value. In case of multiple values for a key, returns the last one.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>True if value has been found for specified key; otherwise false.</returns>
+ public bool TryGetValue(TKey key, out TValue val)
+ {
+ object val0;
+
+ if (!_dict.TryGetValue(key, out val0))
+ {
+ val = default(TValue);
+ return false;
+ }
+
+ var list = val0 as List<TValue>;
+
+ if (list != null)
+ val = list[list.Count - 1];
+ else
+ val = (TValue) val0;
+
+ return true;
+ }
+
+ /// <summary>
+ /// Removes the specified value for the specified key.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="val">The value.</param>
+ public void Remove(TKey key, TValue val)
+ {
+ object val0;
+
+ if (!_dict.TryGetValue(key, out val0))
+ return;
+
+ var list = val0 as List<TValue>;
+
+ if (list != null)
+ {
+ list.Remove(val);
+
+ if (list.Count == 0)
+ _dict.Remove(key);
+ }
+ else if (Equals(val0, val))
+ _dict.Remove(key);
+ }
+
+ /// <summary>
+ /// Removes the last value for the specified key and returns it.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>True if value has been found for specified key; otherwise false.</returns>
+ public bool TryRemove(TKey key, out TValue val)
+ {
+ object val0;
+
+ if (!_dict.TryGetValue(key, out val0))
+ {
+ val = default(TValue);
+
+ return false;
+ }
+
+ var list = val0 as List<TValue>;
+
+ if (list != null)
+ {
+ var index = list.Count - 1;
+
+ val = list[index];
+
+ list.RemoveAt(index);
+
+ if (list.Count == 0)
+ _dict.Remove(key);
+
+ return true;
+ }
+
+ val = (TValue) val0;
+
+ _dict.Remove(key);
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs
new file mode 100644
index 0000000..23cae6b
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs
@@ -0,0 +1,102 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Collections
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+
+ /// <summary>
+ /// Read-only wrapper over ICollection{T}.
+ /// </summary>
+ internal struct ReadOnlyCollection<T> : ICollection<T>
+ {
+ /** Wrapped collection. */
+ private readonly ICollection<T> _col;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ReadOnlyCollection{T}"/> class.
+ /// </summary>
+ public ReadOnlyCollection(ICollection<T> col)
+ {
+ _col = col;
+ }
+
+ /** <inheritdoc /> */
+ public IEnumerator<T> GetEnumerator()
+ {
+ return _col.GetEnumerator();
+ }
+
+ /** <inheritdoc /> */
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable) _col).GetEnumerator();
+ }
+
+ /** <inheritdoc /> */
+ public void Add(T item)
+ {
+ throw GetReadOnlyException();
+ }
+
+ /** <inheritdoc /> */
+ public void Clear()
+ {
+ throw GetReadOnlyException();
+ }
+
+ /** <inheritdoc /> */
+ public bool Contains(T item)
+ {
+ return _col.Contains(item);
+ }
+
+ /** <inheritdoc /> */
+ public void CopyTo(T[] array, int arrayIndex)
+ {
+ _col.CopyTo(array, arrayIndex);
+ }
+
+ /** <inheritdoc /> */
+ public bool Remove(T item)
+ {
+ throw GetReadOnlyException();
+ }
+
+ /** <inheritdoc /> */
+ public int Count
+ {
+ get { return _col.Count; }
+ }
+
+ /** <inheritdoc /> */
+ public bool IsReadOnly
+ {
+ get { return true; }
+ }
+
+ /// <summary>
+ /// Gets the readonly exception.
+ /// </summary>
+ private static Exception GetReadOnlyException()
+ {
+ return new NotSupportedException("Collection is read-only.");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs
new file mode 100644
index 0000000..60ec9d0
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Collections
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+
+ /// <summary>
+ /// Read-only wrapper over IDictionary{K, V}.
+ /// </summary>
+ internal struct ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>
+ {
+ /** Inner dict. */
+ private readonly IDictionary<TKey, TValue> _dict;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ReadOnlyDictionary{K, V}"/> class.
+ /// </summary>
+ /// <param name="dict">The dictionary to wrap.</param>
+ public ReadOnlyDictionary(IDictionary<TKey, TValue> dict)
+ {
+ Debug.Assert(dict != null);
+
+ _dict = dict;
+ }
+
+ /** <inheritdoc /> */
+ public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
+ {
+ return _dict.GetEnumerator();
+ }
+
+ /** <inheritdoc /> */
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable) _dict).GetEnumerator();
+ }
+
+ /** <inheritdoc /> */
+ public void Add(KeyValuePair<TKey, TValue> item)
+ {
+ throw GetReadonlyException();
+ }
+
+ /** <inheritdoc /> */
+ public void Clear()
+ {
+ throw GetReadonlyException();
+ }
+
+ /** <inheritdoc /> */
+ public bool Contains(KeyValuePair<TKey, TValue> item)
+ {
+ return _dict.Contains(item);
+ }
+
+ /** <inheritdoc /> */
+ public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
+ {
+ _dict.CopyTo(array, arrayIndex);
+ }
+
+ /** <inheritdoc /> */
+ public bool Remove(KeyValuePair<TKey, TValue> item)
+ {
+ throw GetReadonlyException();
+ }
+
+ /** <inheritdoc /> */
+ public int Count
+ {
+ get { return _dict.Count; }
+ }
+
+ /** <inheritdoc /> */
+ public bool IsReadOnly
+ {
+ get { return true; }
+ }
+
+ /** <inheritdoc /> */
+ public bool ContainsKey(TKey key)
+ {
+ return _dict.ContainsKey(key);
+ }
+
+ /** <inheritdoc /> */
+ public void Add(TKey key, TValue value)
+ {
+ throw GetReadonlyException();
+ }
+
+ /** <inheritdoc /> */
+ public bool Remove(TKey key)
+ {
+ return _dict.Remove(key);
+ }
+
+ /** <inheritdoc /> */
+ public bool TryGetValue(TKey key, out TValue value)
+ {
+ return _dict.TryGetValue(key, out value);
+ }
+
+ /** <inheritdoc /> */
+ public TValue this[TKey key]
+ {
+ get { return _dict[key]; }
+ set { throw GetReadonlyException(); }
+ }
+
+ /** <inheritdoc /> */
+ public ICollection<TKey> Keys
+ {
+ get { return _dict.Keys; }
+ }
+
+ /** <inheritdoc /> */
+ public ICollection<TValue> Values
+ {
+ get { return _dict.Values; }
+ }
+
+ /// <summary>
+ /// Gets the readonly exception.
+ /// </summary>
+ private static Exception GetReadonlyException()
+ {
+ return new NotSupportedException("Dictionary is read-only.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs
new file mode 100644
index 0000000..4e5c396
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Threading;
+ using Apache.Ignite.Core.Common;
+
+ /// <summary>
+ /// Adapts IGridFuture to the IAsyncResult.
+ /// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable",
+ Justification = "Implementing IDisposable has no point since we return this class as IAsyncResult " +
+ "to the client, and IAsyncResult is not IDisposable.")]
+ public class AsyncResult : IAsyncResult
+ {
+ /** */
+ private readonly ManualResetEvent _waitHandle;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AsyncResult"/> class.
+ /// </summary>
+ /// <param name="fut">The future to wrap.</param>
+ public AsyncResult(IFuture fut)
+ {
+ _waitHandle = new ManualResetEvent(false);
+
+ fut.Listen(() => _waitHandle.Set());
+ }
+
+ /** <inheritdoc /> */
+ public bool IsCompleted
+ {
+ get { return _waitHandle.WaitOne(0); }
+ }
+
+ /** <inheritdoc /> */
+ public WaitHandle AsyncWaitHandle
+ {
+ get { return _waitHandle; }
+ }
+
+ /** <inheritdoc /> */
+ public object AsyncState
+ {
+ get { return null; }
+ }
+
+ /** <inheritdoc /> */
+ public bool CompletedSynchronously
+ {
+ get { return false; }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
new file mode 100644
index 0000000..14195fd
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Threading;
+
+ /// <summary>
+ /// Represents an IAsyncResult that is completed.
+ /// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable",
+ Justification = "Implementing IDisposable has no point since we return this class as IAsyncResult " +
+ "to the client, and IAsyncResult is not IDisposable.")]
+ public class CompletedAsyncResult : IAsyncResult
+ {
+ /** Singleton instance. */
+ public static readonly IAsyncResult Instance = new CompletedAsyncResult();
+
+ /** */
+ private readonly WaitHandle _asyncWaitHandle = new ManualResetEvent(true);
+
+ /// <summary>
+ /// Prevents a default instance of the <see cref="CompletedAsyncResult"/> class from being created.
+ /// </summary>
+ private CompletedAsyncResult()
+ {
+ // No-op.
+ }
+
+ /** <inheritdoc /> */
+ public bool IsCompleted
+ {
+ get { return true; }
+ }
+
+ /** <inheritdoc /> */
+ public WaitHandle AsyncWaitHandle
+ {
+ get { return _asyncWaitHandle; }
+ }
+
+ /** <inheritdoc /> */
+ public object AsyncState
+ {
+ get { return null; }
+ }
+
+ /** <inheritdoc /> */
+ public bool CompletedSynchronously
+ {
+ get { return false; }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
new file mode 100644
index 0000000..fa785b2
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System;
+ using System.Collections.Generic;
+
+ /// <summary>
+ /// Concurrent dictionary with CopyOnWrite mechanism inside.
+ /// Good for frequent reads / infrequent writes scenarios.
+ /// </summary>
+ public class CopyOnWriteConcurrentDictionary<TKey, TValue>
+ {
+ /** */
+ private volatile Dictionary<TKey, TValue> _dict = new Dictionary<TKey, TValue>();
+
+ /// <summary>
+ /// Gets the value associated with the specified key.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>true if the dictionary contains an element with the specified key; otherwise, false.</returns>
+ public bool TryGetValue(TKey key, out TValue val)
+ {
+ return _dict.TryGetValue(key, out val);
+ }
+
+ /// <summary>
+ /// Adds a key/value pair if the key does not already exist.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="valueFactory">The function used to generate a value for the key.</param>
+ /// <returns>The value for the key.</returns>
+ public TValue GetOrAdd(TKey key, Func<TKey, TValue> valueFactory)
+ {
+ lock (this)
+ {
+ TValue res;
+
+ if (_dict.TryGetValue(key, out res))
+ return res;
+
+ var dict0 = new Dictionary<TKey, TValue>(_dict);
+
+ res = valueFactory(key);
+
+ dict0[key] = res;
+
+ _dict = dict0;
+
+ return res;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
new file mode 100644
index 0000000..7f83588
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
@@ -0,0 +1,253 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System;
+ using System.Diagnostics;
+ using System.Linq.Expressions;
+ using System.Reflection;
+ using System.Reflection.Emit;
+
+ /// <summary>
+ /// Converts generic and non-generic delegates.
+ /// </summary>
+ public static class DelegateConverter
+ {
+ /** */
+ private const string DefaultMethodName = "Invoke";
+
+ /// <summary>
+ /// Compiles a function without arguments.
+ /// </summary>
+ /// <param name="targetType">Type of the target.</param>
+ /// <returns>Compiled function that calls specified method on specified target.</returns>
+ public static Func<object, object> CompileFunc(Type targetType)
+ {
+ var method = targetType.GetMethod(DefaultMethodName);
+
+ var targetParam = Expression.Parameter(typeof(object));
+ var targetParamConverted = Expression.Convert(targetParam, targetType);
+
+ var callExpr = Expression.Call(targetParamConverted, method);
+ var convertResultExpr = Expression.Convert(callExpr, typeof(object));
+
+ return Expression.Lambda<Func<object, object>>(convertResultExpr, targetParam).Compile();
+ }
+
+ /// <summary>
+ /// Compiles a function with arbitrary number of arguments.
+ /// </summary>
+ /// <typeparam name="T">Resulting delegate type.</typeparam>
+ /// <param name="targetType">Type of the target.</param>
+ /// <param name="argTypes">Argument types.</param>
+ /// <param name="convertToObject">
+ /// Flags that indicate whether func params and/or return value should be converted from/to object.
+ /// </param>
+ /// <param name="methodName">Name of the method.</param>
+ /// <returns>
+ /// Compiled function that calls specified method on specified target.
+ /// </returns>
+ public static T CompileFunc<T>(Type targetType, Type[] argTypes, bool[] convertToObject = null,
+ string methodName = null)
+ where T : class
+ {
+ var method = targetType.GetMethod(methodName ?? DefaultMethodName, argTypes);
+
+ return CompileFunc<T>(targetType, method, argTypes, convertToObject);
+ }
+
+ /// <summary>
+ /// Compiles a function with arbitrary number of arguments.
+ /// </summary>
+ /// <typeparam name="T">Resulting delegate type.</typeparam>
+ /// <param name="method">Method.</param>
+ /// <param name="targetType">Type of the target.</param>
+ /// <param name="argTypes">Argument types.</param>
+ /// <param name="convertToObject">
+ /// Flags that indicate whether func params and/or return value should be converted from/to object.
+ /// </param>
+ /// <returns>
+ /// Compiled function that calls specified method on specified target.
+ /// </returns>
+ public static T CompileFunc<T>(Type targetType, MethodInfo method, Type[] argTypes,
+ bool[] convertToObject = null)
+ where T : class
+ {
+ if (argTypes == null)
+ {
+ var args = method.GetParameters();
+ argTypes = new Type[args.Length];
+
+ for (int i = 0; i < args.Length; i++)
+ argTypes[i] = args[i].ParameterType;
+ }
+
+ Debug.Assert(convertToObject == null || (convertToObject.Length == argTypes.Length + 1));
+ Debug.Assert(method != null);
+
+ targetType = method.IsStatic ? null : (targetType ?? method.DeclaringType);
+
+ var targetParam = Expression.Parameter(typeof(object));
+
+ Expression targetParamConverted = null;
+ ParameterExpression[] argParams;
+ int argParamsOffset = 0;
+
+ if (targetType != null)
+ {
+ targetParamConverted = Expression.Convert(targetParam, targetType);
+ argParams = new ParameterExpression[argTypes.Length + 1];
+ argParams[0] = targetParam;
+ argParamsOffset = 1;
+ }
+ else
+ argParams = new ParameterExpression[argTypes.Length]; // static method
+
+ var argParamsConverted = new Expression[argTypes.Length];
+
+ for (var i = 0; i < argTypes.Length; i++)
+ {
+ if (convertToObject == null || convertToObject[i])
+ {
+ var argParam = Expression.Parameter(typeof (object));
+ argParams[i + argParamsOffset] = argParam;
+ argParamsConverted[i] = Expression.Convert(argParam, argTypes[i]);
+ }
+ else
+ {
+ var argParam = Expression.Parameter(argTypes[i]);
+ argParams[i + argParamsOffset] = argParam;
+ argParamsConverted[i] = argParam;
+ }
+ }
+
+ Expression callExpr = Expression.Call(targetParamConverted, method, argParamsConverted);
+
+ if (convertToObject == null || convertToObject[argTypes.Length])
+ callExpr = Expression.Convert(callExpr, typeof(object));
+
+ return Expression.Lambda<T>(callExpr, argParams).Compile();
+ }
+
+ /// <summary>
+ /// Compiles a generic ctor with arbitrary number of arguments.
+ /// </summary>
+ /// <typeparam name="T">Result func type.</typeparam>
+ /// <param name="type">Type to be created by ctor.</param>
+ /// <param name="argTypes">Argument types.</param>
+ /// <param name="convertResultToObject">if set to <c>true</c> [convert result to object].
+ /// Flag that indicates whether ctor return value should be converted to object.
+ /// </param>
+ /// <returns>
+ /// Compiled generic constructor.
+ /// </returns>
+ public static T CompileCtor<T>(Type type, Type[] argTypes, bool convertResultToObject = true)
+ {
+ var ctor = type.GetConstructor(argTypes);
+
+ Debug.Assert(ctor != null);
+
+ var args = new ParameterExpression[argTypes.Length];
+ var argsConverted = new Expression[argTypes.Length];
+
+ for (var i = 0; i < argTypes.Length; i++)
+ {
+ var arg = Expression.Parameter(typeof(object));
+ args[i] = arg;
+ argsConverted[i] = Expression.Convert(arg, argTypes[i]);
+ }
+
+ Expression ctorExpr = Expression.New(ctor, argsConverted); // ctor takes args of specific types
+
+ if (convertResultToObject)
+ ctorExpr = Expression.Convert(ctorExpr, typeof (object)); // convert ctor result to object
+
+ return Expression.Lambda<T>(ctorExpr, args).Compile(); // lambda takes args as objects
+ }
+
+ /// <summary>
+ /// Compiles the field setter.
+ /// </summary>
+ /// <param name="field">The field.</param>
+ /// <returns>Compiled field setter.</returns>
+ public static Action<object, object> CompileFieldSetter(FieldInfo field)
+ {
+ Debug.Assert(field != null);
+ Debug.Assert(field.DeclaringType != null); // non-static
+
+ var targetParam = Expression.Parameter(typeof(object));
+ var targetParamConverted = Expression.Convert(targetParam, field.DeclaringType);
+
+ var valParam = Expression.Parameter(typeof(object));
+ var valParamConverted = Expression.Convert(valParam, field.FieldType);
+
+ var assignExpr = Expression.Call(GetWriteFieldMethod(field), targetParamConverted, valParamConverted);
+
+ return Expression.Lambda<Action<object, object>>(assignExpr, targetParam, valParam).Compile();
+ }
+
+ /// <summary>
+ /// Compiles the property setter.
+ /// </summary>
+ /// <param name="prop">The property.</param>
+ /// <returns>Compiled property setter.</returns>
+ public static Action<object, object> CompilePropertySetter(PropertyInfo prop)
+ {
+ Debug.Assert(prop != null);
+ Debug.Assert(prop.DeclaringType != null); // non-static
+
+ var targetParam = Expression.Parameter(typeof(object));
+ var targetParamConverted = Expression.Convert(targetParam, prop.DeclaringType);
+
+ var valParam = Expression.Parameter(typeof(object));
+ var valParamConverted = Expression.Convert(valParam, prop.PropertyType);
+
+ var fld = Expression.Property(targetParamConverted, prop);
+
+ var assignExpr = Expression.Assign(fld, valParamConverted);
+
+ return Expression.Lambda<Action<object, object>>(assignExpr, targetParam, valParam).Compile();
+ }
+
+ /// <summary>
+ /// Gets a method to write a field (including private and readonly).
+ /// NOTE: Expression Trees can't write readonly fields.
+ /// </summary>
+ /// <param name="field">The field.</param>
+ /// <returns>Resulting MethodInfo.</returns>
+ public static DynamicMethod GetWriteFieldMethod(FieldInfo field)
+ {
+ Debug.Assert(field != null);
+
+ var module = Assembly.GetExecutingAssembly().GetModules()[0];
+
+ var method = new DynamicMethod(string.Empty, null, new[] { field.DeclaringType, field.FieldType }, module,
+ true);
+
+ var il = method.GetILGenerator();
+
+ il.Emit(OpCodes.Ldarg_0);
+ il.Emit(OpCodes.Ldarg_1);
+ il.Emit(OpCodes.Stfld, field);
+ il.Emit(OpCodes.Ret);
+
+ return method;
+ }
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
new file mode 100644
index 0000000..c62cfd2
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
@@ -0,0 +1,286 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl.Portable.IO;
+
+ /// <summary>
+ /// Grid future implementation.
+ /// </summary>
+ [SuppressMessage("ReSharper", "ParameterHidesMember")]
+ public sealed class Future<T> : IFutureInternal, IFuture<T>
+ {
+ /** Converter. */
+ private readonly IFutureConverter<T> _converter;
+
+ /** Result. */
+ private T _res;
+
+ /** Caught cxception. */
+ private Exception _err;
+
+ /** Done flag. */
+ private volatile bool _done;
+
+ /** Listener(s). Either Action or List{Action}. */
+ private object _callbacks;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="converter">Future result marshaller and converter.</param>
+ public Future(IFutureConverter<T> converter = null)
+ {
+ _converter = converter;
+ }
+
+ /** <inheritdoc/> */
+ public bool IsDone
+ {
+ get { return _done; }
+ }
+
+ /** <inheritdoc/> */
+ public T Get()
+ {
+ if (!_done)
+ {
+ lock (this)
+ {
+ while (!_done)
+ Monitor.Wait(this);
+ }
+ }
+
+ return Get0();
+ }
+
+ /** <inheritdoc/> */
+ public T Get(TimeSpan timeout)
+ {
+ long ticks = timeout.Ticks;
+
+ if (ticks < 0)
+ throw new ArgumentException("Timeout cannot be negative.");
+
+ if (ticks == 0)
+ return Get();
+
+ if (!_done)
+ {
+ // Fallback to locked mode.
+ lock (this)
+ {
+ long endTime = DateTime.Now.Ticks + ticks;
+
+ if (!_done)
+ {
+ while (true)
+ {
+ Monitor.Wait(this, timeout);
+
+ if (_done)
+ break;
+
+ ticks = endTime - DateTime.Now.Ticks;
+
+ if (ticks <= 0)
+ throw new TimeoutException("Timeout waiting for future completion.");
+
+ timeout = TimeSpan.FromTicks(ticks);
+ }
+ }
+ }
+ }
+
+ return Get0();
+ }
+
+ /** <inheritdoc/> */
+ public void Listen(Action callback)
+ {
+ Listen((Action<IFuture<T>>) (fut => callback()));
+ }
+
+ /** <inheritdoc/> */
+ public void Listen(Action<IFuture> callback)
+ {
+ Listen((Action<IFuture<T>>)callback);
+ }
+
+ /** <inheritdoc/> */
+ public void Listen(Action<IFuture<T>> callback)
+ {
+ GridArgumentCheck.NotNull(callback, "callback");
+
+ if (!_done)
+ {
+ lock (this)
+ {
+ if (!_done)
+ {
+ AddCallback(callback);
+
+ return;
+ }
+ }
+ }
+
+ callback(this);
+ }
+
+ /// <summary>
+ /// Get result or throw an error.
+ /// </summary>
+ private T Get0()
+ {
+ if (_err != null)
+ throw _err;
+
+ return _res;
+ }
+
+ /** <inheritdoc/> */
+ public IAsyncResult ToAsyncResult()
+ {
+ return _done ? CompletedAsyncResult.Instance : new AsyncResult(this);
+ }
+
+ /** <inheritdoc/> */
+ Task<object> IFuture.ToTask()
+ {
+ return Task.Factory.FromAsync(ToAsyncResult(), x => (object) Get());
+ }
+
+ /** <inheritdoc/> */
+ public Task<T> ToTask()
+ {
+ return Task.Factory.FromAsync(ToAsyncResult(), x => Get());
+ }
+
+ /** <inheritdoc/> */
+ object IFuture.Get(TimeSpan timeout)
+ {
+ return Get(timeout);
+ }
+
+ /** <inheritdoc/> */
+ object IFuture.Get()
+ {
+ return Get();
+ }
+
+ /** <inheritdoc /> */
+ public void OnResult(IPortableStream stream)
+ {
+ try
+ {
+ OnResult(_converter.Convert(stream));
+ }
+ catch (Exception ex)
+ {
+ OnError(ex);
+ }
+ }
+
+ /** <inheritdoc /> */
+ public void OnError(Exception err)
+ {
+ OnDone(default(T), err);
+ }
+
+ /** <inheritdoc /> */
+ public void OnNullResult()
+ {
+ OnResult(default(T));
+ }
+
+ /// <summary>
+ /// Set result.
+ /// </summary>
+ /// <param name="res">Result.</param>
+ internal void OnResult(T res)
+ {
+ OnDone(res, null);
+ }
+
+ /// <summary>
+ /// Set future to Done state.
+ /// </summary>
+ /// <param name="res">Result.</param>
+ /// <param name="err">Error.</param>
+ public void OnDone(T res, Exception err)
+ {
+ object callbacks0 = null;
+
+ lock (this)
+ {
+ if (!_done)
+ {
+ _res = res;
+ _err = err;
+
+ _done = true;
+
+ Monitor.PulseAll(this);
+
+ // Notify listeners outside the lock
+ callbacks0 = _callbacks;
+ _callbacks = null;
+ }
+ }
+
+ if (callbacks0 != null)
+ {
+ var list = callbacks0 as List<Action<IFuture<T>>>;
+
+ if (list != null)
+ list.ForEach(x => x(this));
+ else
+ ((Action<IFuture<T>>) callbacks0)(this);
+ }
+ }
+
+ /// <summary>
+ /// Adds a callback.
+ /// </summary>
+ private void AddCallback(Action<IFuture<T>> callback)
+ {
+ if (_callbacks == null)
+ {
+ _callbacks = callback;
+
+ return;
+ }
+
+ var list = _callbacks as List<Action<IFuture<T>>> ??
+ new List<Action<IFuture<T>>> {(Action<IFuture<T>>) _callbacks};
+
+ list.Add(callback);
+
+ _callbacks = list;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
new file mode 100644
index 0000000..0beff04
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ /// <summary>
+ /// Future types.
+ /// </summary>
+ public enum FutureType
+ {
+ /** Future type: byte. */
+ Byte = 1,
+
+ /** Future type: boolean. */
+ Bool = 2,
+
+ /** Future type: short. */
+ Short = 3,
+
+ /** Future type: char. */
+ Char = 4,
+
+ /** Future type: int. */
+ Int = 5,
+
+ /** Future type: float. */
+ Float = 6,
+
+ /** Future type: long. */
+ Long = 7,
+
+ /** Future type: double. */
+ Double = 8,
+
+ /** Future type: object. */
+ Object = 9
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/GridArgumentCheck.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/GridArgumentCheck.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/GridArgumentCheck.cs
new file mode 100644
index 0000000..a1fadfe
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/GridArgumentCheck.cs
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System;
+ using System.Collections.Generic;
+
+ /// <summary>
+ /// Arguments check helpers.
+ /// </summary>
+ public static class GridArgumentCheck
+ {
+ /// <summary>
+ /// Throws an ArgumentNullException if specified arg is null.
+ /// </summary>
+ /// <param name="arg">The argument.</param>
+ /// <param name="argName">Name of the argument.</param>
+ public static void NotNull(object arg, string argName)
+ {
+ if (arg == null)
+ throw new ArgumentNullException(argName);
+ }
+
+ /// <summary>
+ /// Throws an ArgumentException if specified arg is null or empty string.
+ /// </summary>
+ /// <param name="arg">The argument.</param>
+ /// <param name="argName">Name of the argument.</param>
+ public static void NotNullOrEmpty(string arg, string argName)
+ {
+ if (string.IsNullOrEmpty(arg))
+ throw new ArgumentException(string.Format("'{0}' argument should not be null or empty.", argName),
+ argName);
+ }
+
+ /// <summary>
+ /// Throws an ArgumentException if specified arg is null or empty string.
+ /// </summary>
+ /// <param name="collection">The collection.</param>
+ /// <param name="argName">Name of the argument.</param>
+ public static void NotNullOrEmpty<T>(ICollection<T> collection, string argName)
+ {
+ if (collection == null || collection.Count == 0)
+ throw new ArgumentException(string.Format("'{0}' argument should not be null or empty.", argName),
+ argName);
+ }
+
+ /// <summary>
+ /// Throws an ArgumentException if specified condition is false.
+ /// </summary>
+ /// <param name="condition">Condition.</param>
+ /// <param name="argName">Name of the argument.</param>
+ /// <param name="message">Message.</param>
+ public static void Ensure(bool condition, string argName, string message)
+ {
+ if (!condition)
+ throw new ArgumentException(string.Format("'{0}' argument is invalid: {1}", argName, message),
+ argName);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
new file mode 100644
index 0000000..4169c61
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using Apache.Ignite.Core.Impl.Portable.IO;
+
+ /// <summary>
+ /// Marshals and converts future value.
+ /// </summary>
+ public interface IFutureConverter<out T>
+ {
+ /// <summary>
+ /// Reads and converts a value.
+ /// </summary>
+ T Convert(IPortableStream stream);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
new file mode 100644
index 0000000..8547545
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System;
+ using Apache.Ignite.Core.Impl.Portable.IO;
+
+ /// <summary>
+ /// Internal future interface.
+ /// </summary>
+ public interface IFutureInternal
+ {
+ /// <summary>
+ /// Set result from stream.
+ /// </summary>
+ /// <param name="stream">Stream.</param>
+ void OnResult(IPortableStream stream);
+
+ /// <summary>
+ /// Set null result.
+ /// </summary>
+ void OnNullResult();
+
+ /// <summary>
+ /// Set error result.
+ /// </summary>
+ /// <param name="err">Exception.</param>
+ void OnError(Exception err);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs
new file mode 100644
index 0000000..c158d5c
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Reflection;
+
+ /// <summary>
+ /// Resolves loaded assemblies by name.
+ /// </summary>
+ public class LoadedAssembliesResolver
+ {
+ // The lazy singleton instance.
+ private static readonly Lazy<LoadedAssembliesResolver> LazyInstance = new Lazy<LoadedAssembliesResolver>();
+
+ // Assemblies map.
+ private volatile Dictionary<string, Assembly> _map;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LoadedAssembliesResolver"/> class.
+ /// </summary>
+ public LoadedAssembliesResolver()
+ {
+ lock (this)
+ {
+ AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad;
+
+ UpdateMap();
+ }
+ }
+
+ /// <summary>
+ /// Handles the AssemblyLoad event of the AppDomain.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="args">The <see cref="AssemblyLoadEventArgs"/> instance containing the event data.</param>
+ private void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
+ {
+ lock (this)
+ {
+ UpdateMap();
+ }
+ }
+
+ /// <summary>
+ /// Updates the assembly map according to the current list of loaded assemblies.
+ /// </summary>
+ private void UpdateMap()
+ {
+ var assemblies = AppDomain.CurrentDomain.GetAssemblies();
+
+ _map = new Dictionary<string, Assembly>(assemblies.Length);
+
+ foreach (var assembly in assemblies)
+ _map[assembly.FullName] = assembly;
+ }
+
+ /// <summary>
+ /// Gets the singleton instance.
+ /// </summary>
+ public static LoadedAssembliesResolver Instance
+ {
+ get { return LazyInstance.Value; }
+ }
+
+ /// <summary>
+ /// Gets the assembly by name.
+ /// </summary>
+ /// <param name="assemblyName">Name of the assembly.</param>
+ /// <returns>Assembly with specified name, or null.</returns>
+ [SuppressMessage("ReSharper", "InconsistentlySynchronizedField")]
+ public Assembly GetAssembly(string assemblyName)
+ {
+ Assembly asm;
+
+ return _map.TryGetValue(assemblyName, out asm) ? asm : null;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8df6b935/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
new file mode 100644
index 0000000..d0dd2a9
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System;
+ using System.Linq.Expressions;
+
+ /// <summary>
+ /// Does type casts without extra boxing.
+ /// Should be used when casting compile-time incompatible value types instead of "(T)(object)x".
+ /// </summary>
+ /// <typeparam name="T">Target type</typeparam>
+ public static class TypeCaster<T>
+ {
+ /// <summary>
+ /// Efficiently casts an object from TFrom to T.
+ /// Does not cause boxing for value types.
+ /// </summary>
+ /// <typeparam name="TFrom">Source type to cast from.</typeparam>
+ /// <param name="obj">The object to cast.</param>
+ /// <returns>Casted object.</returns>
+ public static T Cast<TFrom>(TFrom obj)
+ {
+ return Casters<TFrom>.Caster(obj);
+ }
+
+ /// <summary>
+ /// Inner class serving as a cache.
+ /// </summary>
+ private static class Casters<TFrom>
+ {
+ /// <summary>
+ /// Compiled caster delegate.
+ /// </summary>
+ internal static readonly Func<TFrom, T> Caster = Compile();
+
+ /// <summary>
+ /// Compiles caster delegate.
+ /// </summary>
+ private static Func<TFrom, T> Compile()
+ {
+ if (typeof (T) == typeof (TFrom))
+ {
+ // Just return what we have
+ var pExpr = Expression.Parameter(typeof(TFrom));
+
+ return Expression.Lambda<Func<TFrom, T>>(pExpr, pExpr).Compile();
+ }
+
+ var paramExpr = Expression.Parameter(typeof(TFrom));
+ var convertExpr = Expression.Convert(paramExpr, typeof(T));
+
+ return Expression.Lambda<Func<TFrom, T>>(convertExpr, paramExpr).Compile();
+ }
+ }
+ }
+}
\ No newline at end of file
[20/41] ignite git commit: Abstracted out metadata processing.
Posted by sb...@apache.org.
Abstracted out metadata processing.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a43e80a9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a43e80a9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a43e80a9
Branch: refs/heads/ignite-1093
Commit: a43e80a9ad3ceb83775a20a84b972a6b0ee396ae
Parents: cdf82e9
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 12:57:08 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 12:57:08 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/processors/platform/PlatformContext.java | 7 +++++++
1 file changed, 7 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a43e80a9/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
index 0385f46..fb1eaa2 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
@@ -104,4 +104,11 @@ public interface PlatformContext {
* @param nodes Nodes.
*/
public void writeNodes(PortableRawWriterEx writer, Collection<ClusterNode> nodes);
+
+ /**
+ * Process metadata from the platform.
+ *
+ * @param reader Reader.
+ */
+ public void processMetadata(PortableRawReaderEx reader);
}
[19/41] ignite git commit: Moved platform future utils to Ignite.
Posted by sb...@apache.org.
Moved platform future utils to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cdf82e94
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cdf82e94
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cdf82e94
Branch: refs/heads/ignite-1093
Commit: cdf82e942d0a2577cd077faf5c60dcc3bec4886a
Parents: bcf3054
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 12:47:55 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 12:47:55 2015 +0300
----------------------------------------------------------------------
.../platform/PlatformExtendedException.java | 39 +++
.../platform/utils/PlatformFutureUtils.java | 326 +++++++++++++++++++
.../platform/utils/PlatformUtils.java | 54 +++
3 files changed, 419 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/cdf82e94/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformExtendedException.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformExtendedException.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformExtendedException.java
new file mode 100644
index 0000000..80b1703
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformExtendedException.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.internal.processors.platform;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ * Denotes an exception which has some data to be written in a special manner.
+ */
+public interface PlatformExtendedException {
+ /**
+ * Gets platform context.
+ *
+ * @return Platform context.
+ */
+ public PlatformContext context();
+
+ /**
+ * Write data.
+ *
+ * @param writer Writer.
+ */
+ public void writeData(PortableRawWriterEx writer);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cdf82e94/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
new file mode 100644
index 0000000..fa986fe
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
@@ -0,0 +1,326 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.utils;
+
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.platform.*;
+import org.apache.ignite.internal.processors.platform.callback.*;
+import org.apache.ignite.internal.processors.platform.memory.*;
+import org.apache.ignite.lang.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * Interop future utils.
+ */
+public class PlatformFutureUtils {
+ /** Future type: byte. */
+ public static final int TYP_BYTE = 1;
+
+ /** Future type: boolean. */
+ public static final int TYP_BOOL = 2;
+
+ /** Future type: short. */
+ public static final int TYP_SHORT = 3;
+
+ /** Future type: char. */
+ public static final int TYP_CHAR = 4;
+
+ /** Future type: int. */
+ public static final int TYP_INT = 5;
+
+ /** Future type: float. */
+ public static final int TYP_FLOAT = 6;
+
+ /** Future type: long. */
+ public static final int TYP_LONG = 7;
+
+ /** Future type: double. */
+ public static final int TYP_DOUBLE = 8;
+
+ /** Future type: object. */
+ public static final int TYP_OBJ = 9;
+
+ /**
+ * Listen future.
+ *
+ * @param ctx Interop context.
+ * @param fut Java future.
+ * @param futPtr Native future pointer.
+ * @param typ Expected return type.
+ */
+ public static void listen(final PlatformContext ctx, IgniteFuture fut, final long futPtr, final int typ) {
+ listen(ctx, new FutureListenable(fut), futPtr, typ, null);
+ }
+
+ /**
+ * Listen future.
+ *
+ * @param ctx Interop context.
+ * @param fut Java future.
+ * @param futPtr Native future pointer.
+ * @param typ Expected return type.
+ * @param writer Writer.
+ */
+ public static void listen(final PlatformContext ctx, IgniteFuture fut, final long futPtr, final int typ,
+ Writer writer) {
+ listen(ctx, new FutureListenable(fut), futPtr, typ, writer);
+ }
+
+ /**
+ * Listen future.
+ *
+ * @param ctx Interop context.
+ * @param fut Java future.
+ * @param futPtr Native future pointer.
+ * @param writer Writer.
+ */
+ public static void listen(final PlatformContext ctx, IgniteFuture fut, final long futPtr, Writer writer) {
+ listen(ctx, new FutureListenable(fut), futPtr, TYP_OBJ, writer);
+ }
+
+ /**
+ * Listen future.
+ *
+ * @param ctx Interop context.
+ * @param listenable Listenable entry.
+ * @param futPtr Native future pointer.
+ * @param typ Expected return type.
+ * @param writer Optional writer.
+ */
+ @SuppressWarnings("unchecked")
+ private static void listen(final PlatformContext ctx, Listenable listenable, final long futPtr, final int typ,
+ @Nullable final Writer writer) {
+ final PlatformCallbackGateway gate = ctx.gateway();
+
+ listenable.listen(new IgniteBiInClosure<Object, Throwable>() {
+ private static final long serialVersionUID = 0L;
+
+ @Override public void apply(Object res, Throwable err) {
+ if (writer != null && writeToWriter(res, err, ctx, writer, futPtr))
+ return;
+
+ if (err != null) {
+ writeFutureError(ctx, futPtr, err);
+
+ return;
+ }
+
+ try {
+ if (typ == TYP_OBJ) {
+ if (res == null)
+ gate.futureNullResult(futPtr);
+ else {
+ try (PlatformMemory mem = ctx.memory().allocate()) {
+ PlatformOutputStream out = mem.output();
+
+ PortableRawWriterEx outWriter = ctx.writer(out);
+
+ outWriter.writeObjectDetached(res);
+
+ out.synchronize();
+
+ gate.futureObjectResult(futPtr, mem.pointer());
+ }
+ }
+ }
+ else if (res == null)
+ gate.futureNullResult(futPtr);
+ else {
+ switch (typ) {
+ case TYP_BYTE:
+ gate.futureByteResult(futPtr, (byte) res);
+
+ break;
+
+ case TYP_BOOL:
+ gate.futureBoolResult(futPtr, (boolean) res ? 1 : 0);
+
+ break;
+
+ case TYP_SHORT:
+ gate.futureShortResult(futPtr, (short) res);
+
+ break;
+
+ case TYP_CHAR:
+ gate.futureCharResult(futPtr, (char) res);
+
+ break;
+
+ case TYP_INT:
+ gate.futureIntResult(futPtr, (int) res);
+
+ break;
+
+ case TYP_FLOAT:
+ gate.futureFloatResult(futPtr, (float) res);
+
+ break;
+
+ case TYP_LONG:
+ gate.futureLongResult(futPtr, (long) res);
+
+ break;
+
+ case TYP_DOUBLE:
+ gate.futureDoubleResult(futPtr, (double) res);
+
+ break;
+
+ default:
+ assert false : "Should not reach this: " + typ;
+ }
+ }
+ }
+ catch (Throwable t) {
+ writeFutureError(ctx, futPtr, t);
+
+ if (t instanceof Error)
+ throw t;
+ }
+ }
+ });
+ }
+
+ /**
+ * Write future error.
+ *
+ * @param ctx Interop context.
+ * @param futPtr Future pointer.
+ * @param err Error.
+ */
+ private static void writeFutureError(final PlatformContext ctx, long futPtr, Throwable err) {
+ try (PlatformMemory mem = ctx.memory().allocate()) {
+ PlatformOutputStream out = mem.output();
+
+ PortableRawWriterEx outWriter = ctx.writer(out);
+
+ outWriter.writeString(err.getClass().getName());
+ outWriter.writeString(err.getMessage());
+
+ PlatformUtils.writeErrorData(err, outWriter);
+
+ out.synchronize();
+
+ ctx.gateway().futureError(futPtr, mem.pointer());
+ }
+ }
+
+ /**
+ * Write result to a custom writer
+ *
+ * @param obj Object to write.
+ * @param err Error to write.
+ * @param ctx Interop context.
+ * @param writer Writer.
+ * @param futPtr Future pointer.
+ * @return Value indicating whether custom write was performed. When false, default write will be used.
+ */
+ private static boolean writeToWriter(Object obj, Throwable err, PlatformContext ctx, Writer writer, long futPtr) {
+ boolean canWrite = writer.canWrite(obj, err);
+
+ if (!canWrite)
+ return false;
+
+ try (PlatformMemory mem = ctx.memory().allocate()) {
+ PlatformOutputStream out = mem.output();
+
+ PortableRawWriterEx outWriter = ctx.writer(out);
+
+ writer.write(outWriter, obj, err);
+
+ out.synchronize();
+
+ ctx.gateway().futureObjectResult(futPtr, mem.pointer());
+ }
+
+ return true;
+ }
+
+ /**
+ * Writer allowing special future result handling.
+ */
+ public static interface Writer {
+ /**
+ * Write object.
+ *
+ * @param writer Writer.
+ * @param obj Object.
+ * @param err Error.
+ */
+ public void write(PortableRawWriterEx writer, Object obj, Throwable err);
+
+ /**
+ * Determines whether this writer can write given data.
+ *
+ * @param obj Object.
+ * @param err Error.
+ * @return Value indicating whether this writer can write given data.
+ */
+ public boolean canWrite(Object obj, Throwable err);
+ }
+
+ /**
+ * Listenable entry.
+ */
+ private static interface Listenable {
+ /**
+ * Listen.
+ *
+ * @param lsnr Listener.
+ */
+ public void listen(IgniteBiInClosure<Object, Throwable> lsnr);
+ }
+
+ /**
+ * Listenable around Ignite future.
+ */
+ private static class FutureListenable implements Listenable {
+ /** Future. */
+ private final IgniteFuture fut;
+
+ /**
+ * Constructor.
+ *
+ * @param fut Future.
+ */
+ public FutureListenable(IgniteFuture fut) {
+ this.fut = fut;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void listen(final IgniteBiInClosure<Object, Throwable> lsnr) {
+ fut.listen(new IgniteInClosure<IgniteFuture>() {
+ private static final long serialVersionUID = 0L;
+
+ @Override public void apply(IgniteFuture fut0) {
+ try {
+ lsnr.apply(fut0.get(), null);
+ }
+ catch (Throwable err) {
+ lsnr.apply(null, err);
+
+ if (err instanceof Error)
+ throw err;
+ }
+ }
+ });
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cdf82e94/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index a620f8e..614346a 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -523,6 +523,60 @@ public class PlatformUtils {
}
/**
+ * Writer error data.
+ *
+ * @param err Error.
+ * @param writer Writer.
+ */
+ public static void writeErrorData(Throwable err, PortableRawWriterEx writer) {
+ writeErrorData(err, writer, null);
+ }
+
+ /**
+ * Write error data.
+ * @param err Error.
+ * @param writer Writer.
+ * @param log Optional logger.
+ */
+ public static void writeErrorData(Throwable err, PortableRawWriterEx writer, @Nullable IgniteLogger log) {
+ // Write additional data if needed.
+ if (err instanceof PlatformExtendedException) {
+ PlatformExtendedException err0 = (PlatformExtendedException)err;
+
+ writer.writeBoolean(true); // Data exists.
+
+ int pos = writer.out().position();
+
+ try {
+ writer.writeBoolean(true); // Optimistically assume that we will be able to write it.
+ err0.writeData(writer);
+ }
+ catch (Exception e) {
+ if (log != null)
+ U.warn(log, "Failed to write interop exception data: " + e.getMessage(), e);
+
+ writer.out().position(pos);
+
+ writer.writeBoolean(false); // Error occurred.
+ writer.writeString(e.getClass().getName());
+
+ String innerMsg;
+
+ try {
+ innerMsg = e.getMessage();
+ }
+ catch (Exception innerErr) {
+ innerMsg = "Exception message is not available.";
+ }
+
+ writer.writeString(innerMsg);
+ }
+ }
+ else
+ writer.writeBoolean(false);
+ }
+
+ /**
* Private constructor.
*/
private PlatformUtils() {
[24/41] ignite git commit: Moved platform transactions to Ignite.
Posted by sb...@apache.org.
Moved platform transactions to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/975f47ea
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/975f47ea
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/975f47ea
Branch: refs/heads/ignite-1093
Commit: 975f47eabdaba54ddf0974c2a2b7a2d13c6ea03c
Parents: 6c46e47
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 15:07:08 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 15:07:08 2015 +0300
----------------------------------------------------------------------
.../internal/portable/PortableContext.java | 1 -
.../transactions/PlatformTransactions.java | 255 +++++++++++++++++++
2 files changed, 255 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/975f47ea/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 83dd01d..2d3cbf0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -206,7 +206,6 @@ public class PortableContext implements Externalizable {
//
// registerPredefinedType(InteropClusterNode.class, 67);
// registerPredefinedType(InteropClusterMetrics.class, 68);
-// registerPredefinedType(InteropTransactionMetrics.class, 69);
// registerPredefinedType(InteropMetadata.class, 70);
//
// registerPredefinedType(InteropDotNetConfiguration.class, 71);
http://git-wip-us.apache.org/repos/asf/ignite/blob/975f47ea/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
new file mode 100644
index 0000000..fa63840
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
@@ -0,0 +1,255 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.transactions;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.platform.*;
+import org.apache.ignite.internal.processors.platform.utils.*;
+import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.transactions.*;
+
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+/**
+ * Native transaction wrapper implementation.
+ */
+@SuppressWarnings({"unchecked", "UnusedDeclaration", "TryFinallyCanBeTryWithResources"})
+public class PlatformTransactions extends PlatformAbstractTarget {
+ /** */
+ public static final int OP_CACHE_CONFIG_PARAMETERS = 1;
+
+ /** */
+ public static final int OP_METRICS = 2;
+
+ /** */
+ private final IgniteTransactions txs;
+
+ /** Map with currently active transactions. */
+ private final ConcurrentMap<Long, Transaction> txMap = GridConcurrentFactory.newMap();
+
+ /** Transaction ID sequence. Must be static to ensure uniqueness across different caches. */
+ private static final AtomicLong TX_ID_GEN = new AtomicLong();
+
+ /**
+ * Constructor.
+ *
+ * @param interopCtx Interop context.
+ */
+ public PlatformTransactions(PlatformContext interopCtx) {
+ super(interopCtx);
+
+ txs = interopCtx.kernalContext().grid().transactions();
+ }
+
+ /**
+ * @param concurrency Concurrency.
+ * @param isolation Isolation.
+ * @param timeout Timeout
+ * @param txSize Number of entries participating in transaction.
+ * @return Transaction thread ID.
+ */
+ public long txStart(int concurrency, int isolation, long timeout, int txSize) {
+ TransactionConcurrency txConcurrency = TransactionConcurrency.fromOrdinal(concurrency);
+
+ assert txConcurrency != null;
+
+ TransactionIsolation txIsolation = TransactionIsolation.fromOrdinal(isolation);
+
+ assert txIsolation != null;
+
+ Transaction tx = txs.txStart(txConcurrency, txIsolation);
+
+ return registerTx(tx);
+ }
+
+ /**
+ * @param id Transaction ID.
+ * @throws org.apache.ignite.IgniteCheckedException In case of error.
+ */
+ public int txCommit(long id) throws IgniteCheckedException {
+ tx(id).commit();
+
+ return txClose(id);
+ }
+
+ /**
+ * @param id Transaction ID.
+ * @throws org.apache.ignite.IgniteCheckedException In case of error.
+ */
+ public int txRollback(long id) throws IgniteCheckedException {
+ tx(id).rollback();
+
+ return txClose(id);
+ }
+
+ /**
+ * @param id Transaction ID.
+ * @throws org.apache.ignite.IgniteCheckedException In case of error.
+ * @return Transaction state.
+ */
+ public int txClose(long id) throws IgniteCheckedException {
+ Transaction tx = tx(id);
+
+ try {
+ tx.close();
+
+ return tx.state().ordinal();
+ }
+ finally {
+ unregisterTx(id);
+ }
+ }
+
+ /**
+ * @param id Transaction ID.
+ * @return Transaction state.
+ */
+ public int txState(long id) {
+ Transaction tx = tx(id);
+
+ return tx.state().ordinal();
+ }
+
+ /**
+ * @param id Transaction ID.
+ * @return {@code True} if rollback only flag was set.
+ */
+ public boolean txSetRollbackOnly(long id) {
+ Transaction tx = tx(id);
+
+ return tx.setRollbackOnly();
+ }
+
+ /**
+ * Commits tx in async mode.
+ */
+ public void txCommitAsync(final long txId, final long futId) {
+ final Transaction asyncTx = (Transaction)tx(txId).withAsync();
+
+ asyncTx.commit();
+
+ listenAndNotifyIntFuture(futId, asyncTx);
+ }
+
+ /**
+ * Rolls back tx in async mode.
+ */
+ public void txRollbackAsync(final long txId, final long futId) {
+ final Transaction asyncTx = (Transaction)tx(txId).withAsync();
+
+ asyncTx.rollback();
+
+ listenAndNotifyIntFuture(futId, asyncTx);
+ }
+
+ /**
+ * Listens to the transaction future and notifies .NET int future.
+ */
+ private void listenAndNotifyIntFuture(final long futId, final Transaction asyncTx) {
+ IgniteFuture fut = asyncTx.future().chain(new C1<IgniteFuture, Object>() {
+ private static final long serialVersionUID = 0L;
+
+ @Override public Object apply(IgniteFuture fut) {
+ return null;
+ }
+ });
+
+ PlatformFutureUtils.listen(interopCtx, fut, futId, PlatformFutureUtils.TYP_OBJ);
+ }
+
+ /**
+ * Resets transaction metrics.
+ */
+ public void resetMetrics() {
+ txs.resetMetrics();
+ }
+
+ /**
+ * Register transaction.
+ *
+ * @param tx Transaction.
+ * @return Transaction ID.
+ */
+ private long registerTx(Transaction tx) {
+ long id = TX_ID_GEN.incrementAndGet();
+
+ Transaction old = txMap.put(id, tx);
+
+ assert old == null : "Duplicate TX ids: " + old;
+
+ return id;
+ }
+
+ /**
+ * Unregister transaction.
+ *
+ * @param id Transaction ID.
+ */
+ private void unregisterTx(long id) {
+ Transaction tx = txMap.remove(id);
+
+ assert tx != null : "Failed to unregister transaction: " + id;
+ }
+
+ /**
+ * Get transaction by ID.
+ *
+ * @param id ID.
+ * @return Transaction.
+ */
+ private Transaction tx(long id) {
+ Transaction tx = txMap.get(id);
+
+ assert tx != null : "Transaction not found for ID: " + id;
+
+ return tx;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void processOutOp(int type, PortableRawWriterEx writer) throws IgniteCheckedException {
+ switch (type) {
+ case OP_CACHE_CONFIG_PARAMETERS:
+ TransactionConfiguration txCfg = interopCtx.kernalContext().config().getTransactionConfiguration();
+
+ writer.writeEnum(txCfg.getDefaultTxConcurrency());
+ writer.writeEnum(txCfg.getDefaultTxIsolation());
+ writer.writeLong(txCfg.getDefaultTxTimeout());
+
+ break;
+
+ case OP_METRICS:
+ TransactionMetrics metrics = txs.metrics();
+
+ writer.writeDate(new Date(metrics.commitTime()));
+ writer.writeDate(new Date(metrics.rollbackTime()));
+ writer.writeInt(metrics.txCommits());
+ writer.writeInt(metrics.txRollbacks());
+
+ break;
+
+ default:
+ throwUnsupported(type);
+ }
+ }
+}
\ No newline at end of file
[04/41] ignite git commit: Platforms: minor refactoring.
Posted by sb...@apache.org.
Platforms: minor refactoring.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2e6d9157
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2e6d9157
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2e6d9157
Branch: refs/heads/ignite-1093
Commit: 2e6d91571e26a819b0b928095c712bf034fc0e29
Parents: 21cff74
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 09:05:56 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 09:05:56 2015 +0300
----------------------------------------------------------------------
.../internal/GridEventConsumeHandler.java | 2 +-
.../eventstorage/GridEventStorageManager.java | 2 +-
.../platform/PlatformAwareEventFilter.java | 37 --------------------
.../platform/PlatformLocalEventListener.java | 28 ---------------
.../platform/PlatformAwareEventFilter.java | 37 ++++++++++++++++++++
.../platform/PlatformLocalEventListener.java | 28 +++++++++++++++
.../resources/META-INF/classnames.properties | 2 +-
7 files changed, 68 insertions(+), 68 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2e6d9157/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
index 134184a..0ae8050 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
@@ -23,9 +23,9 @@ import org.apache.ignite.events.*;
import org.apache.ignite.internal.cluster.*;
import org.apache.ignite.internal.managers.deployment.*;
import org.apache.ignite.internal.managers.eventstorage.*;
-import org.apache.ignite.internal.platform.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.processors.continuous.*;
+import org.apache.ignite.internal.processors.platform.*;
import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.lang.*;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2e6d9157/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
index d8e6ae1..ae7049c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
@@ -25,7 +25,7 @@ import org.apache.ignite.internal.events.*;
import org.apache.ignite.internal.managers.*;
import org.apache.ignite.internal.managers.communication.*;
import org.apache.ignite.internal.managers.deployment.*;
-import org.apache.ignite.internal.platform.*;
+import org.apache.ignite.internal.processors.platform.*;
import org.apache.ignite.internal.util.*;
import org.apache.ignite.internal.util.future.*;
import org.apache.ignite.internal.util.typedef.*;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2e6d9157/modules/core/src/main/java/org/apache/ignite/internal/platform/PlatformAwareEventFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/platform/PlatformAwareEventFilter.java b/modules/core/src/main/java/org/apache/ignite/internal/platform/PlatformAwareEventFilter.java
deleted file mode 100644
index 2ae664d..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/platform/PlatformAwareEventFilter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform;
-
-import org.apache.ignite.events.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.lang.*;
-
-/**
- * Special version of predicate for events with initialize/close callbacks.
- */
-public interface PlatformAwareEventFilter<E extends Event> extends IgnitePredicate<E> {
- /**
- * Initializes the filter.
- */
- public void initialize(GridKernalContext ctx);
-
- /**
- * Closes the filter.
- */
- public void close();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2e6d9157/modules/core/src/main/java/org/apache/ignite/internal/platform/PlatformLocalEventListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/platform/PlatformLocalEventListener.java b/modules/core/src/main/java/org/apache/ignite/internal/platform/PlatformLocalEventListener.java
deleted file mode 100644
index 31c585c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/platform/PlatformLocalEventListener.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.platform;
-
-/**
- * Special version of listener for events with close callbacks.
- */
-public interface PlatformLocalEventListener {
- /**
- * Closes the listener.
- */
- public void close();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2e6d9157/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAwareEventFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAwareEventFilter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAwareEventFilter.java
new file mode 100644
index 0000000..f056bbf
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAwareEventFilter.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform;
+
+import org.apache.ignite.events.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.lang.*;
+
+/**
+ * Special version of predicate for events with initialize/close callbacks.
+ */
+public interface PlatformAwareEventFilter<E extends Event> extends IgnitePredicate<E> {
+ /**
+ * Initializes the filter.
+ */
+ public void initialize(GridKernalContext ctx);
+
+ /**
+ * Closes the filter.
+ */
+ public void close();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2e6d9157/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformLocalEventListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformLocalEventListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformLocalEventListener.java
new file mode 100644
index 0000000..41f41eb
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformLocalEventListener.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform;
+
+/**
+ * Special version of listener for events with close callbacks.
+ */
+public interface PlatformLocalEventListener {
+ /**
+ * Closes the listener.
+ */
+ public void close();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2e6d9157/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index fb1673a..d80cc49 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -278,7 +278,7 @@ org.apache.ignite.internal.managers.eventstorage.GridEventStorageMessage
org.apache.ignite.internal.managers.indexing.GridIndexingManager$1
org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerAdapter
org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager$1
-org.apache.ignite.internal.platform.PlatformAwareEventFilter
+org.apache.ignite.internal.processors.platform.PlatformAwareEventFilter
org.apache.ignite.internal.portable.PortableClassDescriptor$Mode
org.apache.ignite.internal.portable.PortableContext
org.apache.ignite.internal.portable.PortableLazyMap$1$1$1
[23/41] ignite git commit: Moved platform lifecycle bean to Ignite.
Posted by sb...@apache.org.
Moved platform lifecycle bean to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6c46e47b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6c46e47b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6c46e47b
Branch: refs/heads/ignite-1093
Commit: 6c46e47b3c04cdf03946168cfff28b759dd44348
Parents: 0e81fd0
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 13:43:18 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 13:43:18 2015 +0300
----------------------------------------------------------------------
.../lifecycle/PlatformLifecycleBean.java | 72 ++++++++++++++++++++
1 file changed, 72 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6c46e47b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/lifecycle/PlatformLifecycleBean.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/lifecycle/PlatformLifecycleBean.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/lifecycle/PlatformLifecycleBean.java
new file mode 100644
index 0000000..c6a83e6
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/lifecycle/PlatformLifecycleBean.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.lifecycle;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.processors.platform.callback.*;
+import org.apache.ignite.lifecycle.*;
+
+/**
+ * Lifecycle aware bean for interop.
+ */
+public class PlatformLifecycleBean implements LifecycleBean {
+ /** Native gateway. */
+ public PlatformCallbackGateway gate;
+
+ /** Holder pointer. */
+ public long ptr;
+
+ /**
+ * Constructor.
+ */
+ protected PlatformLifecycleBean() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param gate Native gateway.
+ * @param ptr Holder pointer.
+ */
+ public PlatformLifecycleBean(PlatformCallbackGateway gate, long ptr) {
+ initialize(gate, ptr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onLifecycleEvent(LifecycleEventType evt) {
+ if (gate == null)
+ throw new IgniteException("Interop lifecycle bean can only be used in interop mode (did " +
+ "you start the node with native platform bootstrapper?");
+
+ assert ptr != 0;
+
+ gate.lifecycleEvent(ptr, evt.ordinal());
+ }
+
+ /**
+ * Set pointers.
+ *
+ * @param gate Native gateway.
+ * @param ptr Target pointer.
+ */
+ public void initialize(PlatformCallbackGateway gate, long ptr) {
+ this.gate = gate;
+ this.ptr = ptr;
+ }
+}
[03/41] ignite git commit: IGNITE-1269. ignite-hadoop assembly needs
to include ignite-indexing
Posted by sb...@apache.org.
IGNITE-1269. ignite-hadoop assembly needs to include ignite-indexing
Signed-off-by: Konstantin Boudnik <co...@wandisco.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/21cff74e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/21cff74e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/21cff74e
Branch: refs/heads/ignite-1093
Commit: 21cff74e081308fb2ed94b115419ed46c2bc6a77
Parents: 89e94b6
Author: iveselovskiy <iv...@gridgain.com>
Authored: Thu Aug 20 18:48:31 2015 +0300
Committer: Konstantin Boudnik <co...@wandisco.com>
Committed: Tue Aug 25 20:06:11 2015 -0700
----------------------------------------------------------------------
assembly/dependencies-hadoop.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/21cff74e/assembly/dependencies-hadoop.xml
----------------------------------------------------------------------
diff --git a/assembly/dependencies-hadoop.xml b/assembly/dependencies-hadoop.xml
index 4638643..0e282a4 100644
--- a/assembly/dependencies-hadoop.xml
+++ b/assembly/dependencies-hadoop.xml
@@ -34,6 +34,7 @@
<includes>
<include>org.apache.ignite:ignite-spring</include>
<include>org.apache.ignite:ignite-log4j</include>
+ <include>org.apache.ignite:ignite-indexing</include>
</includes>
<sources>
<includeModuleDirectory>true</includeModuleDirectory>
[07/41] ignite git commit: Moving platform classes to
"...internal.processors..." package to follow Ignite common approach.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
new file mode 100644
index 0000000..7e9587f
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
@@ -0,0 +1,468 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.callback;
+
+/**
+ * Platform callback utility methods. Implemented in target platform. All methods in this class must be
+ * package-visible and invoked only through {@link PlatformCallbackGateway}.
+ */
+public class PlatformCallbackUtils {
+ /**
+ * Create cache store.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ static native long cacheStoreCreate(long envPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Object pointer.
+ * @param memPtr Memory pointer.
+ * @param cb Callback.
+ * @return Result.
+ */
+ static native int cacheStoreInvoke(long envPtr, long objPtr, long memPtr, Object cb);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Object pointer.
+ */
+ static native void cacheStoreDestroy(long envPtr, long objPtr);
+
+ /**
+ * Creates cache store session.
+ *
+ * @param envPtr Environment pointer.
+ * @param storePtr Store instance pointer.
+ * @return Session instance pointer.
+ */
+ static native long cacheStoreSessionCreate(long envPtr, long storePtr);
+
+ /**
+ * Creates cache entry filter and returns a pointer.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ static native long cacheEntryFilterCreate(long envPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ static native int cacheEntryFilterApply(long envPtr, long objPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Pointer.
+ */
+ static native void cacheEntryFilterDestroy(long envPtr, long objPtr);
+
+ /**
+ * Invoke cache entry processor.
+ *
+ * @param envPtr Environment pointer.
+ * @param outMemPtr Output memory pointer.
+ * @param inMemPtr Input memory pointer.
+ */
+ static native void cacheInvoke(long envPtr, long outMemPtr, long inMemPtr);
+
+ /**
+ * Perform native task map. Do not throw exceptions, serializing them to the output stream instead.
+ *
+ * @param envPtr Environment pointer.
+ * @param taskPtr Task pointer.
+ * @param outMemPtr Output memory pointer (exists if topology changed, otherwise {@code 0}).
+ * @param inMemPtr Input memory pointer.
+ */
+ static native void computeTaskMap(long envPtr, long taskPtr, long outMemPtr, long inMemPtr);
+
+ /**
+ * Perform native task job result notification.
+ *
+ * @param envPtr Environment pointer.
+ * @param taskPtr Task pointer.
+ * @param jobPtr Job pointer.
+ * @param memPtr Memory pointer (always zero for local job execution).
+ * @return Job result enum ordinal.
+ */
+ static native int computeTaskJobResult(long envPtr, long taskPtr, long jobPtr, long memPtr);
+
+ /**
+ * Perform native task reduce.
+ *
+ * @param envPtr Environment pointer.
+ * @param taskPtr Task pointer.
+ */
+ static native void computeTaskReduce(long envPtr, long taskPtr);
+
+ /**
+ * Complete task with native error.
+ *
+ * @param envPtr Environment pointer.
+ * @param taskPtr Task pointer.
+ * @param memPtr Memory pointer with exception data or {@code 0} in case of success.
+ */
+ static native void computeTaskComplete(long envPtr, long taskPtr, long memPtr);
+
+ /**
+ * Serialize native job.
+ *
+ * @param envPtr Environment pointer.
+ * @param jobPtr Job pointer.
+ * @param memPtr Memory pointer.
+ * @return {@code True} if serialization succeeded.
+ */
+ static native int computeJobSerialize(long envPtr, long jobPtr, long memPtr);
+
+ /**
+ * Create job in native platform.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ * @return Pointer to job.
+ */
+ static native long computeJobCreate(long envPtr, long memPtr);
+
+ /**
+ * Execute native job on a node other than where it was created.
+ *
+ * @param envPtr Environment pointer.
+ * @param jobPtr Job pointer.
+ * @param cancel Cancel flag.
+ * @param memPtr Memory pointer to write result to for remote job execution or {@code 0} for local job execution.
+ */
+ static native void computeJobExecute(long envPtr, long jobPtr, int cancel, long memPtr);
+
+ /**
+ * Cancel the job.
+ *
+ * @param envPtr Environment pointer.
+ * @param jobPtr Job pointer.
+ */
+ static native void computeJobCancel(long envPtr, long jobPtr);
+
+ /**
+ * Destroy the job.
+ *
+ * @param envPtr Environment pointer.
+ * @param ptr Pointer.
+ */
+ static native void computeJobDestroy(long envPtr, long ptr);
+
+ /**
+ * Invoke local callback.
+ *
+ * @param envPtr Environment pointer.
+ * @param cbPtr Callback pointer.
+ * @param memPtr Memory pointer.
+ */
+ static native void continuousQueryListenerApply(long envPtr, long cbPtr, long memPtr);
+
+ /**
+ * Create filter in native platform.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ * @return Pointer to created filter.
+ */
+ static native long continuousQueryFilterCreate(long envPtr, long memPtr);
+
+ /**
+ * Invoke remote filter.
+ *
+ * @param envPtr Environment pointer.
+ * @param filterPtr Filter pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ static native int continuousQueryFilterApply(long envPtr, long filterPtr, long memPtr);
+
+ /**
+ * Release remote filter.
+ *
+ * @param envPtr Environment pointer.
+ * @param filterPtr Filter pointer.
+ */
+ static native void continuousQueryFilterRelease(long envPtr, long filterPtr);
+
+ /**
+ * Notify native data streamer about topology update.
+ *
+ * @param envPtr Environment pointer.
+ * @param ptr Data streamer native pointer.
+ * @param topVer Topology version.
+ * @param topSize Topology size.
+ */
+ static native void dataStreamerTopologyUpdate(long envPtr, long ptr, long topVer, int topSize);
+
+ /**
+ * Invoke stream receiver.
+ *
+ * @param envPtr Environment pointer.
+ * @param ptr Receiver native pointer.
+ * @param cache Cache object.
+ * @param memPtr Stream pointer.
+ * @param keepPortable Portable flag.
+ */
+ static native void dataStreamerStreamReceiverInvoke(long envPtr, long ptr, Object cache, long memPtr,
+ boolean keepPortable);
+
+ /**
+ * Notify future with byte result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureByteResult(long envPtr, long futPtr, int res);
+
+ /**
+ * Notify future with boolean result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureBoolResult(long envPtr, long futPtr, int res);
+
+ /**
+ * Notify future with short result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureShortResult(long envPtr, long futPtr, int res);
+
+ /**
+ * Notify future with byte result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureCharResult(long envPtr, long futPtr, int res);
+
+ /**
+ * Notify future with int result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureIntResult(long envPtr, long futPtr, int res);
+
+ /**
+ * Notify future with float result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureFloatResult(long envPtr, long futPtr, float res);
+
+ /**
+ * Notify future with long result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureLongResult(long envPtr, long futPtr, long res);
+
+ /**
+ * Notify future with double result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param res Result.
+ */
+ static native void futureDoubleResult(long envPtr, long futPtr, double res);
+
+ /**
+ * Notify future with object result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param memPtr Memory pointer.
+ */
+ static native void futureObjectResult(long envPtr, long futPtr, long memPtr);
+
+ /**
+ * Notify future with null result.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ */
+ static native void futureNullResult(long envPtr, long futPtr);
+
+ /**
+ * Notify future with error.
+ *
+ * @param envPtr Environment pointer.
+ * @param futPtr Future pointer.
+ * @param memPtr Pointer to memory with error information.
+ */
+ static native void futureError(long envPtr, long futPtr, long memPtr);
+
+ /**
+ * Creates message filter and returns a pointer.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ static native long messagingFilterCreate(long envPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ static native int messagingFilterApply(long envPtr, long objPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Pointer.
+ */
+ static native void messagingFilterDestroy(long envPtr, long objPtr);
+
+ /**
+ * Creates event filter and returns a pointer.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ * @return Pointer.
+ */
+ static native long eventFilterCreate(long envPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Pointer.
+ * @param memPtr Memory pointer.
+ * @return Result.
+ */
+ static native int eventFilterApply(long envPtr, long objPtr, long memPtr);
+
+ /**
+ * @param envPtr Environment pointer.
+ * @param objPtr Pointer.
+ */
+ static native void eventFilterDestroy(long envPtr, long objPtr);
+
+ /**
+ * Sends node info to native target.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Ptr to a stream with serialized node.
+ */
+ static native void nodeInfo(long envPtr, long memPtr);
+
+ /**
+ * Kernal start callback.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Memory pointer.
+ */
+ static native void onStart(long envPtr, long memPtr);
+
+ /*
+ * Kernal stop callback.
+ *
+ * @param envPtr Environment pointer.
+ */
+ static native void onStop(long envPtr);
+
+ /**
+ * Lifecycle event callback.
+ *
+ * @param envPtr Environment pointer.
+ * @param ptr Holder pointer.
+ * @param evt Event.
+ */
+ static native void lifecycleEvent(long envPtr, long ptr, int evt);
+
+ /**
+ * Re-allocate external memory chunk.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Cross-platform pointer.
+ * @param cap Capacity.
+ */
+ static native void memoryReallocate(long envPtr, long memPtr, int cap);
+
+ /**
+ * Initializes native service.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Stream pointer.
+ * @return Pointer to the native platform service.
+ */
+ static native long serviceInit(long envPtr, long memPtr);
+
+ /**
+ * Executes native service.
+ *
+ * @param envPtr Environment pointer.
+ * @param svcPtr Pointer to the service in the native platform.
+ * @param memPtr Stream pointer.
+ */
+ static native void serviceExecute(long envPtr, long svcPtr, long memPtr);
+
+ /**
+ * Cancels native service.
+ *
+ * @param envPtr Environment pointer.
+ * @param svcPtr Pointer to the service in the native platform.
+ * @param memPtr Stream pointer.
+ */
+ static native void serviceCancel(long envPtr, long svcPtr, long memPtr);
+
+ /**
+ /**
+ * Invokes service method.
+ *
+ * @param envPtr Environment pointer.
+ * @param svcPtr Pointer to the service in the native platform.
+ * @param outMemPtr Output memory pointer.
+ * @param inMemPtr Input memory pointer.
+ */
+ static native void serviceInvokeMethod(long envPtr, long svcPtr, long outMemPtr, long inMemPtr);
+
+ /**
+ * Invokes cluster node filter.
+ *
+ * @param envPtr Environment pointer.
+ * @param memPtr Stream pointer.
+ */
+ static native int clusterNodeFilterApply(long envPtr, long memPtr);
+
+ /**
+ * Private constructor.
+ */
+ private PlatformCallbackUtils() {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java
new file mode 100644
index 0000000..fbbabb7
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+/**
+ * Interop memory chunk abstraction.
+ */
+public abstract class PlatformAbstractMemory implements PlatformMemory {
+ /** Stream factory. */
+ private static final StreamFactory STREAM_FACTORY = PlatformMemoryUtils.LITTLE_ENDIAN ?
+ new LittleEndianStreamFactory() : new BigEndianStreamFactory();
+
+ /** Cross-platform memory pointer. */
+ protected long memPtr;
+
+ /**
+ * Constructor.
+ *
+ * @param memPtr Cross-platform memory pointer.
+ */
+ protected PlatformAbstractMemory(long memPtr) {
+ this.memPtr = memPtr;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformInputStream input() {
+ return STREAM_FACTORY.createInput(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformOutputStream output() {
+ return STREAM_FACTORY.createOutput(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public long pointer() {
+ return memPtr;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long data() {
+ return PlatformMemoryUtils.data(memPtr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int capacity() {
+ return PlatformMemoryUtils.capacity(memPtr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int length() {
+ return PlatformMemoryUtils.length(memPtr);
+ }
+
+ /**
+ * Stream factory.
+ */
+ private static interface StreamFactory {
+ /**
+ * Create input stream.
+ *
+ * @param mem Memory.
+ * @return Input stream.
+ */
+ PlatformInputStreamImpl createInput(PlatformMemory mem);
+
+ /**
+ * Create output stream.
+ *
+ * @param mem Memory.
+ * @return Output stream.
+ */
+ PlatformOutputStreamImpl createOutput(PlatformMemory mem);
+ }
+
+ /**
+ * Stream factory for LITTLE ENDIAN architecture.
+ */
+ private static class LittleEndianStreamFactory implements StreamFactory {
+ /** {@inheritDoc} */
+ @Override public PlatformInputStreamImpl createInput(PlatformMemory mem) {
+ return new PlatformInputStreamImpl(mem);
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformOutputStreamImpl createOutput(PlatformMemory mem) {
+ return new PlatformOutputStreamImpl(mem);
+ }
+ }
+
+ /**
+ * Stream factory for BIG ENDIAN architecture.
+ */
+ private static class BigEndianStreamFactory implements StreamFactory {
+ /** {@inheritDoc} */
+ @Override public PlatformInputStreamImpl createInput(PlatformMemory mem) {
+ return new PlatformBigEndianInputStreamImpl(mem);
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformOutputStreamImpl createOutput(PlatformMemory mem) {
+ return new PlatformBigEndianOutputStreamImpl(mem);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianInputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianInputStreamImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianInputStreamImpl.java
new file mode 100644
index 0000000..b029ee0
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianInputStreamImpl.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.platform.memory;
+
+/**
+ * Interop input stream implementation working with BIG ENDIAN architecture.
+ */
+public class PlatformBigEndianInputStreamImpl extends PlatformInputStreamImpl {
+ /**
+ * Constructor.
+ *
+ * @param mem Memory chunk.
+ */
+ public PlatformBigEndianInputStreamImpl(PlatformMemory mem) {
+ super(mem);
+ }
+
+ /** {@inheritDoc} */
+ @Override public short readShort() {
+ return Short.reverseBytes(super.readShort());
+ }
+
+ /** {@inheritDoc} */
+ @Override public short[] readShortArray(int cnt) {
+ short[] res = super.readShortArray(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ res[i] = Short.reverseBytes(res[i]);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public char readChar() {
+ return Character.reverseBytes(super.readChar());
+ }
+
+ /** {@inheritDoc} */
+ @Override public char[] readCharArray(int cnt) {
+ char[] res = super.readCharArray(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ res[i] = Character.reverseBytes(res[i]);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int readInt() {
+ return Integer.reverseBytes(super.readInt());
+ }
+
+ /** {@inheritDoc} */
+ @Override public int readInt(int pos) {
+ return Integer.reverseBytes(super.readInt(pos));
+ }
+
+ /** {@inheritDoc} */
+ @Override public int[] readIntArray(int cnt) {
+ int[] res = super.readIntArray(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ res[i] = Integer.reverseBytes(res[i]);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public float readFloat() {
+ return Float.intBitsToFloat(Integer.reverseBytes(Float.floatToIntBits(super.readFloat())));
+ }
+
+ /** {@inheritDoc} */
+ @Override public float[] readFloatArray(int cnt) {
+ float[] res = super.readFloatArray(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ res[i] = Float.intBitsToFloat(Integer.reverseBytes(Float.floatToIntBits(res[i])));
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long readLong() {
+ return Long.reverseBytes(super.readLong());
+ }
+
+ /** {@inheritDoc} */
+ @Override public long[] readLongArray(int cnt) {
+ long[] res = super.readLongArray(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ res[i] = Long.reverseBytes(res[i]);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public double readDouble() {
+ return Double.longBitsToDouble(Long.reverseBytes(Double.doubleToLongBits(super.readDouble())));
+ }
+
+ /** {@inheritDoc} */
+ @Override public double[] readDoubleArray(int cnt) {
+ double[] res = super.readDoubleArray(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ res[i] = Double.longBitsToDouble(Long.reverseBytes(Double.doubleToLongBits(res[i])));
+
+ return res;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
new file mode 100644
index 0000000..e1c1585
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.*;
+
+/**
+ * Interop output stream implementation working with BIG ENDIAN architecture.
+ */
+public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl {
+ /**
+ * Constructor.
+ *
+ * @param mem Underlying memory chunk.
+ */
+ public PlatformBigEndianOutputStreamImpl(PlatformMemory mem) {
+ super(mem);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeShort(short val) {
+ super.writeShort(Short.reverseBytes(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeShortArray(short[] val) {
+ int cnt = val.length << 1;
+
+ ensureCapacity(pos + cnt);
+
+ long startPos = data + pos;
+
+ for (short item : val) {
+ UNSAFE.putShort(startPos, Short.reverseBytes(item));
+
+ startPos += 2;
+ }
+
+ shift(cnt);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeChar(char val) {
+ super.writeChar(Character.reverseBytes(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeCharArray(char[] val) {
+ int cnt = val.length << 1;
+
+ ensureCapacity(pos + cnt);
+
+ long startPos = data + pos;
+
+ for (char item : val) {
+ UNSAFE.putChar(startPos, Character.reverseBytes(item));
+
+ startPos += 2;
+ }
+
+ shift(cnt);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeInt(int val) {
+ super.writeInt(Integer.reverseBytes(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeIntArray(int[] val) {
+ int cnt = val.length << 2;
+
+ ensureCapacity(pos + cnt);
+
+ long startPos = data + pos;
+
+ for (int item : val) {
+ UNSAFE.putInt(startPos, Integer.reverseBytes(item));
+
+ startPos += 4;
+ }
+
+ shift(cnt);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeInt(int pos, int val) {
+ super.writeInt(pos, Integer.reverseBytes(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeFloatArray(float[] val) {
+ int cnt = val.length << 2;
+
+ ensureCapacity(pos + cnt);
+
+ long startPos = data + pos;
+
+ for (float item : val) {
+ UNSAFE.putInt(startPos, Integer.reverseBytes(Float.floatToIntBits(item)));
+
+ startPos += 4;
+ }
+
+ shift(cnt);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeLong(long val) {
+ super.writeLong(Long.reverseBytes(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeLongArray(long[] val) {
+ int cnt = val.length << 3;
+
+ ensureCapacity(pos + cnt);
+
+ long startPos = data + pos;
+
+ for (long item : val) {
+ UNSAFE.putLong(startPos, Long.reverseBytes(item));
+
+ startPos += 8;
+ }
+
+ shift(cnt);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDoubleArray(double[] val) {
+ int cnt = val.length << 3;
+
+ ensureCapacity(pos + cnt);
+
+ long startPos = data + pos;
+
+ for (double item : val) {
+ UNSAFE.putLong(startPos, Long.reverseBytes(Double.doubleToLongBits(item)));
+
+ startPos += 8;
+ }
+
+ shift(cnt);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformExternalMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformExternalMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformExternalMemory.java
new file mode 100644
index 0000000..0d47aff
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformExternalMemory.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.processors.platform.callback.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * Interop external memory chunk.
+ */
+public class PlatformExternalMemory extends PlatformAbstractMemory {
+ /** Native gateway. */
+ private final PlatformCallbackGateway gate;
+
+ /**
+ * Constructor.
+ *
+ * @param gate Native gateway.
+ * @param memPtr Memory pointer.
+ */
+ public PlatformExternalMemory(@Nullable PlatformCallbackGateway gate, long memPtr) {
+ super(memPtr);
+
+ this.gate = gate;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void reallocate(int cap) {
+ if (gate == null)
+ throw new IgniteException("Failed to re-allocate external memory chunk because it is read-only.");
+
+ gate.memoryReallocate(memPtr, cap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() {
+ // Do nothing, memory must be released by native platform.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
new file mode 100644
index 0000000..9273e29
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+import org.apache.ignite.internal.portable.streams.*;
+
+/**
+ * Interop output stream,
+ */
+public interface PlatformInputStream extends PortableInputStream {
+ /**
+ * Synchronize input. Must be called before start reading data from a memory changed by another platform.
+ */
+ public void synchronize();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java
new file mode 100644
index 0000000..68beaee
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java
@@ -0,0 +1,323 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+import org.apache.ignite.*;
+
+import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.*;
+
+/**
+ * Interop input stream implementation.
+ */
+public class PlatformInputStreamImpl implements PlatformInputStream {
+ /** Underlying memory. */
+ private final PlatformMemory mem;
+
+ /** Real data pointer */
+ private long data;
+
+ /** Amount of available data. */
+ private int len;
+
+ /** Current position. */
+ private int pos;
+
+ /** Heap-copied data. */
+ private byte[] dataCopy;
+
+ /**
+ * Constructor.
+ *
+ * @param mem Underlying memory chunk.
+ */
+ public PlatformInputStreamImpl(PlatformMemory mem) {
+ this.mem = mem;
+
+ data = mem.data();
+ len = mem.length();
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte readByte() {
+ ensureEnoughData(1);
+
+ return UNSAFE.getByte(data + pos++);
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte[] readByteArray(int cnt) {
+ byte[] res = new byte[cnt];
+
+ copyAndShift(res, BYTE_ARR_OFF, cnt);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean readBoolean() {
+ return readByte() == 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean[] readBooleanArray(int cnt) {
+ boolean[] res = new boolean[cnt];
+
+ copyAndShift(res, BOOLEAN_ARR_OFF, cnt);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public short readShort() {
+ ensureEnoughData(2);
+
+ short res = UNSAFE.getShort(data + pos);
+
+ shift(2);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public short[] readShortArray(int cnt) {
+ int len = cnt << 1;
+
+ short[] res = new short[cnt];
+
+ copyAndShift(res, SHORT_ARR_OFF, len);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public char readChar() {
+ ensureEnoughData(2);
+
+ char res = UNSAFE.getChar(data + pos);
+
+ shift(2);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public char[] readCharArray(int cnt) {
+ int len = cnt << 1;
+
+ char[] res = new char[cnt];
+
+ copyAndShift(res, CHAR_ARR_OFF, len);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int readInt() {
+ ensureEnoughData(4);
+
+ int res = UNSAFE.getInt(data + pos);
+
+ shift(4);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int readInt(int pos) {
+ int delta = pos + 4 - this.pos;
+
+ if (delta > 0)
+ ensureEnoughData(delta);
+
+ return UNSAFE.getInt(data + pos);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int[] readIntArray(int cnt) {
+ int len = cnt << 2;
+
+ int[] res = new int[cnt];
+
+ copyAndShift(res, INT_ARR_OFF, len);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public float readFloat() {
+ ensureEnoughData(4);
+
+ float res = UNSAFE.getFloat(data + pos);
+
+ shift(4);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public float[] readFloatArray(int cnt) {
+ int len = cnt << 2;
+
+ float[] res = new float[cnt];
+
+ copyAndShift(res, FLOAT_ARR_OFF, len);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long readLong() {
+ ensureEnoughData(8);
+
+ long res = UNSAFE.getLong(data + pos);
+
+ shift(8);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long[] readLongArray(int cnt) {
+ int len = cnt << 3;
+
+ long[] res = new long[cnt];
+
+ copyAndShift(res, LONG_ARR_OFF, len);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public double readDouble() {
+ ensureEnoughData(8);
+
+ double res = UNSAFE.getDouble(data + pos);
+
+ shift(8);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public double[] readDoubleArray(int cnt) {
+ int len = cnt << 3;
+
+ double[] res = new double[cnt];
+
+ copyAndShift(res, DOUBLE_ARR_OFF, len);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int read(byte[] arr, int off, int len) {
+ if (len > remaining())
+ len = remaining();
+
+ copyAndShift(arr, BYTE_ARR_OFF + off, len);
+
+ return len;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int remaining() {
+ return len - pos;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int position() {
+ return pos;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void position(int pos) {
+ if (pos > len)
+ throw new IgniteException("Position is out of bounds: " + pos);
+ else
+ this.pos = pos;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte[] array() {
+ return arrayCopy();
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte[] arrayCopy() {
+ if (dataCopy == null) {
+ dataCopy = new byte[len];
+
+ UNSAFE.copyMemory(null, data, dataCopy, BYTE_ARR_OFF, dataCopy.length);
+ }
+
+ return dataCopy;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long offheapPointer() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean hasArray() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void synchronize() {
+ data = mem.data();
+ len = mem.length();
+ }
+
+ /**
+ * Ensure there is enough data in the stream.
+ *
+ * @param cnt Amount of byte expected to be available.
+ */
+ private void ensureEnoughData(int cnt) {
+ if (remaining() < cnt)
+ throw new IgniteException("Not enough data to read the value [position=" + pos +
+ ", requiredBytes=" + cnt + ", remainingBytes=" + remaining() + ']');
+ }
+
+ /**
+ * Copy required amount of data and shift position.
+ *
+ * @param target Target to copy data to.
+ * @param off Offset.
+ * @param cnt Count.
+ */
+ private void copyAndShift(Object target, long off, int cnt) {
+ ensureEnoughData(cnt);
+
+ UNSAFE.copyMemory(null, data + pos, target, off, cnt);
+
+ shift(cnt);
+ }
+
+ /**
+ * Shift position to the right.
+ *
+ * @param cnt Amount of bytes.
+ */
+ private void shift(int cnt) {
+ pos += cnt;
+
+ assert pos <= len;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemory.java
new file mode 100644
index 0000000..9d8f94e
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemory.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+/**
+ * Interop memory chunk.
+ */
+public interface PlatformMemory extends AutoCloseable {
+ /**
+ * Gets input stream.
+ *
+ * @return Input stream.
+ */
+ public PlatformInputStream input();
+
+ /**
+ * Gets output stream.
+ *
+ * @return Output stream.
+ */
+ public PlatformOutputStream output();
+
+ /**
+ * Gets pointer which can be passed between platforms.
+ *
+ * @return Pointer.
+ */
+ public long pointer();
+
+ /**
+ * Gets data pointer.
+ *
+ * @return Data pointer.
+ */
+ public long data();
+
+ /**
+ * Gets capacity.
+ *
+ * @return Capacity.
+ */
+ public int capacity();
+
+ /**
+ * Gets length.
+ *
+ * @return Length.
+ */
+ public int length();
+
+ /**
+ * Reallocate memory chunk.
+ *
+ * @param cap Minimum capacity.
+ */
+ public void reallocate(int cap);
+
+ /**
+ * Close memory releasing it.
+ */
+ @Override void close();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManager.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManager.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManager.java
new file mode 100644
index 0000000..c2233a8
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManager.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+/**
+ * Interop memory manager interface.
+ */
+public interface PlatformMemoryManager {
+ /**
+ * Allocates memory.
+ *
+ * @return Memory.
+ */
+ public PlatformMemory allocate();
+
+ /**
+ * Allocates memory having at least the given capacity.
+ *
+ * @param cap Minimum capacity.
+ * @return Memory.
+ */
+ public PlatformMemory allocate(int cap);
+
+ /**
+ * Gets memory from existing pointer.
+ *
+ * @param memPtr Cross-platform memory pointer.
+ * @return Memory.
+ */
+ public PlatformMemory get(long memPtr);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManagerImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManagerImpl.java
new file mode 100644
index 0000000..83388e0
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryManagerImpl.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+import org.apache.ignite.internal.processors.platform.callback.*;
+import org.jetbrains.annotations.*;
+
+import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.*;
+
+/**
+ * Interop memory manager implementation.
+ */
+public class PlatformMemoryManagerImpl implements PlatformMemoryManager {
+ /** Native gateway. */
+ private final PlatformCallbackGateway gate;
+
+ /** Default allocation capacity. */
+ private final int dfltCap;
+
+ /** Thread-local pool. */
+ private final ThreadLocal<PlatformMemoryPool> threadLocPool = new ThreadLocal<>();
+
+ /**
+ * Constructor.
+ *
+ * @param gate Native gateway.
+ * @param dfltCap Default memory chunk capacity.
+ */
+ public PlatformMemoryManagerImpl(@Nullable PlatformCallbackGateway gate, int dfltCap) {
+ this.gate = gate;
+ this.dfltCap = dfltCap;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformMemory allocate() {
+ return allocate(dfltCap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformMemory allocate(int cap) {
+ return pool().allocate(cap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformMemory get(long memPtr) {
+ int flags = flags(memPtr);
+
+ return isExternal(flags) ? new PlatformExternalMemory(gate, memPtr) :
+ isPooled(flags) ? pool().get(memPtr) : new PlatformUnpooledMemory(memPtr);
+ }
+
+ /**
+ * Gets or creates thread-local memory pool.
+ *
+ * @return Memory pool.
+ */
+ private PlatformMemoryPool pool() {
+ PlatformMemoryPool pool = threadLocPool.get();
+
+ if (pool == null) {
+ pool = new PlatformMemoryPool();
+
+ threadLocPool.set(pool);
+ }
+
+ return pool;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryPool.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryPool.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryPool.java
new file mode 100644
index 0000000..75db4b9
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryPool.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.*;
+
+/**
+ * Memory pool associated with a thread.
+ */
+public class PlatformMemoryPool {
+ /** base pointer. */
+ private final long poolPtr;
+
+ /** First pooled memory chunk. */
+ private PlatformPooledMemory mem1;
+
+ /** Second pooled memory chunk. */
+ private PlatformPooledMemory mem2;
+
+ /** Third pooled memory chunk. */
+ private PlatformPooledMemory mem3;
+
+ /**
+ * Constructor.
+ */
+ public PlatformMemoryPool() {
+ poolPtr = allocatePool();
+
+ sun.misc.Cleaner.create(this, new CleanerRunnable(poolPtr));
+ }
+
+ /**
+ * Allocate memory chunk, optionally pooling it.
+ *
+ * @param cap Minimum capacity.
+ * @return Memory chunk.
+ */
+ public PlatformMemory allocate(int cap) {
+ long memPtr = allocatePooled(poolPtr, cap);
+
+ // memPtr == 0 means that we failed to acquire thread-local memory chunk, so fallback to unpooled memory.
+ return memPtr != 0 ? get(memPtr) : new PlatformUnpooledMemory(allocateUnpooled(cap));
+ }
+
+ /**
+ * Re-allocate existing pool memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @param cap Minimum capacity.
+ */
+ void reallocate(long memPtr, int cap) {
+ reallocatePooled(memPtr, cap);
+ }
+
+ /**
+ * Release pooled memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ */
+ void release(long memPtr) {
+ releasePooled(memPtr);
+ }
+
+ /**
+ * Get pooled memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @return Memory chunk.
+ */
+ public PlatformMemory get(long memPtr) {
+ long delta = memPtr - poolPtr;
+
+ if (delta == POOL_HDR_OFF_MEM_1) {
+ if (mem1 == null)
+ mem1 = new PlatformPooledMemory(this, memPtr);
+
+ return mem1;
+ }
+ else if (delta == POOL_HDR_OFF_MEM_2) {
+ if (mem2 == null)
+ mem2 = new PlatformPooledMemory(this, memPtr);
+
+ return mem2;
+ }
+ else {
+ assert delta == POOL_HDR_OFF_MEM_3;
+
+ if (mem3 == null)
+ mem3 = new PlatformPooledMemory(this, memPtr);
+
+ return mem3;
+ }
+ }
+
+ /**
+ * Cleaner runnable.
+ */
+ private static class CleanerRunnable implements Runnable {
+ /** Pointer. */
+ private final long poolPtr;
+
+ /**
+ * Constructor.
+ *
+ * @param poolPtr Pointer.
+ */
+ private CleanerRunnable(long poolPtr) {
+ assert poolPtr != 0;
+
+ this.poolPtr = poolPtr;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ PlatformMemoryUtils.releasePool(poolPtr);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
new file mode 100644
index 0000000..c5ca971
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
@@ -0,0 +1,468 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+import org.apache.ignite.internal.util.*;
+import sun.misc.*;
+
+import java.nio.*;
+
+/**
+ * Utility classes for memory management.
+ */
+public class PlatformMemoryUtils {
+ /** Unsafe instance. */
+ public static final Unsafe UNSAFE = GridUnsafe.unsafe();
+
+ /** Array offset: boolean. */
+ public static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
+
+ /** Array offset: byte. */
+ public static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
+
+ /** Array offset: short. */
+ public static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
+
+ /** Array offset: char. */
+ public static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
+
+ /** Array offset: int. */
+ public static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
+
+ /** Array offset: float. */
+ public static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
+
+ /** Array offset: long. */
+ public static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
+
+ /** Array offset: double. */
+ public static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
+
+ /** Whether little endian is used on the platform. */
+ public static final boolean LITTLE_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN;
+
+ /** Header length. */
+ public static final int POOL_HDR_LEN = 64;
+
+ /** Pool header offset: first memory chunk. */
+ public static final int POOL_HDR_OFF_MEM_1 = 0;
+
+ /** Pool header offset: second memory chunk. */
+ public static final int POOL_HDR_OFF_MEM_2 = 20;
+
+ /** Pool header offset: third memory chunk. */
+ public static final int POOL_HDR_OFF_MEM_3 = 40;
+
+ /** Memory chunk header length. */
+ public static final int MEM_HDR_LEN = 20;
+
+ /** Offset: capacity. */
+ public static final int MEM_HDR_OFF_CAP = 8;
+
+ /** Offset: length. */
+ public static final int MEM_HDR_OFF_LEN = 12;
+
+ /** Offset: flags. */
+ public static final int MEM_HDR_OFF_FLAGS = 16;
+
+ /** Flag: external. */
+ public static final int FLAG_EXT = 0x1;
+
+ /** Flag: pooled. */
+ public static final int FLAG_POOLED = 0x2;
+
+ /** Flag: whether this pooled memory chunk is acquired. */
+ public static final int FLAG_ACQUIRED = 0x4;
+
+ /** --- COMMON METHODS. --- */
+
+ /**
+ * Gets data pointer for the given memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @return Data pointer.
+ */
+ public static long data(long memPtr) {
+ return UNSAFE.getLong(memPtr);
+ }
+
+ /**
+ * Gets capacity for the given memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @return Capacity.
+ */
+ public static int capacity(long memPtr) {
+ return UNSAFE.getInt(memPtr + MEM_HDR_OFF_CAP);
+ }
+
+ /**
+ * Sets capacity for the given memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @param cap Capacity.
+ */
+ public static void capacity(long memPtr, int cap) {
+ assert !isExternal(memPtr) : "Attempt to update external memory chunk capacity: " + memPtr;
+
+ UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
+ }
+
+ /**
+ * Gets length for the given memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @return Length.
+ */
+ public static int length(long memPtr) {
+ return UNSAFE.getInt(memPtr + MEM_HDR_OFF_LEN);
+ }
+
+ /**
+ * Sets length for the given memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @param len Length.
+ */
+ public static void length(long memPtr, int len) {
+ UNSAFE.putInt(memPtr + MEM_HDR_OFF_LEN, len);
+ }
+
+ /**
+ * Gets flags for the given memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @return Flags.
+ */
+ public static int flags(long memPtr) {
+ return UNSAFE.getInt(memPtr + MEM_HDR_OFF_FLAGS);
+ }
+
+ /**
+ * Sets flags for the given memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @param flags Flags.
+ */
+ public static void flags(long memPtr, int flags) {
+ assert !isExternal(memPtr) : "Attempt to update external memory chunk flags: " + memPtr;
+
+ UNSAFE.putInt(memPtr + MEM_HDR_OFF_FLAGS, flags);
+ }
+
+ /**
+ * Check whether this memory chunk is external.
+ *
+ * @param memPtr Memory pointer.
+ * @return {@code True} if owned by native platform.
+ */
+ public static boolean isExternal(long memPtr) {
+ return isExternal(flags(memPtr));
+ }
+
+ /**
+ * Check whether flags denote that this memory chunk is external.
+ *
+ * @param flags Flags.
+ * @return {@code True} if owned by native platform.
+ */
+ public static boolean isExternal(int flags) {
+ return (flags & FLAG_EXT) == FLAG_EXT;
+ }
+
+ /**
+ * Check whether this memory chunk is pooled.
+ *
+ * @param memPtr Memory pointer.
+ * @return {@code True} if pooled.
+ */
+ public static boolean isPooled(long memPtr) {
+ return isPooled(flags(memPtr));
+ }
+
+ /**
+ * Check whether flags denote pooled memory chunk.
+ *
+ * @param flags Flags.
+ * @return {@code True} if pooled.
+ */
+ public static boolean isPooled(int flags) {
+ return (flags & FLAG_POOLED) != 0;
+ }
+
+ /**
+ * Check whether this memory chunk is pooled and acquired.
+ *
+ * @param memPtr Memory pointer.
+ * @return {@code True} if pooled and acquired.
+ */
+ public static boolean isAcquired(long memPtr) {
+ return isAcquired(flags(memPtr));
+ }
+
+ /**
+ * Check whether flags denote pooled and acquired memory chunk.
+ *
+ * @param flags Flags.
+ * @return {@code True} if acquired.
+ */
+ public static boolean isAcquired(int flags) {
+ assert isPooled(flags);
+
+ return (flags & FLAG_ACQUIRED) != 0;
+ }
+
+ /** --- UNPOOLED MEMORY MANAGEMENT. --- */
+
+ /**
+ * Allocate unpooled memory chunk.
+ *
+ * @param cap Minimum capacity.
+ * @return New memory pointer.
+ */
+ public static long allocateUnpooled(int cap) {
+ assert cap > 0;
+
+ long memPtr = UNSAFE.allocateMemory(MEM_HDR_LEN);
+ long dataPtr = UNSAFE.allocateMemory(cap);
+
+ UNSAFE.putLong(memPtr, dataPtr); // Write address.
+ UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write capacity.
+ UNSAFE.putInt(memPtr + MEM_HDR_OFF_LEN, 0); // Write length.
+ UNSAFE.putInt(memPtr + MEM_HDR_OFF_FLAGS, 0); // Write flags.
+
+ return memPtr;
+ }
+
+ /**
+ * Reallocate unpooled memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @param cap Minimum capacity.
+ */
+ public static void reallocateUnpooled(long memPtr, int cap) {
+ assert cap > 0;
+
+ assert !isExternal(memPtr) : "Attempt to reallocate external memory chunk directly: " + memPtr;
+ assert !isPooled(memPtr) : "Attempt to reallocate pooled memory chunk directly: " + memPtr;
+
+ long dataPtr = data(memPtr);
+
+ long newDataPtr = UNSAFE.reallocateMemory(dataPtr, cap);
+
+ if (dataPtr != newDataPtr)
+ UNSAFE.putLong(memPtr, newDataPtr); // Write new data address if needed.
+
+ UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write new capacity.
+ }
+
+ /**
+ * Release unpooled memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ */
+ public static void releaseUnpooled(long memPtr) {
+ assert !isExternal(memPtr) : "Attempt to release external memory chunk directly: " + memPtr;
+ assert !isPooled(memPtr) : "Attempt to release pooled memory chunk directly: " + memPtr;
+
+ UNSAFE.freeMemory(data(memPtr));
+ UNSAFE.freeMemory(memPtr);
+ }
+
+ /** --- POOLED MEMORY MANAGEMENT. --- */
+
+ /**
+ * Allocate pool memory.
+ *
+ * @return Pool pointer.
+ */
+ public static long allocatePool() {
+ long poolPtr = UNSAFE.allocateMemory(POOL_HDR_LEN);
+
+ UNSAFE.setMemory(poolPtr, POOL_HDR_LEN, (byte)0);
+
+ flags(poolPtr + POOL_HDR_OFF_MEM_1, FLAG_POOLED);
+ flags(poolPtr + POOL_HDR_OFF_MEM_2, FLAG_POOLED);
+ flags(poolPtr + POOL_HDR_OFF_MEM_3, FLAG_POOLED);
+
+ return poolPtr;
+ }
+
+ /**
+ * Release pool memory.
+ *
+ * @param poolPtr Pool pointer.
+ */
+ public static void releasePool(long poolPtr) {
+ // Clean predefined memory chunks.
+ long mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_1);
+
+ if (mem != 0)
+ UNSAFE.freeMemory(mem);
+
+ mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_2);
+
+ if (mem != 0)
+ UNSAFE.freeMemory(mem);
+
+ mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_3);
+
+ if (mem != 0)
+ UNSAFE.freeMemory(mem);
+
+ // Clean pool chunk.
+ UNSAFE.freeMemory(poolPtr);
+ }
+
+ /**
+ * Allocate pooled memory chunk.
+ *
+ * @param poolPtr Pool pointer.
+ * @param cap Capacity.
+ * @return Cross-platform memory pointer or {@code 0} in case there are no free memory chunks in the pool.
+ */
+ public static long allocatePooled(long poolPtr, int cap) {
+ long memPtr1 = poolPtr + POOL_HDR_OFF_MEM_1;
+
+ if (isAcquired(memPtr1)) {
+ long memPtr2 = poolPtr + POOL_HDR_OFF_MEM_2;
+
+ if (isAcquired(memPtr2)) {
+ long memPtr3 = poolPtr + POOL_HDR_OFF_MEM_3;
+
+ if (isAcquired(memPtr3))
+ return 0L;
+ else {
+ allocatePooled0(memPtr3, cap);
+
+ return memPtr3;
+ }
+ }
+ else {
+ allocatePooled0(memPtr2, cap);
+
+ return memPtr2;
+ }
+ }
+ else {
+ allocatePooled0(memPtr1, cap);
+
+ return memPtr1;
+ }
+ }
+
+ /**
+ * Internal pooled memory chunk allocation routine.
+ *
+ * @param memPtr Memory pointer.
+ * @param cap Capacity.
+ */
+ private static void allocatePooled0(long memPtr, int cap) {
+ assert !isExternal(memPtr);
+ assert isPooled(memPtr);
+ assert !isAcquired(memPtr);
+
+ long data = UNSAFE.getLong(memPtr);
+
+ if (data == 0) {
+ // First allocation of the chunk.
+ data = UNSAFE.allocateMemory(cap);
+
+ UNSAFE.putLong(memPtr, data);
+ UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
+ }
+ else {
+ // Ensure that we have enough capacity.
+ int curCap = capacity(memPtr);
+
+ if (cap > curCap) {
+ data = UNSAFE.reallocateMemory(data, cap);
+
+ UNSAFE.putLong(memPtr, data);
+ UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
+ }
+ }
+
+ flags(memPtr, FLAG_POOLED | FLAG_ACQUIRED);
+ }
+
+ /**
+ * Reallocate pooled memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @param cap Minimum capacity.
+ */
+ public static void reallocatePooled(long memPtr, int cap) {
+ assert !isExternal(memPtr);
+ assert isPooled(memPtr);
+ assert isAcquired(memPtr);
+
+ long data = UNSAFE.getLong(memPtr);
+
+ assert data != 0;
+
+ int curCap = capacity(memPtr);
+
+ if (cap > curCap) {
+ data = UNSAFE.reallocateMemory(data, cap);
+
+ UNSAFE.putLong(memPtr, data);
+ UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
+ }
+ }
+
+ /**
+ * Release pooled memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ */
+ public static void releasePooled(long memPtr) {
+ assert !isExternal(memPtr);
+ assert isPooled(memPtr);
+ assert isAcquired(memPtr);
+
+ flags(memPtr, flags(memPtr) ^ FLAG_ACQUIRED);
+ }
+
+ /** --- UTILITY STUFF. --- */
+
+ /**
+ * Reallocate arbitrary memory chunk.
+ *
+ * @param memPtr Memory pointer.
+ * @param cap Capacity.
+ */
+ public static void reallocate(long memPtr, int cap) {
+ int flags = flags(memPtr);
+
+ if (isPooled(flags))
+ reallocatePooled(memPtr, cap);
+ else {
+ assert !isExternal(flags);
+
+ reallocateUnpooled(memPtr, cap);
+ }
+ }
+
+ /**
+ * Constructor.
+ */
+ private PlatformMemoryUtils() {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
new file mode 100644
index 0000000..eb2490a
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+import org.apache.ignite.internal.portable.streams.*;
+
+/**
+ * Interop output stream.
+ */
+public interface PlatformOutputStream extends PortableOutputStream {
+ /**
+ * Synchronize output stream with underlying memory
+ */
+ public void synchronize();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
new file mode 100644
index 0000000..6c7c865
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.*;
+
+/**
+ * Interop output stream implementation.
+ */
+public class PlatformOutputStreamImpl implements PlatformOutputStream {
+ /** Underlying memory chunk. */
+ protected final PlatformMemory mem;
+
+ /** Pointer. */
+ protected long data;
+
+ /** Maximum capacity. */
+ protected int cap;
+
+ /** Current position. */
+ protected int pos;
+
+ /**
+ * Constructor.
+ *
+ * @param mem Underlying memory chunk.
+ */
+ public PlatformOutputStreamImpl(PlatformMemory mem) {
+ this.mem = mem;
+
+ data = mem.data();
+ cap = mem.capacity();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeByte(byte val) {
+ ensureCapacity(pos + 1);
+
+ UNSAFE.putByte(data + pos++, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeByteArray(byte[] val) {
+ copyAndShift(val, BYTE_ARR_OFF, val.length);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBoolean(boolean val) {
+ writeByte(val ? (byte) 1 : (byte) 0);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBooleanArray(boolean[] val) {
+ copyAndShift(val, BOOLEAN_ARR_OFF, val.length);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeShort(short val) {
+ ensureCapacity(pos + 2);
+
+ UNSAFE.putShort(data + pos, val);
+
+ shift(2);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeShortArray(short[] val) {
+ copyAndShift(val, SHORT_ARR_OFF, val.length << 1);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeChar(char val) {
+ ensureCapacity(pos + 2);
+
+ UNSAFE.putChar(data + pos, val);
+
+ shift(2);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeCharArray(char[] val) {
+ copyAndShift(val, CHAR_ARR_OFF, val.length << 1);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeInt(int val) {
+ ensureCapacity(pos + 4);
+
+ UNSAFE.putInt(data + pos, val);
+
+ shift(4);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeIntArray(int[] val) {
+ copyAndShift(val, INT_ARR_OFF, val.length << 2);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeInt(int pos, int val) {
+ ensureCapacity(pos + 4);
+
+ UNSAFE.putInt(data + pos, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeFloat(float val) {
+ writeInt(Float.floatToIntBits(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeFloatArray(float[] val) {
+ copyAndShift(val, FLOAT_ARR_OFF, val.length << 2);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeLong(long val) {
+ ensureCapacity(pos + 8);
+
+ UNSAFE.putLong(data + pos, val);
+
+ shift(8);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeLongArray(long[] val) {
+ copyAndShift(val, LONG_ARR_OFF, val.length << 3);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDouble(double val) {
+ writeLong(Double.doubleToLongBits(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDoubleArray(double[] val) {
+ copyAndShift(val, DOUBLE_ARR_OFF, val.length << 3);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(byte[] arr, int off, int len) {
+ copyAndShift(arr, BYTE_ARR_OFF + off, len);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(long addr, int cnt) {
+ copyAndShift(null, addr, cnt);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int position() {
+ return pos;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void position(int pos) {
+ ensureCapacity(pos);
+
+ this.pos = pos;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte[] array() {
+ assert false;
+
+ throw new UnsupportedOperationException("Should not be called.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte[] arrayCopy() {
+ assert false;
+
+ throw new UnsupportedOperationException("Should not be called.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public long offheapPointer() {
+ assert false;
+
+ throw new UnsupportedOperationException("Should not be called.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean hasArray() {
+ assert false;
+
+ throw new UnsupportedOperationException("Should not be called.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void synchronize() {
+ PlatformMemoryUtils.length(mem.pointer(), pos);
+ }
+
+ /**
+ * Ensure capacity.
+ *
+ * @param reqCap Required byte count.
+ */
+ protected void ensureCapacity(int reqCap) {
+ if (reqCap > cap) {
+ int newCap = cap << 1;
+
+ if (newCap < reqCap)
+ newCap = reqCap;
+
+ mem.reallocate(newCap);
+
+ assert mem.capacity() >= newCap;
+
+ data = mem.data();
+ cap = newCap;
+ }
+ }
+
+ /**
+ * Shift position.
+ *
+ * @param cnt Byte count.
+ */
+ protected void shift(int cnt) {
+ pos += cnt;
+ }
+
+ /**
+ * Copy source object to the stream shifting position afterwards.
+ *
+ * @param src Source.
+ * @param off Offset.
+ * @param len Length.
+ */
+ private void copyAndShift(Object src, long off, int len) {
+ ensureCapacity(pos + len);
+
+ UNSAFE.copyMemory(src, off, null, data + pos, len);
+
+ shift(len);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformPooledMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformPooledMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformPooledMemory.java
new file mode 100644
index 0000000..98a9a58
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformPooledMemory.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.internal.processors.platform.memory;
+
+import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.*;
+
+/**
+ * Interop pooled memory chunk.
+ */
+public class PlatformPooledMemory extends PlatformAbstractMemory {
+ /** Owning memory pool. */
+ private final PlatformMemoryPool pool;
+
+ /**
+ * Constructor.
+ *
+ * @param pool Owning memory pool.
+ * @param memPtr Cross-platform memory pointer.
+ */
+ public PlatformPooledMemory(PlatformMemoryPool pool, long memPtr) {
+ super(memPtr);
+
+ assert isPooled(memPtr);
+ assert isAcquired(memPtr);
+
+ this.pool = pool;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void reallocate(int cap) {
+ assert isAcquired(memPtr);
+
+ // Try doubling capacity to avoid excessive allocations.
+ int doubledCap = PlatformMemoryUtils.capacity(memPtr) << 1;
+
+ if (doubledCap > cap)
+ cap = doubledCap;
+
+ pool.reallocate(memPtr, cap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() {
+ assert isAcquired(memPtr);
+
+ pool.release(memPtr); // Return to the pool.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformUnpooledMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformUnpooledMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformUnpooledMemory.java
new file mode 100644
index 0000000..a236dab
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformUnpooledMemory.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.memory;
+
+import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.*;
+
+/**
+ * Interop un-pooled memory chunk.
+ */
+public class PlatformUnpooledMemory extends PlatformAbstractMemory {
+ /**
+ * Constructor.
+ *
+ * @param memPtr Cross-platform memory pointer.
+ */
+ public PlatformUnpooledMemory(long memPtr) {
+ super(memPtr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void reallocate(int cap) {
+ // Try doubling capacity to avoid excessive allocations.
+ int doubledCap = PlatformMemoryUtils.capacity(memPtr) << 1;
+
+ if (doubledCap > cap)
+ cap = doubledCap;
+
+ reallocateUnpooled(memPtr, cap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() {
+ releaseUnpooled(memPtr);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java
new file mode 100644
index 0000000..ea808d7
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.utils;
+
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.lang.*;
+
+/**
+ * Reader bi-closure.
+ */
+public interface PlatformReaderBiClosure<T1, T2> {
+ /**
+ * Read object from reader.
+ *
+ * @param reader Reader.
+ * @return Object.
+ */
+ IgniteBiTuple<T1, T2> read(PortableRawReaderEx reader);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java
new file mode 100644
index 0000000..cd0523c
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.utils;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ * Reader closure.
+ */
+public interface PlatformReaderClosure<T> {
+
+ /**
+ * Read object from reader.
+ *
+ * @param reader Reader.
+ * @return Object.
+ */
+ T read(PortableRawReaderEx reader);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java
new file mode 100644
index 0000000..89a73b0
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.utils;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ * Interop writer bi-closure.
+ */
+public interface PlatformWriterBiClosure<T1, T2> {
+ /**
+ * Write values.
+ *
+ * @param writer Writer.
+ * @param val1 Value 1.
+ * @param val2 Value 2.
+ */
+ public void write(PortableRawWriterEx writer, T1 val1, T2 val2);
+}
[34/41] ignite git commit: Restored backward compatibility for cache
objects
Posted by sb...@apache.org.
Restored backward compatibility for cache objects
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e428206d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e428206d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e428206d
Branch: refs/heads/ignite-1093
Commit: e428206d3d2281de72e674fe5abf9f887bf221fc
Parents: 38b3ffd
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Aug 26 15:50:34 2015 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Aug 26 15:50:34 2015 -0700
----------------------------------------------------------------------
.../cache/portable/CacheObjectPortableProcessorImpl.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e428206d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
index a421129..e70feb9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
@@ -36,6 +36,7 @@ import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.marshaller.*;
import org.apache.ignite.marshaller.portable.*;
+import org.apache.ignite.plugin.*;
import org.apache.ignite.portable.*;
import org.jetbrains.annotations.*;
@@ -569,7 +570,7 @@ public class CacheObjectPortableProcessorImpl extends IgniteCacheObjectProcessor
}
/** {@inheritDoc} */
- @Override public boolean isPortableEnabled() {
+ @Override public boolean isPortableEnabled(CacheConfiguration<?, ?> ccfg) {
return marsh instanceof PortableMarshaller;
}
[14/41] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4f3c9a2a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4f3c9a2a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4f3c9a2a
Branch: refs/heads/ignite-1093
Commit: 4f3c9a2a1b54c6a61c790b668292a0ed1c33140e
Parents: 28d64d5 76bc7d6
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 11:00:44 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 11:00:44 2015 +0300
----------------------------------------------------------------------
.../IgniteCacheManyAsyncOperationsTest.java | 107 +++++++++++++++++++
1 file changed, 107 insertions(+)
----------------------------------------------------------------------
[22/41] ignite git commit: IGNITE-1306: Moved "AbstractTarget" which
is a root class for all basic platform classes to Ignite.
Posted by sb...@apache.org.
IGNITE-1306: Moved "AbstractTarget" which is a root class for all basic platform classes to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0e81fd0c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0e81fd0c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0e81fd0c
Branch: refs/heads/ignite-1093
Commit: 0e81fd0cd578ecaa6c57625f75abafa1118eccef
Parents: 9382118
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 13:35:30 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 13:35:30 2015 +0300
----------------------------------------------------------------------
.../platform/PlatformAbstractBootstrap.java | 1 +
.../platform/PlatformAbstractTarget.java | 276 +++++++++++++++++++
2 files changed, 277 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0e81fd0c/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java
index 4db3c1e..39af1fa 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.ignite.internal.processors.platform;
import org.apache.ignite.*;
http://git-wip-us.apache.org/repos/asf/ignite/blob/0e81fd0c/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
new file mode 100644
index 0000000..ec728e4
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
@@ -0,0 +1,276 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.platform.memory.*;
+import org.apache.ignite.internal.processors.platform.utils.*;
+import org.apache.ignite.lang.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * Abstract interop target.
+ */
+public abstract class PlatformAbstractTarget implements PlatformTarget {
+ /** Constant: TRUE.*/
+ protected static final int TRUE = 1;
+
+ /** Constant: FALSE. */
+ protected static final int FALSE = 0;
+
+ /** */
+ private static final int OP_META = -1;
+
+ /** Interop context. */
+ protected final PlatformContext interopCtx;
+
+ /** Logger. */
+ protected final IgniteLogger log;
+
+ /**
+ * Constructor.
+ *
+ * @param interopCtx Interop context.
+ */
+ protected PlatformAbstractTarget(PlatformContext interopCtx) {
+ this.interopCtx = interopCtx;
+
+ log = interopCtx.kernalContext().log(PlatformAbstractTarget.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int inOp(int type, long memPtr) throws Exception {
+ try (PlatformMemory mem = interopCtx.memory().get(memPtr)) {
+ PortableRawReaderEx reader = interopCtx.reader(mem);
+
+ if (type == OP_META) {
+ interopCtx.processMetadata(reader);
+
+ return TRUE;
+ }
+ else
+ return processInOp(type, reader);
+ }
+ catch (Exception e) {
+ throw convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object inOpObject(int type, long memPtr) throws Exception {
+ try (PlatformMemory mem = interopCtx.memory().get(memPtr)) {
+ PortableRawReaderEx reader = interopCtx.reader(mem);
+
+ return processInOpObject(type, reader);
+ }
+ catch (Exception e) {
+ throw convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void outOp(int type, long memPtr) throws Exception {
+ try (PlatformMemory mem = interopCtx.memory().get(memPtr)) {
+ PlatformOutputStream out = mem.output();
+
+ PortableRawWriterEx writer = interopCtx.writer(out);
+
+ processOutOp(type, writer);
+
+ out.synchronize();
+ }
+ catch (Exception e) {
+ throw convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void inOutOp(int type, long inMemPtr, long outMemPtr) throws Exception {
+ inOutOp(type, inMemPtr, outMemPtr, null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void inOutOp(int type, long inMemPtr, long outMemPtr, Object arg) throws Exception {
+ try (PlatformMemory inMem = interopCtx.memory().get(inMemPtr)) {
+ PortableRawReaderEx reader = interopCtx.reader(inMem);
+
+ try (PlatformMemory outMem = interopCtx.memory().get(outMemPtr)) {
+ PlatformOutputStream out = outMem.output();
+
+ PortableRawWriterEx writer = interopCtx.writer(out);
+
+ processInOutOp(type, reader, writer, arg);
+
+ out.synchronize();
+ }
+ }
+ catch (Exception e) {
+ throw convertException(e);
+ }
+ }
+
+ /**
+ * Convert caught exception.
+ *
+ * @param e Exception to convert.
+ * @return Converted exception.
+ */
+ protected Exception convertException(Exception e) {
+ return e;
+ }
+
+ /**
+ * @return Interop context.
+ */
+ public PlatformContext interopContext() {
+ return interopCtx;
+ }
+
+ /**
+ * Start listening for the future.
+ *
+ * @param futId Future ID.
+ * @param typ Result type.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ public void listenFuture(final long futId, int typ) throws IgniteCheckedException {
+ PlatformFutureUtils.listen(interopCtx, currentFutureWrapped(), futId, typ, null);
+ }
+
+ /**
+ * Start listening for the future.
+ *
+ * @param futId Future ID.
+ * @param typ Result type.
+ * @param opId Operation ID required to pick correct result writer.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ public void listenFuture(final long futId, int typ, int opId) throws IgniteCheckedException {
+ PlatformFutureUtils.listen(interopCtx, currentFutureWrapped(), futId, typ, futureWriter(opId));
+ }
+
+ /**
+ * Get current future with proper exception conversions.
+ *
+ * @return Future.
+ * @throws org.apache.ignite.IgniteCheckedException If failed.
+ */
+ @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "unchecked"})
+ protected IgniteFuture currentFutureWrapped() throws IgniteCheckedException {
+ return currentFuture().chain(new IgniteClosure<IgniteFuture, Object>() {
+ @Override public Object apply(IgniteFuture o) {
+ try {
+ return o.get();
+ }
+ catch (RuntimeException e) {
+ Exception converted = convertException(e);
+
+ if (converted instanceof RuntimeException)
+ throw (RuntimeException)converted;
+ else {
+ log.error("Interop future result cannot be obtained due to exception.", converted);
+
+ throw new IgniteException("Interop future result cannot be obtained due to exception " +
+ "(see log for more details).");
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * When overridden in a derived class, gets future for the current operation.
+ *
+ * @return current future.
+ * @throws org.apache.ignite.IgniteCheckedException
+ */
+ protected IgniteFuture currentFuture() throws IgniteCheckedException {
+ throw new IgniteCheckedException("Future listening is not supported in " + this.getClass());
+ }
+
+ /**
+ * When overridden in a derived class, gets a custom future writer.
+ *
+ * @param opId Operation id.
+ * @return A custom writer for given op id.
+ */
+ protected @Nullable PlatformFutureUtils.Writer futureWriter(int opId){
+ return null;
+ }
+
+ /**
+ * Process IN operation.
+ *
+ * @param type Type.
+ * @param reader Portable reader.
+ * @return Result.
+ * @throws org.apache.ignite.IgniteCheckedException In case of exception.
+ */
+ protected int processInOp(int type, PortableRawReaderEx reader) throws IgniteCheckedException {
+ return throwUnsupported(type);
+ }
+
+ /**
+ * Process IN operation with managed object as result.
+ *
+ * @param type Type.
+ * @param reader Portable reader.
+ * @return Result.
+ * @throws org.apache.ignite.IgniteCheckedException In case of exception.
+ */
+ protected Object processInOpObject(int type, PortableRawReaderEx reader) throws IgniteCheckedException {
+ return throwUnsupported(type);
+ }
+
+ /**
+ * Process OUT operation.
+ *
+ * @param type Type.
+ * @param writer Portable writer.
+ * @throws org.apache.ignite.IgniteCheckedException In case of exception.
+ */
+ protected void processOutOp(int type, PortableRawWriterEx writer) throws IgniteCheckedException {
+ throwUnsupported(type);
+ }
+
+ /**
+ * Process IN-OUT operation.
+ *
+ * @param type Type.
+ * @param reader Portable reader.
+ * @param writer Portable writer.
+ * @param arg Argument.
+ * @throws org.apache.ignite.IgniteCheckedException In case of exception.
+ */
+ protected void processInOutOp(int type, PortableRawReaderEx reader, PortableRawWriterEx writer,
+ @Nullable Object arg) throws IgniteCheckedException {
+ throwUnsupported(type);
+ }
+
+ /**
+ * Throw an exception rendering unsupported operation type.
+ *
+ * @param type Operation type.
+ * @return Dummy value which is never returned.
+ * @throws org.apache.ignite.IgniteCheckedException Exception to be thrown.
+ */
+ protected <T> T throwUnsupported(int type) throws IgniteCheckedException {
+ throw new IgniteCheckedException("Unsupported operation type: " + type);
+ }
+}
[06/41] ignite git commit: Moving platform classes to
"...internal.processors..." package to follow Ignite common approach.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2225f8d2/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java
new file mode 100644
index 0000000..697335e
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.utils;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ * Interop writer closure.
+ */
+public interface PlatformWriterClosure<T> {
+ /**
+ * Write value.
+ *
+ * @param writer Writer.
+ * @param val Value.
+ */
+ public void write(PortableRawWriterEx writer, T val);
+}
[18/41] ignite git commit: Moving platform utility methods to Ignite.
Posted by sb...@apache.org.
Moving platform utility methods to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bcf3054b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bcf3054b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bcf3054b
Branch: refs/heads/ignite-1093
Commit: bcf3054b0f6861fad32cc81d2ecf89ecd9eaf6aa
Parents: 7c351bf
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 12:28:17 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 12:28:17 2015 +0300
----------------------------------------------------------------------
.../platform/utils/PlatformUtils.java | 531 +++++++++++++++++++
1 file changed, 531 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcf3054b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
new file mode 100644
index 0000000..a620f8e
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -0,0 +1,531 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.utils;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.platform.*;
+import org.apache.ignite.internal.processors.platform.memory.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.*;
+import javax.cache.event.*;
+import java.util.*;
+
+/**
+ * Platform utility methods.
+ */
+@SuppressWarnings({"UnusedDeclaration", "unchecked"})
+public class PlatformUtils {
+ /** Amount of peek modes available. */
+ private static final int CACHE_PEEK_MODES_CNT = CachePeekMode.values().length;
+
+ /** Cache peek modes. */
+ private static volatile CachePeekMode[][] CACHE_PEEK_MODES;
+
+ /**
+ * Static initializer.
+ */
+ static {
+ int len = 1 << CACHE_PEEK_MODES_CNT;
+
+ synchronized (PlatformUtils.class) {
+ CACHE_PEEK_MODES = new CachePeekMode[len][];
+
+ CACHE_PEEK_MODES[0] = new CachePeekMode[0];
+ }
+ }
+
+ /**
+ * Write nullable collection to the writer.
+ *
+ * @param writer Writer.
+ * @param col Collection to write.
+ */
+ public static <T> void writeNullableCollection(PortableRawWriterEx writer, @Nullable Collection<T> col) {
+ writeNullableCollection(writer, col, null, null);
+ }
+
+ /**
+ * Write nullable collection to the writer.
+ *
+ * @param writer Writer.
+ * @param col Collection to write.
+ * @param writeClo Writer closure.
+ */
+ public static <T> void writeNullableCollection(PortableRawWriterEx writer, @Nullable Collection<T> col,
+ @Nullable PlatformWriterClosure<T> writeClo) {
+ writeNullableCollection(writer, col, writeClo, null);
+ }
+
+ /**
+ * Write collection to the writer.
+ *
+ * @param writer Writer.
+ * @param col Collection to write.
+ * @param writeClo Optional writer closure.
+ * @param filter Optional filter.
+ */
+ public static <T> void writeNullableCollection(PortableRawWriterEx writer, @Nullable Collection<T> col,
+ @Nullable PlatformWriterClosure<T> writeClo, @Nullable IgnitePredicate<T> filter) {
+ if (col != null) {
+ writer.writeBoolean(true);
+
+ writeCollection(writer, col, writeClo, filter);
+ }
+ else
+ writer.writeBoolean(false);
+ }
+
+ /**
+ * Write collection to the writer.
+ *
+ * @param writer Writer.
+ * @param col Collection to write.
+ */
+ public static <T> void writeCollection(PortableRawWriterEx writer, Collection<T> col) {
+ writeCollection(writer, col, null, null);
+ }
+
+ /**
+ * Write collection to the writer.
+ *
+ * @param writer Writer.
+ * @param col Collection to write.
+ * @param writeClo Writer closure.
+ */
+ public static <T> void writeCollection(PortableRawWriterEx writer, Collection<T> col,
+ @Nullable PlatformWriterClosure<T> writeClo) {
+ writeCollection(writer, col, writeClo, null);
+ }
+
+ /**
+ * Write collection to the writer.
+ *
+ * @param writer Writer.
+ * @param col Collection to write.
+ * @param writeClo Optional writer closure.
+ * @param filter Optional filter.
+ */
+ public static <T> void writeCollection(PortableRawWriterEx writer, Collection<T> col,
+ @Nullable PlatformWriterClosure<T> writeClo, @Nullable IgnitePredicate<T> filter) {
+ assert col != null;
+
+ if (filter == null) {
+ writer.writeInt(col.size());
+
+ if (writeClo == null) {
+ for (T entry : col)
+ writer.writeObject(entry);
+ }
+ else {
+ for (T entry : col)
+ writeClo.write(writer, entry);
+ }
+ }
+ else {
+ int pos = writer.reserveInt();
+ int cnt = 0;
+
+ for (T entry : col) {
+ if (filter.apply(entry)) {
+ cnt++;
+
+ if (writeClo == null)
+ writer.writeObject(entry);
+ else
+ writeClo.write(writer, entry);
+ }
+ }
+
+ writer.writeInt(pos, cnt);
+ }
+ }
+
+ /**
+ * Write nullable map to the writer.
+ *
+ * @param writer Writer.
+ * @param map Map to write.
+ */
+ public static <K, V> void writeNullableMap(PortableRawWriterEx writer, @Nullable Map<K, V> map) {
+ if (map != null) {
+ writer.writeBoolean(true);
+
+ writeMap(writer, map);
+ }
+ else
+ writer.writeBoolean(false);
+ }
+
+ /**
+ * Write nullable map to the writer.
+ *
+ * @param writer Writer.
+ * @param map Map to write.
+ */
+ public static <K, V> void writeMap(PortableRawWriterEx writer, Map<K, V> map) {
+ assert map != null;
+
+ writeMap(writer, map, null);
+ }
+
+ /**
+ * Write nullable map to the writer.
+ *
+ * @param writer Writer.
+ * @param map Map to write.
+ * @param writeClo Writer closure.
+ */
+ public static <K, V> void writeMap(PortableRawWriterEx writer, Map<K, V> map,
+ @Nullable PlatformWriterBiClosure<K, V> writeClo) {
+ assert map != null;
+
+ writer.writeInt(map.size());
+
+ if (writeClo == null) {
+ for (Map.Entry<K, V> entry : map.entrySet()) {
+ writer.writeObject(entry.getKey());
+ writer.writeObject(entry.getValue());
+ }
+ }
+ else {
+ for (Map.Entry<K, V> entry : map.entrySet())
+ writeClo.write(writer, entry.getKey(), entry.getValue());
+ }
+ }
+
+ /**
+ * Read collection.
+ *
+ * @param reader Reader.
+ * @return List.
+ */
+ public static <T> List<T> readCollection(PortableRawReaderEx reader) {
+ return readCollection(reader, null);
+ }
+
+ /**
+ * Read collection.
+ *
+ * @param reader Reader.
+ * @param readClo Optional reader closure.
+ * @return List.
+ */
+ public static <T> List<T> readCollection(PortableRawReaderEx reader, @Nullable PlatformReaderClosure<T> readClo) {
+ int cnt = reader.readInt();
+
+ List<T> res = new ArrayList<>(cnt);
+
+ if (readClo == null) {
+ for (int i = 0; i < cnt; i++)
+ res.add((T)reader.readObjectDetached());
+ }
+ else {
+ for (int i = 0; i < cnt; i++)
+ res.add(readClo.read(reader));
+ }
+
+ return res;
+ }
+
+ /**
+ * Read nullable collection.
+ *
+ * @param reader Reader.
+ * @return List.
+ */
+ public static <T> List<T> readNullableCollection(PortableRawReaderEx reader) {
+ return readNullableCollection(reader, null);
+ }
+
+ /**
+ * Read nullable collection.
+ *
+ * @param reader Reader.
+ * @return List.
+ */
+ public static <T> List<T> readNullableCollection(PortableRawReaderEx reader,
+ @Nullable PlatformReaderClosure<T> readClo) {
+ if (!reader.readBoolean())
+ return null;
+
+ return readCollection(reader, readClo);
+ }
+
+ /**
+ * @param reader Reader.
+ * @return Set.
+ */
+ public static <T> Set<T> readSet(PortableRawReaderEx reader) {
+ int cnt = reader.readInt();
+
+ Set<T> res = U.newHashSet(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ res.add((T)reader.readObjectDetached());
+
+ return res;
+ }
+
+ /**
+ * @param reader Reader.
+ * @return Set.
+ */
+ public static <T> Set<T> readNullableSet(PortableRawReaderEx reader) {
+ if (!reader.readBoolean())
+ return null;
+
+ return readSet(reader);
+ }
+
+ /**
+ * Read map.
+ *
+ * @param reader Reader.
+ * @return Map.
+ */
+ public static <K, V> Map<K, V> readMap(PortableRawReaderEx reader) {
+ return readMap(reader, null);
+ }
+
+ /**
+ * Read map.
+ *
+ * @param reader Reader.
+ * @param readClo Reader closure.
+ * @return Map.
+ */
+ public static <K, V> Map<K, V> readMap(PortableRawReaderEx reader,
+ @Nullable PlatformReaderBiClosure<K, V> readClo) {
+ int cnt = reader.readInt();
+
+ Map<K, V> map = U.newHashMap(cnt);
+
+ if (readClo == null) {
+ for (int i = 0; i < cnt; i++)
+ map.put((K)reader.readObjectDetached(), (V)reader.readObjectDetached());
+ }
+ else {
+ for (int i = 0; i < cnt; i++) {
+ IgniteBiTuple<K, V> entry = readClo.read(reader);
+
+ map.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ return map;
+ }
+
+ /**
+ * Read nullable map.
+ *
+ * @param reader Reader.
+ * @return Map.
+ */
+ public static <K, V> Map<K, V> readNullableMap(PortableRawReaderEx reader) {
+ if (!reader.readBoolean())
+ return null;
+
+ return readMap(reader);
+ }
+
+ /**
+ * Writes IgniteUuid to a writer.
+ *
+ * @param writer Writer.
+ * @param val Values.
+ */
+ public static void writeIgniteUuid(PortableRawWriterEx writer, IgniteUuid val) {
+ if (val == null)
+ writer.writeUuid(null);
+ else {
+ writer.writeUuid(val.globalId());
+ writer.writeLong(val.localId());
+ }
+ }
+
+ /**
+ * Convert native cache peek modes to Java cache peek modes.
+ *
+ * @param modes Encoded peek modes.
+ * @return Cache peek modes.
+ */
+ public static CachePeekMode[] decodeCachePeekModes(int modes) {
+ // 1. Try getting cache value.
+ CachePeekMode[] res = CACHE_PEEK_MODES[modes];
+
+ if (res == null) {
+ // 2. Calculate modes from scratch.
+ List<CachePeekMode> res0 = new ArrayList<>(CACHE_PEEK_MODES_CNT);
+
+ for (int i = 0; i < CACHE_PEEK_MODES_CNT; i++) {
+ int mask = 1 << i;
+
+ if ((modes & mask) == mask)
+ res0.add(CachePeekMode.fromOrdinal((byte)i));
+ }
+
+ res = res0.toArray(new CachePeekMode[res0.size()]);
+
+ synchronized (PlatformUtils.class) {
+ CACHE_PEEK_MODES[modes] = res;
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * Unwrap query exception.
+ *
+ * @param err Initial error.
+ * @return Unwrapped error.
+ */
+ public static IgniteCheckedException unwrapQueryException(Throwable err) {
+ assert err != null;
+
+ Throwable parent = err;
+ Throwable child = parent.getCause();
+
+ while (true) {
+ if (child == null || child == parent)
+ break;
+
+ if (child instanceof IgniteException || child instanceof IgniteCheckedException
+ || child instanceof CacheException) {
+ // Continue unwrapping.
+ parent = child;
+
+ child = parent.getCause();
+
+ continue;
+ }
+
+ break;
+ }
+
+ // Specific exception found, but detailed message doesn't exist. Just pass exception name then.
+ if (parent.getMessage() == null)
+ return new IgniteCheckedException("Query execution failed due to exception: " +
+ parent.getClass().getName(), err);
+
+ return new IgniteCheckedException(parent.getMessage(), err);
+ }
+
+ /**
+ * Apply continuous query events to listener.
+ *
+ * @param ctx Interop context.
+ * @param lsnrPtr Listener pointer.
+ * @param evts Events.
+ * @throws javax.cache.event.CacheEntryListenerException In case of failure.
+ */
+ public static void applyContinuousQueryEvents(PlatformContext ctx, long lsnrPtr, Iterable<CacheEntryEvent> evts)
+ throws CacheEntryListenerException {
+ assert lsnrPtr != 0;
+ assert evts != null;
+
+ try (PlatformMemory mem = ctx.memory().allocate()) {
+ PlatformOutputStream out = mem.output();
+
+ PortableRawWriterEx writer = ctx.writer(out);
+
+ int cntPos = writer.reserveInt();
+
+ int cnt = 0;
+
+ for (CacheEntryEvent evt : evts) {
+ writeCacheEntryEvent(writer, evt);
+
+ cnt++;
+ }
+
+ writer.writeInt(cntPos, cnt);
+
+ out.synchronize();
+
+ ctx.gateway().continuousQueryListenerApply(lsnrPtr, mem.pointer());
+ }
+ catch (Exception e) {
+ throw toCacheEntryListenerException(e);
+ }
+ }
+
+ /**
+ * Evaluate the filter.
+ *
+ * @param ctx Interop context.
+ * @param filterPtr Native filter pointer.
+ * @param evt Event.
+ * @return Result.
+ * @throws CacheEntryListenerException In case of failure.
+ */
+ public static boolean evaluateContinuousQueryEvent(PlatformContext ctx, long filterPtr, CacheEntryEvent evt)
+ throws CacheEntryListenerException {
+ assert filterPtr != 0;
+
+ try (PlatformMemory mem = ctx.memory().allocate()) {
+ PlatformOutputStream out = mem.output();
+
+ writeCacheEntryEvent(ctx.writer(out), evt);
+
+ out.synchronize();
+
+ return ctx.gateway().continuousQueryFilterApply(filterPtr, mem.pointer()) == 1;
+ }
+ catch (Exception e) {
+ throw toCacheEntryListenerException(e);
+ }
+ }
+
+ /**
+ * Convert exception into listener exception.
+ *
+ * @param e Listener exception.
+ * @return Exception.
+ */
+ private static CacheEntryListenerException toCacheEntryListenerException(Exception e) {
+ assert e != null;
+
+ return e instanceof CacheEntryListenerException ? (CacheEntryListenerException)e : e.getMessage() != null ?
+ new CacheEntryListenerException(e.getMessage(), e) : new CacheEntryListenerException(e);
+ }
+
+ /**
+ * Write event to the writer.
+ *
+ * @param writer Writer.
+ * @param evt Event.
+ */
+ private static void writeCacheEntryEvent(PortableRawWriterEx writer, CacheEntryEvent evt) {
+ writer.writeObjectDetached(evt.getKey());
+ writer.writeObjectDetached(evt.getOldValue());
+ writer.writeObjectDetached(evt.getValue());
+ }
+
+ /**
+ * Private constructor.
+ */
+ private PlatformUtils() {
+ // No-op.
+ }
+}
[27/41] ignite git commit: IGNITE-1308: Moved regular (not
continuous!) queries to Ignite.
Posted by sb...@apache.org.
IGNITE-1308: Moved regular (not continuous!) queries to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8529e108
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8529e108
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8529e108
Branch: refs/heads/ignite-1093
Commit: 8529e10855e71c63c4fc5a83a9cdb2300109bb19
Parents: 975f47e
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 15:43:34 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 15:43:34 2015 +0300
----------------------------------------------------------------------
.../query/PlatformAbstractQueryCursor.java | 192 +++++++++++++++++++
.../cache/query/PlatformFieldsQueryCursor.java | 50 +++++
.../cache/query/PlatformQueryCursor.java | 46 +++++
3 files changed, 288 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8529e108/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java
new file mode 100644
index 0000000..cdd29fd
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.cache.query;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.cache.query.*;
+import org.apache.ignite.internal.processors.platform.*;
+import org.apache.ignite.internal.processors.platform.utils.*;
+
+import java.util.*;
+
+/**
+ *
+ */
+public abstract class PlatformAbstractQueryCursor<T> extends PlatformAbstractTarget implements AutoCloseable {
+ /** Get multiple entries. */
+ private static final int OP_GET_ALL = 1;
+
+ /** Get all entries. */
+ private static final int OP_GET_BATCH = 2;
+
+ /** Get single entry. */
+ private static final int OP_GET_SINGLE = 3;
+
+ /** Underlying cursor. */
+ private final QueryCursorEx<T> cursor;
+
+ /** Batch size size. */
+ private final int batchSize;
+
+ /** Underlying iterator. */
+ private Iterator<T> iter;
+
+ /**
+ * Constructor.
+ *
+ * @param interopCtx Interop context.
+ * @param cursor Underlying cursor.
+ * @param batchSize Batch size.
+ */
+ public PlatformAbstractQueryCursor(PlatformContext interopCtx, QueryCursorEx<T> cursor, int batchSize) {
+ super(interopCtx);
+
+ this.cursor = cursor;
+ this.batchSize = batchSize;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void processOutOp(int type, final PortableRawWriterEx writer) throws IgniteCheckedException {
+ switch (type) {
+ case OP_GET_BATCH: {
+ assert iter != null : "iterator() has not been called";
+
+ try {
+ int cntPos = writer.reserveInt();
+
+ int cnt;
+
+ for (cnt = 0; cnt < batchSize; cnt++) {
+ if (iter.hasNext())
+ write(writer, iter.next());
+ else
+ break;
+ }
+
+ writer.writeInt(cntPos, cnt);
+ }
+ catch (Exception err) {
+ throw PlatformUtils.unwrapQueryException(err);
+ }
+
+ break;
+ }
+
+ case OP_GET_SINGLE: {
+ assert iter != null : "iterator() has not been called";
+
+ try {
+ if (iter.hasNext()) {
+ write(writer, iter.next());
+
+ return;
+ }
+ }
+ catch (Exception err) {
+ throw PlatformUtils.unwrapQueryException(err);
+ }
+
+ throw new IgniteCheckedException("No more data available.");
+ }
+
+ case OP_GET_ALL: {
+ try {
+ int pos = writer.reserveInt();
+
+ Consumer<T> consumer = new Consumer<>(this, writer);
+
+ cursor.getAll(consumer);
+
+ writer.writeInt(pos, consumer.cnt);
+ }
+ catch (Exception err) {
+ throw PlatformUtils.unwrapQueryException(err);
+ }
+
+ break;
+ }
+
+ default:
+ throwUnsupported(type);
+ }
+ }
+
+ /**
+ * Get cursor iterator.
+ */
+ public void iterator() {
+ iter = cursor.iterator();
+ }
+
+ /**
+ * Check whether next iterator entry exists.
+ *
+ * @return {@code True} if exists.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ public boolean iteratorHasNext() {
+ assert iter != null : "iterator() has not been called";
+
+ return iter.hasNext();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() throws Exception {
+ cursor.close();
+ }
+
+ /**
+ * Write value to the stream. Extension point to perform conversions on the object before writing it.
+ *
+ * @param writer Writer.
+ * @param val Value.
+ */
+ protected abstract void write(PortableRawWriterEx writer, T val);
+
+ /**
+ * Query cursor consumer.
+ */
+ private static class Consumer<T> implements QueryCursorEx.Consumer<T> {
+ /** Current query cursor. */
+ private final PlatformAbstractQueryCursor<T> cursor;
+
+ /** Writer. */
+ private final PortableRawWriterEx writer;
+
+ /** Count. */
+ private int cnt;
+
+ /**
+ * Constructor.
+ *
+ * @param writer Writer.
+ */
+ public Consumer(PlatformAbstractQueryCursor<T> cursor, PortableRawWriterEx writer) {
+ this.cursor = cursor;
+ this.writer = writer;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void consume(T val) throws IgniteCheckedException {
+ cursor.write(writer, val);
+
+ cnt++;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8529e108/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java
new file mode 100644
index 0000000..f18a79a
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.cache.query;
+
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.cache.query.*;
+import org.apache.ignite.internal.processors.platform.*;
+
+import java.util.*;
+
+/**
+ * Interop cursor for fields query.
+ */
+public class PlatformFieldsQueryCursor extends PlatformAbstractQueryCursor<List<?>> {
+ /**
+ * Constructor.
+ *
+ * @param interopCtx Interop context.
+ * @param cursor Backing cursor.
+ * @param batchSize Batch size.
+ */
+ public PlatformFieldsQueryCursor(PlatformContext interopCtx, QueryCursorEx<List<?>> cursor, int batchSize) {
+ super(interopCtx, cursor, batchSize);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void write(PortableRawWriterEx writer, List vals) {
+ assert vals != null;
+
+ writer.writeInt(vals.size());
+
+ for (Object val : vals)
+ writer.writeObjectDetached(val);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8529e108/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformQueryCursor.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformQueryCursor.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformQueryCursor.java
new file mode 100644
index 0000000..cc96d6f
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformQueryCursor.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.cache.query;
+
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.cache.query.*;
+import org.apache.ignite.internal.processors.platform.*;
+
+import javax.cache.*;
+
+/**
+ * Interop cursor for regular queries.
+ */
+public class PlatformQueryCursor extends PlatformAbstractQueryCursor<Cache.Entry> {
+ /**
+ * Constructor.
+ *
+ * @param interopCtx Interop context.
+ * @param cursor Backing cursor.
+ * @param batchSize Batch size.
+ */
+ public PlatformQueryCursor(PlatformContext interopCtx, QueryCursorEx<Cache.Entry> cursor, int batchSize) {
+ super(interopCtx, cursor, batchSize);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void write(PortableRawWriterEx writer, Cache.Entry val) {
+ writer.writeObjectDetached(val.getKey());
+ writer.writeObjectDetached(val.getValue());
+ }
+}
[33/41] ignite git commit: Restored backward compatibility for cache
objects
Posted by sb...@apache.org.
Restored backward compatibility for cache objects
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/38b3ffda
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/38b3ffda
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/38b3ffda
Branch: refs/heads/ignite-1093
Commit: 38b3ffdaf2944cb908c45e22e3a1b1b834cf3b6c
Parents: 2938a9b
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Aug 26 15:39:12 2015 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Aug 26 15:39:12 2015 -0700
----------------------------------------------------------------------
.../processors/cacheobject/IgniteCacheObjectProcessor.java | 2 +-
.../processors/cacheobject/IgniteCacheObjectProcessorImpl.java | 2 +-
.../ignite/internal/processors/query/GridQueryProcessor.java | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/38b3ffda/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
index dc0d1e5..b9b6132 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
@@ -78,7 +78,7 @@ public interface IgniteCacheObjectProcessor extends GridProcessor {
*
* @return {@code true} If portable objects are enabled.
*/
- public boolean isPortableEnabled();
+ public boolean isPortableEnabled(CacheConfiguration<?, ?> ccfg);
/**
* @param obj Portable object to get field from.
http://git-wip-us.apache.org/repos/asf/ignite/blob/38b3ffda/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index 3e59b10..e8f7781 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -233,7 +233,7 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
}
/** {@inheritDoc} */
- @Override public boolean isPortableEnabled() {
+ @Override public boolean isPortableEnabled(CacheConfiguration<?, ?> ccfg) {
return false;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/38b3ffda/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index f3ad4b2..c8b8166 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -140,7 +140,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
TypeId typeId;
- if (valCls == null || ctx.cacheObjects().isPortableEnabled()) {
+ if (valCls == null || ctx.cacheObjects().isPortableEnabled(ccfg)) {
processPortableMeta(meta, desc);
typeId = new TypeId(ccfg.getName(), ctx.cacheObjects().typeId(meta.getValueType()));
[35/41] ignite git commit: Moved platform cache iterator to Ignite.
Posted by sb...@apache.org.
Moved platform cache iterator to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/136c099b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/136c099b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/136c099b
Branch: refs/heads/ignite-1093
Commit: 136c099bf4ff1ba400e711dbad34216633b9236a
Parents: e428206
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Aug 27 09:20:44 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Aug 27 09:20:44 2015 +0300
----------------------------------------------------------------------
.../platform/cache/PlatformCacheIterator.java | 72 ++++++++++++++++++++
1 file changed, 72 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/136c099b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheIterator.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheIterator.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheIterator.java
new file mode 100644
index 0000000..45e777d
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheIterator.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.platform.*;
+
+import javax.cache.*;
+import java.util.*;
+
+/**
+ * Interop cache iterator.
+ */
+public class PlatformCacheIterator extends PlatformAbstractTarget {
+ /** Operation: next entry. */
+ private static final int OP_NEXT = 1;
+
+ /** Iterator. */
+ private final Iterator<Cache.Entry> iter;
+
+ /**
+ * Constructor.
+ *
+ * @param platformCtx Context.
+ * @param iter Iterator.
+ */
+ public PlatformCacheIterator(PlatformContext platformCtx, Iterator<Cache.Entry> iter) {
+ super(platformCtx);
+
+ this.iter = iter;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void processOutOp(int type, PortableRawWriterEx writer) throws IgniteCheckedException {
+ switch (type) {
+ case OP_NEXT:
+ if (iter.hasNext()) {
+ Cache.Entry e = iter.next();
+
+ assert e != null;
+
+ writer.writeBoolean(true);
+
+ writer.writeObjectDetached(e.getKey());
+ writer.writeObjectDetached(e.getValue());
+ }
+ else
+ writer.writeBoolean(false);
+
+ break;
+
+ default:
+ throwUnsupported(type);
+ }
+ }
+}
[02/41] ignite git commit: IGNITE-1281 Fixed direct marshalling logic
for last-removed field. Closes #32
Posted by sb...@apache.org.
IGNITE-1281 Fixed direct marshalling logic for last-removed field. Closes #32
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/89e94b63
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/89e94b63
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/89e94b63
Branch: refs/heads/ignite-1093
Commit: 89e94b6308ee0b4c47e8d72417e238f8eb4a59a2
Parents: 3d0dac6
Author: Alexey Goncharuk <ag...@apache.org>
Authored: Tue Aug 25 16:40:59 2015 -0700
Committer: Alexey Goncharuk <ag...@gridgain.com>
Committed: Tue Aug 25 16:40:59 2015 -0700
----------------------------------------------------------------------
.../ignite/codegen/MessageCodeGenerator.java | 30 +++++++++++++-------
.../ignite/internal/GridJobCancelRequest.java | 2 +-
.../ignite/internal/GridJobExecuteRequest.java | 2 +-
.../ignite/internal/GridJobExecuteResponse.java | 2 +-
.../ignite/internal/GridJobSiblingsRequest.java | 2 +-
.../internal/GridJobSiblingsResponse.java | 2 +-
.../ignite/internal/GridTaskCancelRequest.java | 2 +-
.../ignite/internal/GridTaskSessionRequest.java | 2 +-
.../internal/direct/DirectByteBufferStream.java | 2 +-
.../internal/direct/DirectMessageReader.java | 6 ++++
.../checkpoint/GridCheckpointRequest.java | 2 +-
.../managers/communication/GridIoManager.java | 2 +-
.../managers/communication/GridIoMessage.java | 8 ++----
.../communication/GridIoUserMessage.java | 2 +-
.../deployment/GridDeploymentInfoBean.java | 2 +-
.../deployment/GridDeploymentRequest.java | 2 +-
.../deployment/GridDeploymentResponse.java | 2 +-
.../eventstorage/GridEventStorageMessage.java | 2 +-
.../affinity/AffinityTopologyVersion.java | 2 +-
.../cache/CacheEntryInfoCollection.java | 2 +-
.../cache/CacheEntryPredicateAdapter.java | 2 +-
.../cache/CacheEntryPredicateContainsValue.java | 2 +-
.../cache/CacheEntrySerializablePredicate.java | 2 +-
.../processors/cache/CacheEvictionEntry.java | 2 +-
.../cache/CacheInvokeDirectResult.java | 2 +-
.../processors/cache/CacheObjectAdapter.java | 2 +-
.../cache/CacheObjectByteArrayImpl.java | 2 +-
.../processors/cache/GridCacheEntryInfo.java | 2 +-
.../cache/GridCacheEvictionRequest.java | 2 +-
.../cache/GridCacheEvictionResponse.java | 2 +-
.../processors/cache/GridCacheMessage.java | 2 +-
.../processors/cache/GridCacheReturn.java | 2 +-
.../distributed/GridCacheTtlUpdateRequest.java | 3 +-
.../distributed/GridCacheTxRecoveryRequest.java | 2 +-
.../GridCacheTxRecoveryResponse.java | 2 +-
.../distributed/GridDistributedBaseMessage.java | 2 +-
.../distributed/GridDistributedLockRequest.java | 2 +-
.../GridDistributedLockResponse.java | 2 +-
.../GridDistributedTxFinishRequest.java | 8 ++----
.../GridDistributedTxFinishResponse.java | 2 +-
.../GridDistributedTxPrepareRequest.java | 8 ++----
.../GridDistributedTxPrepareResponse.java | 2 +-
.../GridDistributedUnlockRequest.java | 2 +-
.../dht/GridDhtAffinityAssignmentRequest.java | 2 +-
.../dht/GridDhtAffinityAssignmentResponse.java | 2 +-
.../distributed/dht/GridDhtLockRequest.java | 6 ++--
.../distributed/dht/GridDhtLockResponse.java | 2 +-
.../distributed/dht/GridDhtTxFinishRequest.java | 2 +-
.../dht/GridDhtTxFinishResponse.java | 2 +-
.../dht/GridDhtTxPrepareRequest.java | 2 +-
.../dht/GridDhtTxPrepareResponse.java | 2 +-
.../distributed/dht/GridDhtUnlockRequest.java | 2 +-
.../GridDhtAtomicDeferredUpdateResponse.java | 2 +-
.../dht/atomic/GridDhtAtomicUpdateRequest.java | 2 +-
.../dht/atomic/GridDhtAtomicUpdateResponse.java | 2 +-
.../dht/atomic/GridNearAtomicUpdateRequest.java | 2 +-
.../atomic/GridNearAtomicUpdateResponse.java | 2 +-
.../dht/preloader/GridDhtForceKeysRequest.java | 3 +-
.../dht/preloader/GridDhtForceKeysResponse.java | 4 +--
.../GridDhtPartitionDemandMessage.java | 2 +-
.../preloader/GridDhtPartitionExchangeId.java | 2 +-
.../GridDhtPartitionSupplyMessage.java | 2 +-
.../GridDhtPartitionsAbstractMessage.java | 2 +-
.../preloader/GridDhtPartitionsFullMessage.java | 2 +-
.../GridDhtPartitionsSingleMessage.java | 2 +-
.../GridDhtPartitionsSingleRequest.java | 2 +-
.../distributed/near/CacheVersionedValue.java | 2 +-
.../distributed/near/GridNearGetRequest.java | 2 +-
.../distributed/near/GridNearGetResponse.java | 2 +-
.../distributed/near/GridNearLockRequest.java | 2 +-
.../distributed/near/GridNearLockResponse.java | 2 +-
.../near/GridNearTxFinishRequest.java | 2 +-
.../near/GridNearTxFinishResponse.java | 2 +-
.../near/GridNearTxPrepareRequest.java | 2 +-
.../near/GridNearTxPrepareResponse.java | 2 +-
.../distributed/near/GridNearUnlockRequest.java | 2 +-
.../cache/query/GridCacheQueryRequest.java | 2 +-
.../cache/query/GridCacheQueryResponse.java | 2 +-
.../cache/query/GridCacheSqlQuery.java | 9 ++++--
.../continuous/CacheContinuousQueryEntry.java | 2 +-
.../cache/transactions/IgniteTxEntry.java | 2 +-
.../cache/transactions/IgniteTxKey.java | 2 +-
.../cache/transactions/TxEntryValueHolder.java | 2 +-
.../version/GridCacheRawVersionedEntry.java | 2 +-
.../cache/version/GridCacheVersion.java | 2 +-
.../cache/version/GridCacheVersionEx.java | 2 +-
.../clock/GridClockDeltaSnapshotMessage.java | 2 +-
.../processors/clock/GridClockDeltaVersion.java | 2 +-
.../continuous/GridContinuousMessage.java | 2 +-
.../datastreamer/DataStreamerEntry.java | 2 +-
.../datastreamer/DataStreamerRequest.java | 2 +-
.../datastreamer/DataStreamerResponse.java | 2 +-
.../processors/igfs/IgfsAckMessage.java | 2 +-
.../internal/processors/igfs/IgfsBlockKey.java | 2 +-
.../processors/igfs/IgfsBlocksMessage.java | 2 +-
.../igfs/IgfsCommunicationMessage.java | 2 +-
.../processors/igfs/IgfsDeleteMessage.java | 2 +-
.../processors/igfs/IgfsFileAffinityRange.java | 9 ++++--
.../igfs/IgfsFragmentizerRequest.java | 2 +-
.../igfs/IgfsFragmentizerResponse.java | 2 +-
.../processors/igfs/IgfsSyncMessage.java | 2 +-
.../messages/GridQueryCancelRequest.java | 2 +-
.../twostep/messages/GridQueryFailResponse.java | 2 +-
.../messages/GridQueryNextPageRequest.java | 2 +-
.../messages/GridQueryNextPageResponse.java | 3 +-
.../h2/twostep/messages/GridQueryRequest.java | 5 +++-
.../handlers/task/GridTaskResultRequest.java | 2 +-
.../handlers/task/GridTaskResultResponse.java | 2 +-
.../ignite/internal/util/GridByteArrayList.java | 2 +-
.../ignite/internal/util/GridLongList.java | 2 +-
.../internal/util/nio/GridDirectParser.java | 2 +-
.../communication/MessageFormatter.java | 3 +-
.../extensions/communication/MessageReader.java | 13 +++++++++
.../org/apache/ignite/spi/IgniteSpiAdapter.java | 2 +-
.../jobstealing/JobStealingRequest.java | 2 +-
.../communication/tcp/TcpCommunicationSpi.java | 8 +++---
.../testframework/GridSpiTestContext.java | 2 +-
117 files changed, 176 insertions(+), 152 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java
----------------------------------------------------------------------
diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java
index 0540148..cdbbd9e 100644
--- a/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java
+++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java
@@ -142,6 +142,8 @@ public class MessageCodeGenerator {
MessageCodeGenerator gen = new MessageCodeGenerator(srcDir);
+ gen.generateAll(true);
+
// gen.generateAndWrite(DataStreamerEntry.class);
// gen.generateAndWrite(GridDistributedLockRequest.class);
@@ -213,14 +215,19 @@ public class MessageCodeGenerator {
Collection<Class<? extends Message>> classes = classes();
for (Class<? extends Message> cls : classes) {
- boolean isAbstract = Modifier.isAbstract(cls.getModifiers());
+ try {
+ boolean isAbstract = Modifier.isAbstract(cls.getModifiers());
- System.out.println("Processing class: " + cls.getName() + (isAbstract ? " (abstract)" : ""));
+ System.out.println("Processing class: " + cls.getName() + (isAbstract ? " (abstract)" : ""));
- if (write)
- generateAndWrite(cls);
- else
- generate(cls);
+ if (write)
+ generateAndWrite(cls);
+ else
+ generate(cls);
+ }
+ catch (IllegalStateException e) {
+ System.out.println("Will skip class generation [cls=" + cls + ", err=" + e.getMessage() + ']');
+ }
}
}
@@ -370,8 +377,8 @@ public class MessageCodeGenerator {
indent--;
- finish(write);
- finish(read);
+ finish(write, null);
+ finish(read, cls.getSimpleName());
}
/**
@@ -460,7 +467,7 @@ public class MessageCodeGenerator {
/**
* @param code Code lines.
*/
- private void finish(Collection<String> code) {
+ private void finish(Collection<String> code, String readClsName) {
assert code != null;
if (!fields.isEmpty()) {
@@ -468,7 +475,10 @@ public class MessageCodeGenerator {
code.add(EMPTY);
}
- code.add(builder().a("return true;").toString());
+ if (readClsName == null)
+ code.add(builder().a("return true;").toString());
+ else
+ code.add(builder().a("return reader.afterMessageRead(").a(readClsName).a(".class);").toString());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java
index 005fff0..9766171 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java
@@ -178,7 +178,7 @@ public class GridJobCancelRequest implements Message {
}
- return true;
+ return reader.afterMessageRead(GridJobCancelRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java
index 617762c..667f620 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java
@@ -738,7 +738,7 @@ public class GridJobExecuteRequest implements Message {
}
- return true;
+ return reader.afterMessageRead(GridJobExecuteRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java
index 459ba76..be1f929 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java
@@ -329,7 +329,7 @@ public class GridJobExecuteResponse implements Message {
}
- return true;
+ return reader.afterMessageRead(GridJobExecuteResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java
index 36fc1dd..71fe5a7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java
@@ -138,7 +138,7 @@ public class GridJobSiblingsRequest implements Message {
}
- return true;
+ return reader.afterMessageRead(GridJobSiblingsRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
index c558f74..6ca0586 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
@@ -117,7 +117,7 @@ public class GridJobSiblingsResponse implements Message {
}
- return true;
+ return reader.afterMessageRead(GridJobSiblingsResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java
index a2a0e6c..32e082f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java
@@ -101,7 +101,7 @@ public class GridTaskCancelRequest implements Message {
}
- return true;
+ return reader.afterMessageRead(GridTaskCancelRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java
index b150a60..42e1506 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java
@@ -166,7 +166,7 @@ public class GridTaskSessionRequest implements Message {
}
- return true;
+ return reader.afterMessageRead(GridTaskSessionRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java
index 120350b..02b6be9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java
@@ -945,7 +945,7 @@ public class DirectByteBufferStream {
msg = type == Byte.MIN_VALUE ? null : msgFactory.create(type);
if (msg != null)
- reader = msgFormatter.reader(msgFactory);
+ reader = msgFormatter.reader(msgFactory, msg.getClass());
msgTypeDone = true;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
index 669ace1..91fb43f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
@@ -55,6 +55,12 @@ public class DirectMessageReader implements MessageReader {
return true;
}
+ /** {@inheritDoc}
+ * @param msgCls*/
+ @Override public boolean afterMessageRead(Class<? extends Message> msgCls) {
+ return true;
+ }
+
/** {@inheritDoc} */
@Override public byte readByte(String name) {
byte val = stream.readByte();
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java
index 8f97bf1..fdc3ee6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java
@@ -152,7 +152,7 @@ public class GridCheckpointRequest implements Message {
}
- return true;
+ return reader.afterMessageRead(GridCheckpointRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index 85e8421..6698f4f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -235,7 +235,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
return new DirectMessageWriter();
}
- @Override public MessageReader reader(MessageFactory factory) {
+ @Override public MessageReader reader(MessageFactory factory, Class<? extends Message> msgCls) {
return new DirectMessageReader(msgFactory, this);
}
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
index 6cf1ae5..844b62b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
@@ -261,15 +261,11 @@ public class GridIoMessage implements Message {
reader.incrementState();
case 2:
- byte plc0;
-
- plc0 = reader.readByte("plc");
+ plc = reader.readByte("plc");
if (!reader.isLastRead())
return false;
- plc = plc0;
-
reader.incrementState();
case 3:
@@ -306,7 +302,7 @@ public class GridIoMessage implements Message {
}
- return true;
+ return reader.afterMessageRead(GridIoMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java
index 05b9181..dff4197 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java
@@ -331,7 +331,7 @@ public class GridIoUserMessage implements Message {
}
- return true;
+ return reader.afterMessageRead(GridIoUserMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java
index a62d4da..28ad0aa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java
@@ -237,7 +237,7 @@ public class GridDeploymentInfoBean implements Message, GridDeploymentInfo, Exte
}
- return true;
+ return reader.afterMessageRead(GridDeploymentInfoBean.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java
index a6d80bb..1eec2c3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java
@@ -252,7 +252,7 @@ public class GridDeploymentRequest implements Message {
}
- return true;
+ return reader.afterMessageRead(GridDeploymentRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java
index 175e85f..f91bf27 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java
@@ -174,7 +174,7 @@ public class GridDeploymentResponse implements Message {
}
- return true;
+ return reader.afterMessageRead(GridDeploymentResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java
index 6f18aa6..dc80832 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java
@@ -417,7 +417,7 @@ public class GridEventStorageMessage implements Message {
}
- return true;
+ return reader.afterMessageRead(GridEventStorageMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityTopologyVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityTopologyVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityTopologyVersion.java
index 650c047..40dc64d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityTopologyVersion.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityTopologyVersion.java
@@ -177,7 +177,7 @@ public class AffinityTopologyVersion implements Comparable<AffinityTopologyVersi
}
- return true;
+ return reader.afterMessageRead(AffinityTopologyVersion.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java
index 52158f0..e346ec2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java
@@ -96,7 +96,7 @@ public class CacheEntryInfoCollection implements Message {
}
- return true;
+ return reader.afterMessageRead(CacheEntryInfoCollection.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
index c5b20b4..6253fcf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
@@ -64,7 +64,7 @@ public abstract class CacheEntryPredicateAdapter implements CacheEntryPredicate
if (!reader.beforeMessageRead())
return false;
- return true;
+ return reader.afterMessageRead(CacheEntryPredicateAdapter.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java
index c9fdf9f..03ff850 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java
@@ -118,7 +118,7 @@ public class CacheEntryPredicateContainsValue extends CacheEntryPredicateAdapter
}
- return true;
+ return reader.afterMessageRead(CacheEntryPredicateContainsValue.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
index 0c07bfd..23ec70a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
@@ -137,7 +137,7 @@ public class CacheEntrySerializablePredicate implements CacheEntryPredicate {
}
- return true;
+ return reader.afterMessageRead(CacheEntrySerializablePredicate.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionEntry.java
index 6d3ad5e..434a241 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionEntry.java
@@ -172,7 +172,7 @@ public class CacheEvictionEntry implements Message {
}
- return true;
+ return reader.afterMessageRead(CacheEvictionEntry.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
index 7b153d3..7b3a998e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
@@ -198,7 +198,7 @@ public class CacheInvokeDirectResult implements Message {
}
- return true;
+ return reader.afterMessageRead(CacheInvokeDirectResult.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
index 173483d..6b2f46d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
@@ -80,7 +80,7 @@ public abstract class CacheObjectAdapter implements CacheObject, Externalizable
}
- return true;
+ return reader.afterMessageRead(CacheObjectAdapter.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
index 96b838c..ecd4c43 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
@@ -126,7 +126,7 @@ public class CacheObjectByteArrayImpl implements CacheObject, Externalizable {
}
- return true;
+ return reader.afterMessageRead(CacheObjectByteArrayImpl.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
index 4845635..3303cfc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
@@ -317,7 +317,7 @@ public class GridCacheEntryInfo implements Message {
}
- return true;
+ return reader.afterMessageRead(GridCacheEntryInfo.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java
index fba0771..3097114 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java
@@ -220,7 +220,7 @@ public class GridCacheEvictionRequest extends GridCacheMessage implements GridCa
}
- return true;
+ return reader.afterMessageRead(GridCacheEvictionRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java
index cd10e11..94a3e60 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java
@@ -198,7 +198,7 @@ public class GridCacheEvictionResponse extends GridCacheMessage {
}
- return true;
+ return reader.afterMessageRead(GridCacheEvictionResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
index 8ebce35..67ac33d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
@@ -635,7 +635,7 @@ public abstract class GridCacheMessage implements Message {
}
- return true;
+ return reader.afterMessageRead(GridCacheMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
index 743d42c..073dd2e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
@@ -425,7 +425,7 @@ public class GridCacheReturn implements Externalizable, Message {
}
- return true;
+ return reader.afterMessageRead(GridCacheReturn.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java
index 3ff7aa8..4c98c73 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java
@@ -25,7 +25,6 @@ import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.util.tostring.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.plugin.extensions.communication.*;
-import org.jetbrains.annotations.*;
import java.nio.*;
import java.util.*;
@@ -305,7 +304,7 @@ public class GridCacheTtlUpdateRequest extends GridCacheMessage {
}
- return true;
+ return reader.afterMessageRead(GridCacheTtlUpdateRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryRequest.java
index 2f49ef4..07aecee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryRequest.java
@@ -241,7 +241,7 @@ public class GridCacheTxRecoveryRequest extends GridDistributedBaseMessage {
}
- return true;
+ return reader.afterMessageRead(GridCacheTxRecoveryRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryResponse.java
index 99b676a..6218da6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryResponse.java
@@ -162,7 +162,7 @@ public class GridCacheTxRecoveryResponse extends GridDistributedBaseMessage {
}
- return true;
+ return reader.afterMessageRead(GridCacheTxRecoveryResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java
index 7b84f32..3292583 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java
@@ -275,7 +275,7 @@ public abstract class GridDistributedBaseMessage extends GridCacheMessage implem
}
- return true;
+ return reader.afterMessageRead(GridDistributedBaseMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
index ecf3259..8bcf813 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
@@ -525,7 +525,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
}
- return true;
+ return reader.afterMessageRead(GridDistributedLockRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
index 295506a..de5eb63 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
@@ -303,7 +303,7 @@ public class GridDistributedLockResponse extends GridDistributedBaseMessage {
}
- return true;
+ return reader.afterMessageRead(GridDistributedLockResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
index 7a84f9a..63f7f16 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
@@ -359,15 +359,11 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
reader.incrementState();
case 12:
- byte plcOrd;
-
- plcOrd = reader.readByte("plc");
+ plc = reader.readByte("plc");
if (!reader.isLastRead())
return false;
- plc = plcOrd;
-
reader.incrementState();
case 13:
@@ -412,7 +408,7 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
}
- return true;
+ return reader.afterMessageRead(GridDistributedTxFinishRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java
index b016cdd..88b8c71 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java
@@ -134,7 +134,7 @@ public class GridDistributedTxFinishResponse extends GridCacheMessage {
}
- return true;
+ return reader.afterMessageRead(GridDistributedTxFinishResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
index 20aa833..25f267d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
@@ -502,15 +502,11 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
case 13:
- byte plcOrd;
-
- plcOrd = reader.readByte("plc");
+ plc = reader.readByte("plc");
if (!reader.isLastRead())
return false;
- plc = plcOrd;
-
reader.incrementState();
case 14:
@@ -579,7 +575,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
}
- return true;
+ return reader.afterMessageRead(GridDistributedTxPrepareRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
index f920e48..0f74780 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
@@ -151,7 +151,7 @@ public class GridDistributedTxPrepareResponse extends GridDistributedBaseMessage
}
- return true;
+ return reader.afterMessageRead(GridDistributedTxPrepareResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java
index 7f31b06..a88ca6b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java
@@ -138,7 +138,7 @@ public class GridDistributedUnlockRequest extends GridDistributedBaseMessage {
}
- return true;
+ return reader.afterMessageRead(GridDistributedUnlockRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
index 2f3fa23..c3025e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
@@ -125,7 +125,7 @@ public class GridDhtAffinityAssignmentRequest extends GridCacheMessage {
}
- return true;
+ return reader.afterMessageRead(GridDhtAffinityAssignmentRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
index 4fc1b87..67919b3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
@@ -199,7 +199,7 @@ public class GridDhtAffinityAssignmentResponse extends GridCacheMessage {
}
- return true;
+ return reader.afterMessageRead(GridDhtAffinityAssignmentResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
index 7ce38f7..de4c9ef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
@@ -465,9 +465,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 25:
- ownedValues = reader.readObjectArray("ownedValues",
- MessageCollectionItemType.MSG,
- GridCacheVersion.class);
+ ownedValues = reader.readObjectArray("ownedValues", MessageCollectionItemType.MSG, GridCacheVersion.class);
if (!reader.isLastRead())
return false;
@@ -508,7 +506,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
}
- return true;
+ return reader.afterMessageRead(GridDhtLockRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java
index 8c9f32c..505a63c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java
@@ -268,7 +268,7 @@ public class GridDhtLockResponse extends GridDistributedLockResponse {
}
- return true;
+ return reader.afterMessageRead(GridDhtLockResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
index fe72b24..f2b5317 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
@@ -385,7 +385,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
}
- return true;
+ return reader.afterMessageRead(GridDhtTxFinishRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
index 5eff453..c6ac483 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
@@ -115,7 +115,7 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
}
- return true;
+ return reader.afterMessageRead(GridDhtTxFinishResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
index 909080d..7a7769d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
@@ -533,7 +533,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
}
- return true;
+ return reader.afterMessageRead(GridDhtTxPrepareRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java
index bcf7f8b..da03521 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java
@@ -345,7 +345,7 @@ public class GridDhtTxPrepareResponse extends GridDistributedTxPrepareResponse {
}
- return true;
+ return reader.afterMessageRead(GridDhtTxPrepareResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java
index f7f8167..eedcdb4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java
@@ -142,7 +142,7 @@ public class GridDhtUnlockRequest extends GridDistributedUnlockRequest {
}
- return true;
+ return reader.afterMessageRead(GridDhtUnlockRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java
index 1163761..db14b3d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java
@@ -119,7 +119,7 @@ public class GridDhtAtomicDeferredUpdateResponse extends GridCacheMessage implem
}
- return true;
+ return reader.afterMessageRead(GridDhtAtomicDeferredUpdateResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
index f83b8fa..514ab5b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
@@ -884,7 +884,7 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements Grid
}
- return true;
+ return reader.afterMessageRead(GridDhtAtomicUpdateRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
index c5b5a37..8a2befb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
@@ -262,7 +262,7 @@ public class GridDhtAtomicUpdateResponse extends GridCacheMessage implements Gri
}
- return true;
+ return reader.afterMessageRead(GridDhtAtomicUpdateResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
index 86c5ab8..670995b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
@@ -921,7 +921,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
}
- return true;
+ return reader.afterMessageRead(GridNearAtomicUpdateRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
index 330e43c..3bf99c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
@@ -602,7 +602,7 @@ public class GridNearAtomicUpdateResponse extends GridCacheMessage implements Gr
}
- return true;
+ return reader.afterMessageRead(GridNearAtomicUpdateResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java
index 29823f9..83d139c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java
@@ -26,7 +26,6 @@ import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.plugin.extensions.communication.*;
-import org.jetbrains.annotations.*;
import java.io.*;
import java.nio.*;
@@ -243,7 +242,7 @@ public class GridDhtForceKeysRequest extends GridCacheMessage implements GridCac
}
- return true;
+ return reader.afterMessageRead(GridDhtForceKeysRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
index 41ce0be..8bb6b3a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
@@ -82,7 +82,7 @@ public class GridDhtForceKeysResponse extends GridCacheMessage implements GridCa
/**
* Sets error.
- * @param err
+ * @param err Error.
*/
public void error(IgniteCheckedException err){
this.err = err;
@@ -288,7 +288,7 @@ public class GridDhtForceKeysResponse extends GridCacheMessage implements GridCa
}
- return true;
+ return reader.afterMessageRead(GridDhtForceKeysResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
index a849b54..4beee06 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
@@ -308,7 +308,7 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
}
- return true;
+ return reader.afterMessageRead(GridDhtPartitionDemandMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java
index 8a3287c..3320d62 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java
@@ -217,7 +217,7 @@ public class GridDhtPartitionExchangeId implements Message, Comparable<GridDhtPa
}
- return true;
+ return reader.afterMessageRead(GridDhtPartitionExchangeId.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
index 75846a1..bda526b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
@@ -374,7 +374,7 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
}
- return true;
+ return reader.afterMessageRead(GridDhtPartitionSupplyMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java
index 5a8616d..ff40daa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java
@@ -140,7 +140,7 @@ abstract class GridDhtPartitionsAbstractMessage extends GridCacheMessage {
}
- return true;
+ return reader.afterMessageRead(GridDhtPartitionsAbstractMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
index 73794ae..c285215 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
@@ -180,7 +180,7 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
}
- return true;
+ return reader.afterMessageRead(GridDhtPartitionsFullMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
index 713a80b..d9633d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
@@ -170,7 +170,7 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
}
- return true;
+ return reader.afterMessageRead(GridDhtPartitionsSingleMessage.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java
index 7578e97..0b443f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java
@@ -71,7 +71,7 @@ public class GridDhtPartitionsSingleRequest extends GridDhtPartitionsAbstractMes
if (!super.readFrom(buf, reader))
return false;
- return true;
+ return reader.afterMessageRead(GridDhtPartitionsSingleRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java
index 97b96c8..745ca17 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java
@@ -149,7 +149,7 @@ public class CacheVersionedValue implements Message {
}
- return true;
+ return reader.afterMessageRead(CacheVersionedValue.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java
index 93c869d..4b52e69 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java
@@ -461,7 +461,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
}
- return true;
+ return reader.afterMessageRead(GridNearGetRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
index 73d877a..25a6969 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
@@ -331,7 +331,7 @@ public class GridNearGetResponse extends GridCacheMessage implements GridCacheDe
}
- return true;
+ return reader.afterMessageRead(GridNearGetResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
index 4776963..4440e89 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
@@ -577,7 +577,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
}
- return true;
+ return reader.afterMessageRead(GridNearLockRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java
index 62002dc..110501b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java
@@ -307,7 +307,7 @@ public class GridNearLockResponse extends GridDistributedLockResponse {
}
- return true;
+ return reader.afterMessageRead(GridNearLockResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
index 26e4bdc..5730357 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
@@ -271,7 +271,7 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
}
- return true;
+ return reader.afterMessageRead(GridNearTxFinishRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
index 68e23ce..84f4f46 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
@@ -188,7 +188,7 @@ public class GridNearTxFinishResponse extends GridDistributedTxFinishResponse {
}
- return true;
+ return reader.afterMessageRead(GridNearTxFinishResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
index 4cc8f91..f018d18 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
@@ -470,7 +470,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
}
- return true;
+ return reader.afterMessageRead(GridNearTxPrepareRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java
index b24c62d..6f8e334 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java
@@ -514,7 +514,7 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse
}
- return true;
+ return reader.afterMessageRead(GridNearTxPrepareResponse.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java
index 292e04d..14f468f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java
@@ -73,7 +73,7 @@ public class GridNearUnlockRequest extends GridDistributedUnlockRequest {
if (!super.readFrom(buf, reader))
return false;
- return true;
+ return reader.afterMessageRead(GridNearUnlockRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
index 2113e7a..76ddebd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
@@ -732,7 +732,7 @@ public class GridCacheQueryRequest extends GridCacheMessage implements GridCache
}
- return true;
+ return reader.afterMessageRead(GridCacheQueryRequest.class);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/89e94b63/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
index 1988cff..95f7dfa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
@@ -318,7 +318,7 @@ public class GridCacheQueryResponse extends GridCacheMessage implements GridCach
}
- return true;
+ return reader.afterMessageRead(GridCacheQueryResponse.class);
}
/** {@inheritDoc} */
[17/41] ignite git commit: IGNITE-1292: Moved handle registry to
Ignite. Contributed by Pavel Tupitsyn.
Posted by sb...@apache.org.
IGNITE-1292: Moved handle registry to Ignite.
Contributed by Pavel Tupitsyn.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7c351bf3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7c351bf3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7c351bf3
Branch: refs/heads/ignite-1093
Commit: 7c351bf3e0ef5fd28b88d9a279a32f4796a60c91
Parents: 08be80f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 12:10:32 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 12:10:32 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.csproj | 3 +
.../Apache.Ignite.Core/Impl/Handle/Handle.cs | 69 ++++
.../Impl/Handle/HandleRegistry.cs | 340 +++++++++++++++++++
.../Apache.Ignite.Core/Impl/Handle/IHandle.cs | 35 ++
4 files changed, 447 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c351bf3/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index c6c8324..658e5fb 100644
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -48,6 +48,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Ignition.cs" />
+ <Compile Include="Impl\Handle\Handle.cs" />
+ <Compile Include="Impl\Handle\HandleRegistry.cs" />
+ <Compile Include="Impl\Handle\IHandle.cs" />
<Compile Include="Impl\Memory\IPlatformMemory.cs" />
<Compile Include="Impl\Memory\PlatformBigEndianMemoryStream.cs" />
<Compile Include="Impl\Memory\PlatformMemory.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c351bf3/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
new file mode 100644
index 0000000..0168963
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Handle
+{
+ using System;
+ using System.Threading;
+
+ /// <summary>
+ /// Wrapper over some resource ensuring it's release.
+ /// </summary>
+ public class Handle<T> : IHandle
+ {
+ /** Target.*/
+ private readonly T _target;
+
+ /** Release action. */
+ private readonly Action<T> _releaseAction;
+
+ /** Release flag. */
+ private int _released;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="target">Target.</param>
+ /// <param name="releaseAction">Release action.</param>
+ public Handle(T target, Action<T> releaseAction)
+ {
+ _target = target;
+ _releaseAction = releaseAction;
+ }
+
+ /// <summary>
+ /// Target.
+ /// </summary>
+ public T Target
+ {
+ get { return _target; }
+ }
+
+ /** <inheritdoc /> */
+ public void Release()
+ {
+ if (Interlocked.CompareExchange(ref _released, 1, 0) == 0)
+ _releaseAction(_target);
+ }
+
+ /** <inheritdoc /> */
+ public bool Released
+ {
+ get { return Thread.VolatileRead(ref _released) == 1; }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c351bf3/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
new file mode 100644
index 0000000..2a67c41
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
@@ -0,0 +1,340 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Handle
+{
+ using System;
+ using System.Collections.Concurrent;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading;
+
+ /// <summary>
+ /// Resource registry.
+ /// </summary>
+ public class HandleRegistry
+ {
+ /** Default critical resources capacity. */
+ internal const int DfltFastCap = 1024;
+
+ /** Array for fast-path. */
+ private readonly object[] _fast;
+
+ /** Dictionery for slow-path. */
+ private readonly ConcurrentDictionary<long, object> _slow;
+
+ /** Capacity of fast array. */
+ private readonly int _fastCap;
+
+ /** Counter for fast-path. */
+ private int _fastCtr;
+
+ /** Counter for slow-path. */
+ private long _slowCtr;
+
+ /** Close flag. */
+ private int _closed;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public HandleRegistry() : this(DfltFastCap)
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fastCap">Amount of critical resources this registry can allocate in "fast" mode.</param>
+ public HandleRegistry(int fastCap)
+ {
+ _fastCap = fastCap;
+ _fast = new object[fastCap];
+
+ _slow = new ConcurrentDictionary<long, object>();
+ _slowCtr = fastCap;
+ }
+
+ /// <summary>
+ /// Allocate a handle for resource.
+ /// </summary>
+ /// <param name="target">Target.</param>
+ /// <returns>Pointer.</returns>
+ public long Allocate(object target)
+ {
+ return Allocate0(target, false, false);
+ }
+
+ /// <summary>
+ /// Allocate a handle in safe mode.
+ /// </summary>
+ /// <param name="target">Target.</param>
+ /// <returns>Pointer.</returns>
+ public long AllocateSafe(object target)
+ {
+ return Allocate0(target, false, true);
+ }
+
+ /// <summary>
+ /// Allocate a handle for critical resource.
+ /// </summary>
+ /// <param name="target">Target.</param>
+ /// <returns>Pointer.</returns>
+ public long AllocateCritical(object target)
+ {
+ return Allocate0(target, true, false);
+ }
+
+ /// <summary>
+ /// Allocate a handle for critical resource in safe mode.
+ /// </summary>
+ /// <param name="target">Target.</param>
+ /// <returns>Pointer.</returns>
+ public long AllocateCriticalSafe(object target)
+ {
+ return Allocate0(target, true, true);
+ }
+
+ /// <summary>
+ /// Internal allocation routine.
+ /// </summary>
+ /// <param name="target">Target.</param>
+ /// <param name="critical">Critical flag.</param>
+ /// <param name="safe">Safe flag.</param>
+ /// <returns>Pointer.</returns>
+ private long Allocate0(object target, bool critical, bool safe)
+ {
+ if (Closed)
+ throw ClosedException();
+
+ // Try allocating on critical path.
+ if (critical)
+ {
+ if (_fastCtr < _fastCap) // Non-volatile read could yield in old value, but increment resolves this.
+ {
+ int fastIdx = Interlocked.Increment(ref _fastCtr);
+
+ if (fastIdx < _fastCap)
+ {
+ Thread.VolatileWrite(ref _fast[fastIdx], target);
+
+ if (safe && Closed)
+ {
+ Thread.VolatileWrite(ref _fast[fastIdx], null);
+
+ Release0(target, true);
+
+ throw ClosedException();
+ }
+
+ return fastIdx;
+ }
+ }
+ }
+
+ // Critical allocation failed, fallback to slow mode.
+ long slowIdx = Interlocked.Increment(ref _slowCtr);
+
+ _slow[slowIdx] = target;
+
+ if (safe && Closed)
+ {
+ _slow[slowIdx] = null;
+
+ Release0(target, true);
+
+ throw ClosedException();
+ }
+
+ return slowIdx;
+ }
+
+
+ /// <summary>
+ /// Release handle.
+ /// </summary>
+ /// <param name="id">Identifier.</param>
+ /// <param name="quiet">Whether release must be quiet or not.</param>
+ public void Release(long id, bool quiet = false)
+ {
+ if (id < _fastCap)
+ {
+ object target = Thread.VolatileRead(ref _fast[id]);
+
+ if (target != null)
+ {
+ Thread.VolatileWrite(ref _fast[id], null);
+
+ Release0(target, quiet);
+ }
+ }
+ else
+ {
+ object target;
+
+ if (_slow.TryRemove(id, out target))
+ Release0(target, quiet);
+ }
+ }
+
+ /// <summary>
+ /// Internal release routine.
+ /// </summary>
+ /// <param name="target">Target.</param>
+ /// <param name="quiet">Whether release must be quiet or not.</param>
+ private static void Release0(object target, bool quiet)
+ {
+ IHandle target0 = target as IHandle;
+
+ if (target0 != null)
+ {
+ if (quiet)
+ {
+ try
+ {
+ target0.Release();
+ }
+ catch (Exception)
+ {
+ // No-op.
+ }
+ }
+ else
+ target0.Release();
+ }
+ }
+
+ /// <summary>
+ /// Gets handle target.
+ /// </summary>
+ /// <param name="id">Identifier.</param>
+ /// <returns>Target.</returns>
+ public T Get<T>(long id)
+ {
+ return Get<T>(id, false);
+ }
+
+ /// <summary>
+ /// Gets handle target.
+ /// </summary>
+ /// <param name="id">Identifier.</param>
+ /// <param name="throwOnAbsent">Whether to throw an exception if resource is not found.</param>
+ /// <returns>Target.</returns>
+ public T Get<T>(long id, bool throwOnAbsent)
+ {
+ object target;
+
+ if (id < _fastCap)
+ {
+ target = Thread.VolatileRead(ref _fast[id]);
+
+ if (target != null)
+ return (T)target;
+ }
+ else
+ {
+ if (_slow.TryGetValue(id, out target))
+ return (T) target;
+ }
+
+ if (throwOnAbsent)
+ throw new InvalidOperationException("Resource handle has been released (is grid stopping?).");
+
+ return default(T);
+ }
+
+ /// <summary>
+ /// Close the registry. All resources allocated at the moment of close are
+ /// guaranteed to be released.
+ /// </summary>
+ public void Close()
+ {
+ if (Interlocked.CompareExchange(ref _closed, 1, 0) == 0)
+ {
+ // Cleanup on fast-path.
+ for (int i = 0; i < _fastCap; i++)
+ {
+ object target = Thread.VolatileRead(ref _fast[i]);
+
+ if (target != null)
+ {
+ Thread.VolatileWrite(ref _fast[i], null);
+
+ Release0(target, true);
+ }
+ }
+
+ // Cleanup on slow-path.
+ foreach (var item in _slow)
+ {
+ object target = item.Value;
+
+ if (target != null)
+ Release0(target, true);
+ }
+
+ _slow.Clear();
+ }
+ }
+
+ /// <summary>
+ /// Closed flag.
+ /// </summary>
+ public bool Closed
+ {
+ get { return Thread.VolatileRead(ref _closed) == 1; }
+ }
+
+ /// <summary>
+ /// Gets the current handle count.
+ /// </summary>
+ public int Count
+ {
+ get
+ {
+ Thread.MemoryBarrier();
+
+ return _fast.Count(x => x != null) + _slow.Count;
+ }
+ }
+
+ /// <summary>
+ /// Gets a snapshot of currently referenced objects list.
+ /// </summary>
+ public List<KeyValuePair<long, object>> GetItems()
+ {
+ Thread.MemoryBarrier();
+
+ return
+ _fast.Select((x, i) => new KeyValuePair<long, object>(i, x))
+ .Where(x => x.Value != null)
+ .Concat(_slow)
+ .ToList();
+ }
+
+ /// <summary>
+ /// Create new exception for closed state.
+ /// </summary>
+ /// <returns>Exception.</returns>
+ private static Exception ClosedException()
+ {
+ return new InvalidOperationException("Cannot allocate a resource handle because grid is stopping.");
+ }
+ }
+}
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c351bf3/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
new file mode 100644
index 0000000..d147f8b
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Handle
+{
+ /// <summary>
+ /// Wrapper over some resource ensuring it's release.
+ /// </summary>
+ public interface IHandle
+ {
+ /// <summary>
+ /// Release the resource.
+ /// </summary>
+ void Release();
+
+ /// <summary>
+ /// Resource released flag.
+ /// </summary>
+ bool Released { get; }
+ }
+}
\ No newline at end of file
[30/41] ignite git commit: Platforms: minor refactoring: interopCtx
-> platformCtx.
Posted by sb...@apache.org.
Platforms: minor refactoring: interopCtx -> platformCtx.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d9a13974
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d9a13974
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d9a13974
Branch: refs/heads/ignite-1093
Commit: d9a13974b6e7c5fdd2b533e806e928fcca33bbaa
Parents: 8df6b93
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 26 16:03:25 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 26 16:03:25 2015 +0300
----------------------------------------------------------------------
.../platform/PlatformAbstractTarget.java | 44 ++++++++++----------
.../query/PlatformAbstractQueryCursor.java | 6 +--
.../cache/query/PlatformFieldsQueryCursor.java | 6 +--
.../cache/query/PlatformQueryCursor.java | 6 +--
.../transactions/PlatformTransactions.java | 12 +++---
.../platform/utils/PlatformFutureUtils.java | 12 +++---
.../platform/utils/PlatformUtils.java | 4 +-
7 files changed, 45 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d9a13974/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
index ec728e4..b68b16e 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
@@ -37,8 +37,8 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
/** */
private static final int OP_META = -1;
- /** Interop context. */
- protected final PlatformContext interopCtx;
+ /** Context. */
+ protected final PlatformContext platformCtx;
/** Logger. */
protected final IgniteLogger log;
@@ -46,21 +46,21 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
/**
* Constructor.
*
- * @param interopCtx Interop context.
+ * @param platformCtx Context.
*/
- protected PlatformAbstractTarget(PlatformContext interopCtx) {
- this.interopCtx = interopCtx;
+ protected PlatformAbstractTarget(PlatformContext platformCtx) {
+ this.platformCtx = platformCtx;
- log = interopCtx.kernalContext().log(PlatformAbstractTarget.class);
+ log = platformCtx.kernalContext().log(PlatformAbstractTarget.class);
}
/** {@inheritDoc} */
@Override public int inOp(int type, long memPtr) throws Exception {
- try (PlatformMemory mem = interopCtx.memory().get(memPtr)) {
- PortableRawReaderEx reader = interopCtx.reader(mem);
+ try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
+ PortableRawReaderEx reader = platformCtx.reader(mem);
if (type == OP_META) {
- interopCtx.processMetadata(reader);
+ platformCtx.processMetadata(reader);
return TRUE;
}
@@ -74,8 +74,8 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
/** {@inheritDoc} */
@Override public Object inOpObject(int type, long memPtr) throws Exception {
- try (PlatformMemory mem = interopCtx.memory().get(memPtr)) {
- PortableRawReaderEx reader = interopCtx.reader(mem);
+ try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
+ PortableRawReaderEx reader = platformCtx.reader(mem);
return processInOpObject(type, reader);
}
@@ -86,10 +86,10 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
/** {@inheritDoc} */
@Override public void outOp(int type, long memPtr) throws Exception {
- try (PlatformMemory mem = interopCtx.memory().get(memPtr)) {
+ try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
PlatformOutputStream out = mem.output();
- PortableRawWriterEx writer = interopCtx.writer(out);
+ PortableRawWriterEx writer = platformCtx.writer(out);
processOutOp(type, writer);
@@ -107,13 +107,13 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
/** {@inheritDoc} */
@Override public void inOutOp(int type, long inMemPtr, long outMemPtr, Object arg) throws Exception {
- try (PlatformMemory inMem = interopCtx.memory().get(inMemPtr)) {
- PortableRawReaderEx reader = interopCtx.reader(inMem);
+ try (PlatformMemory inMem = platformCtx.memory().get(inMemPtr)) {
+ PortableRawReaderEx reader = platformCtx.reader(inMem);
- try (PlatformMemory outMem = interopCtx.memory().get(outMemPtr)) {
+ try (PlatformMemory outMem = platformCtx.memory().get(outMemPtr)) {
PlatformOutputStream out = outMem.output();
- PortableRawWriterEx writer = interopCtx.writer(out);
+ PortableRawWriterEx writer = platformCtx.writer(out);
processInOutOp(type, reader, writer, arg);
@@ -136,10 +136,10 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
}
/**
- * @return Interop context.
+ * @return Context.
*/
- public PlatformContext interopContext() {
- return interopCtx;
+ public PlatformContext platformContext() {
+ return platformCtx;
}
/**
@@ -150,7 +150,7 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
*/
@SuppressWarnings("UnusedDeclaration")
public void listenFuture(final long futId, int typ) throws IgniteCheckedException {
- PlatformFutureUtils.listen(interopCtx, currentFutureWrapped(), futId, typ, null);
+ PlatformFutureUtils.listen(platformCtx, currentFutureWrapped(), futId, typ, null);
}
/**
@@ -162,7 +162,7 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
*/
@SuppressWarnings("UnusedDeclaration")
public void listenFuture(final long futId, int typ, int opId) throws IgniteCheckedException {
- PlatformFutureUtils.listen(interopCtx, currentFutureWrapped(), futId, typ, futureWriter(opId));
+ PlatformFutureUtils.listen(platformCtx, currentFutureWrapped(), futId, typ, futureWriter(opId));
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/d9a13974/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java
index cdd29fd..c01da0e 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java
@@ -50,12 +50,12 @@ public abstract class PlatformAbstractQueryCursor<T> extends PlatformAbstractTar
/**
* Constructor.
*
- * @param interopCtx Interop context.
+ * @param platformCtx Context.
* @param cursor Underlying cursor.
* @param batchSize Batch size.
*/
- public PlatformAbstractQueryCursor(PlatformContext interopCtx, QueryCursorEx<T> cursor, int batchSize) {
- super(interopCtx);
+ public PlatformAbstractQueryCursor(PlatformContext platformCtx, QueryCursorEx<T> cursor, int batchSize) {
+ super(platformCtx);
this.cursor = cursor;
this.batchSize = batchSize;
http://git-wip-us.apache.org/repos/asf/ignite/blob/d9a13974/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java
index f18a79a..6b2902c 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformFieldsQueryCursor.java
@@ -30,12 +30,12 @@ public class PlatformFieldsQueryCursor extends PlatformAbstractQueryCursor<List<
/**
* Constructor.
*
- * @param interopCtx Interop context.
+ * @param platformCtx Platform context.
* @param cursor Backing cursor.
* @param batchSize Batch size.
*/
- public PlatformFieldsQueryCursor(PlatformContext interopCtx, QueryCursorEx<List<?>> cursor, int batchSize) {
- super(interopCtx, cursor, batchSize);
+ public PlatformFieldsQueryCursor(PlatformContext platformCtx, QueryCursorEx<List<?>> cursor, int batchSize) {
+ super(platformCtx, cursor, batchSize);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/d9a13974/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformQueryCursor.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformQueryCursor.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformQueryCursor.java
index cc96d6f..0d323a3 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformQueryCursor.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformQueryCursor.java
@@ -30,12 +30,12 @@ public class PlatformQueryCursor extends PlatformAbstractQueryCursor<Cache.Entry
/**
* Constructor.
*
- * @param interopCtx Interop context.
+ * @param platformCtx Context.
* @param cursor Backing cursor.
* @param batchSize Batch size.
*/
- public PlatformQueryCursor(PlatformContext interopCtx, QueryCursorEx<Cache.Entry> cursor, int batchSize) {
- super(interopCtx, cursor, batchSize);
+ public PlatformQueryCursor(PlatformContext platformCtx, QueryCursorEx<Cache.Entry> cursor, int batchSize) {
+ super(platformCtx, cursor, batchSize);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/d9a13974/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
index fa63840..aedc380 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
@@ -54,12 +54,12 @@ public class PlatformTransactions extends PlatformAbstractTarget {
/**
* Constructor.
*
- * @param interopCtx Interop context.
+ * @param platformCtx Context.
*/
- public PlatformTransactions(PlatformContext interopCtx) {
- super(interopCtx);
+ public PlatformTransactions(PlatformContext platformCtx) {
+ super(platformCtx);
- txs = interopCtx.kernalContext().grid().transactions();
+ txs = platformCtx.kernalContext().grid().transactions();
}
/**
@@ -175,7 +175,7 @@ public class PlatformTransactions extends PlatformAbstractTarget {
}
});
- PlatformFutureUtils.listen(interopCtx, fut, futId, PlatformFutureUtils.TYP_OBJ);
+ PlatformFutureUtils.listen(platformCtx, fut, futId, PlatformFutureUtils.TYP_OBJ);
}
/**
@@ -230,7 +230,7 @@ public class PlatformTransactions extends PlatformAbstractTarget {
@Override protected void processOutOp(int type, PortableRawWriterEx writer) throws IgniteCheckedException {
switch (type) {
case OP_CACHE_CONFIG_PARAMETERS:
- TransactionConfiguration txCfg = interopCtx.kernalContext().config().getTransactionConfiguration();
+ TransactionConfiguration txCfg = platformCtx.kernalContext().config().getTransactionConfiguration();
writer.writeEnum(txCfg.getDefaultTxConcurrency());
writer.writeEnum(txCfg.getDefaultTxIsolation());
http://git-wip-us.apache.org/repos/asf/ignite/blob/d9a13974/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
index fa986fe..677cb1c 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
@@ -58,7 +58,7 @@ public class PlatformFutureUtils {
/**
* Listen future.
*
- * @param ctx Interop context.
+ * @param ctx Context.
* @param fut Java future.
* @param futPtr Native future pointer.
* @param typ Expected return type.
@@ -70,7 +70,7 @@ public class PlatformFutureUtils {
/**
* Listen future.
*
- * @param ctx Interop context.
+ * @param ctx Context.
* @param fut Java future.
* @param futPtr Native future pointer.
* @param typ Expected return type.
@@ -84,7 +84,7 @@ public class PlatformFutureUtils {
/**
* Listen future.
*
- * @param ctx Interop context.
+ * @param ctx Context.
* @param fut Java future.
* @param futPtr Native future pointer.
* @param writer Writer.
@@ -96,7 +96,7 @@ public class PlatformFutureUtils {
/**
* Listen future.
*
- * @param ctx Interop context.
+ * @param ctx Context.
* @param listenable Listenable entry.
* @param futPtr Native future pointer.
* @param typ Expected return type.
@@ -200,7 +200,7 @@ public class PlatformFutureUtils {
/**
* Write future error.
*
- * @param ctx Interop context.
+ * @param ctx Context.
* @param futPtr Future pointer.
* @param err Error.
*/
@@ -226,7 +226,7 @@ public class PlatformFutureUtils {
*
* @param obj Object to write.
* @param err Error to write.
- * @param ctx Interop context.
+ * @param ctx Context.
* @param writer Writer.
* @param futPtr Future pointer.
* @return Value indicating whether custom write was performed. When false, default write will be used.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d9a13974/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index 614346a..66e87e2 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -434,7 +434,7 @@ public class PlatformUtils {
/**
* Apply continuous query events to listener.
*
- * @param ctx Interop context.
+ * @param ctx Context.
* @param lsnrPtr Listener pointer.
* @param evts Events.
* @throws javax.cache.event.CacheEntryListenerException In case of failure.
@@ -473,7 +473,7 @@ public class PlatformUtils {
/**
* Evaluate the filter.
*
- * @param ctx Interop context.
+ * @param ctx Context.
* @param filterPtr Native filter pointer.
* @param evt Event.
* @return Result.
[25/41] ignite git commit: Added test.
Posted by sb...@apache.org.
Added test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7ad43fca
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7ad43fca
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7ad43fca
Branch: refs/heads/ignite-1093
Commit: 7ad43fca62c64a7a8ced5ef5a7a030907bbf68cc
Parents: 76bc7d6
Author: sboikov <sb...@gridgain.com>
Authored: Wed Aug 26 15:41:15 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Aug 26 15:41:15 2015 +0300
----------------------------------------------------------------------
.../processors/cache/IgniteCacheManyAsyncOperationsTest.java | 2 +-
.../java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ad43fca/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java
index ab4f1b8..0f0d929 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java
@@ -76,7 +76,7 @@ public class IgniteCacheManyAsyncOperationsTest extends IgniteCacheAbstractTest
Map<Integer, byte[]> map = new HashMap<>();
- for (int i = 0; i < 500; i++)
+ for (int i = 0; i < 100; i++)
map.put(i, new byte[128]);
for (int iter = 0; iter < 3; iter++) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ad43fca/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index bafdfef..b16d1e3 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -135,6 +135,7 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(GridCacheGetStoreErrorSelfTest.class);
suite.addTestSuite(CacheFutureExceptionSelfTest.class);
suite.addTestSuite(GridCacheAsyncOperationsLimitSelfTest.class);
+ suite.addTestSuite(IgniteCacheManyAsyncOperationsTest.class);
suite.addTestSuite(GridCacheTtlManagerSelfTest.class);
suite.addTestSuite(GridCacheLifecycleAwareSelfTest.class);
suite.addTestSuite(IgniteCacheAtomicStopBusySelfTest.class);
[39/41] ignite git commit: WIP on cluster node and cluster metrics.
Posted by sb...@apache.org.
WIP on cluster node and cluster metrics.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e4ba2eba
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e4ba2eba
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e4ba2eba
Branch: refs/heads/ignite-1093
Commit: e4ba2ebaf2544ac978c201a6a02e6330e1d5ac81
Parents: 5718480
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Aug 27 11:28:46 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Aug 27 11:28:46 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/portable/PortableContext.java | 3 ---
.../internal/processors/platform/PlatformContext.java | 9 +++++++++
2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4ba2eba/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 2d3cbf0..a9d64d9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -204,15 +204,12 @@ public class PortableContext implements Externalizable {
// registerPredefinedType(DrSenderAttributes.class, 65);
// registerPredefinedType(DrSenderRemoteAttributes.class, 66);
//
-// registerPredefinedType(InteropClusterNode.class, 67);
-// registerPredefinedType(InteropClusterMetrics.class, 68);
// registerPredefinedType(InteropMetadata.class, 70);
//
// registerPredefinedType(InteropDotNetConfiguration.class, 71);
// registerPredefinedType(InteropDotNetPortableConfiguration.class, 72);
// registerPredefinedType(InteropDotNetPortableTypeConfiguration.class, 73);
// registerPredefinedType(InteropIgniteProxy.class, 74);
-// registerPredefinedType(InteropCacheMetrics.class, 75);
// registerPredefinedType(InteropProductLicence.class, 78);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4ba2eba/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
index fb1eaa2..90ed85d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContext.java
@@ -22,6 +22,7 @@ import org.apache.ignite.internal.*;
import org.apache.ignite.internal.portable.*;
import org.apache.ignite.internal.processors.platform.callback.*;
import org.apache.ignite.internal.processors.platform.memory.*;
+import org.jetbrains.annotations.*;
import java.util.*;
@@ -111,4 +112,12 @@ public interface PlatformContext {
* @param reader Reader.
*/
public void processMetadata(PortableRawReaderEx reader);
+
+ /**
+ * Write cluster metrics.
+ *
+ * @param writer Writer.
+ * @param metrics Metrics.
+ */
+ public void writeClusterMetrics(PortableRawWriterEx writer, @Nullable ClusterMetrics metrics);
}