Search in sources :

Example 1 with PlatformCachePluginConfiguration

use of org.apache.ignite.internal.processors.platform.plugin.cache.PlatformCachePluginConfiguration in project ignite by apache.

the class PlatformConfigurationUtils method writeCacheConfiguration.

/**
 * Writes cache configuration.
 *
 * @param writer Writer.
 * @param ccfg Configuration.
 */
public static void writeCacheConfiguration(BinaryRawWriter writer, CacheConfiguration ccfg) {
    assert writer != null;
    assert ccfg != null;
    writeEnumInt(writer, ccfg.getAtomicityMode(), CacheConfiguration.DFLT_CACHE_ATOMICITY_MODE);
    writer.writeInt(ccfg.getBackups());
    writeEnumInt(writer, ccfg.getCacheMode(), CacheConfiguration.DFLT_CACHE_MODE);
    writer.writeBoolean(ccfg.isCopyOnRead());
    writer.writeBoolean(ccfg.isEagerTtl());
    writer.writeBoolean(ccfg.isInvalidate());
    writer.writeBoolean(ccfg.isStoreKeepBinary());
    writer.writeBoolean(ccfg.isLoadPreviousValue());
    writer.writeLong(ccfg.getDefaultLockTimeout());
    // noinspection deprecation
    writer.writeLong(ccfg.getLongQueryWarningTimeout());
    writer.writeInt(ccfg.getMaxConcurrentAsyncOperations());
    writer.writeString(ccfg.getName());
    writer.writeBoolean(ccfg.isReadFromBackup());
    writer.writeInt(ccfg.getRebalanceBatchSize());
    writer.writeLong(ccfg.getRebalanceDelay());
    writeEnumInt(writer, ccfg.getRebalanceMode(), CacheConfiguration.DFLT_REBALANCE_MODE);
    writer.writeLong(ccfg.getRebalanceThrottle());
    writer.writeLong(ccfg.getRebalanceTimeout());
    writer.writeBoolean(ccfg.isSqlEscapeAll());
    writer.writeInt(ccfg.getWriteBehindBatchSize());
    writer.writeBoolean(ccfg.isWriteBehindEnabled());
    writer.writeLong(ccfg.getWriteBehindFlushFrequency());
    writer.writeInt(ccfg.getWriteBehindFlushSize());
    writer.writeInt(ccfg.getWriteBehindFlushThreadCount());
    writer.writeBoolean(ccfg.getWriteBehindCoalescing());
    writeEnumInt(writer, ccfg.getWriteSynchronizationMode());
    writer.writeBoolean(ccfg.isReadThrough());
    writer.writeBoolean(ccfg.isWriteThrough());
    writer.writeBoolean(ccfg.isStatisticsEnabled());
    // noinspection deprecation
    writer.writeString(ccfg.getMemoryPolicyName());
    writer.writeInt(ccfg.getPartitionLossPolicy().ordinal());
    writer.writeString(ccfg.getGroupName());
    if (ccfg.getCacheStoreFactory() instanceof PlatformDotNetCacheStoreFactoryNative)
        writer.writeObject(((PlatformDotNetCacheStoreFactoryNative) ccfg.getCacheStoreFactory()).getNativeFactory());
    else
        writer.writeObject(null);
    writer.writeInt(ccfg.getSqlIndexMaxInlineSize());
    writer.writeBoolean(ccfg.isOnheapCacheEnabled());
    writer.writeInt(ccfg.getStoreConcurrentLoadAllThreshold());
    writer.writeInt(ccfg.getRebalanceOrder());
    writer.writeLong(ccfg.getRebalanceBatchesPrefetchCount());
    writer.writeInt(ccfg.getMaxQueryIteratorsCount());
    writer.writeInt(ccfg.getQueryDetailMetricsSize());
    writer.writeInt(ccfg.getQueryParallelism());
    writer.writeString(ccfg.getSqlSchema());
    writer.writeBoolean(ccfg.isEncryptionEnabled());
    Collection<QueryEntity> qryEntities = ccfg.getQueryEntities();
    if (qryEntities != null) {
        writer.writeInt(qryEntities.size());
        for (QueryEntity e : qryEntities) writeQueryEntity(writer, e);
    } else
        writer.writeInt(0);
    NearCacheConfiguration nearCfg = ccfg.getNearConfiguration();
    if (nearCfg != null) {
        writer.writeBoolean(true);
        writeNearConfiguration(writer, nearCfg);
    } else
        writer.writeBoolean(false);
    writeEvictionPolicy(writer, ccfg.getEvictionPolicy());
    writeAffinityFunction(writer, ccfg.getAffinity());
    writeExpiryPolicyFactory(writer, ccfg.getExpiryPolicyFactory());
    writeAttributeNodeFilter(writer, ccfg.getNodeFilter());
    CacheKeyConfiguration[] keys = ccfg.getKeyConfiguration();
    if (keys != null) {
        writer.writeInt(keys.length);
        for (CacheKeyConfiguration key : keys) {
            writer.writeString(key.getTypeName());
            writer.writeString(key.getAffinityKeyFieldName());
        }
    } else {
        writer.writeInt(0);
    }
    PlatformCacheConfiguration platCfg = ccfg.getPlatformCacheConfiguration();
    if (platCfg != null) {
        writer.writeBoolean(true);
        writer.writeString(platCfg.getKeyTypeName());
        writer.writeString(platCfg.getValueTypeName());
        writer.writeBoolean(platCfg.isKeepBinary());
    } else {
        writer.writeBoolean(false);
    }
    CachePluginConfiguration[] plugins = ccfg.getPluginConfigurations();
    if (plugins != null) {
        int cnt = 0;
        for (CachePluginConfiguration cfg : plugins) {
            if (cfg instanceof PlatformCachePluginConfiguration)
                cnt++;
        }
        writer.writeInt(cnt);
        for (CachePluginConfiguration cfg : plugins) {
            if (cfg instanceof PlatformCachePluginConfiguration) {
                // Pure platform plugin.
                writer.writeBoolean(false);
                writer.writeObject(((PlatformCachePluginConfiguration) cfg).nativeCfg());
            }
        }
    }
}
Also used : PlatformDotNetCacheStoreFactoryNative(org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactoryNative) CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration) PlatformCachePluginConfiguration(org.apache.ignite.internal.processors.platform.plugin.cache.PlatformCachePluginConfiguration) CachePluginConfiguration(org.apache.ignite.plugin.CachePluginConfiguration) PlatformCachePluginConfiguration(org.apache.ignite.internal.processors.platform.plugin.cache.PlatformCachePluginConfiguration) PlatformCacheConfiguration(org.apache.ignite.configuration.PlatformCacheConfiguration) QueryEntity(org.apache.ignite.cache.QueryEntity) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 2 with PlatformCachePluginConfiguration

