Merge branch 'sprint-2' of 
https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-141

Conflicts:
        modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
        modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7635588c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7635588c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7635588c

Branch: refs/heads/ignite-141
Commit: 7635588c1eb28f344ff02c4be87964fdb3a45442
Parents: dbca433 b2675bc
Author: Valentin Kulichenko <vkuliche...@gridgain.com>
Authored: Mon Mar 2 10:45:38 2015 -0800
Committer: Valentin Kulichenko <vkuliche...@gridgain.com>
Committed: Mon Mar 2 10:45:38 2015 -0800

----------------------------------------------------------------------
 examples/pom-standalone.xml                     |   2 +-
 .../java/org/apache/ignite/IgniteCluster.java   |   8 +-
 .../apache/ignite/cache/store/CacheStore.java   |   4 +-
 .../configuration/IgniteConfiguration.java      |   5 +-
 .../ignite/internal/GridKernalContext.java      |  10 +-
 .../ignite/internal/GridKernalContextImpl.java  |  14 +-
 .../apache/ignite/internal/IgniteKernal.java    |  23 +-
 .../org/apache/ignite/internal/IgnitionEx.java  | 572 ++++++++-----------
 .../affinity/GridAffinityAssignmentCache.java   |  13 +-
 .../processors/cache/CacheMetricsImpl.java      |   4 +
 .../processors/cache/GridCacheContext.java      |  19 +
 .../processors/cache/GridCacheMapEntry.java     |   9 +
 .../processors/cache/GridCacheProcessor.java    |  15 +
 .../processors/cache/GridCacheStoreManager.java |  12 +-
 .../GridDistributedCacheAdapter.java            |   2 +
 .../distributed/dht/GridDhtCacheEntry.java      |   3 +
 .../distributed/dht/GridDhtLocalPartition.java  |   5 +
 .../dht/atomic/GridDhtAtomicCache.java          |   2 +-
 .../dht/colocated/GridDhtColocatedCache.java    |   2 +-
 .../cache/transactions/IgniteTxManager.java     |   7 +-
 .../processors/cluster/ClusterProcessor.java    |  46 ++
 .../dataload/IgniteDataLoaderImpl.java          |  29 +-
 .../ignite/internal/util/IgniteUtils.java       |  90 ++-
 .../ignite/internal/visor/cache/VisorCache.java | 190 ++----
 .../cache/VisorCacheAffinityConfiguration.java  |  53 +-
 .../visor/cache/VisorCacheConfiguration.java    | 484 +++-------------
 .../cache/VisorCacheDefaultConfiguration.java   |  27 +-
 .../cache/VisorCacheEvictionConfiguration.java  |  81 +--
 .../cache/VisorCacheNearConfiguration.java      |  42 +-
 .../cache/VisorCachePreloadConfiguration.java   |  54 +-
 .../cache/VisorCacheStoreConfiguration.java     | 148 ++++-
 .../VisorCacheWriteBehindConfiguration.java     | 137 -----
 .../visor/node/VisorAtomicConfiguration.java    |  27 +-
 .../visor/node/VisorBasicConfiguration.java     | 180 +-----
 .../node/VisorCacheQueryConfiguration.java      |  45 +-
 .../node/VisorExecutorServiceConfiguration.java |  54 +-
 .../visor/node/VisorGridConfiguration.java      | 177 +-----
 .../visor/node/VisorIgfsConfiguration.java      | 244 +-------
 .../visor/node/VisorLifecycleConfiguration.java |   9 +-
 .../visor/node/VisorMetricsConfiguration.java   |  29 +-
 .../node/VisorPeerToPeerConfiguration.java      |  28 +-
 .../visor/node/VisorQueryConfiguration.java     |  65 +--
 .../visor/node/VisorRestConfiguration.java      |  80 +--
 .../node/VisorSegmentationConfiguration.java    |  45 +-
 .../visor/node/VisorSpisConfiguration.java      |  92 +--
 .../node/VisorTransactionConfiguration.java     |  62 +-
 .../internal/visor/util/VisorTaskUtils.java     |   4 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      | 137 +++--
 .../discovery/tcp/TcpDiscoverySpiAdapter.java   | 116 ++++
 .../core/src/main/resources/ignite.properties   |   2 +-
 .../core/src/test/config/store/jdbc/Ignite.xml  |  63 +-
 .../GridCacheAbstractLocalStoreSelfTest.java    | 440 ++++++++++++++
 .../cache/GridCacheAbstractMetricsSelfTest.java |  42 ++
 ...acheAbstractUsersAffinityMapperSelfTest.java | 207 +++++++
 ...dCacheAtomicUsersAffinityMapperSelfTest.java |  45 ++
 .../GridCachePartitionedLocalStoreSelfTest.java |  51 ++
 ...chePartitionedOffHeapLocalStoreSelfTest.java |  56 ++
 .../GridCacheReplicatedLocalStoreSelfTest.java  |  51 ++
 ...heReplicatedUsersAffinityMapperSelfTest.java |  45 ++
 ...ridCacheTxPartitionedLocalStoreSelfTest.java |  51 ++
 .../GridCacheTxUsersAffinityMapperSelfTest.java |  45 ++
 .../GridCacheQueueCleanupSelfTest.java          |   1 -
 .../IgniteCacheExpiryPolicyAbstractTest.java    |  38 +-
 .../ignite/testsuites/IgniteCacheTestSuite.java |   4 +
 modules/scalar/pom.xml                          |   6 +
 .../ignite/schema/generator/XmlGenerator.java   |   8 +-
 .../apache/ignite/schema/model/PojoField.java   |  11 +-
 .../apache/ignite/schema/load/model/Ignite.xml  | 133 +++--
 .../commands/cache/VisorCacheCommand.scala      |  25 +-
 .../yardstick/config/ignite-store-config.xml    |  15 +-
 pom.xml                                         |   4 +-
 71 files changed, 2373 insertions(+), 2476 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7635588c/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 71c9a5e,f46d071..90d283a
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@@ -678,9 -675,7 +675,9 @@@ public class IgniteKernal implements Ig
                  igfsExecSvc,
                  restExecSvc);
  
 +            cfg.getMarshaller().setContext(new MarshallerContextImpl(ctx));
 +
