[jboss-cvs] JBossCache/src/org/jboss/cache ...
Vladmir Blagojevic
vladimir.blagojevic at jboss.com
Tue Apr 24 11:27:22 EDT 2007
User: vblagojevic
Date: 07/04/24 11:27:21
Modified: src/org/jboss/cache RegionManager.java CacheImpl.java
Log:
strong type fetchPartialState invocation
Revision Changes Path
1.36 +5 -19 JBossCache/src/org/jboss/cache/RegionManager.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RegionManager.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/RegionManager.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- RegionManager.java 23 Apr 2007 15:56:30 -0000 1.35
+++ RegionManager.java 24 Apr 2007 15:27:21 -0000 1.36
@@ -384,23 +384,8 @@
subtreeRoot = cache.createSubtreeRootNode(fqn);
}
- Address[] groupMembers = null;
List<Address> members = cache.getMembers();
- synchronized (members)
- {
- groupMembers = members.toArray(new Address[members.size()]);
- }
- if (groupMembers.length < 2)
- {
- if (log.isDebugEnabled())
- {
- log.debug("No nodes able to give state");
- }
- }
- else
- {
- cache.fetchPartialState(groupMembers, subtreeRoot.getFqn());
- }
+ cache.fetchPartialState(members, subtreeRoot.getFqn());
}
else
{
@@ -410,7 +395,8 @@
for (Iterator it = buddies.iterator(); it.hasNext();)
{
Address buddy = (Address) it.next();
- Object sources[] = new Object[]{buddy};
+ List <Address> sources = new ArrayList<Address>(1);
+ sources.add(buddy);
Fqn base = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(buddy));
Fqn buddyRoot = new Fqn(base, fqn);
subtreeRoot = cache.findNode(buddyRoot);
1.60 +10 -10 JBossCache/src/org/jboss/cache/CacheImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheImpl.java,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- CacheImpl.java 20 Apr 2007 12:10:12 -0000 1.59
+++ CacheImpl.java 24 Apr 2007 15:27:21 -0000 1.60
@@ -77,7 +77,6 @@
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
@@ -463,13 +462,13 @@
}
}
- public void fetchPartialState(Object sources[], Fqn sourceTarget, Fqn integrationTarget) throws Exception
+ void fetchPartialState(List <Address> sources, Fqn sourceTarget, Fqn integrationTarget) throws Exception
{
String encodedStateId = sourceTarget + StateTransferManager.PARTIAL_STATE_DELIMITER + integrationTarget;
fetchPartialState(sources, encodedStateId);
}
- public void fetchPartialState(Object sources[], Fqn subtree) throws Exception
+ void fetchPartialState(List <Address> sources, Fqn subtree) throws Exception
{
if (subtree == null)
{
@@ -478,22 +477,22 @@
fetchPartialState(sources, subtree.toString());
}
- private void fetchPartialState(Object sources[], String stateId) throws Exception
+ private void fetchPartialState(List <Address> sources, String stateId) throws Exception
{
- if (sources == null || sources.length < 1 || stateId == null)
+ if (sources == null || sources.isEmpty() || stateId == null)
{
// should this really be throwing an exception? Are there valid use cases where partial state may not be available? - Manik
// Yes -- cache is configured LOCAL but app doesn't know it -- Brian
//throw new IllegalArgumentException("Cannot fetch partial state, targets are " + sources + " and stateId is " + stateId);
if (log.isWarnEnabled())
{
- log.warn("Cannot fetch partial state, targets are " + Arrays.asList(sources) +
+ log.warn("Cannot fetch partial state, targets are " + sources +
" and stateId is " + stateId);
}
return;
}
- List<Address> targets = new LinkedList(Arrays.asList(sources));
+ List<Address> targets = new LinkedList<Address>(sources);
//skip *this* node as a target
targets.remove(getLocalAddress());
@@ -508,9 +507,8 @@
log.debug("Node " + getLocalAddress() + " fetching partial state " + stateId + " from members " + targets);
boolean successfulTransfer = false;
- for (Iterator iter = targets.iterator(); iter.hasNext() && !successfulTransfer;)
+ for (Address target: targets)
{
- Address target = (Address) iter.next();
log.debug("Node " + getLocalAddress() + " fetching partial state " + stateId + " from member " + target);
isStateSet = false;
successfulTransfer = channel.getState(target, stateId, getStateFetchTimeout());
@@ -526,6 +524,8 @@
}
}
log.debug("Node " + getLocalAddress() + " fetching partial state " + stateId + " from member " + target + (successfulTransfer ? " successful" : " failed"));
+ if(successfulTransfer)
+ break;
}
if (!successfulTransfer)
More information about the jboss-cvs-commits
mailing list