use of org.apache.ignite.internal.processors.platform.plugin.cache.PlatformCachePluginConfiguration in project ignite by apache.

the class PlatformConfigurationUtils method readCacheConfiguration.

/**
 * Reads cache configuration from a stream.
 *
 * @param in Stream.
 * @return Cache configuration.
 */
public static CacheConfiguration readCacheConfiguration(BinaryRawReaderEx in) {
    assert in != null;
    CacheConfiguration ccfg = new CacheConfiguration();
    ccfg.setAtomicityMode(CacheAtomicityMode.fromOrdinal(in.readInt()));
    ccfg.setBackups(in.readInt());
    ccfg.setCacheMode(CacheMode.fromOrdinal(in.readInt()));
    ccfg.setCopyOnRead(in.readBoolean());
    ccfg.setEagerTtl(in.readBoolean());
    ccfg.setInvalidate(in.readBoolean());
    ccfg.setStoreKeepBinary(in.readBoolean());
    ccfg.setLoadPreviousValue(in.readBoolean());
    ccfg.setDefaultLockTimeout(in.readLong());
    // noinspection deprecation
    ccfg.setLongQueryWarningTimeout(in.readLong());
    ccfg.setMaxConcurrentAsyncOperations(in.readInt());
    ccfg.setName(in.readString());
    ccfg.setReadFromBackup(in.readBoolean());
    ccfg.setRebalanceBatchSize(in.readInt());
    ccfg.setRebalanceDelay(in.readLong());
    ccfg.setRebalanceMode(CacheRebalanceMode.fromOrdinal(in.readInt()));
    ccfg.setRebalanceThrottle(in.readLong());
    ccfg.setRebalanceTimeout(in.readLong());
    ccfg.setSqlEscapeAll(in.readBoolean());
    ccfg.setWriteBehindBatchSize(in.readInt());
    ccfg.setWriteBehindEnabled(in.readBoolean());
    ccfg.setWriteBehindFlushFrequency(in.readLong());
    ccfg.setWriteBehindFlushSize(in.readInt());
    ccfg.setWriteBehindFlushThreadCount(in.readInt());
    ccfg.setWriteBehindCoalescing(in.readBoolean());
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.fromOrdinal(in.readInt()));
    ccfg.setReadThrough(in.readBoolean());
    ccfg.setWriteThrough(in.readBoolean());
    ccfg.setStatisticsEnabled(in.readBoolean());
    String dataRegionName = in.readString();
    if (dataRegionName != null)
        // noinspection deprecation
        ccfg.setMemoryPolicyName(dataRegionName);
    ccfg.setPartitionLossPolicy(PartitionLossPolicy.fromOrdinal((byte) in.readInt()));
    ccfg.setGroupName(in.readString());
    Object storeFactory = in.readObjectDetached();
    if (storeFactory != null)
        ccfg.setCacheStoreFactory(new PlatformDotNetCacheStoreFactoryNative(storeFactory));
    ccfg.setSqlIndexMaxInlineSize(in.readInt());
    ccfg.setOnheapCacheEnabled(in.readBoolean());
    ccfg.setStoreConcurrentLoadAllThreshold(in.readInt());
    ccfg.setRebalanceOrder(in.readInt());
    ccfg.setRebalanceBatchesPrefetchCount(in.readLong());
    ccfg.setMaxQueryIteratorsCount(in.readInt());
    ccfg.setQueryDetailMetricsSize(in.readInt());
    ccfg.setQueryParallelism(in.readInt());
    ccfg.setSqlSchema(in.readString());
    ccfg.setEncryptionEnabled(in.readBoolean());
    int qryEntCnt = in.readInt();
    if (qryEntCnt > 0) {
        Collection<QueryEntity> entities = new ArrayList<>(qryEntCnt);
        for (int i = 0; i < qryEntCnt; i++) entities.add(readQueryEntity(in));
        ccfg.setQueryEntities(entities);
    }
    if (in.readBoolean())
        ccfg.setNearConfiguration(readNearConfiguration(in));
    ccfg.setEvictionPolicy(readEvictionPolicy(in));
    if (ccfg.getEvictionPolicy() != null)
        ccfg.setOnheapCacheEnabled(true);
    ccfg.setAffinity(readAffinityFunction(in));
    ccfg.setExpiryPolicyFactory(readExpiryPolicyFactory(in));
    ccfg.setNodeFilter(readAttributeNodeFilter(in));
    int keyCnt = in.readInt();
    if (keyCnt > 0) {
        CacheKeyConfiguration[] keys = new CacheKeyConfiguration[keyCnt];
        for (int i = 0; i < keyCnt; i++) keys[i] = new CacheKeyConfiguration(in.readString(), in.readString());
        ccfg.setKeyConfiguration(keys);
    }
    if (in.readBoolean())
        ccfg.setPlatformCacheConfiguration(readPlatformCacheConfiguration(in));
    int pluginCnt = in.readInt();
    if (pluginCnt > 0) {
        ArrayList<CachePluginConfiguration> plugins = new ArrayList<>();
        for (int i = 0; i < pluginCnt; i++) {
            if (in.readBoolean()) {
                // Java cache plugin.
                readCachePluginConfiguration(ccfg, in);
            } else {
                // Platform cache plugin.
                plugins.add(new PlatformCachePluginConfiguration(in.readObjectDetached()));
            }
        }
        if (ccfg.getPluginConfigurations() != null)
            Collections.addAll(plugins, ccfg.getPluginConfigurations());
        ccfg.setPluginConfigurations(plugins.toArray(new CachePluginConfiguration[plugins.size()]));
    }
    return ccfg;
}
Also used : CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration) PlatformCachePluginConfiguration(org.apache.ignite.internal.processors.platform.plugin.cache.PlatformCachePluginConfiguration) CachePluginConfiguration(org.apache.ignite.plugin.CachePluginConfiguration) PlatformCachePluginConfiguration(org.apache.ignite.internal.processors.platform.plugin.cache.PlatformCachePluginConfiguration) ArrayList(java.util.ArrayList) QueryEntity(org.apache.ignite.cache.QueryEntity) PlatformDotNetCacheStoreFactoryNative(org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactoryNative) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) PlatformCacheConfiguration(org.apache.ignite.configuration.PlatformCacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Aggregations

CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)2 QueryEntity (org.apache.ignite.cache.QueryEntity)2 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)2 PlatformCacheConfiguration (org.apache.ignite.configuration.PlatformCacheConfiguration)2 PlatformCachePluginConfiguration (org.apache.ignite.internal.processors.platform.plugin.cache.PlatformCachePluginConfiguration)2 PlatformDotNetCacheStoreFactoryNative (org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactoryNative)2 CachePluginConfiguration (org.apache.ignite.plugin.CachePluginConfiguration)2 ArrayList (java.util.ArrayList)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1