Package org.elasticsearch.cache.memory

Examples of org.elasticsearch.cache.memory.ByteBufferCache


    public static void main(String[] args) throws Exception {
        Environment environment = new Environment();
        Settings settings = EMPTY_SETTINGS;
        NodeEnvironment nodeEnvironment = new NodeEnvironment(settings, environment);
        ByteBufferCache byteBufferCache = new ByteBufferCache(settings);

        ShardId shardId = new ShardId(new Index("index"), 1);
        String type = args.length > 0 ? args[0] : "ram";
        Store store;
        if (type.equalsIgnoreCase("ram")) {
View Full Code Here


    public static void main(String[] args) throws Exception {
        ShardId shardId = new ShardId(new Index("index"), 1);
        Settings settings = EMPTY_SETTINGS;

//        Store store = new RamStore(shardId, settings);
        Store store = new ByteBufferStore(shardId, settings, null, new ByteBufferCache(settings));
//        Store store = new NioFsStore(shardId, settings);

        store.deleteContent();

        ThreadPool threadPool = new ThreadPool();
View Full Code Here

* @author kimchy
*/
public class SimpleByteBufferStoreTests {

    @Test public void test1BufferNoCache() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(1, 0, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);
        insertData(dir, 1);
        verifyData(dir);
        dir.close();
        cache.close();
    }
View Full Code Here

        dir.close();
        cache.close();
    }

    @Test public void test1Buffer() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(1, 10, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);
        insertData(dir, 1);
        verifyData(dir);
        dir.close();
        cache.close();
    }
View Full Code Here

        dir.close();
        cache.close();
    }

    @Test public void test3Buffer() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(3, 10, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);
        insertData(dir, 3);
        verifyData(dir);
        dir.close();
        cache.close();
    }
View Full Code Here

        dir.close();
        cache.close();
    }

    @Test public void test10Buffer() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(10, 20, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);
        insertData(dir, 10);
        verifyData(dir);
        dir.close();
        cache.close();
    }
View Full Code Here

        dir.close();
        cache.close();
    }

    @Test public void test15Buffer() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(15, 30, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);
        insertData(dir, 15);
        verifyData(dir);
        dir.close();
        cache.close();
    }
View Full Code Here

        dir.close();
        cache.close();
    }

    @Test public void test40Buffer() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(40, 80, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);
        insertData(dir, 40);
        verifyData(dir);
        dir.close();
        cache.close();
    }
View Full Code Here

        dir.close();
        cache.close();
    }

    @Test public void testSimpleLocking() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(40, 80, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);

        Lock lock = dir.makeLock("testlock");

        assertThat(lock.isLocked(), equalTo(false));
        assertThat(lock.obtain(200), equalTo(true));
        assertThat(lock.isLocked(), equalTo(true));
        try {
            assertThat(lock.obtain(200), equalTo(false));
            assertThat("lock should be thrown", false, equalTo(true));
        } catch (LockObtainFailedException e) {
            // all is well
        }
        lock.release();
        assertThat(lock.isLocked(), equalTo(false));
        dir.close();
        cache.close();
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.cache.memory.ByteBufferCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.