Search in sources :

Example 11 with MemoryConfiguration

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

the class IgniteCacheDistributedPartitionQueryAbstractSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    MemoryConfiguration memCfg = new MemoryConfiguration().setDefaultMemoryPolicySize(20 * 1024 * 1024);
    cfg.setMemoryConfiguration(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 : MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 12 with MemoryConfiguration

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

the class IgniteSlowClientDetectionSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setClientReconnectDisabled(true);
    if (getTestIgniteInstanceName(nodeCount() - 1).equals(igniteInstanceName) || getTestIgniteInstanceName(nodeCount() - 2).equals(igniteInstanceName))
        cfg.setClientMode(true);
    TcpCommunicationSpi commSpi = new TcpCommunicationSpi();
    commSpi.setSlowClientQueueLimit(50);
    commSpi.setSharedMemoryPort(-1);
    commSpi.setIdleConnectionTimeout(300_000);
    commSpi.setConnectionsPerNode(1);
    cfg.setCommunicationSpi(commSpi);
    MemoryConfiguration dbCfg = new MemoryConfiguration();
    dbCfg.setPageSize(16 * 1024);
    cfg.setMemoryConfiguration(dbCfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 13 with MemoryConfiguration

use of org.apache.ignite.configuration.MemoryConfiguration 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>");
    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();
                if (args.getNearCacheSize() != 0)
                    nearCfg.setNearEvictionPolicy(new LruEvictionPolicy(args.getNearCacheSize()));
                cc.setNearConfiguration(nearCfg);
            }
            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() != MemoryConfiguration.DFLT_PAGE_SIZE) {
        MemoryConfiguration dbCfg = c.getMemoryConfiguration();
        if (dbCfg == null) {
            dbCfg = new MemoryConfiguration();
            c.setMemoryConfiguration(dbCfg);
        }
        dbCfg.setPageSize(args.getPageSize());
    }
    ignite = IgniteSpring.start(c, appCtx);
    BenchmarkUtils.println("Configured marshaller: " + ignite.cluster().localNode().attribute(ATTR_MARSHALLER));
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) ConnectorConfiguration(org.apache.ignite.configuration.ConnectorConfiguration) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)

Example 14 with MemoryConfiguration

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

the class IgniteCacheDatabaseSharedManager method init.

/**
     * @throws IgniteCheckedException If failed.
     */
public void init() throws IgniteCheckedException {
    if (memPlcMap == null) {
        MemoryConfiguration memCfg = cctx.kernalContext().config().getMemoryConfiguration();
        if (memCfg == null)
            memCfg = new MemoryConfiguration();
        validateConfiguration(memCfg);
        pageSize = memCfg.getPageSize();
        initPageMemoryPolicies(memCfg);
        registerMetricsMBeans();
        startMemoryPolicies();
        initPageMemoryDataStructures(memCfg);
    }
}
Also used : MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration)

Example 15 with MemoryConfiguration

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

the class DynamicIndexAbstractSelfTest method commonConfiguration.

/**
     * Create common node configuration.
     *
     * @param idx Index.
     * @return Configuration.
     * @throws Exception If failed.
     */
protected IgniteConfiguration commonConfiguration(int idx) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(getTestIgniteInstanceName(idx));
    cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
    cfg.setMarshaller(new BinaryMarshaller());
    MemoryConfiguration memCfg = new MemoryConfiguration().setDefaultMemoryPolicyName("default").setMemoryPolicies(new MemoryPolicyConfiguration().setName("default").setMaxSize(32 * 1024 * 1024L).setInitialSize(32 * 1024 * 1024L));
    cfg.setMemoryConfiguration(memCfg);
    return optimize(cfg);
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

MemoryConfiguration (org.apache.ignite.configuration.MemoryConfiguration)28 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)17 MemoryPolicyConfiguration (org.apache.ignite.configuration.MemoryPolicyConfiguration)14 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)11 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)10 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)3 IgniteOutOfMemoryException (org.apache.ignite.internal.mem.IgniteOutOfMemoryException)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)2 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Socket (java.net.Socket)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AffinityKey (org.apache.ignite.cache.affinity.AffinityKey)1 LruEvictionPolicy (org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)1 ConnectorConfiguration (org.apache.ignite.configuration.ConnectorConfiguration)1 FileSystemConfiguration (org.apache.ignite.configuration.FileSystemConfiguration)1 TransactionConfiguration (org.apache.ignite.configuration.TransactionConfiguration)1