protected int totalNumberOfTargets() { if(this.familyClusterInfo != null) { return this.familyClusterInfo.getTargets().size(); } else { return 0; } }
protected int totalNumberOfTargets () { int size = 0; if( familyClusterInfo != null ) size = familyClusterInfo.getTargets().size(); return size; }
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 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(); }
public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation routingDecision) { List targets = clusterFamily.getTargets (); if (targets.size () == 0) return null; if ( (this.electedTarget != null) && targets.contains (this.electedTarget) ) { return this.electedTarget; } else { int cursor = RandomRobin.localRandomizer.nextInt(targets.size()); this.electedTarget = targets.get(cursor); return this.electedTarget; } } }
@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); }
/** 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); }
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; } }
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); }
/** * This method returns either, a new target based on RoundRobin policy, or * if there's a ongoing transaction, the target associated with that * transaction. * * @param familyClusterInfo cluster family information * @param invocation current invocation * @return a new target or the target associated with the transaction */ public Object chooseTarget(FamilyClusterInfo clusterFamily, Invocation routingDecision) { trace = log.isTraceEnabled(); Object txStickyTarget = routingDecision.getTransientValue("TX_STICKY_TARGET"); if (txStickyTarget != null && clusterFamily.getTargets().contains(txStickyTarget)) { if (trace) { log.trace("Transaction bound target exists: " + txStickyTarget); } return txStickyTarget; } return chooseNewTarget(clusterFamily, routingDecision); }
/** * 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); }
if (getFamilyClusterInfo(invocation).getTargets().contains(stickyTarget))
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); }
while(familyClusterInfo.getTargets() != null && familyClusterInfo.getTargets().size() > 0 && failoverAuthorized)