Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2013-06-10 10:38:03 -0400
committerMarkus Tiede2013-06-10 10:38:08 -0400
commitc330a3fddda4b5154098ad5ac6849c8b0d251511 (patch)
treefdeaa1b37565f6f06694d861985febcdb16ad6ec /org.eclipse.jubula.autagent
parent4858f554584f6472db7558f55a3104d8c57eac08 (diff)
downloadorg.eclipse.jubula.core-c330a3fddda4b5154098ad5ac6849c8b0d251511.tar.gz
org.eclipse.jubula.core-c330a3fddda4b5154098ad5ac6849c8b0d251511.tar.xz
org.eclipse.jubula.core-c330a3fddda4b5154098ad5ac6849c8b0d251511.zip
Sprint task - synchronize shutdown timeout behavior implementation.
Diffstat (limited to 'org.eclipse.jubula.autagent')
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/AutAgent.java49
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/IRestartAutHandler.java11
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutAutRun.java4
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutConfiguration.java4
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/RestartAutCommand.java2
-rw-r--r--org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StopAUTServerCommand.java2
6 files changed, 39 insertions, 33 deletions
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/AutAgent.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/AutAgent.java
index 49ec2ad0d..be20f703b 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/AutAgent.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/AutAgent.java
@@ -451,7 +451,7 @@ public class AutAgent {
* Removes the given AUT from the collection of registered AUTs.
*
* @param autId
- * The ID of the AUT to deregister.
+ * The ID of the AUT to de-register.
*/
private void removeAut(AutIdentifier autId) {
boolean wasSetChanged = false;
@@ -583,11 +583,30 @@ public class AutAgent {
*
* @param autId
* The ID of the Running AUT to stop.
- * @param force
- * indicates whether the AUT should be forced to quit or whether
- * the AUT will terminate by itself
+ * @param timeout
+ * indicates whether the AUT should be forced to quit (timeout ==
+ * 0) or whether the AUT should terminate by itself (timeout > 0)
*/
- public void stopAut(AutIdentifier autId, boolean force) {
+ public void stopAut(AutIdentifier autId, int timeout) {
+ boolean force = timeout == 0;
+ if (!force) {
+ long startTime = System.currentTimeMillis();
+ boolean timedOut = false;
+ while (m_auts.containsKey(autId) && !timedOut) {
+ timedOut = (startTime + timeout) < System.currentTimeMillis();
+ TimeUtil.delay(250);
+ }
+ if (!timedOut) {
+ // The AUT has just unregistered itself - which must not be exactly
+ // the same as terminated - therefore we wait for another moment
+ // of time
+ TimeUtil.delayDefaultOrExternalTime(
+ AUT_POST_DEREGISTRATION_DELAY_DEFAULT,
+ AUT_POST_DEREGISTRATION_DELAY_VAR);
+ } else {
+ force = true;
+ }
+ }
synchronized (m_auts) {
Communicator autCommunicator = m_auts.get(autId);
if (autCommunicator != null) {
@@ -596,16 +615,6 @@ public class AutAgent {
}
}
}
- if (!force) {
- while (m_auts.containsKey(autId)) {
- TimeUtil.delay(250);
- }
- // The AUT has just unregistered itself - which must not be exactly
- // the same as terminated - therefore we wait for another moment of time
- TimeUtil.delayDefaultOrExternalTime(
- AUT_POST_DEREGISTRATION_DELAY_DEFAULT,
- AUT_POST_DEREGISTRATION_DELAY_VAR);
- }
}
/**
@@ -613,15 +622,15 @@ public class AutAgent {
*
* @param autId
* The ID of the Running AUT to restart.
- * @param force
- * indicates whether the AUT should be forced to quit or whether
- * the AUT will terminate by itself
+ * @param timeout
+ * indicates whether the AUT should be forced to quit (timeout ==
+ * 0) or whether the AUT should terminate by itself (timeout > 0)
*/
- public void restartAut(AutIdentifier autId, boolean force) {
+ public void restartAut(AutIdentifier autId, int timeout) {
// cache the start method
final IRestartAutHandler message = m_autIdToRestartHandler.get(autId);
- message.restartAut(this, force);
+ message.restartAut(this, timeout);
}
/**
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/IRestartAutHandler.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/IRestartAutHandler.java
index 58fe05ce3..97d1192c3 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/IRestartAutHandler.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/IRestartAutHandler.java
@@ -18,16 +18,13 @@ package org.eclipse.jubula.autagent.agent;
* @created Mar 26, 2010
*/
public interface IRestartAutHandler {
-
/**
- *
* @param agent
* The AUT Agent with which the AUT to be restarted is
* registered. This may be used, for example, to stop the AUT.
- * @param force
- * indicates whether the AUT should be forced to quit or whether
- * the AUT will terminate by itself
+ * @param timeout
+ * indicates whether the AUT should be forced to quit (timeout ==
+ * 0) or whether the AUT should terminate by itself (timeout > 0)
*/
- public void restartAut(AutAgent agent, boolean force);
-
+ public void restartAut(AutAgent agent, int timeout);
}
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutAutRun.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutAutRun.java
index 335bc0dae..d918b1fe3 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutAutRun.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutAutRun.java
@@ -60,7 +60,7 @@ public class RestartAutAutRun implements IRestartAutHandler {
/**
* {@inheritDoc}
*/
- public void restartAut(AutAgent agent, boolean force) {
+ public void restartAut(AutAgent agent, int timeout) {
try {
PrintWriter writer = new PrintWriter(
m_autrunSocket.getOutputStream(), true);
@@ -68,7 +68,7 @@ public class RestartAutAutRun implements IRestartAutHandler {
writer.println(RestartAutProtocol.REQ_PREPARE_FOR_RESTART);
m_socketReader.readLine();
- agent.stopAut(m_autId, force);
+ agent.stopAut(m_autId, timeout);
writer.println(RestartAutProtocol.REQ_RESTART);
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutConfiguration.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutConfiguration.java
index 2924e6617..e51cd1a84 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutConfiguration.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/agent/RestartAutConfiguration.java
@@ -43,8 +43,8 @@ public class RestartAutConfiguration implements IRestartAutHandler {
}
/** {@inheritDoc} */
- public void restartAut(AutAgent agent, boolean force) {
- agent.stopAut(m_autId, force);
+ public void restartAut(AutAgent agent, int timeout) {
+ agent.stopAut(m_autId, timeout);
StartAUTServerCommand startCommand = new StartAUTServerCommand();
startCommand.setMessage(m_startAutMessage);
startCommand.execute();
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/RestartAutCommand.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/RestartAutCommand.java
index 3176353eb..2f372e214 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/RestartAutCommand.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/RestartAutCommand.java
@@ -47,7 +47,7 @@ public class RestartAutCommand implements ICommand {
invokeMonitoringRestartMethod();
}
AutStarter.getInstance().getAgent()
- .restartAut(autId, m_message.isForceAUTTermination());
+ .restartAut(autId, m_message.getTimeout());
return null;
}
/**
diff --git a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StopAUTServerCommand.java b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StopAUTServerCommand.java
index 10007c1fe..749bdf65e 100644
--- a/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StopAUTServerCommand.java
+++ b/org.eclipse.jubula.autagent/src/org/eclipse/jubula/autagent/commands/StopAUTServerCommand.java
@@ -79,7 +79,7 @@ public class StopAUTServerCommand implements ICommand {
final AutAgent agent = AutStarter.getInstance().getAgent();
if (agent != null) {
- agent.stopAut(m_message.getAutId(), true);
+ agent.stopAut(m_message.getAutId(), 0);
return new StopAUTServerStateMessage();
}

Back to the top