Search in sources :

Example 6 with SimulationJobStatusPersistent

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

the class AdminDBTopLevel method getSimulationJobStatus.

/**
 * Insert the method's description here.
 * Creation date: (1/31/2003 2:35:44 PM)
 * @return cbit.vcell.solvers.SimulationJobStatus[]
 * @param bActiveOnly boolean
 * @param owner cbit.vcell.server.User
 */
public SimulationJobStatusPersistent getSimulationJobStatus(KeyValue simKey, int jobIndex, int taskID, boolean bEnableRetry) throws java.sql.SQLException, DataAccessException {
    Object lock = new Object();
    Connection con = conFactory.getConnection(lock);
    try {
        SimulationJobStatusPersistent jobStatus = getSimulationJobStatus(con, simKey, jobIndex, taskID);
        return jobStatus;
    } catch (Throwable e) {
        lg.error("failure in getSimulationJobStatus()", e);
        if (bEnableRetry && isBadConnection(con)) {
            conFactory.failed(con, lock);
            return getSimulationJobStatus(simKey, jobIndex, taskID, false);
        } else {
            handle_DataAccessException_SQLException(e);
            // never gets here;
            return null;
        }
    } finally {
        conFactory.release(con, lock);
    }
}
Also used : Connection(java.sql.Connection) SimulationJobStatusPersistent(cbit.vcell.server.SimulationJobStatusPersistent)

Example 7 with SimulationJobStatusPersistent

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

the class AdminDBTopLevel method getSimulationStatus.

/**
 * Insert the method's description here.
 * Creation date: (1/31/2003 2:35:44 PM)
 * @return cbit.vcell.solvers.SimulationJobStatus[]
 * @param bActiveOnly boolean
 * @param owner cbit.vcell.server.User
 */
SimulationStatusPersistent getSimulationStatus(KeyValue simKey, boolean bEnableRetry) throws java.sql.SQLException, DataAccessException {
    Object lock = new Object();
    Connection con = conFactory.getConnection(lock);
    try {
        SimulationJobStatusPersistent[] jobStatuses = jobDB.getSimulationJobStatus(con, simKey);
        if (jobStatuses.length > 0) {
            return new SimulationStatusPersistent(jobStatuses);
        } else {
            return null;
        }
    } catch (Throwable e) {
        lg.error("failure in getSimulationStatus()", e);
        if (bEnableRetry && isBadConnection(con)) {
            conFactory.failed(con, lock);
            return getSimulationStatus(simKey, false);
        } else {
            handle_DataAccessException_SQLException(e);
            // never gets here;
            return null;
        }
    } finally {
        conFactory.release(con, lock);
    }
}
Also used : Connection(java.sql.Connection) SimulationStatusPersistent(cbit.vcell.server.SimulationStatusPersistent) SimulationJobStatusPersistent(cbit.vcell.server.SimulationJobStatusPersistent)

Example 8 with SimulationJobStatusPersistent

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

the class AdminDBTopLevel method getSimulationJobStatusArray.

/**
 * Insert the method's description here.
 * Creation date: (1/31/2003 2:35:44 PM)
 * @return cbit.vcell.solvers.SimulationJobStatus[]
 * @param bActiveOnly boolean
 * @param owner cbit.vcell.server.User
 */
public SimulationJobStatusPersistent[] getSimulationJobStatusArray(KeyValue simKey, boolean bEnableRetry) throws java.sql.SQLException, DataAccessException {
    Object lock = new Object();
    Connection con = conFactory.getConnection(lock);
    try {
        SimulationJobStatusPersistent[] jobStatus = getSimulationJobStatusArray(con, simKey);
        return jobStatus;
    } catch (Throwable e) {
        lg.error("failure in getSimulationJobStatusArray()", e);
        if (bEnableRetry && isBadConnection(con)) {
            conFactory.failed(con, lock);
            return getSimulationJobStatusArray(simKey, false);
        } else {
            handle_DataAccessException_SQLException(e);
            // never gets here;
            return null;
        }
    } finally {
        conFactory.release(con, lock);
    }
}
Also used : Connection(java.sql.Connection) SimulationJobStatusPersistent(cbit.vcell.server.SimulationJobStatusPersistent)

