public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation routingDecision) { Object target = clusterFamily.getObject (); List targets = clusterFamily.getTargets (); if (targets.size () == 0) return null; if (target != null && targets.contains (target) ) { return target; } else { int cursor = RandomRobin.localRandomizer.nextInt (targets.size()); target = targets.get(cursor); clusterFamily.setObject (target); return target; } }
protected void removeDeadTarget(Object target) { //System.out.println("Size before : " + Integer.toString(targets.length)); if (this.familyClusterInfo != null) this.familyClusterInfo.removeDeadTarget (target); }
protected void resetView() { this.familyClusterInfo.resetView(); }
public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation routingDecision) { int cursor = clusterFamily.getCursor (); List targets = clusterFamily.getTargets (); if (targets.size () == 0) return null; if (cursor == FamilyClusterInfo.UNINITIALIZED_CURSOR) { // Obtain a random index into targets cursor = RandomRobin.localRandomizer.nextInt(targets.size()); } else { // Choose the next target cursor = ( (cursor + 1) % targets.size() ); } clusterFamily.setCursor (cursor); return targets.get(cursor); }
@SuppressWarnings("unchecked") private void writeObject (ObjectOutputStream stream) throws IOException { // JBAS-2071 - sync on FCI to ensure targets and vid are consistent ArrayList currentTargets = null; long vid = 0; synchronized (this.familyClusterInfo) { // JBAS-6345 -- write an ArrayList for compatibility with AS 3.x/4.x clients currentTargets = new ArrayList(this.familyClusterInfo.getTargets()); vid = this.familyClusterInfo.getCurrentViewId (); } stream.writeUTF(key); stream.writeObject(currentTargets); stream.writeLong(vid); stream.writeObject(loadBalancePolicy); }
protected int totalNumberOfTargets() { if(this.familyClusterInfo != null) { return this.familyClusterInfo.getTargets().size(); } else { return 0; } }
public Object invoke (Invocation mi) throws Throwable { Object data = mi.getValue ("DO_FAIL_DURING_NEXT_CALL"); if (data != null && data instanceof java.lang.Boolean && data.equals (java.lang.Boolean.TRUE)) { // Clear the instruction mi.setValue ("DO_FAIL_DURING_NEXT_CALL", Boolean.FALSE, PayloadKey.AS_IS); if (proxyFamilyName == null) { proxyFamilyName = getProxyFamilyName(mi); } // Clear the targets to simulate exhausting them all FamilyClusterInfo info = ClusteringTargetsRepository.getFamilyClusterInfo(proxyFamilyName); for (Object target: info.getTargets()) info.removeDeadTarget(target); throw new ServiceUnavailableException("Service unavailable", new Exception("Test")); } return getNext().invoke(mi); }
public void updateClusterInfo (List<?> targets, long viewId) { if (familyClusterInfo != null) this.familyClusterInfo.updateClusterInfo (targets, viewId); }
HARMIResponse rsp = target.invoke(this.familyClusterInfo.getCurrentViewId (), mi); if (rsp.newReplicants != null)
/** Externalize this instance. */ @SuppressWarnings("unchecked") public void writeExternal(final ObjectOutput out) throws IOException { // JBAS-2071 - sync on FCI to ensure targets and vid are consistent ArrayList currentTargets = null; long vid = 0; synchronized (this.familyClusterInfo) { // JBAS-6345 -- write an ArrayList for compatibility with AS 3.x/4.x clients currentTargets = new ArrayList(this.familyClusterInfo.getTargets()); vid = this.familyClusterInfo.getCurrentViewId (); } out.writeObject(currentTargets); out.writeLong(vid); out.writeObject(this.loadBalancePolicy); out.writeObject(this.proxyFamilyName); }
protected int totalNumberOfTargets () { int size = 0; if( familyClusterInfo != null ) size = familyClusterInfo.getTargets().size(); return size; }
public void updateClusterInfo (List<?> targets, long viewId) { if (familyClusterInfo != null) this.familyClusterInfo.updateClusterInfo (targets, viewId); }
mi.setValue("CLUSTER_VIEW_ID", new Long(familyClusterInfo.getCurrentViewId())); String target = (String) getRemoteTarget(invocation); boolean failoverAuthorized = true;
/** * Externalize this instance and handle obtaining the remoteInvoker stub */ public void writeExternal(final ObjectOutput out) throws IOException { out.writeInt(CURRENT_VERSION); out.writeUTF(getLocator().getOriginalURI()); out.writeBoolean(isStrictRMIException()); // JBAS-2071 - sync on FCI to ensure targets and vid are consistent ArrayList targets = null; long vid = 0; synchronized (this.familyClusterInfo) { // JBAS-6345 -- write an ArrayList for compatibility with AS 3.x/4.x clients targets = new ArrayList(this.familyClusterInfo.getTargets ()); vid = this.familyClusterInfo.getCurrentViewId (); } out.writeObject(targets); out.writeObject(this.loadBalancePolicy); out.writeObject(this.proxyFamilyName); out.writeLong(vid); }
public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation routingDecision) { List targets = clusterFamily.getTargets (); int max = targets.size(); if (max == 0) return null; int cursor = localRandomizer.nextInt (max); return targets.get(cursor); }
private void removeDeadTarget(InvokerLocator locator) { if(locator != null) { if(this.familyClusterInfo != null) { familyClusterInfo.removeDeadTarget(locator); if (trace) { log.trace("Removed " + locator + " from target list."); } } } }
public void updateClusterInfo(List<?> newReplicants, long currentViewId) { if(familyClusterInfo != null) { familyClusterInfo.updateClusterInfo(newReplicants, currentViewId); if (trace) { log.trace("Updating cluster info. New view id: " + currentViewId); log.trace("New cluster target list is:"); for(int x = 0; x < newReplicants.size(); x++) { log.trace(newReplicants.get(x)); } } } }
protected void resetView () { familyClusterInfo.resetView(); }
while(familyClusterInfo.getTargets() != null && familyClusterInfo.getTargets().size() > 0 && failoverAuthorized) invocation.setValue("CLUSTER_VIEW_ID", new Long(this.familyClusterInfo.getCurrentViewId())); log.trace("Client cluster view id: " + familyClusterInfo.getCurrentViewId()); log.trace(printPossibleTargets());
private Object printPossibleTargets() { StringBuffer buffer = new StringBuffer(); if(familyClusterInfo != null) { List possibleTargets = familyClusterInfo.getTargets(); if(possibleTargets != null && possibleTargets.size() > 0) { for(int x = 0; x < possibleTargets.size(); x++) { buffer.append("\nPossible target " + (x + 1) + ": " + possibleTargets.get(x)); } } } return buffer.toString(); }