Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a number of issues, all revolving around VCell locking up under the right (wrong) conditions #1332

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
cfc3aef
Formatting updates
CodeByDrescher Jul 22, 2024
0687ef5
[WIP] Added dispatch call to schedule check
CodeByDrescher Jul 22, 2024
3171869
Formatting fixes
CodeByDrescher Jul 22, 2024
337ac53
Create instance of SwingWorker to help separate responsibility.
CodeByDrescher Jul 22, 2024
75f702b
Clean-up SwingWorker
CodeByDrescher Jul 22, 2024
d126ca0
Cleaning up Swing Worker logic Part 1
CodeByDrescher Jul 22, 2024
05c82ab
Separate anonymous SwingWorker instance into independent class
CodeByDrescher Jul 22, 2024
2deef28
Formatting and Rearranging
CodeByDrescher Jul 22, 2024
cf75f95
Added missing parameters
CodeByDrescher Jul 22, 2024
42db58c
class name changes
CodeByDrescher Jul 23, 2024
9fb88fe
Change API logging to display certain info notices when debug is enabled
CodeByDrescher Jul 23, 2024
4b5d063
More transition from magic strings to enums
CodeByDrescher Jul 23, 2024
1f416bb
Changed name to match similar closures
CodeByDrescher Jul 23, 2024
f631690
Integrated Futures into newly named VCellSwingWorker system
CodeByDrescher Jul 23, 2024
7550f35
Changed to blocking call; currently negligible delay
CodeByDrescher Jul 24, 2024
9fec4a7
changed to debug call
CodeByDrescher Jul 24, 2024
3c1296e
Removed object synchronization, and instead locked on the object;
CodeByDrescher Jul 24, 2024
975aee6
Formatting updates
CodeByDrescher Jul 22, 2024
318e233
[WIP] Added dispatch call to schedule check
CodeByDrescher Jul 22, 2024
9ad335b
Formatting fixes
CodeByDrescher Jul 22, 2024
3059360
Create instance of SwingWorker to help separate responsibility.
CodeByDrescher Jul 22, 2024
94efc81
Clean-up SwingWorker
CodeByDrescher Jul 22, 2024
64046b9
Cleaning up Swing Worker logic Part 1
CodeByDrescher Jul 22, 2024
f7495a4
Separate anonymous SwingWorker instance into independent class
CodeByDrescher Jul 22, 2024
05291f4
Formatting and Rearranging
CodeByDrescher Jul 22, 2024
02c2a12
Added missing parameters
CodeByDrescher Jul 22, 2024
bc113ac
class name changes
CodeByDrescher Jul 23, 2024
a05615f
Change API logging to display certain info notices when debug is enabled
CodeByDrescher Jul 23, 2024
da8a010
More transition from magic strings to enums
CodeByDrescher Jul 23, 2024
27ba0cc
Changed name to match similar closures
CodeByDrescher Jul 23, 2024
fdf9f96
Integrated Futures into newly named VCellSwingWorker system
CodeByDrescher Jul 23, 2024
e342110
Changed to blocking call; currently negligible delay
CodeByDrescher Jul 24, 2024
22adf12
changed to debug call
CodeByDrescher Jul 24, 2024
f307ae0
Removed object synchronization, and instead locked on the object;
CodeByDrescher Jul 24, 2024
68c4662
Merge remote-tracking branch 'origin/PrimaryLockUpFix_BadRemoteCall' …
CodeByDrescher Jul 24, 2024
12d5e2a
Removed super useful logging.
CodeByDrescher Jul 24, 2024
08f7039
Changed to "tryLock()" to prevent uneccessary reconnect calls
CodeByDrescher Jul 24, 2024
19753af
Cleaned up ClientRequestManager
CodeByDrescher Jul 24, 2024
3c95fbe
Clean up class
CodeByDrescher Jul 24, 2024
2f40a44
Commented out unused class (will delete once confirmed not useful)
CodeByDrescher Jul 24, 2024
f9ed66b
Restored logging to polling
CodeByDrescher Jul 26, 2024
883b484
Changed debug_log4j2 to actually use debug levels
CodeByDrescher Jul 26, 2024
0f750e3
Logging Improvements for clarity, organization, and efficiency
CodeByDrescher Jul 26, 2024
3a3b1bb
Fixed pop-up window's message when VCell is opened without internet
CodeByDrescher Jul 26, 2024
7a262a3
Fixed NPE exception
CodeByDrescher Jul 26, 2024
297fca1
Added timeout to message call to drastically improve disconnect response
CodeByDrescher Jul 26, 2024
8d8fa35
eliminated unnecessary instance variable and further improved respons…
CodeByDrescher Jul 26, 2024
da0f3b2
Used Collatz Conjecture to check timeout feature.
CodeByDrescher Jul 26, 2024
3a02aeb
Cleaned up class
CodeByDrescher Jul 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions debug_log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
</Appenders>

