Search in sources :

Example 16 with MemoryConfiguration

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

the class CacheStartOnJoinTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    TcpDiscoverySpi testSpi = new TcpDiscoverySpi() {

        /** */
        private boolean delay = true;

        @Override
        protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg, long timeout) throws IOException, IgniteCheckedException {
            super.writeToSocket(sock, out, msg, timeout);
        }

        @Override
        protected void startMessageProcess(TcpDiscoveryAbstractMessage msg) {
            if (getTestIgniteInstanceName(0).equals(ignite.name())) {
                if (msg instanceof TcpDiscoveryJoinRequestMessage) {
                    TcpDiscoveryJoinRequestMessage msg0 = (TcpDiscoveryJoinRequestMessage) msg;
                    if (msg0.client() && delay) {
                        log.info("Delay join processing: " + msg0);
                        delay = false;
                        doSleep(5000);
                    }
                }
            }
            super.startMessageProcess(msg);
        }
    };
    testSpi.setIpFinder(ipFinder);
    testSpi.setJoinTimeout(60_000);
    cfg.setDiscoverySpi(testSpi);
    MemoryConfiguration memCfg = new MemoryConfiguration();
    memCfg.setPageSize(1024);
    memCfg.setDefaultMemoryPolicySize(50 * 1024 * 1024);
    cfg.setMemoryConfiguration(memCfg);
    cfg.setClientMode(client);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryAbstractMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage) OutputStream(java.io.OutputStream) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) Socket(java.net.Socket) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) TcpDiscoveryJoinRequestMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryJoinRequestMessage)

Example 17 with MemoryConfiguration

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

the class CacheClientStoreSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    boolean client = igniteInstanceName != null && igniteInstanceName.startsWith("client");
    cfg.setClientMode(client);
    if (client)
        cfg.setMemoryConfiguration(new MemoryConfiguration());
    CacheConfiguration cc = new CacheConfiguration(DEFAULT_CACHE_NAME);
    cc.setName(CACHE_NAME);
    cc.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    cc.setCacheMode(cacheMode);
    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cc.setBackups(1);
    cc.setCacheStoreFactory(factory);
    if (factory instanceof Factory3)
        cc.setReadThrough(true);
    if (client && nearEnabled)
        cc.setNearConfiguration(new NearCacheConfiguration());
    cfg.setCacheConfiguration(cc);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(IP_FINDER);
    cfg.setDiscoverySpi(disco);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 18 with MemoryConfiguration

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

the class CacheMemoryPolicyConfigurationTest method testProperlySizedMemoryPolicy.

/**
     * Verifies that with enough memory allocated adding values to cache doesn't cause any exceptions.
     */
public void testProperlySizedMemoryPolicy() throws Exception {
    memCfg = new MemoryConfiguration();
    MemoryPolicyConfiguration dfltPlcCfg = new MemoryPolicyConfiguration();
    dfltPlcCfg.setName("dfltPlc");
    dfltPlcCfg.setInitialSize(DFLT_MEM_PLC_SIZE);
    dfltPlcCfg.setMaxSize(DFLT_MEM_PLC_SIZE);
    MemoryPolicyConfiguration bigPlcCfg = new MemoryPolicyConfiguration();
    bigPlcCfg.setName("bigPlc");
    bigPlcCfg.setMaxSize(BIG_MEM_PLC_SIZE);
    memCfg.setMemoryPolicies(dfltPlcCfg, bigPlcCfg);
    memCfg.setDefaultMemoryPolicyName("dfltPlc");
    ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setMemoryPolicyName("bigPlc");
    IgniteEx ignite0 = startGrid(0);
    IgniteCache<Object, Object> cache = ignite0.cache(DEFAULT_CACHE_NAME);
    try {
        for (int i = 0; i < 500_000; i++) cache.put(i, "abc");
    } catch (Exception e) {
        fail("With properly sized MemoryPolicy no exceptions are expected to be thrown.");
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteOutOfMemoryException(org.apache.ignite.internal.mem.IgniteOutOfMemoryException)

Example 19 with MemoryConfiguration

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

the class CacheMemoryPolicyConfigurationTest method testTooSmallMemoryPolicy.

/**
     * Verifies that {@link IgniteOutOfMemoryException} is thrown when cache is configured with too small MemoryPolicy.
     */
public void testTooSmallMemoryPolicy() throws Exception {
    memCfg = new MemoryConfiguration();
    MemoryPolicyConfiguration dfltPlcCfg = new MemoryPolicyConfiguration();
    dfltPlcCfg.setName("dfltPlc");
    dfltPlcCfg.setInitialSize(10 * 1024 * 1024);
    dfltPlcCfg.setMaxSize(10 * 1024 * 1024);
    MemoryPolicyConfiguration bigPlcCfg = new MemoryPolicyConfiguration();
    bigPlcCfg.setName("bigPlc");
    bigPlcCfg.setMaxSize(1024 * 1024 * 1024);
    memCfg.setMemoryPolicies(dfltPlcCfg, bigPlcCfg);
    memCfg.setDefaultMemoryPolicyName("dfltPlc");
    ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    IgniteEx ignite0 = startGrid(0);
    IgniteCache<Object, Object> cache = ignite0.cache(DEFAULT_CACHE_NAME);
    boolean oomeThrown = false;
    try {
        for (int i = 0; i < 500_000; i++) cache.put(i, "abc");
    } catch (Exception e) {
        Throwable cause = e;
        do {
            if (cause instanceof IgniteOutOfMemoryException) {
                oomeThrown = true;
                break;
            }
            if (cause == null)
                break;
            if (cause.getSuppressed() == null || cause.getSuppressed().length == 0)
                cause = cause.getCause();
            else
                cause = cause.getSuppressed()[0];
        } while (true);
    }
    if (!oomeThrown)
        fail("OutOfMemoryException hasn't been thrown");
}
Also used : IgniteOutOfMemoryException(org.apache.ignite.internal.mem.IgniteOutOfMemoryException) IgniteEx(org.apache.ignite.internal.IgniteEx) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteOutOfMemoryException(org.apache.ignite.internal.mem.IgniteOutOfMemoryException)

Example 20 with MemoryConfiguration

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

the class CacheConfigurationLeakTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration() throws Exception {
    IgniteConfiguration cfg = super.getConfiguration();
    MemoryConfiguration memCfg = new MemoryConfiguration();
    MemoryPolicyConfiguration plc = new MemoryPolicyConfiguration();
    plc.setName("dfltPlc");
    plc.setMaxSize(MemoryConfiguration.DFLT_MEMORY_POLICY_MAX_SIZE * 10);
    memCfg.setDefaultMemoryPolicyName("dfltPlc");
    memCfg.setMemoryPolicies(plc);
    cfg.setMemoryConfiguration(memCfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration)

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