User: patriot1burke Date: 01/09/19 16:57:59 Modified: src/main/org/jboss/ha/jndi HANamingService.java HAJNDI.java Log: HAJNDI sort of works now. Framework definately works now. Revision Changes Path 1.3 +24 -19 jbossmx/src/main/org/jboss/ha/jndi/HANamingService.java Index: HANamingService.java =================================================================== RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/jndi/HANamingService.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- HANamingService.java 2001/09/18 21:21:08 1.2 +++ HANamingService.java 2001/09/19 23:57:59 1.3 @@ -58,7 +58,7 @@ @author oberg @author [EMAIL PROTECTED] - @version $Revision: 1.2 $ + @version $Revision: 1.3 $ */ public class HANamingService extends ServiceMBeanSupport implements Runnable, HANamingServiceMBean, DistributedReplicantManager.ReplicantListener { @@ -107,7 +107,7 @@ public String getName() { - return "HA-JNDI"; + return "HAJNDI"; } public ObjectName getObjectName(MBeanServer server, ObjectName name) @@ -195,8 +195,10 @@ public void replicantsChanged(String key, ArrayList newReplicants) { - if (key.equals("HA-JNDI")) + log.info("replicantsChanged"); + if (key.equals("HAJNDI")) { + log.info("HAJNDI replicantChanged"); synchronized(this.hatarget) { hatarget.setTargets(newReplicants.toArray()); @@ -204,6 +206,7 @@ } else if (key.equals("DistributedReplicantManager")) { + log.info("DistributedReplicantManager replicantChanged"); synchronized(this.hatarget) { hatarget.setManagers(newReplicants); @@ -213,37 +216,39 @@ public void initService() throws Exception { - } - - public void startService() - throws Exception - { - log.info("Starting HA-JNDI server"); + log.info("Initializing HAJNDI server"); partition = (HAPartition)new InitialContext().lookup("/HAPartition/" + partitionName); replicantManager = partition.getDistributedReplicantManager(); log.info("Create remote object"); theServer = new HAJNDI(partition); - ((HAJNDI)theServer).init(); - log.info("Export RMI server"); stub = UnicastRemoteObject.exportObject(theServer); + log.info("initialize HAJNDI"); + theServer.init(); + } + + public void startService() + throws Exception + { + log.info("Starting HAJNDI server"); log.info("Bind replicant to DistributedReplicantManager"); - replicantManager.add("HA-JNDI", stub); + replicantManager.add("HAJNDI", stub); - log.info("Get all replicants for DistributedReplicantManager and HA-JNDI"); + log.info("Get all replicants for DistributedReplicantManager and HAJNDI"); ArrayList managers = this.replicantManager.lookupReplicants("DistributedReplicantManager"); - ArrayList replicants = this.replicantManager.lookupReplicants("HA-JNDI"); + ArrayList replicants = this.replicantManager.lookupReplicants("HAJNDI"); - log.info("Create HA-JNDI RMI Proxy with " + replicants.size() + " replicants"); - this.hatarget = new HARMITarget("HA-JNDI", 100000, 500000, managers, replicants.toArray(), new RoundRobin()); + log.info("Create HAJNDI RMI Proxy with " + replicants.size() + " replicants"); + this.hatarget = new HARMITarget("HAJNDI", 100000, 500000, managers, replicants.toArray(), new RoundRobin()); this.hastub = (Naming)Proxy.newProxyInstance( Naming.class.getClassLoader(), new Class[] { Naming.class }, this.hatarget); - log.info("Register with replicantManager as listener for HA-JNDI replicants"); - replicantManager.registerListener("HA-JNDI", this); + log.info("Register with replicantManager as listener for HAJNDI replicants"); + replicantManager.registerListener("HAJNDI", this); + replicantManager.registerListener("DistributedReplicantManager", this); log.info("Start listener"); try @@ -340,7 +345,7 @@ protected void listen() { - Thread t = new Thread(this, "HA-JNDI Server"); + Thread t = new Thread(this, "HAJNDI Server"); t.start(); } 1.3 +51 -11 jbossmx/src/main/org/jboss/ha/jndi/HAJNDI.java Index: HAJNDI.java =================================================================== RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/jndi/HAJNDI.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- HAJNDI.java 2001/09/18 13:59:28 1.2 +++ HAJNDI.java 2001/09/19 23:57:59 1.3 @@ -40,21 +40,25 @@ import org.jnp.server.NamingServer; import org.jboss.ha.HAPartition; import org.jboss.ha.HARMITarget; +import org.jboss.logging.Logger; + /** * <description> * * @see <related> * @author $Author: patriot1burke $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ public class HAJNDI extends NamingServer implements Naming, java.io.Serializable, HAPartition.HAPartitionStateTransfer { private HAPartition partition; + private Logger log; public HAJNDI(HAPartition partition) throws NamingException { super(); + log = Logger.create("HAJNDI"); this.partition = partition; } @@ -62,17 +66,21 @@ public void init() throws Exception { - partition.registerRPCHandler("HA-JNDI", this); - partition.subscribeToStateTransferEvents("HA-JNDI", this); + log.info("subscribeToStateTransferEvents"); + partition.subscribeToStateTransferEvents("HAJNDI", this); + log.info("registerRPCHandler"); + partition.registerRPCHandler("HAJNDI", this); } public Serializable getCurrentState() { + log.info("getCurrentState called"); return table; } public void setCurrentState(Serializable newState) { + log.info("setCurrentState called"); table.clear(); table.putAll((Hashtable)newState); } @@ -80,11 +88,17 @@ // Naming implementation ----------------------------------------- - public synchronized void bind(Name name, Object obj, String className) + public synchronized void _bind(Name name, Object obj, String className) throws NamingException { + log.info("_bind"); super.bind(name, obj, className); - + } + public synchronized void bind(Name name, Object obj, String className) + throws NamingException + { + log.info("bind"); + _bind(name, obj, className); // if we get here, this means we can do it on every node. Object[] args = new Object[3]; args[0] = name; @@ -92,7 +106,7 @@ args[2] = className; try { - partition.callMethodOnCluster("HA-JNDI", "bind", args, true); + partition.callMethodOnCluster("HAJNDI", "_bind", args, true); } catch (Exception ignored) { // FIXME is this right? @@ -102,6 +116,7 @@ public synchronized void rebind(Name name, Object obj, String className) throws NamingException { + log.info("rebind"); super.rebind(name, obj, className); // if we get here, this means we can do it on every node. @@ -111,7 +126,7 @@ args[2] = className; try { - partition.callMethodOnCluster("HA-JNDI", "rebind", args, true); + partition.callMethodOnCluster("HAJNDI", "rebind", args, true); } catch (Exception ignored) { @@ -122,6 +137,7 @@ public synchronized void unbind(Name name) throws NamingException { + log.info("unbind"); super.unbind(name); // if we get here, this means we can do it on every node. @@ -129,7 +145,7 @@ args[0] = name; try { - partition.callMethodOnCluster("HA-JNDI", "unbind", args, true); + partition.callMethodOnCluster("HAJNDI", "unbind", args, true); } catch (Exception ignored) { @@ -140,6 +156,7 @@ public Object lookup(Name name) throws NamingException { + log.info("lookup"); Object result = null; try { @@ -160,19 +177,40 @@ ArrayList rsp = null; try { - rsp = partition.callMethodOnCluster("HA-JNDI", "lookupLocally", args, true); + log.info("calling lookupLocally"); + rsp = partition.callMethodOnCluster("HAJNDI", "lookupLocally", args, true); } catch (Exception ignored) {} if (rsp == null || rsp.size() == 0) throw new NameNotFoundException(); - result = rsp.get(0); + for (int i = 0; i < rsp.size(); i++) + { + result = rsp.get(i); + log.info("_lookupLocally returned: " + result.getClass().getName()); + if (!(result instanceof NamingException)) + return result; + } + throw new NameNotFoundException(); } - } return result; } + public Object _lookupLocally(Name name) + { + log.info("_lookupLocally"); + try + { + return lookupLocally(name); + } + catch (NamingException ex) + { + log.info("_lookupLocally returning NameNotFoundException"); + return ex; + } + } public Object lookupLocally(Name name) throws NamingException { + log.info("lookupLocally"); return new InitialContext().lookup(name); } @@ -194,6 +232,7 @@ public Collection list(Name name) throws NamingException { + log.info("list"); Collection result = null; try { @@ -210,6 +249,7 @@ public Collection listBindings(Name name) throws NamingException { + log.info("listBindings"); Collection result = null; try { _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development