<Loggers>
<Logger name="org.vcell" level="info" additivity="false">
<Logger name="org.vcell" level="debug" additivity="false">
<AppenderRef ref="console"/>
</Logger>
<Logger name="cbit" level="info" additivity="false">
<Logger name="cbit" level="debug" additivity="false">
<AppenderRef ref="console"/>
</Logger>
<Logger name="cbit" level="info" additivity="false">
<Logger name="cbit" level="debug" additivity="false">
<AppenderRef ref="console"/>
</Logger>
<Logger name="org.apache.http" level="info" additivity="false">
Expand All @@ -28,7 +28,7 @@
<Logger name = "io.jhdf" level="warn" additivity="false">
<AppenderRef ref="console"/>
</Logger>
<Root level="info">
<Root level="debug">
<AppenderRef ref="console"/>
</Root>
</Loggers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

import java.awt.*;
import java.util.Hashtable;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static cbit.vcell.client.task.AsynchClientTask.*;

Expand Down Expand Up @@ -40,6 +43,37 @@ public void sbNotLast( ) {
test(TASKTYPE_NONSWING_BLOCKING,TASKTYPE_NONSWING_BLOCKING, TASKTYPE_SWING_NONBLOCKING, TASKTYPE_NONSWING_BLOCKING);
});
}

@Test void blockingCheck(){
AsynchClientTask collatzConjecture = new AsynchClientTask(
"Collatz Conjecture", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
for (long startingNum = 1; startingNum < Long.MAX_VALUE; startingNum++) {
long currentNum = startingNum;
long counter = 0;
while(true){
if (currentNum == 1 || currentNum == 2 || currentNum == 4) {
// We won't waste storage space
System.out.print(counter + ", ");
break;
}
counter++;
if (currentNum % 2 == 0) currentNum /= 2; // Even case
if (currentNum %2 == 1) currentNum = (3 * currentNum) + 1;
}
}
}
} ;
Assertions.assertThrows(TimeoutException.class, () -> {
Hashtable<String, Object> hashTable = new Hashtable<>();
Future<?> terribleFuture = ClientTaskDispatcher.dispatchWithFuture(null, hashTable,
new AsynchClientTask[]{collatzConjecture});
terribleFuture.get(2, TimeUnit.SECONDS); // Not expensive but significant timeout
});

}

private AsynchClientTask[] create(int ... types) {
AsynchClientTask[] rval = new AsynchClientTask[types.length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
public class VCellApiClient implements AutoCloseable {

private static final Logger lg = LogManager.getLogger(VCellApiClient.class);
private static final boolean activeLogLevelIsSensitiveEnough;

static {
activeLogLevelIsSensitiveEnough = lg.isTraceEnabled();
}

private final HttpHost httpHost;
private final String pathPrefix_v0;
private final String clientID;
Expand Down Expand Up @@ -202,13 +208,13 @@ public SimulationTaskRepresentation[] getSimTasks(SimTasksQuerySpec simTasksQuer
HttpGet httpget = new HttpGet(getApiUrlPrefix() + "/simtask?" + simTasksQuerySpec.getQueryString());
httpget.addHeader("Authorization","Bearer "+httpClientContext.getUserToken(String.class));

if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("Executing request to retrieve simulation tasks " + httpget.getRequestLine());
}

String responseBody = httpclient.execute(httpget, new VCellStringResponseHandler("getSimTasks()", httpget), httpClientContext);
String simTasksJson = responseBody;
if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("returned: "+toStringTruncated(simTasksJson));
}

Expand All @@ -231,13 +237,13 @@ public BiomodelRepresentation[] getBioModels(BioModelsQuerySpec bioModelsQuerySp
HttpGet httpget = new HttpGet(getApiUrlPrefix()+"/biomodel?"+bioModelsQuerySpec.getQueryString());
httpget.addHeader("Authorization","Bearer "+httpClientContext.getUserToken(String.class));

if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("Executing request to retrieve biomodels " + httpget.getRequestLine());
}

String responseBody = httpclient.execute(httpget, new VCellStringResponseHandler("getBioModels()", httpget), httpClientContext);
String bimodelsJson = responseBody;
if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("returned: "+toStringTruncated(bimodelsJson));
}

Expand All @@ -251,13 +257,13 @@ public EventWrapper[] getEvents(long beginTimestamp) throws IOException {
HttpGet httpget = new HttpGet(getApiUrlPrefix()+"/events?beginTimestamp="+beginTimestamp);
httpget.addHeader("Authorization","Bearer "+httpClientContext.getUserToken(String.class));

if (lg.isInfoEnabled()) {
if (lg.isTraceEnabled()) {
lg.info("Executing request to retrieve user events " + httpget.getRequestLine());
}

String responseBody = httpclient.execute(httpget, new VCellStringResponseHandler("getEvents()", httpget), httpClientContext);
String eventWrappersJson = responseBody;
if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("returned: "+toStringTruncated(eventWrappersJson));
}

Expand All @@ -271,13 +277,13 @@ public BiomodelRepresentation getBioModel(String bmId) throws IOException {
HttpGet httpget = new HttpGet(getApiUrlPrefix()+"/biomodel/"+bmId);
httpget.addHeader("Authorization","Bearer "+httpClientContext.getUserToken(String.class));

if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("Executing request to retrieve biomodel " + httpget.getRequestLine());
}

String responseBody = httpclient.execute(httpget, new VCellStringResponseHandler("getBioModel()", httpget), httpClientContext);
String bimodelsJson = responseBody;
if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("returned: "+toStringTruncated(bimodelsJson));
}

Expand All @@ -291,7 +297,7 @@ public String getBioModelVCML(String bmId) throws IOException {
HttpGet httpget = new HttpGet(getApiUrlPrefix()+"/biomodel/"+bmId+"/biomodel.vcml");
httpget.addHeader("Authorization","Bearer "+httpClientContext.getUserToken(String.class));

if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("Executing request to retrieve biomodel " + httpget.getRequestLine());
}

Expand All @@ -306,13 +312,13 @@ public SimulationRepresentation getSimulation(String bmId, String simKey) throws
HttpGet httpget = new HttpGet(getApiUrlPrefix()+"/biomodel/"+bmId+"/simulation/"+simKey);
httpget.addHeader("Authorization","Bearer "+httpClientContext.getUserToken(String.class));

if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("Executing request to retrieve simulation " + httpget.getRequestLine());
}

