Search in sources :

Example 6 with CacheKeyConfiguration

use of org.apache.ignite.cache.CacheKeyConfiguration 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 7 with CacheKeyConfiguration

use of org.apache.ignite.cache.CacheKeyConfiguration 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)

Example 8 with CacheKeyConfiguration

use of org.apache.ignite.cache.CacheKeyConfiguration in project ignite by apache.

the class Comparers method equalKeyConfiguration.

/**
 * Check whether cache key configurations are equal..
 *
 * @param cfgs1 Config 1.
 * @param cfgs2 Config 2.
 * @return {@code True} if equal.
 */
public static boolean equalKeyConfiguration(CacheKeyConfiguration[] cfgs1, CacheKeyConfiguration[] cfgs2) {
    if (cfgs1 == null && cfgs2 == null)
        return true;
    if (cfgs1 == null || cfgs2 == null)
        return false;
    if (cfgs1.length != cfgs2.length)
        return false;
    for (int i = 0; i < cfgs1.length; i++) {
        CacheKeyConfiguration cfg1 = cfgs1[i];
        CacheKeyConfiguration cfg2 = cfgs2[i];
        if (!F.eq(cfg1.getTypeName(), cfg2.getTypeName()) || !F.eq(cfg1.getAffinityKeyFieldName(), cfg2.getAffinityKeyFieldName()))
            return false;
    }
    return true;
}
Also used : CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration)

Example 9 with CacheKeyConfiguration

use of org.apache.ignite.cache.CacheKeyConfiguration in project ignite by apache.

the class FunctionalTest method testCacheConfiguration.

/**
 * Tested API:
 * <ul>
 * <li>{@link ClientCache#getName()}</li>
 * <li>{@link ClientCache#getConfiguration()}</li>
 * </ul>
 */
