Search in sources :

Example 1 with DeploymentMode

use of org.apache.ignite.configuration.DeploymentMode in project ignite by apache.

the class GridCacheProcessor method validate.

/**
 * @param c Ignite configuration.
 * @param cc Configuration to validate.
 * @param cacheType Cache type.
 * @param cfgStore Cache store.
 * @throws IgniteCheckedException If failed.
 */
private void validate(IgniteConfiguration c, CacheConfiguration cc, CacheType cacheType, @Nullable CacheStore cfgStore) throws IgniteCheckedException {
    assertParameter(cc.getName() != null && !cc.getName().isEmpty(), "name is null or empty");
    if (cc.getCacheMode() == REPLICATED) {
        if (cc.getNearConfiguration() != null && ctx.discovery().cacheAffinityNode(ctx.discovery().localNode(), cc.getName())) {
            U.warn(log, "Near cache cannot be used with REPLICATED cache, " + "will be ignored [cacheName=" + U.maskName(cc.getName()) + ']');
            cc.setNearConfiguration(null);
        }
    }
    if (storesLocallyOnClient(c, cc))
        throw new IgniteCheckedException("DataRegion for client caches must be explicitly configured " + "on client node startup. Use DataStorageConfiguration to configure DataRegion.");
    if (cc.getCacheMode() == LOCAL && !cc.getAffinity().getClass().equals(LocalAffinityFunction.class))
        U.warn(log, "AffinityFunction configuration parameter will be ignored for local cache [cacheName=" + U.maskName(cc.getName()) + ']');
    if (cc.getAffinity().partitions() > CacheConfiguration.MAX_PARTITIONS_COUNT)
        throw new IgniteCheckedException("Cannot have more than " + CacheConfiguration.MAX_PARTITIONS_COUNT + " partitions [cacheName=" + cc.getName() + ", partitions=" + cc.getAffinity().partitions() + ']');
    if (cc.getRebalanceMode() != CacheRebalanceMode.NONE)
        assertParameter(cc.getRebalanceBatchSize() > 0, "rebalanceBatchSize > 0");
    if (cc.getCacheMode() == PARTITIONED || cc.getCacheMode() == REPLICATED) {
        if (cc.getAtomicityMode() == ATOMIC && cc.getWriteSynchronizationMode() == FULL_ASYNC)
            U.warn(log, "Cache write synchronization mode is set to FULL_ASYNC. All single-key 'put' and " + "'remove' operations will return 'null', all 'putx' and 'removex' operations will return" + " 'true' [cacheName=" + U.maskName(cc.getName()) + ']');
    }
    DeploymentMode depMode = c.getDeploymentMode();
    if (c.isPeerClassLoadingEnabled() && (depMode == PRIVATE || depMode == ISOLATED) && !CU.isSystemCache(cc.getName()) && !(c.getMarshaller() instanceof BinaryMarshaller))
        throw new IgniteCheckedException("Cache can be started in PRIVATE or ISOLATED deployment mode only when" + " BinaryMarshaller is used [depMode=" + ctx.config().getDeploymentMode() + ", marshaller=" + c.getMarshaller().getClass().getName() + ']');
    if (cc.getAffinity().partitions() > CacheConfiguration.MAX_PARTITIONS_COUNT)
        throw new IgniteCheckedException("Affinity function must return at most " + CacheConfiguration.MAX_PARTITIONS_COUNT + " partitions [actual=" + cc.getAffinity().partitions() + ", affFunction=" + cc.getAffinity() + ", cacheName=" + cc.getName() + ']');
    if (cc.isWriteBehindEnabled()) {
        if (cfgStore == null)
            throw new IgniteCheckedException("Cannot enable write-behind (writer or store is not provided) " + "for cache: " + U.maskName(cc.getName()));
        assertParameter(cc.getWriteBehindBatchSize() > 0, "writeBehindBatchSize > 0");
        assertParameter(cc.getWriteBehindFlushSize() >= 0, "writeBehindFlushSize >= 0");
        assertParameter(cc.getWriteBehindFlushFrequency() >= 0, "writeBehindFlushFrequency >= 0");
        assertParameter(cc.getWriteBehindFlushThreadCount() > 0, "writeBehindFlushThreadCount > 0");
        if (cc.getWriteBehindFlushSize() == 0 && cc.getWriteBehindFlushFrequency() == 0)
            throw new IgniteCheckedException("Cannot set both 'writeBehindFlushFrequency' and " + "'writeBehindFlushSize' parameters to 0 for cache: " + U.maskName(cc.getName()));
    }
    if (cc.isReadThrough() && cfgStore == null)
        throw new IgniteCheckedException("Cannot enable read-through (loader or store is not provided) " + "for cache: " + U.maskName(cc.getName()));
    if (cc.isWriteThrough() && cfgStore == null)
        throw new IgniteCheckedException("Cannot enable write-through (writer or store is not provided) " + "for cache: " + U.maskName(cc.getName()));
    long delay = cc.getRebalanceDelay();
    if (delay != 0) {
        if (cc.getCacheMode() != PARTITIONED)
            U.warn(log, "Rebalance delay is supported only for partitioned caches (will ignore): " + (cc.getName()), "Will ignore rebalance delay for cache: " + U.maskName(cc.getName()));
        else if (cc.getRebalanceMode() == SYNC) {
            if (delay < 0) {
                U.warn(log, "Ignoring SYNC rebalance mode with manual rebalance start (node will not wait for " + "rebalancing to be finished): " + U.maskName(cc.getName()), "Node will not wait for rebalance in SYNC mode: " + U.maskName(cc.getName()));
            } else {
                U.warn(log, "Using SYNC rebalance mode with rebalance delay (node will wait until rebalancing is " + "initiated for " + delay + "ms) for cache: " + U.maskName(cc.getName()), "Node will wait until rebalancing is initiated for " + delay + "ms for cache: " + U.maskName(cc.getName()));
            }
        }
    }
    ctx.igfsHelper().validateCacheConfiguration(cc);
    if (cc.getAtomicityMode() == ATOMIC)
        assertParameter(cc.getTransactionManagerLookupClassName() == null, "transaction manager can not be used with ATOMIC cache");
    if ((cc.getEvictionPolicyFactory() != null || cc.getEvictionPolicy() != null) && !cc.isOnheapCacheEnabled())
        throw new IgniteCheckedException("Onheap cache must be enabled if eviction policy is configured [cacheName=" + U.maskName(cc.getName()) + "]");
    if (cacheType != CacheType.DATA_STRUCTURES && DataStructuresProcessor.isDataStructureCache(cc.getName()))
        throw new IgniteCheckedException("Using cache names reserved for datastructures is not allowed for " + "other cache types [cacheName=" + cc.getName() + ", cacheType=" + cacheType + "]");
    if (cacheType != CacheType.DATA_STRUCTURES && DataStructuresProcessor.isReservedGroup(cc.getGroupName()))
        throw new IgniteCheckedException("Using cache group names reserved for datastructures is not allowed for " + "other cache types [cacheName=" + cc.getName() + ", groupName=" + cc.getGroupName() + ", cacheType=" + cacheType + "]");
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) DeploymentMode(org.apache.ignite.configuration.DeploymentMode)

