IGNITE-383 Rename preload to rebalance.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/dc04e98c Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/dc04e98c Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/dc04e98c Branch: refs/heads/ignite-411 Commit: dc04e98c616ec68f13d591c1536fb2b275f20744 Parents: 11efb91 Author: nikolay_tikhonov <ntikho...@gridgain.com> Authored: Mon Mar 2 16:53:06 2015 +0300 Committer: nikolay_tikhonov <ntikho...@gridgain.com> Committed: Mon Mar 2 16:56:02 2015 +0300 ---------------------------------------------------------------------- examples/config/example-cache.xml | 4 +- .../MemcacheRestExampleNodeStartup.java | 5 +- .../clients/src/test/resources/spring-cache.xml | 8 +- .../apache/ignite/cache/CachePreloadMode.java | 67 ------ .../apache/ignite/cache/CacheRebalanceMode.java | 67 ++++++ .../java/org/apache/ignite/cache/GridCache.java | 14 +- .../configuration/CacheConfiguration.java | 232 +++++++++---------- .../ignite/events/CachePreloadingEvent.java | 172 -------------- .../ignite/events/CacheRebalancingEvent.java | 172 ++++++++++++++ .../java/org/apache/ignite/events/Event.java | 2 +- .../org/apache/ignite/events/EventType.java | 46 ++-- .../org/apache/ignite/internal/IgnitionEx.java | 6 +- .../processors/cache/GridCacheAttributes.java | 32 +-- .../processors/cache/GridCacheContext.java | 8 +- .../processors/cache/GridCacheEventManager.java | 12 +- .../cache/GridCacheEvictionManager.java | 6 +- .../GridCachePartitionExchangeManager.java | 6 +- .../processors/cache/GridCacheProcessor.java | 74 +++--- .../processors/cache/GridCacheUtils.java | 4 +- .../distributed/dht/GridDhtLocalPartition.java | 4 +- .../distributed/dht/GridDhtLockFuture.java | 4 +- .../dht/GridDhtPartitionTopologyImpl.java | 14 +- .../distributed/dht/GridDhtTxPrepareFuture.java | 4 +- .../dht/preloader/GridDhtForceKeysFuture.java | 30 +-- .../preloader/GridDhtPartitionDemandPool.java | 76 +++--- .../preloader/GridDhtPartitionSupplyPool.java | 22 +- .../dht/preloader/GridDhtPreloader.java | 14 +- .../cache/VisorCachePreloadConfiguration.java | 16 +- .../core/src/test/config/discovery-stress.xml | 2 +- modules/core/src/test/config/example-cache.xml | 4 +- .../config/load/dsi-49-server-production.xml | 4 +- .../src/test/config/load/dsi-load-client.xml | 4 +- .../src/test/config/load/dsi-load-server.xml | 4 +- .../core/src/test/config/spring-cache-load.xml | 2 +- .../core/src/test/config/spring-multicache.xml | 16 +- .../test/config/websession/spring-cache-1.xml | 6 +- .../test/config/websession/spring-cache-2.xml | 6 +- .../test/config/websession/spring-cache-3.xml | 6 +- .../GridDiscoveryManagerAliveCacheSelfTest.java | 4 +- .../GridCacheAbstractFailoverSelfTest.java | 4 +- .../cache/GridCacheBasicStoreAbstractTest.java | 4 +- .../GridCacheConcurrentTxMultiNodeTest.java | 4 +- ...idCacheConfigurationConsistencySelfTest.java | 6 +- ...ridCacheConfigurationValidationSelfTest.java | 8 +- .../cache/GridCacheDeploymentSelfTest.java | 4 +- ...idCacheGetAndTransformStoreAbstractTest.java | 4 +- .../cache/GridCacheIncrementTransformTest.java | 4 +- .../cache/GridCacheMultiUpdateLockSelfTest.java | 4 +- .../GridCacheOrderedPreloadingSelfTest.java | 6 +- .../cache/GridCacheP2PUndeploySelfTest.java | 8 +- .../cache/GridCachePartitionedGetSelfTest.java | 4 +- ...hePartitionedProjectionAffinitySelfTest.java | 4 +- .../GridCachePreloadingEvictionsSelfTest.java | 6 +- .../GridCacheQueryInternalKeysSelfTest.java | 4 +- .../cache/GridCacheSwapPreloadSelfTest.java | 4 +- .../GridCacheValueBytesPreloadingSelfTest.java | 2 +- ...idCacheValueConsistencyAbstractSelfTest.java | 4 +- .../IgniteCacheAbstractStopBusySelfTest.java | 2 +- ...tAllUpdateNonPreloadedPartitionSelfTest.java | 2 +- .../IgniteCollectionAbstractTest.java | 4 +- ...GridCachePartitionedNodeRestartSelfTest.java | 4 +- ...idCachePartitionedNodeRestartTxSelfTest.java | 4 +- ...PartitionedQueueCreateMultiNodeSelfTest.java | 4 +- .../GridCacheAbstractNodeRestartSelfTest.java | 6 +- .../GridCacheAbstractPrimarySyncSelfTest.java | 4 +- ...acheEntrySetIterationPreloadingSelfTest.java | 2 +- ...heExpiredEntriesPreloadAbstractSelfTest.java | 6 +- .../distributed/GridCacheLockAbstractTest.java | 4 +- ...dCacheMultithreadedFailoverAbstractTest.java | 4 +- ...dCachePartitionedAffinityFilterSelfTest.java | 4 +- .../GridCachePreloadEventsAbstractSelfTest.java | 8 +- .../GridCachePreloadLifecycleAbstractTest.java | 6 +- ...GridCachePreloadRestartAbstractSelfTest.java | 10 +- ...iteTxConsistencyRestartAbstractSelfTest.java | 4 +- .../IgniteTxPreloadAbstractTest.java | 4 +- .../dht/GridCacheAtomicNearCacheSelfTest.java | 4 +- ...dCacheColocatedTxSingleThreadedSelfTest.java | 4 +- ...GridCacheDhtEvictionNearReadersSelfTest.java | 4 +- .../dht/GridCacheDhtEvictionSelfTest.java | 4 +- .../dht/GridCacheDhtInternalEntrySelfTest.java | 4 +- .../dht/GridCacheDhtMappingSelfTest.java | 4 +- .../dht/GridCacheDhtPreloadBigDataSelfTest.java | 10 +- .../dht/GridCacheDhtPreloadDelayedSelfTest.java | 20 +- .../GridCacheDhtPreloadDisabledSelfTest.java | 8 +- .../GridCacheDhtPreloadMessageCountTest.java | 4 +- .../dht/GridCacheDhtPreloadPutGetSelfTest.java | 6 +- .../dht/GridCacheDhtPreloadSelfTest.java | 28 +-- .../GridCacheDhtPreloadStartStopSelfTest.java | 12 +- .../dht/GridCacheDhtPreloadUnloadSelfTest.java | 10 +- ...ePartitionedNearDisabledMetricsSelfTest.java | 4 +- ...idCachePartitionedPreloadEventsSelfTest.java | 8 +- ...dCachePartitionedTopologyChangeSelfTest.java | 4 +- ...ridCachePartitionedUnloadEventsSelfTest.java | 13 +- ...eAtomicInvalidPartitionHandlingSelfTest.java | 4 +- ...unctionExcludeNeighborsAbstractSelfTest.java | 4 +- ...GridCacheAtomicMultiNodeFullApiSelfTest.java | 4 +- ...idCacheAtomicPartitionedMetricsSelfTest.java | 4 +- .../near/GridCacheNearEvictionSelfTest.java | 7 +- .../near/GridCacheNearMultiGetSelfTest.java | 4 +- .../near/GridCacheNearOnlyTopologySelfTest.java | 4 +- .../GridCacheNearPartitionedClearSelfTest.java | 4 +- .../near/GridCacheNearReadersSelfTest.java | 4 +- .../near/GridCacheNearTxMultiNodeSelfTest.java | 4 +- ...AffinityExcludeNeighborsPerformanceTest.java | 4 +- .../GridCachePartitionedAffinitySelfTest.java | 4 +- .../GridCachePartitionedBasicOpSelfTest.java | 2 +- .../near/GridCachePartitionedEventSelfTest.java | 4 +- ...idCachePartitionedHitsAndMissesSelfTest.java | 2 +- .../GridCachePartitionedMetricsSelfTest.java | 4 +- ...achePartitionedMultiNodeCounterSelfTest.java | 4 +- ...achePartitionedMultiNodeFullApiSelfTest.java | 4 +- .../GridCachePartitionedNodeRestartTest.java | 4 +- ...ePartitionedOptimisticTxNodeRestartTest.java | 4 +- ...achePartitionedPreloadLifecycleSelfTest.java | 4 +- ...hePartitionedQueryMultiThreadedSelfTest.java | 2 +- .../GridCachePartitionedTxSalvageSelfTest.java | 2 +- ...achePartitionedTxSingleThreadedSelfTest.java | 4 +- .../GridCacheReplicatedInvalidateSelfTest.java | 4 +- .../GridCacheReplicatedNodeRestartSelfTest.java | 6 +- .../GridCacheSyncReplicatedPreloadSelfTest.java | 6 +- ...CacheReplicatedPreloadLifecycleSelfTest.java | 4 +- .../GridCacheReplicatedPreloadSelfTest.java | 16 +- ...eplicatedPreloadStartStopEventsSelfTest.java | 6 +- .../GridCacheEvictionFilterSelfTest.java | 4 +- .../GridCacheLruNearEvictionPolicySelfTest.java | 4 +- ...heNearOnlyLruNearEvictionPolicySelfTest.java | 4 +- ...ridCacheContinuousQueryAbstractSelfTest.java | 4 +- ...dCacheAbstractReduceFieldsQuerySelfTest.java | 4 +- .../processors/igfs/IgfsSizeSelfTest.java | 8 +- .../loadtests/GridCacheMultiNodeLoadTest.java | 4 +- .../capacity/spring-capacity-cache.xml | 4 +- .../loadtests/colocation/spring-colocation.xml | 4 +- .../GridCachePartitionedAtomicLongLoadTest.java | 2 +- .../GridP2PContinuousDeploymentSelfTest.java | 4 +- .../tcp/GridCacheDhtLockBackupSelfTest.java | 4 +- .../junits/common/GridCommonAbstractTest.java | 4 +- .../webapp/META-INF/ignite-webapp-config.xml | 12 +- .../GridCacheAbstractFieldsQuerySelfTest.java | 4 +- .../cache/GridCacheAbstractQuerySelfTest.java | 4 +- .../cache/GridCacheCrossCacheQuerySelfTest.java | 4 +- .../GridCacheCrossCacheQuerySelfTestNewApi.java | 4 +- .../cache/GridIndexingWithNoopSwapSelfTest.java | 4 +- .../near/GridCacheQueryNodeRestartSelfTest.java | 6 +- .../query/h2/sql/GridQueryParsingTest.java | 5 +- .../tcp/GridOrderedMessageCancelSelfTest.java | 4 +- .../commands/events/VisorEventsCommand.scala | 4 +- .../scala/org/apache/ignite/visor/visor.scala | 4 +- 147 files changed, 864 insertions(+), 874 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/examples/config/example-cache.xml ---------------------------------------------------------------------- diff --git a/examples/config/example-cache.xml b/examples/config/example-cache.xml index 2ccecf9..8c7fee5 100644 --- a/examples/config/example-cache.xml +++ b/examples/config/example-cache.xml @@ -140,8 +140,8 @@ <!-- Initial cache size. --> <property name="startSize" value="3000000"/> - <!-- Set synchronous preloading (default is asynchronous). --> - <property name="preloadMode" value="SYNC"/> + <!-- Set synchronous rebalancing (default is asynchronous). --> + <property name="rebalanceMode" value="SYNC"/> <!-- Set to FULL_SYNC for examples, default is PRIMARY_SYNC. --> <property name="writeSynchronizationMode" value="FULL_SYNC"/> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/examples/src/main/java/org/apache/ignite/examples/misc/client/memcache/MemcacheRestExampleNodeStartup.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/misc/client/memcache/MemcacheRestExampleNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/misc/client/memcache/MemcacheRestExampleNodeStartup.java index 1b2b41e..b856fc4 100644 --- a/examples/src/main/java/org/apache/ignite/examples/misc/client/memcache/MemcacheRestExampleNodeStartup.java +++ b/examples/src/main/java/org/apache/ignite/examples/misc/client/memcache/MemcacheRestExampleNodeStartup.java @@ -18,7 +18,6 @@ package org.apache.ignite.examples.misc.client.memcache; import org.apache.ignite.*; -import org.apache.ignite.cache.query.*; import org.apache.ignite.configuration.*; import org.apache.ignite.marshaller.optimized.*; import org.apache.ignite.spi.discovery.tcp.*; @@ -27,7 +26,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import java.util.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; -import static org.apache.ignite.cache.CachePreloadMode.*; +import static org.apache.ignite.cache.CacheRebalanceMode.*; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; import static org.apache.ignite.configuration.DeploymentMode.*; @@ -73,7 +72,7 @@ public class MemcacheRestExampleNodeStartup { cacheCfg.setAtomicityMode(TRANSACTIONAL); cacheCfg.setWriteSynchronizationMode(FULL_SYNC); - cacheCfg.setPreloadMode(SYNC); + cacheCfg.setRebalanceMode(SYNC); cacheCfg.setAtomicityMode(TRANSACTIONAL); CacheQueryConfiguration qryCfg = new CacheQueryConfiguration(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/clients/src/test/resources/spring-cache.xml ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/resources/spring-cache.xml b/modules/clients/src/test/resources/spring-cache.xml index d34e3cc..b815c5d 100644 --- a/modules/clients/src/test/resources/spring-cache.xml +++ b/modules/clients/src/test/resources/spring-cache.xml @@ -99,8 +99,8 @@ --> <property name="backups" value="1"/> - <!-- Set synchronous preloading (default is asynchronous). --> - <property name="preloadMode" value="SYNC"/> + <!-- Set synchronous rebalancing (default is asynchronous). --> + <property name="rebalanceMode" value="SYNC"/> </bean> <!-- @@ -121,8 +121,8 @@ <!-- REPLICATED cache mode. --> <property name="cacheMode" value="REPLICATED"/> - <!-- Set synchronous preloading (default is asynchronous). --> - <property name="preloadMode" value="SYNC"/> + <!-- Set synchronous rebalancing (default is asynchronous). --> + <property name="rebalanceMode" value="SYNC"/> <!-- Initial cache size. --> <property name="startSize" value="150000"/> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/cache/CachePreloadMode.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CachePreloadMode.java b/modules/core/src/main/java/org/apache/ignite/cache/CachePreloadMode.java deleted file mode 100644 index 522bd32..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/CachePreloadMode.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache; - -import org.jetbrains.annotations.*; - -/** - * Cache preload mode. When preloading is enabled (i.e. has value other than {@link #NONE}), distributed caches - * will attempt to preload all necessary values from other grid nodes. This enumeration is used to configure - * preloading via {@link org.apache.ignite.configuration.CacheConfiguration#getPreloadMode()} configuration property. If not configured - * explicitly, then {@link org.apache.ignite.configuration.CacheConfiguration#DFLT_PRELOAD_MODE} is used. - * <p> - * Replicated caches will try to load the full set of cache entries from other nodes (or as defined by - * pluggable {@link org.apache.ignite.cache.affinity.CacheAffinityFunction}), while partitioned caches will only load the entries for which - * current node is primary or back up. - * <p> - * Note that preload mode only makes sense for {@link CacheMode#REPLICATED} and {@link CacheMode#PARTITIONED} - * caches. Caches with {@link CacheMode#LOCAL} mode are local by definition and therefore cannot preload - * any values from neighboring nodes. - */ -public enum CachePreloadMode { - /** - * Synchronous preload mode. Distributed caches will not start until all necessary data - * is loaded from other available grid nodes. - */ - SYNC, - - /** - * Asynchronous preload mode. Distributed caches will start immediately and will load all necessary - * data from other available grid nodes in the background. - */ - ASYNC, - - /** - * In this mode no preloading will take place which means that caches will be either loaded on - * demand from persistent store whenever data is accessed, or will be populated explicitly. - */ - NONE; - - /** Enumerated values. */ - private static final CachePreloadMode[] VALS = values(); - - /** - * Efficiently gets enumerated value from its ordinal. - * - * @param ord Ordinal value. - * @return Enumerated value or {@code null} if ordinal out of range. - */ - @Nullable public static CachePreloadMode fromOrdinal(int ord) { - return ord >= 0 && ord < VALS.length ? VALS[ord] : null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/cache/CacheRebalanceMode.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheRebalanceMode.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheRebalanceMode.java new file mode 100644 index 0000000..90d9ba4 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheRebalanceMode.java @@ -0,0 +1,67 @@ +/* + * 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.cache; + +import org.jetbrains.annotations.*; + +/** + * Cache rebalance mode. When rebalancing is enabled (i.e. has value other than {@link #NONE}), distributed caches + * will attempt to rebalance all necessary values from other grid nodes. This enumeration is used to configure + * rebalancing via {@link org.apache.ignite.configuration.CacheConfiguration#getRebalanceMode()} configuration property. If not configured + * explicitly, then {@link org.apache.ignite.configuration.CacheConfiguration#DFLT_REBALANCE_MODE} is used. + * <p> + * Replicated caches will try to load the full set of cache entries from other nodes (or as defined by + * pluggable {@link org.apache.ignite.cache.affinity.CacheAffinityFunction}), while partitioned caches will only load the entries for which + * current node is primary or back up. + * <p> + * Note that rebalance mode only makes sense for {@link CacheMode#REPLICATED} and {@link CacheMode#PARTITIONED} + * caches. Caches with {@link CacheMode#LOCAL} mode are local by definition and therefore cannot rebalance + * any values from neighboring nodes. + */ +public enum CacheRebalanceMode { + /** + * Synchronous rebalance mode. Distributed caches will not start until all necessary data + * is loaded from other available grid nodes. + */ + SYNC, + + /** + * Asynchronous rebalance mode. Distributed caches will start immediately and will load all necessary + * data from other available grid nodes in the background. + */ + ASYNC, + + /** + * In this mode no rebalancing will take place which means that caches will be either loaded on + * demand from persistent store whenever data is accessed, or will be populated explicitly. + */ + NONE; + + /** Enumerated values. */ + private static final CacheRebalanceMode[] VALS = values(); + + /** + * Efficiently gets enumerated value from its ordinal. + * + * @param ord Ordinal value. + * @return Enumerated value or {@code null} if ordinal out of range. + */ + @Nullable public static CacheRebalanceMode fromOrdinal(int ord) { + return ord >= 0 && ord < VALS.length ? VALS[ord] : null; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/cache/GridCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/GridCache.java b/modules/core/src/main/java/org/apache/ignite/cache/GridCache.java index 8bbea1f..ee1762e 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/GridCache.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/GridCache.java @@ -19,11 +19,9 @@ package org.apache.ignite.cache; import org.apache.ignite.*; import org.apache.ignite.cache.affinity.*; -import org.apache.ignite.cache.store.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.lang.*; import org.apache.ignite.mxbean.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; @@ -201,23 +199,23 @@ public interface GridCache<K, V> extends CacheProjection<K, V> { /** * Forces this cache node to re-balance its partitions. This method is usually used when - * {@link CacheConfiguration#getPreloadPartitionedDelay()} configuration parameter has non-zero value. + * {@link CacheConfiguration#getRebalancePartitionedDelay()} configuration parameter has non-zero value. * When many nodes are started or stopped almost concurrently, it is more efficient to delay - * preloading until the node topology is stable to make sure that no redundant re-partitioning + * rebalancing until the node topology is stable to make sure that no redundant re-partitioning * happens. * <p> * In case of{@link CacheMode#PARTITIONED} caches, for better efficiency user should * usually make sure that new nodes get placed on the same place of consistent hash ring as * the left nodes, and that nodes are restarted before - * {@link CacheConfiguration#getPreloadPartitionedDelay() preloadDelay} expires. To place nodes + * {@link CacheConfiguration#getRebalancePartitionedDelay() rebalanceDelay} expires. To place nodes * on the same place in consistent hash ring, use * {@link org.apache.ignite.cache.affinity.consistenthash.CacheConsistentHashAffinityFunction#setHashIdResolver(org.apache.ignite.cache.affinity.CacheAffinityNodeHashResolver)} to make sure that * a node maps to the same hash ID if re-started. * <p> - * See {@link org.apache.ignite.configuration.CacheConfiguration#getPreloadPartitionedDelay()} for more information on how to configure - * preload re-partition delay. + * See {@link org.apache.ignite.configuration.CacheConfiguration#getRebalancePartitionedDelay()} for more information on how to configure + * rebalance re-partition delay. * <p> - * @return Future that will be completed when preloading is finished. + * @return Future that will be completed when rebalancing is finished. */ public IgniteInternalFuture<?> forceRepartition(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java index 57583d4..f8186bc 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java @@ -43,14 +43,14 @@ import java.util.*; */ @SuppressWarnings("RedundantFieldInitialization") public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { - /** Default size of preload thread pool. */ - public static final int DFLT_PRELOAD_THREAD_POOL_SIZE = 2; + /** Default size of rebalance thread pool. */ + public static final int DFLT_REBALANCE_THREAD_POOL_SIZE = 2; - /** Default preload timeout (ms).*/ - public static final long DFLT_PRELOAD_TIMEOUT = 10000; + /** Default rebalance timeout (ms).*/ + public static final long DFLT_REBALANCE_TIMEOUT = 10000; - /** Time in milliseconds to wait between preload messages to avoid overloading CPU. */ - public static final long DFLT_PRELOAD_THROTTLE = 0; + /** Time in milliseconds to wait between rebalance messages to avoid overloading CPU. */ + public static final long DFLT_REBALANCE_THROTTLE = 0; /** * Default time to live. The value is <tt>0</tt> which means that @@ -91,11 +91,11 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { /** Default value for 'storeValueBytes' flag indicating if value bytes should be stored. */ public static final boolean DFLT_STORE_VALUE_BYTES = true; - /** Default preload mode for distributed cache. */ - public static final CachePreloadMode DFLT_PRELOAD_MODE = CachePreloadMode.ASYNC; + /** Default rebalance mode for distributed cache. */ + public static final CacheRebalanceMode DFLT_REBALANCE_MODE = CacheRebalanceMode.ASYNC; - /** Default preload batch size in bytes. */ - public static final int DFLT_PRELOAD_BATCH_SIZE = 512 * 1024; // 512K + /** Default rebalance batch size in bytes. */ + public static final int DFLT_REBALANCE_BATCH_SIZE = 512 * 1024; // 512K /** Default maximum eviction queue ratio. */ public static final float DFLT_MAX_EVICTION_OVERFLOW_RATIO = 10; @@ -163,11 +163,11 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { /** Cache name. */ private String name; - /** Preload thread pool size. */ - private int preloadPoolSize = DFLT_PRELOAD_THREAD_POOL_SIZE; + /** Rebalance thread pool size. */ + private int rebalancePoolSize = DFLT_REBALANCE_THREAD_POOL_SIZE; - /** Preload timeout. */ - private long preloadTimeout = DFLT_PRELOAD_TIMEOUT; + /** Rebalance timeout. */ + private long rebalanceTimeout = DFLT_REBALANCE_TIMEOUT; /** Default time to live for cache entries. */ private long ttl = DFLT_TIME_TO_LIVE; @@ -250,14 +250,14 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { /** Name of class implementing GridCacheTmLookup. */ private String tmLookupClsName; - /** Distributed cache preload mode. */ - private CachePreloadMode preloadMode = DFLT_PRELOAD_MODE; + /** Distributed cache rebalance mode. */ + private CacheRebalanceMode rebalanceMode = DFLT_REBALANCE_MODE; - /** Cache preload order. */ - private int preloadOrder; + /** Cache rebalance order. */ + private int rebalanceOrder; - /** Preload batch size. */ - private int preloadBatchSize = DFLT_PRELOAD_BATCH_SIZE; + /** Rebalance batch size. */ + private int rebalanceBatchSize = DFLT_REBALANCE_BATCH_SIZE; /** Off-heap memory size. */ private long offHeapMaxMem = DFLT_OFFHEAP_MEMORY; @@ -299,10 +299,10 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { private String indexingSpiName; /** */ - private long preloadDelay; + private long rebalanceDelay; /** */ - private long preloadThrottle = DFLT_PRELOAD_THROTTLE; + private long rebalanceThrottle = DFLT_REBALANCE_THROTTLE; /** */ private CacheInterceptor<?, ?> interceptor; @@ -376,13 +376,13 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { name = cc.getName(); nearStartSize = cc.getNearStartSize(); nearEvictPlc = cc.getNearEvictionPolicy(); - preloadMode = cc.getPreloadMode(); - preloadBatchSize = cc.getPreloadBatchSize(); - preloadDelay = cc.getPreloadPartitionedDelay(); - preloadOrder = cc.getPreloadOrder(); - preloadPoolSize = cc.getPreloadThreadPoolSize(); - preloadTimeout = cc.getPreloadTimeout(); - preloadThrottle = cc.getPreloadThrottle(); + rebalanceMode = cc.getRebalanceMode(); + rebalanceBatchSize = cc.getRebalanceBatchSize(); + rebalanceDelay = cc.getRebalancePartitionedDelay(); + rebalanceOrder = cc.getRebalanceOrder(); + rebalancePoolSize = cc.getRebalanceThreadPoolSize(); + rebalanceTimeout = cc.getRebalanceTimeout(); + rebalanceThrottle = cc.getRebalanceThrottle(); qryCfg = cc.getQueryConfiguration(); qryIdxEnabled = cc.isQueryIndexEnabled(); readFromBackup = cc.isReadFromBackup(); @@ -1033,73 +1033,73 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { } /** - * Sets cache preload mode. + * Sets cache rebalance mode. * - * @param preloadMode Preload mode. + * @param rebalanceMode Rebalance mode. */ - public void setPreloadMode(CachePreloadMode preloadMode) { - this.preloadMode = preloadMode; + public void setRebalanceMode(CacheRebalanceMode rebalanceMode) { + this.rebalanceMode = rebalanceMode; } /** - * Gets preload mode for distributed cache. + * Gets rebalance mode for distributed cache. * <p> - * Default is defined by {@link #DFLT_PRELOAD_MODE}. + * Default is defined by {@link #DFLT_REBALANCE_MODE}. * - * @return Preload mode. + * @return Rebalance mode. */ - public CachePreloadMode getPreloadMode() { - return preloadMode; + public CacheRebalanceMode getRebalanceMode() { + return rebalanceMode; } /** - * Gets cache preload order. Preload order can be set to non-zero value for caches with - * {@link CachePreloadMode#SYNC SYNC} or {@link CachePreloadMode#ASYNC ASYNC} preload modes only. + * Gets cache rebalance order. Rebalance order can be set to non-zero value for caches with + * {@link CacheRebalanceMode#SYNC SYNC} or {@link CacheRebalanceMode#ASYNC ASYNC} rebalance modes only. * <p/> - * If cache preload order is positive, preloading for this cache will be started only when preloading for - * all caches with smaller preload order (except caches with preload order {@code 0}) will be completed. + * If cache rebalance order is positive, rebalancing for this cache will be started only when rebalancing for + * all caches with smaller rebalance order (except caches with rebalance order {@code 0}) will be completed. * <p/> * Note that cache with order {@code 0} does not participate in ordering. This means that cache with - * preload order {@code 1} will never wait for any other caches. All caches with order {@code 0} will - * be preloaded right away concurrently with each other and ordered preload processes. + * rebalance order {@code 1} will never wait for any other caches. All caches with order {@code 0} will + * be rebalanced right away concurrently with each other and ordered rebalance processes. * <p/> - * If not set, cache order is 0, i.e. preloading is not ordered. + * If not set, cache order is 0, i.e. rebalancing is not ordered. * - * @return Cache preload order. + * @return Cache rebalance order. */ - public int getPreloadOrder() { - return preloadOrder; + public int getRebalanceOrder() { + return rebalanceOrder; } /** - * Sets cache preload order. + * Sets cache rebalance order. * - * @param preloadOrder Cache preload order. - * @see #getPreloadOrder() + * @param rebalanceOrder Cache rebalance order. + * @see #getRebalanceOrder() */ - public void setPreloadOrder(int preloadOrder) { - this.preloadOrder = preloadOrder; + public void setRebalanceOrder(int rebalanceOrder) { + this.rebalanceOrder = rebalanceOrder; } /** - * Gets size (in number bytes) to be loaded within a single preload message. - * Preloading algorithm will split total data set on every node into multiple + * Gets size (in number bytes) to be loaded within a single rebalance message. + * Rebalancing algorithm will split total data set on every node into multiple * batches prior to sending data. Default value is defined by - * {@link #DFLT_PRELOAD_BATCH_SIZE}. + * {@link #DFLT_REBALANCE_BATCH_SIZE}. * - * @return Size in bytes of a single preload message. + * @return Size in bytes of a single rebalance message. */ - public int getPreloadBatchSize() { - return preloadBatchSize; + public int getRebalanceBatchSize() { + return rebalanceBatchSize; } /** - * Sets preload batch size. + * Sets rebalance batch size. * - * @param preloadBatchSize Preload batch size. + * @param rebalanceBatchSize Rebalance batch size. */ - public void setPreloadBatchSize(int preloadBatchSize) { - this.preloadBatchSize = preloadBatchSize; + public void setRebalanceBatchSize(int rebalanceBatchSize) { + this.rebalanceBatchSize = rebalanceBatchSize; } /** @@ -1292,54 +1292,54 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { } /** - * Gets size of preloading thread pool. Note that size serves as a hint and implementation - * may create more threads for preloading than specified here (but never less threads). + * Gets size of rebalancing thread pool. Note that size serves as a hint and implementation + * may create more threads for rebalancing than specified here (but never less threads). * <p> - * Default value is {@link #DFLT_PRELOAD_THREAD_POOL_SIZE}. + * Default value is {@link #DFLT_REBALANCE_THREAD_POOL_SIZE}. * - * @return Size of preloading thread pool. + * @return Size of rebalancing thread pool. */ - public int getPreloadThreadPoolSize() { - return preloadPoolSize; + public int getRebalanceThreadPoolSize() { + return rebalancePoolSize; } /** - * Sets size of preloading thread pool. Note that size serves as a hint and implementation may create more threads - * for preloading than specified here (but never less threads). + * Sets size of rebalancing thread pool. Note that size serves as a hint and implementation may create more threads + * for rebalancing than specified here (but never less threads). * - * @param preloadPoolSize Size of preloading thread pool. + * @param rebalancePoolSize Size of rebalancing thread pool. */ - public void setPreloadThreadPoolSize(int preloadPoolSize) { - this.preloadPoolSize = preloadPoolSize; + public void setRebalanceThreadPoolSize(int rebalancePoolSize) { + this.rebalancePoolSize = rebalancePoolSize; } /** - * Gets preload timeout (ms). + * Gets rebalance timeout (ms). * <p> - * Default value is {@link #DFLT_PRELOAD_TIMEOUT}. + * Default value is {@link #DFLT_REBALANCE_TIMEOUT}. * - * @return Preload timeout (ms). + * @return Rebalance timeout (ms). */ - public long getPreloadTimeout() { - return preloadTimeout; + public long getRebalanceTimeout() { + return rebalanceTimeout; } /** - * Sets preload timeout (ms). + * Sets rebalance timeout (ms). * - * @param preloadTimeout Preload timeout (ms). + * @param rebalanceTimeout Rebalance timeout (ms). */ - public void setPreloadTimeout(long preloadTimeout) { - this.preloadTimeout = preloadTimeout; + public void setRebalanceTimeout(long rebalanceTimeout) { + this.rebalanceTimeout = rebalanceTimeout; } /** - * Gets delay in milliseconds upon a node joining or leaving topology (or crash) after which preloading - * should be started automatically. Preloading should be delayed if you plan to restart nodes + * Gets delay in milliseconds upon a node joining or leaving topology (or crash) after which rebalancing + * should be started automatically. Rebalancing should be delayed if you plan to restart nodes * after they leave topology, or if you plan to start multiple nodes at once or one after another - * and don't want to repartition and preload until all nodes are started. + * and don't want to repartition and rebalance until all nodes are started. * <p> - * Delayed preloading is applied to {@link CacheMode#PARTITIONED} caches only. + * Delayed rebalancing is applied to {@link CacheMode#PARTITIONED} caches only. * For better efficiency user should usually make sure that new nodes get placed on * the same place of consistent hash ring as the left nodes, and that nodes are * restarted before this delay expires. To place nodes on the same place in consistent hash ring, @@ -1347,59 +1347,59 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { * to make sure that a node maps to the same hash ID event if restarted. As an example, * node IP address and port combination may be used in this case. * <p> - * Default value is {@code 0} which means that repartitioning and preloading will start - * immediately upon node leaving topology. If {@code -1} is returned, then preloading + * Default value is {@code 0} which means that repartitioning and rebalancing will start + * immediately upon node leaving topology. If {@code -1} is returned, then rebalancing * will only be started manually by calling {@link GridCache#forceRepartition()} method or * from management console. * - * @return Preloading delay, {@code 0} to start preloading immediately, {@code -1} to - * start preloading manually, or positive value to specify delay in milliseconds - * after which preloading should start automatically. + * @return Rebalancing delay, {@code 0} to start rebalancing immediately, {@code -1} to + * start rebalancing manually, or positive value to specify delay in milliseconds + * after which rebalancing should start automatically. */ - public long getPreloadPartitionedDelay() { - return preloadDelay; + public long getRebalancePartitionedDelay() { + return rebalanceDelay; } /** - * Sets preload delay (see {@link #getPreloadPartitionedDelay()} for more information). + * Sets rebalance delay (see {@link #getRebalancePartitionedDelay()} for more information). * - * @param preloadDelay Preload delay to set. + * @param rebalanceDelay Rebalance delay to set. */ - public void setPreloadPartitionedDelay(long preloadDelay) { - this.preloadDelay = preloadDelay; + public void setRebalancePartitionedDelay(long rebalanceDelay) { + this.rebalanceDelay = rebalanceDelay; } /** - * Time in milliseconds to wait between preload messages to avoid overloading of CPU or network. - * When preloading large data sets, the CPU or network can get over-consumed with preloading messages, + * Time in milliseconds to wait between rebalance messages to avoid overloading of CPU or network. + * When rebalancing large data sets, the CPU or network can get over-consumed with rebalancing messages, * which consecutively may slow down the application performance. This parameter helps tune - * the amount of time to wait between preload messages to make sure that preloading process + * the amount of time to wait between rebalance messages to make sure that rebalancing process * does not have any negative performance impact. Note that application will continue to work - * properly while preloading is still in progress. + * properly while rebalancing is still in progress. * <p> * Value of {@code 0} means that throttling is disabled. By default throttling is disabled - - * the default is defined by {@link #DFLT_PRELOAD_THROTTLE} constant. + * the default is defined by {@link #DFLT_REBALANCE_THROTTLE} constant. * - * @return Time in milliseconds to wait between preload messages to avoid overloading of CPU, + * @return Time in milliseconds to wait between rebalance messages to avoid overloading of CPU, * {@code 0} to disable throttling. */ - public long getPreloadThrottle() { - return preloadThrottle; + public long getRebalanceThrottle() { + return rebalanceThrottle; } /** - * Time in milliseconds to wait between preload messages to avoid overloading of CPU or network. When preloading - * large data sets, the CPU or network can get over-consumed with preloading messages, which consecutively may slow - * down the application performance. This parameter helps tune the amount of time to wait between preload messages - * to make sure that preloading process does not have any negative performance impact. Note that application will - * continue to work properly while preloading is still in progress. <p> Value of {@code 0} means that throttling is - * disabled. By default throttling is disabled - the default is defined by {@link #DFLT_PRELOAD_THROTTLE} constant. + * Time in milliseconds to wait between rebalance messages to avoid overloading of CPU or network. When rebalancing + * large data sets, the CPU or network can get over-consumed with rebalancing messages, which consecutively may slow + * down the application performance. This parameter helps tune the amount of time to wait between rebalance messages + * to make sure that rebalancing process does not have any negative performance impact. Note that application will + * continue to work properly while rebalancing is still in progress. <p> Value of {@code 0} means that throttling is + * disabled. By default throttling is disabled - the default is defined by {@link #DFLT_REBALANCE_THROTTLE} constant. * - * @param preloadThrottle Time in milliseconds to wait between preload messages to avoid overloading of CPU, {@code - * 0} to disable throttling. + * @param rebalanceThrottle Time in milliseconds to wait between rebalance messages to avoid overloading of CPU, + * {@code 0} to disable throttling. */ - public void setPreloadThrottle(long preloadThrottle) { - this.preloadThrottle = preloadThrottle; + public void setRebalanceThrottle(long rebalanceThrottle) { + this.rebalanceThrottle = rebalanceThrottle; } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/events/CachePreloadingEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/CachePreloadingEvent.java b/modules/core/src/main/java/org/apache/ignite/events/CachePreloadingEvent.java deleted file mode 100644 index 25ec68a..0000000 --- a/modules/core/src/main/java/org/apache/ignite/events/CachePreloadingEvent.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.events; - -import org.apache.ignite.cluster.*; -import org.apache.ignite.internal.util.typedef.internal.*; - -/** - * In-memory database (cache) preloading event. Preload event happens every time there is a change - * in grid topology, which means that a node has either joined or left the grid. - * <p> - * Grid events are used for notification about what happens within the grid. Note that by - * design Ignite keeps all events generated on the local node locally and it provides - * APIs for performing a distributed queries across multiple nodes: - * <ul> - * <li> - * {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} - - * asynchronously querying events occurred on the nodes specified, including remote nodes. - * </li> - * <li> - * {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} - - * querying only local events stored on this local node. - * </li> - * <li> - * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} - - * listening to local grid events (events from remote nodes not included). - * </li> - * </ul> - * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}. - * <h1 class="header">Events and Performance</h1> - * Note that by default all events in Ignite are enabled and therefore generated and stored - * by whatever event storage SPI is configured. Ignite can and often does generate thousands events per seconds - * under the load and therefore it creates a significant additional load on the system. If these events are - * not needed by the application this load is unnecessary and leads to significant performance degradation. - * <p> - * It is <b>highly recommended</b> to enable only those events that your application logic requires - * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in Ignite configuration. Note that certain - * events are required for Ignite's internal operations and such events will still be generated but not stored by - * event storage SPI if they are disabled in Ignite configuration. - * @see EventType#EVT_CACHE_PRELOAD_PART_LOADED - * @see EventType#EVT_CACHE_PRELOAD_PART_UNLOADED - * @see EventType#EVT_CACHE_PRELOAD_STARTED - * @see EventType#EVT_CACHE_PRELOAD_STOPPED - */ -public class CachePreloadingEvent extends EventAdapter { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache name. */ - private String cacheName; - - /** Partition for the event. */ - private int part; - - /** Discovery node. */ - private ClusterNode discoNode; - - /** Discovery event type. */ - private int discoEvtType; - - /** Discovery event time. */ - private long discoTs; - - /** - * Constructs cache event. - * - * @param cacheName Cache name. - * @param node Event node. - * @param msg Event message. - * @param type Event type. - * @param part Partition for the event (usually the partition the key belongs to). - * @param discoNode Node that triggered this preloading event. - * @param discoEvtType Discovery event type that triggered this preloading event. - * @param discoTs Timestamp of discovery event that triggered this preloading event. - */ - public CachePreloadingEvent(String cacheName, ClusterNode node, String msg, int type, int part, - ClusterNode discoNode, int discoEvtType, long discoTs) { - super(node, msg, type); - this.cacheName = cacheName; - this.part = part; - this.discoNode = discoNode; - this.discoEvtType = discoEvtType; - this.discoTs = discoTs; - } - - /** - * Gets cache name. - * - * @return Cache name. - */ - public String cacheName() { - return cacheName; - } - - /** - * Gets partition for the event. - * - * @return Partition for the event. - */ - public int partition() { - return part; - } - - /** - * Gets shadow of the node that triggered this preloading event. - * - * @return Shadow of the node that triggered this preloading event. - */ - public ClusterNode discoveryNode() { - return discoNode; - } - - /** - * Gets type of discovery event that triggered this preloading event. - * - * @return Type of discovery event that triggered this preloading event. - * @see DiscoveryEvent#type() - */ - public int discoveryEventType() { - return discoEvtType; - } - - /** - * Gets name of discovery event that triggered this preloading event. - * - * @return Name of discovery event that triggered this preloading event. - * @see DiscoveryEvent#name() - */ - public String discoveryEventName() { - return U.gridEventName(discoEvtType); - } - - /** - * Gets timestamp of discovery event that caused this preloading event. - * - * @return Timestamp of discovery event that caused this preloading event. - */ - public long discoveryTimestamp() { - return discoTs; - } - - /** {@inheritDoc} */ - @Override public String shortDisplay() { - return name() + ": cache=" + CU.mask(cacheName) + ", cause=" + - discoveryEventName(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(CachePreloadingEvent.class, this, - "discoEvtName", discoveryEventName(), - "nodeId8", U.id8(node().id()), - "msg", message(), - "type", name(), - "tstamp", timestamp()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/events/CacheRebalancingEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/CacheRebalancingEvent.java b/modules/core/src/main/java/org/apache/ignite/events/CacheRebalancingEvent.java new file mode 100644 index 0000000..661c2b5 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/CacheRebalancingEvent.java @@ -0,0 +1,172 @@ +/* + * 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.events; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +/** + * In-memory database (cache) rebalancing event. Rebalance event happens every time there is a change + * in grid topology, which means that a node has either joined or left the grid. + * <p> + * Grid events are used for notification about what happens within the grid. Note that by + * design Ignite keeps all events generated on the local node locally and it provides + * APIs for performing a distributed queries across multiple nodes: + * <ul> + * <li> + * {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} - + * asynchronously querying events occurred on the nodes specified, including remote nodes. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} - + * querying only local events stored on this local node. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} - + * listening to local grid events (events from remote nodes not included). + * </li> + * </ul> + * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}. + * <h1 class="header">Events and Performance</h1> + * Note that by default all events in Ignite are enabled and therefore generated and stored + * by whatever event storage SPI is configured. Ignite can and often does generate thousands events per seconds + * under the load and therefore it creates a significant additional load on the system. If these events are + * not needed by the application this load is unnecessary and leads to significant performance degradation. + * <p> + * It is <b>highly recommended</b> to enable only those events that your application logic requires + * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in Ignite configuration. Note that certain + * events are required for Ignite's internal operations and such events will still be generated but not stored by + * event storage SPI if they are disabled in Ignite configuration. + * @see EventType#EVT_CACHE_REBALANCE_PART_LOADED + * @see EventType#EVT_CACHE_REBALANCE_PART_UNLOADED + * @see EventType#EVT_CACHE_REBALANCE_STARTED + * @see EventType#EVT_CACHE_REBALANCE_STOPPED + */ +public class CacheRebalancingEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** Cache name. */ + private String cacheName; + + /** Partition for the event. */ + private int part; + + /** Discovery node. */ + private ClusterNode discoNode; + + /** Discovery event type. */ + private int discoEvtType; + + /** Discovery event time. */ + private long discoTs; + + /** + * Constructs cache event. + * + * @param cacheName Cache name. + * @param node Event node. + * @param msg Event message. + * @param type Event type. + * @param part Partition for the event (usually the partition the key belongs to). + * @param discoNode Node that triggered this rebalancing event. + * @param discoEvtType Discovery event type that triggered this rebalancing event. + * @param discoTs Timestamp of discovery event that triggered this rebalancing event. + */ + public CacheRebalancingEvent(String cacheName, ClusterNode node, String msg, int type, int part, + ClusterNode discoNode, int discoEvtType, long discoTs) { + super(node, msg, type); + this.cacheName = cacheName; + this.part = part; + this.discoNode = discoNode; + this.discoEvtType = discoEvtType; + this.discoTs = discoTs; + } + + /** + * Gets cache name. + * + * @return Cache name. + */ + public String cacheName() { + return cacheName; + } + + /** + * Gets partition for the event. + * + * @return Partition for the event. + */ + public int partition() { + return part; + } + + /** + * Gets shadow of the node that triggered this rebalancing event. + * + * @return Shadow of the node that triggered this rebalancing event. + */ + public ClusterNode discoveryNode() { + return discoNode; + } + + /** + * Gets type of discovery event that triggered this rebalancing event. + * + * @return Type of discovery event that triggered this rebalancing event. + * @see DiscoveryEvent#type() + */ + public int discoveryEventType() { + return discoEvtType; + } + + /** + * Gets name of discovery event that triggered this rebalancing event. + * + * @return Name of discovery event that triggered this rebalancing event. + * @see DiscoveryEvent#name() + */ + public String discoveryEventName() { + return U.gridEventName(discoEvtType); + } + + /** + * Gets timestamp of discovery event that caused this rebalancing event. + * + * @return Timestamp of discovery event that caused this rebalancing event. + */ + public long discoveryTimestamp() { + return discoTs; + } + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + ": cache=" + CU.mask(cacheName) + ", cause=" + + discoveryEventName(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(CacheRebalancingEvent.class, this, + "discoEvtName", discoveryEventName(), + "nodeId8", U.id8(node().id()), + "msg", message(), + "type", name(), + "tstamp", timestamp()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/events/Event.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/Event.java b/modules/core/src/main/java/org/apache/ignite/events/Event.java index b47bd54..3951677 100644 --- a/modules/core/src/main/java/org/apache/ignite/events/Event.java +++ b/modules/core/src/main/java/org/apache/ignite/events/Event.java @@ -75,7 +75,7 @@ import java.io.*; * </ul> * @see JobEvent * @see CacheEvent - * @see CachePreloadingEvent + * @see CacheRebalancingEvent * @see SwapSpaceEvent * @see CheckpointEvent * @see DeploymentEvent http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/events/EventType.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/EventType.java b/modules/core/src/main/java/org/apache/ignite/events/EventType.java index 5821da5..2ce47eb 100644 --- a/modules/core/src/main/java/org/apache/ignite/events/EventType.java +++ b/modules/core/src/main/java/org/apache/ignite/events/EventType.java @@ -17,10 +17,8 @@ package org.apache.ignite.events; -import org.apache.ignite.internal.managers.discovery.*; import org.apache.ignite.internal.util.typedef.internal.*; -import java.io.*; import java.util.*; /** @@ -39,7 +37,7 @@ import java.util.*; * <li>{@link #EVTS_JOB_EXECUTION}</li> * <li>{@link #EVTS_TASK_EXECUTION}</li> * <li>{@link #EVTS_CACHE}</li> - * <li>{@link #EVTS_CACHE_PRELOAD}</li> + * <li>{@link #EVTS_CACHE_REBALANCE}</li> * <li>{@link #EVTS_CACHE_QUERY}</li> * <li>{@link #EVTS_SWAPSPACE}</li> * </ul> @@ -556,24 +554,24 @@ public interface EventType { public static final int EVT_CACHE_OBJECT_FROM_OFFHEAP = 77; /** - * Built-in event type: cache preload started. + * Built-in event type: cache rebalance started. * <p> * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for * internal Ignite events and should not be used by user-defined events. * * @see SwapSpaceEvent */ - public static final int EVT_CACHE_PRELOAD_STARTED = 80; + public static final int EVT_CACHE_REBALANCE_STARTED = 80; /** - * Built-in event type: cache preload stopped. + * Built-in event type: cache rebalance stopped. * <p> * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for * internal Ignite events and should not be used by user-defined events. * * @see SwapSpaceEvent */ - public static final int EVT_CACHE_PRELOAD_STOPPED = 81; + public static final int EVT_CACHE_REBALANCE_STOPPED = 81; /** * Built-in event type: cache partition loaded. @@ -583,7 +581,7 @@ public interface EventType { * * @see SwapSpaceEvent */ - public static final int EVT_CACHE_PRELOAD_PART_LOADED = 82; + public static final int EVT_CACHE_REBALANCE_PART_LOADED = 82; /** * Built-in event type: cache partition unloaded. @@ -591,15 +589,15 @@ public interface EventType { * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for * internal Ignite events and should not be used by user-defined events. */ - public static final int EVT_CACHE_PRELOAD_PART_UNLOADED = 83; + public static final int EVT_CACHE_REBALANCE_PART_UNLOADED = 83; /** - * Built-in event type: cache entry preloaded. + * Built-in event type: cache entry rebalanced. * <p> * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for * internal Ignite events and should not be used by user-defined events. */ - public static final int EVT_CACHE_PRELOAD_OBJECT_LOADED = 84; + public static final int EVT_CACHE_REBALANCE_OBJECT_LOADED = 84; /** * Built-in event type: cache entry unloaded. @@ -607,7 +605,7 @@ public interface EventType { * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for * internal Ignite events and should not be used by user-defined events. */ - public static final int EVT_CACHE_PRELOAD_OBJECT_UNLOADED = 85; + public static final int EVT_CACHE_REBALANCE_OBJECT_UNLOADED = 85; /** * Built-in event type: query executed. @@ -822,8 +820,8 @@ public interface EventType { EVT_TASK_DEPLOY_FAILED, EVT_TASK_DEPLOYED, EVT_TASK_UNDEPLOYED, - EVT_CACHE_PRELOAD_STARTED, - EVT_CACHE_PRELOAD_STOPPED + EVT_CACHE_REBALANCE_STARTED, + EVT_CACHE_REBALANCE_STOPPED }; /** @@ -919,17 +917,17 @@ public interface EventType { }; /** - * All cache preload events. This array can be directly passed into + * All cache rebalance events. This array can be directly passed into * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to - * subscribe to all cache preload events. - */ - public static final int[] EVTS_CACHE_PRELOAD = { - EVT_CACHE_PRELOAD_STARTED, - EVT_CACHE_PRELOAD_STOPPED, - EVT_CACHE_PRELOAD_PART_LOADED, - EVT_CACHE_PRELOAD_PART_UNLOADED, - EVT_CACHE_PRELOAD_OBJECT_LOADED, - EVT_CACHE_PRELOAD_OBJECT_UNLOADED + * subscribe to all cache rebalance events. + */ + public static final int[] EVTS_CACHE_REBALANCE = { + EVT_CACHE_REBALANCE_STARTED, + EVT_CACHE_REBALANCE_STOPPED, + EVT_CACHE_REBALANCE_PART_LOADED, + EVT_CACHE_REBALANCE_PART_UNLOADED, + EVT_CACHE_REBALANCE_OBJECT_LOADED, + EVT_CACHE_REBALANCE_OBJECT_UNLOADED }; /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/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 6503ed9..19cfc39 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 @@ -77,7 +77,7 @@ import static org.apache.ignite.IgniteSystemProperties.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; import static org.apache.ignite.cache.CacheDistributionMode.*; import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.cache.CachePreloadMode.*; +import static org.apache.ignite.cache.CacheRebalanceMode.*; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; import static org.apache.ignite.configuration.IgniteConfiguration.*; import static org.apache.ignite.internal.IgniteComponentType.*; @@ -1933,7 +1933,7 @@ public class IgnitionEx { cache.setAtomicityMode(TRANSACTIONAL); cache.setSwapEnabled(false); cache.setQueryIndexEnabled(false); - cache.setPreloadMode(SYNC); + cache.setRebalanceMode(SYNC); cache.setWriteSynchronizationMode(FULL_SYNC); cache.setAffinity(new CacheRendezvousAffinityFunction(false, 100)); @@ -1957,7 +1957,7 @@ public class IgnitionEx { ccfg.setAtomicityMode(TRANSACTIONAL); ccfg.setSwapEnabled(false); ccfg.setQueryIndexEnabled(false); - ccfg.setPreloadMode(SYNC); + ccfg.setRebalanceMode(SYNC); ccfg.setWriteSynchronizationMode(FULL_SYNC); ccfg.setCacheMode(cfg.getCacheMode()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java index a4762ab..00679c0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java @@ -70,14 +70,14 @@ public class GridCacheAttributes implements Externalizable { /** Flag indicating if cached values should be additionally stored in serialized form. */ private boolean storeValBytes; - /** Cache preload mode. */ - private CachePreloadMode preloadMode; + /** Cache rebalance mode. */ + private CacheRebalanceMode rebalanceMode; /** Partitioned cache mode. */ private CacheDistributionMode partDistro; - /** Preload batch size. */ - private int preloadBatchSize; + /** Rebalance batch size. */ + private int rebalanceBatchSize; /** Synchronization mode. */ private CacheWriteSynchronizationMode writeSyncMode; @@ -170,8 +170,8 @@ public class GridCacheAttributes implements Externalizable { loadPrevVal = cfg.isLoadPreviousValue(); name = cfg.getName(); partDistro = GridCacheUtils.distributionMode(cfg); - preloadBatchSize = cfg.getPreloadBatchSize(); - preloadMode = cfg.getPreloadMode(); + rebalanceBatchSize = cfg.getRebalanceBatchSize(); + rebalanceMode = cfg.getRebalanceMode(); qryIdxEnabled = cfg.isQueryIndexEnabled(); readThrough = cfg.isReadThrough(); storeValBytes = cfg.isStoreValueBytes(); @@ -261,10 +261,10 @@ public class GridCacheAttributes implements Externalizable { } /** - * @return Preload mode. + * @return Rebalance mode. */ - public CachePreloadMode cachePreloadMode() { - return preloadMode; + public CacheRebalanceMode cacheRebalanceMode() { + return rebalanceMode; } /** @@ -423,10 +423,10 @@ public class GridCacheAttributes implements Externalizable { } /** - * @return Preload batch size. + * @return Rebalance batch size. */ - public int preloadBatchSize() { - return preloadBatchSize; + public int rebalanceBatchSize() { + return rebalanceBatchSize; } /** @@ -519,8 +519,8 @@ public class GridCacheAttributes implements Externalizable { out.writeBoolean(loadPrevVal); U.writeString(out, name); U.writeEnum(out, partDistro); - out.writeInt(preloadBatchSize); - U.writeEnum(out, preloadMode); + out.writeInt(rebalanceBatchSize); + U.writeEnum(out, rebalanceMode); out.writeBoolean(qryIdxEnabled); out.writeBoolean(readThrough); out.writeBoolean(storeValBytes); @@ -563,8 +563,8 @@ public class GridCacheAttributes implements Externalizable { loadPrevVal = in.readBoolean(); name = U.readString(in); partDistro = CacheDistributionMode.fromOrdinal(in.readByte()); - preloadBatchSize = in.readInt(); - preloadMode = CachePreloadMode.fromOrdinal(in.readByte()); + rebalanceBatchSize = in.readInt(); + rebalanceMode = CacheRebalanceMode.fromOrdinal(in.readByte()); qryIdxEnabled = in.readBoolean(); readThrough = in.readBoolean(); storeValBytes = in.readBoolean(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/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 3ec013c..22c7fe4 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 @@ -63,7 +63,7 @@ import java.util.concurrent.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; import static org.apache.ignite.cache.CacheMemoryMode.*; -import static org.apache.ignite.cache.CachePreloadMode.*; +import static org.apache.ignite.cache.CacheRebalanceMode.*; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; import static org.apache.ignite.internal.managers.communication.GridIoPolicy.*; import static org.apache.ignite.internal.processors.cache.CacheFlag.*; @@ -635,10 +635,10 @@ public class GridCacheContext<K, V> implements Externalizable { } /** - * @return {@code True} if preload is enabled. + * @return {@code True} if rebalance is enabled. */ - public boolean preloadEnabled() { - return cacheCfg.getPreloadMode() != NONE; + public boolean rebalanceEnabled() { + return cacheCfg.getRebalanceMode() != NONE; } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java index e1ff9c0..781005a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java @@ -219,8 +219,8 @@ public class GridCacheEventManager<K, V> extends GridCacheManagerAdapter<K, V> { if (!cctx.events().isRecordable(type)) LT.warn(log, null, "Added event without checking if event is recordable: " + U.gridEventName(type)); - cctx.gridEvents().record(new CachePreloadingEvent(cctx.name(), cctx.localNode(), - "Cache preloading event.", type, part, discoNode, discoType, discoTs)); + cctx.gridEvents().record(new CacheRebalancingEvent(cctx.name(), cctx.localNode(), + "Cache rebalancing event.", type, part, discoNode, discoType, discoTs)); } /** @@ -229,12 +229,12 @@ public class GridCacheEventManager<K, V> extends GridCacheManagerAdapter<K, V> { * @param part Partition. */ public void addUnloadEvent(int part) { - if (!cctx.events().isRecordable(EVT_CACHE_PRELOAD_PART_UNLOADED)) + if (!cctx.events().isRecordable(EVT_CACHE_REBALANCE_PART_UNLOADED)) LT.warn(log, null, "Added event without checking if event is recordable: " + - U.gridEventName(EVT_CACHE_PRELOAD_PART_UNLOADED)); + U.gridEventName(EVT_CACHE_REBALANCE_PART_UNLOADED)); - cctx.gridEvents().record(new CachePreloadingEvent(cctx.name(), cctx.localNode(), - "Cache unloading event.", EVT_CACHE_PRELOAD_PART_UNLOADED, part, null, 0, 0)); + cctx.gridEvents().record(new CacheRebalancingEvent(cctx.name(), cctx.localNode(), + "Cache unloading event.", EVT_CACHE_REBALANCE_PART_UNLOADED, part, null, 0, 0)); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java index 382eb61..a7f9310 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java @@ -494,7 +494,7 @@ public class GridCacheEvictionManager<K, V> extends GridCacheManagerAdapter<K, V * @param p Partition ID. */ private void saveEvictionInfo(K key, GridCacheVersion ver, int p) { - assert cctx.preloadEnabled(); + assert cctx.rebalanceEnabled(); if (!cctx.isNear()) { try { @@ -520,7 +520,7 @@ public class GridCacheEvictionManager<K, V> extends GridCacheManagerAdapter<K, V * {@code false} if preloading is finished or disabled and no lock is needed. */ private boolean lockPartition(int p) { - if (!cctx.preloadEnabled()) + if (!cctx.rebalanceEnabled()) return false; if (!cctx.isNear()) { @@ -556,7 +556,7 @@ public class GridCacheEvictionManager<K, V> extends GridCacheManagerAdapter<K, V * @param p Partition ID. */ private void unlockPartition(int p) { - if (!cctx.preloadEnabled()) + if (!cctx.rebalanceEnabled()) return; if (!cctx.isNear()) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java index d7b1914..482b5a5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java @@ -824,11 +824,11 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana changed |= cacheCtx.topology().afterExchange(exchFut.exchangeId()); // Preload event notification. - if (cacheCtx.events().isRecordable(EVT_CACHE_PRELOAD_STARTED)) { + if (cacheCtx.events().isRecordable(EVT_CACHE_REBALANCE_STARTED)) { if (!cacheCtx.isReplicated() || !startEvtFired) { DiscoveryEvent discoEvt = exchFut.discoveryEvent(); - cacheCtx.events().addPreloadEvent(-1, EVT_CACHE_PRELOAD_STARTED, + cacheCtx.events().addPreloadEvent(-1, EVT_CACHE_REBALANCE_STARTED, discoEvt.eventNode(), discoEvt.type(), discoEvt.timestamp()); } } @@ -851,7 +851,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana } for (GridCacheContext<K, V> cacheCtx : cctx.cacheContexts()) { - long delay = cacheCtx.config().getPreloadPartitionedDelay(); + long delay = cacheCtx.config().getRebalancePartitionedDelay(); GridDhtPreloaderAssignments<K, V> assigns = null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java index e99c706..c427053 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java @@ -60,7 +60,7 @@ import static org.apache.ignite.cache.CacheAtomicityMode.*; import static org.apache.ignite.configuration.CacheConfiguration.*; import static org.apache.ignite.cache.CacheDistributionMode.*; import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.cache.CachePreloadMode.*; +import static org.apache.ignite.cache.CacheRebalanceMode.*; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; import static org.apache.ignite.configuration.DeploymentMode.*; import static org.apache.ignite.internal.IgniteNodeAttributes.*; @@ -90,8 +90,8 @@ public class GridCacheProcessor extends GridProcessorAdapter { /** Map of preload finish futures grouped by preload order. */ private final NavigableMap<Integer, IgniteInternalFuture<?>> preloadFuts; - /** Maximum detected preload order. */ - private int maxPreloadOrder; + /** Maximum detected rebalance order. */ + private int maxRebalanceOrder; /** System cache names. */ private final Set<String> sysCaches; @@ -169,8 +169,8 @@ public class GridCacheProcessor extends GridProcessorAdapter { ctx.igfsHelper().preProcessCacheConfiguration(cfg); - if (cfg.getPreloadMode() == null) - cfg.setPreloadMode(ASYNC); + if (cfg.getRebalanceMode() == null) + cfg.setRebalanceMode(ASYNC); if (cfg.getAtomicityMode() == null) cfg.setAtomicityMode(ATOMIC); @@ -333,9 +333,9 @@ public class GridCacheProcessor extends GridProcessorAdapter { U.warn(log, "CacheAffinityFunction configuration parameter will be ignored for local cache [cacheName=" + cc.getName() + ']'); - if (cc.getPreloadMode() != CachePreloadMode.NONE) { - assertParameter(cc.getPreloadThreadPoolSize() > 0, "preloadThreadPoolSize > 0"); - assertParameter(cc.getPreloadBatchSize() > 0, "preloadBatchSize > 0"); + if (cc.getRebalanceMode() != CacheRebalanceMode.NONE) { + assertParameter(cc.getRebalanceThreadPoolSize() > 0, "rebalanceThreadPoolSize > 0"); + assertParameter(cc.getRebalanceBatchSize() > 0, "rebalanceBatchSize > 0"); } if (cc.getCacheMode() == PARTITIONED || cc.getCacheMode() == REPLICATED) { @@ -384,23 +384,23 @@ public class GridCacheProcessor extends GridProcessorAdapter { throw new IgniteCheckedException("Cannot enable write-through (writer or store is not provided) " + "for cache: " + cc.getName()); - long delay = cc.getPreloadPartitionedDelay(); + long delay = cc.getRebalancePartitionedDelay(); if (delay != 0) { if (cc.getCacheMode() != PARTITIONED) - U.warn(log, "Preload delay is supported only for partitioned caches (will ignore): " + cc.getName(), - "Will ignore preload delay for cache: " + cc.getName()); - else if (cc.getPreloadMode() == SYNC) { + U.warn(log, "Rebalance delay is supported only for partitioned caches (will ignore): " + cc.getName(), + "Will ignore rebalance delay for cache: " + cc.getName()); + else if (cc.getRebalanceMode() == SYNC) { if (delay < 0) { - U.warn(log, "Ignoring SYNC preload mode with manual preload start (node will not wait for " + - "preloading to be finished): " + cc.getName(), - "Node will not wait for preload in SYNC mode: " + cc.getName()); + U.warn(log, "Ignoring SYNC rebalance mode with manual rebalance start (node will not wait for " + + "rebalancing to be finished): " + cc.getName(), + "Node will not wait for rebalance in SYNC mode: " + cc.getName()); } else { U.warn(log, - "Using SYNC preload mode with preload delay (node will wait until preloading is " + + "Using SYNC rebalance mode with rebalance delay (node will wait until rebalancing is " + "initiated for " + delay + "ms) for cache: " + cc.getName(), - "Node will wait until preloading is initiated for " + delay + "ms for cache: " + cc.getName()); + "Node will wait until rebalancing is initiated for " + delay + "ms for cache: " + cc.getName()); } } } @@ -556,7 +556,7 @@ public class GridCacheProcessor extends GridProcessorAdapter { "Deployment mode for cache is not CONTINUOUS or SHARED."); } - maxPreloadOrder = validatePreloadOrder(ctx.config().getCacheConfiguration()); + maxRebalanceOrder = validatePreloadOrder(ctx.config().getCacheConfiguration()); // Internal caches which should not be returned to user. IgfsConfiguration[] igfsCfgs = ctx.grid().configuration().getIgfsConfiguration(); @@ -967,23 +967,23 @@ public class GridCacheProcessor extends GridProcessorAdapter { int maxOrder = 0; for (CacheConfiguration cfg : cfgs) { - int preloadOrder = cfg.getPreloadOrder(); + int rebalanceOrder = cfg.getRebalanceOrder(); - if (preloadOrder > 0) { + if (rebalanceOrder > 0) { if (cfg.getCacheMode() == LOCAL) - throw new IgniteCheckedException("Preload order set for local cache (fix configuration and restart the " + + throw new IgniteCheckedException("Rebalance order set for local cache (fix configuration and restart the " + "node): " + cfg.getName()); - if (cfg.getPreloadMode() == CachePreloadMode.NONE) - throw new IgniteCheckedException("Only caches with SYNC or ASYNC preload mode can be set as preload " + + if (cfg.getRebalanceMode() == CacheRebalanceMode.NONE) + throw new IgniteCheckedException("Only caches with SYNC or ASYNC rebalance mode can be set as rebalance " + "dependency for other caches [cacheName=" + cfg.getName() + - ", preloadMode=" + cfg.getPreloadMode() + ", preloadOrder=" + cfg.getPreloadOrder() + ']'); + ", rebalanceMode=" + cfg.getRebalanceMode() + ", rebalanceOrder=" + cfg.getRebalanceOrder() + ']'); - maxOrder = Math.max(maxOrder, preloadOrder); + maxOrder = Math.max(maxOrder, rebalanceOrder); } - else if (preloadOrder < 0) - throw new IgniteCheckedException("Preload order cannot be negative for cache (fix configuration and restart " + - "the node) [cacheName=" + cfg.getName() + ", preloadOrder=" + preloadOrder + ']'); + else if (rebalanceOrder < 0) + throw new IgniteCheckedException("Rebalance order cannot be negative for cache (fix configuration and restart " + + "the node) [cacheName=" + cfg.getName() + ", rebalanceOrder=" + rebalanceOrder + ']'); } return maxOrder; @@ -1080,8 +1080,8 @@ public class GridCacheProcessor extends GridProcessorAdapter { CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "atomicityMode", "Cache atomicity mode", locAttr.atomicityMode(), rmtAttr.atomicityMode(), true); - CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "cachePreloadMode", - "Cache preload mode", locAttr.cachePreloadMode(), rmtAttr.cachePreloadMode(), true); + CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "cacheRebalanceMode", + "Cache rebalance mode", locAttr.cacheRebalanceMode(), rmtAttr.cacheRebalanceMode(), true); CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "cacheAffinity", "Cache affinity", locAttr.cacheAffinityClassName(), rmtAttr.cacheAffinityClassName(), true); @@ -1129,8 +1129,8 @@ public class GridCacheProcessor extends GridProcessorAdapter { CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "defaultTimeToLive", "Default time to live", locAttr.defaultTimeToLive(), rmtAttr.defaultTimeToLive(), false); - CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "preloadBatchSize", - "Preload batch size", locAttr.preloadBatchSize(), rmtAttr.preloadBatchSize(), false); + CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "rebalanceBatchSize", + "Rebalance batch size", locAttr.rebalanceBatchSize(), rmtAttr.rebalanceBatchSize(), false); CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "swapEnabled", "Swap enabled", locAttr.swapEnabled(), rmtAttr.swapEnabled(), false); @@ -1298,12 +1298,12 @@ public class GridCacheProcessor extends GridProcessorAdapter { for (Map.Entry<String, GridCacheAdapter<?, ?>> e : caches.entrySet()) { GridCacheAdapter cache = e.getValue(); - if (maxPreloadOrder > 0) { + if (maxRebalanceOrder > 0) { CacheConfiguration cfg = cache.configuration(); - int order = cfg.getPreloadOrder(); + int order = cfg.getRebalanceOrder(); - if (order > 0 && order != maxPreloadOrder && cfg.getCacheMode() != LOCAL) { + if (order > 0 && order != maxRebalanceOrder && cfg.getCacheMode() != LOCAL) { GridCompoundFuture<Object, Object> fut = (GridCompoundFuture<Object, Object>)preloadFuts .get(order); @@ -1331,9 +1331,9 @@ public class GridCacheProcessor extends GridProcessorAdapter { for (GridCacheAdapter<?, ?> cache : caches.values()) { CacheConfiguration cfg = cache.configuration(); - if (cfg.getPreloadMode() == SYNC) { + if (cfg.getRebalanceMode() == SYNC) { if (cfg.getCacheMode() == REPLICATED || - (cfg.getCacheMode() == PARTITIONED && cfg.getPreloadPartitionedDelay() >= 0)) + (cfg.getCacheMode() == PARTITIONED && cfg.getRebalancePartitionedDelay() >= 0)) cache.preloader().syncFuture().get(); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dc04e98c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java index 1e67907..004dda3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java @@ -49,7 +49,7 @@ import static org.apache.ignite.IgniteSystemProperties.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; import static org.apache.ignite.cache.CacheDistributionMode.*; import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.cache.CachePreloadMode.*; +import static org.apache.ignite.cache.CacheRebalanceMode.*; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; import static org.apache.ignite.internal.GridTopic.*; import static org.apache.ignite.internal.IgniteNodeAttributes.*; @@ -1512,7 +1512,7 @@ public class GridCacheUtils { cache.setQueryIndexEnabled(false); cache.setCacheStoreFactory(null); cache.setEagerTtl(true); - cache.setPreloadMode(SYNC); + cache.setRebalanceMode(SYNC); return cache; }