@Test
public void testCacheConfiguration() throws Exception {
    final String dataRegionName = "functional-test-data-region";
    IgniteConfiguration cfg = Config.getServerConfiguration().setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setName(dataRegionName)));
    try (Ignite ignored = Ignition.start(cfg);
        IgniteClient client = Ignition.startClient(getClientConfiguration())) {
        final String CACHE_NAME = "testCacheConfiguration";
        ClientCacheConfiguration cacheCfgTemplate = new ClientCacheConfiguration().setName(CACHE_NAME).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setBackups(3).setCacheMode(CacheMode.PARTITIONED).setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC).setEagerTtl(false).setGroupName("FunctionalTest").setDefaultLockTimeout(12345).setPartitionLossPolicy(PartitionLossPolicy.READ_WRITE_SAFE).setReadFromBackup(true).setRebalanceBatchSize(67890).setRebalanceBatchesPrefetchCount(102938).setRebalanceDelay(54321).setRebalanceMode(CacheRebalanceMode.SYNC).setRebalanceOrder(2).setRebalanceThrottle(564738).setRebalanceTimeout(142536).setKeyConfiguration(new CacheKeyConfiguration("Employee", "orgId")).setQueryEntities(new QueryEntity(int.class.getName(), "Employee").setTableName("EMPLOYEE").setFields(Stream.of(new SimpleEntry<>("id", Integer.class.getName()), new SimpleEntry<>("orgId", Integer.class.getName())).collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue, (a, b) -> a, LinkedHashMap::new))).setKeyFields(Collections.emptySet()).setKeyFieldName("id").setNotNullFields(Collections.singleton("id")).setDefaultFieldValues(Collections.singletonMap("id", 0)).setIndexes(Collections.singletonList(new QueryIndex("id", true, "IDX_EMPLOYEE_ID"))).setAliases(Stream.of("id", "orgId").collect(Collectors.toMap(f -> f, String::toUpperCase)))).setExpiryPolicy(new PlatformExpiryPolicy(10, 20, 30)).setCopyOnRead(!CacheConfiguration.DFLT_COPY_ON_READ).setDataRegionName(dataRegionName).setMaxConcurrentAsyncOperations(4).setMaxQueryIteratorsCount(4).setOnheapCacheEnabled(true).setQueryDetailMetricsSize(1024).setQueryParallelism(4).setSqlEscapeAll(true).setSqlIndexMaxInlineSize(1024).setSqlSchema("functional-test-schema").setStatisticsEnabled(true);
        ClientCacheConfiguration cacheCfg = new ClientCacheConfiguration(cacheCfgTemplate);
        ClientCache<Object, Object> cache = client.createCache(cacheCfg);
        assertEquals(CACHE_NAME, cache.getName());
        assertTrue(Comparers.equal(cacheCfgTemplate, cache.getConfiguration()));
    }
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) ModifiedExpiryPolicy(javax.cache.expiry.ModifiedExpiryPolicy) BinaryObject(org.apache.ignite.binary.BinaryObject) Arrays(java.util.Arrays) AbstractBinaryArraysTest(org.apache.ignite.internal.binary.AbstractBinaryArraysTest) SERIALIZABLE(org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE) CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration) Date(java.util.Date) Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) TestEnum(org.apache.ignite.internal.processors.cache.CacheEnumOperationsAbstractTest.TestEnum) REPEATABLE_READ(org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ) AccessedExpiryPolicy(javax.cache.expiry.AccessedExpiryPolicy) CacheRebalanceMode(org.apache.ignite.cache.CacheRebalanceMode) GridTestUtils.runAsync(org.apache.ignite.testframework.GridTestUtils.runAsync) VAL3(org.apache.ignite.internal.processors.cache.CacheEnumOperationsAbstractTest.TestEnum.VAL3) VAL1(org.apache.ignite.internal.processors.cache.CacheEnumOperationsAbstractTest.TestEnum.VAL1) VAL2(org.apache.ignite.internal.processors.cache.CacheEnumOperationsAbstractTest.TestEnum.VAL2) Map(java.util.Map) QueryEntity(org.apache.ignite.cache.QueryEntity) ClientStatus(org.apache.ignite.internal.processors.platform.client.ClientStatus) GridTestUtils.assertThrowsAnyCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause) CyclicBarrier(java.util.concurrent.CyclicBarrier) ImmutableSet(com.google.common.collect.ImmutableSet) CachePeekMode(org.apache.ignite.cache.CachePeekMode) SystemView(org.apache.ignite.spi.systemview.view.SystemView) TransactionView(org.apache.ignite.spi.systemview.view.TransactionView) Set(java.util.Set) OPTIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC) READ_COMMITTED(org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED) ClientListenerProcessor(org.apache.ignite.internal.processors.odbc.ClientListenerProcessor) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IgniteCache(org.apache.ignite.IgniteCache) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Stream(java.util.stream.Stream) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) IntStream(java.util.stream.IntStream) TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) U(org.apache.ignite.internal.util.typedef.internal.U) HashMap(java.util.HashMap) ClientServerError(org.apache.ignite.internal.client.thin.ClientServerError) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) PartitionLossPolicy(org.apache.ignite.cache.PartitionLossPolicy) PlatformExpiryPolicy(org.apache.ignite.internal.processors.platform.cache.expiry.PlatformExpiryPolicy) ClientProcessorMXBean(org.apache.ignite.mxbean.ClientProcessorMXBean) CacheWriteSynchronizationMode(org.apache.ignite.cache.CacheWriteSynchronizationMode) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) Timeout(org.junit.rules.Timeout) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) LinkedList(java.util.LinkedList) SimpleEntry(java.util.AbstractMap.SimpleEntry) Duration(javax.cache.expiry.Duration) F(org.apache.ignite.internal.util.typedef.F) CreatedExpiryPolicy(javax.cache.expiry.CreatedExpiryPolicy) Iterator(java.util.Iterator) TXS_MON_LIST(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.TXS_MON_LIST) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) T2(org.apache.ignite.internal.util.typedef.T2) TimeUnit(java.util.concurrent.TimeUnit) Ignition(org.apache.ignite.Ignition) Rule(org.junit.Rule) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Collections(java.util.Collections) QueryIndex(org.apache.ignite.cache.QueryIndex) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) CacheMode(org.apache.ignite.cache.CacheMode) ClientConnectorConfiguration(org.apache.ignite.configuration.ClientConnectorConfiguration) CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration) SimpleEntry(java.util.AbstractMap.SimpleEntry) QueryEntity(org.apache.ignite.cache.QueryEntity) PlatformExpiryPolicy(org.apache.ignite.internal.processors.platform.cache.expiry.PlatformExpiryPolicy) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) QueryIndex(org.apache.ignite.cache.QueryIndex) Ignite(org.apache.ignite.Ignite) BinaryObject(org.apache.ignite.binary.BinaryObject) AbstractBinaryArraysTest(org.apache.ignite.internal.binary.AbstractBinaryArraysTest) Test(org.junit.Test)

Example 10 with CacheKeyConfiguration

