Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sboikov committed Apr 3, 2015
1 parent 6c3f101 commit cd7f1a9
Show file tree
Hide file tree
Showing 22 changed files with 431 additions and 100 deletions.
@@ -0,0 +1,77 @@
/*
* 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.cache;

import org.apache.ignite.internal.managers.communication.*;

import static org.apache.ignite.internal.managers.communication.GridIoPolicy.*;

/**
*
*/
public enum CacheType {
/**
* Regular cache created by user, visible via public API (e.g. {@link org.apache.ignite.Ignite#cache(String)}).
*/
USER(true, SYSTEM_POOL),

/**
* Internal cache, should not be visible via public API (caches used by IGFS, Hadoop, data structures).
*/
INTERNAL(false, SYSTEM_POOL),

/**
* Internal replicated cache, should use separate thread pool.
*/
UTILITY(false, UTILITY_CACHE_POOL),

/**
* Internal marshaller cache, should use separate thread pool.
*/
MARSHALLER(false, MARSH_CACHE_POOL);

/** */
private final boolean userCache;

/** */
private final GridIoPolicy ioPlc;

/**
* @param userCache {@code True} if cache created by user.
* @param ioPlc Cache IO policy.
*/
CacheType(boolean userCache, GridIoPolicy ioPlc) {
this.userCache = userCache;
this.ioPlc = ioPlc;
}

/**
* @return Cache IO policy.
*/
public GridIoPolicy ioPolicy() {
return ioPlc;
}

/**
* @return {@code True} if cache created by user.
*/
public boolean userCache() {
return userCache;
}
}

Expand Up @@ -42,6 +42,9 @@ public class DynamicCacheChangeRequest implements Serializable {
/** Cache start configuration. */ /** Cache start configuration. */
private CacheConfiguration startCfg; private CacheConfiguration startCfg;


/** Cache type. */
private CacheType cacheType;

/** Near node ID in case if near cache is being started. */ /** Near node ID in case if near cache is being started. */
private UUID initiatingNodeId; private UUID initiatingNodeId;


Expand Down Expand Up @@ -158,6 +161,20 @@ public void startCacheConfiguration(CacheConfiguration startCfg) {
this.startCfg = startCfg; this.startCfg = startCfg;
} }


/**
* @param cacheType Cache type.
*/
public void cacheType(CacheType cacheType) {
this.cacheType = cacheType;
}

/**
* @return Cache type.
*/
public CacheType cacheType() {
return cacheType;
}

/** /**
* @return Client start only. * @return Client start only.
*/ */
Expand Down
Expand Up @@ -47,17 +47,30 @@ public class DynamicCacheDescriptor {
/** Started flag. */ /** Started flag. */
private boolean started; private boolean started;


/** Cache type. */
private CacheType cacheType;

/** */ /** */
private volatile Map<UUID, CacheConfiguration> rmtCfgs; private volatile Map<UUID, CacheConfiguration> rmtCfgs;


/** /**
* @param cacheCfg Cache configuration. * @param cacheCfg Cache configuration.
* @param cacheType Cache type.
* @param deploymentId Deployment ID.
*/ */
public DynamicCacheDescriptor(CacheConfiguration cacheCfg, IgniteUuid deploymentId) { public DynamicCacheDescriptor(CacheConfiguration cacheCfg, CacheType cacheType, IgniteUuid deploymentId) {
this.cacheCfg = cacheCfg; this.cacheCfg = cacheCfg;
this.cacheType = cacheType;
this.deploymentId = deploymentId; this.deploymentId = deploymentId;
} }


/**
* @return Cache type.
*/
public CacheType cacheType() {
return cacheType;
}

/** /**
* @return Start ID. * @return Start ID.
*/ */
Expand Down
Expand Up @@ -2015,7 +2015,7 @@ public <K1, V1> IgniteInternalFuture<Map<K1, V1>> getAllAsync0(@Nullable final C
return new GridFinishedFuture<>(e); return new GridFinishedFuture<>(e);
} }


tx = ctx.tm().threadLocalTx(ctx.system() ? ctx : null); tx = ctx.tm().threadLocalTx(ctx.systemTx() ? ctx : null);
} }


