diff options
| author | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
|---|---|---|
| committer | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
| commit | 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch) | |
| tree | 5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/entity/agent | |
| parent | 036cbdba66f804743c4c838ed598d6972c4b3e17 (diff) | |
More code cleanup:
Refactored Entity Proxy Subscription to handle generics better
Rewrote RemoteMap to use TreeMap instead of the internal array for
order. It now sorts its keys by number if they parse, else as strings.
Removed a no-longer-in-progress outcome form class
Diffstat (limited to 'source/com/c2kernel/entity/agent')
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/entity/agent/ActiveEntity.java | 76 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/entity/agent/ActiveLocator.java | 8 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/entity/agent/Job.java | 17 | ||||
| -rw-r--r-- | source/com/c2kernel/entity/agent/JobArrayList.java | 8 | ||||
| -rw-r--r-- | source/com/c2kernel/entity/agent/JobList.java | 41 |
5 files changed, 75 insertions, 75 deletions
diff --git a/source/com/c2kernel/entity/agent/ActiveEntity.java b/source/com/c2kernel/entity/agent/ActiveEntity.java index cb77bbb..3d45e35 100755..100644 --- a/source/com/c2kernel/entity/agent/ActiveEntity.java +++ b/source/com/c2kernel/entity/agent/ActiveEntity.java @@ -12,7 +12,12 @@ package com.c2kernel.entity.agent; import java.util.Iterator;
-import com.c2kernel.common.*;
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.CannotManageException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.ObjectCannotBeUpdated;
+import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.PersistencyException;
import com.c2kernel.entity.AgentPOA;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.lookup.AgentPath;
@@ -21,6 +26,7 @@ import com.c2kernel.lookup.RolePath; import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.TransactionManager;
import com.c2kernel.process.Gateway;
+import com.c2kernel.property.Property;
import com.c2kernel.property.PropertyArrayList;
import com.c2kernel.utils.CastorXMLUtility;
import com.c2kernel.utils.Logger;
@@ -48,13 +54,13 @@ public class ActiveEntity extends AgentPOA * Connection to the persistency backeng
**************************************************************************/
private TransactionManager mDatabase = null;
-
+
/**************************************************************************
- * The agent's joblist
+ * The agent's joblist
**************************************************************************/
private JobList currentJobs;
/**
- *
+ *
* @param key
* @param poa
*/
@@ -73,7 +79,8 @@ public class ActiveEntity extends AgentPOA /**
* initialise cristal2 properties & collector
*/
- public void initialise( String agentProps )
+ @Override
+ public void initialise( String agentProps )
throws AccessRightsException,
InvalidDataException,
PersistencyException
@@ -99,7 +106,7 @@ public class ActiveEntity extends AgentPOA }
/**
- *
+ *
* @param propsString
* @return Properties
* @throws InvalidDataException Properties cannot be unmarshalled
@@ -112,7 +119,7 @@ public class ActiveEntity extends AgentPOA PropertyArrayList props = null;
// create properties
- if( !propsString.equals("") && propsString != null )
+ if( propsString != null && !propsString.equals("") )
{
try
{
@@ -126,10 +133,10 @@ public class ActiveEntity extends AgentPOA throw new InvalidDataException(ex.toString(), null);
}
- Iterator iter = props.list.iterator();
+ Iterator<Property> iter = props.list.iterator();
while( iter.hasNext() )
- mDatabase.put( mSystemKey, (C2KLocalObject)iter.next(), props );
+ mDatabase.put( mSystemKey, iter.next(), props );
}
else
{
@@ -138,12 +145,13 @@ public class ActiveEntity extends AgentPOA return props;
}
-
+
/**************************************************************************
*
*
**************************************************************************/
- public org.omg.PortableServer.POA _default_POA()
+ @Override
+ public org.omg.PortableServer.POA _default_POA()
{
if(mPOA != null)
return mPOA;
@@ -156,7 +164,8 @@ public class ActiveEntity extends AgentPOA *
*
**************************************************************************/
- public int getSystemKey()
+ @Override
+ public int getSystemKey()
{
return mSystemKey;
}
@@ -166,7 +175,8 @@ public class ActiveEntity extends AgentPOA *
*
**************************************************************************/
- public String queryData(String xpath)
+ @Override
+ public String queryData(String xpath)
throws AccessRightsException,
ObjectNotFoundException,
PersistencyException
@@ -203,7 +213,7 @@ public class ActiveEntity extends AgentPOA }
catch (ObjectNotFoundException ex) {
throw ex;
- }
+ }
catch(Throwable ex)
{
Logger.error("ActiveEntity::queryData("+mSystemKey+") - " +
@@ -218,37 +228,39 @@ public class ActiveEntity extends AgentPOA }
-
+
/**
* Called by an activity when it reckons we need to update our joblist for it
*/
-
- public synchronized void refreshJobList(int sysKey, String stepPath, String newJobs) {
+
+ @Override
+ public synchronized void refreshJobList(int sysKey, String stepPath, String newJobs) {
try {
JobArrayList newJobList = (JobArrayList)CastorXMLUtility.unmarshall(newJobs);
-
+
// get our joblist
if (currentJobs == null)
currentJobs = new JobList( mSystemKey, null);
-
+
// remove old jobs for this item
currentJobs.removeJobsForStep( sysKey, stepPath );
-
+
// merge new jobs in
- for (Iterator iter = newJobList.list.iterator(); iter.hasNext();) {
- Job newJob = (Job)iter.next();
+ for (Object name : newJobList.list) {
+ Job newJob = (Job)name;
Logger.msg(6, "Adding job for "+newJob.getItemSysKey()+"/"+newJob.getStepPath()+":"+newJob.getPossibleTransition());
currentJobs.addJob(newJob);
}
-
+
} catch (Throwable ex) {
Logger.error("Could not refresh job list.");
- Logger.error(ex);
+ Logger.error(ex);
}
-
+
}
-
- public void addRole(String roleName) throws CannotManageException, ObjectNotFoundException {
+
+ @Override
+ public void addRole(String roleName) throws CannotManageException, ObjectNotFoundException {
RolePath newRole = Gateway.getLDAPLookup().getRoleManager().getRolePath(roleName);
try {
newRole.addAgent(new AgentPath(mSystemKey));
@@ -258,11 +270,12 @@ public class ActiveEntity extends AgentPOA throw new CannotManageException("Could not update role");
}
}
-
- public void removeRole(String roleName) throws CannotManageException, ObjectNotFoundException {
+
+ @Override
+ public void removeRole(String roleName) throws CannotManageException, ObjectNotFoundException {
RolePath rolePath = Gateway.getLDAPLookup().getRoleManager().getRolePath(roleName);
try {
- rolePath.removeAgent(new AgentPath(mSystemKey));
+ rolePath.removeAgent(new AgentPath(mSystemKey));
} catch (InvalidEntityPathException e) {
throw new CannotManageException("Invalid syskey for agent: "+mSystemKey, "");
} catch (ObjectCannotBeUpdated ex) {
@@ -272,7 +285,8 @@ public class ActiveEntity extends AgentPOA /**
*
*/
- protected void finalize() throws Throwable {
+ @Override
+ protected void finalize() throws Throwable {
Logger.msg(7, "Agent "+mSystemKey+" reaped");
Gateway.getStorage().clearCache(mSystemKey, null);
super.finalize();
diff --git a/source/com/c2kernel/entity/agent/ActiveLocator.java b/source/com/c2kernel/entity/agent/ActiveLocator.java index 25324ee..eb50dbf 100755..100644 --- a/source/com/c2kernel/entity/agent/ActiveLocator.java +++ b/source/com/c2kernel/entity/agent/ActiveLocator.java @@ -45,7 +45,8 @@ public class ActiveLocator extends org.omg.PortableServer.ServantLocatorPOA /**************************************************************************
*
**************************************************************************/
- public org.omg.PortableServer.Servant preinvoke(
+ @Override
+ public org.omg.PortableServer.Servant preinvoke(
byte[] oid,
org.omg.PortableServer.POA poa,
String operation,
@@ -56,8 +57,6 @@ public class ActiveLocator extends org.omg.PortableServer.ServantLocatorPOA {
int syskey = Integer.parseInt(new String(oid));
- org.omg.PortableServer.Servant servant;
-
Logger.msg(1,"===========================================================");
Logger.msg(1,"Agent called at "+new Timestamp( System.currentTimeMillis()) +": " + operation +
"(" + syskey + ")." );
@@ -76,7 +75,8 @@ public class ActiveLocator extends org.omg.PortableServer.ServantLocatorPOA /**************************************************************************
*
**************************************************************************/
- public void postinvoke(
+ @Override
+ public void postinvoke(
byte[] oid,
org.omg.PortableServer.POA poa,
String operation,
diff --git a/source/com/c2kernel/entity/agent/Job.java b/source/com/c2kernel/entity/agent/Job.java index 12423d6..b5274ec 100755..100644 --- a/source/com/c2kernel/entity/agent/Job.java +++ b/source/com/c2kernel/entity/agent/Job.java @@ -32,7 +32,7 @@ public class Job implements C2KLocalObject private int mPossibleTransition;
private int mCurrentState;
-
+
private int mTargetState;
private String mStepName;
@@ -61,7 +61,7 @@ public class Job implements C2KLocalObject }
/***************************************************************************
- *
+ *
**************************************************************************/
public Job(int sysKey, String path, int transition, int currState, int targState, String stepName, CastorHashMap actProps, String stepType, String agentName)
{
@@ -197,7 +197,8 @@ public class Job implements C2KLocalObject return mID;
}
- public String getName()
+ @Override
+ public String getName()
{
return mName;
}
@@ -208,7 +209,8 @@ public class Job implements C2KLocalObject mName = String.valueOf(id);
}
- public void setName(String name)
+ @Override
+ public void setName(String name)
{
mName = name;
try
@@ -226,7 +228,8 @@ public class Job implements C2KLocalObject item = null;
}
- public String getClusterType()
+ @Override
+ public String getClusterType()
{
return ClusterStorage.JOB;
}
@@ -322,7 +325,7 @@ public class Job implements C2KLocalObject /**
* Returns the actType.
- *
+ *
* @return String
*/
public String getStepType()
@@ -332,7 +335,7 @@ public class Job implements C2KLocalObject /**
* Sets the actType.
- *
+ *
* @param actType
* The actType to set
*/
diff --git a/source/com/c2kernel/entity/agent/JobArrayList.java b/source/com/c2kernel/entity/agent/JobArrayList.java index fa85368..dcb3215 100644 --- a/source/com/c2kernel/entity/agent/JobArrayList.java +++ b/source/com/c2kernel/entity/agent/JobArrayList.java @@ -17,14 +17,14 @@ public class JobArrayList extends CastorArrayList<Job> {
public JobArrayList()
- {
+ {
super();
}
-
+
public JobArrayList(ArrayList<Job> aList)
- {
+ {
super(aList);
}
-
+
}
diff --git a/source/com/c2kernel/entity/agent/JobList.java b/source/com/c2kernel/entity/agent/JobList.java index 15ce0dd..f8a88ee 100644 --- a/source/com/c2kernel/entity/agent/JobList.java +++ b/source/com/c2kernel/entity/agent/JobList.java @@ -3,8 +3,6 @@ package com.c2kernel.entity.agent; import java.util.Iterator;
import java.util.Vector;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.lookup.InvalidEntityPathException;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.RemoteMap;
import com.c2kernel.utils.Logger;
@@ -15,14 +13,13 @@ import com.c2kernel.utils.Logger; * @author $Author: abranson $ $Date: 2006/03/03 13:52:21 $
* @version $Revision: 1.15 $
***************************************************************************/
-public class JobList extends RemoteMap
+public class JobList extends RemoteMap<Job>
{
/**************************************************************************
* Empty constructor for Castor
**************************************************************************/
- public JobList(int sysKey, Object locker)
- throws ObjectNotFoundException, InvalidEntityPathException
+ public JobList(int sysKey, Object locker)
{
super(sysKey, ClusterStorage.JOB, locker);
}
@@ -43,29 +40,15 @@ public class JobList extends RemoteMap /**
* Cannot be stored
*/
+ @Override
public String getClusterType() {
return null;
}
-
- public int containsJob( Job job )
- {
- Iterator actMembers = keySet().iterator();
- Job j = null;
- while( actMembers.hasNext() )
- {
- j = (Job)actMembers.next();
- if( j.equals(job) )
- return j.getID();
- }
-
- return -1;
- }
-
public Job getJob(int id) {
- return (Job)get(String.valueOf(id));
- }
+ return get(String.valueOf(id));
+ }
/**
@@ -73,12 +56,12 @@ public class JobList extends RemoteMap */
public void removeJobsWithSysKey( int sysKey )
{
- Iterator currentMembers = values().iterator();
+ Iterator<Job> currentMembers = values().iterator();
Job j = null;
while( currentMembers.hasNext() )
{
- j = (Job)currentMembers.next();
+ j = currentMembers.next();
if( j.getItemSysKey() == sysKey )
remove( String.valueOf(j.getID()) );
@@ -89,10 +72,10 @@ public class JobList extends RemoteMap public void removeJobsForStep( int sysKey, String stepPath )
{
- Iterator currentMembers = values().iterator();
+ Iterator<Job> currentMembers = values().iterator();
while( currentMembers.hasNext() )
{
- Job j = (Job)currentMembers.next();
+ Job j = currentMembers.next();
if( j.getItemSysKey() == sysKey && j.getStepPath().equals(stepPath))
remove( String.valueOf(j.getID()) );
}
@@ -104,15 +87,15 @@ public class JobList extends RemoteMap * @param string
* @return
*/
- public Vector getJobsOfSysKey(int sysKey)
+ public Vector<Job> getJobsOfSysKey(int sysKey)
{
- Iterator currentMembers = values().iterator();
+ Iterator<Job> currentMembers = values().iterator();
Job j = null;
Vector<Job> jobs = new Vector<Job>();
while( currentMembers.hasNext() )
{
- j = (Job)currentMembers.next();
+ j = currentMembers.next();
if( j.getItemSysKey() == sysKey )
jobs.add(j);
|
