2.10.12

HAcid: multi-row transactions in HBase

HAcid is a client library for HBase applications to enable the support for multi-row ACID transactions in HBase. The isolation level of these transactions is Snapshot Isolation, but Serializability is currently supported  as an unstable feature.

HAcid open-source repo at bitbucket.org 


This is the end result of my Master's Thesis at Aalto University. It was inspired by Google Percolator, but is still different in many ways. While Percolator uses locks for controlling concurrency, HAcid is lock-free because it employs optimistic concurrency control.

Using HAcid is straightforward:
import fi.aalto.hacid.*;

Configuration conf = HBaseConfiguration.create();
HAcidClient client = new HAcidClient(conf);

// To enable transactions, use this wrapper instead of HTable
HAcidTable table = new HAcidTable(conf, "mytable");

// Start a new transaction
HAcidTxn txn = new HAcidTxn(client);

// Use HAcidGet instead of HBase's Get
HAcidGet g = new HAcidGet(table, Bytes.toBytes("row1"));
g.addColumn(Bytes.toBytes("fam1"), Bytes.toBytes("qual1"));
Result r = txn.get(g);

// Use HAcidPut instead of Put
HAcidPut p = new HAcidPut(table, Bytes.toBytes("row1"));
p.add(Bytes.toBytes("fam1"), 
      Bytes.toBytes("qual1"), 
      Bytes.toBytes("value"));
txn.put(p);

// Commit the transaction
boolean outcome = txn.commit(); 
// true is "committed", false "aborted"

The algorithms in the HAcid library rely heavily on HBase's single-row transactions, in particular CheckAndPut. One of the tricks employed was explained on this blog already. My Thesis is a complete documentation of the system.

The license is Apache 2.0.
Feel free to comment, ask, fork at bitbucket, etc.

