# IGNITE-598: Implemented.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/35d05e92 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/35d05e92 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/35d05e92 Branch: refs/heads/ignite-645 Commit: 35d05e9282903ee9b78bbbef30bd41c9d250bea4 Parents: 0dfb5c0 Author: vozerov-gridgain <voze...@gridgain.com> Authored: Wed Apr 1 11:16:25 2015 +0300 Committer: vozerov-gridgain <voze...@gridgain.com> Committed: Wed Apr 1 11:16:25 2015 +0300 ---------------------------------------------------------------------- .../configuration/CacheConfiguration.java | 23 ++++ .../ignite/internal/GridCachePluginContext.java | 72 +++++++++++++ .../ignite/internal/GridKernalContextImpl.java | 9 +- .../processors/cache/GridCacheContext.java | 17 ++- .../processors/cache/GridCacheProcessor.java | 44 ++++---- .../processors/cache/GridCacheUtils.java | 39 +++++++ .../processors/plugin/CachePluginManager.java | 107 +++++++++++++++++++ .../ignite/plugin/CachePluginConfiguration.java | 33 ++++++ .../ignite/plugin/CachePluginContext.java | 54 ++++++++++ .../ignite/plugin/CachePluginProvider.java | 83 ++++++++++++++ ...eJdbcStoreAbstractMultithreadedSelfTest.java | 11 +- .../cache/GridCacheMemoryModeSelfTest.java | 12 ++- .../loadtests/hashmap/GridCacheTestContext.java | 4 +- 13 files changed, 470 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/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 19e9c62..8d5ba6c 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 @@ -30,6 +30,7 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.*; import org.jetbrains.annotations.*; import javax.cache.*; @@ -326,6 +327,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { /** Copy on read flag. */ private boolean cpOnRead = DFLT_COPY_ON_READ; + /** Cache plugin configurations. */ + private CachePluginConfiguration[] pluginCfgs; + /** Empty constructor (all values are initialized to their defaults). */ public CacheConfiguration() { /* No-op. */ @@ -409,6 +413,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { writeBehindFlushSize = cc.getWriteBehindFlushSize(); writeBehindFlushThreadCnt = cc.getWriteBehindFlushThreadCount(); writeSync = cc.getWriteSynchronizationMode(); + pluginCfgs = cc.getPluginConfigurations(); } /** @@ -1575,6 +1580,24 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { this.sqlOnheapRowCacheSize = size; } + /** + * Gets array of cache plugin configurations. + * + * @return Cache plugin configurations. + */ + public CachePluginConfiguration[] getPluginConfigurations() { + return pluginCfgs != null ? pluginCfgs : new CachePluginConfiguration[0]; + } + + /** + * Sets cache plugin configurations. + * + * @param pluginCfgs Cache plugin configurations. + */ + public void setPluginConfigurations(CachePluginConfiguration... pluginCfgs) { + this.pluginCfgs = pluginCfgs; + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(CacheConfiguration.class, this); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/modules/core/src/main/java/org/apache/ignite/internal/GridCachePluginContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridCachePluginContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridCachePluginContext.java new file mode 100644 index 0000000..57df0b0 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridCachePluginContext.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal; + +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.plugin.*; + +/** + * TODO: Add class description. + */ +public class GridCachePluginContext<C extends CachePluginConfiguration> implements CachePluginContext<C> { + /** */ + private final GridKernalContext ctx; + + /** */ + private final CacheConfiguration igniteCacheCfg; + + /** */ + private final CachePluginConfiguration cachePluginCfg; + + /** + * @param ctx Kernal context. + * @param cachePluginCfg Cache plugin config. + * @param igniteCacheCfg Ignite config. + */ + public GridCachePluginContext(GridKernalContext ctx, CacheConfiguration igniteCacheCfg, + CachePluginConfiguration cachePluginCfg) { + this.ctx = ctx; + this.cachePluginCfg = cachePluginCfg; + this.igniteCacheCfg = igniteCacheCfg; + } + + @Override public IgniteConfiguration igniteConfiguration() { + return ctx.config(); + } + + /** {@inheritDoc} */ + @Override public C cacheConfiguration() { + return (C)cachePluginCfg; + } + + /** {@inheritDoc} */ + @Override public CacheConfiguration igniteCacheConfiguration() { + return igniteCacheCfg; + } + + /** {@inheritDoc} */ + @Override public Ignite grid() { + return ctx.grid(); + } + + /** {@inheritDoc} */ + @Override public IgniteLogger log(Class<?> cls) { + return ctx.log(cls); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java index 4abf5e7..845344b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java @@ -31,7 +31,6 @@ import org.apache.ignite.internal.managers.loadbalancer.*; import org.apache.ignite.internal.managers.swapspace.*; import org.apache.ignite.internal.processors.affinity.*; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.processors.cache.dr.*; import org.apache.ignite.internal.processors.cacheobject.*; import org.apache.ignite.internal.processors.clock.*; import org.apache.ignite.internal.processors.closure.*; @@ -56,8 +55,8 @@ import org.apache.ignite.internal.processors.service.*; import org.apache.ignite.internal.processors.session.*; import org.apache.ignite.internal.processors.task.*; import org.apache.ignite.internal.processors.timeout.*; -import org.apache.ignite.internal.util.spring.*; import org.apache.ignite.internal.util.*; +import org.apache.ignite.internal.util.spring.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; @@ -787,12 +786,8 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable if (res != null) return res; - if (cls.equals(GridCacheDrManager.class)) - return (T)new GridOsCacheDrManager(); - else if (cls.equals(IgniteCacheObjectProcessor.class)) + if (cls.equals(IgniteCacheObjectProcessor.class)) return (T)new IgniteCacheObjectProcessorImpl(this); - else if (cls.equals(CacheConflictResolutionManager.class)) - return (T)new CacheOsConflictResolutionManager<>(); throw new IgniteException("Unsupported component type: " + cls); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/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 feb6925..e7f3ad4 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 @@ -43,6 +43,7 @@ import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.processors.cacheobject.*; import org.apache.ignite.internal.processors.closure.*; import org.apache.ignite.internal.processors.offheap.*; +import org.apache.ignite.internal.processors.plugin.*; import org.apache.ignite.internal.processors.timeout.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.lang.*; @@ -137,6 +138,9 @@ public class GridCacheContext<K, V> implements Externalizable { /** Conflict resolver manager. */ private CacheConflictResolutionManager rslvrMgr; + /** Cache plugin manager. */ + private CachePluginManager pluginMgr; + /** Managers. */ private List<GridCacheManager<K, V>> mgrs = new LinkedList<>(); @@ -213,6 +217,7 @@ public class GridCacheContext<K, V> implements Externalizable { * @param ttlMgr TTL manager. * @param drMgr Data center replication manager. * @param jtaMgr JTA manager. + * @param pluginMgr Cache plugin manager. */ @SuppressWarnings({"unchecked"}) public GridCacheContext( @@ -237,7 +242,8 @@ public class GridCacheContext<K, V> implements Externalizable { GridCacheTtlManager ttlMgr, GridCacheDrManager drMgr, CacheJtaManagerAdapter jtaMgr, - CacheConflictResolutionManager<K, V> rslvrMgr + CacheConflictResolutionManager<K, V> rslvrMgr, + CachePluginManager pluginMgr ) { assert ctx != null; assert sharedCtx != null; @@ -253,6 +259,7 @@ public class GridCacheContext<K, V> implements Externalizable { assert dataStructuresMgr != null; assert ttlMgr != null; assert rslvrMgr != null; + assert pluginMgr != null; this.ctx = ctx; this.sharedCtx = sharedCtx; @@ -275,6 +282,7 @@ public class GridCacheContext<K, V> implements Externalizable { this.drMgr = add(drMgr); this.jtaMgr = add(jtaMgr); this.rslvrMgr = add(rslvrMgr); + this.pluginMgr = add(pluginMgr); log = ctx.log(getClass()); @@ -997,6 +1005,13 @@ public class GridCacheContext<K, V> implements Externalizable { } /** + * @return Cache plugin manager. + */ + public CachePluginManager plugin() { + return pluginMgr; + } + + /** * @param p Predicate. * @return {@code True} if given predicate is filter for {@code putIfAbsent} operation. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/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 0e96994..6716d2e 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 @@ -42,6 +42,7 @@ import org.apache.ignite.internal.processors.cache.query.*; import org.apache.ignite.internal.processors.cache.query.continuous.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; +import org.apache.ignite.internal.processors.plugin.*; import org.apache.ignite.internal.processors.query.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.future.*; @@ -65,10 +66,10 @@ import java.util.concurrent.*; import static org.apache.ignite.IgniteSystemProperties.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; -import static org.apache.ignite.configuration.CacheConfiguration.*; import static org.apache.ignite.cache.CacheMode.*; import static org.apache.ignite.cache.CacheRebalanceMode.*; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; +import static org.apache.ignite.configuration.CacheConfiguration.*; import static org.apache.ignite.configuration.DeploymentMode.*; import static org.apache.ignite.internal.IgniteComponentType.*; import static org.apache.ignite.internal.IgniteNodeAttributes.*; @@ -1015,8 +1016,12 @@ public class GridCacheProcessor extends GridProcessorAdapter { CacheContinuousQueryManager contQryMgr = new CacheContinuousQueryManager(); CacheDataStructuresManager dataStructuresMgr = new CacheDataStructuresManager(); GridCacheTtlManager ttlMgr = new GridCacheTtlManager(); - GridCacheDrManager drMgr = ctx.createComponent(GridCacheDrManager.class); - CacheConflictResolutionManager rslvrMgr = ctx.createComponent(CacheConflictResolutionManager.class); + CachePluginManager pluginMgr = new CachePluginManager(ctx, cfg); + + pluginMgr.validate(); + + CacheConflictResolutionManager rslvrMgr = pluginMgr.createComponent(CacheConflictResolutionManager.class); + GridCacheDrManager drMgr = pluginMgr.createComponent(GridCacheDrManager.class); GridCacheStoreManager storeMgr = new GridCacheStoreManager(ctx, sesHolders, cfgStore, cfg); @@ -1041,7 +1046,8 @@ public class GridCacheProcessor extends GridProcessorAdapter { ttlMgr, drMgr, jta, - rslvrMgr + rslvrMgr, + pluginMgr ); cacheCtx.cacheObjectContext(cacheObjCtx); @@ -1144,7 +1150,8 @@ public class GridCacheProcessor extends GridProcessorAdapter { swapMgr = new GridCacheSwapManager(true); evictMgr = new GridCacheEvictionManager(); evtMgr = new GridCacheEventManager(); - drMgr = ctx.createComponent(GridCacheDrManager.class); + drMgr = pluginMgr.createComponent(GridCacheDrManager.class); + pluginMgr = new CachePluginManager(ctx, cfg); cacheCtx = new GridCacheContext( ctx, @@ -1167,7 +1174,8 @@ public class GridCacheProcessor extends GridProcessorAdapter { ttlMgr, drMgr, jta, - rslvrMgr + rslvrMgr, + pluginMgr ); cacheCtx.cacheObjectContext(cacheObjCtx); @@ -2018,6 +2026,14 @@ public class GridCacheProcessor extends GridProcessorAdapter { true); } } + + // TODO 10006: implement remote configs validation. + // Check plugin configurations. +// for (CachePluginConfiguration locPluginCcfg : locCfg.getPluginConfigurations()) { +// CachePluginProvider provider = ...; +// +// provider.validateRemote(locCfg, locPluginCcfg, rmtCfg, rmtNode); +// } } /** @@ -2040,22 +2056,6 @@ public class GridCacheProcessor extends GridProcessorAdapter { } /** - * Checks if store check should be skipped for given nodes. - * - * @param cfg Cache configuration. - * @param rmtNode Remote node. - * @param locNode Local node. - * @return {@code True} if store check should be skipped. - */ - private boolean checkStoreConsistency(CacheConfiguration cfg, ClusterNode rmtNode, ClusterNode locNode) { - return - // In atomic mode skip check if either local or remote node is client. - cfg.getAtomicityMode() == ATOMIC && - (!ctx.discovery().cacheAffinityNode(rmtNode, cfg.getName()) || - !ctx.discovery().cacheAffinityNode(locNode, cfg.getName())); - } - - /** * Gets preload finish future for preload-ordered cache with given order. I.e. will get compound preload future * with maximum order less than {@code order}. * http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/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 d5e466b..8f48d3d 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 @@ -35,6 +35,7 @@ import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; import org.jsr166.*; @@ -1827,4 +1828,42 @@ public class GridCacheUtils { @Nullable public static <T> T value(@Nullable CacheObject cacheObj, GridCacheContext ctx, boolean cpy) { return cacheObj != null ? cacheObj.<T>value(ctx.cacheObjectContext(), cpy) : null; } + + /** + * @param cfg Cache configuration. + * @param cl Type of cache plugin configuration. + * @return Cache plugin configuration by type from cache configuration or <code>null</code>. + */ + public static <C extends CachePluginConfiguration> C cachePluginConfiguration( + CacheConfiguration cfg, Class<C> cl) { + if (cfg.getPluginConfigurations() != null) { + for (CachePluginConfiguration pluginCfg : cfg.getPluginConfigurations()) { + if (pluginCfg.getClass() == cl) + return (C)pluginCfg; + } + } + + return null; + } + + /** + * @param cfg Config. + * @param cls Class. + * @return Not <code>null</code> list. + */ + public static <T extends CachePluginConfiguration> List<T> cachePluginConfigurations(IgniteConfiguration cfg, + Class<T> cls) { + List<T> res = new ArrayList<>(); + + if (cfg.getCacheConfiguration() != null) { + for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) { + for (CachePluginConfiguration pluginCcfg : ccfg.getPluginConfigurations()) { + if (cls == pluginCcfg.getClass()) + res.add((T)pluginCcfg); + } + } + } + + return res; + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java new file mode 100644 index 0000000..993d4b1 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.plugin; + +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.processors.cache.dr.*; +import org.apache.ignite.plugin.*; + +import java.util.*; + +/** + * TODO: Add class description. + */ +public class CachePluginManager extends GridCacheManagerAdapter { + /** */ + private final List<CachePluginProvider> providers = new ArrayList<>(); + + /** + * @param ctx Context. + * @param cfg Cache config. + */ + public CachePluginManager(GridKernalContext ctx, CacheConfiguration cfg) { + if (cfg.getPluginConfigurations() != null) { + for (CachePluginConfiguration cachePluginCfg : cfg.getPluginConfigurations()) { + CachePluginContext pluginCtx = new GridCachePluginContext(ctx, cfg, cachePluginCfg); + + CachePluginProvider provider = cachePluginCfg.createProvider(pluginCtx); + + providers.add(provider); + } + } + } + + /** {@inheritDoc} */ + @Override protected void onKernalStart0() throws IgniteCheckedException { + for (CachePluginProvider provider : providers) + provider.onIgniteStart(); + } + + /** {@inheritDoc} */ + @Override protected void onKernalStop0(boolean cancel) { + for (ListIterator<CachePluginProvider> iter = providers.listIterator(); iter.hasPrevious();) + iter.previous().onIgniteStop(cancel); + } + + /** {@inheritDoc} */ + @Override protected void start0() throws IgniteCheckedException { + for (CachePluginProvider provider : providers) + provider.start(); + } + + /** {@inheritDoc} */ + @Override protected void stop0(boolean cancel) { + for (ListIterator<CachePluginProvider> iter = providers.listIterator(); iter.hasPrevious();) + iter.previous().stop(cancel); + } + + /** + * Creates optional component. + * + * @param cls Component class. + * @return Created component. + */ + public <T> T createComponent(Class<T> cls) { + for (CachePluginProvider provider : providers) { + T res = (T)provider.createComponent(cls); + + if (res != null) + return res; + } + + if (cls.equals(GridCacheDrManager.class)) + return (T)new GridOsCacheDrManager(); + else if (cls.equals(CacheConflictResolutionManager.class)) + return (T)new CacheOsConflictResolutionManager<>(); + + throw new IgniteException("Unsupported component type: " + cls); + } + + /** + * Validates cache plugin configurations. Throw exception if validation failed. + * + * @throws IgniteCheckedException If validation failed. + */ + public void validate() throws IgniteCheckedException { + for (CachePluginProvider provider : providers) + provider.validate(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginConfiguration.java b/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginConfiguration.java new file mode 100644 index 0000000..271a591 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginConfiguration.java @@ -0,0 +1,33 @@ +/* + * 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.plugin; + +import java.io.*; + +/** + * TODO: Add class description. + */ +public interface CachePluginConfiguration<K, V> extends Serializable { + /** + * Creates cache plugin provider. + * + * @return Cache plugin provider class. + * @param ctx + */ + public CachePluginProvider createProvider(CachePluginContext ctx); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginContext.java b/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginContext.java new file mode 100644 index 0000000..8f283dd --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginContext.java @@ -0,0 +1,54 @@ +/* + * 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.plugin; + +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; + +/** + * TODO: Add interface description. + */ +public interface CachePluginContext<C extends CachePluginConfiguration> { + /** + * @return Ignite configuration. + */ + public IgniteConfiguration igniteConfiguration(); + + /** + * @return Plugin cache configuration. + */ + public C cacheConfiguration(); + + /** + * @return Ignite cache configuration. + */ + public CacheConfiguration igniteCacheConfiguration(); + + /** + * @return Grid. + */ + public Ignite grid(); + + /** + * Gets logger for given class. + * + * @param cls Class to get logger for. + * @return Logger. + */ + public IgniteLogger log(Class<?> cls); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java b/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java new file mode 100644 index 0000000..264e2af --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.plugin; + +import org.apache.ignite.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.configuration.*; +import org.jetbrains.annotations.*; + +/** + * TODO: Add class description. + */ +public interface CachePluginProvider<C extends CachePluginConfiguration> { + /** + * Starts grid component. + * + * @throws IgniteCheckedException Throws in case of any errors. + */ + public void start() throws IgniteCheckedException; + + /** + * Stops grid component. + * + * @param cancel If {@code true}, then all ongoing tasks or jobs for relevant + * components need to be cancelled. + * @throws IgniteCheckedException Thrown in case of any errors. + */ + public void stop(boolean cancel); + + /** + * Callback that notifies that Ignite has successfully started, + * including all internal components. + * + * @throws IgniteCheckedException Thrown in case of any errors. + */ + public void onIgniteStart() throws IgniteCheckedException; + + /** + * Callback to notify that Ignite is about to stop. + * + * @param cancel Flag indicating whether jobs should be canceled. + */ + public void onIgniteStop(boolean cancel); + + /** + * @param cls Ignite component class. + * @return Ignite component or {@code null} if component is not supported. + */ + @Nullable public <T> T createComponent(Class<T> cls); + + /** + * Validates cache plugin configuration in process of cache creation. Throw exception if validation failed. + * + * @throws IgniteCheckedException If validation failed. + */ + public void validate() throws IgniteCheckedException; + + /** + * Checks that remote caches has configuration compatible with the local. + * + * @param locCfg Local configuration. + * @param locPluginCcfg Local plugin configuration. + * @param rmtCfg Remote configuration. + * @param node Node. + */ + public void validateRemote(CacheConfiguration locCfg, C locPluginCcfg, CacheConfiguration rmtCfg, ClusterNode node) + throws IgniteCheckedException; +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java index da797ed..eac7669 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java @@ -119,6 +119,13 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach c.setDiscoverySpi(disco); + c.setCacheConfiguration(cacheConfiguration()); + + return c; + } + + /** */ + protected CacheConfiguration cacheConfiguration() throws Exception { CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); @@ -164,9 +171,7 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach cc.setWriteThrough(true); cc.setLoadPreviousValue(true); - c.setCacheConfiguration(cc); - - return c; + return cc; } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java index 076e6bb..08e35ce 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java @@ -75,6 +75,13 @@ public class GridCacheMemoryModeSelfTest extends GridCommonAbstractTest { cfg.setSwapSpaceSpi(new FileSwapSpaceSpi()); + cfg.setCacheConfiguration(cacheConfiguration()); + cfg.setMarshaller(new OptimizedMarshaller(false)); + + return cfg; + } + + protected CacheConfiguration cacheConfiguration() { CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setWriteSynchronizationMode(FULL_SYNC); @@ -86,10 +93,7 @@ public class GridCacheMemoryModeSelfTest extends GridCommonAbstractTest { cacheCfg.setAtomicityMode(atomicity); cacheCfg.setOffHeapMaxMemory(offheapSize); - cfg.setCacheConfiguration(cacheCfg); - cfg.setMarshaller(new OptimizedMarshaller(false)); - - return cfg; + return cacheCfg; } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/35d05e92/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java index 90b6b1f..20a9caf 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java @@ -27,6 +27,7 @@ import org.apache.ignite.internal.processors.cache.query.*; import org.apache.ignite.internal.processors.cache.query.continuous.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; +import org.apache.ignite.internal.processors.plugin.*; import org.apache.ignite.testframework.junits.*; import java.util.*; @@ -70,7 +71,8 @@ public class GridCacheTestContext<K, V> extends GridCacheContext<K, V> { new GridCacheTtlManager(), new GridOsCacheDrManager(), new CacheNoopJtaManager(), - new CacheOsConflictResolutionManager<K, V>() + new CacheOsConflictResolutionManager<K, V>(), + new CachePluginManager(ctx, new CacheConfiguration()) ); } }