Skip to content

Commit b2e15de

Browse files
authored
Merge pull request #19150 from tajila/issue3
(0.44) Update CRaC options
2 parents ad529aa + 7b1ab0b commit b2e15de

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

jcl/src/java.base/share/classes/jdk/crac/Core.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ public class Core {
4141
*/
4242
public static Context<Resource> getGlobalContext() {
4343
if ((globalContext == null) && InternalCRIUSupport.isCRaCSupportEnabled()) {
44-
globalContext = new CRIUSupportContext<>();
44+
try {
45+
globalContext = new CRIUSupportContext<>();
46+
} catch (IllegalArgumentException e) {
47+
System.err.println("Invalid checkpoint directory supplied: " + InternalCRIUSupport.getCRaCCheckpointToDir()); //$NON-NLS-1$
48+
throw e;
49+
}
4550
}
4651
return (Context<Resource>)globalContext;
4752
}
@@ -69,7 +74,10 @@ class CRIUSupportContext<R extends Resource> extends Context<R> {
6974
// InternalCRIUSupport.getCRaCCheckpointToDir() is not null if
7075
// InternalCRIUSupport.isCRaCSupportEnabled() returns true before creating CRIUSupportContext<>().
7176
private final InternalCRIUSupport internalCRIUSupport = new InternalCRIUSupport(
72-
Paths.get(InternalCRIUSupport.getCRaCCheckpointToDir())).setLeaveRunning(false).setShellJob(true)
77+
Paths.get(InternalCRIUSupport.getCRaCCheckpointToDir()))
78+
.setLeaveRunning(false)
79+
.setShellJob(true)
80+
.setTCPEstablished(true)
7381
.setFileLocks(true);
7482

7583
@Override
@@ -111,6 +119,12 @@ public void afterRestore(Context<? extends Resource> resource) throws RestoreExc
111119
}
112120

113121
public void checkpointJVM() {
114-
internalCRIUSupport.checkpointJVM();
122+
try {
123+
internalCRIUSupport.checkpointJVM();
124+
} catch (Exception e) {
125+
e.printStackTrace();
126+
throw e;
127+
}
128+
115129
}
116130
}

jcl/src/java.base/share/classes/openj9/internal/criu/InternalCRIUSupport.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*******************************************************************************/
2323
package openj9.internal.criu;
2424

25+
import com.ibm.oti.vm.VM;
26+
2527
import java.lang.reflect.Constructor;
2628
import java.lang.reflect.Field;
2729
import java.lang.reflect.Method;
@@ -952,6 +954,42 @@ public synchronized void checkpointJVM() {
952954
J9InternalCheckpointHookAPI.registerPostRestoreHook(HookMode.SINGLE_THREAD_MODE, RESTORE_CLEAR_INETADDRESS_CACHE_PRIORITY, "Clear InetAddress cache on restore", InternalCRIUSupport::clearInetAddressCache); //$NON-NLS-1$
953955
J9InternalCheckpointHookAPI.registerPostRestoreHook(HookMode.SINGLE_THREAD_MODE, RESTORE_ENVIRONMENT_VARIABLES_PRIORITY, "Restore system properties", InternalCRIUSupport::setRestoreJavaProperties); //$NON-NLS-1$
954956

957+
/* Add option overrides. */
958+
Properties props = VM.internalGetProperties();
959+
960+
String unprivilegedOpt = props.getProperty("openj9.internal.criu.unprivilegedMode"); //$NON-NLS-1$
961+
if (unprivilegedOpt != null) {
962+
setUnprivileged(Boolean.parseBoolean(unprivilegedOpt));
963+
}
964+
965+
String tcpEstablishedOpt = props.getProperty("openj9.internal.criu.tcpEstablished"); //$NON-NLS-1$
966+
if (tcpEstablishedOpt != null) {
967+
setTCPEstablished(Boolean.parseBoolean(tcpEstablishedOpt));
968+
}
969+
970+
String ghostFileLimitOpt = props.getProperty("openj9.internal.criu.ghostFileLimit"); //$NON-NLS-1$
971+
if (ghostFileLimitOpt != null) {
972+
try {
973+
setGhostFileLimit(Long.parseLong(ghostFileLimitOpt));
974+
} catch (NumberFormatException e) {
975+
System.err.println("Invalid value specified: `-Dopenj9.internal.criu.ghostFileLimit=" + ghostFileLimitOpt + "`."); //$NON-NLS-1$ //$NON-NLS-2$
976+
}
977+
}
978+
979+
String logLevelOpt = props.getProperty("openj9.internal.criu.logLevel"); //$NON-NLS-1$
980+
if (logLevelOpt != null) {
981+
try {
982+
setLogLevel(Integer.parseInt(logLevelOpt));
983+
} catch (NumberFormatException e) {
984+
System.err.println("Invalid value specified: `-Dopenj9.internal.criu.logLevel=" + logLevelOpt + "` ."); //$NON-NLS-1$ //$NON-NLS-2$
985+
}
986+
}
987+
988+
String logFileOpt = props.getProperty("openj9.internal.criu.logFile"); //$NON-NLS-1$
989+
if (logFileOpt != null) {
990+
setLogFile(logFileOpt);
991+
}
992+
955993
/* Add security provider hooks. */
956994
SecurityProviders.registerResetCRIUState();
957995
SecurityProviders.registerRestoreSecurityProviders();

0 commit comments

Comments
 (0)