Skip to content

Commit a3fcf62

Browse files
committed
Removed default timeout for start and stop domain
- By default we are sure what we are doing - It is not easy to estimate how much time is needed. - Can be explicitly set using --timeout argument Signed-off-by: David Matějček <[email protected]>
1 parent f904e6a commit a3fcf62

File tree

6 files changed

+40
-14
lines changed

6 files changed

+40
-14
lines changed

nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIConstants.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public final class CLIConstants {
3535
public static final String DEFAULT_HOSTNAME = "localhost";
3636
public static final String EOL = System.lineSeparator();
3737

38-
public static final Duration WAIT_FOR_DAS_TIME_MS = getEnv(TIMEOUT_START_SERVER, 60L);
38+
public static final Duration WAIT_FOR_DAS_TIME_MS = getEnv(TIMEOUT_START_SERVER);
3939
public static final int RESTART_NORMAL = 10;
4040
public static final int RESTART_DEBUG_ON = 11;
4141
public static final int RESTART_DEBUG_OFF = 12;
@@ -44,7 +44,7 @@ public final class CLIConstants {
4444
public static final int SUCCESS = 0;
4545
public static final int ERROR = 1;
4646
public static final int WARNING = 4;
47-
public static final Duration DEATH_TIMEOUT_MS = getEnv(TIMEOUT_STOP_SERVER, 60L);
47+
public static final Duration DEATH_TIMEOUT_MS = getEnv(TIMEOUT_STOP_SERVER);
4848

4949
public static final String K_ADMIN_PORT = "agent.adminPort";
5050
public static final String K_ADMIN_HOST = "agent.adminHost";
@@ -74,11 +74,11 @@ private CLIConstants() {
7474
// no instances allowed!
7575
}
7676

77-
private static Duration getEnv(GlassFishVariable variable, long defaultValue) {
77+
private static Duration getEnv(GlassFishVariable variable) {
7878
String name = variable.getEnvName();
7979
String value = System.getenv(name);
8080
if (value == null) {
81-
return Duration.ofSeconds(defaultValue);
81+
return null;
8282
}
8383
try {
8484
int parsedValue = Integer.parseInt(value);
@@ -87,11 +87,11 @@ private static Duration getEnv(GlassFishVariable variable, long defaultValue) {
8787
}
8888
System.getLogger(CLIConstants.class.getName()).log(Level.WARNING,
8989
"The value of the environment property {0} must be positive.", name);
90-
return Duration.ofSeconds(defaultValue);
90+
return null;
9191
} catch (NumberFormatException e) {
9292
System.getLogger(CLIConstants.class.getName()).log(Level.WARNING,
9393
"Environment property {0} is set to a value {1} which cannot be parsed to duration.", name, value);
94-
return Duration.ofSeconds(defaultValue);
94+
return null;
9595
}
9696
}
9797
}

nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/RestartDomainCommand.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,11 @@ protected int dasNotRunning() throws CommandException {
122122
opts.add("--domaindir");
123123
opts.add(domainDirParam);
124124
}
125-
opts.add("--timeout");
126-
opts.add(Long.toString(getStartTimeout().toSeconds()));
125+
final Duration startTimeout = getStartTimeout();
126+
if (startTimeout != null) {
127+
opts.add("--timeout");
128+
opts.add(Long.toString(startTimeout.toSeconds()));
129+
}
127130
if (getDomainName() != null) {
128131
opts.add(getDomainName());
129132
}
@@ -147,6 +150,16 @@ private Duration getRestartTimeout() {
147150
if (paramTimeout != null) {
148151
return paramTimeout;
149152
}
153+
final Duration startTimeout = getStartTimeout();
154+
if (startTimeout == null && DEATH_TIMEOUT_MS == null) {
155+
return null;
156+
}
157+
if (startTimeout == null) {
158+
return DEATH_TIMEOUT_MS.plusSeconds(5L);
159+
}
160+
if (DEATH_TIMEOUT_MS == null) {
161+
return startTimeout.plusSeconds(5L);
162+
}
150163
return WAIT_FOR_DAS_TIME_MS.plus(DEATH_TIMEOUT_MS).plusSeconds(5);
151164
}
152165
}

nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/LocalStrings.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ StopInstance.noInstanceNameAllowed=No instance name allowed with --host option.
9191
StopInstance.instanceNotRunning=CLI1306 Warning - server instance is not running.
9292
Instance.noSuchInstance=CLI1307 Warning - no server instance found with that name.
9393
StopInstance.waitForDeath=Waiting for the instance to stop
94-
StopInstance.instanceNotDead=Timed out ({0} seconds) waiting for the instance to stop.
9594
## SynchronizeInstanceCommand
9695
Sync.noDASConfigured=CLI800 das.properties file is missing, expected to find it here: {0}
9796
Sync.alreadySynced=CLI801 Instance is already synchronized

nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/RestartLocalInstanceCommand.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ protected int instanceNotRunning() throws CommandException {
109109
if (instanceName != null) {
110110
opts.add(instanceName);
111111
}
112-
opts.add("--timeout");
113-
opts.add(Long.toString(getStartTimeout().toSeconds()));
114-
112+
final Duration startTimeout = getStartTimeout();
113+
if (startTimeout != null) {
114+
opts.add("--timeout");
115+
opts.add(Long.toString(startTimeout.toSeconds()));
116+
}
115117
return cmd.execute(opts.toArray(String[]::new));
116118
}
117119

@@ -131,6 +133,16 @@ private Duration getRestartTimeout() {
131133
if (paramTimeout != null) {
132134
return paramTimeout;
133135
}
136+
final Duration startTimeout = getStartTimeout();
137+
if (startTimeout == null && DEATH_TIMEOUT_MS == null) {
138+
return null;
139+
}
140+
if (startTimeout == null) {
141+
return DEATH_TIMEOUT_MS.plusSeconds(5L);
142+
}
143+
if (DEATH_TIMEOUT_MS == null) {
144+
return startTimeout.plusSeconds(5L);
145+
}
134146
return WAIT_FOR_DAS_TIME_MS.plus(DEATH_TIMEOUT_MS).plusSeconds(5);
135147
}
136148
}

nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/StopLocalInstanceCommand.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.io.File;
2626
import java.net.ConnectException;
27+
import java.text.MessageFormat;
2728
import java.time.Duration;
2829
import java.util.logging.Level;
2930

@@ -182,7 +183,8 @@ protected void doCommand() throws CommandException {
182183
}
183184
final boolean dead = pid == null || ProcessUtils.waitWhileIsAlive(pid, getStopTimeout(), printDots);
184185
if (!dead) {
185-
throw new CommandException(Strings.get("StopInstance.instanceNotDead", getStopTimeout().toSeconds()));
186+
throw new CommandException(MessageFormat
187+
.format("Timed out {0} seconds waiting for the instance to stop.", getStopTimeout().toSeconds()));
186188
}
187189
} catch (Exception e) {
188190
// The server may have died so fast we didn't have time to

nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public static void kill(File pidFile, Duration timeout, boolean printDots)
225225
// This is because File.exists() can cache file attributes
226226
if (!waitWhileIsAlive(pid, timeout, printDots)) {
227227
throw new KillTimeoutException(MessageFormat.format(
228-
"The process {0} was killed, but it is still alive after timeout {1} s.", pid, timeout.getSeconds()));
228+
"The process {0} was killed, but it is still alive after timeout {1} s.", pid, timeout.toSeconds()));
229229
}
230230
}
231231

0 commit comments

Comments
 (0)