use of org.apache.ignite.plugin.CachePluginContext in project ignite by apache.
the class ClusterCachesInfo method onKernalStart.
/**
* @param checkConsistency {@code True} if need check cache configurations consistency.
* @throws IgniteCheckedException If failed.
*/
public void onKernalStart(boolean checkConsistency) throws IgniteCheckedException {
if (gridData != null && gridData.conflictErr != null)
throw new IgniteCheckedException(gridData.conflictErr);
if (gridData != null && gridData.joinDiscoData != null) {
CacheJoinNodeDiscoveryData joinDiscoData = gridData.joinDiscoData;
for (CacheJoinNodeDiscoveryData.CacheInfo locCacheInfo : joinDiscoData.caches().values()) {
CacheConfiguration locCfg = locCacheInfo.cacheData().config();
CacheData cacheData = gridData.gridData.caches().get(locCfg.getName());
if (cacheData != null) {
if (!F.eq(cacheData.sql(), locCacheInfo.sql())) {
throw new IgniteCheckedException("Cache configuration mismatch (local cache was created " + "via " + (locCacheInfo.sql() ? "CREATE TABLE" : "Ignite API") + ", while remote cache " + "was created via " + (cacheData.sql() ? "CREATE TABLE" : "Ignite API") + "): " + locCacheInfo.cacheData().config().getName());
}
if (checkConsistency) {
checkCache(locCacheInfo, cacheData, cacheData.receivedFrom());
ClusterNode rmt = ctx.discovery().node(cacheData.receivedFrom());
if (rmt == null) {
for (ClusterNode node : ctx.discovery().localJoin().discoCache().serverNodes()) {
if (!node.isLocal() && ctx.discovery().cacheAffinityNode(node, locCfg.getName())) {
rmt = node;
break;
}
}
}
if (rmt != null) {
for (PluginProvider p : ctx.plugins().allProviders()) {
CachePluginContext pluginCtx = new GridCachePluginContext(ctx, locCfg);
CachePluginProvider provider = p.createCacheProvider(pluginCtx);
if (provider != null)
provider.validateRemote(locCfg, cacheData.cacheConfiguration(), rmt);
}
}
}
}
if (checkConsistency)
validateStartCacheConfiguration(locCfg);
}
}
gridData = null;
}
use of org.apache.ignite.plugin.CachePluginContext in project ignite by apache.
the class CdcCacheVersionTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setDataStorageConfiguration(new DataStorageConfiguration().setCdcEnabled(true).setWalForceArchiveTimeout(WAL_ARCHIVE_TIMEOUT).setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));
cfg.setPluginProviders(new AbstractTestPluginProvider() {
@Override
public String name() {
return "ConflictResolverProvider";
}
@Override
public CachePluginProvider createCacheProvider(CachePluginContext ctx) {
if (!ctx.igniteCacheConfiguration().getName().equals(DEFAULT_CACHE_NAME))
return null;
return new AbstractCachePluginProvider() {
@Override
@Nullable
public Object createComponent(Class cls) {
if (cls != CacheConflictResolutionManager.class || conflictResolutionMgrSupplier == null)
return null;
return new TestCacheConflictResolutionManager<>();
}
};
}
@Override
@Nullable
public <T> T createComponent(PluginContext ctx, Class<T> cls) {
if (IgniteWriteAheadLogManager.class.equals(cls))
return (T) walProvider.apply(((IgniteEx) ctx.grid()).context());
return null;
}
});
return cfg;
}
use of org.apache.ignite.plugin.CachePluginContext in project ignite by apache.
the class CachePluginManager method validateRemotes.
/**
* Checks that remote caches has configuration compatible with the local.
*
* @param rmtCfg Remote cache configuration.
* @param rmtNode Remote rmtNode.
* @throws IgniteCheckedException If failed.
*/
public void validateRemotes(CacheConfiguration rmtCfg, ClusterNode rmtNode) throws IgniteCheckedException {
for (Map.Entry<CachePluginContext, CachePluginProvider> entry : providersMap.entrySet()) {
CachePluginContext cctx = entry.getKey();
CachePluginProvider provider = entry.getValue();
provider.validateRemote(cctx.igniteCacheConfiguration(), rmtCfg, rmtNode);
}
}
Aggregations