Search in sources :

Example 26 with MemoryConfiguration

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

the class LargeEntryUpdateTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    cfg.setPublicThreadPoolSize(THREAD_COUNT);
    MemoryConfiguration mem = new MemoryConfiguration();
    mem.setPageSize(PAGE_SIZE);
    cfg.setMemoryConfiguration(mem);
    CacheConfiguration[] ccfgs = new CacheConfiguration[CACHE_COUNT];
    for (int i = 0; i < CACHE_COUNT; ++i) {
        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
        ccfg.setName(CACHE_PREFIX + i);
        ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
        ccfg.setCacheMode(CacheMode.PARTITIONED);
        ccfgs[i] = ccfg;
    }
    cfg.setCacheConfiguration(ccfgs);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 27 with MemoryConfiguration

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

the class IgniteCacheContinuousQueryBackupQueueTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME);
    ccfg.setCacheMode(PARTITIONED);
    ccfg.setAtomicityMode(ATOMIC);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setBackups(1);
    cfg.setCacheConfiguration(ccfg);
    cfg.setClientMode(client);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    MemoryConfiguration memCfg = new MemoryConfiguration();
    memCfg.setPageSize(16 * 1024);
    cfg.setMemoryConfiguration(memCfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 28 with MemoryConfiguration

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

the class IgfsSizeSelfTest method checkOversize.

/**
     * Ensure that an exception is thrown in case of IGFS oversize.
     *
     * @throws Exception If failed.
     */
private void checkOversize() throws Exception {
    final long maxSize = 32 * 1024 * 1024;
    memIgfsdDataPlcSetter = new IgniteInClosure<IgniteConfiguration>() {

        @Override
        public void apply(IgniteConfiguration cfg) {
            String memPlcName = "igfsDataMemPlc";
            cfg.setMemoryConfiguration(new MemoryConfiguration().setMemoryPolicies(new MemoryPolicyConfiguration().setMaxSize(maxSize).setInitialSize(maxSize).setName(memPlcName)));
            FileSystemConfiguration igfsCfg = cfg.getFileSystemConfiguration()[0];
            igfsCfg.getDataCacheConfiguration().setMemoryPolicyName(memPlcName);
            cfg.setCacheConfiguration(new CacheConfiguration().setName("QQQ").setMemoryPolicyName(memPlcName));
        }
    };
    startUp();
    final IgfsPath path = new IgfsPath("/file");
    final int writeChunkSize = (int) (maxSize / 1024);
    // This write is expected to be successful.
    IgfsOutputStream os = igfs(0).create(path, false);
    os.write(chunk(writeChunkSize));
    os.close();
    // This write must be successful as well.
    os = igfs(0).append(path, false);
    os.write(chunk(1));
    os.close();
    // This write must fail w/ exception.
    GridTestUtils.assertThrows(log(), new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            IgfsOutputStream osErr = igfs(0).append(path, false);
            try {
                for (int i = 0; i < maxSize / writeChunkSize * GRID_CNT; ++i) osErr.write(chunk(writeChunkSize));
                osErr.close();
                return null;
            } catch (IOException e) {
                Throwable e0 = e;
                while (e0.getCause() != null) e0 = e0.getCause();
                throw (Exception) e0;
            } finally {
                U.closeQuiet(osErr);
            }
        }
    }, IgniteOutOfMemoryException.class, "Not enough memory allocated");
}
Also used : MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) IOException(java.io.IOException) IgfsOutputStream(org.apache.ignite.igfs.IgfsOutputStream) IOException(java.io.IOException) IgniteOutOfMemoryException(org.apache.ignite.internal.mem.IgniteOutOfMemoryException) IgfsPath(org.apache.ignite.igfs.IgfsPath) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) FileSystemConfiguration(org.apache.ignite.configuration.FileSystemConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

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