use of org.cristalise.kernel.entity.agent.JobList in project kernel by cristal-ise.
the class ClusterStorageManager method get.
/**
* Internal get method. Retrieves clusters from ClusterStorages & maintains the memory cache.
* <br>
* There is a special case for Viewpoint. When path ends with /data it returns referenced Outcome instead of Viewpoint.
*
* @param itemPath current Iten
* @param path the cluster path
* @return the C2KObject located by path
*/
public C2KLocalObject get(ItemPath itemPath, String path) throws PersistencyException, ObjectNotFoundException {
// check cache first
Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(itemPath);
if (sysKeyMemCache != null) {
synchronized (sysKeyMemCache) {
C2KLocalObject obj = sysKeyMemCache.get(path);
if (obj != null) {
Logger.msg(7, "ClusterStorageManager.get() - found " + itemPath + "/" + path + " in memcache");
return obj;
}
}
}
// special case for Viewpoint- When path ends with /data it returns referenced Outcome instead of Viewpoint
if (path.startsWith(VIEWPOINT.getName()) && path.endsWith("/data")) {
StringTokenizer tok = new StringTokenizer(path, "/");
if (tok.countTokens() == 4) {
// to not catch viewpoints called 'data'
Viewpoint view = (Viewpoint) get(itemPath, path.substring(0, path.lastIndexOf("/")));
if (view != null)
return view.getOutcome();
else
return null;
}
}
C2KLocalObject result = null;
// deal out top level remote maps
if (path.indexOf('/') == -1) {
if (path.equals(HISTORY.getName())) {
result = new History(itemPath, null);
} else if (path.equals(JOB.getName())) {
if (itemPath instanceof AgentPath)
result = new JobList((AgentPath) itemPath, null);
else
throw new ObjectNotFoundException("Items do not have job lists");
}
}
if (result == null) {
// else try each reader in turn until we find it
ArrayList<ClusterStorage> readers = findStorages(ClusterStorage.getClusterType(path), false);
for (ClusterStorage thisReader : readers) {
try {
result = thisReader.get(itemPath, path);
Logger.msg(7, "ClusterStorageManager.get() - reading " + path + " from " + thisReader.getName() + " for item " + itemPath);
// got it!
if (result != null)
break;
} catch (PersistencyException e) {
Logger.msg(7, "ClusterStorageManager.get() - reader " + thisReader.getName() + " could not retrieve " + itemPath + "/" + path + ": " + e.getMessage());
}
}
}
// No result was found after reading the list of ClusterStorages
if (result == null) {
throw new ObjectNotFoundException("ClusterStorageManager.get() - Path " + path + " not found in " + itemPath);
}
putInMemoryCache(itemPath, path, result);
return result;
}
Aggregations