Author: rob.stryker(a)jboss.com
Date: 2008-03-07 18:08:31 -0500 (Fri, 07 Mar 2008)
New Revision: 6796
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
Log:
Continued API change. Bug consisted of poll threads continuing to run even if somehow the
server state changed adn the poll thread was unaware. This leads to continued polling even
when the process has been canceled, for example. Fixed.
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java 2008-03-07
22:12:25 UTC (rev 6795)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java 2008-03-07
23:08:31 UTC (rev 6796)
@@ -268,4 +268,8 @@
public void setPollerType(ServerStatePollerType type) {
this.type = type;
}
+
+ public IServer getServer() {
+ return server;
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java 2008-03-07
22:12:25 UTC (rev 6795)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java 2008-03-07
23:08:31 UTC (rev 6796)
@@ -51,6 +51,10 @@
this.server = (JBossServerBehavior)server.loadAdapter(JBossServerBehavior.class, new
NullProgressMonitor());
}
+ public IServer getServer() {
+ return server.getServer();
+ }
+
public void cancel(int type) {
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java 2008-03-07
22:12:25 UTC (rev 6795)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/TimeoutPoller.java 2008-03-07
23:08:31 UTC (rev 6796)
@@ -54,6 +54,10 @@
this.server = server;
this.endTime = new Date().getTime() + getTimeout() - 2000;
}
+
+ public IServer getServer() {
+ return server;
+ }
public void cancel(int type) {
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2008-03-07
22:12:25 UTC (rev 6795)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2008-03-07
23:08:31 UTC (rev 6796)
@@ -40,11 +40,13 @@
public static final int CANCEL = 0;
public static final int TIMEOUT_REACHED = 1;
+ public static final int SUCCESS = 2;
+ public static final int FAILED = 3;
public ServerStatePollerType getPollerType();
public void setPollerType(ServerStatePollerType type);
public void beginPolling(IServer server, boolean expectedState, PollThread pt); //
expected to launch own thread
-
+ public IServer getServer();
public boolean isComplete() throws PollingException, RequiresInfoException;
public boolean getState() throws PollingException, RequiresInfoException;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2008-03-07
22:12:25 UTC (rev 6795)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2008-03-07
23:08:31 UTC (rev 6796)
@@ -58,9 +58,8 @@
public static final String POLL_THREAD_EXCEPTION_MESSAGE =
"org.jboss.ide.eclipse.as.core.runtime.server.PollThread.exception.message";
- private boolean expectedState;
+ private boolean expectedState, abort, stateStartedOrStopped;
private IServerStatePoller poller;
- private boolean abort;
private String abortMessage;
private JBossServerBehavior behavior;
private EventLogRoot eventRoot;
@@ -138,7 +137,8 @@
poller.beginPolling(getServer(), expectedState, this);
// begin the loop; ask the poller every so often
- while( !abort && !done && new Date().getTime() < startTime + maxWait
) {
+ while( !stateStartedOrStopped && !abort && !done &&
+ new Date().getTime() < startTime + maxWait ) {
try {
Thread.sleep(100);
} catch( InterruptedException ie ) { }
@@ -161,15 +161,26 @@
handler.handle(poller, action, poller.getRequiredProperties());
}
}
+ stateStartedOrStopped = checkServerState();
}
- boolean currentState = !expectedState;
// we stopped. Did we abort?
- if( abort ) {
+ if( stateStartedOrStopped ) {
+ int state = behavior.getServer().getServerState();
+ boolean success = false;
+ if( expectedState == IServerStatePoller.SERVER_UP)
+ success = state == IServer.STATE_STARTED;
+ else
+ success = state == IServer.STATE_STOPPED;
+
+ poller.cancel(success ? IServerStatePoller.SUCCESS : IServerStatePoller.FAILED);
+ poller.cleanup();
+ } else if( abort ) {
poller.cancel(IServerStatePoller.CANCEL);
poller.cleanup();
alertEventLogAbort();
} else {
+ boolean currentState = !expectedState;
boolean finalAlert = true;
if( done ) {
// the poller has an answer
@@ -198,6 +209,13 @@
}
}
+ protected boolean checkServerState() {
+ int state = behavior.getServer().getServerState();
+ if( state == IServer.STATE_STARTED ) return true;
+ if( state == IServer.STATE_STOPPED ) return true;
+ return false;
+ }
+
protected void alertBehavior(boolean currentState, boolean finalAlert) {
if( currentState != expectedState ) {
// it didnt work... cancel all processes! force stop
Show replies by date