-             cluster = new IgniteClusterImpl(ctx);
+             startProcessor(ctx, new ClusterProcessor(ctx), attrs);
  
              U.onGridStart();
  

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7635588c/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index da21e3b,cb2efbf..7844522
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@@ -1302,12 -1295,186 +1295,175 @@@ public class IgnitionEx 
          private void start0(GridStartContext startCtx) throws 
IgniteCheckedException {
              assert grid == null : "Grid is already started: " + name;
  
-             IgniteConfiguration cfg = startCtx.config();
+             IgniteConfiguration cfg = startCtx.config() != null ? 
startCtx.config() : new IgniteConfiguration();
  
-             if (cfg == null)
-                 cfg = new IgniteConfiguration();
+             IgniteConfiguration myCfg = initializeConfiguration(cfg);
  
-             IgniteConfiguration myCfg = new IgniteConfiguration();
+             // Set configuration URL, if any, into system property.
+             if (startCtx.configUrl() != null)
+                 System.setProperty(IGNITE_CONFIG_URL, 
startCtx.configUrl().toString());
+ 
+             // Ensure that SPIs support multiple grid instances, if required.
+             if (!startCtx.single()) {
+                 ensureMultiInstanceSupport(myCfg.getDeploymentSpi());
+                 ensureMultiInstanceSupport(myCfg.getCommunicationSpi());
+                 ensureMultiInstanceSupport(myCfg.getDiscoverySpi());
+                 ensureMultiInstanceSupport(myCfg.getCheckpointSpi());
+                 ensureMultiInstanceSupport(myCfg.getEventStorageSpi());
+                 ensureMultiInstanceSupport(myCfg.getCollisionSpi());
+                 ensureMultiInstanceSupport(myCfg.getFailoverSpi());
+                 ensureMultiInstanceSupport(myCfg.getLoadBalancingSpi());
+                 ensureMultiInstanceSupport(myCfg.getSwapSpaceSpi());
+             }
+ 
+             execSvc = new IgniteThreadPoolExecutor(
+                 "pub-" + cfg.getGridName(),
+                 cfg.getPublicThreadPoolSize(),
+                 cfg.getPublicThreadPoolSize(),
+                 DFLT_PUBLIC_KEEP_ALIVE_TIME,
+                 new 
LinkedBlockingQueue<Runnable>(DFLT_PUBLIC_THREADPOOL_QUEUE_CAP));
+ 
+             // Pre-start all threads as they are guaranteed to be needed.
+             ((ThreadPoolExecutor) execSvc).prestartAllCoreThreads();
+ 
+             // Note that since we use 'LinkedBlockingQueue', number of
+             // maximum threads has no effect.
+             sysExecSvc = new IgniteThreadPoolExecutor(
+                 "sys-" + cfg.getGridName(),
+                 cfg.getSystemThreadPoolSize(),
+                 cfg.getSystemThreadPoolSize(),
+                 DFLT_SYSTEM_KEEP_ALIVE_TIME,
+                 new 
LinkedBlockingQueue<Runnable>(DFLT_SYSTEM_THREADPOOL_QUEUE_CAP));
+ 
+             // Pre-start all threads as they are guaranteed to be needed.
+             ((ThreadPoolExecutor) sysExecSvc).prestartAllCoreThreads();
+ 
+             // Note that since we use 'LinkedBlockingQueue', number of
+             // maximum threads has no effect.
+             // Note, that we do not pre-start threads here as management pool 
may
+             // not be needed.
+             mgmtExecSvc = new IgniteThreadPoolExecutor(
+                 "mgmt-" + cfg.getGridName(),
+                 cfg.getManagementThreadPoolSize(),
+                 cfg.getManagementThreadPoolSize(),
+                 0,
+                 new LinkedBlockingQueue<Runnable>());
+ 
+             // Note that since we use 'LinkedBlockingQueue', number of
+             // maximum threads has no effect.
+             // Note, that we do not pre-start threads here as class loading 
pool may
+             // not be needed.
+             p2pExecSvc = new IgniteThreadPoolExecutor(
+                 "p2p-" + cfg.getGridName(),
+                 cfg.getPeerClassLoadingThreadPoolSize(),
+                 cfg.getPeerClassLoadingThreadPoolSize(),
+                 0,
+                 new LinkedBlockingQueue<Runnable>());
+ 
+             // Note that we do not pre-start threads here as igfs pool may 
not be needed.
+             igfsExecSvc = new IgniteThreadPoolExecutor(
+                 "igfs-" + cfg.getGridName(),
+                 cfg.getIgfsThreadPoolSize(),
+                 cfg.getIgfsThreadPoolSize(),
+                 0,
+                 new LinkedBlockingQueue<Runnable>());
+ 
+             if (myCfg.getConnectorConfiguration() != null) {
+                 restExecSvc = new IgniteThreadPoolExecutor(
+                     "rest-" + myCfg.getGridName(),
+                     myCfg.getConnectorConfiguration().getThreadPoolSize(),
+                     myCfg.getConnectorConfiguration().getThreadPoolSize(),
+                     ConnectorConfiguration.DFLT_KEEP_ALIVE_TIME,
+                     new 
LinkedBlockingQueue<Runnable>(ConnectorConfiguration.DFLT_THREADPOOL_QUEUE_CAP)
+                 );
+             }
+ 
+             utilityCacheExecSvc = new IgniteThreadPoolExecutor(
+                 "utility-" + cfg.getGridName(),
+                 DFLT_SYSTEM_CORE_THREAD_CNT,
+                 DFLT_SYSTEM_MAX_THREAD_CNT,
+                 DFLT_SYSTEM_KEEP_ALIVE_TIME,
+                 new 
LinkedBlockingQueue<Runnable>(DFLT_SYSTEM_THREADPOOL_QUEUE_CAP));
+ 
+             // Register Ignite MBean for current grid instance.
+             registerFactoryMbean(myCfg.getMBeanServer());
+ 
 -            try {
 -                // Use reflection to avoid loading undesired classes.
 -                Class helperCls = 
Class.forName("org.apache.ignite.util.GridConfigurationHelper");
 -
 -                helperCls.getMethod("overrideConfiguration", 
IgniteConfiguration.class, Properties.class,
 -                    String.class, IgniteLogger.class).invoke(helperCls, 
myCfg, System.getProperties(), name, log);
 -            }
 -            catch (Exception ignored) {
 -                // No-op.
 -            }
 -
+             boolean started = false;
+ 
+             try {
+                 IgniteKernal grid0 = new 
IgniteKernal(startCtx.springContext());
+ 
+                 // Init here to make grid available to lifecycle listeners.
+                 grid = grid0;
+ 
+                 grid0.start(myCfg, utilityCacheExecSvc, execSvc, sysExecSvc, 
p2pExecSvc, mgmtExecSvc, igfsExecSvc,
+                     restExecSvc,
+                     new CA() {
+                         @Override public void apply() {
+                         startLatch.countDown();
+                     }
+                 });
+ 
+                 state = STARTED;
+ 
+                 if (log.isDebugEnabled())
+                     log.debug("Grid factory started ok: " + name);
+ 
+                 started = true;
+             }
+             catch (IgniteCheckedException e) {
+                 unregisterFactoryMBean();
+ 
+                 throw e;
+             }
+             // Catch Throwable to protect against any possible failure.
+             catch (Throwable e) {
+                 unregisterFactoryMBean();
+ 
+                 throw new IgniteCheckedException("Unexpected exception when 
starting grid.", e);
+             }
+             finally {
+                 if (!started)
+                     // Grid was not started.
+                     grid = null;
+             }
+ 
+             // Do NOT set it up only if IGNITE_NO_SHUTDOWN_HOOK=TRUE is 
provided.
+             if (!IgniteSystemProperties.getBoolean(IGNITE_NO_SHUTDOWN_HOOK, 
false)) {
+                 try {
+                     Runtime.getRuntime().addShutdownHook(shutdownHook = new 
Thread() {
+                         @Override public void run() {
+                             if (log.isInfoEnabled())
+                                 log.info("Invoking shutdown hook...");
+ 
+                             IgniteNamedInstance.this.stop(true);
+                         }
+                     });
+ 
+                     if (log.isDebugEnabled())
+                         log.debug("Shutdown hook is installed.");
+                 }
+                 catch (IllegalStateException e) {
+                     stop(true);
+ 
+                     throw new IgniteCheckedException("Failed to install 
shutdown hook.", e);
+                 }
+             }
+             else {
+                 if (log.isDebugEnabled())
+                     log.debug("Shutdown hook has not been installed because 
environment " +
+                         "or system property " + IGNITE_NO_SHUTDOWN_HOOK + " 
is set.");
+             }
+         }
+ 
+         /**
+          * @param cfg Ignite configuration copy to.
+          * @return New ignite configuration.
+          * @throws IgniteCheckedException If failed.
+          */
+         private IgniteConfiguration 
initializeConfiguration(IgniteConfiguration cfg)
+             throws IgniteCheckedException {
+             IgniteConfiguration myCfg = new IgniteConfiguration(cfg);
  
              String ggHome = cfg.getIgniteHome();
  
@@@ -1742,95 -1713,66 +1706,67 @@@
                      copies[cacheIdx] = 
atomicsSystemCache(cfg.getAtomicConfiguration(), clientDisco);
              }
  
 -            // Always add utility cache.
 -            copies[0] = utilitySystemCache(clientDisco);
 +            // Always add marshaller and utility caches.
 +            copies[0] = marshallerSystemCache(clientDisco);
 +            copies[1] = utilitySystemCache(clientDisco);
  
-             myCfg.setCacheConfiguration(copies);
+             cfg.setCacheConfiguration(copies);
+         }
+ 
+         /**
+          * Initialize default SPI implementations.
+          *
+          * @param cfg Ignite configuration.
+          */
+         private void initializeDefaultSpi(IgniteConfiguration cfg) {
+             if (cfg.getDiscoverySpi() == null)
+                 cfg.setDiscoverySpi(new TcpDiscoverySpi());
  
-             myCfg.setCacheSanityCheckEnabled(cfg.isCacheSanityCheckEnabled());
+             if (cfg.getDiscoverySpi() instanceof TcpDiscoverySpi) {
+                 TcpDiscoverySpi tcpDisco = 
(TcpDiscoverySpi)cfg.getDiscoverySpi();
  
-             // Ensure that SPIs support multiple grid instances, if required.
-             if (!startCtx.single()) {
-                 ensureMultiInstanceSupport(deploySpi);
-                 ensureMultiInstanceSupport(commSpi);
-                 ensureMultiInstanceSupport(discoSpi);
-                 ensureMultiInstanceSupport(cpSpi);
-                 ensureMultiInstanceSupport(evtSpi);
-                 ensureMultiInstanceSupport(colSpi);
-                 ensureMultiInstanceSupport(failSpi);
-                 ensureMultiInstanceSupport(loadBalancingSpi);
-                 ensureMultiInstanceSupport(swapspaceSpi);
+                 if (tcpDisco.getIpFinder() == null)
+                     tcpDisco.setIpFinder(new TcpDiscoveryMulticastIpFinder());
              }
  
-             // Register Ignite MBean for current grid instance.
-             registerFactoryMbean(myCfg.getMBeanServer());
+             if (cfg.getCommunicationSpi() == null)
+                 cfg.setCommunicationSpi(new TcpCommunicationSpi());
  
-             boolean started = false;
- 
-             try {
-                 IgniteKernal grid0 = new 
IgniteKernal(startCtx.springContext());
+             if (cfg.getDeploymentSpi() == null)
+                 cfg.setDeploymentSpi(new LocalDeploymentSpi());
  
-                 // Init here to make grid available to lifecycle listeners.
-                 grid = grid0;
+             if (cfg.getEventStorageSpi() == null)
+                 cfg.setEventStorageSpi(new MemoryEventStorageSpi());
  
-                 grid0.start(myCfg, utilityCacheExecSvc, execSvc, sysExecSvc, 
p2pExecSvc, mgmtExecSvc, igfsExecSvc,
-                     restExecSvc,
-                     new CA() {
-                         @Override public void apply() {
-                         startLatch.countDown();
-                     }
-                 });
+             if (cfg.getCheckpointSpi() == null)
+                 cfg.setCheckpointSpi(new CheckpointSpi[] {new 
NoopCheckpointSpi()});
  
-                 state = STARTED;
+             if (cfg.getCollisionSpi() == null)
+                 cfg.setCollisionSpi(new NoopCollisionSpi());
  
-                 if (log.isDebugEnabled())
-                     log.debug("Grid factory started ok: " + name);
+             if (cfg.getFailoverSpi() == null)
+                 cfg.setFailoverSpi(new FailoverSpi[] {new 
AlwaysFailoverSpi()});
  
-                 started = true;
-             }
-             catch (IgniteCheckedException e) {
-                 unregisterFactoryMBean();
+             if (cfg.getLoadBalancingSpi() == null)
+                 cfg.setLoadBalancingSpi(new LoadBalancingSpi[] {new 
RoundRobinLoadBalancingSpi()});
  
-                 throw e;
-             }
-             // Catch Throwable to protect against any possible failure.
-             catch (Throwable e) {
-                 unregisterFactoryMBean();
+             if (cfg.getIndexingSpi() == null)
+                 cfg.setIndexingSpi(new NoopIndexingSpi());
  
-                 throw new IgniteCheckedException("Unexpected exception when 
starting grid.", e);
-             }
-             finally {
-                 if (!started)
-                     // Grid was not started.
-                     grid = null;
-             }
+             if (cfg.getSwapSpaceSpi() == null) {
+                 boolean needSwap = false;
  
-             // Do NOT set it up only if IGNITE_NO_SHUTDOWN_HOOK=TRUE is 
provided.
-             if (!IgniteSystemProperties.getBoolean(IGNITE_NO_SHUTDOWN_HOOK, 
false)) {
-                 try {
-                     Runtime.getRuntime().addShutdownHook(shutdownHook = new 
Thread() {
-                         @Override public void run() {
-                             if (log.isInfoEnabled())
-                                 log.info("Invoking shutdown hook...");
+                 if (cfg.getCacheConfiguration() != null) {
+                     for (CacheConfiguration c : cfg.getCacheConfiguration()) {
+                         if (c.isSwapEnabled()) {
+                             needSwap = true;
  
-                             IgniteNamedInstance.this.stop(true);
+                             break;
                          }
-                     });
- 
-                     if (log.isDebugEnabled())
-                         log.debug("Shutdown hook is installed.");
+                     }
                  }
-                 catch (IllegalStateException e) {
-                     stop(true);
  
-                     throw new IgniteCheckedException("Failed to install 
shutdown hook.", e);
-                 }
-             }
-             else {
-                 if (log.isDebugEnabled())
-                     log.debug("Shutdown hook has not been installed because 
environment " +
-                         "or system property " + IGNITE_NO_SHUTDOWN_HOOK + " 
is set.");
+                 cfg.setSwapSpaceSpi(needSwap ? new FileSwapSpaceSpi() : new 
NoopSwapSpaceSpi());
              }
          }
  

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7635588c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7635588c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7635588c/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------

Reply via email to