Merge branch 'sprint-1' into ignite-113
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b5631df3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b5631df3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b5631df3 Branch: refs/heads/ignite-26 Commit: b5631df3233c3c098a2c1b08e084eca89cc176b8 Parents: 5bb5f5d d6a720f Author: Artem SHutak <ashu...@gridgain.com> Authored: Thu Jan 29 16:50:33 2015 +0300 Committer: Artem SHutak <ashu...@gridgain.com> Committed: Thu Jan 29 16:50:33 2015 +0300 ---------------------------------------------------------------------- ipc/shmem/Makefile.am | 2 +- ipc/shmem/Makefile.in | 2 +- ipc/shmem/configure | 4 +- ipc/shmem/configure.ac | 2 +- ipc/shmem/ggshmem/Makefile.am | 23 - ipc/shmem/ggshmem/Makefile.in | 589 ---- ..._util_ipc_shmem_GridIpcSharedMemoryUtils.cpp | 882 ----- ipc/shmem/igniteshmem/Makefile.am | 23 + ipc/shmem/igniteshmem/Makefile.in | 589 ++++ ...rnal_util_ipc_shmem_IpcSharedMemoryUtils.cpp | 882 +++++ ipc/shmem/include/Makefile.am | 2 +- ipc/shmem/include/Makefile.in | 2 +- ...ternal_util_ipc_shmem_IpcSharedMemoryUtils.h | 117 + ...id_util_ipc_shmem_GridIpcSharedMemoryUtils.h | 117 - ipc/shmem/readme.txt | 9 +- .../ClientAbstractMultiThreadedSelfTest.java | 2 +- .../ClientAbstractMultiNodeSelfTest.java | 4 +- .../rest/RestBinaryProtocolSelfTest.java | 2 +- .../rest/TaskCommandHandlerSelfTest.java | 2 +- .../java/META-INF/native/linux64/libggshmem.so | Bin 138023 -> 0 bytes .../META-INF/native/linux64/libigniteshmem.so | Bin 0 -> 138345 bytes .../java/META-INF/native/osx/libggshmem.dylib | Bin 32940 -> 0 bytes .../META-INF/native/osx/libigniteshmem.dylib | Bin 0 -> 33116 bytes .../main/java/org/apache/ignite/Ignition.java | 38 +- .../apache/ignite/cache/CachingProvider.java | 2 +- .../ignite/fs/mapreduce/IgniteFsTask.java | 2 +- .../ignite/internal/ClusterGroupAdapter.java | 2 +- .../internal/ClusterNodeLocalMapImpl.java | 2 +- .../java/org/apache/ignite/internal/GridEx.java | 143 - .../org/apache/ignite/internal/GridGainEx.java | 2399 ------------- .../org/apache/ignite/internal/GridKernal.java | 3322 ------------------ .../ignite/internal/GridKernalContext.java | 2 +- .../ignite/internal/GridKernalContextImpl.java | 8 +- .../apache/ignite/internal/GridLoggerProxy.java | 2 +- .../ignite/internal/GridUpdateNotifier.java | 2 +- .../ignite/internal/IgniteClusterAsyncImpl.java | 4 +- .../org/apache/ignite/internal/IgniteEx.java | 143 + .../apache/ignite/internal/IgniteKernal.java | 3322 ++++++++++++++++++ .../org/apache/ignite/internal/IgnitionEx.java | 2396 +++++++++++++ .../processors/affinity/GridAffinityUtils.java | 2 +- .../processors/cache/GridCacheAdapter.java | 8 +- .../processors/cache/GridCacheContext.java | 4 +- .../GridCacheDataStructuresManager.java | 4 +- .../cache/query/GridCacheQueryManager.java | 2 +- .../jdbc/GridCacheQueryJdbcMetadataTask.java | 2 +- .../query/jdbc/GridCacheQueryJdbcTask.java | 2 +- .../dr/GridDrDataLoadCacheUpdater.java | 2 +- .../internal/processors/fs/GridGgfsImpl.java | 2 +- .../internal/processors/fs/GridGgfsServer.java | 26 +- .../processors/fs/GridGgfsServerManager.java | 8 +- .../processors/fs/IgniteFsNoopProcessor.java | 2 +- .../processors/fs/IgniteFsProcessor.java | 4 +- .../processors/fs/IgniteFsProcessorAdapter.java | 2 +- .../resource/GridResourceProcessor.java | 2 +- .../resource/GridSpringResourceContext.java | 2 +- .../handlers/cache/GridCacheCommandHandler.java | 6 +- .../handlers/task/GridTaskCommandHandler.java | 2 +- .../processors/service/GridServiceProxy.java | 2 +- .../apache/ignite/internal/util/GridUtils.java | 43 +- .../internal/util/ipc/GridIpcEndpoint.java | 49 - .../util/ipc/GridIpcEndpointBindException.java | 47 - .../util/ipc/GridIpcEndpointFactory.java | 84 - .../internal/util/ipc/GridIpcEndpointType.java | 29 - .../util/ipc/GridIpcServerEndpoint.java | 73 - .../ipc/GridIpcServerEndpointDeserializer.java | 66 - .../internal/util/ipc/GridIpcToNioAdapter.java | 250 -- .../ignite/internal/util/ipc/IpcEndpoint.java | 49 + .../util/ipc/IpcEndpointBindException.java | 47 + .../internal/util/ipc/IpcEndpointFactory.java | 84 + .../internal/util/ipc/IpcEndpointType.java | 29 + .../internal/util/ipc/IpcServerEndpoint.java | 73 + .../util/ipc/IpcServerEndpointDeserializer.java | 66 + .../internal/util/ipc/IpcToNioAdapter.java | 250 ++ .../ipc/loopback/GridIpcClientTcpEndpoint.java | 87 - .../ipc/loopback/GridIpcServerTcpEndpoint.java | 179 - .../util/ipc/loopback/IpcClientTcpEndpoint.java | 87 + .../util/ipc/loopback/IpcServerTcpEndpoint.java | 179 + .../GridIpcOutOfSystemResourcesException.java | 59 - .../GridIpcSharedMemoryClientEndpoint.java | 336 -- .../shmem/GridIpcSharedMemoryInitRequest.java | 67 - .../shmem/GridIpcSharedMemoryInitResponse.java | 171 - .../shmem/GridIpcSharedMemoryInputStream.java | 99 - .../shmem/GridIpcSharedMemoryNativeLoader.java | 242 -- ...cSharedMemoryOperationTimedoutException.java | 59 - .../shmem/GridIpcSharedMemoryOutputStream.java | 80 - .../GridIpcSharedMemoryServerEndpoint.java | 707 ---- .../ipc/shmem/GridIpcSharedMemorySpace.java | 374 -- .../ipc/shmem/GridIpcSharedMemoryUtils.java | 242 -- .../shmem/IpcOutOfSystemResourcesException.java | 59 + .../shmem/IpcSharedMemoryClientEndpoint.java | 336 ++ .../ipc/shmem/IpcSharedMemoryInitRequest.java | 67 + .../ipc/shmem/IpcSharedMemoryInitResponse.java | 171 + .../ipc/shmem/IpcSharedMemoryInputStream.java | 99 + .../ipc/shmem/IpcSharedMemoryNativeLoader.java | 261 ++ ...cSharedMemoryOperationTimedoutException.java | 59 + .../ipc/shmem/IpcSharedMemoryOutputStream.java | 80 + .../shmem/IpcSharedMemoryServerEndpoint.java | 707 ++++ .../util/ipc/shmem/IpcSharedMemorySpace.java | 374 ++ .../util/ipc/shmem/IpcSharedMemoryUtils.java | 242 ++ .../util/nio/GridShmemCommunicationClient.java | 4 +- .../apache/ignite/internal/visor/VisorJob.java | 2 +- .../internal/visor/VisorMultiNodeTask.java | 2 +- .../ignite/internal/visor/cache/VisorCache.java | 2 +- .../compute/VisorComputeMonitoringHolder.java | 10 +- .../visor/node/VisorBasicConfiguration.java | 2 +- .../visor/node/VisorGridConfiguration.java | 2 +- .../visor/node/VisorNodeDataCollectorJob.java | 6 +- .../internal/visor/query/VisorQueryTask.java | 2 +- .../communication/tcp/TcpCommunicationSpi.java | 24 +- .../StreamerCacheAffinityEventRouter.java | 2 +- .../ignite/GridExceptionHelpLinksSelfTest.java | 106 - .../ignite/GridExternalizableAbstractTest.java | 41 - .../IgniteExceptionHelpLinksSelfTest.java | 106 + .../IgniteExternalizableAbstractTest.java | 41 + ...CachePartitionFairAffinityNodesSelfTest.java | 6 +- ...CacheJdbcBlobStoreMultithreadedSelfTest.java | 2 +- .../fs/GridGgfsEventsAbstractSelfTest.java | 2 +- .../ignite/fs/GridGgfsFragmentizerSelfTest.java | 2 +- .../internal/GridDiscoveryEventSelfTest.java | 3 +- .../ignite/internal/GridDiscoverySelfTest.java | 4 +- .../internal/GridExecutorServiceTest.java | 315 -- .../GridExplicitImplicitDeploymentSelfTest.java | 476 --- .../ignite/internal/GridKernalTestUtils.java | 3 +- .../internal/GridListenActorSelfTest.java | 3 +- .../GridTopicExternalizableSelfTest.java | 3 +- .../GridTopologyBuildVersionSelfTest.java | 2 +- .../internal/GridUpdateNotifierSelfTest.java | 3 +- .../internal/IgniteExecutorServiceTest.java | 315 ++ ...gniteExplicitImplicitDeploymentSelfTest.java | 476 +++ .../GridCheckpointManagerAbstractSelfTest.java | 2 +- .../GridCommunicationSendMessageSelfTest.java | 4 +- .../GridDiscoveryManagerAliveCacheSelfTest.java | 2 +- .../discovery/GridDiscoveryManagerSelfTest.java | 6 +- .../swapspace/GridSwapSpaceManagerSelfTest.java | 2 +- .../GridAffinityProcessorAbstractSelfTest.java | 6 +- .../cache/GridCacheAbstractFullApiSelfTest.java | 4 +- .../cache/GridCacheAbstractSelfTest.java | 2 +- .../cache/GridCacheAffinityApiSelfTest.java | 4 +- .../GridCacheConcurrentTxMultiNodeTest.java | 4 +- .../cache/GridCacheEntryVersionSelfTest.java | 4 +- .../GridCacheFinishPartitionsSelfTest.java | 4 +- .../GridCacheGroupLockAbstractSelfTest.java | 4 +- .../processors/cache/GridCacheLeakTest.java | 2 +- ...GridCacheMixedPartitionExchangeSelfTest.java | 2 +- .../cache/GridCacheMultiUpdateLockSelfTest.java | 2 +- .../cache/GridCacheMvccFlagsTest.java | 4 +- .../cache/GridCacheMvccManagerSelfTest.java | 4 +- .../cache/GridCacheMvccPartitionedSelfTest.java | 4 +- .../processors/cache/GridCacheMvccSelfTest.java | 4 +- .../cache/GridCacheNestedTxAbstractTest.java | 2 +- .../cache/GridCacheObjectToStringSelfTest.java | 2 +- .../GridCacheOrderedPreloadingSelfTest.java | 2 +- .../cache/GridCacheP2PUndeploySelfTest.java | 6 +- .../cache/GridCachePartitionedGetSelfTest.java | 2 +- .../GridCachePreloadingEvictionsSelfTest.java | 6 +- .../GridCacheQueryInternalKeysSelfTest.java | 2 +- .../cache/GridCacheSlowTxWarnTest.java | 4 +- .../cache/GridCacheStoreValueBytesSelfTest.java | 4 +- .../cache/GridCacheSwapReloadSelfTest.java | 2 +- .../cache/GridCacheTtlManagerLoadTest.java | 2 +- .../cache/GridCacheTtlManagerSelfTest.java | 2 +- .../IgniteCacheEntryListenerAbstractTest.java | 2 +- .../processors/cache/IgniteTxAbstractTest.java | 2 +- .../IgniteTxConcurrentGetAbstractTest.java | 3 +- .../IgniteTxExceptionAbstractSelfTest.java | 2 +- .../cache/IgniteTxMultiNodeAbstractTest.java | 6 +- .../IgniteTxStoreExceptionAbstractSelfTest.java | 2 +- ...actQueueFailoverDataConsistencySelfTest.java | 2 +- .../GridCacheCountDownLatchSelfTest.java | 2 +- .../GridCacheQueueCleanupSelfTest.java | 2 +- .../GridCacheSetAbstractSelfTest.java | 8 +- .../GridCacheSetFailoverAbstractSelfTest.java | 2 +- .../GridCacheAtomicTimeoutSelfTest.java | 2 +- .../distributed/GridCacheEventAbstractTest.java | 2 +- ...heExpiredEntriesPreloadAbstractSelfTest.java | 2 +- .../GridCacheMultiNodeLockAbstractTest.java | 2 +- ...iteTxConsistencyRestartAbstractSelfTest.java | 4 +- ...xOriginatingNodeFailureAbstractSelfTest.java | 10 +- ...cOriginatingNodeFailureAbstractSelfTest.java | 20 +- .../dht/GridCacheAtomicNearCacheSelfTest.java | 2 +- .../dht/GridCacheColocatedDebugTest.java | 6 +- .../dht/GridCacheDhtEntrySelfTest.java | 2 +- ...GridCacheDhtEvictionNearReadersSelfTest.java | 4 +- .../dht/GridCacheDhtEvictionSelfTest.java | 4 +- .../dht/GridCacheDhtMappingSelfTest.java | 2 +- .../dht/GridCacheDhtPreloadDelayedSelfTest.java | 2 +- .../GridCacheDhtPreloadStartStopSelfTest.java | 2 +- ...dCachePartitionedTopologyChangeSelfTest.java | 32 +- ...itionedTxOriginatingNodeFailureSelfTest.java | 8 +- ...eAtomicInvalidPartitionHandlingSelfTest.java | 2 +- .../atomic/GridCacheAtomicPreloadSelfTest.java | 4 +- .../near/GridCacheNearMultiNodeSelfTest.java | 6 +- .../near/GridCacheNearReadersSelfTest.java | 4 +- .../near/GridCacheNearTxMultiNodeSelfTest.java | 2 +- .../GridCachePartitionedFullApiSelfTest.java | 4 +- ...achePartitionedMultiNodeCounterSelfTest.java | 2 +- .../GridCachePartitionedProjectionSelfTest.java | 4 +- .../GridCachePartitionedTxSalvageSelfTest.java | 2 +- .../IgniteCacheExpiryPolicyAbstractTest.java | 2 +- ...ridCacheContinuousQueryAbstractSelfTest.java | 4 +- .../clock/GridTimeSyncProcessorSelfTest.java | 6 +- .../continuous/GridEventConsumeSelfTest.java | 2 +- .../processors/fs/GridGgfsAbstractSelfTest.java | 2 +- .../processors/fs/GridGgfsModesSelfTest.java | 4 +- .../fs/GridGgfsProcessorSelfTest.java | 2 +- ...IpcEndpointRegistrationAbstractSelfTest.java | 6 +- ...pcEndpointRegistrationOnWindowsSelfTest.java | 4 +- .../processors/fs/GridGgfsSizeSelfTest.java | 8 +- .../cache/GridCacheCommandHandlerSelfTest.java | 6 +- .../GridServiceReassignmentSelfTest.java | 2 +- .../ignite/internal/util/GridUtilsSelfTest.java | 41 +- .../util/future/GridFinishedFutureSelfTest.java | 2 +- ...idIpcServerEndpointDeserializerSelfTest.java | 160 - .../IpcServerEndpointDeserializerSelfTest.java | 160 + .../ipc/shmem/GgfsSharedMemoryTestClient.java | 76 + .../ipc/shmem/GgfsSharedMemoryTestServer.java | 71 + .../shmem/GridGgfsSharedMemoryTestClient.java | 76 - .../shmem/GridGgfsSharedMemoryTestServer.java | 71 - ...idIpcSharedMemoryCrashDetectionSelfTest.java | 500 --- .../shmem/GridIpcSharedMemoryFakeClient.java | 36 - .../shmem/GridIpcSharedMemoryNodeStartup.java | 87 - .../shmem/GridIpcSharedMemorySpaceSelfTest.java | 267 -- .../shmem/GridIpcSharedMemoryUtilsSelfTest.java | 84 - .../IpcSharedMemoryCrashDetectionSelfTest.java | 500 +++ .../ipc/shmem/IpcSharedMemoryFakeClient.java | 36 + .../IpcSharedMemoryNativeLoaderSelfTest.java | 78 + .../ipc/shmem/IpcSharedMemoryNodeStartup.java | 87 + .../ipc/shmem/IpcSharedMemorySpaceSelfTest.java | 267 ++ .../ipc/shmem/IpcSharedMemoryUtilsSelfTest.java | 84 + .../LoadWithCorruptedLibFileTestRunner.java | 65 + .../GridIpcSharedMemoryBenchmarkParty.java | 35 - .../GridIpcSharedMemoryBenchmarkReader.java | 133 - .../GridIpcSharedMemoryBenchmarkWriter.java | 125 - .../IpcSharedMemoryBenchmarkParty.java | 35 + .../IpcSharedMemoryBenchmarkReader.java | 133 + .../IpcSharedMemoryBenchmarkWriter.java | 125 + .../cache/GridCachePutRemoveLoadTest.java | 2 +- .../communication/GridIoManagerBenchmark.java | 10 +- .../communication/GridIoManagerBenchmark0.java | 12 +- .../ignite/loadtests/dsi/GridDsiPerfJob.java | 2 +- .../marshaller/GridMarshallerAbstractTest.java | 6 +- .../tcp/GridTcpDiscoveryMultiThreadedTest.java | 2 +- .../discovery/tcp/GridTcpDiscoverySelfTest.java | 14 +- .../ignite/testframework/GridTestUtils.java | 4 +- .../testframework/junits/GridAbstractTest.java | 14 +- .../junits/GridTestKernalContext.java | 2 +- .../junits/common/GridCommonAbstractTest.java | 22 +- .../ignite/testsuites/IgniteBasicTestSuite.java | 2 +- .../testsuites/IgniteComputeGridTestSuite.java | 4 +- .../ignite/testsuites/IgniteFsTestSuite.java | 2 +- .../IgniteIpcSharedMemorySelfTestSuite.java | 7 +- .../internal/fs/hadoop/GridGgfsHadoopIpcIo.java | 10 +- .../GridHadoopDefaultMapReducePlanner.java | 2 +- .../GridHadoopExternalCommunication.java | 26 +- .../GridHadoopIpcToNioAdapter.java | 6 +- ...doop20FileSystemLoopbackPrimarySelfTest.java | 2 +- ...sHadoop20FileSystemShmemPrimarySelfTest.java | 2 +- .../GridGgfsHadoopFileSystemClientSelfTest.java | 4 +- ...idGgfsHadoopFileSystemHandshakeSelfTest.java | 2 +- ...ridGgfsHadoopFileSystemIpcCacheSelfTest.java | 2 +- ...adoopFileSystemLoopbackAbstractSelfTest.java | 2 +- ...fsHadoopFileSystemShmemAbstractSelfTest.java | 8 +- .../fs/GridGgfsNearOnlyMultiNodeSelfTest.java | 4 +- .../ignite/fs/IgniteFsEventsTestSuite.java | 4 +- ...idHadoopDefaultMapReducePlannerSelfTest.java | 4 +- .../hadoop/GridHadoopJobTrackerSelfTest.java | 2 +- .../cache/GridCacheAbstractQuerySelfTest.java | 6 +- .../cache/GridCacheOffHeapAndSwapSelfTest.java | 4 +- .../cache/GridCacheQueryLoadSelfTest.java | 2 +- .../GridCacheQueryMultiThreadedSelfTest.java | 8 +- .../GridCacheReplicatedFieldsQuerySelfTest.java | 2 +- .../GridCacheReplicatedQuerySelfTest.java | 4 +- .../query/h2/sql/GridQueryParsingTest.java | 2 +- .../tcp/GridOrderedMessageCancelSelfTest.java | 2 +- .../GridTmLookupLifecycleAwareSelfTest.java | 2 +- .../java/org/apache/ignite/IgniteSpring.java | 8 +- .../cache/spring/SpringDynamicCacheManager.java | 2 +- .../scala/org/apache/ignite/visor/visor.scala | 6 +- .../IgniteServletContextListenerStartup.java | 4 +- .../startup/servlet/IgniteServletStartup.java | 4 +- 280 files changed, 13934 insertions(+), 13721 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b5631df3/modules/core/src/main/java/org/apache/ignite/Ignition.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b5631df3/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractQuerySelfTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b5631df3/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryMultiThreadedSelfTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b5631df3/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b5631df3/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridTmLookupLifecycleAwareSelfTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b5631df3/modules/web/src/main/java/org/apache/ignite/startup/servlet/IgniteServletContextListenerStartup.java ---------------------------------------------------------------------- diff --cc modules/web/src/main/java/org/apache/ignite/startup/servlet/IgniteServletContextListenerStartup.java index 456177e,0000000..e28f3e2 mode 100644,000000..100644 --- a/modules/web/src/main/java/org/apache/ignite/startup/servlet/IgniteServletContextListenerStartup.java +++ b/modules/web/src/main/java/org/apache/ignite/startup/servlet/IgniteServletContextListenerStartup.java @@@ -1,181 -1,0 +1,181 @@@ +/* + * 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.startup.servlet; + +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.internal.processors.resource.*; +import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import javax.servlet.*; +import java.net.*; +import java.util.*; + +/** + * This class defines GridGain startup based on servlet context listener. + * This startup can be used to start GridGain inside any web container. + * <p> + * This startup must be defined in {@code web.xml} file. + * <pre name="code" class="xml"> + * <listener> + * <listener-class>org.apache.ignite.startup.servlet.IgniteServletContextListenerStartup</listener-class> + * </listener> + * + * <context-param> + * <param-name>GridGainConfigurationFilePath</param-name> + * <param-value>config/default-config.xml</param-value> + * </context-param> + * </pre> + * <p> + * Servlet context listener based startup may be used in any web container like Tomcat, Jetty and etc. + * Depending on the way this startup is deployed the GridGain instance can be accessed + * by either all web applications or by only one. See web container class loading architecture: + * <ul> + * <li><a target=_blank href="http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html">http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html</a></li> + * <li><a target=_blank href="http://docs.codehaus.org/display/JETTY/Classloading">http://docs.codehaus.org/display/JETTY/Classloading</a></li> + * </ul> + * <p> + * <h2 class="header">Tomcat</h2> + * There are two ways to start GridGain on Tomcat. + * <ul> + * <li>GridGain started when web container starts and GridGain instance is accessible only to all web applications. + * <ol> + * <li>Add GridGain libraries in Tomcat common loader. + * Add in file {@code $TOMCAT_HOME/conf/catalina.properties} for property {@code common.loader} + * the following {@code $GRIDGAIN_HOME/*.jar,$GRIDGAIN_HOME/libs/*.jar} + * (replace {@code $GRIDGAIN_HOME} with absolute path). + * </li> + * <li>Configure this startup in {@code $TOMCAT_HOME/conf/web.xml} + * <pre name="code" class="xml"> + * <listener> + * <listener-class>org.apache.ignite.startup.servlet.IgniteServletContextListenerStartup</listener-class> + * </listener> + * + * <context-param> + * <param-name>GridGainConfigurationFilePath</param-name> + * <param-value>config/default-config.xml</param-value> + * </context-param> + * </pre> + * </li> + * </ol> + * </li> + * <li> + * GridGain started from WAR-file and GridGain instance is accessible only to that web application. + * Difference with approach described above is that {@code web.xml} file and all libraries should + * be added in WAR file without changes in Tomcat configuration files. + * </li> + * </ul> + */ +public class IgniteServletContextListenerStartup implements ServletContextListener { + /** Configuration file path parameter name. */ + public static final String GRIDGAIN_CFG_FILE_PATH_PARAM = "GridGainConfigurationFilePath"; + + /** Names of started grids. */ + private final Collection<String> gridNames = new ArrayList<>(); + + /** {@inheritDoc} */ + @Override public void contextInitialized(ServletContextEvent evt) { + ServletContext ctx = evt.getServletContext(); + + String cfgFile = ctx.getInitParameter(GRIDGAIN_CFG_FILE_PATH_PARAM); + + Collection<IgniteConfiguration> cfgs; + GridSpringResourceContext rsrcCtx = null; + + if (cfgFile != null) { + URL cfgUrl = null; + + try { + cfgUrl = evt.getServletContext().getResource("/META-INF/" + cfgFile); + } + catch (MalformedURLException ignored) { + // Ignore, we still need to try with GRIDGAIN_HOME. + } + + if (cfgUrl == null) + // Try with GRIDGAIN_HOME and with context class loader. + cfgUrl = U.resolveGridGainUrl(cfgFile); + + if (cfgUrl == null) + throw new IgniteException("Failed to find Spring configuration file (path provided should be " + + "either absolute, relative to GRIDGAIN_HOME, or relative to META-INF folder): " + cfgFile); + + IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> t; + + try { - t = GridGainEx.loadConfigurations(cfgUrl); ++ t = IgnitionEx.loadConfigurations(cfgUrl); + } + catch (IgniteCheckedException e) { + throw new IgniteException("Failed to load GridGain configuration.", e); + } + + cfgs = t.get1(); + rsrcCtx = t.get2(); + + if (cfgs.isEmpty()) + throw new IgniteException("Can't find grid factory configuration in: " + cfgUrl); + } + else + cfgs = Collections.<IgniteConfiguration>singleton(new IgniteConfiguration()); + + try { + assert !cfgs.isEmpty(); + + for (IgniteConfiguration cfg : cfgs) { + assert cfg != null; + + Ignite ignite; + + synchronized (IgniteServletContextListenerStartup.class) { + try { + ignite = G.ignite(cfg.getGridName()); + } + catch (IgniteIllegalStateException ignored) { - ignite = GridGainEx.start(new IgniteConfiguration(cfg), rsrcCtx); ++ ignite = IgnitionEx.start(new IgniteConfiguration(cfg), rsrcCtx); + } + } + + // Check if grid is not null - started properly. + if (ignite != null) + gridNames.add(ignite.name()); + } + } + catch (IgniteCheckedException e) { + // Stop started grids only. + for (String name : gridNames) + G.stop(name, true); + + throw new IgniteException("Failed to start GridGain.", e); + } + } + + /** {@inheritDoc} */ + @Override public void contextDestroyed(ServletContextEvent evt) { + // Stop started grids only. + for (String name: gridNames) + G.stop(name, true); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(IgniteServletContextListenerStartup.class, this); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b5631df3/modules/web/src/main/java/org/apache/ignite/startup/servlet/IgniteServletStartup.java ---------------------------------------------------------------------- diff --cc modules/web/src/main/java/org/apache/ignite/startup/servlet/IgniteServletStartup.java index 92cca30,0000000..32c456c mode 100644,000000..100644 --- a/modules/web/src/main/java/org/apache/ignite/startup/servlet/IgniteServletStartup.java +++ b/modules/web/src/main/java/org/apache/ignite/startup/servlet/IgniteServletStartup.java @@@ -1,187 -1,0 +1,187 @@@ +/* + * 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.startup.servlet; + +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.internal.processors.resource.*; +import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import javax.servlet.*; +import javax.servlet.http.*; +import java.net.*; +import java.util.*; + +/** + * This class defines servlet-based GridGain startup. This startup can be used to start GridGain + * inside any web container as servlet. + * <p> + * This startup must be defined in {@code web.xml} file. + * <pre name="code" class="xml"> + * <servlet> + * <servlet-name>GridGain</servlet-name> + * <servlet-class>org.apache.ignite.startup.servlet.IgniteServletStartup</servlet-class> + * <init-param> + * <param-name>cfgFilePath</param-name> + * <param-value>config/default-config.xml</param-value> + * </init-param> + * <load-on-startup>1</load-on-startup> + * </servlet> + * </pre> + * <p> + * Servlet-based startup may be used in any web container like Tomcat, Jetty and etc. + * Depending on the way this startup is deployed the GridGain instance can be accessed + * by either all web applications or by only one. See web container class loading architecture: + * <ul> + * <li><a target=_blank href="http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html">http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html</a></li> + * <li><a target=_blank href="http://docs.codehaus.org/display/JETTY/Classloading">http://docs.codehaus.org/display/JETTY/Classloading</a></li> + * </ul> + * <p> + * <h2 class="header">Tomcat</h2> + * There are two ways to start GridGain on Tomcat. + * <ul> + * <li>GridGain started when web container starts and GridGain instance is accessible only to all web applications. + * <ol> + * <li>Add GridGain libraries in Tomcat common loader. + * Add in file {@code $TOMCAT_HOME/conf/catalina.properties} for property {@code shared.loader} + * the following {@code $GRIDGAIN_HOME/gridgain.jar,$GRIDGAIN_HOME/libs/*.jar} + * (replace {@code $GRIDGAIN_HOME} with absolute path). + * </li> + * <li>Configure startup in {@code $TOMCAT_HOME/conf/web.xml} + * <pre name="code" class="xml"> + * <servlet> + * <servlet-name>GridGain</servlet-name> + * <servlet-class>org.apache.ignite.startup.servlet.IgniteServletStartup</servlet-class> + * <init-param> + * <param-name>cfgFilePath</param-name> + * <param-value>config/default-config.xml</param-value> + * </init-param> + * <load-on-startup>1</load-on-startup> + * </servlet> + * </pre> + * </li> + * </ol> + * </li> + * <li> + * GridGain started from WAR-file and GridGain instance is accessible only to that web application. + * Difference with approach described above is that {@code web.xml} file and all libraries should + * be added in WAR file without changes in Tomcat configuration files. + * </li> + * </ul> + * <p> + * <h2 class="header">Jetty</h2> + * Below is Java code example with Jetty API: + * <pre name="code" class="java"> + * Server service = new Server(); + * + * service.addListener("localhost:8090"); + * + * ServletHttpContext ctx = (ServletHttpContext)service.getContext("/"); + * + * ServletHolder servlet = ctx.addServlet("GridGain", "/GridGainStartup", + * "org.apache.ignite.startup.servlet.IgniteServletStartup"); + * + * servlet.setInitParameter("cfgFilePath", "config/default-config.xml"); + * + * servlet.setInitOrder(1); + * + * servlet.start(); + * + * service.start(); + * </pre> + */ +public class IgniteServletStartup extends HttpServlet { + /** */ + private static final long serialVersionUID = 0L; + + /** Grid loaded flag. */ + private static boolean loaded; + + /** Configuration file path variable name. */ + private static final String cfgFilePathParam = "cfgFilePath"; + + /** */ + private Collection<String> gridNames = new ArrayList<>(); + + /** {@inheritDoc} */ + @SuppressWarnings({"unchecked"}) + @Override public void init() throws ServletException { + // Avoid multiple servlet instances. GridGain should be loaded once. + if (loaded) + return; + + String cfgFile = getServletConfig().getInitParameter(cfgFilePathParam); + + if (cfgFile == null) + throw new ServletException("Failed to read property: " + cfgFilePathParam); + + URL cfgUrl = U.resolveGridGainUrl(cfgFile); + + if (cfgUrl == null) + throw new ServletException("Failed to find Spring configuration file (path provided should be " + + "either absolute, relative to GRIDGAIN_HOME, or relative to META-INF folder): " + cfgFile); + + try { + IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> t = - GridGainEx.loadConfigurations(cfgUrl); ++ IgnitionEx.loadConfigurations(cfgUrl); + + Collection<IgniteConfiguration> cfgs = t.get1(); + + if (cfgs == null) + throw new ServletException("Failed to find a single grid factory configuration in: " + cfgUrl); + + for (IgniteConfiguration cfg : cfgs) { + assert cfg != null; + + IgniteConfiguration adapter = new IgniteConfiguration(cfg); + - Ignite ignite = GridGainEx.start(adapter, t.get2()); ++ Ignite ignite = IgnitionEx.start(adapter, t.get2()); + + // Test if grid is not null - started properly. + if (ignite != null) + gridNames.add(ignite.name()); + } + } + catch (IgniteCheckedException e) { + // Stop started grids only. + for (String name: gridNames) + G.stop(name, true); + + throw new ServletException("Failed to start GridGain.", e); + } + + loaded = true; + } + + /** {@inheritDoc} */ + @Override public void destroy() { + // Stop started grids only. + for (String name: gridNames) + G.stop(name, true); + + loaded = false; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(IgniteServletStartup.class, this); + } +}