1 22 package org.jboss.ha.singleton; 23 24 25 import org.jboss.ha.framework.interfaces.HAPartition; 26 import org.jboss.ha.framework.server.ClusterPartition; 27 import org.jboss.logging.Logger; 28 import org.jboss.system.ServiceMBeanSupport; 29 30 37 public abstract class HASingletonElectionPolicyBase 38 extends ServiceMBeanSupport 39 implements HASingletonElectionPolicyMBean 40 { 41 private Object mManagedSingleton; 42 private HAPartition mPartition; 43 44 47 public void setManagedSingleton(Object singleton) 48 { 49 this.mManagedSingleton = singleton; 50 } 51 52 55 public Object getManagedSingleton() 56 { 57 return this.mManagedSingleton; 58 } 59 60 63 public void setHAPartition(HAPartition partition) 64 { 65 this.mPartition = partition; 66 } 67 68 71 public HAPartition getHAPartition() 72 { 73 return this.mPartition; 74 } 75 76 79 public boolean isElectedMaster() 80 { 81 if (null == this.mPartition) 82 throw new IllegalStateException ("HAPartition is not set"); 83 84 return pickSingleton().equals(this.mPartition.getClusterNode()); 85 } 86 87 90 public boolean isElectedMaster(HAPartition partition) 91 { 92 if (null == partition) 93 throw new IllegalStateException ("parameter cannot be null"); 94 95 return pickSingleton(partition).equals(partition.getClusterNode()); 96 } 97 } 98 | Popular Tags |