diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2012-05-30 08:37:45 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2012-05-30 08:37:45 +0200 |
| commit | b086f57f56bf0eb9dab9cf321a0f69aaaae84347 (patch) | |
| tree | 8e6e26e8b7eed6abad7a17b093bdbb55c5e6b1ba /source/com/c2kernel/entity/agent | |
| parent | 22088ae8d2d5ff390518dbe1c4372325ffb3a647 (diff) | |
Initial Maven Conversion
Diffstat (limited to 'source/com/c2kernel/entity/agent')
| -rw-r--r-- | source/com/c2kernel/entity/agent/ActiveEntity.java | 295 | ||||
| -rw-r--r-- | source/com/c2kernel/entity/agent/ActiveLocator.java | 87 | ||||
| -rw-r--r-- | source/com/c2kernel/entity/agent/Job.java | 346 | ||||
| -rw-r--r-- | source/com/c2kernel/entity/agent/JobArrayList.java | 30 | ||||
| -rw-r--r-- | source/com/c2kernel/entity/agent/JobList.java | 108 |
5 files changed, 0 insertions, 866 deletions
diff --git a/source/com/c2kernel/entity/agent/ActiveEntity.java b/source/com/c2kernel/entity/agent/ActiveEntity.java deleted file mode 100644 index 3d45e35..0000000 --- a/source/com/c2kernel/entity/agent/ActiveEntity.java +++ /dev/null @@ -1,295 +0,0 @@ -/**************************************************************************
- * BasicAgent.java
- *
- * $Revision: 1.39 $
- * $Date: 2005/04/26 06:48:12 $
- *
- * Copyright (C) 2001-2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-
-package com.c2kernel.entity.agent;
-
-import java.util.Iterator;
-
-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;
-import com.c2kernel.lookup.InvalidEntityPathException;
-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;
-
-/**************************************************************************
- * ActiveEntity
- *
- * @author $Author: abranson $ $Date: 2005/04/26 06:48:12 $
- * @version $Revision: 1.39 $
- **************************************************************************/
-public class ActiveEntity extends AgentPOA
-{
-
- /**************************************************************************
- * The CORBA Portable Object Adapter which holds the Agent
- **************************************************************************/
- private org.omg.PortableServer.POA mPOA = null;
-
- /**************************************************************************
- * The C2Kernel system key of the Agent
- **************************************************************************/
- private int mSystemKey = -1;
-
- /**************************************************************************
- * Connection to the persistency backeng
- **************************************************************************/
- private TransactionManager mDatabase = null;
-
- /**************************************************************************
- * The agent's joblist
- **************************************************************************/
- private JobList currentJobs;
- /**
- *
- * @param key
- * @param poa
- */
- public ActiveEntity( int key,
- org.omg.PortableServer.POA poa )
- {
- Logger.msg(5, "ActiveEntity::constructor() - SystemKey:" + key );
-
- mSystemKey = key;
- mPOA = poa;
- mDatabase = Gateway.getStorage();
-
- Logger.msg(5, "ActiveEntity::constructor - completed.");
- }
-
- /**
- * initialise cristal2 properties & collector
- */
- @Override
- public void initialise( String agentProps )
- throws AccessRightsException,
- InvalidDataException,
- PersistencyException
- {
- PropertyArrayList props = null;
- Logger.msg(1, "ActiveEntity::initialise("+mSystemKey+")");
- //initialise cristal2 properties & collector
- try
- {
- props = initProps( agentProps );
- mDatabase.commit( props );
- }
- catch( ClusterStorageException ex )
- {
- Logger.error("ActiveEntity::init() - Failed to init props/collector, aborting!");
- Logger.error(ex);
-
- mDatabase.abort( props );
- throw new PersistencyException("Failed to init props => transaction aborted!");
- }
-
- Logger.msg(5, "ActiveEntity::init() - completed.");
- }
-
- /**
- *
- * @param propsString
- * @return Properties
- * @throws InvalidDataException Properties cannot be unmarshalled
- * @throws ClusterStorageException
- */
- private PropertyArrayList initProps( String propsString )
- throws InvalidDataException,
- ClusterStorageException
- {
- PropertyArrayList props = null;
-
- // create properties
- if( propsString != null && !propsString.equals("") )
- {
- try
- {
- props = (PropertyArrayList)CastorXMLUtility.unmarshall(propsString);
- }
- catch( Exception ex )
- {
- //any exception during unmarshall indicates that data was
- //incorrect or the castor mapping was not set up
- Logger.error(ex);
- throw new InvalidDataException(ex.toString(), null);
- }
-
- Iterator<Property> iter = props.list.iterator();
-
- while( iter.hasNext() )
- mDatabase.put( mSystemKey, iter.next(), props );
- }
- else
- {
- Logger.warning("ActiveEntity::initProps() - NO Properties!");
- }
-
- return props;
- }
-
- /**************************************************************************
- *
- *
- **************************************************************************/
- @Override
- public org.omg.PortableServer.POA _default_POA()
- {
- if(mPOA != null)
- return mPOA;
- else
- return super._default_POA();
- }
-
-
- /**************************************************************************
- *
- *
- **************************************************************************/
- @Override
- public int getSystemKey()
- {
- return mSystemKey;
- }
-
-
- /**************************************************************************
- *
- *
- **************************************************************************/
- @Override
- public String queryData(String xpath)
- throws AccessRightsException,
- ObjectNotFoundException,
- PersistencyException
- {
- String result = "";
- int allPos = -1;
-
- Logger.msg(1, "ActiveEntity::queryData("+mSystemKey+") - " + xpath );
-
- try
- {
- if( (allPos=xpath.indexOf("all")) != -1 )
- {
- String query = xpath.substring(0,allPos);
- String[] ids = mDatabase.getClusterContents( mSystemKey, query );
-
- for( int i=0; i<ids.length; i++ )
- {
-
- result += ids[i];
-
- if( i != ids.length-1 )
- result += ",";
- }
- }
- //****************************************************************
- else
- {
- C2KLocalObject obj = mDatabase.get( mSystemKey, xpath, null );
-
- result = CastorXMLUtility.marshall(obj);
- }
-
- }
- catch (ObjectNotFoundException ex) {
- throw ex;
- }
- catch(Throwable ex)
- {
- Logger.error("ActiveEntity::queryData("+mSystemKey+") - " +
- xpath + " FAILED");
- Logger.error(ex);
- result = "<ERROR/>";
- }
-
- Logger.msg(7, "ActiveEntity::queryData("+mSystemKey+") - result:" + result );
-
- return result;
- }
-
-
-
- /**
- * Called by an activity when it reckons we need to update our joblist for it
- */
-
- @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 (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);
- }
-
- }
-
- @Override
- public void addRole(String roleName) throws CannotManageException, ObjectNotFoundException {
- RolePath newRole = Gateway.getLDAPLookup().getRoleManager().getRolePath(roleName);
- try {
- newRole.addAgent(new AgentPath(mSystemKey));
- } catch (InvalidEntityPathException ex) {
- throw new CannotManageException("Invalid syskey for agent: "+mSystemKey, "");
- } catch (ObjectCannotBeUpdated ex) {
- throw new CannotManageException("Could not update role");
- }
- }
-
- @Override
- public void removeRole(String roleName) throws CannotManageException, ObjectNotFoundException {
- RolePath rolePath = Gateway.getLDAPLookup().getRoleManager().getRolePath(roleName);
- try {
- rolePath.removeAgent(new AgentPath(mSystemKey));
- } catch (InvalidEntityPathException e) {
- throw new CannotManageException("Invalid syskey for agent: "+mSystemKey, "");
- } catch (ObjectCannotBeUpdated ex) {
- throw new CannotManageException("Could not update role");
- }
- }
- /**
- *
- */
- @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 deleted file mode 100644 index eb50dbf..0000000 --- a/source/com/c2kernel/entity/agent/ActiveLocator.java +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************
- * TraceableLocator
- *
- * $Workfile$
- * $Revision: 1.9 $
- * $Date: 2005/10/05 07:39:36 $
- *
- * Copyright (C) 2001 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-
-package com.c2kernel.entity.agent;
-
-
-import java.sql.Timestamp;
-
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2005/10/05 07:39:36 $
- * @version $Revision: 1.9 $
- **************************************************************************/
-public class ActiveLocator extends org.omg.PortableServer.ServantLocatorPOA
-{
-
- /**************************************************************************
- *
- **************************************************************************/
- private org.omg.PortableServer.POA mParentPoa;
-
-
- /**************************************************************************
- *
- **************************************************************************/
- public ActiveLocator( org.omg.PortableServer.POA poa )
- {
- mParentPoa = poa;
- }
-
-
- /**************************************************************************
- *
- **************************************************************************/
- @Override
- public org.omg.PortableServer.Servant preinvoke(
- byte[] oid,
- org.omg.PortableServer.POA poa,
- String operation,
- org.omg.PortableServer.ServantLocatorPackage.CookieHolder cookie )
- {
-
- try
- {
- int syskey = Integer.parseInt(new String(oid));
-
- Logger.msg(1,"===========================================================");
- Logger.msg(1,"Agent called at "+new Timestamp( System.currentTimeMillis()) +": " + operation +
- "(" + syskey + ")." );
-
- return Gateway.getCorbaServer().getAgent(syskey, mParentPoa);
-
- }
- catch (ObjectNotFoundException ex)
- {
- Logger.error("ObjectNotFoundException::ActiveLocator::preinvoke() "+ex.toString());
- throw new org.omg.CORBA.OBJECT_NOT_EXIST();
- }
- }
-
-
- /**************************************************************************
- *
- **************************************************************************/
- @Override
- public void postinvoke(
- byte[] oid,
- org.omg.PortableServer.POA poa,
- String operation,
- java.lang.Object the_cookie,
- org.omg.PortableServer.Servant the_servant )
- {
- }
-}
diff --git a/source/com/c2kernel/entity/agent/Job.java b/source/com/c2kernel/entity/agent/Job.java deleted file mode 100644 index b5274ec..0000000 --- a/source/com/c2kernel/entity/agent/Job.java +++ /dev/null @@ -1,346 +0,0 @@ -package com.c2kernel.entity.agent;
-
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.entity.C2KLocalObject;
-import com.c2kernel.entity.proxy.AgentProxy;
-import com.c2kernel.entity.proxy.ItemProxy;
-import com.c2kernel.lifecycle.instance.stateMachine.Transitions;
-import com.c2kernel.lookup.EntityPath;
-import com.c2kernel.lookup.InvalidEntityPathException;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.persistency.outcome.Outcome;
-import com.c2kernel.persistency.outcome.Viewpoint;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.CastorHashMap;
-import com.c2kernel.utils.KeyValuePair;
-import com.c2kernel.utils.Logger;
-
-/*******************************************************************************
- * @author $Author: abranson $ $Date: 2005/05/20 13:07:49 $
- * @version $Revision: 1.62 $
- ******************************************************************************/
-public class Job implements C2KLocalObject
-{
- private int mID;
-
- private String mName;
-
- private int mItemSysKey;
-
- private String mStepPath;
-
- private int mPossibleTransition;
-
- private int mCurrentState;
-
- private int mTargetState;
-
- private String mStepName;
-
- private int mAgentId = -1;
-
- private String mAgentName;
-
- private String mAgentRole;
-
- private CastorHashMap mActProps = new CastorHashMap();
-
- private String mOutcome;
-
- private String mStepType;
-
- private ItemProxy item = null;
-
- private AgentProxy agent = null;
-
- /***************************************************************************
- * Empty constructor for Castor
- **************************************************************************/
- public Job()
- {
- }
-
- /***************************************************************************
- *
- **************************************************************************/
- public Job(int sysKey, String path, int transition, int currState, int targState, String stepName, CastorHashMap actProps, String stepType, String agentName)
- {
- setItemSysKey(sysKey);
- setStepPath(path);
- setPossibleTransition(transition);
- setCurrentState(currState);
- setTargetState(targState);
- setStepName(stepName);
- setActProps(actProps);
- setStepType(stepType);
- setAgentName(agentName);
- }
-
- public int getItemSysKey()
- {
- return mItemSysKey;
- }
-
- public ItemProxy getItemProxy() throws ObjectNotFoundException, InvalidEntityPathException
- {
- if (item == null)
- item = (ItemProxy) Gateway.getProxyManager().getProxy(new EntityPath(mItemSysKey));
- return item;
- }
-
- public AgentProxy getAgentProxy() throws ObjectNotFoundException, InvalidEntityPathException
- {
- if (agent == null)
- agent = (AgentProxy) Gateway.getProxyManager().getProxy(new EntityPath(getAgentId()));
- return agent;
- }
-
- public String getDescription()
- {
- String desc = (String) mActProps.get("Description");
- if (desc == null)
- desc = "No Description";
- return desc;
- }
-
- public String getSchemaType()
- {
- return (String) mActProps.get("SchemaType");
- }
-
- public int getSchemaVersion()
- {
- try
- {
- return Integer.parseInt((String) mActProps.get("SchemaVersion"));
- } catch (NumberFormatException ex)
- {
- return -1;
- }
- }
-
- public void setOutcome(String outcome)
- {
- mOutcome = outcome;
- }
-
- public String getOutcomeString()
- {
- Logger.debug(8, "getOutcomeString() " + (mOutcome == null && isOutcomeUsed()));
- if (mOutcome == null && isOutcomeUsed())
- {
- String viewName = (String) getActProp("Viewpoint");
- mOutcome = null;
- if (viewName.length() > 0)
- try
- {
- Viewpoint view = (Viewpoint) Gateway.getStorage().get(getItemSysKey(), ClusterStorage.VIEWPOINT + "/" + getSchemaType() + "/" + viewName, null);
- mOutcome = view.getOutcome().getData();
- } catch (Exception ex)
- { // not found, return null
- }
- }
- return mOutcome;
- }
-
- public Outcome getOutcome()
- {
- Logger.msg(1, "Get outcome");
- return new Outcome(-1, getOutcomeString(), getSchemaType(), getSchemaVersion());
- }
-
- public int getAgentId() throws ObjectNotFoundException
- {
- if (mAgentId == -1)
- mAgentId = Gateway.getLDAPLookup().getRoleManager().getAgentPath(getAgentName()).getSysKey();
- return mAgentId;
- }
-
- public void setAgentId(int id)
- {
- mAgentId = id;
- agent = null;
- }
-
- public String getAgentName()
- {
- if (mAgentName == null)
- mAgentName = (String) mActProps.get("AgentName");
- return mAgentName;
- }
-
- public void setAgentName(String agentName)
- {
- mAgentName = agentName;
- }
-
- public String getAgentRole()
- {
- if (mAgentRole == null)
- mAgentRole = (String) mActProps.get("Agent Role");
- return mAgentRole;
- }
-
- public void setAgentRole(String role)
- {
- mAgentRole = role;
- }
-
- public boolean isOutcomeUsed()
- {
- String schemaType = getSchemaType();
- return (Boolean.TRUE.equals(getActProp("AlwaysUseOutcome")) || mPossibleTransition == Transitions.DONE || mPossibleTransition == Transitions.COMPLETE) && !(schemaType == null || schemaType.equals(""));
- }
-
- public int getID()
- {
- return mID;
- }
-
- @Override
- public String getName()
- {
- return mName;
- }
-
- public void setID(int id)
- {
- mID = id;
- mName = String.valueOf(id);
- }
-
- @Override
- public void setName(String name)
- {
- mName = name;
- try
- {
- mID = Integer.parseInt(name);
- } catch (NumberFormatException ex)
- {
- mID = -1;
- }
- }
-
- public void setItemSysKey(int sysKey)
- {
- mItemSysKey = sysKey;
- item = null;
- }
-
- @Override
- public String getClusterType()
- {
- return ClusterStorage.JOB;
- }
-
- public boolean equals(Job job)
- {
- return (getItemSysKey() == job.getItemSysKey()) && this.mStepPath.equals(job.mStepPath) && this.mPossibleTransition == job.mPossibleTransition;
- }
-
- public Object getActProp(String name)
- {
- return mActProps.get(name);
- }
-
- public String getActPropString(String name)
- {
- try
- {
- return mActProps.get(name).toString();
- } catch (NullPointerException ex)
- {
- return null;
- }
- }
-
- public String getStepName()
- {
- return mStepName;
- }
-
- public void setStepName(String string)
- {
- mStepName = string;
- }
-
- public String getStepPath()
- {
- return mStepPath;
- }
-
- public void setStepPath(String string)
- {
- mStepPath = string;
- }
-
- public int getPossibleTransition()
- {
- return mPossibleTransition;
- }
-
- public void setPossibleTransition(int lint)
- {
- mPossibleTransition = lint;
- }
-
- public CastorHashMap getActProps()
- {
- return mActProps;
- }
-
- public void setActProps(CastorHashMap map)
- {
- mActProps = map;
- }
-
- public KeyValuePair[] getKeyValuePairs()
- {
- return mActProps.getKeyValuePairs();
- }
-
- public void setKeyValuePairs(KeyValuePair[] pairs)
- {
- mActProps.setKeyValuePairs(pairs);
- }
-
- public int getCurrentState()
- {
- return mCurrentState;
- }
-
- public void setCurrentState(int string)
- {
- mCurrentState = string;
- }
-
- public int getTargetState() {
- return mTargetState;
- }
-
- public void setTargetState(int mTargetState) {
- this.mTargetState = mTargetState;
- }
-
- /**
- * Returns the actType.
- *
- * @return String
- */
- public String getStepType()
- {
- return mStepType;
- }
-
- /**
- * Sets the actType.
- *
- * @param actType
- * The actType to set
- */
- public void setStepType(String actType)
- {
- mStepType = actType;
- }
-}
\ No newline at end of file diff --git a/source/com/c2kernel/entity/agent/JobArrayList.java b/source/com/c2kernel/entity/agent/JobArrayList.java deleted file mode 100644 index dcb3215..0000000 --- a/source/com/c2kernel/entity/agent/JobArrayList.java +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************
- *
- * $Revision: 1.2 $
- * $Date: 2003/06/20 11:44:30 $
- *
- * Copyright (C) 2001 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-
-package com.c2kernel.entity.agent;
-
-import java.util.ArrayList;
-
-import com.c2kernel.utils.CastorArrayList;
-
-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 deleted file mode 100644 index f8a88ee..0000000 --- a/source/com/c2kernel/entity/agent/JobList.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.c2kernel.entity.agent;
-
-import java.util.Iterator;
-import java.util.Vector;
-
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.persistency.RemoteMap;
-import com.c2kernel.utils.Logger;
-
-
-/**************************************************************************
-*
-* @author $Author: abranson $ $Date: 2006/03/03 13:52:21 $
-* @version $Revision: 1.15 $
-***************************************************************************/
-public class JobList extends RemoteMap<Job>
-{
-
- /**************************************************************************
- * Empty constructor for Castor
- **************************************************************************/
- public JobList(int sysKey, Object locker)
- {
- super(sysKey, ClusterStorage.JOB, locker);
- }
-
-
- /**************************************************************************
- *
- **************************************************************************/
- public void addJob( Job job )
- {
- synchronized(this) {
- int jobId = getLastId()+1;
- job.setID(jobId);
- put(String.valueOf(jobId), job);
- }
- }
-
- /**
- * Cannot be stored
- */
- @Override
- public String getClusterType() {
- return null;
- }
-
-
- public Job getJob(int id) {
- return get(String.valueOf(id));
- }
-
-
- /**
- * @param job
- */
- public void removeJobsWithSysKey( int sysKey )
- {
- Iterator<Job> currentMembers = values().iterator();
- Job j = null;
-
- while( currentMembers.hasNext() )
- {
- j = currentMembers.next();
-
- if( j.getItemSysKey() == sysKey )
- remove( String.valueOf(j.getID()) );
- }
-
- Logger.msg(5, "JobList::removeJobsWithSysKey() - " + sysKey + " DONE." );
- }
-
- public void removeJobsForStep( int sysKey, String stepPath )
- {
- Iterator<Job> currentMembers = values().iterator();
- while( currentMembers.hasNext() )
- {
- Job j = currentMembers.next();
- if( j.getItemSysKey() == sysKey && j.getStepPath().equals(stepPath))
- remove( String.valueOf(j.getID()) );
- }
-
- Logger.msg(5, "JobList::removeJobsForStep() - " + sysKey + " DONE." );
- }
- /**
- * @param itemKey
- * @param string
- * @return
- */
- public Vector<Job> getJobsOfSysKey(int sysKey)
- {
- Iterator<Job> currentMembers = values().iterator();
- Job j = null;
- Vector<Job> jobs = new Vector<Job>();
-
- while( currentMembers.hasNext() )
- {
- j = currentMembers.next();
-
- if( j.getItemSysKey() == sysKey )
- jobs.add(j);
- }
-
- Logger.msg(5, "JobList::getJobsOfSysKey() - returning " + jobs.size() + " Jobs." );
-
- return jobs;
- }
-}
\ No newline at end of file |
