summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-09-09 12:13:21 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-09-09 12:13:21 +0200
commitda731d2bb81666b9c697d9099da632e7dfcdc0f7 (patch)
tree567693c3c48f3d15ecbb2dac4f9db03bb6e58c72 /src/main/java/com/c2kernel/entity/proxy/ItemProxy.java
parentae1e79e33fd30e3d8bcedbef8891a14a048276d7 (diff)
Replaced int sysKey Item identifier with UUID, which is now portable.
ItemPath objects are now used to identify Items throughout the kernel, replacing ints and Integers.
Diffstat (limited to 'src/main/java/com/c2kernel/entity/proxy/ItemProxy.java')
-rw-r--r--src/main/java/com/c2kernel/entity/proxy/ItemProxy.java95
1 files changed, 32 insertions, 63 deletions
diff --git a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java
index 454da6d..987873f 100644
--- a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java
+++ b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java
@@ -34,9 +34,8 @@ import com.c2kernel.entity.agent.Job;
import com.c2kernel.entity.agent.JobArrayList;
import com.c2kernel.lifecycle.instance.CompositeActivity;
import com.c2kernel.lifecycle.instance.Workflow;
-import com.c2kernel.lookup.InvalidItemPathException;
+import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.Path;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.outcome.Viewpoint;
@@ -57,9 +56,8 @@ public class ItemProxy
{
protected Item mItem = null;
+ protected ItemPath mItemPath;
protected org.omg.CORBA.Object mIOR;
- protected int mSystemKey;
- protected Path mPath;
private final HashMap<MemberSubscription<?>, ProxyObserver<?>>
mSubscriptions;
@@ -67,29 +65,18 @@ public class ItemProxy
*
**************************************************************************/
protected ItemProxy( org.omg.CORBA.Object ior,
- int systemKey)
- throws ObjectNotFoundException
+ ItemPath itemPath)
{
- Logger.msg(8, "ItemProxy::initialise() - Initialising entity " +systemKey);
+ Logger.msg(8, "ItemProxy::initialise() - Initialising item proxy " +itemPath);
mIOR = ior;
- mSystemKey = systemKey;
+ mItemPath = itemPath;
mSubscriptions = new HashMap<MemberSubscription<?>, ProxyObserver<?>>();
- try {
- mPath = new ItemPath(systemKey);
- } catch (InvalidItemPathException e) {
- throw new ObjectNotFoundException();
- }
}
-
- public int getSystemKey()
- {
- return mSystemKey;
- }
- public Path getPath() {
- return mPath;
+ public ItemPath getPath() {
+ return mItemPath;
}
protected Item getItem() throws ObjectNotFoundException {
@@ -105,23 +92,13 @@ public class ItemProxy
} catch (org.omg.CORBA.BAD_PARAM ex) { }
throw new ObjectNotFoundException("CORBA Object was not an Item, or the server is down.");
}
- /**
- * @throws MappingException
- * @throws IOException
- * @throws ValidationException
- * @throws MarshalException ************************************************************************
- *
- *
- **************************************************************************/
- public void initialise( int agentId,
+
+ public void initialise( AgentPath agentId,
PropertyArrayList itemProps,
CompositeActivity workflow,
CollectionArrayList colls
)
- throws AccessRightsException,
- InvalidDataException,
- PersistencyException,
- ObjectNotFoundException, MarshalException, ValidationException, IOException, MappingException
+ throws AccessRightsException, InvalidDataException, PersistencyException, ObjectNotFoundException, MarshalException, ValidationException, IOException, MappingException
{
Logger.msg(7, "ItemProxy::initialise - started");
CastorXMLUtility xml = Gateway.getMarshaller();
@@ -132,7 +109,7 @@ public class ItemProxy
String collString = "";
if (colls != null) collString = xml.marshall(colls);
- getItem().initialise( agentId, propString, wfString, collString);
+ getItem().initialise( agentId.getSystemKey(), propString, wfString, collString);
}
public void setProperty(AgentProxy agent, String name, String value)
@@ -174,25 +151,25 @@ public class ItemProxy
else
outcome="";
- if (thisJob.getAgentId() == -1)
+ if (thisJob.getAgentPath() == null)
throw new InvalidDataException("No Agent specified.", "");
Logger.msg(7, "ItemProxy - executing "+thisJob.getStepPath()+" for "+thisJob.getAgentName());
- return getItem().requestAction (thisJob.getAgentId(), thisJob.getStepPath(),
+ return getItem().requestAction (thisJob.getAgentPath().getSystemKey(), thisJob.getStepPath(),
thisJob.getTransition().getId(), outcome);
}
/**************************************************************************
*
**************************************************************************/
- private ArrayList<Job> getJobList(int agentId, boolean filter)
+ private ArrayList<Job> getJobList(AgentPath agentPath, boolean filter)
throws AccessRightsException,
ObjectNotFoundException,
PersistencyException
{
JobArrayList thisJobList;
try {
- String jobs = getItem().queryLifeCycle(agentId, filter);
+ String jobs = getItem().queryLifeCycle(agentPath.getSystemKey(), filter);
thisJobList = (JobArrayList)Gateway.getMarshaller().unmarshall(jobs);
}
catch (Exception e) {
@@ -207,23 +184,15 @@ public class ItemProxy
ObjectNotFoundException,
PersistencyException
{
- return getJobList(agent.getSystemKey());
- }
-
- private ArrayList<Job> getJobList(int agentId)
- throws AccessRightsException,
- ObjectNotFoundException,
- PersistencyException
- {
- return getJobList(agentId, true);
+ return getJobList(agent.getPath(), true);
}
- private Job getJobByName(String actName, int agentId)
+ private Job getJobByName(String actName, AgentPath agent)
throws AccessRightsException,
ObjectNotFoundException,
PersistencyException {
- ArrayList<Job> jobList = getJobList(agentId);
+ ArrayList<Job> jobList = getJobList(agent, true);
for (Job job : jobList) {
if (job.getStepName().equals(actName) && job.hasOutcome())
return job;
@@ -248,7 +217,7 @@ public class ItemProxy
throws AccessRightsException,
ObjectNotFoundException,
PersistencyException {
- return getJobByName(actName, agent.getSystemKey());
+ return getJobByName(actName, agent.getPath());
}
/**
@@ -256,9 +225,9 @@ public class ItemProxy
*/
@Override
protected void finalize() throws Throwable {
- Logger.msg(7, "Proxy "+mSystemKey+" reaped");
- Gateway.getStorage().clearCache(mSystemKey, null);
- Gateway.getProxyManager().removeProxy(mSystemKey);
+ Logger.msg(7, "Proxy "+mItemPath+" reaped");
+ Gateway.getStorage().clearCache(mItemPath, null);
+ Gateway.getProxyManager().removeProxy(mItemPath);
super.finalize();
}
@@ -270,10 +239,10 @@ public class ItemProxy
{
try {
- Logger.msg(7, "EntityProxy.queryData() - "+mSystemKey+"/"+path);
+ Logger.msg(7, "EntityProxy.queryData() - "+mItemPath+"/"+path);
if (path.endsWith("all")) {
Logger.msg(7, "EntityProxy.queryData() - listing contents");
- String[] result = Gateway.getStorage().getClusterContents(mSystemKey, path.substring(0, path.length()-3));
+ String[] result = Gateway.getStorage().getClusterContents(mItemPath, path.substring(0, path.length()-3));
StringBuffer retString = new StringBuffer();
for (int i = 0; i < result.length; i++) {
retString.append(result[i]);
@@ -282,7 +251,7 @@ public class ItemProxy
Logger.msg(7, "EntityProxy.queryData() - "+retString.toString());
return retString.toString();
}
- C2KLocalObject target = Gateway.getStorage().get(mSystemKey, path, null);
+ C2KLocalObject target = Gateway.getStorage().get(mItemPath, path, null);
return Gateway.getMarshaller().marshall(target);
} catch (ObjectNotFoundException e) {
throw e;
@@ -294,7 +263,7 @@ public class ItemProxy
public String[] getContents( String path ) throws ObjectNotFoundException {
try {
- return Gateway.getStorage().getClusterContents(mSystemKey, path.substring(0, path.length()));
+ return Gateway.getStorage().getClusterContents(mItemPath, path.substring(0, path.length()));
} catch (ClusterStorageException e) {
throw new ObjectNotFoundException(e.toString());
}
@@ -310,11 +279,11 @@ public class ItemProxy
// load from storage, falling back to proxy loader if not found in others
try
{
- return Gateway.getStorage().get( mSystemKey, xpath , null);
+ return Gateway.getStorage().get( mItemPath, xpath , null);
}
catch( ClusterStorageException ex )
{
- Logger.msg(4, "Exception loading object :"+mSystemKey+"/"+xpath);
+ Logger.msg(4, "Exception loading object :"+mItemPath+"/"+xpath);
throw new ObjectNotFoundException( ex.toString() );
}
}
@@ -324,7 +293,7 @@ public class ItemProxy
public String getProperty( String name )
throws ObjectNotFoundException
{
- Logger.msg(5, "Get property "+name+" from syskey/"+mSystemKey);
+ Logger.msg(5, "Get property "+name+" from item "+mItemPath);
Property prop = (Property)getObject("Property/"+name);
try
{
@@ -377,7 +346,7 @@ public class ItemProxy
public void dumpSubscriptions(int logLevel) {
if (mSubscriptions.size() == 0) return;
- Logger.msg(logLevel, "Subscriptions to proxy "+mSystemKey+":");
+ Logger.msg(logLevel, "Subscriptions to proxy "+mItemPath+":");
synchronized(this) {
for (MemberSubscription<?> element : mSubscriptions.keySet()) {
ProxyObserver<?> obs = element.getObserver();
@@ -390,10 +359,10 @@ public class ItemProxy
}
public void notify(ProxyMessage message) {
- Logger.msg(4, "EntityProxy.notify() - Received change notification for "+message.getPath()+" on "+mSystemKey);
+ Logger.msg(4, "EntityProxy.notify() - Received change notification for "+message.getPath()+" on "+mItemPath);
synchronized (this){
if (Gateway.getProxyServer()== null || !message.getServer().equals(Gateway.getProxyServer().getServerName()))
- Gateway.getStorage().clearCache(mSystemKey, message.getPath());
+ Gateway.getStorage().clearCache(mItemPath, message.getPath());
for (Iterator<MemberSubscription<?>> e = mSubscriptions.keySet().iterator(); e.hasNext();) {
MemberSubscription<?> newSub = e.next();
if (newSub.getObserver() == null) { // phantom