Example 2 with DeploymentMode

use of org.apache.ignite.configuration.DeploymentMode in project ignite by apache.

the class IgniteServiceProcessor method validate.

/**
 * Validates service configuration.
 *
 * @param c Service configuration.
 * @throws IgniteException If validation failed.
 */
private void validate(ServiceConfiguration c) throws IgniteException {
    IgniteConfiguration cfg = ctx.config();
    DeploymentMode depMode = cfg.getDeploymentMode();
    if (cfg.isPeerClassLoadingEnabled() && (depMode == PRIVATE || depMode == ISOLATED))
        throw new IgniteException("Cannot deploy services in PRIVATE or ISOLATED deployment mode: " + depMode);
    ensure(c.getName() != null, "getName() != null", null);
    ensure(c.getTotalCount() >= 0, "getTotalCount() >= 0", c.getTotalCount());
    ensure(c.getMaxPerNodeCount() >= 0, "getMaxPerNodeCount() >= 0", c.getMaxPerNodeCount());
    ensure(c.getService() != null, "getService() != null", c.getService());
    ensure(c.getTotalCount() > 0 || c.getMaxPerNodeCount() > 0, "c.getTotalCount() > 0 || c.getMaxPerNodeCount() > 0", null);
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteException(org.apache.ignite.IgniteException) DeploymentMode(org.apache.ignite.configuration.DeploymentMode)

Example 3 with DeploymentMode

use of org.apache.ignite.configuration.DeploymentMode in project ignite by apache.

the class IgniteServiceProcessor method start.

/**
 * {@inheritDoc}
 */
@Override
public void start() throws IgniteCheckedException {
    IgniteConfiguration cfg = ctx.config();
    DeploymentMode depMode = cfg.getDeploymentMode();
    if (cfg.isPeerClassLoadingEnabled() && (depMode == PRIVATE || depMode == ISOLATED) && !F.isEmpty(cfg.getServiceConfiguration()))
        throw new IgniteCheckedException("Cannot deploy services in PRIVATE or ISOLATED deployment mode: " + depMode);
    ctx.discovery().setCustomEventListener(ServiceChangeBatchRequest.class, new CustomEventListener<ServiceChangeBatchRequest>() {

        @Override
        public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, ServiceChangeBatchRequest msg) {
            processServicesChangeRequest(snd, msg);
        }
    });
    ctx.discovery().setCustomEventListener(ChangeGlobalStateMessage.class, new CustomEventListener<ChangeGlobalStateMessage>() {

        @Override
        public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, ChangeGlobalStateMessage msg) {
            processChangeGlobalStateRequest(msg);
        }
    });
    ctx.discovery().setCustomEventListener(DynamicCacheChangeBatch.class, new CustomEventListener<DynamicCacheChangeBatch>() {

        @Override
        public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, DynamicCacheChangeBatch msg) {
            processDynamicCacheChangeRequest(msg);
        }
    });
    ctx.discovery().setCustomEventListener(ServiceClusterDeploymentResultBatch.class, new CustomEventListener<ServiceClusterDeploymentResultBatch>() {

        @Override
        public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, ServiceClusterDeploymentResultBatch msg) {
            processServicesFullDeployments(msg);
        }
    });
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) ChangeGlobalStateMessage(org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) DynamicCacheChangeBatch(org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch) DeploymentMode(org.apache.ignite.configuration.DeploymentMode)

