Search in sources :

Example 1 with StateInfo

use of cbit.vcell.server.StateInfo in project vcell by virtualcell.

the class SimulationDatabaseDirect method getSimpleJobStatus.

@Override
public SimpleJobStatus[] getSimpleJobStatus(User user, SimpleJobStatusQuerySpec simStatusQuerySpec) throws ObjectNotFoundException, DataAccessException {
    // 
    // create corresponding SimpleJobStatus[] from SimpleJobStatusPersistent[]
    // 1) get SimpleJobStatusPersistent from database (with stored status, metadata, and documentLinks - but no stateInfo)
    // 2) if already in cache, use SimulationJobStatus and stateInfo from cache.
    // 3) if not in cache, use SimulationJobStatus from database and no stateInfo, populate cache.
    // 
    List<SimpleJobStatusPersistent> simpleJobStatusPersistentList = databaseServerImpl.getSimpleJobStatus(simStatusQuerySpec);
    ArrayList<SimpleJobStatus> simpleJobStatusList = new ArrayList<SimpleJobStatus>();
    for (SimpleJobStatusPersistent simpleJobStatusPersistent : simpleJobStatusPersistentList) {
        SimulationJobStatusPersistent simJobStatusDb = simpleJobStatusPersistent.jobStatus;
        SimJobStatusKey key = new SimJobStatusKey(simpleJobStatusPersistent.simulationMetadata.vcSimID.getSimulationKey(), simJobStatusDb.getJobIndex(), simJobStatusDb.getTaskID());
        SimStatusCacheEntry simStatusCacheEntry = cache.get(key);
        // TODO need to get this from memory cache.
        StateInfo cachedStateInfo = null;
        SimulationJobStatus latestSimulationJobStatus = null;
        if (simStatusCacheEntry != null) {
            cachedStateInfo = simStatusCacheEntry.stateInfo;
            latestSimulationJobStatus = simStatusCacheEntry.jobStatus;
        } else {
            latestSimulationJobStatus = translateToSimulationJobStatusTransient(simJobStatusDb);
            cache.put(key, new SimStatusCacheEntry(latestSimulationJobStatus, null));
        }
        SimpleJobStatus bestSimpleJobStatus = translateToSimpleJobStatusTransient(simpleJobStatusPersistent, latestSimulationJobStatus, cachedStateInfo);
        // uses latest SimulationJobStatus and StateInfo.
        simpleJobStatusList.add(bestSimpleJobStatus);
    }
    return simpleJobStatusList.toArray(new SimpleJobStatus[simpleJobStatusList.size()]);
}
Also used : StateInfo(cbit.vcell.server.StateInfo) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) ArrayList(java.util.ArrayList) SimpleJobStatusPersistent(cbit.vcell.server.SimpleJobStatusPersistent) SimulationJobStatusPersistent(cbit.vcell.server.SimulationJobStatusPersistent) SimpleJobStatus(cbit.vcell.server.SimpleJobStatus)

Aggregations

SimpleJobStatus (cbit.vcell.server.SimpleJobStatus)1 SimpleJobStatusPersistent (cbit.vcell.server.SimpleJobStatusPersistent)1 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)1 SimulationJobStatusPersistent (cbit.vcell.server.SimulationJobStatusPersistent)1 StateInfo (cbit.vcell.server.StateInfo)1 ArrayList (java.util.ArrayList)1