1 19 package org.objectweb.carol.cmi; 20 21 import java.rmi.AlreadyBoundException ; 22 import java.rmi.ConnectException ; 23 import java.rmi.ConnectIOException ; 24 import java.rmi.NotBoundException ; 25 import java.rmi.Remote ; 26 import java.rmi.RemoteException ; 27 28 31 public class ClusterRegistryImpl_Cluster 32 implements ClusterStub, ClusterRegistryInternal { 33 private ClusterStubData csd; 34 private StubLB lb; 35 36 public ClusterRegistryImpl_Cluster(ClusterStubData csd) 38 throws RemoteException { 39 this.csd = csd; 40 lb = csd.getRandom(); 41 } 42 43 private void setLB() { 44 if (lb == null) { 45 lb = csd.getRandom(); 46 } 47 } 48 49 public String [] list() throws RemoteException { 50 setLB(); 51 StubData sd = lb.get(); 52 ClusterRegistryInternal stub = (ClusterRegistryInternal) sd.getStub(); 53 StubLBFilter filter = null; 54 do { 55 try { 56 java.lang.String [] result = stub.list(); 57 return result; 58 } catch (RemoteException e) { 59 if (!(e instanceof ConnectException ) 60 && !(e instanceof ConnectIOException )) { 61 throw e; 62 } 63 if (csd.isStubDebug()) { 64 csd.debug("Connection to registry refused, retry"); 65 } 66 if (filter == null) { 67 filter = new StubLBFilter(); 68 } 69 filter.add(sd); 70 sd = lb.get(filter); 71 stub = (ClusterRegistryInternal) sd.getStub(); 72 } 73 } while (true); 74 } 75 76 78 public void test() throws RemoteException { 79 setLB(); 80 StubData sd = lb.get(); 81 ClusterRegistryInternal stub = (ClusterRegistryInternal) sd.getStub(); 82 StubLBFilter filter = null; 83 do { 84 try { 85 stub.test(); 86 } catch (RemoteException e) { 87 if (!(e instanceof ConnectException ) 88 && !(e instanceof ConnectIOException )) { 89 throw e; 90 } 91 if (csd.isStubDebug()) { 92 csd.debug("Connection to registry refused, retry"); 93 } 94 if (filter == null) { 95 filter = new StubLBFilter(); 96 } 97 filter.add(sd); 98 sd = lb.get(filter); 99 stub = (ClusterRegistryInternal) sd.getStub(); 100 } 101 } while (true); 102 } 103 104 public Object lookup(String name) 105 throws NotBoundException , RemoteException { 106 setLB(); 107 StubData sd = lb.get(); 108 ClusterRegistryInternal stub = (ClusterRegistryInternal) sd.getStub(); 109 StubLBFilter filter = null; 110 do { 111 try { 112 return stub.lookup(name); 113 } catch (RemoteException e) { 114 if (!(e instanceof ConnectException ) 115 && !(e instanceof ConnectIOException )) { 116 throw e; 117 } 118 if (csd.isStubDebug()) { 119 csd.debug("Connection to registry refused, retry"); 120 } 121 if (filter == null) { 122 filter = new StubLBFilter(); 123 } 124 filter.add(sd); 125 sd = lb.get(filter); 126 stub = (ClusterRegistryInternal) sd.getStub(); 127 } 128 } while (true); 129 } 130 131 public void bindSingle(String name, Remote obj) 132 throws AlreadyBoundException , RemoteException { 133 throw new RemoteException ("Can't bind into multiple servers"); 134 } 135 136 public void rebindSingle(String name, Remote obj) 137 throws RemoteException { 138 throw new RemoteException ("Can't rebind into multiple servers"); 139 } 140 141 public void bindCluster(String name, byte[] obj) 142 throws AlreadyBoundException , RemoteException { 143 csd.getLocal(); 144 throw new RemoteException ("Can't bind into multiple servers"); 145 } 148 149 public void rebindCluster(String name, byte[] obj) 150 throws RemoteException { 151 csd.getLocal(); 152 throw new RemoteException ("Can't rebind into multiple servers"); 153 } 156 157 public void unbind(java.lang.String name) 158 throws NotBoundException , RemoteException { 159 csd.getLocal(); 160 throw new RemoteException ("Can't unbind from multiple servers"); 161 } 164 } 165 | Popular Tags |