Example 4 with DeploymentMode

use of org.apache.ignite.configuration.DeploymentMode in project ignite by apache.

the class ValidationOnNodeJoinUtils method checkConsistency.

/**
 * @param ctx Context.
 * @param log Logger.
 * @throws IgniteCheckedException if check failed.
 */
static void checkConsistency(GridKernalContext ctx, IgniteLogger log) throws IgniteCheckedException {
    Collection<ClusterNode> rmtNodes = ctx.discovery().remoteNodes();
    boolean changeablePoolSize = IgniteFeatures.allNodesSupports(rmtNodes, IgniteFeatures.DIFFERENT_REBALANCE_POOL_SIZE);
    for (ClusterNode n : rmtNodes) {
        if (Boolean.TRUE.equals(n.attribute(ATTR_CONSISTENCY_CHECK_SKIPPED)))
            continue;
        if (!changeablePoolSize)
            checkRebalanceConfiguration(n, ctx);
        checkTransactionConfiguration(n, ctx, log);
        checkMemoryConfiguration(n, ctx);
        DeploymentMode locDepMode = ctx.config().getDeploymentMode();
        DeploymentMode rmtDepMode = n.attribute(IgniteNodeAttributes.ATTR_DEPLOYMENT_MODE);
        CU.checkAttributeMismatch(log, null, n.id(), "deploymentMode", "Deployment mode", locDepMode, rmtDepMode, true);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) DetachedClusterNode(org.apache.ignite.internal.cluster.DetachedClusterNode) DeploymentMode(org.apache.ignite.configuration.DeploymentMode)

Example 5 with DeploymentMode

use of org.apache.ignite.configuration.DeploymentMode in project ignite by apache.

the class GridServiceProcessor method start.

/** {@inheritDoc} */
@Override
public void start(boolean activeOnStart) throws IgniteCheckedException {
    ctx.addNodeAttribute(ATTR_SERVICES_COMPATIBILITY_MODE, srvcCompatibilitySysProp);
    if (ctx.isDaemon() || !activeOnStart)
        return;
    IgniteConfiguration cfg = ctx.config();
    DeploymentMode depMode = cfg.getDeploymentMode();
    if (cfg.isPeerClassLoadingEnabled() && (depMode == PRIVATE || depMode == ISOLATED) && !F.isEmpty(cfg.getServiceConfiguration()))
        throw new IgniteCheckedException("Cannot deploy services in PRIVATE or ISOLATED deployment mode: " + depMode);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) DeploymentMode(org.apache.ignite.configuration.DeploymentMode)

Aggregations

DeploymentMode (org.apache.ignite.configuration.DeploymentMode)11 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 ClusterNode (org.apache.ignite.cluster.ClusterNode)5 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)5 IgniteException (org.apache.ignite.IgniteException)3 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)3 DetachedClusterNode (org.apache.ignite.internal.cluster.DetachedClusterNode)3 HashMap (java.util.HashMap)2 IdentityHashMap (java.util.IdentityHashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 EternalExpiryPolicy (javax.cache.expiry.EternalExpiryPolicy)2 ExpiryPolicy (javax.cache.expiry.ExpiryPolicy)2 QueryEntity (org.apache.ignite.cache.QueryEntity)2 DataRegion (org.apache.ignite.internal.processors.cache.persistence.DataRegion)2 IgniteTransactionsImpl (org.apache.ignite.internal.processors.cache.transactions.IgniteTransactionsImpl)2 String.format (java.lang.String.format)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1