[jboss-jira] [JBoss JIRA] Commented: (JGRP-384) DistributedLockManager.unlock() throws an exception if one of the group members terminates.

Bela Ban (JIRA) jira-events at lists.jboss.org
Tue Oct 2 09:35:03 EDT 2007


    [ http://jira.jboss.com/jira/browse/JGRP-384?page=comments#action_12379895 ] 
            
Bela Ban commented on JGRP-384:
-------------------------------

Note that - in order to determine a coordinator - you don't need a cluster wide lock; you could simply take the view, which is the *same on all nodes in a cluster*, and (for example) pick the first (= oldest member) in the list. This is faster and doesn't require communication.

> DistributedLockManager.unlock() throws an exception if one of the group members terminates.
> -------------------------------------------------------------------------------------------
>
>                 Key: JGRP-384
>                 URL: http://jira.jboss.com/jira/browse/JGRP-384
>             Project: JGroups
>          Issue Type: Bug
>    Affects Versions: 2.4
>         Environment: Suse Linux 10.1 Desktop
> java version "1.5.0_07"
> Dell Optiplex GX280
>            Reporter: Sean Landis
>         Assigned To: Bela Ban
>             Fix For: 2.6
>
>         Attachments: bla2.java
>
>
> I am trying to use the DLM to implement a failover mechanism. Two
> identical processes are started. One acquires the lock and becomes the
> primary; the other can't acquire the lock and becomes the backup. The
> primary does it's processing. The backup checks periodically if it can
> get the lock. Should the primary fail, the backup will acquire the
> lock and do the processing.
> This works fine. The problem I am having is if both are running, the
> backup fails, and the primary tries to unlock. I get the following
> stack trace:
> Exception in thread "main"
> org.jgroups.blocks.LockNotReleasedException: Lock cannot be unlocked.
>        at org.jgroups.blocks.DistributedLockManager.unlock(DistributedLockManager.java:318)
>        at org.jgroups.blocks.DistributedLockManager.unlock(DistributedLockManager.java:260)
>        at com.overstock.distlock.examples.FailoverTest.doIt(FailoverTest.java:50)
>        at com.overstock.distlock.examples.FailoverTest.main(FailoverTest.java:61)
> I am running version 2.4. Here's a sample program:
> package distlock.examples;
> import org.jgroups.JChannel;
> import org.jgroups.blocks.DistributedLockManager;
> import org.jgroups.blocks.LockNotGrantedException;
> import org.jgroups.blocks.VotingAdapter;
> public class FailoverTest {
>  public static final String SERVER_PROTOCOL_STACK =
>    "UDP(mcast_addr=228.3.11.76;mcast_port=12345;ip_ttl=1;"
>            + "mcast_send_buf_size=150000;mcast_recv_buf_size=80000)"
>            + ":PING(timeout=500;num_initial_members=1)"
>            + ":FD"
>            + ":VERIFY_SUSPECT(timeout=1500)"
>            + ":pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800)"
>            + ":UNICAST(timeout=5000)"
>            + ":pbcast.STABLE(desired_avg_gossip=200)"
>            + ":FRAG(frag_size=4096)"
>            + ":pbcast.GMS(join_timeout=5000;join_retry_timeout=1000;"
>            +     "shun=false;print_local_addr=false)"
>    ;
>  private void doIt() throws Exception {
>    JChannel channel = new JChannel(SERVER_PROTOCOL_STACK);
>    VotingAdapter adapter = new VotingAdapter(channel);
>    channel.connect("cluster");
>    DistributedLockManager dlm = new DistributedLockManager(adapter, "Mgr");
>    String lockId = "theLock";
>    for (int i = 0; i < 40; i++) {
>      while (true) {
>        try {
>          System.out.println("Trying to get lock.");
>          dlm.lock(lockId, channel.getLocalAddress(), 10000);
>          break;
>        } catch (LockNotGrantedException ex) {
>          System.out.println("Could not get lock.");
>        }
>        try {
>          Thread.sleep(5000);
>        } catch(InterruptedException ex) {
>        }
>      }
>      System.out.println("Got lock, sleeping.");
>      try {
>        Thread.sleep(10000);
>      } catch(InterruptedException ex) {
>      }
>      System.out.println("unlocking and sleeping.");
>      dlm.unlock(lockId, channel.getLocalAddress());
>      try {
>        Thread.sleep(5000);
>      } catch(InterruptedException ex) {
>      }
>    }
>    channel.close();
>  }
>  public static void main(String[] args) throws Exception {
>    System.setProperty("java.net.preferIPv4Stack", "true");
>    new FailoverTest().doIt();
>  }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list