public void destroy() { try { target.destroy(); HARMIServer.rmiServers.remove(key); UnicastRemoteObject.unexportObject(this, true); } catch (Exception e) { log.error("failed to destroy", e); } }
public synchronized void replicantsChanged(String key, List<?> newReplicants, int newReplicantsViewId, boolean merge) { super.replicantsChanged (key, newReplicants, newReplicantsViewId, merge); initGeneratedProxies(); // we now update all generated proxies // List<SoftReference<HARMIClient>> trash = new ArrayList<SoftReference<HARMIClient>>(); for (SoftReference<HARMIClient> ref : generatedProxies) { HARMIClient proxy = ref.get (); if (proxy == null) { trash.add (ref); } else { proxy.updateClusterInfo (this.replicants, this.clusterViewId); } } if (trash.size () > 0) generatedProxies.removeAll(trash); }
this.target = new RefreshProxiesHATarget(partition, replicantName, rmistub, HATarget.ENABLE_INVOCATIONS);
public HARMIResponse invoke(long clientViewId, MarshalledInvocation mi) throws Exception { mi.setMethodMap(invokerMap); Method method = mi.getMethod(); try { HARMIResponse rsp = new HARMIResponse(); if (clientViewId != target.getCurrentViewId()) { rsp.newReplicants = new ArrayList<Object>(target.getReplicantList()); rsp.currentViewId = target.getCurrentViewId(); } rsp.response = method.invoke(handler, mi.getArguments()); return rsp; } catch (IllegalAccessException iae) { throw iae; } catch (IllegalArgumentException iae) { throw iae; } catch (java.lang.reflect.InvocationTargetException ite) { throw (Exception)ite.getTargetException(); } }
/** * Once a HARMIServer implementation exists, it is possible to ask for a stub that can, for example, * be bound in JNDI for client use. Each client stub may incorporate a specific load-balancing * policy. * * @param policy {@link org.jboss.ha.client.loadbalance.LoadBalancePolicy} implementation to ues on the client. * @return proxy instance object */ public Object createHAStub(LoadBalancePolicy policy) { HARMIClient client = new HARMIClient(target.getReplicantList(), target.getCurrentViewId (), policy, key, handler); this.target.addProxy (client); return Proxy.newProxyInstance( intf.getClassLoader(), new Class[]{ intf, HARMIProxy.class }, client); }
public List<?> getReplicants() throws Exception { return target.getReplicantList(); }
public synchronized void addProxy (HARMIClient client) { initGeneratedProxies(); generatedProxies.add (new SoftReference<HARMIClient>(client)); }