Package org.apache.activemq.store.kahadb.disk.page

Examples of org.apache.activemq.store.kahadb.disk.page.Transaction$CallableClosure


public class HashIndexBenchMark extends IndexBenchmark {

    @Override
    protected Index<String, Long> createIndex() throws Exception {

        Transaction tx = pf.tx();
        long id = tx.allocate().getPageId();
        tx.commit();

        HashIndex<String, Long> index = new HashIndex<String, Long>(pf, id);
        index.setKeyMarshaller(StringMarshaller.INSTANCE);
        index.setValueMarshaller(LongMarshaller.INSTANCE);
       
View Full Code Here


        pf = new PageFile(ROOT_DIR, getClass().getName());
        pf.load();
    }

    protected void tearDown() throws Exception {
        Transaction tx = pf.tx();
        for (Index<?, ?> i : indexes.values()) {
            try {
                i.unload(tx);
            } catch (Throwable ignore) {
            }
        }
        tx.commit();
    }
View Full Code Here

    }

    abstract protected Index<String, Long> createIndex() throws Exception;

    synchronized private Index<String, Long> openIndex(String name) throws Exception {
        Transaction tx = pf.tx();
        Index<String, Long> index = indexes.get(name);
        if (index == null) {
            index = createIndex();
            index.load(tx);
            indexes.put(name, index);
        }
        tx.commit();
        return index;
    }
View Full Code Here

        @Override
        public void run() {
            try {

                Transaction tx = pf.tx();

                Index<String,Long> index = openIndex(name);
                long counter = 0;
                while (!shutdown.get()) {
                    long c = counter;

                    String key = key(c);
                    index.put(tx, key, c);
                    tx.commit();
                    Thread.yield(); // This avoids consumer starvation..

                    onProduced(counter++);
                }
View Full Code Here

        }

        @Override
        public void run() {
            try {
                Transaction tx = pf.tx();

                Index<String,Long> index = openIndex(name);
                long counter = 0;
                while (!shutdown.get()) {
                    long c = counter;
                    String key = key(c);

                    Long record = index.get(tx, key);
                    if (record != null) {
                        if( index.remove(tx, key) == null ) {
                            System.out.print("Remove failed...");
                        }
                        tx.commit();
                        onConsumed(counter++);
                    }
                }
            } catch (Throwable e) {
                e.printStackTrace();
View Full Code Here

    }
   
    @Override
    protected Index<String, Long> createIndex() throws Exception {

        Transaction tx = pf.tx();
        long id = tx.allocate().getPageId();
        tx.commit();

        BTreeIndex<String, Long> index = new BTreeIndex<String, Long>(pf, id);
        index.setKeyMarshaller(StringMarshaller.INSTANCE);
        index.setValueMarshaller(LongMarshaller.INSTANCE);
       
View Full Code Here

        return index;
    }
   
    @Override
    protected void dumpIndex(Index<String, Long> index) throws IOException {
        Transaction tx = pf.tx();
        ((BTreeIndex)index).printStructure(tx, System.out);
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.store.kahadb.disk.page.Transaction$CallableClosure

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.