Search in sources :

Example 1 with DataStorageConfiguration

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

the class SqlUserCommandSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    if (getTestIgniteInstanceIndex(igniteInstanceName) == CLI_NODE)
        cfg.setClientMode(true);
    TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setIpFinder(IP_FINDER);
    cfg.setDiscoverySpi(spi);
    cfg.setAuthenticationEnabled(true);
    cfg.setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 2 with DataStorageConfiguration

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

the class IgniteCacheDistributedPartitionQueryAbstractSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    DataStorageConfiguration memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(20 * 1024 * 1024));
    cfg.setDataStorageConfiguration(memCfg);
    TcpDiscoverySpi spi = (TcpDiscoverySpi) cfg.getDiscoverySpi();
    spi.setIpFinder(IP_FINDER);
    cfg.setDiscoverySpi(spi);
    /**
     * Clients cache
     */
    CacheConfiguration<ClientKey, Client> clientCfg = new CacheConfiguration<>();
    clientCfg.setName("cl");
    clientCfg.setWriteSynchronizationMode(FULL_SYNC);
    clientCfg.setAtomicityMode(TRANSACTIONAL);
    clientCfg.setRebalanceMode(SYNC);
    clientCfg.setBackups(2);
    clientCfg.setAffinity(AFFINITY);
    clientCfg.setIndexedTypes(ClientKey.class, Client.class);
    /**
     * Deposits cache
     */
    CacheConfiguration<DepositKey, Deposit> depoCfg = new CacheConfiguration<>();
    depoCfg.setName("de");
    depoCfg.setWriteSynchronizationMode(FULL_SYNC);
    depoCfg.setAtomicityMode(TRANSACTIONAL);
    depoCfg.setRebalanceMode(SYNC);
    depoCfg.setBackups(2);
    depoCfg.setAffinity(AFFINITY);
    depoCfg.setIndexedTypes(DepositKey.class, Deposit.class);
    /**
     * Regions cache. Uses default affinity.
     */
    CacheConfiguration<Integer, Region> regionCfg = new CacheConfiguration<>();
    regionCfg.setName("re");
    regionCfg.setWriteSynchronizationMode(FULL_SYNC);
    regionCfg.setAtomicityMode(TRANSACTIONAL);
    regionCfg.setRebalanceMode(SYNC);
    regionCfg.setCacheMode(CacheMode.REPLICATED);
    regionCfg.setIndexedTypes(Integer.class, Region.class);
    cfg.setCacheConfiguration(clientCfg, depoCfg, regionCfg);
    if ("client".equals(gridName))
        cfg.setClientMode(true);
    else {
        Integer reg = regionForGrid(gridName);
        cfg.setUserAttributes(F.asMap(REGION_ATTR_NAME, reg));
        log().info("Assigned region " + reg + " to grid " + gridName);
    }
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 3 with DataStorageConfiguration

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

the class IgniteCacheQueryNodeRestartSelfTest2 method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    DataStorageConfiguration memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(50 * 1024 * 1024));
    c.setDataStorageConfiguration(memCfg);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    c.setDiscoverySpi(disco);
    int i = 0;
    CacheConfiguration<?, ?>[] ccs = new CacheConfiguration[4];
    for (String name : F.asList("pe", "pu")) {
        CacheConfiguration<?, ?> cc = defaultCacheConfiguration();
        cc.setName(name);
        cc.setCacheMode(PARTITIONED);
        cc.setBackups(2);
        cc.setWriteSynchronizationMode(FULL_SYNC);
        cc.setAtomicityMode(TRANSACTIONAL);
        cc.setRebalanceMode(SYNC);
        cc.setAffinity(new RendezvousAffinityFunction(false, 60));
        if (name.equals("pe")) {
            cc.setIndexedTypes(Integer.class, Person.class);
        } else if (name.equals("pu")) {
            cc.setIndexedTypes(AffinityKey.class, Purchase.class);
        }
        ccs[i++] = cc;
    }
    for (String name : F.asList("co", "pr")) {
        CacheConfiguration<?, ?> cc = defaultCacheConfiguration();
        cc.setName(name);
        cc.setCacheMode(REPLICATED);
        cc.setWriteSynchronizationMode(FULL_SYNC);
        cc.setAtomicityMode(TRANSACTIONAL);
        cc.setRebalanceMode(SYNC);
        cc.setAffinity(new RendezvousAffinityFunction(false, 50));
        if (name.equals("co")) {
            cc.setIndexedTypes(Integer.class, Company.class);
        } else if (name.equals("pr")) {
            cc.setIndexedTypes(Integer.class, Product.class);
        }
        ccs[i++] = cc;
    }
    c.setCacheConfiguration(ccs);
    return c;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) AffinityKey(org.apache.ignite.cache.affinity.AffinityKey) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 4 with DataStorageConfiguration

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

the class IgniteNode method start.

/**
 * {@inheritDoc}
 */