String responseBody = httpclient.execute(httpget, new VCellStringResponseHandler("getSimulation()", httpget), httpClientContext);
String simulationJson = responseBody;
if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("returned: "+toStringTruncated(simulationJson));
}

Expand All @@ -326,12 +332,12 @@ public String getOptRunJson(String optimizationId,boolean bStop) throws IOExcept
HttpGet httpget = new HttpGet(getApiUrlPrefix()+"/optimization/"+optimizationId+"?bStop="+bStop);
httpget.addHeader("Authorization","Bearer "+httpClientContext.getUserToken(String.class));

if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("Executing request to retrieve optimization run " + httpget.getRequestLine());
}

String responseBody = httpclient.execute(httpget, new VCellStringResponseHandler("getOptRunJson()", httpget), httpClientContext);
if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("returned: "+toStringTruncated(responseBody));
}
return responseBody;
Expand Down Expand Up @@ -429,7 +435,7 @@ public SimulationTaskRepresentation[] startSimulation(String bmId, String simKey
HttpPost httppost = new HttpPost(getApiUrlPrefix()+"/biomodel/"+bmId+"/simulation/"+simKey+"/startSimulation");
httppost.addHeader("Authorization", "Bearer "+httpClientContext.getUserToken(String.class));

if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("Executing request to retrieve simulation " + httppost.getRequestLine());
}

Expand All @@ -453,13 +459,13 @@ public SimulationTaskRepresentation[] stopSimulation(String bmId, String simKey)
HttpPost httppost = new HttpPost(getApiUrlPrefix()+"/biomodel/"+bmId+"/simulation/"+simKey+"/stopSimulation");
httppost.addHeader("Authorization", "Bearer "+httpClientContext.getUserToken(String.class));

if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("Executing request to retrieve simulation " + httppost.getRequestLine());
}

String responseBody = httpclient.execute(httppost, new VCellStringResponseHandler("stopSimulation()", httppost), httpClientContext);
String simTaskReps = responseBody;
if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("returned: "+toStringTruncated(simTaskReps));
}

Expand Down Expand Up @@ -826,7 +832,7 @@ public String getServerSoftwareVersion() throws ClientProtocolException, IOExcep

HttpGet httpget = new HttpGet(getApiUrlPrefix()+"/swversion");

if (lg.isInfoEnabled()) {
if (activeLogLevelIsSensitiveEnough) {
lg.info("Executing request to retrieve server software version " + httpget.getRequestLine());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@
import cbit.gui.graph.actions.CartoonToolSaveAsImageActions;
import cbit.gui.graph.actions.GraphViewAction;
import cbit.gui.graph.groups.VCGroupManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.vcell.util.gui.GeneralGuiUtils;

public abstract class CartoonTool implements GraphView, MouseListener,
MouseMotionListener, ActionListener, KeyListener {

private static final Logger lg = LogManager.getLogger(CartoonTool.class);
public static final boolean GROUPS_ARE_ENABLED = false;

private GraphPane graphPane = null;
Expand Down Expand Up @@ -359,7 +361,7 @@ public final void updateButtonGroup(ButtonGroup buttonGroup,
return;
}
}
System.out.println("ERROR: button with actionCommand " + actionCommand + " not found");
lg.warn("ERROR: button with actionCommand {} not found", actionCommand);
return;
}

Expand Down
Loading
Loading