Skip to content

Commit

Permalink
Merge pull request #836 from virtualcell/834-refine-database-logging
Browse files Browse the repository at this point in the history
refine database logging, and Biomodel saves
  • Loading branch information
jcschaff authored Mar 17, 2023
2 parents 75037aa + 92d098a commit aca89dd
Show file tree
Hide file tree
Showing 146 changed files with 653 additions and 462 deletions.
2 changes: 1 addition & 1 deletion docker/build/vcell-api.log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</Root>
<!-- <Logger name="org.vcell" level="warn" />-->
<!-- <Logger name="cbit.vcell" level="warn" />-->
<!-- <Logger name="cbit.vcell.modeldb" level="warn" />-->
<Logger name="cbit.vcell.modeldb" level="debug" />
<!-- <Logger name="cbit.vcell.message.server.cmd" level="debug" />-->
<!-- <Logger name="org.vcell.util.exe" level="debug" />-->
<!-- <Logger name="org.vcell.util.CommentStringTokenizer" level="warn" />-->
Expand Down
2 changes: 1 addition & 1 deletion docker/build/vcell-data.log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</Root>
<!-- <Logger name="org.vcell" level="warn" />-->
<!-- <Logger name="cbit.vcell" level="warn" />-->
<!-- <Logger name="cbit.vcell.modeldb" level="warn" />-->
<Logger name="cbit.vcell.modeldb" level="debug" />
<!-- <Logger name="cbit.vcell.message.server.cmd" level="debug" />-->
<!-- <Logger name="org.vcell.util.exe" level="debug" />-->
<!-- <Logger name="org.vcell.util.CommentStringTokenizer" level="warn" />-->
Expand Down
2 changes: 1 addition & 1 deletion docker/build/vcell-db.log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</Root>
<!-- <Logger name="org.vcell" level="warn" />-->
<!-- <Logger name="cbit.vcell" level="warn" />-->
<!-- <Logger name="cbit.vcell.modeldb" level="warn" />-->
<Logger name="cbit.vcell.modeldb" level="debug" />
<!-- <Logger name="cbit.vcell.message.server.cmd" level="debug" />-->
<!-- <Logger name="org.vcell.util.exe" level="debug" />-->
<!-- <Logger name="org.vcell.util.CommentStringTokenizer" level="warn" />-->
Expand Down
2 changes: 1 addition & 1 deletion docker/build/vcell-sched.log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</Root>
<!-- <Logger name="org.vcell" level="warn" />-->
<!-- <Logger name="cbit.vcell" level="warn" />-->
<!-- <Logger name="cbit.vcell.modeldb" level="warn" />-->
<Logger name="cbit.vcell.modeldb" level="debug" />
<!-- <Logger name="cbit.vcell.message.server.cmd" level="warn" />-->
<!-- <Logger name="org.vcell.util.exe" level="warn" />-->
<!-- <Logger name="org.vcell.util.CommentStringTokenizer" level="warn" />-->
Expand Down
2 changes: 1 addition & 1 deletion docker/build/vcell-submit.log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<!-- <Logger name="cbit.vcell.mongodb" level="trace" />-->
<!-- <Logger name="org.vcell" level="warn" />-->
<!-- <Logger name="cbit.vcell" level="warn" />-->
<!-- <Logger name="cbit.vcell.modeldb" level="warn" />-->
<Logger name="cbit.vcell.modeldb" level="debug" />
<!-- <Logger name="cbit.vcell.message.server.cmd" level="warn" />-->
<!-- <Logger name="org.vcell.util.exe" level="warn" />-->
<!-- <Logger name="org.vcell.util.CommentStringTokenizer" level="warn" />-->
Expand Down
2 changes: 1 addition & 1 deletion docker/build/vcell-web.log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</Root>
<!-- <Logger name="org.vcell" level="warn" />-->
<!-- <Logger name="cbit.vcell" level="warn" />-->
<!-- <Logger name="cbit.vcell.modeldb" level="warn" />-->
<Logger name="cbit.vcell.modeldb" level="debug" />
<!-- <Logger name="cbit.vcell.message.server.cmd" level="debug" />-->
<!-- <Logger name="org.vcell.util.exe" level="debug" />-->
<!-- <Logger name="org.vcell.util.CommentStringTokenizer" level="warn" />-->
Expand Down
52 changes: 32 additions & 20 deletions vcell-admin/src/main/java/org/vcell/stochtest/StochtestDbUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import java.sql.ResultSet;
import java.sql.SQLException;

import cbit.vcell.modeldb.DbDriver;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.vcell.db.ConnectionFactory;
import org.vcell.stochtest.TimeSeriesMultitrialData.SummaryStatistics;
import org.vcell.util.DataAccessException;
Expand All @@ -14,6 +17,7 @@
import cbit.vcell.modeldb.StochtestTable;

