summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-10-03 17:30:41 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-10-03 17:30:41 +0200
commit275d0bbf555c8917be82ce4cc21eb4cabb00f4c5 (patch)
treeddcc6b14077d90d1b970b67829f07120547dbb62 /src/main/java/com/c2kernel/persistency/ClusterStorageManager.java
parenta139f95bfeca603333b8c0310ae09c6805e58584 (diff)
Huge exception overhaul: Merged ClusterStorageException with
PersistencyException. Replaced MembershipException with InvalidCollectionModification CORBA Exception. Made all predef steps throw more accurate exceptions when they go wrong, and let more exceptions bubble through from underneath.
Diffstat (limited to 'src/main/java/com/c2kernel/persistency/ClusterStorageManager.java')
-rw-r--r--src/main/java/com/c2kernel/persistency/ClusterStorageManager.java43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java
index 61e04a7..baabb19 100644
--- a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java
+++ b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java
@@ -27,7 +27,8 @@ import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
+import com.c2kernel.common.PersistencyException;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.entity.agent.JobList;
import com.c2kernel.entity.proxy.ProxyMessage;
@@ -60,10 +61,10 @@ public class ClusterStorageManager {
* 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.
*/
- public ClusterStorageManager(Authenticator auth) throws ClusterStorageException {
+ public ClusterStorageManager(Authenticator auth) throws PersistencyException {
Object clusterStorageProp = Gateway.getProperties().getObject("ClusterStorage");
if (clusterStorageProp == null || clusterStorageProp.equals("")) {
- throw new ClusterStorageException("ClusterStorageManager.init() - no ClusterStorages defined. No persistency!");
+ throw new PersistencyException("ClusterStorageManager.init() - no ClusterStorages defined. No persistency!");
}
ArrayList<ClusterStorage> rootStores;
@@ -77,20 +78,20 @@ public class ClusterStorageManager {
if (thisStore instanceof ClusterStorage)
rootStores.add((ClusterStorage)thisStore);
else
- throw new ClusterStorageException("Supplied ClusterStorage "+thisStore.toString()+" was not an instance of ClusterStorage");
+ throw new PersistencyException("Supplied ClusterStorage "+thisStore.toString()+" was not an instance of ClusterStorage");
}
}
else {
- throw new ClusterStorageException("Unknown class of ClusterStorage property: "+clusterStorageProp.getClass().getName());
+ throw new PersistencyException("Unknown class of ClusterStorage property: "+clusterStorageProp.getClass().getName());
}
int clusterNo = 0;
for (ClusterStorage newStorage : rootStores) {
try {
newStorage.open(auth);
- } catch (ClusterStorageException ex) {
+ } catch (PersistencyException ex) {
Logger.error(ex);
- throw new ClusterStorageException("ClusterStorageManager.init() - Error initialising storage handler " + newStorage.getClass().getName() +
+ throw new PersistencyException("ClusterStorageManager.init() - Error initialising storage handler " + newStorage.getClass().getName() +
": " + ex.getMessage());
}
Logger.msg(5, "ClusterStorageManager.init() - Cluster storage " + newStorage.getClass().getName() +
@@ -102,7 +103,7 @@ public class ClusterStorageManager {
}
- public ArrayList<ClusterStorage> instantiateStores(String allClusters) throws ClusterStorageException {
+ public ArrayList<ClusterStorage> instantiateStores(String allClusters) throws PersistencyException {
ArrayList<ClusterStorage> rootStores = new ArrayList<ClusterStorage>();
StringTokenizer tok = new StringTokenizer(allClusters, ",");
clusterPriority = new String[tok.countTokens()];
@@ -117,13 +118,13 @@ public class ClusterStorageManager {
newStorage = (ClusterStorage)(Class.forName("com.c2kernel.persistency."+newStorageClass).newInstance());
}
} catch (ClassNotFoundException ex) {
- throw new ClusterStorageException("ClusterStorageManager.init() - The cluster storage handler class " + newStorageClass +
+ throw new PersistencyException("ClusterStorageManager.init() - The cluster storage handler class " + newStorageClass +
" could not be found.");
} catch (InstantiationException ex) {
- throw new ClusterStorageException("ClusterStorageManager.init() - The cluster storage handler class " + newStorageClass +
+ throw new PersistencyException("ClusterStorageManager.init() - The cluster storage handler class " + newStorageClass +
" could not be instantiated.");
} catch (IllegalAccessException ex) {
- throw new ClusterStorageException("ClusterStorageManager.init() - The cluster storage handler class " + newStorageClass +
+ throw new PersistencyException("ClusterStorageManager.init() - The cluster storage handler class " + newStorageClass +
" was not allowed to be instantiated.");
}
rootStores.add(newStorage);
@@ -135,7 +136,7 @@ public class ClusterStorageManager {
for (ClusterStorage thisStorage : allStores.values()) {
try {
thisStorage.close();
- } catch (ClusterStorageException ex) {
+ } catch (PersistencyException ex) {
Logger.error(ex);
}
}
@@ -177,7 +178,7 @@ public class ClusterStorageManager {
* Retrieves the ids of the next level of a cluster
* Does not look in any currently open transactions.
*/
- public String[] getClusterContents(ItemPath itemPath, String path) throws ClusterStorageException {
+ public String[] getClusterContents(ItemPath itemPath, String path) throws PersistencyException {
ArrayList<String> contents = new ArrayList<String>();
// get all readers
@@ -194,7 +195,7 @@ public class ClusterStorageManager {
contents.add(thisArr[j]);
}
}
- } catch (ClusterStorageException e) {
+ } catch (PersistencyException e) {
Logger.msg(5, "ClusterStorageManager.getClusterContents() - reader " + thisReader.getName() +
" could not retrieve contents of " + itemPath + "/" + path + ": " + e.getMessage());
}
@@ -206,7 +207,7 @@ public class ClusterStorageManager {
}
/** Internal get method. Retrieves clusters from ClusterStorages & maintains the memory cache */
- public C2KLocalObject get(ItemPath itemPath, String path) throws ClusterStorageException, ObjectNotFoundException {
+ public C2KLocalObject get(ItemPath itemPath, String path) throws PersistencyException, ObjectNotFound {
C2KLocalObject result = null;
// check cache first
Map<String, C2KLocalObject> sysKeyMemCache = null;
@@ -271,23 +272,23 @@ public class ClusterStorageManager {
// then return it
return result;
}
- } catch (ClusterStorageException e) {
+ } catch (PersistencyException e) {
Logger.msg(7, "ClusterStorageManager.get() - reader " + thisReader.getName() + " could not retrieve " + itemPath +
"/" + path + ": " + e.getMessage());
}
}
- throw new ObjectNotFoundException("ClusterStorageManager.get() - Path " + path + " not found in " + itemPath, "");
+ throw new ObjectNotFound("ClusterStorageManager.get() - Path " + path + " not found in " + itemPath);
}
/** Internal put method. Creates or overwrites a cluster in all writers. Used when committing transactions. */
- public void put(ItemPath itemPath, C2KLocalObject obj) throws ClusterStorageException {
+ public void put(ItemPath itemPath, C2KLocalObject obj) throws PersistencyException {
String path = ClusterStorage.getPath(obj);
ArrayList<ClusterStorage> writers = findStorages(ClusterStorage.getClusterType(path), true);
for (ClusterStorage thisWriter : writers) {
try {
Logger.msg(7, "ClusterStorageManager.put() - writing "+path+" to "+thisWriter.getName());
thisWriter.put(itemPath, obj);
- } catch (ClusterStorageException e) {
+ } catch (PersistencyException e) {
Logger.error("ClusterStorageManager.put() - writer " + thisWriter.getName() + " could not store " +
itemPath + "/" + path + ": " + e.getMessage());
throw e;
@@ -317,13 +318,13 @@ public class ClusterStorageManager {
}
/** Deletes a cluster from all writers */
- public void remove(ItemPath itemPath, String path) throws ClusterStorageException {
+ public void remove(ItemPath itemPath, String path) throws PersistencyException {
ArrayList<ClusterStorage> writers = findStorages(ClusterStorage.getClusterType(path), true);
for (ClusterStorage thisWriter : writers) {
try {
Logger.msg(7, "ClusterStorageManager.delete() - removing "+path+" from "+thisWriter.getName());
thisWriter.delete(itemPath, path);
- } catch (ClusterStorageException e) {
+ } catch (PersistencyException e) {
Logger.error("ClusterStorageManager.delete() - writer " + thisWriter.getName() + " could not delete " + itemPath +
"/" + path + ": " + e.getMessage());
throw e;