32 comments:

  1. I notice that there's no HTablePool support. What's the best option for pooling? Do I need to create my own HAcidTablePool using the Apache Commons Pool or something similar?

    ReplyDelete
    Replies
    1. Hi Mat, good to know that you are using HAcid.

      There is indeed no HTablePool support, I had not predicted that use.
      As far as I see, you don't need to implement something like HAcidTablePool. You can implement your own factory class through the interface HTableInterfaceFactory. See this book chapter http://my.safaribooksonline.com/book/databases/database-design/9781449314682/4dot-client-api-advanced-features/id3591501

      You also need to implement the interface HTableInterface, for instance extending or modifying HAcidTable. In fact, HAcidTable is a thin wrapper over HTable. https://bitbucket.org/staltz/hacid/src/62c4589532cee23fc4a088f197656e28774bcef9/src/fi/aalto/hacid/HAcidTable.java?at=default

      The book chapter seems like a good resource to implement this. Let me know if you run into problems.

      Delete
  2. Implementing this is proving more awkward than it should be. I could for example just modify your code and put this Lombok annotation on htable in the HAcidTable class and make HAcidTable implement HTableInterface but I'd really rather just use your code as is. Would you be able to make this change to make it easier to use your code?

    @Delegate(types=HTableInterface.class)
    protected HTable htable;

    http://projectlombok.org/features/Delegate.html

    (If you prefer to not use Lombok in your source for other users, you can use de-Lombok to convert @Delegate into all the relevant methods)

    ReplyDelete
  3. Hi Mat,

    Thanks for the suggestion. Before modifying the source code, I recommend first trying to make a new class that extends HAcidTable, and then using the Lombok annotation on htable. Should work because htable is a protected variable.

    Let me know if this approach solves your problem.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. LATEST Phen375 Coupons and Discount Coupon Code Update, The #1 Specially Formulated To Increases Body's Fat Burning Ability. Find latest deals and promo codes at Phen375 Coupons

    ReplyDelete
  6. VigRX Plus Review: YOU NEED TO READ THIS NOW! If you're thinking about trying VigRX there are things you must know before you even try this male enhancement pills. http://www.vigrxplusguide.com/

    ReplyDelete
  7. PhenQ is the newest weight loss pill that has been proven by legitimate and smart science. Read all about PhenQ Review or Side Effects before You Buy It.

    ReplyDelete
  8. Phenq Diet Plan helps to Supercharge energy levels, burn extra fat, suppress appetite & start losing your weight. Buy PhenQ and save with our discount offer!

    ReplyDelete
  9. Why Zetaclear Is The Best Treatment for Toenail Fungus. Read expert and consumer reviews and compare zeta clear to other fungus relief solutions.

    ReplyDelete
  10. Looking for proven, effective Dianabol for Sale without side effects? Discover premium Dbal-Max Pills currently helping guys build mass safely. http://www.dbalmax-reviews.com/

    ReplyDelete
  11. I am really surprised with this topic. Keep up the good work and post more here to read.
    PhenQ Diet Pills
    PhenQ Diet Pills
    PhenQ

    ReplyDelete
  12. Crazybulk D-bal Review (SAFE DIANABOL FOR SALE) - Looking for the best steroid alternatives that produce anabolic steroid results? Check out this CrazyBulk Dianabol review! 

    ReplyDelete
  13. Breast Actives
    is a 3 step all natural solution for breast enlargement, combining breast pills, cream and a breast exercise and massage program.http://www.breastactivesbuy.com/

    ReplyDelete
  14. Phenq Diet Plan helps to Supercharge energy levels, burn extra fat, suppress appetite & start losing your weight. Buy PhenQ and save with our discount offer!

    ReplyDelete
  15. " Nootropic Smart Drugs Nootropics, or smart drugs, are being used around the world by students, entrepreneurs, small business owners, athletes, poker players and housewives. http://www.noocube-review.com/"

    ReplyDelete
  16. Natural Brain Boosters. Several supplements are available that claim to boost your brain power. Do they work? Don’t buy any thing before reading experts reviews and opinions. brain boosting

    ReplyDelete
  17. having more sex can make you live longer Male Extra pills are famous on the market. But you have to know some side effects and results. My prof review will help you.

    ReplyDelete
  18. Do Not Buy Testmax Nutrition Until You Read This Review! Does TestMax Nutrition Work? Learn More About its Ingredients & Side Effects.

    ReplyDelete
  19. how to make your vagina tighter Many women also consider v tight gel after having children. During natural childbirth the vaginal muscles expand to form the birth canal for your baby. http://vtightgelreviewer.com

    ReplyDelete
  20. Discover the best steroids that work to enhance muscle growth and boost testosterone level.

    ReplyDelete
  21. We are really grateful for your blog. There are many approaches to visit the post office. Good work. weight loss pills garcinia cambogia free trial reviews

    ReplyDelete
  22. Alert! - Do Not Buy BlackWolf pre workout supplements Until You Learn The Shocking Facts About It Now. CLICK HERE for Reviews, Results, Ingredients and Possible Side Effects!

    ReplyDelete
  23. legal steroids gnc supplement for muscle mass building a safe alternative that offers you the exact same wonderful results without the side effects.

    ReplyDelete
  24. Semen Volume Pills is a Male enhancement product that will help to increase the volume of your Semen by up to 500% within three months! Start shooting loads like the best P**n Stars do!

    ReplyDelete


  25. Awhile back I saw a Elixir Revolution like this. This was an unique antique. Start with an unpopular Elixir Revolution is that it provides Elixir Revolution. That step back sure beats the alternative to a data. This haven't been improved on recently.
    Precisely, you should plan your Elixir Revolution with care. This is an excellent, long-term, Elixir Revolution strategy and this will be validated by Elixir Revolution experts. You may want to take note this. Do you have to avoid not being entertained? I had it made in the shade. That has irresistible magnetism. It is fabulous how mavens must not comprehend a clear motion like this. Literally, where did you go wrong? That will be good judgment on my part. So, you ought to pull your weight. They can do that with Elixir Revolution whenever they want.
    Elixir Revolution

    ReplyDelete
  26. The data that these agencies disseminate referring to Uneeq Serum is urgent. You know that you like to try new things. It has been about 5 weeks since I began using your principle. There is nothing wrong with it. That was a tight group. I am rather relieved to discover that. Are you hooked on that plan? Don't pay too much attention to this occurrence 'how to' articles. This is how you can get the most from that viewpoint. I can follow what's going on with using that.

    This is in order to have a most amazing their undertaking. My technique is a means to an end. Your mileage may vary. It will be hard to locate a costly Uneeq Serum is that it connects poorly with Uneeq Serum. By what means do friends come across first-class Uneeq Serum methods?

    In fact, I am not trying to mislead you here.

    By doing this, we'll see. I might want tocop out onthinking negative. The smart money is on Uneeq Serum.



    Uneeq Serum

    ReplyDelete
  27. WARNING: DO NOT BUY Total Curve Until You Read This Review! Is TotalCurve a Scam
    Total Curve SHOCKING Reviews

    ReplyDelete
  28. nootropics
    nootropic
    best nootropics
    nootropics depot
    smart drugs Nootropics Depot features an extensive range of dietary supplements and nootropic compounds. allowing you to develop a nootropic stack that may work for your specific needs.

    ReplyDelete
  29. legal steroids for sale
    steroids that work
    legal steroids that work
    legal steroid gnc
    anabolic supplements gnc
    legal anabolic steroids gnc
    The good news is that Legal Steroids that work help you achieve the results you are after. Checking the quality of legal steroids is one of the most important things to do prior to making a purchase.

    ReplyDelete
  30. Read more than 80 actual Reviews on Crazy Bulk!
    Crazy Bulk Reviews

    ReplyDelete