summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorogattaz <olivier@gattaz.com>2014-08-28 10:57:11 +0200
committerogattaz <olivier@gattaz.com>2014-08-28 10:57:11 +0200
commitacc72802a1e5374b9654c865c9843fd70e544d35 (patch)
treebc471354a549c8ce18a54f5deb8ab4d88513da6f /src/main/java
parentf37883c23f9032ace7e0e780fa0e641859863c0c (diff)
Put in place a protection in the constructor to set the size of the
"clusterPriority" at the right size according the fact that the "clusterStorageProp" property could contains a List of instances of String and/or ClusterStorage
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/c2kernel/persistency/ClusterStorageManager.java35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java
index b1489e0..5227ab8 100644
--- a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java
+++ b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java
@@ -23,9 +23,10 @@ import com.c2kernel.utils.WeakCache;
/**
* instantiates ClusterStorages listed in properties file All read/write requests to storage pass through this object, which
* can query the capabilities of each declared storage, and channel requests accordingly. Transaction based.
- *
- * * @version $Revision: 1.62 $ $Date: 2006/02/01 13:27:46 $
- * @author $Author: abranson $
+ *
+ * @author abranson
+ * @author ogattaz
+ *
*/
public class ClusterStorageManager {
HashMap<String, ClusterStorage> allStores = new HashMap<String, ClusterStorage>();
@@ -35,10 +36,20 @@ public class ClusterStorageManager {
// we don't need a soft cache for the top level cache - the proxies and entities clear that when reaped
HashMap<Integer, Map<String, C2KLocalObject>> memoryCache = new HashMap<Integer, Map<String, C2KLocalObject>>();
- /**
- * Initialises all ClusterStorage handlers listed by class name in the property "ClusterStorages"
- * This property is usually process specific, and so should be in the server/client.conf and not the connect file.
- */
+ /**
+ * Initialises all ClusterStorage handlers listed by class name in the
+ * property "ClusterStorages" This property is usually process specific, and
+ * so should be in the server/client.conf and not the connect file.
+ *
+ * 2014/08/28 ogattaz : put in place a protection in the constructor : set
+ * the clusterPriority at the right size according the fact that the
+ * "clusterStorageProp" property could contains a List of instance of String
+ * and/or ClusterStorage
+ *
+ * @param auth
+ * an instance of Authenticator
+ * @throws ClusterStorageException
+ */
public ClusterStorageManager(Authenticator auth) throws ClusterStorageException {
Object clusterStorageProp = Gateway.getProperties().getObject("ClusterStorage");
if (clusterStorageProp == null || clusterStorageProp.equals("")) {
@@ -49,9 +60,13 @@ public class ClusterStorageManager {
if (clusterStorageProp instanceof String)
rootStores = instantiateStores((String)clusterStorageProp);
else if (clusterStorageProp instanceof ArrayList<?>) {
- ArrayList<?> propStores = (ArrayList<?>)clusterStorageProp;
+ ArrayList<?> wTempStorages = (ArrayList<?>)clusterStorageProp;
+
+ // set the clusterPriority at the right size
+ clusterPriority = new String[wTempStorages.size()];
+
rootStores = new ArrayList<ClusterStorage>();
- for (Object thisStore : propStores) {
+ for (Object thisStore : wTempStorages) {
if (thisStore instanceof ClusterStorage)
rootStores.add((ClusterStorage)thisStore);
else
@@ -74,7 +89,7 @@ public class ClusterStorageManager {
Logger.msg(5, "ClusterStorageManager.init() - Cluster storage " + newStorage.getClass().getName() +
" initialised successfully.");
allStores.put(newStorage.getId(), newStorage);
- clusterPriority[clusterNo++] = newStorage.getId();
+ clusterPriority[clusterNo++] = newStorage.getId();
}
clusterReaders.put(ClusterStorage.ROOT, rootStores); // all storages are queried for clusters at the root level