Search in sources :

Example 1 with MemoryMetricsImpl

use of org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl in project ignite by apache.

the class BPlusTreeBenchmark method createPageMemory.

/**
     * @return Page memory.
     * @throws Exception If failed.
     */
private PageMemory createPageMemory() throws Exception {
    long[] sizes = new long[CPUS];
    for (int i = 0; i < sizes.length; i++) sizes[i] = 1024 * MB / CPUS;
    MemoryPolicyConfiguration plcCfg = new MemoryPolicyConfiguration().setMaxSize(1024 * MB);
    PageMemory pageMem = new PageMemoryNoStoreImpl(new JavaLogger(), new UnsafeMemoryProvider(new JavaLogger()), null, PAGE_SIZE, plcCfg, new MemoryMetricsImpl(plcCfg), false);
    pageMem.start();
    return pageMem;
}
Also used : PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) JavaLogger(org.apache.ignite.logger.java.JavaLogger) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider) MemoryMetricsImpl(org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)

Example 2 with MemoryMetricsImpl

use of org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl in project ignite by apache.

the class MetadataStorageSelfTest method memory.

/**
     * @param clean Clean flag. If {@code true}, will clean previous memory state and allocate
     *      new empty page memory.
     * @return Page memory instance.
     */
protected PageMemory memory(boolean clean) throws Exception {
    DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), allocationPath);
    MemoryPolicyConfiguration plcCfg = new MemoryPolicyConfiguration().setMaxSize(30 * 1024 * 1024).setInitialSize(30 * 1024 * 1024);
    return new PageMemoryNoStoreImpl(log, provider, null, PAGE_SIZE, plcCfg, new MemoryMetricsImpl(plcCfg), true);
}
Also used : MappedFileMemoryProvider(org.apache.ignite.internal.mem.file.MappedFileMemoryProvider) PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) DirectMemoryProvider(org.apache.ignite.internal.mem.DirectMemoryProvider) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) MemoryMetricsImpl(org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)

Example 3 with MemoryMetricsImpl

use of org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl in project ignite by apache.

the class PageMemoryNoLoadSelfTest method memory.

/**
     * @return Page memory implementation.
     * @throws Exception If failed.
     */
protected PageMemory memory() throws Exception {
    File memDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "pagemem", false);
    MemoryPolicyConfiguration plcCfg = new MemoryPolicyConfiguration().setMaxSize(MAX_MEMORY_SIZE).setInitialSize(MAX_MEMORY_SIZE);
    DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), memDir);
    return new PageMemoryNoStoreImpl(log(), provider, null, PAGE_SIZE, plcCfg, new MemoryMetricsImpl(plcCfg), true);
}
Also used : MappedFileMemoryProvider(org.apache.ignite.internal.mem.file.MappedFileMemoryProvider) DirectMemoryProvider(org.apache.ignite.internal.mem.DirectMemoryProvider) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) File(java.io.File) MemoryMetricsImpl(org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)

Example 4 with MemoryMetricsImpl

use of org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl in project ignite by apache.

the class InlineIndexHelperTest method testStringTruncate.

/** */
public void testStringTruncate() throws Exception {
    MemoryPolicyConfiguration plcCfg = new MemoryPolicyConfiguration().setMaxSize(1024 * MB);
    JavaLogger log = new JavaLogger();
    PageMemory pageMem = new PageMemoryNoStoreImpl(log, new UnsafeMemoryProvider(log), null, PAGE_SIZE, plcCfg, new MemoryMetricsImpl(plcCfg), false);
    pageMem.start();
    long pageId = 0L;
    long page = 0L;
    try {
        pageId = pageMem.allocatePage(CACHE_ID, 1, PageIdAllocator.FLAG_DATA);
        page = pageMem.acquirePage(CACHE_ID, pageId);
        long pageAddr = pageMem.readLock(CACHE_ID, pageId, page);
        int off = 0;
        InlineIndexHelper ih = new InlineIndexHelper(Value.STRING, 1, 0);
        ih.put(pageAddr, off, ValueString.get("aaaaaaa"), 3 + 5);
        assertFalse(ih.isValueFull(pageAddr, off));
        assertEquals("aaaaa", ih.get(pageAddr, off, 3 + 5).getString());
        ih.put(pageAddr, off, ValueString.get("aaa"), 3 + 5);
        assertTrue(ih.isValueFull(pageAddr, off));
        assertEquals("aaa", ih.get(pageAddr, off, 3 + 5).getString());
    } finally {
        if (page != 0L)
            pageMem.releasePage(CACHE_ID, pageId, page);
        pageMem.stop();
    }
}
Also used : PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) JavaLogger(org.apache.ignite.logger.java.JavaLogger) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider) MemoryMetricsImpl(org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)

Example 5 with MemoryMetricsImpl

use of org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl in project ignite by apache.

the class InlineIndexHelperTest method testPutGet.

/** */
private void testPutGet(Value v1, Value v2, Value v3) throws Exception {
    MemoryPolicyConfiguration plcCfg = new MemoryPolicyConfiguration().setMaxSize(1024 * MB);
    JavaLogger log = new JavaLogger();
    PageMemory pageMem = new PageMemoryNoStoreImpl(log, new UnsafeMemoryProvider(log), null, PAGE_SIZE, plcCfg, new MemoryMetricsImpl(plcCfg), false);
    pageMem.start();
    long pageId = 0L;
    long page = 0L;
    try {
        pageId = pageMem.allocatePage(CACHE_ID, 1, PageIdAllocator.FLAG_DATA);
        page = pageMem.acquirePage(CACHE_ID, pageId);
        long pageAddr = pageMem.readLock(CACHE_ID, pageId, page);
        int off = 0;
        int max = 255;
        InlineIndexHelper ih = new InlineIndexHelper(v1.getType(), 1, 0);
        off += ih.put(pageAddr, off, v1, max - off);
        off += ih.put(pageAddr, off, v2, max - off);
        off += ih.put(pageAddr, off, v3, max - off);
        Value v11 = ih.get(pageAddr, 0, max);
        Value v22 = ih.get(pageAddr, ih.fullSize(pageAddr, 0), max);
        assertEquals(v1.getObject(), v11.getObject());
        assertEquals(v2.getObject(), v22.getObject());
    } finally {
        if (page != 0L)
            pageMem.releasePage(CACHE_ID, pageId, page);
        pageMem.stop();
    }
}
Also used : PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) Value(org.h2.value.Value) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) JavaLogger(org.apache.ignite.logger.java.JavaLogger) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider) MemoryMetricsImpl(org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)

Aggregations

MemoryMetricsImpl (org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)11 MemoryPolicyConfiguration (org.apache.ignite.configuration.MemoryPolicyConfiguration)9 PageMemoryNoStoreImpl (org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl)7 UnsafeMemoryProvider (org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)6 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)6 JavaLogger (org.apache.ignite.logger.java.JavaLogger)4 DirectMemoryProvider (org.apache.ignite.internal.mem.DirectMemoryProvider)2 MappedFileMemoryProvider (org.apache.ignite.internal.mem.file.MappedFileMemoryProvider)2 File (java.io.File)1 IgniteCache (org.apache.ignite.IgniteCache)1 MemoryPolicy (org.apache.ignite.internal.processors.cache.database.MemoryPolicy)1 NoOpPageEvictionTracker (org.apache.ignite.internal.processors.cache.database.evict.NoOpPageEvictionTracker)1 FreeListImpl (org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl)1 Value (org.h2.value.Value)1