Search in sources :

Example 1 with ServiceStatus

use of cbit.vcell.message.server.ServiceStatus in project vcell by virtualcell.

the class ServiceStatusDbDriver method getAllServiceStatus.

public List<ServiceStatus> getAllServiceStatus(Connection con) throws SQLException {
    String sql = "select * from " + serviceTable.getTableName() + " where " + serviceTable.serverID + "='" + VCellServerID.getSystemServerID() + "'" + " order by " + serviceTable.serverID + "," + serviceTable.type + "," + serviceTable.ordinal;
    List<ServiceStatus> services = new ArrayList<ServiceStatus>();
    Statement stmt = con.createStatement();
    ServiceStatus serviceStatus = null;
    try {
        ResultSet rset = stmt.executeQuery(sql);
        while (rset.next()) {
            serviceStatus = serviceTable.getServiceStatus(rset);
            services.add(serviceStatus);
        }
    } finally {
        stmt.close();
    }
    return services;
}
Also used : ServiceStatus(cbit.vcell.message.server.ServiceStatus) Statement(java.sql.Statement) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet)

Example 2 with ServiceStatus

use of cbit.vcell.message.server.ServiceStatus in project vcell by virtualcell.

the class ServiceStatusDbDriver method getServiceStatus.

/**
 * This method was created in VisualAge.
 * @return int
 * @param user java.lang.String
 * @param imageName java.lang.String
 */
public ServiceStatus getServiceStatus(Connection con, VCellServerID serverID, ServiceType type, int ordinal, boolean lockRowForUpdate) throws SQLException {
    String sql = "select * from " + serviceTable.getTableName() + " where " + serviceTable.serverID.getQualifiedColName() + "='" + serverID + "'" + " AND " + serviceTable.type.getQualifiedColName() + "='" + type.getName() + "'" + " AND " + serviceTable.ordinal.getQualifiedColName() + "=" + ordinal;
    if (lockRowForUpdate) {
        sql += " FOR UPDATE OF " + serviceTable.getTableName() + ".id";
    }
    // log.print(sql);
    Statement stmt = con.createStatement();
    ServiceStatus serviceStatus = null;
    try {
        ResultSet rset = stmt.executeQuery(sql);
        if (rset.next()) {
            serviceStatus = serviceTable.getServiceStatus(rset);
        }
    } finally {
        stmt.close();
    }
    return serviceStatus;
}
Also used : Statement(java.sql.Statement) ServiceStatus(cbit.vcell.message.server.ServiceStatus) ResultSet(java.sql.ResultSet)

Example 3 with ServiceStatus

use of cbit.vcell.message.server.ServiceStatus in project vcell by virtualcell.

the class ServiceTable method getServiceStatus.

/**
 * This method was created in VisualAge.
 * @return VCImage
 * @param rset ResultSet
 * @param log SessionLog
 */
public ServiceStatus getServiceStatus(ResultSet rset) throws SQLException {
    // serverID
    String parsedServerIDString = rset.getString(serverID.toString());
    VCellServerID parsedServerID = VCellServerID.getServerID(parsedServerIDString);
    // type
    String parsedType = rset.getString(type.toString());
    // ordinal
    int parsedOrdinal = rset.getInt(ordinal.toString());
    // startupType
    int parsedStartupType = rset.getInt(startupType.toString());
    // memoryMB
    int parsedMemoryMB = rset.getInt(memoryMB.toString());
    // date
    java.util.Date parsedDate = rset.getTimestamp(date.toString());
    if (rset.wasNull()) {
        parsedDate = null;
    }
    // status
    int parsedStatus = rset.getInt(status.toString());
    // statusMsg
    String parsedStatusMsg = rset.getString(statusMsg.toString());
    if (rset.wasNull()) {
        parsedStatusMsg = null;
    }
    // host
    HtcJobID parsedHtcJobId = null;
    String parsedHtcJobDatabaseString = rset.getString(pbsjobid.toString());
    if (!rset.wasNull() && parsedHtcJobDatabaseString != null && parsedHtcJobDatabaseString.length() > 0) {
        parsedHtcJobId = SimulationJobTable.fromDatabase(parsedHtcJobDatabaseString);
    }
    ServiceStatus serviceStatus = new ServiceStatus(new ServiceSpec(parsedServerID, ServiceType.fromName(parsedType), parsedOrdinal, ServiceStartupType.fromDatabaseNumber(parsedStartupType), parsedMemoryMB), parsedDate, ServiceStatusType.fromDatabaseNumber(parsedStatus), parsedStatusMsg, parsedHtcJobId);
    return serviceStatus;
}
Also used : VCellServerID(org.vcell.util.document.VCellServerID) ServiceStatus(cbit.vcell.message.server.ServiceStatus) ServiceSpec(cbit.vcell.message.server.ServiceSpec) HtcJobID(cbit.vcell.server.HtcJobID)