if (tx == null || tx.implicit()) { if (tx == null || tx.implicit()) {
Expand Down Expand Up @@ -4368,7 +4368,7 @@ private int globalSize(boolean primaryOnly) throws IgniteCheckedException {
tx = ctx.tm().newTx( tx = ctx.tm().newTx(
true, true,
op.single(), op.single(),
ctx.system() ? ctx : null, ctx.systemTx() ? ctx : null,
OPTIMISTIC, OPTIMISTIC,
READ_COMMITTED, READ_COMMITTED,
tCfg.getDefaultTxTimeout(), tCfg.getDefaultTxTimeout(),
Expand Down Expand Up @@ -4439,7 +4439,7 @@ private <T> IgniteInternalFuture<T> asyncOp(final AsyncOp<T> op) {
tx = ctx.tm().newTx( tx = ctx.tm().newTx(
true, true,
op.single(), op.single(),
ctx.system() ? ctx : null, ctx.systemTx() ? ctx : null,
OPTIMISTIC, OPTIMISTIC,
READ_COMMITTED, READ_COMMITTED,
ctx.kernalContext().config().getTransactionConfiguration().getDefaultTxTimeout(), ctx.kernalContext().config().getTransactionConfiguration().getDefaultTxTimeout(),
Expand Down
Expand Up @@ -166,8 +166,8 @@ public class GridCacheContext<K, V> implements Externalizable {
/** Cache ID. */ /** Cache ID. */
private int cacheId; private int cacheId;


/** System cache flag. */ /** Cache type. */
private boolean sys; private CacheType cacheType;


/** IO policy. */ /** IO policy. */
private GridIoPolicy plc; private GridIoPolicy plc;
Expand Down Expand Up @@ -207,6 +207,8 @@ public GridCacheContext() {
* @param ctx Kernal context. * @param ctx Kernal context.
* @param sharedCtx Cache shared context. * @param sharedCtx Cache shared context.
* @param cacheCfg Cache configuration. * @param cacheCfg Cache configuration.
* @param cacheType Cache type.
* @param affNode {@code True} if local node is affinity node.
* @param evtMgr Cache event manager. * @param evtMgr Cache event manager.
* @param swapMgr Cache swap manager. * @param swapMgr Cache swap manager.
* @param storeMgr Store manager. * @param storeMgr Store manager.
Expand All @@ -218,13 +220,15 @@ public GridCacheContext() {
* @param ttlMgr TTL manager. * @param ttlMgr TTL manager.
* @param drMgr Data center replication manager. * @param drMgr Data center replication manager.
* @param jtaMgr JTA manager. * @param jtaMgr JTA manager.
* @param rslvrMgr Conflict resolution manager.
* @param pluginMgr Cache plugin manager. * @param pluginMgr Cache plugin manager.
*/ */
@SuppressWarnings({"unchecked"}) @SuppressWarnings({"unchecked"})
public GridCacheContext( public GridCacheContext(
GridKernalContext ctx, GridKernalContext ctx,
GridCacheSharedContext sharedCtx, GridCacheSharedContext sharedCtx,
CacheConfiguration cacheCfg, CacheConfiguration cacheCfg,
CacheType cacheType,
boolean affNode, boolean affNode,


/* /*
Expand Down Expand Up @@ -265,6 +269,7 @@ public GridCacheContext(
this.ctx = ctx; this.ctx = ctx;
this.sharedCtx = sharedCtx; this.sharedCtx = sharedCtx;
this.cacheCfg = cacheCfg; this.cacheCfg = cacheCfg;
this.cacheType = cacheType;
this.affNode = affNode; this.affNode = affNode;


/* /*
Expand Down Expand Up @@ -297,9 +302,7 @@ public GridCacheContext(


cacheId = CU.cacheId(cacheName); cacheId = CU.cacheId(cacheName);


sys = ctx.cache().systemCache(cacheName); plc = cacheType.ioPolicy();

plc = CU.isMarshallerCache(cacheName) ? MARSH_CACHE_POOL : sys ? UTILITY_CACHE_POOL : SYSTEM_POOL;


Factory<ExpiryPolicy> factory = cacheCfg.getExpiryPolicyFactory(); Factory<ExpiryPolicy> factory = cacheCfg.getExpiryPolicyFactory();


Expand Down Expand Up @@ -434,10 +437,17 @@ public int cacheId() {
} }


/** /**
* @return System cache flag. * @return {@code True} if should use system transactions which are isolated from user transactions.
*/
public boolean systemTx() {
return cacheType == CacheType.UTILITY;
}

/**
* @return {@code True} if cache created by user.
*/ */
public boolean system() { public boolean userCache() {
return sys; return cacheType.userCache();
} }


/** /**
Expand Down
Expand Up @@ -256,7 +256,7 @@ private void onUndeploy0(final ClassLoader ldr, final GridCacheContext<K, V> cac
cacheCtx.near().dht().context().swap().onUndeploy(ldr) : cacheCtx.near().dht().context().swap().onUndeploy(ldr) :
cacheCtx.swap().onUndeploy(ldr); cacheCtx.swap().onUndeploy(ldr);


if (!cacheCtx.system()) { if (cacheCtx.userCache()) {
U.quietAndWarn(log, ""); U.quietAndWarn(log, "");
U.quietAndWarn( U.quietAndWarn(
log, log,
Expand Down
Expand Up @@ -339,9 +339,7 @@ public void addUnloadEvent(int part) {
* @return {@code True} if event is recordable. * @return {@code True} if event is recordable.
*/ */
public boolean isRecordable(int type) { public boolean isRecordable(int type) {
return !cctx.system() && return cctx.userCache() && cctx.gridEvents().isRecordable(type);
!CU.isAtomicsCache(cctx.name()) &&
cctx.gridEvents().isRecordable(type);
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
Expand Down

0 comments on commit cd7f1a9

Please sign in to comment.