0 Replies Latest reply on Dec 9, 2002 12:29 AM by belaban

    TransactionalHashtable

    belaban

      This is the second building block. Checkout the previously posted URL for interface description.

      THT is a subclass of java.util.Map, and overrides the 4 methods put(), putAll(), remove() and clear(). All of these modify the state, and the changes are replicated to all instances of THT.

      Let's start with a simple example of how to use THT:
      TransactionalHashtable tht=new TransactionalHashtable("demogroup", "file:/home/bela/state_transfer.xml", 0);
      tht.put("name", "Bela Ban", false, 0); // #1
      tht.put("name", "Bela Ban", true, 10000); // #2

      try {
      tht.begin(); // #3
      tht.put("name", "Bela Ban", 10000, 5000, 10000, false);
      tht.put("age", new Integer(37), 10000, 5000, 10000, false);
      tht.commit();
      }
      catch(LockingException lex) {
      tht.rollback();
      }


      #1 (async replication): multicasts an update with the given key and value and returns immediately (synchronous == false).

      #2 (sync replication): multicasts an update with the given key and value and waits 10000 milliseconds max for all responses (null response is also a response).

      #3(sync replication with locking): acquires a transaction and associates it with the current thread (if there is already one associated, it will be reused). The 2 updates are multicast, both will acquire locks. If a lock cannot be acquired (LockingException), the transaction will be rolled back, otherwise it will be committed.

      --------------------------

      THT is an example of how RepicationManager and ReplicationReceiver are to be used. I will probably copy a modified version of THT into org.jboss.cache.

      Comments/suggestions on ReplicationManager/THT ?


      Bela