Package org.fusesource.hawtdb.api

Examples of org.fusesource.hawtdb.api.Transaction.commit()


        factory.setKeyCodec(StringCodec.INSTANCE);
        factory.setValueCodec(LongCodec.INSTANCE);
        //
        Transaction tx = pageFile.tx();
        Index<String, Long> index = factory.create(tx);
        tx.commit();
        return index;
    }

    @Override
    protected Index<String, Long> openIndex(Transaction tx) {
View Full Code Here


                Transaction tx = pff.getTxPageFile().tx();
                for (int i = 0; i < INITIAL_PAGE_COUNT; i++) {
                    int page = tx.allocator().alloc(1);
                    tx.write(page, new Buffer(THE_DATA));
                }
                tx.commit();
            }
        });
    }

}
View Full Code Here

        // Create the root index at the root page.
        Transaction tx = pf.tx();
        SortedIndex<Long, String> root = ROOT_FACTORY.create(tx);
        assertEquals(0, root.getIndexLocation());
        tx.commit();
        pf.flush();

        int MAX_KEY=1000;
        long putCounter=0;
        long removeCounter=0;
View Full Code Here

            // validate that the number of keys in the map is what is expected.
            {
                tx = pf.tx();
                root = ROOT_FACTORY.open(tx, 0);
                assertEquals(putCounter-removeCounter, root.size());
                tx.commit();
            }


            // Do a bunch of transactions before reloading the page file.
            for(int txLoop=0; txLoop < 1000; txLoop ++) {
View Full Code Here

                        root.remove(key);
                        removeCounter++;
                    }

                }
                tx.commit();

                // flush every 100 commits..
                if( txLoop%100 == 0 ) {
                    pf.flush();
                }
View Full Code Here

        factory.setKeyCodec(StringCodec.INSTANCE);
        factory.setValueCodec(LongCodec.INSTANCE);
        //
        Transaction tx = pageFile.tx();
        Index<String, Long> index = factory.create(tx);
        tx.commit();
        return index;
    }

    @Override
    protected Index<String, Long> openIndex(Transaction tx) {
View Full Code Here

                        for (int i = 0; i < 1000; i++) {
                            index.put("" + i, Long.valueOf(i));
                        }
                        mutationLatch.countDown();
                        if (preCommitLatch.await(60, TimeUnit.SECONDS)) {
                            writer.commit();
                        } else {
                            throw new RuntimeException();
                        }
                    } catch (InterruptedException ex) {
                        error.set(ex);
View Full Code Here

                                if (index.get("" + i) != null) {
                                    error.set(new RuntimeException("Bad transaction isolation!"));
                                    throw new RuntimeException();
                                }
                            }
                            reader.commit();
                            preCommitLatch.countDown();
                        } else {
                            throw new RuntimeException();
                        }
                    } catch (InterruptedException ex) {
View Full Code Here

            Transaction checker = pageFile.tx();
            Index<String, Long> index = openIndex(checker);
            for (int i = 0; i < 1000; i++) {
                assertEquals(Long.valueOf(i), index.get("" + i));
            }
            checker.commit();
        } else {
            throw (Exception) error.get();
        }
        //
        executor.shutdownNow();
View Full Code Here

                            index.put("" + i, Long.valueOf(i));
                        }
                        preCommitLatch.countDown();
                        if (preCommitLatch.await(10, TimeUnit.SECONDS)) {
                            try {
                                writer.commit();
                                System.out.println("Committed from 1.");
                            } catch (OptimisticUpdateException ex) {
                                System.out.println("Replaying from 1...");
                                run();
                            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.