Example 9 with SimulationJobStatusPersistent

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

the class VCComprehensiveStatistics method collectMathModelStats.

private void collectMathModelStats(long startDateInMs, long endDateInMs) throws DataAccessException {
    retrieveUsers();
    for (User user : userList) {
        if (!userConstraintList.contains(user.getName())) {
            continue;
        }
        if (!internalDeveloper.contains(user.getName())) {
            boolean bInternal = internalUsers.contains(user.getName());
            ModelStat modelStat = mathModelStats[bInternal ? 0 : 1];
            MathModelInfo[] mathModelInfos = dbServerImpl.getMathModelInfos(user, false);
            for (MathModelInfo mmi : mathModelInfos) {
                Date createDate = mmi.getVersion().getDate();
                long t = createDate.getTime();
                // }
                if (t < startDateInMs || t > endDateInMs) {
                    continue;
                }
                // modelStat.count_model ++;
                try {
                    BigString mathModelXML = dbServerImpl.getMathModelXML(user, mmi.getVersion().getVersionKey());
                    MathModel mathModel = (MathModel) waitForModel(mathModelXML, true);
                    if (mathModel == null) {
                        System.out.println("----------          Skipped MathModel " + mmi.getVersion() + "          ----------");
                        continue;
                    }
                    modelStat.count_model++;
                    boolean bHasCompletedSim = false;
                    for (Simulation sim : mathModel.getSimulations()) {
                        SimulationStatusPersistent ss = dbServerImpl.getSimulationStatus(sim.getKey());
                        for (int scan = 0; scan < sim.getScanCount(); scan++) {
                            SimulationJobStatusPersistent jobStatus = ss.getJobStatus(scan);
                            if (jobStatus != null) {
                                if (jobStatus.getSchedulerStatus() == SchedulerStatus.COMPLETED) {
                                    bHasCompletedSim = true;
                                    long elapsed = jobStatus.getEndDate().getTime() - jobStatus.getStartDate().getTime();
                                    if (elapsed < 2 * MINUTE_IN_MS) {
                                        modelStat.runningTimeHistogram[0]++;
                                    } else if (elapsed < 5 * MINUTE_IN_MS) {
                                        modelStat.runningTimeHistogram[1]++;
                                    } else if (elapsed < 20 * MINUTE_IN_MS) {
                                        modelStat.runningTimeHistogram[2]++;
                                    } else if (elapsed < HOUR_IN_MS) {
                                        modelStat.runningTimeHistogram[3]++;
                                    } else if (elapsed < DAY_IN_MS) {
                                        modelStat.runningTimeHistogram[4]++;
                                    } else {
                                        modelStat.runningTimeHistogram[5]++;
                                    }
                                }
                                int dimension = sim.getMathDescription().getGeometry().getDimension();
                                modelStat.count_geoDimSim[dimension]++;
                                if (sim.getMathDescription().isNonSpatialStoch()) {
                                    modelStat.count_sim_stochastic++;
                                } else {
                                    modelStat.count_sim_deterministic++;
                                }
                                if (dimension > 0) {
                                    if (sim.getSolverTaskDescription().getSolverDescription().isSemiImplicitPdeSolver()) {
                                        modelStat.count_semiSim++;
                                    } else {
                                        modelStat.count_fullySim++;
                                    }
                                }
                            }
                        }
                    }
                    if (bHasCompletedSim) {
                        modelStat.count_model_simcomplete++;
                    }
                } catch (Exception e2) {
                    e2.printStackTrace(System.out);
                }
            }
        }
    }
    itemCount++;
    statOutputPW.println(itemCount + ". MathModel Statistics ");
    statOutputPW.println("====================================================");
    for (ModelStat modelStat : mathModelStats) {
        statOutputPW.println("\t" + modelStat.title);
        statOutputPW.println("========================================");
        statOutputPW.println("number of mathmodels saved :\t" + modelStat.count_model);
        statOutputPW.println("number of mathmodels that has at least 1 completed simulation :\t" + modelStat.count_model_simcomplete);
        statOutputPW.println();
        statOutputPW.println("Simulation statistics (including all simulations (stopped, failed, completed) :");
        statOutputPW.println("number of run simulation ODE :\t" + modelStat.count_geoDimSim[0]);
        statOutputPW.println("number of run simulation 1D :\t" + modelStat.count_geoDimSim[1]);
        statOutputPW.println("number of run simulation 2D :\t" + modelStat.count_geoDimSim[2]);
        statOutputPW.println("number of run simulation 3D :\t" + modelStat.count_geoDimSim[3]);
        statOutputPW.println("number of run simulation Semi-Implicit :\t" + modelStat.count_semiSim);
        statOutputPW.println("number of run simulation Fully-Implicit :\t" + modelStat.count_fullySim);
        statOutputPW.println("number of run simulation stochastic :\t" + modelStat.count_sim_stochastic);
        statOutputPW.println("number of run simulation deterministic :\t" + modelStat.count_sim_deterministic);
        statOutputPW.println();
        statOutputPW.println("Running time histogram for completed simulations only:");
        statOutputPW.println("0 ~ 2min:\t" + modelStat.runningTimeHistogram[0]);
        statOutputPW.println("2 ~ 5min:\t" + modelStat.runningTimeHistogram[1]);
        statOutputPW.println("5 ~ 20min:\t" + modelStat.runningTimeHistogram[2]);
        statOutputPW.println("20min ~ 1hr:\t" + modelStat.runningTimeHistogram[3]);
        statOutputPW.println("1hr ~ 1day:\t" + modelStat.runningTimeHistogram[4]);
        statOutputPW.println(">1day:\t" + modelStat.runningTimeHistogram[5]);
        statOutputPW.println();
        statOutputPW.println();
        statOutputPW.flush();
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) User(org.vcell.util.document.User) SimulationStatusPersistent(cbit.vcell.server.SimulationStatusPersistent) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationJobStatusPersistent(cbit.vcell.server.SimulationJobStatusPersistent) BigString(org.vcell.util.BigString) Date(java.util.Date) SQLException(java.sql.SQLException) DataAccessException(org.vcell.util.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) Simulation(cbit.vcell.solver.Simulation)

Example 10 with SimulationJobStatusPersistent

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

the class SimulationJobTable method getSimulationJobStatus.

/**
 * This method was created in VisualAge.
 * @return VCImage
 * @param rset ResultSet
 * @param log SessionLog
 */
public SimulationJobStatusPersistent getSimulationJobStatus(ResultSet rset) throws SQLException {
    // serverid
    String serID = rset.getString(this.serverID.toString());
    if (rset.wasNull()) {
        serID = null;
    }
    // simRef
    KeyValue parsedSimKey = new KeyValue(rset.getBigDecimal(simRef.toString()));
    // userKey
    KeyValue userKey = new KeyValue(rset.getBigDecimal(SimulationTable.table.ownerRef.toString()));
    // userKey
    String userid = rset.getString(UserTable.table.userid.toString());
    org.vcell.util.document.User owner = new org.vcell.util.document.User(userid, userKey);
    // submitDate
    java.util.Date parsedSubmitDate = rset.getTimestamp(submitDate.toString());
    // taskID
    int parsedTaskID = rset.getInt(taskID.toString());
    // schedulerStatus
    int parsedSchedulerStatusInt = rset.getInt(schedulerStatus.toString());
    SchedulerStatus parsedSchedulerStatus = SchedulerStatus.fromDatabaseNumber(parsedSchedulerStatusInt);
    // statusMsg
    String parsedStatusMsg = TokenMangler.getSQLRestoredString(rset.getString(statusMsg.toString()));
    SimulationMessagePersistent simulationMessage = SimulationMessagePersistent.fromSerialized(parsedSchedulerStatus, parsedStatusMsg);
    // 
    // read queue stuff
    // 
    // queueDate
    java.util.Date parsedQueuedDate = rset.getTimestamp(queueDate.toString());
    // queuePriority
    int parsedQueuePriority = rset.getInt(queuePriority.toString());
    if (rset.wasNull()) {
        parsedQueuePriority = -1;
    }
    // queueID
    int parsedQueueID = rset.getInt(queueID.toString());
    if (rset.wasNull()) {
        parsedQueueID = -1;
    }
    SimulationJobStatusPersistent.SimulationQueueID simulationQueueID = SimulationJobStatusPersistent.SimulationQueueID.fromDatabaseNumber(parsedQueueID);
    SimulationQueueEntryStatusPersistent simQueueEntryStatus = new SimulationQueueEntryStatusPersistent(parsedQueuedDate, parsedQueuePriority, simulationQueueID);
    // 
    // read solver stuff
    // 
    // startDate
    java.util.Date parsedStartDate = rset.getTimestamp(startDate.toString());
    // computeHost
    String parsedComputeHost = rset.getString(computeHost.toString());
    // latestUpdateDate
    java.util.Date parsedLatestUpdateDate = rset.getTimestamp(latestUpdateDate.toString());
    // endDate
    java.util.Date parsedEndDate = rset.getTimestamp(endDate.toString());
    // hasData
    String parsedHasData = rset.getString(hasData.toString());
    HtcJobID parsedHtcJobID = null;
    String htcJobIDString = rset.getString(pbsJobID.toString());
    if (!rset.wasNull() && htcJobIDString != null && htcJobIDString.length() > 0) {
        parsedHtcJobID = SimulationJobTable.fromDatabase(htcJobIDString);
    }
    SimulationExecutionStatusPersistent simExeStatus = new SimulationExecutionStatusPersistent(parsedStartDate, parsedComputeHost, parsedLatestUpdateDate, parsedEndDate, parsedHasData != null, parsedHtcJobID);
    VCSimulationIdentifier parsedVCSimID = new VCSimulationIdentifier(parsedSimKey, owner);
    // jobIndex
    int parsedJobIndex = rset.getInt(jobIndex.toString());
    SimulationJobStatusPersistent simulationJobStatus = new SimulationJobStatusPersistent(VCellServerID.getServerID(serID), parsedVCSimID, parsedJobIndex, parsedSubmitDate, parsedSchedulerStatus, parsedTaskID, simulationMessage, simQueueEntryStatus, simExeStatus);
    // sysDate
    java.util.Date parsedSysDate = rset.getTimestamp(DatabaseConstants.SYSDATE_COLUMN_NAME);
    if (!rset.wasNull()) {
        simulationJobStatus.setTimeDateStamp(parsedSysDate);
    }
    return simulationJobStatus;
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) KeyValue(org.vcell.util.document.KeyValue) SchedulerStatus(cbit.vcell.server.SimulationJobStatusPersistent.SchedulerStatus) SimulationQueueEntryStatusPersistent(cbit.vcell.server.SimulationQueueEntryStatusPersistent) SimulationExecutionStatusPersistent(cbit.vcell.server.SimulationExecutionStatusPersistent) SimulationJobStatusPersistent(cbit.vcell.server.SimulationJobStatusPersistent) SimulationMessagePersistent(cbit.vcell.solver.server.SimulationMessagePersistent) HtcJobID(cbit.vcell.server.HtcJobID)

Aggregations

SimulationJobStatusPersistent (cbit.vcell.server.SimulationJobStatusPersistent)23 ResultSet (java.sql.ResultSet)8 Statement (java.sql.Statement)8 ArrayList (java.util.ArrayList)8 Connection (java.sql.Connection)5 SimulationStatusPersistent (cbit.vcell.server.SimulationStatusPersistent)4 SimulationExecutionStatusPersistent (cbit.vcell.server.SimulationExecutionStatusPersistent)3 SimulationQueueEntryStatusPersistent (cbit.vcell.server.SimulationQueueEntryStatusPersistent)3 SQLException (java.sql.SQLException)3 Date (java.util.Date)3 DataAccessException (org.vcell.util.DataAccessException)3 User (org.vcell.util.document.User)3 SimpleJobStatusPersistent (cbit.vcell.server.SimpleJobStatusPersistent)2 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)2 Simulation (cbit.vcell.solver.Simulation)2 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)2 SimulationMessagePersistent (cbit.vcell.solver.server.SimulationMessagePersistent)2 FileNotFoundException (java.io.FileNotFoundException)2 BigString (org.vcell.util.BigString)2 KeyValue (org.vcell.util.document.KeyValue)2