ignite-471: revert 8a6dd007d79e6bd62fb288f1c38310860949ca45
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/9433882d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/9433882d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/9433882d Branch: refs/heads/ignite-471 Commit: 9433882d6f8de71f477e83cbcf38ae2314610683 Parents: 63e7952 Author: Denis Magda <dma...@gridgain.com> Authored: Mon May 18 11:32:06 2015 +0300 Committer: Denis Magda <dma...@gridgain.com> Committed: Mon May 18 11:32:06 2015 +0300 ---------------------------------------------------------------------- assembly/release-base.xml | 4 +- bin/ignite-schema-import.bat | 2 +- bin/ignite-schema-import.sh | 2 +- bin/ignite.bat | 2 +- bin/ignite.sh | 2 +- bin/ignitevisorcmd.bat | 2 +- bin/ignitevisorcmd.sh | 2 +- bin/include/build-classpath.bat | 46 + bin/include/build-classpath.sh | 71 ++ bin/include/functions.sh | 2 +- bin/include/target-classpath.bat | 46 - bin/include/target-classpath.sh | 71 -- .../streaming/StreamTransformerExample.java | 4 +- .../streaming/StreamVisitorExample.java | 4 +- .../ignite/examples/streaming/package-info.java | 1 - .../streaming/wordcount/CacheConfig.java | 2 +- .../streaming/wordcount/QueryWords.java | 12 +- .../streaming/wordcount/StreamWords.java | 12 +- .../streaming/wordcount/package-info.java | 1 - .../socket/WordsSocketStreamerClient.java | 82 ++ .../socket/WordsSocketStreamerServer.java | 124 +++ .../wordcount/socket/package-info.java | 21 + .../org/apache/ignite/internal/IgnitionEx.java | 136 +-- .../internal/direct/DirectByteBufferStream.java | 4 +- .../internal/interop/InteropBootstrap.java | 34 + .../interop/InteropBootstrapFactory.java | 39 + .../internal/interop/InteropIgnition.java | 103 ++ .../internal/interop/InteropProcessor.java | 25 + .../eventstorage/GridEventStorageManager.java | 5 +- .../processors/cache/GridCacheAdapter.java | 127 +-- .../processors/cache/GridCacheContext.java | 7 + .../processors/cache/GridCacheMapEntry.java | 106 +- .../processors/cache/GridCacheMvccManager.java | 4 +- .../GridDistributedCacheAdapter.java | 210 ++-- .../distributed/GridDistributedLockRequest.java | 111 +- .../GridDistributedTxFinishRequest.java | 70 +- .../GridDistributedTxPrepareRequest.java | 112 +- .../GridDistributedTxRemoteAdapter.java | 20 +- .../distributed/dht/GridDhtCacheAdapter.java | 16 +- .../distributed/dht/GridDhtLockFuture.java | 2 - .../distributed/dht/GridDhtLockRequest.java | 45 +- .../dht/GridDhtOffHeapCacheEntry.java | 63 ++ .../dht/GridDhtTransactionalCacheAdapter.java | 15 +- .../distributed/dht/GridDhtTxFinishFuture.java | 3 - .../distributed/dht/GridDhtTxFinishRequest.java | 43 +- .../cache/distributed/dht/GridDhtTxLocal.java | 38 +- .../distributed/dht/GridDhtTxLocalAdapter.java | 95 +- .../cache/distributed/dht/GridDhtTxMapping.java | 2 +- .../distributed/dht/GridDhtTxPrepareFuture.java | 99 +- .../dht/GridDhtTxPrepareRequest.java | 60 +- .../cache/distributed/dht/GridDhtTxRemote.java | 8 +- .../distributed/dht/GridNoStorageCacheMap.java | 4 +- .../dht/atomic/GridDhtAtomicCache.java | 3 + .../atomic/GridDhtAtomicOffHeapCacheEntry.java | 63 ++ .../dht/colocated/GridDhtColocatedCache.java | 5 +- .../colocated/GridDhtColocatedLockFuture.java | 31 +- .../GridDhtColocatedOffHeapCacheEntry.java | 63 ++ .../colocated/GridDhtDetachedCacheEntry.java | 4 +- .../GridDhtPartitionsExchangeFuture.java | 2 +- .../distributed/near/GridNearCacheAdapter.java | 3 + .../distributed/near/GridNearCacheEntry.java | 4 +- .../distributed/near/GridNearLockFuture.java | 11 - .../distributed/near/GridNearLockRequest.java | 61 +- .../near/GridNearOffHeapCacheEntry.java | 60 + .../near/GridNearOptimisticTxPrepareFuture.java | 768 +++++++++++++ .../GridNearPessimisticTxPrepareFuture.java | 347 ++++++ .../near/GridNearTransactionalCache.java | 4 - .../near/GridNearTxFinishRequest.java | 28 +- .../cache/distributed/near/GridNearTxLocal.java | 104 +- .../near/GridNearTxPrepareFuture.java | 1050 ------------------ .../near/GridNearTxPrepareFutureAdapter.java | 226 ++++ .../near/GridNearTxPrepareRequest.java | 52 +- .../distributed/near/GridNearTxRemote.java | 24 +- .../cache/local/GridLocalCacheEntry.java | 18 + .../cache/transactions/IgniteInternalTx.java | 14 +- .../transactions/IgniteTransactionsImpl.java | 4 +- .../cache/transactions/IgniteTxAdapter.java | 74 +- .../cache/transactions/IgniteTxEntry.java | 48 +- .../cache/transactions/IgniteTxHandler.java | 74 +- .../transactions/IgniteTxLocalAdapter.java | 167 +-- .../cache/transactions/IgniteTxLocalEx.java | 21 +- .../cache/transactions/IgniteTxManager.java | 74 +- .../processors/resource/GridResourceField.java | 16 +- .../processors/resource/GridResourceIoc.java | 389 +++---- .../processors/resource/GridResourceMethod.java | 13 + .../resource/GridResourceProcessor.java | 20 +- .../ignite/internal/util/IgniteUtils.java | 22 +- .../util/lang/GridComputeJobWrapper.java | 96 -- .../internal/util/nio/GridBufferedParser.java | 4 - .../internal/util/nio/GridDelimitedParser.java | 91 ++ .../util/nio/GridNioDelimitedBuffer.java | 106 ++ .../communication/tcp/TcpCommunicationSpi.java | 2 +- .../spi/discovery/tcp/TcpDiscoverySpi.java | 48 +- .../discovery/tcp/TcpDiscoverySpiAdapter.java | 8 +- .../org/apache/ignite/stream/StreamAdapter.java | 111 ++ .../ignite/stream/StreamTupleExtractor.java | 33 + .../stream/socket/SocketMessageConverter.java | 31 + .../ignite/stream/socket/SocketStreamer.java | 218 ++++ .../ignite/stream/socket/package-info.java | 21 + .../resources/META-INF/classnames.properties | 1 - .../cache/CacheOffheapMapEntrySelfTest.java | 168 +++ .../cache/CacheRemoveAllSelfTest.java | 81 ++ .../GridCacheAbstractFailoverSelfTest.java | 8 +- .../GridCacheAbstractNodeRestartSelfTest.java | 11 +- .../distributed/GridCacheLockAbstractTest.java | 2 - .../distributed/IgniteTxGetAfterStopTest.java | 131 +++ ...achePartitionedNearDisabledLockSelfTest.java | 47 + ...ePrimaryNodeFailureRecoveryAbstractTest.java | 4 +- ...idCacheAtomicReplicatedFailoverSelfTest.java | 6 + .../GridCachePartitionedTxSalvageSelfTest.java | 25 +- .../near/NoneRebalanceModeSelfTest.java | 67 ++ .../GridCacheReplicatedFailoverSelfTest.java | 6 + .../GridCacheReplicatedLockSelfTest.java | 5 + .../GridCacheReplicatedNodeRestartSelfTest.java | 80 ++ .../GridCacheLocalIsolatedNodesSelfTest.java | 18 +- .../util/nio/GridNioDelimitedBufferTest.java | 112 ++ .../discovery/tcp/TcpDiscoveryRestartTest.java | 199 ++++ .../stream/socket/SocketStreamerSelfTest.java | 316 ++++++ .../ignite/stream/socket/package-info.java | 21 + .../IgniteCacheFailoverTestSuite.java | 10 +- .../testsuites/IgniteCacheRestartTestSuite.java | 8 +- .../testsuites/IgniteCacheTestSuite2.java | 2 + .../testsuites/IgniteCacheTestSuite3.java | 2 + .../testsuites/IgniteCacheTestSuite4.java | 4 + .../testsuites/IgniteStreamTestSuite.java | 39 + .../testsuites/IgniteUtilSelfTestSuite.java | 1 + .../cache/GridCacheOffheapIndexGetSelfTest.java | 111 ++ .../IgniteCacheWithIndexingTestSuite.java | 2 + .../processors/cache/jta/CacheJtaManager.java | 4 +- .../scalar/tests/ScalarCacheQueriesSpec.scala | 154 +-- .../ignite/scalar/tests/ScalarCacheSpec.scala | 23 +- .../scalar/tests/ScalarConversionsSpec.scala | 43 +- .../scalar/tests/ScalarProjectionSpec.scala | 128 ++- .../scalar/tests/ScalarReturnableSpec.scala | 41 +- modules/visor-console/pom.xml | 2 +- .../ignite/visor/VisorRuntimeBaseSpec.scala | 2 +- .../visor/commands/VisorArgListSpec.scala | 60 +- .../commands/VisorFileNameCompleterSpec.scala | 34 +- .../commands/ack/VisorAckCommandSpec.scala | 20 +- .../commands/alert/VisorAlertCommandSpec.scala | 68 +- .../cache/VisorCacheClearCommandSpec.scala | 48 +- .../commands/cache/VisorCacheCommandSpec.scala | 66 +- .../config/VisorConfigurationCommandSpec.scala | 8 +- .../cswap/VisorCacheSwapCommandSpec.scala | 24 +- .../deploy/VisorDeployCommandSpec.scala | 10 +- .../disco/VisorDiscoveryCommandSpec.scala | 46 +- .../events/VisorEventsCommandSpec.scala | 28 +- .../visor/commands/gc/VisorGcCommandSpec.scala | 30 +- .../commands/help/VisorHelpCommandSpec.scala | 57 +- .../commands/kill/VisorKillCommandSpec.scala | 58 +- .../commands/log/VisorLogCommandSpec.scala | 10 +- .../commands/mem/VisorMemoryCommandSpec.scala | 77 +- .../commands/node/VisorNodeCommandSpec.scala | 22 +- .../commands/open/VisorOpenCommandSpec.scala | 16 +- .../commands/ping/VisorPingCommandSpec.scala | 16 +- .../commands/start/VisorStartCommandSpec.scala | 126 +-- .../commands/tasks/VisorTasksCommandSpec.scala | 112 +- .../commands/top/VisorTopologyCommandSpec.scala | 52 +- .../commands/vvm/VisorVvmCommandSpec.scala | 30 +- parent/pom.xml | 2 + pom.xml | 85 +- 161 files changed, 5910 insertions(+), 3836 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/assembly/release-base.xml ---------------------------------------------------------------------- diff --git a/assembly/release-base.xml b/assembly/release-base.xml index 6d6465e..88f1d10 100644 --- a/assembly/release-base.xml +++ b/assembly/release-base.xml @@ -71,7 +71,7 @@ <excludes> <exclude>**/*hadoop*.bat</exclude> <exclude>igniterouter.bat</exclude> - <exclude>**/target-classpath.bat</exclude> + <exclude>**/build-classpath.bat</exclude> <exclude>ignitevisorcmd.bat</exclude> <exclude>ignite-schema-import.bat</exclude> </excludes> @@ -87,7 +87,7 @@ <excludes> <exclude>**/*hadoop*.sh</exclude> <exclude>igniterouter.sh</exclude> - <exclude>**/target-classpath.sh</exclude> + <exclude>**/build-classpath.sh</exclude> <exclude>**/service.sh</exclude> <exclude>ignitevisorcmd.sh</exclude> <exclude>ignite-schema-import.sh</exclude> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/bin/ignite-schema-import.bat ---------------------------------------------------------------------- diff --git a/bin/ignite-schema-import.bat b/bin/ignite-schema-import.bat index 4731105..a4ec86b 100644 --- a/bin/ignite-schema-import.bat +++ b/bin/ignite-schema-import.bat @@ -91,7 +91,7 @@ if /i "%SCRIPTS_HOME%\" == "%~dp0" goto run :: Set IGNITE_LIBS :: call "%SCRIPTS_HOME%\include\setenv.bat" -call "%SCRIPTS_HOME%\include\target-classpath.bat" &:: Will be removed in release. +call "%SCRIPTS_HOME%\include\build-classpath.bat" &:: Will be removed in the binary release. set CP=%JAVA_HOME%\jre\lib\jfxrt.jar;%IGNITE_HOME%\bin\include\schema-import\*;%IGNITE_LIBS% :: http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/bin/ignite-schema-import.sh ---------------------------------------------------------------------- diff --git a/bin/ignite-schema-import.sh b/bin/ignite-schema-import.sh index 0a70d54..1029882 100755 --- a/bin/ignite-schema-import.sh +++ b/bin/ignite-schema-import.sh @@ -57,7 +57,7 @@ setIgniteHome # Set IGNITE_LIBS. # . "${SCRIPTS_HOME}"/include/setenv.sh -. "${SCRIPTS_HOME}"/include/target-classpath.sh # Will be removed in release. +. "${SCRIPTS_HOME}"/include/build-classpath.sh # Will be removed in the binary release. CP="${JAVA_HOME}/jre/lib/jfxrt.jar${SEP}${IGNITE_HOME}/bin/include/schema-import/*${SEP}${IGNITE_LIBS}" # http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/bin/ignite.bat ---------------------------------------------------------------------- diff --git a/bin/ignite.bat b/bin/ignite.bat index 687db60..1a4a58c 100644 --- a/bin/ignite.bat +++ b/bin/ignite.bat @@ -102,7 +102,7 @@ if "%OS%" == "Windows_NT" set PROG_NAME=%~nx0% :: Set IGNITE_LIBS :: call "%SCRIPTS_HOME%\include\setenv.bat" -call "%SCRIPTS_HOME%\include\target-classpath.bat" &:: Will be removed in release. +call "%SCRIPTS_HOME%\include\build-classpath.bat" &:: Will be removed in the binary release. set CP=%IGNITE_LIBS% :: http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/bin/ignite.sh ---------------------------------------------------------------------- diff --git a/bin/ignite.sh b/bin/ignite.sh index a246613..660a80f 100755 --- a/bin/ignite.sh +++ b/bin/ignite.sh @@ -58,7 +58,7 @@ fi # Set IGNITE_LIBS. # . "${SCRIPTS_HOME}"/include/setenv.sh -. "${SCRIPTS_HOME}"/include/target-classpath.sh # Will be removed in release. +. "${SCRIPTS_HOME}"/include/build-classpath.sh # Will be removed in the binary release. CP="${IGNITE_LIBS}" RANDOM_NUMBER=$("$JAVA" -cp "${CP}" org.apache.ignite.startup.cmdline.CommandLineRandomNumberGenerator) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/bin/ignitevisorcmd.bat ---------------------------------------------------------------------- diff --git a/bin/ignitevisorcmd.bat b/bin/ignitevisorcmd.bat index 1cf2b26..4a1aafd 100644 --- a/bin/ignitevisorcmd.bat +++ b/bin/ignitevisorcmd.bat @@ -100,7 +100,7 @@ if "%OS%" == "Windows_NT" set PROG_NAME=%~nx0% :: Set IGNITE_LIBS :: call "%SCRIPTS_HOME%\include\setenv.bat" -call "%SCRIPTS_HOME%\include\target-classpath.bat" &:: Will be removed in release. +call "%SCRIPTS_HOME%\include\build-classpath.bat" &:: Will be removed in the binary release. set CP=%IGNITE_HOME%\bin\include\visor-common\*;%IGNITE_HOME%\bin\include\visorcmd\*;%IGNITE_LIBS% :: http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/bin/ignitevisorcmd.sh ---------------------------------------------------------------------- diff --git a/bin/ignitevisorcmd.sh b/bin/ignitevisorcmd.sh index 6118560..fe74f6a 100755 --- a/bin/ignitevisorcmd.sh +++ b/bin/ignitevisorcmd.sh @@ -53,7 +53,7 @@ setIgniteHome # Set IGNITE_LIBS. # . "${SCRIPTS_HOME}"/include/setenv.sh -. "${SCRIPTS_HOME}"/include/target-classpath.sh # Will be removed in release. +. "${SCRIPTS_HOME}"/include/build-classpath.sh # Will be removed in the binary release. CP="${IGNITE_HOME}/bin/include/visor-common/*${SEP}${IGNITE_HOME}/bin/include/visorcmd/*${SEP}${IGNITE_LIBS}" # http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/bin/include/build-classpath.bat ---------------------------------------------------------------------- diff --git a/bin/include/build-classpath.bat b/bin/include/build-classpath.bat new file mode 100644 index 0000000..5f932d3 --- /dev/null +++ b/bin/include/build-classpath.bat @@ -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. +:: + +:: Target class path resolver. +:: +:: Can be used like: +:: call "%IGNITE_HOME%\bin\include\build-classpath.bat" +:: in other scripts to set classpath using libs from target folder. +:: +:: Will be excluded in release. + +@echo off + +for /D %%F in (modules\*) do if not %%F == "modules" call :includeToClassPath %%F + +for /D %%F in (%IGNITE_HOME%\modules\*) do if not %%F == "%IGNITE_HOME%\modules" call :includeToClassPath %%F + +goto :eof + +:includeToClassPath +if exist "%1\target\" ( + if exist "%1\target\classes\" call :concat %1\target\classes + + if exist "%1\target\test-classes\" call :concat %1\target\test-classes + + if exist "%1\target\libs\" call :concat %1\target\libs\* +) +goto :eof + +:concat +set IGNITE_LIBS=%IGNITE_LIBS%;%1 +goto :eof http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/bin/include/build-classpath.sh ---------------------------------------------------------------------- diff --git a/bin/include/build-classpath.sh b/bin/include/build-classpath.sh new file mode 100644 index 0000000..9f0c878 --- /dev/null +++ b/bin/include/build-classpath.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# +# 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. +# + +# Target class path resolver. +# +# Can be used like: +# . "${IGNITE_HOME}"/bin/include/build-classpath.sh +# in other scripts to set classpath using libs from target folder. +# +# Will be excluded in release. + + +# +# OS specific support. +# +SEP=":"; + +case "`uname`" in + MINGW*) + SEP=";"; + export IGNITE_HOME=`echo $IGNITE_HOME | sed -e 's/^\/\([a-zA-Z]\)/\1:/'` + ;; + CYGWIN*) + SEP=";"; + export IGNITE_HOME=`echo $IGNITE_HOME | sed -e 's/^\/\([a-zA-Z]\)/\1:/'` + ;; +esac + +includeToClassPath() { + for file in $1/* + do + if [ -d ${file} ] && [ -d "${file}/target" ]; then + if [ -d "${file}/target/classes" ]; then + IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/classes + fi + + if [ -d "${file}/target/test-classes" ]; then + IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/test-classes + fi + + if [ -d "${file}/target/libs" ]; then + IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/libs/* + fi + fi + done +} + +# +# Include target libraries for enterprise modules to classpath. +# +includeToClassPath modules + +# +# Include target libraries for opensourse modules to classpath. +# +includeToClassPath ${IGNITE_HOME}/modules http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/bin/include/functions.sh ---------------------------------------------------------------------- diff --git a/bin/include/functions.sh b/bin/include/functions.sh index f0430c1..b18b150 100755 --- a/bin/include/functions.sh +++ b/bin/include/functions.sh @@ -34,7 +34,7 @@ checkJava() { # Check JAVA_HOME. if [ "$JAVA_HOME" = "" ]; then - JAVA=`which java` + JAVA=`type -p java` RETCODE=$? if [ $RETCODE -ne 0 ]; then http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/bin/include/target-classpath.bat ---------------------------------------------------------------------- diff --git a/bin/include/target-classpath.bat b/bin/include/target-classpath.bat deleted file mode 100644 index 4416557..0000000 --- a/bin/include/target-classpath.bat +++ /dev/null @@ -1,46 +0,0 @@ -:: -:: Licensed to the Apache Software Foundation (ASF) under one or more -:: contributor license agreements. See the NOTICE file distributed with -:: this work for additional information regarding copyright ownership. -:: The ASF licenses this file to You under the Apache License, Version 2.0 -:: (the "License"); you may not use this file except in compliance with -:: the License. You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. -:: - -:: Target class path resolver. -:: -:: Can be used like: -:: call "%IGNITE_HOME%\bin\include\target-classpath.bat" -:: in other scripts to set classpath using libs from target folder. -:: -:: Will be excluded in release. - -@echo off - -for /D %%F in (modules\*) do if not %%F == "modules" call :includeToClassPath %%F - -for /D %%F in (%IGNITE_HOME%\modules\*) do if not %%F == "%IGNITE_HOME%\modules" call :includeToClassPath %%F - -goto :eof - -:includeToClassPath -if exist "%1\target\" ( - if exist "%1\target\classes\" call :concat %1\target\classes - - if exist "%1\target\test-classes\" call :concat %1\target\test-classes - - if exist "%1\target\libs\" call :concat %1\target\libs\* -) -goto :eof - -:concat -set IGNITE_LIBS=%IGNITE_LIBS%;%1 -goto :eof http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/bin/include/target-classpath.sh ---------------------------------------------------------------------- diff --git a/bin/include/target-classpath.sh b/bin/include/target-classpath.sh deleted file mode 100644 index 871d517..0000000 --- a/bin/include/target-classpath.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh -# -# 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. -# - -# Target class path resolver. -# -# Can be used like: -# . "${IGNITE_HOME}"/bin/include/target-classpath.sh -# in other scripts to set classpath using libs from target folder. -# -# Will be excluded in release. - - -# -# OS specific support. -# -SEP=":"; - -case "`uname`" in - MINGW*) - SEP=";"; - export IGNITE_HOME=`echo $IGNITE_HOME | sed -e 's/^\/\([a-zA-Z]\)/\1:/'` - ;; - CYGWIN*) - SEP=";"; - export IGNITE_HOME=`echo $IGNITE_HOME | sed -e 's/^\/\([a-zA-Z]\)/\1:/'` - ;; -esac - -includeToClassPath() { - for file in $1/* - do - if [ -d ${file} ] && [ -d "${file}/target" ]; then - if [ -d "${file}/target/classes" ]; then - IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/classes - fi - - if [ -d "${file}/target/test-classes" ]; then - IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/test-classes - fi - - if [ -d "${file}/target/libs" ]; then - IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/libs/* - fi - fi - done -} - -# -# Include target libraries for enterprise modules to classpath. -# -includeToClassPath modules - -# -# Include target libraries for opensourse modules to classpath. -# -includeToClassPath ${IGNITE_HOME}/modules http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java index 5e95892..966fce2 100644 --- a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java @@ -30,11 +30,9 @@ import java.util.*; * Stream random numbers into the streaming cache. * To start the example, you should: * <ul> - * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li> + * <li>Start a few nodes using {@link ExampleNodeStartup}.</li> * <li>Start streaming using {@link StreamTransformerExample}.</li> * </ul> - * <p> - * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM. */ public class StreamTransformerExample { /** Random number generator. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java index 0fbce68..baae5af 100644 --- a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java @@ -31,11 +31,9 @@ import java.util.*; * Stream random numbers into the streaming cache. * To start the example, you should: * <ul> - * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li> + * <li>Start a few nodes using {@link ExampleNodeStartup}.</li> * <li>Start streaming using {@link StreamVisitorExample}.</li> * </ul> - * <p> - * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM. */ public class StreamVisitorExample { /** Random number generator. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java b/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java index 43dea13..43fbab3 100644 --- a/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java +++ b/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java @@ -16,7 +16,6 @@ */ /** - * <!-- Package description. --> * Demonstrates usage of data streamer. */ package org.apache.ignite.examples.streaming; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/CacheConfig.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/CacheConfig.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/CacheConfig.java index 58704ca..d17b97d 100644 --- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/CacheConfig.java +++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/CacheConfig.java @@ -26,7 +26,7 @@ import javax.cache.expiry.*; import static java.util.concurrent.TimeUnit.*; /** - * Configuration for the streaming cache to store the stream of random numbers. + * Configuration for the streaming cache to store the stream of words. * This cache is configured with sliding window of 1 second, which means that * data older than 1 second will be automatically removed from the cache. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java index 3bd9d3d..58c6ef2 100644 --- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java +++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java @@ -28,14 +28,18 @@ import java.util.*; * Periodically query popular numbers from the streaming cache. * To start the example, you should: * <ul> - * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li> + * <li>Start a few nodes using {@link ExampleNodeStartup}.</li> * <li>Start streaming using {@link StreamWords}.</li> - * <li>Start querying popular numbers using {@link QueryWords}.</li> + * <li>Start querying popular words using {@link QueryWords}.</li> * </ul> - * <p> - * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM. */ public class QueryWords { + /** + * Schedules words query execution. + * + * @param args Command line arguments (none required). + * @throws Exception If failed. + */ public static void main(String[] args) throws Exception { // Mark this cluster member as client. Ignition.setClientMode(true); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java index c59fa51..6024c4b 100644 --- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java +++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java @@ -27,14 +27,18 @@ import java.io.*; * Stream words into Ignite cache. * To start the example, you should: * <ul> - * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li> + * <li>Start a few nodes using {@link ExampleNodeStartup}.</li> * <li>Start streaming using {@link StreamWords}.</li> - * <li>Start querying popular numbers using {@link QueryWords}.</li> + * <li>Start querying popular words using {@link QueryWords}.</li> * </ul> - * <p> - * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM. */ public class StreamWords { + /** + * Starts words streaming. + * + * @param args Command line arguments (none required). + * @throws Exception If failed. + */ public static void main(String[] args) throws Exception { // Mark this cluster member as client. Ignition.setClientMode(true); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/package-info.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/package-info.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/package-info.java index 010f86a..5d48ae3 100644 --- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/package-info.java +++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/package-info.java @@ -16,7 +16,6 @@ */ /** - * <!-- Package description. --> * Streaming word count example. */ package org.apache.ignite.examples.streaming.wordcount; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerClient.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerClient.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerClient.java new file mode 100644 index 0000000..c4d7b8c --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerClient.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.streaming.wordcount.socket; + +import org.apache.ignite.examples.*; +import org.apache.ignite.examples.streaming.wordcount.*; +import org.apache.ignite.stream.socket.*; + +import java.io.*; +import java.net.*; + +/** + * Example demonstrates streaming of data from external components into Ignite cache. + * <p> + * {@code WordsSocketStreamerClient} is simple socket streaming client implementation that sends words to socket server + * based on {@link SocketStreamer} using message delimiter based protocol. Example illustrates usage of TCP socket + * streamer in case of non-Java clients. In this example words are zero-terminated strings. + * <p> + * To start the example, you should: + * <ul> + * <li>Start a few nodes using {@link ExampleNodeStartup}.</li> + * <li>Start socket server using {@link WordsSocketStreamerServer}.</li> + * <li>Start a few socket clients using {@link WordsSocketStreamerClient}.</li> + * <li>Start querying popular words using {@link QueryWords}.</li> + * </ul> + */ +public class WordsSocketStreamerClient { + /** Port. */ + private static final int PORT = 5555; + + /** Delimiter. */ + private static final byte[] DELIM = new byte[] {0}; + + /** + * @param args Args. + */ + public static void main(String[] args) throws IOException { + InetAddress addr = InetAddress.getLocalHost(); + + try ( + Socket sock = new Socket(addr, PORT); + OutputStream oos = new BufferedOutputStream(sock.getOutputStream()) + ) { + System.out.println("Words streaming started."); + + while (true) { + try (InputStream in = WordsSocketStreamerClient.class.getResourceAsStream("../alice-in-wonderland.txt"); + LineNumberReader rdr = new LineNumberReader(new InputStreamReader(in))) { + for (String line = rdr.readLine(); line != null; line = rdr.readLine()) { + for (String word : line.split(" ")) { + if (!word.isEmpty()) { + // Stream words into Ignite through socket. + byte[] arr = word.getBytes("ASCII"); + + // Write message + oos.write(arr); + + // Write message delimiter + oos.write(DELIM); + } + } + } + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java new file mode 100644 index 0000000..9e68096 --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.streaming.wordcount.socket; + +import org.apache.ignite.*; +import org.apache.ignite.cache.affinity.*; +import org.apache.ignite.examples.*; +import org.apache.ignite.examples.streaming.wordcount.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.stream.*; +import org.apache.ignite.stream.socket.*; + +import java.io.*; +import java.net.*; +import java.util.*; + +/** + * Example demonstrates streaming of data from external components into Ignite cache. + * <p> + * {@code WordsSocketStreamerServer} is simple socket streaming server implementation that + * receives words from socket using {@link SocketStreamer} and message delimiter based protocol + * and streams them into Ignite cache. Example illustrates usage of TCP socket streamer in case of non-Java clients. + * In this example words are zero-terminated strings. + * <p> + * To start the example, you should: + * <ul> + * <li>Start a few nodes using {@link ExampleNodeStartup}.</li> + * <li>Start socket server using {@link WordsSocketStreamerServer}.</li> + * <li>Start a few socket clients using {@link WordsSocketStreamerClient}.</li> + * <li>Start querying popular words using {@link QueryWords}.</li> + * </ul> + */ +public class WordsSocketStreamerServer { + /** Port. */ + private static final int PORT = 5555; + + /** Delimiter. */ + private static final byte[] DELIM = new byte[] {0}; + + /** + * Starts socket streaming server. + * + * @param args Command line arguments (none required). + * @throws Exception If failed. + */ + public static void main(String[] args) throws Exception { + // Mark this cluster member as client. + Ignition.setClientMode(true); + + Ignite ignite = Ignition.start("examples/config/example-ignite.xml"); + + if (!ExamplesUtils.hasServerNodes(ignite)) { + ignite.close(); + + return; + } + + // The cache is configured with sliding window holding 1 second of the streaming data. + IgniteCache<AffinityUuid, String> stmCache = ignite.getOrCreateCache(CacheConfig.wordCache()); + + IgniteDataStreamer<AffinityUuid, String> stmr = ignite.dataStreamer(stmCache.getName()); + + InetAddress addr = InetAddress.getLocalHost(); + + // Configure socket streamer + SocketStreamer<String, AffinityUuid, String> sockStmr = new SocketStreamer<>(); + + sockStmr.setAddr(addr); + + sockStmr.setPort(PORT); + + sockStmr.setDelimiter(DELIM); + + sockStmr.setIgnite(ignite); + + sockStmr.setStreamer(stmr); + + // Converter from zero-terminated string to Java strings. + sockStmr.setConverter(new SocketMessageConverter<String>() { + @Override public String convert(byte[] msg) { + try { + return new String(msg, "ASCII"); + } + catch (UnsupportedEncodingException e) { + throw new IgniteException(e); + } + } + }); + + sockStmr.setTupleExtractor(new StreamTupleExtractor<String, AffinityUuid, String>() { + @Override public Map.Entry<AffinityUuid, String> extract(String word) { + // By using AffinityUuid we ensure that identical + // words are processed on the same cluster node. + return new IgniteBiTuple<>(new AffinityUuid(word), word); + } + }); + + try { + sockStmr.start(); + } + catch (IgniteException e) { + System.err.println("Streaming server didn't start due to an error: "); + + e.printStackTrace(); + + ignite.close(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/package-info.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/package-info.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/package-info.java new file mode 100644 index 0000000..048299f --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/package-info.java @@ -0,0 +1,21 @@ +/* + * 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. + */ + +/** + * Contains {@link org.apache.ignite.stream.socket.SocketStreamer} usage examples. + */ +package org.apache.ignite.examples.streaming.wordcount.socket; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java index 8d88677..d54e06f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java @@ -532,22 +532,6 @@ public class IgnitionEx { } /** - * Start Grid passing a closure which will modify configuration before it is passed to start routine. - * - * @param springCfgPath Spring config path. - * @param gridName Grid name. - * @param cfgClo Configuration closure. - * @return Started Grid. - * @throws IgniteCheckedException If failed. - */ - public static Ignite startWithClosure(@Nullable String springCfgPath, @Nullable String gridName, - IgniteClosure<IgniteConfiguration, IgniteConfiguration> cfgClo) throws IgniteCheckedException { - URL url = U.resolveSpringUrl(springCfgPath); - - return start(url, gridName, null, cfgClo); - } - - /** * Loads all grid configurations specified within given Spring XML configuration file. * <p> * Usually Spring XML configuration file will contain only one Grid definition. Note that @@ -734,7 +718,40 @@ public class IgnitionEx { */ public static Ignite start(URL springCfgUrl, @Nullable String gridName, @Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException { - return start(springCfgUrl, gridName, springCtx, null); + A.notNull(springCfgUrl, "springCfgUrl"); + + boolean isLog4jUsed = U.gridClassLoader().getResource("org/apache/log4j/Appender.class") != null; + + IgniteBiTuple<Object, Object> t = null; + + if (isLog4jUsed) { + try { + t = U.addLog4jNoOpLogger(); + } + catch (IgniteCheckedException ignore) { + isLog4jUsed = false; + } + } + + Collection<Handler> savedHnds = null; + + if (!isLog4jUsed) + savedHnds = U.addJavaNoOpLogger(); + + IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap; + + try { + cfgMap = loadConfigurations(springCfgUrl); + } + finally { + if (isLog4jUsed && t != null) + U.removeLog4jNoOpLogger(t); + + if (!isLog4jUsed) + U.removeJavaNoOpLogger(savedHnds); + } + + return startConfigurations(cfgMap, springCfgUrl, gridName, springCtx); } /** @@ -780,73 +797,6 @@ public class IgnitionEx { */ public static Ignite start(InputStream springCfgStream, @Nullable String gridName, @Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException { - return start(springCfgStream, gridName, springCtx, null); - } - - /** - * Internal Spring-based start routine. - * - * @param springCfgUrl Spring XML configuration file URL. This cannot be {@code null}. - * @param gridName Grid name that will override default. - * @param springCtx Optional Spring application context. - * @param cfgClo Optional closure to change configuration before it is used to start the grid. - * @return Started grid. - * @throws IgniteCheckedException If failed. - */ - private static Ignite start(final URL springCfgUrl, @Nullable String gridName, - @Nullable GridSpringResourceContext springCtx, - @Nullable IgniteClosure<IgniteConfiguration, IgniteConfiguration> cfgClo) - throws IgniteCheckedException { - A.notNull(springCfgUrl, "springCfgUrl"); - - boolean isLog4jUsed = U.gridClassLoader().getResource("org/apache/log4j/Appender.class") != null; - - IgniteBiTuple<Object, Object> t = null; - - if (isLog4jUsed) { - try { - t = U.addLog4jNoOpLogger(); - } - catch (IgniteCheckedException ignore) { - isLog4jUsed = false; - } - } - - Collection<Handler> savedHnds = null; - - if (!isLog4jUsed) - savedHnds = U.addJavaNoOpLogger(); - - IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap; - - try { - cfgMap = loadConfigurations(springCfgUrl); - } - finally { - if (isLog4jUsed && t != null) - U.removeLog4jNoOpLogger(t); - - if (!isLog4jUsed) - U.removeJavaNoOpLogger(savedHnds); - } - - return startConfigurations(cfgMap, springCfgUrl, gridName, springCtx, cfgClo); - } - - /** - * Internal Spring-based start routine. - * - * @param springCfgStream Input stream containing Spring XML configuration. This cannot be {@code null}. - * @param gridName Grid name that will override default. - * @param springCtx Optional Spring application context. - * @param cfgClo Optional closure to change configuration before it is used to start the grid. - * @return Started grid. - * @throws IgniteCheckedException If failed. - */ - private static Ignite start(final InputStream springCfgStream, @Nullable String gridName, - @Nullable GridSpringResourceContext springCtx, - @Nullable IgniteClosure<IgniteConfiguration, IgniteConfiguration> cfgClo) - throws IgniteCheckedException { A.notNull(springCfgStream, "springCfgUrl"); boolean isLog4jUsed = U.gridClassLoader().getResource("org/apache/log4j/Appender.class") != null; @@ -880,7 +830,7 @@ public class IgnitionEx { U.removeJavaNoOpLogger(savedHnds); } - return startConfigurations(cfgMap, null, gridName, springCtx, cfgClo); + return startConfigurations(cfgMap, null, gridName, springCtx); } /** @@ -890,7 +840,6 @@ public class IgnitionEx { * @param springCfgUrl Spring XML configuration file URL. * @param gridName Grid name that will override default. * @param springCtx Optional Spring application context. - * @param cfgClo Optional closure to change configuration before it is used to start the grid. * @return Started grid. * @throws IgniteCheckedException If failed. */ @@ -898,8 +847,7 @@ public class IgnitionEx { IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap, URL springCfgUrl, @Nullable String gridName, - @Nullable GridSpringResourceContext springCtx, - @Nullable IgniteClosure<IgniteConfiguration, IgniteConfiguration> cfgClo) + @Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException { List<IgniteNamedInstance> grids = new ArrayList<>(cfgMap.size()); @@ -910,12 +858,6 @@ public class IgnitionEx { if (cfg.getGridName() == null && !F.isEmpty(gridName)) cfg.setGridName(gridName); - if (cfgClo != null) { - cfg = cfgClo.apply(cfg); - - assert cfg != null; - } - // Use either user defined context or our one. IgniteNamedInstance grid = start0( new GridStartContext(cfg, springCfgUrl, springCtx == null ? cfgMap.get2() : springCtx)); @@ -1600,9 +1542,9 @@ public class IgnitionEx { igfsExecSvc, restExecSvc, new CA() { @Override public void apply() { - startLatch.countDown(); - } - }); + startLatch.countDown(); + } + }); state = STARTED; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java index 64c895b..4ca318e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java @@ -66,10 +66,10 @@ public class DirectByteBufferStream { private static final short[] SHORT_ARR_EMPTY = new short[0]; /** */ - private static final int[] INT_ARR_EMPTY = new int[0]; + private static final int[] INT_ARR_EMPTY = U.EMPTY_INTS; /** */ - private static final long[] LONG_ARR_EMPTY = new long[0]; + private static final long[] LONG_ARR_EMPTY = U.EMPTY_LONGS; /** */ private static final float[] FLOAT_ARR_EMPTY = new float[0]; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/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 new file mode 100644 index 0000000..820bef9 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.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. + * @return Ignite node. + */ + public InteropProcessor start(IgniteConfiguration cfg, long envPtr); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/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 new file mode 100644 index 0000000..b61ca89 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrapFactory.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.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/incubator-ignite/blob/9433882d/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 new file mode 100644 index 0000000..f245122 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java @@ -0,0 +1,103 @@ +/* + * 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 { + /** + * Start Ignite node in interop mode. + * + * @param springCfgPath Spring configuration path. + * @param gridName Grid name. + * @param factoryId Factory ID. + * @param envPtr Environment pointer. + * @return Ignite instance. + */ + public static InteropProcessor start(@Nullable String springCfgPath, @Nullable String gridName, int factoryId, + long envPtr) { + IgniteConfiguration cfg = configuration(springCfgPath); + + if (gridName != null) + cfg.setGridName(gridName); + + InteropBootstrap bootstrap = bootstrap(factoryId); + + return bootstrap.start(cfg, envPtr); + } + + 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/incubator-ignite/blob/9433882d/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 new file mode 100644 index 0000000..6c55296 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.interop; + +/** + * Interop processor. + */ +public interface InteropProcessor { + // No-op. +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/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 4b969d7..010aab4 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 @@ -51,9 +51,6 @@ import static org.apache.ignite.internal.managers.communication.GridIoPolicy.*; * Grid event storage SPI manager. */ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi> { - /** */ - private static final int[] EMPTY = new int[0]; - /** Local event listeners. */ private final ConcurrentMap<Integer, Set<GridLocalEventListener>> lsnrs = new ConcurrentHashMap8<>(); @@ -107,7 +104,7 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi> int[] cfgInclEvtTypes0 = ctx.config().getIncludeEventTypes(); if (F.isEmpty(cfgInclEvtTypes0)) - cfgInclEvtTypes = EMPTY; + cfgInclEvtTypes = U.EMPTY_INTS; else { cfgInclEvtTypes0 = copy(cfgInclEvtTypes0); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index dc13d17..b972da8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -1133,7 +1133,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes); - ctx.kernalContext().task().execute(new ClearTask(ctx, keys), null).get(); + ctx.kernalContext().task().execute( + new ClearTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys), null).get(); } } @@ -1152,7 +1153,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V if (!nodes.isEmpty()) { ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes); - return ctx.kernalContext().task().execute(new ClearTask(ctx, keys), null); + return ctx.kernalContext().task().execute( + new ClearTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys), null); } else return new GridFinishedFuture<>(); @@ -3571,7 +3573,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes); - return ctx.kernalContext().task().execute(new SizeTask(ctx, peekModes), null); + return ctx.kernalContext().task().execute( + new SizeTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), peekModes), null); } /** {@inheritDoc} */ @@ -3903,9 +3906,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V READ_COMMITTED, tCfg.getDefaultTxTimeout(), !ctx.skipStore(), - 0, - /** group lock keys */null, - /** partition lock */false + 0 ); assert tx != null; @@ -3974,9 +3975,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V READ_COMMITTED, ctx.kernalContext().config().getTransactionConfiguration().getDefaultTxTimeout(), !ctx.skipStore(), - 0, - null, - false); + 0); return asyncOp(tx, op); } @@ -4827,13 +4826,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V private static final long serialVersionUID = 0L; /** - * Empty constructor for serialization. - */ - public GlobalClearAllJob() { - // No-op. - } - - /** * @param cacheName Cache name. * @param topVer Affinity topology version. */ @@ -4859,14 +4851,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V private static final long serialVersionUID = 0L; /** Keys to remove. */ - private Set<? extends K> keys; - - /** - * Empty constructor for serialization. - */ - public GlobalClearKeySetJob() { - // No-op. - } + private final Set<? extends K> keys; /** * @param cacheName Cache name. @@ -4897,14 +4882,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V private static final long serialVersionUID = 0L; /** Peek modes. */ - private CachePeekMode[] peekModes; - - /** - * Required by {@link Externalizable}. - */ - public SizeJob() { - // No-op. - } + private final CachePeekMode[] peekModes; /** * @param cacheName Cache name. @@ -5515,17 +5493,10 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V protected Ignite ignite; /** Affinity topology version. */ - protected AffinityTopologyVersion topVer; + protected final AffinityTopologyVersion topVer; /** Cache name. */ - protected String cacheName; - - /** - * Empty constructor for serialization. - */ - public TopologyVersionAwareJob() { - // No-op. - } + protected final String cacheName; /** * @param cacheName Cache name. @@ -5584,24 +5555,23 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V /** */ private static final long serialVersionUID = 0L; - /** Cache context. */ - private GridCacheContext ctx; + /** Cache name. */ + private final String cacheName; - /** Peek modes. */ - private CachePeekMode[] peekModes; + /** Affinity topology version. */ + private final AffinityTopologyVersion topVer; - /** - * Empty constructor for serialization. - */ - public SizeTask() { - // No-op. - } + /** Peek modes. */ + private final CachePeekMode[] peekModes; /** - * @param ctx Cache context. + * @param cacheName Cache name. + * @param topVer Affinity topology version. + * @param peekModes Cache peek modes. */ - public SizeTask(GridCacheContext ctx, CachePeekMode[] peekModes) { - this.ctx = ctx; + public SizeTask(String cacheName, AffinityTopologyVersion topVer, CachePeekMode[] peekModes) { + this.cacheName = cacheName; + this.topVer = topVer; this.peekModes = peekModes; } @@ -5611,13 +5581,22 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V Map<ComputeJob, ClusterNode> jobs = new HashMap(); for (ClusterNode node : subgrid) - jobs.put(new SizeJob(ctx.name(), ctx.affinity().affinityTopologyVersion(), peekModes), node); + jobs.put(new SizeJob(cacheName, topVer, peekModes), node); return jobs; } /** {@inheritDoc} */ @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) { + IgniteException e = res.getException(); + + if (e != null) { + if (e instanceof ClusterTopologyException) + return ComputeJobResultPolicy.WAIT; + + throw new IgniteException("Remote job threw exception.", e); + } + return ComputeJobResultPolicy.WAIT; } @@ -5641,25 +5620,23 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V /** */ private static final long serialVersionUID = 0L; - /** Cache context. */ - private GridCacheContext ctx; + /** Cache name. */ + private final String cacheName; - /** Keys to clear. */ - private Set<? extends K> keys; + /** Affinity topology version. */ + private final AffinityTopologyVersion topVer; - /** - * Empty constructor for serialization. - */ - public ClearTask() { - // No-op. - } + /** Keys to clear. */ + private final Set<? extends K> keys; /** - * @param ctx Cache context. + * @param cacheName Cache name. + * @param topVer Affinity topology version. * @param keys Keys to clear. */ - public ClearTask(GridCacheContext ctx, Set<? extends K> keys) { - this.ctx = ctx; + public ClearTask(String cacheName, AffinityTopologyVersion topVer, Set<? extends K> keys) { + this.cacheName = cacheName; + this.topVer = topVer; this.keys = keys; } @@ -5669,9 +5646,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V Map<ComputeJob, ClusterNode> jobs = new HashMap(); for (ClusterNode node : subgrid) { - jobs.put(keys == null ? - new GlobalClearAllJob(ctx.name(), ctx.affinity().affinityTopologyVersion()) : - new GlobalClearKeySetJob<K>(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys), + jobs.put(keys == null ? new GlobalClearAllJob(cacheName, topVer) : + new GlobalClearKeySetJob<K>(cacheName, topVer, keys), node); } @@ -5680,6 +5656,15 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V /** {@inheritDoc} */ @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) { + IgniteException e = res.getException(); + + if (e != null) { + if (e instanceof ClusterTopologyException) + return ComputeJobResultPolicy.WAIT; + + throw new IgniteException("Remote job threw exception.", e); + } + return ComputeJobResultPolicy.WAIT; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java index 9bee148..6f9099f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java @@ -1656,6 +1656,13 @@ public class GridCacheContext<K, V> implements Externalizable { } /** + * @return {@code True} if should use entry with offheap value pointer. + */ + public boolean useOffheapEntry() { + return cacheCfg.getMemoryMode() == OFFHEAP_TIERED || cacheCfg.getMemoryMode() == OFFHEAP_VALUES; + } + + /** * Converts temporary offheap object to heap-based. * * @param obj Object. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java index 1c2f8d5..cbb78e7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java @@ -115,9 +115,6 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { @GridToStringInclude private final int hash; - /** Off-heap value pointer. */ - protected long valPtr; - /** Extras */ @GridToStringInclude private GridCacheEntryExtras extras; @@ -188,7 +185,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (cctx.cache().isIgfsDataCache() && cctx.kernalContext().igfsHelper().isIgfsBlockKey(key.value(cctx.cacheObjectContext(), false))) { int newSize = valueLength0(val, null); - int oldSize = valueLength0(this.val, (this.val == null && valPtr != 0) ? valueBytes0() : null); + int oldSize = valueLength0(this.val, (this.val == null && hasOffHeapPointer()) ? valueBytes0() : null); int delta = newSize - oldSize; @@ -199,7 +196,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (!isOffHeapValuesOnly()) { this.val = val; - valPtr = 0; + offHeapPointer(0); } else { try { @@ -227,12 +224,13 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (val != null) { byte type = val.type(); - valPtr = mem.putOffHeap(valPtr, U.toArray(val.valueBytes(cctx.cacheObjectContext())), type); + offHeapPointer(mem.putOffHeap(offHeapPointer(), U.toArray(val.valueBytes(cctx.cacheObjectContext())), + type)); } else { - mem.removeOffHeap(valPtr); + mem.removeOffHeap(offHeapPointer()); - valPtr = 0; + offHeapPointer(0); } } catch (IgniteCheckedException e) { @@ -270,7 +268,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { CacheObject val0 = val; - if (val0 == null && valPtr != 0) { + if (val0 == null && hasOffHeapPointer()) { IgniteBiTuple<ByteBuffer, Byte> t = valueBytes0(); return cctx.cacheObjects().toCacheObject(cctx.cacheObjectContext(), t.get2(), t.get1()); @@ -434,16 +432,16 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (e != null) { if (e.offheapPointer() > 0) { - valPtr = e.offheapPointer(); + offHeapPointer(e.offheapPointer()); if (needVal) { - CacheObject val = cctx.fromOffheap(valPtr, false); + CacheObject val = cctx.fromOffheap(offHeapPointer(), false); e.value(val); } } else // Read from swap. - valPtr = 0; + offHeapPointer(0); } } else @@ -468,7 +466,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { // Must update valPtr again since update() will reset it. if (cctx.offheapTiered() && e.offheapPointer() > 0) - valPtr = e.offheapPointer(); + offHeapPointer(e.offheapPointer()); return val; } @@ -495,13 +493,13 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (cctx.offheapTiered()) { cctx.swap().removeOffheap(key); - valPtr = 0; + offHeapPointer(0); } return; } - if (val == null && cctx.offheapTiered() && valPtr != 0) { + if (val == null && cctx.offheapTiered() && hasOffHeapPointer()) { if (log.isDebugEnabled()) log.debug("Value did not change, skip write swap entry: " + this); @@ -540,10 +538,10 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { protected IgniteBiTuple<ByteBuffer, Byte> valueBytes0() { assert Thread.holdsLock(this); - if (valPtr != 0) { + if (hasOffHeapPointer()) { assert isOffHeapValuesOnly() || cctx.offheapTiered(); - IgniteBiTuple<byte[], Byte> t = cctx.unsafeMemory().get(valPtr); + IgniteBiTuple<byte[], Byte> t = cctx.unsafeMemory().get(offHeapPointer()); return F.t(ByteBuffer.wrap(t.get1()), t.get2()); } @@ -674,7 +672,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { CacheObject val = this.val; - hasOldBytes = valPtr != 0; + hasOldBytes = hasOffHeapPointer(); if ((unmarshal || isOffHeapValuesOnly()) && !expired && val == null && hasOldBytes) val = rawGetOrUnmarshalUnlocked(tmp); @@ -818,7 +816,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { // Update indexes before actual write to entry. updateIndex(ret, expTime, nextVer, prevVal); - boolean hadValPtr = valPtr != 0; + boolean hadValPtr = hasOffHeapPointer(); // Don't change version for read-through. update(ret, expTime, ttl, nextVer); @@ -966,13 +964,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { synchronized (this) { checkObsolete(); - if (cctx.kernalContext().config().isCacheSanityCheckEnabled()) { - if (tx != null && tx.groupLock()) - groupLockSanityCheck(tx); - else - assert tx == null || (!tx.local() && tx.onePhaseCommit()) || tx.ownsLock(this) : - "Transaction does not own lock for update [entry=" + this + ", tx=" + tx + ']'; - } + assert tx == null || (!tx.local() && tx.onePhaseCommit()) || tx.ownsLock(this) : + "Transaction does not own lock for update [entry=" + this + ", tx=" + tx + ']'; // Load and remove from swap if it is new. boolean startVer = isStartVersion(); @@ -1130,10 +1123,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { synchronized (this) { checkObsolete(); - if (tx != null && tx.groupLock() && cctx.kernalContext().config().isCacheSanityCheckEnabled()) - groupLockSanityCheck(tx); - else - assert tx == null || (!tx.local() && tx.onePhaseCommit()) || tx.ownsLock(this) : + assert tx == null || (!tx.local() && tx.onePhaseCommit()) || tx.ownsLock(this) : "Transaction does not own lock for remove[entry=" + this + ", tx=" + tx + ']'; boolean startVer = isStartVersion(); @@ -1166,7 +1156,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { // can be updated without actually holding entry lock. clearIndex(old); - boolean hadValPtr = valPtr != 0; + boolean hadValPtr = hasOffHeapPointer(); update(null, 0, 0, newVer); @@ -1200,7 +1190,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { obsoleteVer = newVer; else { // Only delete entry if the lock is not explicit. - if (tx.groupLock() || lockedBy(tx.xidVersion())) + if (lockedBy(tx.xidVersion())) obsoleteVer = tx.xidVersion(); else if (log.isDebugEnabled()) log.debug("Obsolete version was not set because lock was explicit: " + this); @@ -1523,7 +1513,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { // Must persist inside synchronization in non-tx mode. cctx.store().remove(null, keyValue(false)); - boolean hasValPtr = valPtr != 0; + boolean hasValPtr = hasOffHeapPointer(); // Update index inside synchronization since it can be updated // in load methods without actually holding entry lock. @@ -2124,7 +2114,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { enqueueVer = newVer; - boolean hasValPtr = valPtr != 0; + boolean hasValPtr = hasOffHeapPointer(); // Clear value on backup. Entry will be removed from cache when it got evicted from queue. update(null, CU.TTL_ETERNAL, CU.EXPIRE_TIME_ETERNAL, newVer); @@ -2801,25 +2791,6 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { } /** - * Checks that entries in group locks transactions are not locked during commit. - * - * @param tx Transaction to check. - * @throws GridCacheEntryRemovedException If entry is obsolete. - * @throws IgniteCheckedException If entry was externally locked. - */ - private void groupLockSanityCheck(IgniteInternalTx tx) throws GridCacheEntryRemovedException, IgniteCheckedException { - assert tx.groupLock(); - - IgniteTxEntry txEntry = tx.entry(txKey()); - - if (txEntry.groupLockEntry()) { - if (lockedByAny()) - throw new IgniteCheckedException("Failed to update cache entry (entry was externally locked while " + - "accessing entry within group lock transaction) [entry=" + this + ", tx=" + tx + ']'); - } - } - - /** * @param failFast Fail fast flag. * @param topVer Topology version. * @param filter Filter. @@ -2931,8 +2902,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (val != null) return val; - if (valPtr != 0) { - CacheObject val0 = cctx.fromOffheap(valPtr, tmp); + if (hasOffHeapPointer()) { + CacheObject val0 = cctx.fromOffheap(offHeapPointer(), tmp); if (!tmp && cctx.kernalContext().config().isPeerClassLoadingEnabled()) val0.finishUnmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader()); @@ -2954,7 +2925,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { protected boolean hasValueUnlocked() { assert Thread.holdsLock(this); - return val != null || valPtr != 0; + return val != null || hasOffHeapPointer(); } /** {@inheritDoc} */ @@ -3300,7 +3271,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { synchronized (this) { CacheObject expiredVal = saveValueForIndexUnlocked(); - boolean hasOldBytes = valPtr != 0; + boolean hasOldBytes = hasOffHeapPointer(); boolean expired = checkExpired(); @@ -4104,6 +4075,27 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { } /** + * @return True if entry has off-heap value pointer. + */ + protected boolean hasOffHeapPointer() { + return false; + } + + /** + * @return Off-heap value pointer. + */ + protected long offHeapPointer() { + return 0; + } + + /** + * @param valPtr Off-heap value pointer. + */ + protected void offHeapPointer(long valPtr) { + // No-op. + } + + /** * @return Size of extras object. */ private int extrasSize() { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java index 0bb97a9..c05e4b4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java @@ -510,7 +510,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter { * @return Future. */ @SuppressWarnings({"unchecked"}) - @Nullable public <T> GridCacheFuture<T> future(GridCacheVersion ver, IgniteUuid futId) { + @Nullable public GridCacheFuture future(GridCacheVersion ver, IgniteUuid futId) { Collection<? extends GridCacheFuture> futs = this.futs.get(ver); if (futs != null) @@ -519,7 +519,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter { if (log.isDebugEnabled()) log.debug("Found future in futures map: " + fut); - return (GridCacheFuture<T>)fut; + return fut; } if (log.isDebugEnabled())