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;
}
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;
}
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;
}
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();
}
}
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);
}
}
Aggregations