public class StochtestDbUtils {
private static final Logger lg = LogManager.getLogger(StochtestDbUtils.class);

public static StochtestRun getStochtestRun(ConnectionFactory conFactory, KeyValue stochtestRunKey) throws IllegalArgumentException, SQLException, DataAccessException {

Expand Down Expand Up @@ -112,11 +116,13 @@ public static void finalizeAcceptedStochtestRun(ConnectionFactory conFactory, St
stochtestRunTable.networkGenProbs.getUnqualifiedColName() + " = " + networkGenProbsRHS + " " +
" WHERE "+stochtestRunTable.id.getUnqualifiedColName()+" = " + acceptedStochtestRun.key.toString();
stmt = con.createStatement();
System.out.println(sql);
int numrows = stmt.executeUpdate(sql);
if (numrows != 1){
throw new DataAccessException("failed to update mathgen status for id = "+acceptedStochtestRun.key);
}
if (lg.isDebugEnabled()) {
lg.debug("executeUpdate() SQL: '" + sql + "'", new DbDriver.StackTraceGenerationException());
}
int numrows = stmt.executeUpdate(sql); // jcs: added logging
if (numrows != 1) {
throw new DataAccessException("failed to update mathgen status for id = " + acceptedStochtestRun.key);
}
} finally {
if (stmt != null) {
stmt.close();
Expand Down Expand Up @@ -171,11 +177,13 @@ public static void finalizeAcceptedStochtestCompare(ConnectionFactory conFactory
}
sql += " WHERE "+stochtestCompareTable.id.getUnqualifiedColName()+" = " + acceptedStochtestCompare.key.toString();
stmt = con.createStatement();
System.out.println(sql);
int numrows = stmt.executeUpdate(sql);
if (numrows != 1){
throw new DataAccessException("failed to update mathgen status for id = "+acceptedStochtestCompare.key);
}
if (lg.isDebugEnabled()) {
lg.debug("executeUpdate() SQL: '" + sql + "'", new DbDriver.StackTraceGenerationException());
}
int numrows = stmt.executeUpdate(sql); // jcs: added logging
if (numrows != 1) {
throw new DataAccessException("failed to update mathgen status for id = " + acceptedStochtestCompare.key);
}
} finally {
if (stmt != null) {
stmt.close();
Expand Down Expand Up @@ -262,11 +270,13 @@ public static StochtestRun acceptNextWaitingStochtestRun(ConnectionFactory conFa
" SET "+stochtestRunTable.status.getUnqualifiedColName() + " = " + "'"+StochtestRun.StochtestRunStatus.accepted+"'" +
" WHERE "+stochtestRunTable.id.getUnqualifiedColName()+" = " + stochtestRun.key.toString();
stmt = con.createStatement();
System.out.println(sql);
int numrows = stmt.executeUpdate(sql);
if (numrows != 1){
throw new DataAccessException("failed to update mathgen status for id = "+stochtestRun.key);
}
if (lg.isDebugEnabled()) {
lg.debug("executeUpdate() SQL: '" + sql + "'", new DbDriver.StackTraceGenerationException());
}
int numrows = stmt.executeUpdate(sql); // jcs: added logging
if (numrows != 1) {
throw new DataAccessException("failed to update mathgen status for id = " + stochtestRun.key);
}
} finally {
if (stmt != null) {
stmt.close();
Expand Down Expand Up @@ -341,11 +351,13 @@ public static StochtestCompare acceptNextWaitingStochtestCompare(ConnectionFacto
" SET "+stochtestCompareTable.status.getUnqualifiedColName() + " = " + "'"+StochtestCompare.StochtestCompareStatus.accepted+"'" +
" WHERE "+stochtestCompareTable.id.getUnqualifiedColName()+" = " + stochtestCompare.key.toString();
stmt = con.createStatement();
System.out.println(sql);
int numrows = stmt.executeUpdate(sql);
if (numrows != 1){
throw new DataAccessException("failed to update mathgen status for id = "+stochtestCompare.key);
}
if (lg.isDebugEnabled()) {
lg.debug("executeUpdate() SQL: '" + sql + "'", new DbDriver.StackTraceGenerationException());
}
int numrows = stmt.executeUpdate(sql); // jcs: added logging
if (numrows != 1) {
throw new DataAccessException("failed to update mathgen status for id = " + stochtestCompare.key);
}
} finally {
if (stmt != null) {
stmt.close();
Expand Down
2 changes: 1 addition & 1 deletion vcell-api/src/main/java/org/vcell/rest/UserVerifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public AuthenticationStatus verify(ChallengeResponse challengeResponse) {
return AuthenticationStatus.valid;
}
}catch (Exception e){
lg.error(e);
lg.error(e.getMessage(), e);
return AuthenticationStatus.invalid;
}
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected int logout(Request request, Response response) {
}

}catch (Exception e){
lg.error(e);
lg.error(e.getMessage(), e);
getLogger().log(Level.SEVERE,"MyCookieAuthenticator.logout(request,response) - exception while invalidating '"+CustomAuthHelper.ACCESS_TOKEN+"'",e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void handle(Request req, Response response) {

} catch (Exception e) {
getLogger().severe("failed to retrieve job status: "+e.getMessage());
lg.error(e);
lg.error(e.getMessage(), e);
response.setStatus(Status.SERVER_ERROR_INTERNAL);
response.setEntity("failed to retrieve job status: "+e.getMessage(), MediaType.TEXT_PLAIN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void handle(Request req, Response response) {
response.setEntity(new JsonRepresentation(eventWrappersJSON));
} catch (Exception e) {
getLogger().severe("internal error retrieving events: "+e.getMessage());
lg.error(e);
lg.error(e.getMessage(), e);
response.setStatus(Status.SERVER_ERROR_INTERNAL);
response.setEntity("internal error retrieving events: "+e.getMessage(), MediaType.TEXT_PLAIN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void handle(Request req, Response response) {
}
}
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
response.setStatus(Status.SERVER_ERROR_INTERNAL);
response.setEntity("failed to retrieve system health: "+e.getMessage(), MediaType.TEXT_PLAIN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public void setMessage(String message) { }
try {
vcellConnection.getSimulationController().stopSimulation(runningSimId);
}catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
}
}
if (savedBioModelKey!=null) {
Expand Down
4 changes: 2 additions & 2 deletions vcell-api/src/main/java/org/vcell/rest/rpc/RpcRestlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void handle(Request req, Response response) {
} catch (Exception e) {
String errMesg = "<html><body>Error RpcRestlet.handle(...) req='"+req.toString()+"' <br>err='"+e.getMessage()+"'</br>"+"</body></html>";
getLogger().severe(errMesg);
lg.error(e);
lg.error(e.getMessage(), e);
response.setStatus(Status.SERVER_ERROR_INTERNAL);
response.setEntity(errMesg, MediaType.TEXT_HTML);
}
Expand Down Expand Up @@ -185,7 +185,7 @@ public void handle(Request req, Response response) {
response.setEntity(new ByteArrayRepresentation(serializedResultObject));
return;
} catch (Exception e1) {
lg.error(e1);
lg.error(e1.getMessage(), e1);
//continue and send error message
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public ByteArrayRepresentation get_png() {
byte[] imageBytes = outputStream.toByteArray();
return new ByteArrayRepresentation(imageBytes, MediaType.IMAGE_PNG, imageBytes.length);
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void save(JsonRepresentation jsonOverrides) throws JSONException {
lg.error(e);
throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "simulation not found");
} catch (Exception e){
lg.error(e);
lg.error(e.getMessage(), e);
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public StringRepresentation get_html() {
StringBuffer sb = createHtml(bm);
return new StringRepresentation(sb.toString(), MediaType.TEXT_HTML);
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
if(e instanceof ResourceException) {
throw (ResourceException)e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public OptSocketStreams(Socket optSocket, ObjectInputStream ois, ObjectOutputStr
}
public void closeAll(String optID) {
paramOptActiveSockets.remove(optID);
try{ois.close();}catch(Exception e2) { lg.error(e2); }
try{oos.close();}catch(Exception e2) { lg.error(e2); }
try{optSocket.close();}catch(Exception e2) { lg.error(e2); }
try{ois.close();}catch(Exception e2) { lg.error(e2.getMessage(), e2); }
try{oos.close();}catch(Exception e2) { lg.error(e2.getMessage(), e2); }
try{optSocket.close();}catch(Exception e2) { lg.error(e2.getMessage(), e2); }
}
public OptMessage.OptResponseMessage sendCommand(OptMessage.OptCommandMessage optCommandMessage) throws IOException,ClassNotFoundException{
lg.info("sending command "+optCommandMessage+" with ID="+optCommandMessage.optID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public SimulationRep startSimulation(BiomodelSimulationStartServerResource resou
try {
userLoginInfo.setUser(vcellUser);
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
throw new DataAccessException(e.getMessage());
}
RpcSimServerProxy rpcSimServerProxy = new RpcSimServerProxy(userLoginInfo, rpcSession);
Expand Down Expand Up @@ -223,7 +223,7 @@ public SimulationRep stopSimulation(BiomodelSimulationStopServerResource resourc
try {
userLoginInfo.setUser(vcellUser);
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
throw new DataAccessException(e.getMessage());
}
RpcSimServerProxy rpcSimServerProxy = new RpcSimServerProxy(userLoginInfo, rpcSession);
Expand Down Expand Up @@ -713,7 +713,7 @@ public SimpleJobStatus[] query(SimulationTasksServerResource resource, User vcel
try {
userLoginInfo.setUser(vcellUser);
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
throw new DataAccessException(e.getMessage());
}
RpcSimServerProxy rpcSimServerProxy = new RpcSimServerProxy(userLoginInfo, rpcSession);
Expand Down Expand Up @@ -778,7 +778,7 @@ public SimulationStatusRepresentation[] query(SimulationStatusServerResource res
try {
userLoginInfo.setUser(vcellUser);
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
throw new DataAccessException(e.getMessage());
}
RpcSimServerProxy rpcSimServerProxy = new RpcSimServerProxy(userLoginInfo, rpcSession);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Representation get_html() {
try {
simData = getSimDataRepresentation(vcellUser);
}catch (Exception e){
lg.error(e);
lg.error(e.getMessage(), e);
}
Map<String,Object> dataModel = new HashMap<String,Object>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public boolean accept(File pathname) {
mapBMidToBiomodelRep.put(bm.getVersion().getVersionKey().toString(), bmrep);
} catch (Exception e) {
// TODO Auto-generated catch block
lg.error(e);
lg.error(e.getMessage(), e);
}
}
//Create a Restlet server on local machine that will accept queries from a regular web browser
Expand All @@ -130,7 +130,7 @@ public boolean accept(File pathname) {
restletComponent.start();
} catch (Exception e) {
// TODO Auto-generated catch block
lg.error(e);
lg.error(e.getMessage(), e);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void handle(Request request, Response response) {

sendErrorReportEmail(errorReport);
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
response.setStatus(Status.SERVER_ERROR_INTERNAL);
response.setEntity("We failed to report an error to VCell support", MediaType.TEXT_PLAIN);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void handle(Request request, Response response) {
VCellApiApplication vcellApiApplication = (VCellApiApplication)getApplication();
vcellApiApplication.getRestDatabaseService().sendLostPassword(userid);
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
response.setStatus(Status.SERVER_ERROR_INTERNAL);
response.setEntity("we failed to send a verification email for account '"+userid+"': "+e.getMessage(), MediaType.TEXT_PLAIN);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void handleJsonRequest(Request request, Response response) {
request.getResourceRef().getHostIdentifier()+"/"+VCellApiApplication.NEWUSER_VERIFY+"?"+VCellApiApplication.EMAILVERIFYTOKEN_FORMNAME+"="+emailVerifyToken.getString()
);
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
response.setStatus(Status.SERVER_ERROR_INTERNAL);
response.setEntity("we failed to send a verification email to "+newUserInfo.email, MediaType.TEXT_PLAIN);
return;
Expand Down Expand Up @@ -227,7 +227,7 @@ public void handle(Request request, Response response) {
request.getResourceRef().getHostIdentifier()+"/"+VCellApiApplication.NEWUSER_VERIFY+"?"+VCellApiApplication.EMAILVERIFYTOKEN_FORMNAME+"="+emailVerifyToken.getString()
);
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
response.setStatus(Status.SERVER_ERROR_INTERNAL);
response.setEntity("we failed to send a verification email to "+newUserInfo.email, MediaType.TEXT_PLAIN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ public void propertyChange(java.beans.PropertyChangeEvent evt) {
}
}
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
}
}
if (evt.getSource() == optSolverCallbacks && (evt.getPropertyName().equals(CopasiOptSolverCallbacks.STOP_REQUESTED))) {
Expand All @@ -592,7 +592,7 @@ public void propertyChange(java.beans.PropertyChangeEvent evt) {
OptimizationResultSet optimizationResultSet = CopasiUtils.getOptimizationResultSet(parameterEstimationTask, optSolverCallbacks.getProgressReport());
parameterEstimationTask.setOptimizationResultSet(optimizationResultSet);
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion vcell-core/src/main/java/cbit/gui/graph/GraphModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public void paint(java.awt.Graphics2D g) {
g.setColor(Color.red);
g.drawString("EXCEPTION IN GraphModel.paint(): " + e.getMessage(),
20, 20);
lg.error(e);
lg.error(e.getMessage(), e);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void collapseAsNewGroup() {
ShapeGroupUtil.collapseGroup(groupShape);
graphView.repaint();
} catch (Exception e) {
lg.error(e);
lg.error(e.getMessage(), e);
}
}

Expand Down
Loading

0 comments on commit aca89dd

Please sign in to comment.