You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2015/08/24 21:22:48 UTC
[01/10] ignite git commit: ignite-1280 - Fixed near evictions with
off heap. Closes #26.
Repository: ignite
Updated Branches:
refs/heads/ignite-1281 7845225c7 -> d1501915c
ignite-1280 - Fixed near evictions with off heap. Closes #26.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/13273404
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/13273404
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/13273404
Branch: refs/heads/ignite-1281
Commit: 132734040374203d36a7f35b9c5e3cc1651034a6
Parents: 15daf9d
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Fri Aug 21 16:27:17 2015 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Fri Aug 21 16:27:17 2015 -0700
----------------------------------------------------------------------
.../cache/GridCacheEvictionManager.java | 2 +-
.../lru/LruNearEvictionPolicySelfTest.java | 29 ++++++++++-
.../LruNearOnlyNearEvictionPolicySelfTest.java | 55 +++++++++++++++++++-
3 files changed, 83 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/13273404/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index 55669a7..fd71ab5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -134,7 +134,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
memoryMode = cctx.config().getMemoryMode();
- plcEnabled = plc != null && memoryMode != OFFHEAP_TIERED;
+ plcEnabled = plc != null && (cctx.isNear() || memoryMode != OFFHEAP_TIERED);
filter = cfg.getEvictionFilter();
http://git-wip-us.apache.org/repos/asf/ignite/blob/13273404/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearEvictionPolicySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearEvictionPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearEvictionPolicySelfTest.java
index 218b817..7910e41 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearEvictionPolicySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearEvictionPolicySelfTest.java
@@ -29,6 +29,7 @@ import org.apache.ignite.testframework.junits.common.*;
import java.util.*;
import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMemoryMode.*;
import static org.apache.ignite.cache.CacheMode.*;
import static org.apache.ignite.cache.CacheRebalanceMode.*;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
@@ -49,14 +50,18 @@ public class LruNearEvictionPolicySelfTest extends GridCommonAbstractTest {
/** Cache atomicity mode specified by test. */
private CacheAtomicityMode atomicityMode;
+ /** Memory mode. */
+ private CacheMemoryMode memMode;
+
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration c = super.getConfiguration(gridName);
CacheConfiguration cc = new CacheConfiguration();
- cc.setAtomicityMode(atomicityMode);
cc.setCacheMode(PARTITIONED);
+ cc.setAtomicityMode(atomicityMode);
+ cc.setMemoryMode(memMode);
cc.setWriteSynchronizationMode(PRIMARY_SYNC);
cc.setRebalanceMode(SYNC);
cc.setStartSize(100);
@@ -86,6 +91,17 @@ public class LruNearEvictionPolicySelfTest extends GridCommonAbstractTest {
*/
public void testAtomicNearEvictionMaxSize() throws Exception {
atomicityMode = ATOMIC;
+ memMode = ONHEAP_TIERED;
+
+ checkNearEvictionMaxSize();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAtomicOffHeapNearEvictionMaxSize() throws Exception {
+ atomicityMode = ATOMIC;
+ memMode = CacheMemoryMode.OFFHEAP_TIERED;
checkNearEvictionMaxSize();
}
@@ -95,6 +111,17 @@ public class LruNearEvictionPolicySelfTest extends GridCommonAbstractTest {
*/
public void testTransactionalNearEvictionMaxSize() throws Exception {
atomicityMode = TRANSACTIONAL;
+ memMode = ONHEAP_TIERED;
+
+ checkNearEvictionMaxSize();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTransactionalOffHeapNearEvictionMaxSize() throws Exception {
+ atomicityMode = TRANSACTIONAL;
+ memMode = CacheMemoryMode.OFFHEAP_TIERED;
checkNearEvictionMaxSize();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/13273404/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearOnlyNearEvictionPolicySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearOnlyNearEvictionPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearOnlyNearEvictionPolicySelfTest.java
index 0d3c692..6bf343b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearOnlyNearEvictionPolicySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearOnlyNearEvictionPolicySelfTest.java
@@ -27,6 +27,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.testframework.junits.common.*;
import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMemoryMode.*;
import static org.apache.ignite.cache.CacheMode.*;
import static org.apache.ignite.cache.CacheRebalanceMode.*;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
@@ -53,6 +54,9 @@ public class LruNearOnlyNearEvictionPolicySelfTest extends GridCommonAbstractTes
/** Cache atomicity mode specified by test. */
private CacheAtomicityMode atomicityMode;
+ /** Memory mode. */
+ private CacheMemoryMode memMode;
+
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
super.beforeTest();
@@ -69,8 +73,9 @@ public class LruNearOnlyNearEvictionPolicySelfTest extends GridCommonAbstractTes
else {
CacheConfiguration cc = new CacheConfiguration();
- cc.setAtomicityMode(atomicityMode);
cc.setCacheMode(cacheMode);
+ cc.setAtomicityMode(atomicityMode);
+ cc.setMemoryMode(memMode);
cc.setWriteSynchronizationMode(PRIMARY_SYNC);
cc.setRebalanceMode(SYNC);
cc.setStartSize(100);
@@ -92,6 +97,18 @@ public class LruNearOnlyNearEvictionPolicySelfTest extends GridCommonAbstractTes
public void testPartitionedAtomicNearEvictionMaxSize() throws Exception {
atomicityMode = ATOMIC;
cacheMode = PARTITIONED;
+ memMode = ONHEAP_TIERED;
+
+ checkNearEvictionMaxSize();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPartitionedAtomicOffHeapNearEvictionMaxSize() throws Exception {
+ atomicityMode = ATOMIC;
+ cacheMode = PARTITIONED;
+ memMode = OFFHEAP_TIERED;
checkNearEvictionMaxSize();
}
@@ -102,6 +119,18 @@ public class LruNearOnlyNearEvictionPolicySelfTest extends GridCommonAbstractTes
public void testPartitionedTransactionalNearEvictionMaxSize() throws Exception {
atomicityMode = TRANSACTIONAL;
cacheMode = PARTITIONED;
+ memMode = ONHEAP_TIERED;
+
+ checkNearEvictionMaxSize();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPartitionedTransactionalOffHeapNearEvictionMaxSize() throws Exception {
+ atomicityMode = TRANSACTIONAL;
+ cacheMode = PARTITIONED;
+ memMode = OFFHEAP_TIERED;
checkNearEvictionMaxSize();
}
@@ -112,6 +141,18 @@ public class LruNearOnlyNearEvictionPolicySelfTest extends GridCommonAbstractTes
public void testReplicatedAtomicNearEvictionMaxSize() throws Exception {
atomicityMode = ATOMIC;
cacheMode = REPLICATED;
+ memMode = ONHEAP_TIERED;
+
+ checkNearEvictionMaxSize();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReplicatedAtomicOffHeapNearEvictionMaxSize() throws Exception {
+ atomicityMode = ATOMIC;
+ cacheMode = REPLICATED;
+ memMode = OFFHEAP_TIERED;
checkNearEvictionMaxSize();
}
@@ -122,6 +163,18 @@ public class LruNearOnlyNearEvictionPolicySelfTest extends GridCommonAbstractTes
public void testReplicatedTransactionalNearEvictionMaxSize() throws Exception {
atomicityMode = TRANSACTIONAL;
cacheMode = REPLICATED;
+ memMode = ONHEAP_TIERED;
+
+ checkNearEvictionMaxSize();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReplicatedTransactionalOffHeapNearEvictionMaxSize() throws Exception {
+ atomicityMode = TRANSACTIONAL;
+ cacheMode = REPLICATED;
+ memMode = OFFHEAP_TIERED;
checkNearEvictionMaxSize();
}
[06/10] ignite git commit: IGNITE-1285: Moved Java memory management
stuff to Ignite.
Posted by ag...@apache.org.
IGNITE-1285: Moved Java memory management stuff to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4b818ae3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4b818ae3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4b818ae3
Branch: refs/heads/ignite-1281
Commit: 4b818ae3e5d914638c450f2705c23f3fe37f36ab
Parents: 30fc466
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Aug 24 12:50:32 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 24 12:50:32 2015 +0300
----------------------------------------------------------------------
.../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 ++
15 files changed, 2027 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4b818ae3/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
new file mode 100644
index 0000000..cf4c02a
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/4b818ae3/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
new file mode 100644
index 0000000..fbf7f8e
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/4b818ae3/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
new file mode 100644
index 0000000..144e5dc
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/4b818ae3/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
new file mode 100644
index 0000000..e04779d
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/4b818ae3/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
new file mode 100644
index 0000000..96db40d
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.platform.memory;
+
+import org.apache.ignite.internal.processors.portable.*;
+
+/**
+ * Interop output stream,
+ */
+public interface PlatformInputStream extends GridPortableInputStream {
+ /**
+ * 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/4b818ae3/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
new file mode 100644
index 0000000..e741c9e
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/4b818ae3/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
new file mode 100644
index 0000000..648827a
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/4b818ae3/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
new file mode 100644
index 0000000..73ec915
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/4b818ae3/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
new file mode 100644
index 0000000..53a3e19
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/4b818ae3/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
new file mode 100644
index 0000000..a012b5c
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/4b818ae3/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
new file mode 100644
index 0000000..d820ca6
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/4b818ae3/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
new file mode 100644
index 0000000..cd3c676
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.platform.memory;
+
+import org.apache.ignite.internal.processors.portable.*;
+
+/**
+ * Interop output stream.
+ */
+public interface PlatformOutputStream extends GridPortableOutputStream {
+ /**
+ * Synchronize output stream with underlying memory
+ */
+ public void synchronize();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4b818ae3/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
new file mode 100644
index 0000000..13492eb
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/4b818ae3/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
new file mode 100644
index 0000000..5043fd1
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/4b818ae3/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
new file mode 100644
index 0000000..f3fe227
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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);
+ }
+}
+
[02/10] ignite git commit: IGNITE-1283: Creating infrastructure for
platforms module.
Posted by ag...@apache.org.
IGNITE-1283: Creating infrastructure for platforms module.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/aaf43758
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/aaf43758
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/aaf43758
Branch: refs/heads/ignite-1281
Commit: aaf43758caa68a80a31b9cce653e18888da04887
Parents: 1327340
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Aug 24 11:20:11 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 24 11:20:11 2015 +0300
----------------------------------------------------------------------
.../configuration/IgniteConfiguration.java | 22 +++
.../configuration/PlatformConfiguration.java | 25 +++
.../internal/GridEventConsumeHandler.java | 14 +-
.../interop/InteropAwareEventFilter.java | 37 ----
.../internal/interop/InteropBootstrap.java | 35 ----
.../interop/InteropBootstrapFactory.java | 39 ----
.../internal/interop/InteropException.java | 71 -------
.../internal/interop/InteropIgnition.java | 186 -------------------
.../interop/InteropLocalEventListener.java | 28 ---
.../interop/InteropNoCallbackException.java | 50 -----
.../internal/interop/InteropProcessor.java | 39 ----
.../eventstorage/GridEventStorageManager.java | 10 +-
.../platform/PlatformAwareEventFilter.java | 37 ++++
.../platform/PlatformLocalEventListener.java | 28 +++
modules/platform/pom.xml | 65 +++++++
.../ignite/internal/platform/Platform.java | 39 ++++
.../internal/platform/PlatformBootstrap.java | 35 ++++
.../platform/PlatformBootstrapFactory.java | 37 ++++
.../internal/platform/PlatformException.java | 71 +++++++
.../internal/platform/PlatformIgnition.java | 186 +++++++++++++++++++
.../platform/PlatformNoCallbackException.java | 50 +++++
pom.xml | 1 +
22 files changed, 608 insertions(+), 497 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index b670398..1fa1de4 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -416,6 +416,9 @@ public class IgniteConfiguration {
/** SSL connection factory. */
private Factory<SSLContext> sslCtxFactory;
+ /** Platform configuration. */
+ private PlatformConfiguration platformCfg;
+
/**
* Creates valid grid configuration with all default values.
*/
@@ -490,6 +493,7 @@ public class IgniteConfiguration {
p2pLocClsPathExcl = cfg.getPeerClassLoadingLocalClassPathExclude();
p2pMissedCacheSize = cfg.getPeerClassLoadingMissedResourcesCacheSize();
p2pPoolSize = cfg.getPeerClassLoadingThreadPoolSize();
+ platformCfg = cfg.getPlatformConfiguration();
pluginCfgs = cfg.getPluginConfigurations();
pubPoolSize = cfg.getPublicThreadPoolSize();
segChkFreq = cfg.getSegmentCheckFrequency();
@@ -2371,6 +2375,24 @@ public class IgniteConfiguration {
return this;
}
+ /**
+ * Gets platform configuration.
+ *
+ * @return Platform configuration.
+ */
+ public PlatformConfiguration getPlatformConfiguration() {
+ return platformCfg;
+ }
+
+ /**
+ * Sets platform configuration.
+ *
+ * @param platformCfg Platform configuration.
+ */
+ public void setPlatformConfiguration(PlatformConfiguration platformCfg) {
+ this.platformCfg = platformCfg;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgniteConfiguration.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/modules/core/src/main/java/org/apache/ignite/configuration/PlatformConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/PlatformConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/PlatformConfiguration.java
new file mode 100644
index 0000000..14d5e1d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/PlatformConfiguration.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.configuration;
+
+/**
+ * Platform configuration marker interface.
+ */
+public class PlatformConfiguration {
+ // No-op.
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/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 f33fa39..134184a 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
@@ -21,9 +21,9 @@ import org.apache.ignite.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.events.*;
import org.apache.ignite.internal.cluster.*;
-import org.apache.ignite.internal.interop.*;
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.util.typedef.*;
@@ -125,8 +125,8 @@ class GridEventConsumeHandler implements GridContinuousHandler {
if (filter != null)
ctx.resource().injectGeneric(filter);
- if (filter instanceof InteropAwareEventFilter)
- ((InteropAwareEventFilter)filter).initialize(ctx);
+ if (filter instanceof PlatformAwareEventFilter)
+ ((PlatformAwareEventFilter)filter).initialize(ctx);
final boolean loc = nodeId.equals(ctx.localNodeId());
@@ -246,16 +246,16 @@ class GridEventConsumeHandler implements GridContinuousHandler {
RuntimeException err = null;
try {
- if (filter instanceof InteropAwareEventFilter)
- ((InteropAwareEventFilter)filter).close();
+ if (filter instanceof PlatformAwareEventFilter)
+ ((PlatformAwareEventFilter)filter).close();
}
catch(RuntimeException ex) {
err = ex;
}
try {
- if (cb instanceof InteropLocalEventListener)
- ((InteropLocalEventListener)cb).close();
+ if (cb instanceof PlatformLocalEventListener)
+ ((PlatformLocalEventListener)cb).close();
}
catch (RuntimeException ex) {
if (err == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropAwareEventFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropAwareEventFilter.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropAwareEventFilter.java
deleted file mode 100644
index 8dbc73b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropAwareEventFilter.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.interop;
-
-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 InteropAwareEventFilter<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/aaf43758/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java
deleted file mode 100644
index df5af6c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java
+++ /dev/null
@@ -1,35 +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.interop;
-
-import org.apache.ignite.configuration.*;
-
-/**
- * Interop bootstrap. Responsible for starting Ignite node in interop mode.
- */
-public interface InteropBootstrap {
- /**
- * Start Ignite node.
- *
- * @param cfg Configuration.
- * @param envPtr Environment pointer.
- * @param dataPtr Optional pointer to additional data required for startup.
- * @return Ignite node.
- */
- public InteropProcessor start(IgniteConfiguration cfg, long envPtr, long dataPtr);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrapFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrapFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrapFactory.java
deleted file mode 100644
index b61ca89..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrapFactory.java
+++ /dev/null
@@ -1,39 +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.interop;
-
-import java.io.*;
-
-/**
- * Interop bootstrap factory.
- */
-public interface InteropBootstrapFactory extends Serializable {
- /**
- * Get bootstrap factory ID.
- *
- * @return ID.
- */
- public int id();
-
- /**
- * Create bootstrap instance.
- *
- * @return Bootstrap instance.
- */
- public InteropBootstrap create();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.java
deleted file mode 100644
index d74b9d4..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.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.interop;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
-
-/**
- * Interop checked exception.
- */
-public class InteropException extends IgniteCheckedException {
- /** */
- private static final long serialVersionUID = 0L;
-
- /**
- * Create empty exception.
- */
- public InteropException() {
- // No-op.
- }
-
- /**
- * Creates new exception with given error message.
- *
- * @param msg Error message.
- */
- public InteropException(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 InteropException(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 InteropException(String msg, @Nullable Throwable cause) {
- super(msg, cause);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(InteropException.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
deleted file mode 100644
index 35e9bc9..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
+++ /dev/null
@@ -1,186 +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.interop;
-
-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 interop nodes.
- */
-@SuppressWarnings("UnusedDeclaration")
-public class InteropIgnition {
- /** Map with active instances. */
- private static final HashMap<String, InteropProcessor> instances = new HashMap<>();
-
- /**
- * Start Ignite node in interop 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 InteropProcessor 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(InteropIgnition.class.getClassLoader());
-
- try {
- IgniteConfiguration cfg = configuration(springCfgPath);
-
- if (gridName != null)
- cfg.setGridName(gridName);
- else
- gridName = cfg.getGridName();
-
- InteropBootstrap bootstrap = bootstrap(factoryId);
-
- InteropProcessor proc = bootstrap.start(cfg, envPtr, dataPtr);
-
- InteropProcessor 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 InteropProcessor 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) {
- InteropProcessor 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)) {
- InteropProcessor 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 (InteropProcessor 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 InteropBootstrap bootstrap(final int factoryId) {
- InteropBootstrapFactory factory = AccessController.doPrivileged(
- new PrivilegedAction<InteropBootstrapFactory>() {
- @Override public InteropBootstrapFactory run() {
- for (InteropBootstrapFactory factory : ServiceLoader.load(InteropBootstrapFactory.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 InteropIgnition() {
- // No-op.
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropLocalEventListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropLocalEventListener.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropLocalEventListener.java
deleted file mode 100644
index 180863b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropLocalEventListener.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.interop;
-
-/**
- * Special version of listener for events with close callbacks.
- */
-public interface InteropLocalEventListener {
- /**
- * Closes the listener.
- */
- public void close();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropNoCallbackException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropNoCallbackException.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropNoCallbackException.java
deleted file mode 100644
index 6fd614a..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropNoCallbackException.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.interop;
-
-import org.apache.ignite.internal.util.typedef.internal.*;
-
-/**
- * Exception raised when interop callback is not set in native platform.
- */
-@SuppressWarnings("UnusedDeclaration")
-public class InteropNoCallbackException extends InteropException {
- /** */
- private static final long serialVersionUID = 0L;
-
- /**
- * Constructor.
- */
- public InteropNoCallbackException() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param msg Message.
- */
- public InteropNoCallbackException(String msg) {
- super(msg);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(InteropNoCallbackException.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java
deleted file mode 100644
index 2551047..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java
+++ /dev/null
@@ -1,39 +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.interop;
-
-import org.apache.ignite.*;
-
-/**
- * Interop processor.
- */
-public interface InteropProcessor {
- /**
- * Get owning Ignite instance.
- *
- * @return Ignite instance.
- */
- public Ignite ignite();
-
- /**
- * Get environment pointer associated with this processor.
- *
- * @return Environment pointer.
- */
- public long environmentPointer();
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/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 365076b..d8e6ae1 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
@@ -22,10 +22,10 @@ import org.apache.ignite.cluster.*;
import org.apache.ignite.events.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.events.*;
-import org.apache.ignite.internal.interop.*;
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.util.*;
import org.apache.ignite.internal.util.future.*;
import org.apache.ignite.internal.util.typedef.*;
@@ -655,8 +655,8 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
{
IgnitePredicate p = ((UserListenerWrapper)lsnr).listener();
- if (p instanceof InteropLocalEventListener)
- ((InteropLocalEventListener)p).close();
+ if (p instanceof PlatformLocalEventListener)
+ ((PlatformLocalEventListener)p).close();
}
return found;
@@ -761,8 +761,8 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
public <T extends Event> Collection<T> localEvents(IgnitePredicate<T> p) {
assert p != null;
- if (p instanceof InteropAwareEventFilter) {
- InteropAwareEventFilter p0 = (InteropAwareEventFilter)p;
+ if (p instanceof PlatformAwareEventFilter) {
+ PlatformAwareEventFilter p0 = (PlatformAwareEventFilter)p;
p0.initialize(ctx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/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
new file mode 100644
index 0000000..2ae664d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/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.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/aaf43758/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
new file mode 100644
index 0000000..31c585c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/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.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/aaf43758/modules/platform/pom.xml
----------------------------------------------------------------------
diff --git a/modules/platform/pom.xml b/modules/platform/pom.xml
new file mode 100644
index 0000000..e583f6a
--- /dev/null
+++ b/modules/platform/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<!--
+ POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-platform</artifactId>
+ <version>1.4.1-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/modules/platform/src/main/java/org/apache/ignite/internal/platform/Platform.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/platform/Platform.java b/modules/platform/src/main/java/org/apache/ignite/internal/platform/Platform.java
new file mode 100644
index 0000000..6306723
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/platform/Platform.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.platform;
+
+import org.apache.ignite.*;
+
+/**
+ * Platform entry point.
+ */
+public interface Platform {
+ /**
+ * Get owning Ignite instance.
+ *
+ * @return Ignite instance.
+ */
+ public Ignite ignite();
+
+ /**
+ * Get environment pointer associated with this processor.
+ *
+ * @return Environment pointer.
+ */
+ public long environmentPointer();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/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
new file mode 100644
index 0000000..1044445
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformBootstrap.java
@@ -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.
+ */
+
+package org.apache.ignite.internal.platform;
+
+import org.apache.ignite.configuration.*;
+
+/**
+ * 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 Ignite node.
+ */
+ public Platform start(IgniteConfiguration cfg, long envPtr, long dataPtr);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaf43758/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
new file mode 100644
index 0000000..31d1ca5
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/aaf43758/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
new file mode 100644
index 0000000..d0bf565
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/aaf43758/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
new file mode 100644
index 0000000..293d79d
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/platform/PlatformIgnition.java
@@ -0,0 +1,186 @@
+package org.apache.ignite.internal.platform;
+
+/*
+ * 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.
+ */
+
+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, Platform> 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 Platform 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(Platform.class.getClassLoader());
+
+ try {
+ IgniteConfiguration cfg = configuration(springCfgPath);
+
+ if (gridName != null)
+ cfg.setGridName(gridName);
+ else
+ gridName = cfg.getGridName();
+
+ PlatformBootstrap bootstrap = bootstrap(factoryId);
+
+ Platform proc = bootstrap.start(cfg, envPtr, dataPtr);
+
+ Platform 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 Platform 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) {
+ Platform 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)) {
+ Platform 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 (Platform 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/aaf43758/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
new file mode 100644
index 0000000..893c332
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/aaf43758/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index fa3eaa4..0540361 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,6 +76,7 @@
<module>modules/yarn</module>
<module>modules/jms11</module>
<module>modules/zookeeper</module>
+ <module>modules/platform</module>
</modules>
<profiles>
[08/10] ignite git commit: IGNITE-1286: .Net solution and project
skeletons. Contributed by Pavel Tupitsyn.
Posted by ag...@apache.org.
IGNITE-1286: .Net solution and project skeletons.
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/ff666ca6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ff666ca6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ff666ca6
Branch: refs/heads/ignite-1281
Commit: ff666ca631470de43e9c1bfa3d27436c46b14cc8
Parents: 4df0716
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Aug 24 17:20:11 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 24 17:20:11 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.csproj | 47 +++++++++++++
.../main/dotnet/Apache.Ignite.Core/Ignition.cs | 23 +++++++
.../Properties/AssemblyInfo.cs | 35 ++++++++++
.../platform/src/main/dotnet/Apache.Ignite.sln | 35 ++++++++++
.../Apache.Ignite.Core.Tests.csproj | 64 ++++++++++++++++++
.../Apache.Ignite.Core.Tests/IgnitionTest.cs | 30 +++++++++
.../Properties/AssemblyInfo.cs | 35 ++++++++++
.../Apache.Ignite.Core.Tests/TestRunner.cs | 70 ++++++++++++++++++++
8 files changed, 339 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff666ca6/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
new file mode 100644
index 0000000..0980c8f
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.Core</RootNamespace>
+ <AssemblyName>Apache.Ignite.Core</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <PlatformTarget>x86</PlatformTarget>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <PlatformTarget>x86</PlatformTarget>
+ <OutputPath>bin\x86\Release\</OutputPath>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Ignition.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </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.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff666ca6/modules/platform/src/main/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Ignition.cs
new file mode 100644
index 0000000..a61a1a8
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -0,0 +1,23 @@
+/*
+ * 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
+{
+ public class Ignition
+ {
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff666ca6/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..9d99a3d
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.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.
+ */
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Apache.Ignite.Core")]
+[assembly: AssemblyDescription("Apache Ignite .NET Core")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache Ignite")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("97db45a8-f922-456a-a819-7b3c6e5e03ba")]
+
+[assembly: AssemblyVersion("1.4.1.0")]
+[assembly: AssemblyFileVersion("1.4.1.0")]
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff666ca6/modules/platform/src/main/dotnet/Apache.Ignite.sln
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.sln b/modules/platform/src/main/dotnet/Apache.Ignite.sln
new file mode 100644
index 0000000..91bd2b6
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.sln
@@ -0,0 +1,35 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core", "Apache.Ignite.Core\Apache.Ignite.Core.csproj", "{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core.Tests", "..\..\test\dotnet\Apache.Ignite.Core.Tests\Apache.Ignite.Core.Tests.csproj", "{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.ActiveCfg = Debug|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.Build.0 = Debug|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.ActiveCfg = Debug|x86
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.Build.0 = Debug|x86
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.ActiveCfg = Release|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.Build.0 = Release|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.ActiveCfg = Release|x86
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.Build.0 = Release|x86
+ {6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Debug|x64.ActiveCfg = Debug|x64
+ {6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Debug|x64.Build.0 = Debug|x64
+ {6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Debug|x86.ActiveCfg = Debug|x86
+ {6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Debug|x86.Build.0 = Debug|x86
+ {6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Release|x64.ActiveCfg = Release|x64
+ {6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Release|x64.Build.0 = Release|x64
+ {6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Release|x86.ActiveCfg = Release|x86
+ {6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff666ca6/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
new file mode 100644
index 0000000..21dc6ce
--- /dev/null
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.Core.Tests</RootNamespace>
+ <AssemblyName>Apache.Ignite.Core.Tests</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject />
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <PlatformTarget>x86</PlatformTarget>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <PlatformTarget>x86</PlatformTarget>
+ <OutputPath>bin\x86\Release\</OutputPath>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="nunit-console-runner">
+ <HintPath>..\libs\nunit-console-runner.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\libs\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="IgnitionTest.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TestRunner.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\main\dotnet\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+ <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
+ <Name>Apache.Ignite.Core</Name>
+ </ProjectReference>
+ </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.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff666ca6/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/IgnitionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/IgnitionTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/IgnitionTest.cs
new file mode 100644
index 0000000..a2698d1
--- /dev/null
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/IgnitionTest.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Tests
+{
+ using NUnit.Framework;
+
+ public class IgnitionTest
+ {
+ [Test]
+ public void Test()
+ {
+ Assert.IsNotNull(new Ignition());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff666ca6/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..4600569
--- /dev/null
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.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.
+ */
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Apache.Ignite.Core.Tests")]
+[assembly: AssemblyDescription("Apache Ignite .NET Core Tests")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache.Ignite.Core.Tests")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("de8dd5cc-7c7f-4a09-80d5-7086d9416a7b")]
+
+[assembly: AssemblyVersion("1.4.1.0")]
+[assembly: AssemblyFileVersion("1.4.1.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff666ca6/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
new file mode 100644
index 0000000..feb91bc
--- /dev/null
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/TestRunner.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.Tests
+{
+ using System;
+ using System.Diagnostics;
+ using System.Reflection;
+
+ public static class TestRunner
+ {
+ [STAThread]
+ static void Main()
+ {
+ Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
+ Debug.AutoFlush = true;
+
+ //TestOne(typeof(ContinuousQueryAtomiclBackupTest), "TestInitialQuery");
+
+ TestAll(typeof(IgnitionTest));
+
+ //TestAllInAssembly();
+ }
+
+ private static void TestOne(Type testClass, string method)
+ {
+ string[] args = { "/run:" + testClass.FullName + "." + method, Assembly.GetAssembly(testClass).Location };
+
+ int returnCode = NUnit.ConsoleRunner.Runner.Main(args);
+
+ if (returnCode != 0)
+ Console.Beep();
+ }
+
+ private static void TestAll(Type testClass)
+ {
+ string[] args = { "/run:" + testClass.FullName, Assembly.GetAssembly(testClass).Location };
+
+ int returnCode = NUnit.ConsoleRunner.Runner.Main(args);
+
+ if (returnCode != 0)
+ Console.Beep();
+ }
+
+ private static void TestAllInAssembly()
+ {
+ string[] args = { Assembly.GetAssembly(typeof(IgnitionTest)).Location };
+
+ int returnCode = NUnit.ConsoleRunner.Runner.Main(args);
+
+ if (returnCode != 0)
+ Console.Beep();
+ }
+
+ }
+}
[09/10] ignite git commit: master - Fixed RAT excludes.
Posted by ag...@apache.org.
master - Fixed RAT excludes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/321b78a7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/321b78a7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/321b78a7
Branch: refs/heads/ignite-1281
Commit: 321b78a758450a5bf45d3fdeca42e88edca549c4
Parents: ff666ca
Author: Alexey Goncharuk <ag...@gridgain.com>
Authored: Mon Aug 24 12:19:15 2015 -0700
Committer: Alexey Goncharuk <ag...@gridgain.com>
Committed: Mon Aug 24 12:19:15 2015 -0700
----------------------------------------------------------------------
parent/pom.xml | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/321b78a7/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index efa6494..49aa36f 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -725,6 +725,10 @@
<exclude>ipc/shmem/igniteshmem/.deps/*</exclude><!--tmp files-->
<exclude>ipc/shmem/igniteshmem/libigniteshmem.la</exclude><!--tmp (not under VCS)-->
<exclude>ipc/shmem/igniteshmem/libigniteshmem_la-org_apache_ignite_internal_util_ipc_shmem_IpcSharedMemoryUtils.lo</exclude><!--tmp (not under VCS)-->
+ <!--platform-->
+ <exclude>src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj</exclude>
+ <exclude>src/main/dotnet/Apache.Ignite.sln</exclude>
+ <exclude>src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj</exclude>
</excludes>
</configuration>
</execution>
[07/10] ignite git commit: Improved test to check data consistency.
Posted by ag...@apache.org.
Improved test to check data consistency.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4df0716d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4df0716d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4df0716d
Branch: refs/heads/ignite-1281
Commit: 4df0716dec4265e8abaf7b67aefb5d798f2fe8b4
Parents: 4b818ae
Author: sboikov <sb...@gridgain.com>
Authored: Mon Aug 24 14:23:11 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Aug 24 14:23:11 2015 +0300
----------------------------------------------------------------------
.../near/IgniteCacheNearOnlyTxTest.java | 82 +++++++++++++-------
1 file changed, 54 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4df0716d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
index 88e7f03..c79f742 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java
@@ -26,6 +26,7 @@ import org.apache.ignite.testframework.*;
import org.apache.ignite.transactions.*;
import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
import static org.apache.ignite.cache.CacheAtomicityMode.*;
import static org.apache.ignite.transactions.TransactionConcurrency.*;
@@ -78,18 +79,31 @@ public class IgniteCacheNearOnlyTxTest extends IgniteCacheAbstractTest {
ignite1.createNearCache(null, new NearCacheConfiguration<>());
- GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
- @Override public Object call() throws Exception {
- IgniteCache cache = ignite1.cache(null);
+ final Integer key = 1;
- int key = 1;
+ final AtomicInteger idx = new AtomicInteger();
- for (int i = 0; i < 100; i++)
- cache.put(key, 1);
+ IgniteCache<Integer, Integer> cache0 = ignite(0).cache(null);
+ IgniteCache<Integer, Integer> cache1 = ignite1.cache(null);
- return null;
- }
- }, 5, "put-thread");
+ for (int i = 0; i < 5; i++) {
+ log.info("Iteration: " + i);
+
+ GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ int val = idx.getAndIncrement();
+
+ IgniteCache<Integer, Integer> cache = ignite1.cache(null);
+
+ for (int i = 0; i < 100; i++)
+ cache.put(key, val);
+
+ return null;
+ }
+ }, 5, "put-thread");
+
+ assertEquals(cache0.localPeek(key), cache1.localPeek(key));
+ }
}
/**
@@ -107,6 +121,7 @@ public class IgniteCacheNearOnlyTxTest extends IgniteCacheAbstractTest {
}
/**
+ * @param optimistic If {@code true} uses optimistic transaction.
* @throws Exception If failed.
*/
private void txMultithreaded(final boolean optimistic) throws Exception {
@@ -116,27 +131,40 @@ public class IgniteCacheNearOnlyTxTest extends IgniteCacheAbstractTest {
ignite1.createNearCache(null, new NearCacheConfiguration<>());
- GridTestUtils.runMultiThreaded(new Callable<Object>() {
- @Override public Object call() throws Exception {
- IgniteCache cache = ignite1.cache(null);
+ final AtomicInteger idx = new AtomicInteger();
- int key = 1;
+ final Integer key = 1;
- IgniteTransactions txs = ignite1.transactions();
+ IgniteCache<Integer, Integer> cache0 = ignite(0).cache(null);
+ IgniteCache<Integer, Integer> cache1 = ignite1.cache(null);
- for (int i = 0; i < 100; i++) {
- try (Transaction tx = txs.txStart(optimistic ? OPTIMISTIC : PESSIMISTIC, REPEATABLE_READ)) {
- cache.get(key);
+ for (int i = 0; i < 5; i++) {
+ log.info("Iteration: " + i);
- cache.put(key, 1);
+ GridTestUtils.runMultiThreaded(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ IgniteCache<Integer, Integer> cache = ignite1.cache(null);
- tx.commit();
+ IgniteTransactions txs = ignite1.transactions();
+
+ int val = idx.getAndIncrement();
+
+ for (int i = 0; i < 100; i++) {
+ try (Transaction tx = txs.txStart(optimistic ? OPTIMISTIC : PESSIMISTIC, REPEATABLE_READ)) {
+ cache.get(key);
+
+ cache.put(key, val);
+
+ tx.commit();
+ }
}
+
+ return null;
}
+ }, 5, "put-thread");
- return null;
- }
- }, 5, "put-thread");
+ assertEquals(cache0.localPeek(key), cache1.localPeek(key));
+ }
}
/**
@@ -149,11 +177,11 @@ public class IgniteCacheNearOnlyTxTest extends IgniteCacheAbstractTest {
ignite1.createNearCache(null, new NearCacheConfiguration<>());
+ final Integer key = 1;
+
IgniteInternalFuture<?> fut1 = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
@Override public Object call() throws Exception {
- IgniteCache cache = ignite1.cache(null);
-
- int key = 1;
+ IgniteCache<Integer, Integer> cache = ignite1.cache(null);
for (int i = 0; i < 100; i++)
cache.put(key, 1);
@@ -164,9 +192,7 @@ public class IgniteCacheNearOnlyTxTest extends IgniteCacheAbstractTest {
IgniteInternalFuture<?> fut2 = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
@Override public Object call() throws Exception {
- IgniteCache cache = ignite1.cache(null);
-
- int key = 1;
+ IgniteCache<Integer, Integer> cache = ignite1.cache(null);
IgniteTransactions txs = ignite1.transactions();
[05/10] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by ag...@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/30fc4662
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/30fc4662
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/30fc4662
Branch: refs/heads/ignite-1281
Commit: 30fc46623fc4e643b112f6d2426b2131bb3710b2
Parents: 2c51c56 b4e6724
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Aug 24 12:02:58 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 24 12:02:58 2015 +0300
----------------------------------------------------------------------
pom.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
[03/10] ignite git commit: Graduation!
Posted by ag...@apache.org.
Graduation!
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b4e67240
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b4e67240
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b4e67240
Branch: refs/heads/ignite-1281
Commit: b4e67240fceccc4e2b83a804de06baa3d55b1af1
Parents: aaf4375
Author: Anton Vinogradov <vi...@gmail.com>
Authored: Mon Aug 24 11:35:42 2015 +0300
Committer: Anton Vinogradov <vi...@gmail.com>
Committed: Mon Aug 24 11:35:42 2015 +0300
----------------------------------------------------------------------
pom.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b4e67240/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0540361..96305a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,9 +41,9 @@
</properties>
<scm>
- <url>https://git-wip-us.apache.org/repos/asf/incubator-ignite</url>
- <connection>scm:git:https://git-wip-us.apache.org/repos/asf/incubator-ignite</connection>
- <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/incubator-ignite</developerConnection>
+ <url>https://git-wip-us.apache.org/repos/asf/ignite</url>
+ <connection>scm:git:https://git-wip-us.apache.org/repos/asf/ignite</connection>
+ <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/ignite</developerConnection>
<tag>HEAD</tag>
</scm>
[04/10] ignite git commit: IGNITE-1284: Added callback utility
classes.
Posted by ag...@apache.org.
IGNITE-1284: Added callback utility classes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2c51c569
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2c51c569
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2c51c569
Branch: refs/heads/ignite-1281
Commit: 2c51c56919bc5c0f61e4c96ebf4a47a4aa804986
Parents: aaf4375
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Aug 24 12:02:34 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 24 12:02:34 2015 +0300
----------------------------------------------------------------------
.../internal/platform/PlatformIgnition.java | 4 +-
.../callback/PlatformCallbackGateway.java | 869 +++++++++++++++++++
.../callback/PlatformCallbackUtils.java | 468 ++++++++++
3 files changed, 1339 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c51c569/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
index 293d79d..685cded 100644
--- 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
@@ -1,5 +1,3 @@
-package org.apache.ignite.internal.platform;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,6 +15,8 @@ package org.apache.ignite.internal.platform;
* limitations under the License.
*/
+package org.apache.ignite.internal.platform;
+
import org.apache.ignite.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.*;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c51c569/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
new file mode 100644
index 0000000..d565c00
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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/2c51c569/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
new file mode 100644
index 0000000..d81ce68
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/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.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.
+ }
+}
[10/10] ignite git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/ignite into ignite-1281
Posted by ag...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-1281
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d1501915
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d1501915
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d1501915
Branch: refs/heads/ignite-1281
Commit: d1501915c430581f2e0f7d8727e3bef441ac85ea
Parents: 7845225 321b78a
Author: Alexey Goncharuk <ag...@gridgain.com>
Authored: Mon Aug 24 12:21:08 2015 -0700
Committer: Alexey Goncharuk <ag...@gridgain.com>
Committed: Mon Aug 24 12:21:08 2015 -0700
----------------------------------------------------------------------
.../configuration/IgniteConfiguration.java | 22 +
.../configuration/PlatformConfiguration.java | 25 +
.../internal/GridEventConsumeHandler.java | 14 +-
.../interop/InteropAwareEventFilter.java | 37 -
.../internal/interop/InteropBootstrap.java | 35 -
.../interop/InteropBootstrapFactory.java | 39 -
.../internal/interop/InteropException.java | 71 --
.../internal/interop/InteropIgnition.java | 186 ----
.../interop/InteropLocalEventListener.java | 28 -
.../interop/InteropNoCallbackException.java | 50 --
.../internal/interop/InteropProcessor.java | 39 -
.../eventstorage/GridEventStorageManager.java | 10 +-
.../platform/PlatformAwareEventFilter.java | 37 +
.../platform/PlatformLocalEventListener.java | 28 +
.../cache/GridCacheEvictionManager.java | 2 +-
.../near/IgniteCacheNearOnlyTxTest.java | 82 +-
.../lru/LruNearEvictionPolicySelfTest.java | 29 +-
.../LruNearOnlyNearEvictionPolicySelfTest.java | 55 +-
modules/platform/pom.xml | 65 ++
.../Apache.Ignite.Core.csproj | 47 +
.../main/dotnet/Apache.Ignite.Core/Ignition.cs | 23 +
.../Properties/AssemblyInfo.cs | 35 +
.../platform/src/main/dotnet/Apache.Ignite.sln | 35 +
.../ignite/internal/platform/Platform.java | 39 +
.../internal/platform/PlatformBootstrap.java | 35 +
.../platform/PlatformBootstrapFactory.java | 37 +
.../internal/platform/PlatformException.java | 71 ++
.../internal/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 ++
.../Apache.Ignite.Core.Tests.csproj | 64 ++
.../Apache.Ignite.Core.Tests/IgnitionTest.cs | 30 +
.../Properties/AssemblyInfo.cs | 35 +
.../Apache.Ignite.Core.Tests/TestRunner.cs | 70 ++
parent/pom.xml | 4 +
pom.xml | 7 +-
52 files changed, 4455 insertions(+), 531 deletions(-)
----------------------------------------------------------------------