Example 4 with ServiceStatus

use of cbit.vcell.message.server.ServiceStatus in project vcell by virtualcell.

the class ServerManageConsole method newService.

void newService() {
    AddNewServiceDialog dialog = new AddNewServiceDialog(this);
    dialog.setLocationRelativeTo(this);
    dialog.setVisible(true);
    if (dialog.isAction()) {
        ServiceSpec ss = dialog.getServiceSpec();
        ServiceStatus config = new ServiceStatus(ss, null, ServiceStatusType.ServiceNotRunning, "newly created", null);
        try {
            config = adminDbTop.insertServiceStatus(config, true);
        } catch (Exception e) {
            e.printStackTrace();
            javax.swing.JOptionPane.showMessageDialog(this, e.getMessage(), "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
        }
        refresh();
    }
}
Also used : ServiceStatus(cbit.vcell.message.server.ServiceStatus) ServiceSpec(cbit.vcell.message.server.ServiceSpec) UserCancelException(org.vcell.util.UserCancelException)

Example 5 with ServiceStatus

use of cbit.vcell.message.server.ServiceStatus in project vcell by virtualcell.

the class AdminDBTopLevel method modifyServiceStatus.

public ServiceStatus modifyServiceStatus(ServiceStatus oldServiceStatus, ServiceStatus newServiceStatus, boolean bEnableRetry) throws SQLException, UpdateSynchronizationException {
    Object lock = new Object();
    Connection con = conFactory.getConnection(lock);
    try {
        ServiceStatus currentServiceStatus = serviceStatusDB.getServiceStatus(con, oldServiceStatus.getServiceSpec().getServerID(), oldServiceStatus.getServiceSpec().getType(), oldServiceStatus.getServiceSpec().getOrdinal(), false);
        if (!currentServiceStatus.compareEqual(oldServiceStatus)) {
            throw new UpdateSynchronizationException("service doesn't exist:" + currentServiceStatus);
        }
        serviceStatusDB.updateServiceStatus(con, newServiceStatus);
        con.commit();
        ServiceStatus updatedServiceStatus = serviceStatusDB.getServiceStatus(con, oldServiceStatus.getServiceSpec().getServerID(), oldServiceStatus.getServiceSpec().getType(), oldServiceStatus.getServiceSpec().getOrdinal(), false);
        return updatedServiceStatus;
    } catch (Throwable e) {
        lg.error("failure in modifyServiceStatus()", e);
        try {
            con.rollback();
        } catch (Throwable rbe) {
            lg.error("exception during rollback, bEnableRetry = " + bEnableRetry, rbe);
        }
        if (bEnableRetry && isBadConnection(con)) {
            conFactory.failed(con, lock);
            return modifyServiceStatus(oldServiceStatus, newServiceStatus, false);
        } else {
            handle_SQLException(e);
            return null;
        }
    } finally {
        conFactory.release(con, lock);
    }
}
Also used : ServiceStatus(cbit.vcell.message.server.ServiceStatus) Connection(java.sql.Connection) UpdateSynchronizationException(cbit.vcell.server.UpdateSynchronizationException)

Aggregations

ServiceStatus (cbit.vcell.message.server.ServiceStatus)8 UpdateSynchronizationException (cbit.vcell.server.UpdateSynchronizationException)4 Connection (java.sql.Connection)4 ServiceSpec (cbit.vcell.message.server.ServiceSpec)2 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2 HtcJobID (cbit.vcell.server.HtcJobID)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 DataAccessException (org.vcell.util.DataAccessException)1 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)1 UserCancelException (org.vcell.util.UserCancelException)1 UseridIDExistsException (org.vcell.util.UseridIDExistsException)1 VCellServerID (org.vcell.util.document.VCellServerID)1