use of org.apache.ignite.cache.CacheKeyConfiguration in project ignite by apache.

the class ClientCacheConfigurationTest method testSerialization.

/**
 * Java serialization/deserialization.
 */
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
    ClientCacheConfiguration target = new ClientCacheConfiguration().setName("Person").setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setBackups(3).setCacheMode(CacheMode.PARTITIONED).setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC).setEagerTtl(false).setGroupName("FunctionalTest").setDefaultLockTimeout(12345).setPartitionLossPolicy(PartitionLossPolicy.READ_WRITE_ALL).setReadFromBackup(true).setRebalanceBatchSize(67890).setRebalanceBatchesPrefetchCount(102938).setRebalanceDelay(54321).setRebalanceMode(CacheRebalanceMode.SYNC).setRebalanceOrder(2).setRebalanceThrottle(564738).setRebalanceTimeout(142536).setKeyConfiguration(new CacheKeyConfiguration("Employee", "orgId")).setQueryEntities(new QueryEntity(int.class.getName(), "Employee").setTableName("EMPLOYEE").setFields(Stream.of(new SimpleEntry<>("id", Integer.class.getName()), new SimpleEntry<>("orgId", Integer.class.getName())).collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue, (a, b) -> a, LinkedHashMap::new))).setKeyFields(Collections.singleton("id")).setNotNullFields(Collections.singleton("id")).setDefaultFieldValues(Collections.singletonMap("id", 0)).setIndexes(Collections.singletonList(new QueryIndex("id", true, "IDX_EMPLOYEE_ID"))).setAliases(Stream.of("id", "orgId").collect(Collectors.toMap(f -> f, String::toUpperCase))));
    ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
    ObjectOutput out = new ObjectOutputStream(outBytes);
    out.writeObject(target);
    out.flush();
    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(outBytes.toByteArray()));
    Object desTarget = in.readObject();
    assertTrue(Comparers.equal(target, desTarget));
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration) ObjectOutput(java.io.ObjectOutput) ObjectInputStream(java.io.ObjectInputStream) CacheRebalanceMode(org.apache.ignite.cache.CacheRebalanceMode) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) PartitionLossPolicy(org.apache.ignite.cache.PartitionLossPolicy) CacheWriteSynchronizationMode(org.apache.ignite.cache.CacheWriteSynchronizationMode) ObjectOutputStream(java.io.ObjectOutputStream) QueryEntity(org.apache.ignite.cache.QueryEntity) SimpleEntry(java.util.AbstractMap.SimpleEntry) F(org.apache.ignite.internal.util.typedef.F) Collection(java.util.Collection) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) AbstractThinClientTest(org.apache.ignite.internal.client.thin.AbstractThinClientTest) Stream(java.util.stream.Stream) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) ObjectInput(java.io.ObjectInput) Collections(java.util.Collections) QueryIndex(org.apache.ignite.cache.QueryIndex) CacheMode(org.apache.ignite.cache.CacheMode) CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration) ObjectOutput(java.io.ObjectOutput) SimpleEntry(java.util.AbstractMap.SimpleEntry) ByteArrayOutputStream(java.io.ByteArrayOutputStream) QueryEntity(org.apache.ignite.cache.QueryEntity) ObjectOutputStream(java.io.ObjectOutputStream) LinkedHashMap(java.util.LinkedHashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) QueryIndex(org.apache.ignite.cache.QueryIndex) ObjectInput(java.io.ObjectInput) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test) AbstractThinClientTest(org.apache.ignite.internal.client.thin.AbstractThinClientTest)

Aggregations

CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)41 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)24 QueryEntity (org.apache.ignite.cache.QueryEntity)19 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)17 ArrayList (java.util.ArrayList)11 LinkedHashMap (java.util.LinkedHashMap)7 QueryIndex (org.apache.ignite.cache.QueryIndex)7 Ignite (org.apache.ignite.Ignite)6 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)6 HashMap (java.util.HashMap)5 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)5 Map (java.util.Map)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)4 SimpleEntry (java.util.AbstractMap.SimpleEntry)3 Collectors (java.util.stream.Collectors)3 BinaryObject (org.apache.ignite.binary.BinaryObject)3 CacheAtomicityMode (org.apache.ignite.cache.CacheAtomicityMode)3 CacheMode (org.apache.ignite.cache.CacheMode)3 CacheRebalanceMode (org.apache.ignite.cache.CacheRebalanceMode)3