@Override
public void start(BenchmarkConfiguration cfg) throws Exception {
    IgniteBenchmarkArguments args = new IgniteBenchmarkArguments();
    BenchmarkUtils.jcommander(cfg.commandLineArguments(), args, "<ignite-node>");
    if (args.clientNodesAfterId() >= 0 && cfg.memberId() > args.clientNodesAfterId())
        clientMode = true;
    IgniteBiTuple<IgniteConfiguration, ? extends ApplicationContext> tup = loadConfiguration(args.configuration());
    IgniteConfiguration c = tup.get1();
    assert c != null;
    if (args.cleanWorkDirectory())
        FileUtils.cleanDirectory(U.workDirectory(c.getWorkDirectory(), c.getIgniteHome()));
    ApplicationContext appCtx = tup.get2();
    assert appCtx != null;
    CacheConfiguration[] ccfgs = c.getCacheConfiguration();
    if (ccfgs != null) {
        for (CacheConfiguration cc : ccfgs) {
            // IgniteNode can not run in CLIENT_ONLY mode,
            // except the case when it's used inside IgniteAbstractBenchmark.
            boolean cl = args.isClientOnly() && (args.isNearCache() || clientMode);
            if (cl)
                c.setClientMode(true);
            if (args.isNearCache()) {
                NearCacheConfiguration nearCfg = new NearCacheConfiguration();
                int nearCacheSize = args.getNearCacheSize();
                if (nearCacheSize != 0)
                    nearCfg.setNearEvictionPolicy(new LruEvictionPolicy(nearCacheSize));
                cc.setNearConfiguration(nearCfg);
            }
            if (args.cacheGroup() != null)
                cc.setGroupName(args.cacheGroup());
            cc.setWriteSynchronizationMode(args.syncMode());
            cc.setBackups(args.backups());
            if (args.restTcpPort() != 0) {
                ConnectorConfiguration ccc = new ConnectorConfiguration();
                ccc.setPort(args.restTcpPort());
                if (args.restTcpHost() != null)
                    ccc.setHost(args.restTcpHost());
                c.setConnectorConfiguration(ccc);
            }
            cc.setReadThrough(args.isStoreEnabled());
            cc.setWriteThrough(args.isStoreEnabled());
            cc.setWriteBehindEnabled(args.isWriteBehind());
            BenchmarkUtils.println(cfg, "Cache configured with the following parameters: " + cc);
        }
    } else
        BenchmarkUtils.println(cfg, "There are no caches configured");
    TransactionConfiguration tc = c.getTransactionConfiguration();
    tc.setDefaultTxConcurrency(args.txConcurrency());
    tc.setDefaultTxIsolation(args.txIsolation());
    TcpCommunicationSpi commSpi = (TcpCommunicationSpi) c.getCommunicationSpi();
    if (commSpi == null)
        commSpi = new TcpCommunicationSpi();
    c.setCommunicationSpi(commSpi);
    if (args.getPageSize() != DataStorageConfiguration.DFLT_PAGE_SIZE) {
        DataStorageConfiguration memCfg = c.getDataStorageConfiguration();
        if (memCfg == null) {
            memCfg = new DataStorageConfiguration();
            c.setDataStorageConfiguration(memCfg);
        }
        memCfg.setPageSize(args.getPageSize());
    }
    if (args.persistentStoreEnabled()) {
        DataStorageConfiguration pcCfg = new DataStorageConfiguration();
        c.setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(false));
        c.setDataStorageConfiguration(pcCfg);
    }
    ignite = IgniteSpring.start(c, appCtx);
    BenchmarkUtils.println("Configured marshaller: " + ignite.cluster().localNode().attribute(ATTR_MARSHALLER));
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) ConnectorConfiguration(org.apache.ignite.configuration.ConnectorConfiguration) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)

Example 5 with DataStorageConfiguration

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

the class H2DynamicTableSelfTest method commonConfiguration.

/**
 * Create common node configuration.
 *
 * @param idx Index.
 * @return Configuration.
 * @throws Exception If failed.
 */
private IgniteConfiguration commonConfiguration(int idx) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(getTestIgniteInstanceName(idx));
    DataRegionConfiguration dataRegionCfg = new DataRegionConfiguration().setName(DATA_REGION_NAME);
    cfg.setMarshaller(new BinaryMarshaller());
    cfg.setDataStorageConfiguration(new DataStorageConfiguration().setDataRegionConfigurations(dataRegionCfg));
    return optimize(cfg);
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller)

Aggregations

DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)143 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)120 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)119 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)55 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)51 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)33 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 File (java.io.File)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 ArrayList (java.util.ArrayList)4 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)4 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)4 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)4 ConnectorConfiguration (org.apache.ignite.configuration.ConnectorConfiguration)3 IgniteOutOfMemoryException (org.apache.ignite.internal.mem.IgniteOutOfMemoryException)3 IOException (java.io.IOException)2 LinkedHashMap (java.util.LinkedHashMap)2 QueryEntity (org.apache.ignite.cache.QueryEntity)2 QueryIndex (org.apache.ignite.cache.QueryIndex)2