From b8c17e83497cd29e54929e4909dc412623dfc4bd Mon Sep 17 00:00:00 2001 From: Amarpreet Singh Date: Sun, 24 Dec 2023 06:44:58 -0500 Subject: [PATCH] Get the start time of the criu restore process Get the start time of the criu restore process, which is the parent process of the restored java process. Issue: https://github.com/eclipse-openj9/openj9/issues/18598 Depends-on: https://github.com/eclipse/omr/pull/7214 Signed-off-by: Amarpreet Singh --- .../internal/criu/InternalCRIUSupport.java | 14 +++++++- runtime/jcl/common/criu.cpp | 10 +++++- runtime/jcl/exports.cmake | 1 + runtime/jcl/uma/criu_exports.xml | 1 + runtime/nls/j9vm/j9vm.nls | 7 ++++ runtime/oti/j9nonbuilder.h | 3 +- runtime/oti/j9port_generated.h | 3 ++ runtime/oti/jclprots.h | 3 ++ runtime/tests/port/si.c | 24 +++++++++++++ runtime/vm/CRIUHelpers.cpp | 29 ++++++++++++++-- runtime/vm/j9vm.tdf | 4 ++- runtime/vm/jvminit.c | 3 +- .../org/openj9/test/util/TimeUtilities.java | 7 ++++ .../cmdLineTests/criu/criu_nonPortable.xml | 18 +++++++++- .../src/org/openj9/criu/TimeChangeTest.java | 34 +++++++++++++++++-- 15 files changed, 150 insertions(+), 11 deletions(-) diff --git a/jcl/src/java.base/share/classes/openj9/internal/criu/InternalCRIUSupport.java b/jcl/src/java.base/share/classes/openj9/internal/criu/InternalCRIUSupport.java index 84ab2c76805..e2bf70ed564 100644 --- a/jcl/src/java.base/share/classes/openj9/internal/criu/InternalCRIUSupport.java +++ b/jcl/src/java.base/share/classes/openj9/internal/criu/InternalCRIUSupport.java @@ -69,6 +69,7 @@ public final class InternalCRIUSupport { private static native boolean enableCRIUSecProviderImpl(); private static native long getCheckpointRestoreNanoTimeDeltaImpl(); private static native long getLastRestoreTimeImpl(); + private static native long getProcessRestoreStartTimeImpl(); private static native boolean isCRIUSupportEnabledImpl(); private static native boolean isCheckpointAllowedImpl(); /*[IF CRAC_SUPPORT]*/ @@ -95,13 +96,24 @@ public static long getCheckpointRestoreNanoTimeDelta() { * Retrieve the time when the last restore occurred. In the case of multiple * restores the previous times are overwritten. * - * @return the time in milliseconds since the start of the epoch, -1 if restore + * @return the time in nanoseconds since the start of the epoch, -1 if restore * has not occurred. */ public static long getLastRestoreTime() { return getLastRestoreTimeImpl(); } + /** + * Get the start time of the CRIU process that restores the java process. + * The time that is set by the restored java process when it resumes from + * checkpoint can be retrieved with {@link #getLastRestoreTime()}. + * + * @return the time in nanoseconds since the epoch, -1 if restore has not occurred. + */ + public static long getProcessRestoreStartTime() { + return getProcessRestoreStartTimeImpl(); + } + /** * Queries if CRaC or CRIU support is enabled. * diff --git a/runtime/jcl/common/criu.cpp b/runtime/jcl/common/criu.cpp index 0d7c546de4a..1a25fc950be 100644 --- a/runtime/jcl/common/criu.cpp +++ b/runtime/jcl/common/criu.cpp @@ -43,7 +43,15 @@ Java_openj9_internal_criu_InternalCRIUSupport_getLastRestoreTimeImpl(JNIEnv *env { J9VMThread *currentThread = (J9VMThread *)env; - return currentThread->javaVM->checkpointState.lastRestoreTimeMillis; + return currentThread->javaVM->checkpointState.lastRestoreTimeInNanoseconds; +} + +jlong JNICALL +Java_openj9_internal_criu_InternalCRIUSupport_getProcessRestoreStartTimeImpl(JNIEnv *env, jclass unused) +{ + J9VMThread *currentThread = (J9VMThread *)env; + + return currentThread->javaVM->checkpointState.processRestoreStartTimeInNanoseconds; } jboolean JNICALL diff --git a/runtime/jcl/exports.cmake b/runtime/jcl/exports.cmake index f94855ad6e2..feed01666e3 100644 --- a/runtime/jcl/exports.cmake +++ b/runtime/jcl/exports.cmake @@ -675,6 +675,7 @@ if(J9VM_OPT_CRIU_SUPPORT) Java_openj9_internal_criu_InternalCRIUSupport_enableCRIUSecProviderImpl Java_openj9_internal_criu_InternalCRIUSupport_getCheckpointRestoreNanoTimeDeltaImpl Java_openj9_internal_criu_InternalCRIUSupport_getLastRestoreTimeImpl + Java_openj9_internal_criu_InternalCRIUSupport_getProcessRestoreStartTimeImpl Java_openj9_internal_criu_InternalCRIUSupport_getRestoreSystemProperites Java_openj9_internal_criu_InternalCRIUSupport_isCheckpointAllowedImpl Java_openj9_internal_criu_InternalCRIUSupport_isCRIUSupportEnabledImpl diff --git a/runtime/jcl/uma/criu_exports.xml b/runtime/jcl/uma/criu_exports.xml index b09ddbbf3b6..084bca186f2 100644 --- a/runtime/jcl/uma/criu_exports.xml +++ b/runtime/jcl/uma/criu_exports.xml @@ -23,6 +23,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex + diff --git a/runtime/nls/j9vm/j9vm.nls b/runtime/nls/j9vm/j9vm.nls index 37c0da2dd25..cfebde5be30 100644 --- a/runtime/nls/j9vm/j9vm.nls +++ b/runtime/nls/j9vm/j9vm.nls @@ -2313,3 +2313,10 @@ J9NLS_VM_CRIU_CRAC_INCOMPATIBLE_SETTING.explanation=-XX:+EnableCRIUSupport and - J9NLS_VM_CRIU_CRAC_INCOMPATIBLE_SETTING.system_action=The JVM will fail to start. J9NLS_VM_CRIU_CRAC_INCOMPATIBLE_SETTING.user_response=Remove one of the options from the command line. # END NON-TRANSLATABLE + +J9NLS_VM_CRIU_J9_GET_PROCESS_START_TIME_FAILURE=j9sysinfo_get_process_start_time failed with errno=%zi +# START NON-TRANSLATABLE +J9NLS_VM_CRIU_J9_GET_PROCESS_START_TIME_FAILURE.explanation=j9sysinfo_get_process_start_time failed. +J9NLS_VM_CRIU_J9_GET_PROCESS_START_TIME_FAILURE.system_action=The JVM will throw a JVMRestoreException. +J9NLS_VM_CRIU_J9_GET_PROCESS_START_TIME_FAILURE.user_response=View CRIU documentation to determine how to resolve the error. +# END NON-TRANSLATABLE diff --git a/runtime/oti/j9nonbuilder.h b/runtime/oti/j9nonbuilder.h index 523ecf401cf..ed59f893c23 100644 --- a/runtime/oti/j9nonbuilder.h +++ b/runtime/oti/j9nonbuilder.h @@ -4228,7 +4228,8 @@ typedef struct J9CRIUCheckpointState { * Only supports one Checkpoint, could be restored multiple times. */ I_64 checkpointRestoreTimeDelta; - I_64 lastRestoreTimeMillis; + I_64 lastRestoreTimeInNanoseconds; + I_64 processRestoreStartTimeInNanoseconds; UDATA maxRetryForNotCheckpointSafe; UDATA sleepMillisecondsForNotCheckpointSafe; jclass criuJVMCheckpointExceptionClass; diff --git a/runtime/oti/j9port_generated.h b/runtime/oti/j9port_generated.h index 3b0ae3384af..63b1da6480b 100644 --- a/runtime/oti/j9port_generated.h +++ b/runtime/oti/j9port_generated.h @@ -761,6 +761,9 @@ extern J9_CFUNC int32_t j9port_isCompatible(struct J9PortLibraryVersion *expecte #define j9sysinfo_get_open_file_count(param1) OMRPORT_FROM_J9PORT(privatePortLibrary)->sysinfo_get_open_file_count(OMRPORT_FROM_J9PORT(privatePortLibrary),param1) #define j9sysinfo_get_os_description(param1) OMRPORT_FROM_J9PORT(privatePortLibrary)->sysinfo_get_os_description(OMRPORT_FROM_J9PORT(privatePortLibrary),param1) #define j9sysinfo_os_has_feature(param1,param2) OMRPORT_FROM_J9PORT(privatePortLibrary)->sysinfo_os_has_feature(OMRPORT_FROM_J9PORT(privatePortLibrary),param1,param2) +#if defined(J9VM_OPT_CRIU_SUPPORT) +#define j9sysinfo_get_process_start_time(param1,param2) OMRPORT_FROM_J9PORT(privatePortLibrary)->sysinfo_get_process_start_time(OMRPORT_FROM_J9PORT(privatePortLibrary),param1,param2) +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ #define j9syslog_write(param1,param2) OMRPORT_FROM_J9PORT(privatePortLibrary)->syslog_write(OMRPORT_FROM_J9PORT(privatePortLibrary),param1,param2) #define j9hypervisor_startup() privatePortLibrary->hypervisor_startup(privatePortLibrary) #define j9hypervisor_shutdown() privatePortLibrary->hypervisor_shutdown(privatePortLibrary) diff --git a/runtime/oti/jclprots.h b/runtime/oti/jclprots.h index f8f3ad4abe5..c69afbf0553 100644 --- a/runtime/oti/jclprots.h +++ b/runtime/oti/jclprots.h @@ -1303,6 +1303,9 @@ Java_openj9_internal_criu_InternalCRIUSupport_getCheckpointRestoreNanoTimeDeltaI jlong JNICALL Java_openj9_internal_criu_InternalCRIUSupport_getLastRestoreTimeImpl(JNIEnv *env, jclass unused); +jlong JNICALL +Java_openj9_internal_criu_InternalCRIUSupport_getProcessRestoreStartTimeImpl(JNIEnv *env, jclass unused); + jboolean JNICALL Java_openj9_internal_criu_InternalCRIUSupport_isCheckpointAllowedImpl(JNIEnv *env, jclass unused); diff --git a/runtime/tests/port/si.c b/runtime/tests/port/si.c index 72cfd468445..e2d58f8441a 100644 --- a/runtime/tests/port/si.c +++ b/runtime/tests/port/si.c @@ -2280,6 +2280,27 @@ j9sysinfo_test_get_l1dcache_line_size(struct J9PortLibrary *portLibrary) return reportTestExit(portLibrary, testName); } +#if defined(J9VM_OPT_CRIU_SUPPORT) +I_32 +j9sysinfo_test_get_process_start_time(struct J9PortLibrary *portLibrary) +{ + PORT_ACCESS_FROM_PORT(portLibrary); + const char *testName = "j9sysinfo_test_get_process_start_time"; + UDATA pid = j9sysinfo_get_pid(); + U_64 processStartTimeInNanoseconds = 0; + I_32 rc = j9sysinfo_get_process_start_time(pid, &processStartTimeInNanoseconds); + if ((0 != rc) || (0 == processStartTimeInNanoseconds)) { + outputErrorMessage( + PORTTEST_ERROR_ARGS, + "j9sysinfo_get_process_start_time, pid=%zu, processStartTimeInNanoseconds=%llu, rc=%d.\n", + pid, + processStartTimeInNanoseconds, + rc); + } + return reportTestExit(portLibrary, testName); +} +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ + /* * pass in the port library to do sysinfo tests */ @@ -2350,6 +2371,9 @@ j9sysinfo_runTests(struct J9PortLibrary *portLibrary, char *argv0) /* Not supported on Z & OSX (and Windows, of course). Enable, when available. */ rc |= j9sysinfo_test_get_open_file_count(portLibrary); #endif /* defined(LINUX) || defined(AIXPPC) */ +#if defined(J9VM_OPT_CRIU_SUPPORT) + rc |= j9sysinfo_test_get_process_start_time(portLibrary); +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ /* Output results */ j9tty_printf(PORTLIB, "\nSysinfo test done%s\n\n", rc == TEST_PASS ? "." : ", failures detected."); diff --git a/runtime/vm/CRIUHelpers.cpp b/runtime/vm/CRIUHelpers.cpp index 2e16b1431ca..69340134f3b 100644 --- a/runtime/vm/CRIUHelpers.cpp +++ b/runtime/vm/CRIUHelpers.cpp @@ -60,7 +60,6 @@ static BOOLEAN criuRestoreDisableSharedClassCache(J9VMThread *currentThread, voi static BOOLEAN criuRestoreInitializeDump(J9VMThread *currentThread, void *userData, const char **nlsMsgFormat); static jvmtiIterationControl objectIteratorCallback(J9JavaVM *vm, J9MM_IterateObjectDescriptor *objectDesc, void *userData); -#define J9TIME_NANOSECONDS_PER_MILLIS 1000000 #define STRING_BUFFER_SIZE 256 #define ENV_FILE_BUFFER 1024 @@ -1510,6 +1509,7 @@ criuCheckpointJVMImpl(JNIEnv *env, I_32 syslogBufferSize = 0; UDATA oldVMState = VM_VMHelpers::setVMState(currentThread, J9VMSTATE_CRIU_SUPPORT_CHECKPOINT_PHASE_START); UDATA notSafeToCheckpoint = 0; + UDATA criuRestorePid = 0; vmFuncs->internalEnterVMFromJNI(currentThread); @@ -1756,8 +1756,31 @@ criuCheckpointJVMImpl(JNIEnv *env, VM_VMHelpers::setVMState(currentThread, J9VMSTATE_CRIU_SUPPORT_RESTORE_PHASE_START); restoreNanoTimeMonotonic = j9time_nano_time(); restoreNanoUTCTime = j9time_current_time_nanos(&success); - vm->checkpointState.lastRestoreTimeMillis = (I_64)(restoreNanoUTCTime / J9TIME_NANOSECONDS_PER_MILLIS); - Trc_VM_criu_after_dump(currentThread, restoreNanoTimeMonotonic, restoreNanoUTCTime, vm->checkpointState.lastRestoreTimeMillis); + if (0 == success) { + systemReturnCode = errno; + currentExceptionClass = vm->checkpointState.criuSystemRestoreExceptionClass; + nlsMsgFormat = j9nls_lookup_message( + J9NLS_DO_NOT_PRINT_MESSAGE_TAG | J9NLS_DO_NOT_APPEND_NEWLINE, + J9NLS_VM_CRIU_J9_CURRENT_TIME_NANOS_FAILURE, + NULL); + j9mem_free_memory(syslogOptions); + goto wakeJavaThreadsWithExclusiveVMAccess; + } + vm->checkpointState.lastRestoreTimeInNanoseconds = (I_64)restoreNanoUTCTime; + Trc_VM_criu_after_dump(currentThread, restoreNanoTimeMonotonic, vm->checkpointState.lastRestoreTimeInNanoseconds); + criuRestorePid = j9sysinfo_get_ppid(); + systemReturnCode = j9sysinfo_get_process_start_time(criuRestorePid, &restoreNanoUTCTime); + if (0 != systemReturnCode) { + currentExceptionClass = vm->checkpointState.criuSystemRestoreExceptionClass; + nlsMsgFormat = j9nls_lookup_message( + J9NLS_DO_NOT_PRINT_MESSAGE_TAG | J9NLS_DO_NOT_APPEND_NEWLINE, + J9NLS_VM_CRIU_J9_GET_PROCESS_START_TIME_FAILURE, + NULL); + j9mem_free_memory(syslogOptions); + goto wakeJavaThreadsWithExclusiveVMAccess; + } + vm->checkpointState.processRestoreStartTimeInNanoseconds = (I_64)restoreNanoUTCTime; + Trc_VM_criu_process_restore_start_after_dump(currentThread, criuRestorePid, vm->checkpointState.processRestoreStartTimeInNanoseconds); if (!syslogFlagNone) { /* Re-open the system logger, and set options with saved string value. */ j9port_control(J9PORT_CTLDATA_SYSLOG_OPEN, 0); diff --git a/runtime/vm/j9vm.tdf b/runtime/vm/j9vm.tdf index f7c3861391d..2e5bf9f6779 100644 --- a/runtime/vm/j9vm.tdf +++ b/runtime/vm/j9vm.tdf @@ -960,5 +960,7 @@ TraceException=Trc_VM_criu_setupJNIFieldIDsAndCRIUAPI_null_exception_class Overh TraceException=Trc_VM_criu_setupJNIFieldIDsAndCRIUAPI_null_init Overhead=1 Level=1 Template="setupJNIFieldIDsAndCRIUAPI() criuSystemRestoreExceptionInit(%p) criuJVMRestoreExceptionInit(%p) criuSystemCheckpointExceptionInit(%p) criuJVMCheckpointExceptionInit(%p)" TraceExit=Trc_VM_criu_checkpointJVMImpl_Exit Overhead=1 Level=2 Template="Java_openj9_internal_criu_CRIUSupport_checkpointJVMImpl" -TraceEvent=Trc_VM_criu_after_dump Overhead=1 Level=2 Template="After checkpoint criu_dump(), criuRestoreNanoTimeMonotonic (%lld), criuRestoreNanoUTCTime (%llu), lastRestoreTimeMillis (%lld)" +TraceEvent=Trc_VM_criu_after_dump Obsolete Overhead=1 Level=2 Template="After checkpoint criu_dump(), criuRestoreNanoTimeMonotonic (%lld), criuRestoreNanoUTCTime (%llu), lastRestoreTimeMillis (%lld)" TraceEvent=Trc_VM_crac_checkpointTo NoEnv Overhead=1 Level=3 Template="-XX:CRaCCheckpointTo=%s" +TraceEvent=Trc_VM_criu_after_dump Overhead=1 Level=2 Template="After checkpoint criu_dump(), restoreNanoTimeMonotonic (%lld), lastRestoreTimeInNanoseconds (%lld)" +TraceEvent=Trc_VM_criu_process_restore_start_after_dump Overhead=1 Level=2 Template="After checkpoint criu_dump(), restorePid (%zu), processRestoreStartTimeInNanoseconds (%lld)" diff --git a/runtime/vm/jvminit.c b/runtime/vm/jvminit.c index 8fb7c7eb2d0..3cfacfab978 100644 --- a/runtime/vm/jvminit.c +++ b/runtime/vm/jvminit.c @@ -3978,7 +3978,8 @@ processVMArgsFromFirstToLast(J9JavaVM * vm) } } - vm->checkpointState.lastRestoreTimeMillis = -1; + vm->checkpointState.lastRestoreTimeInNanoseconds = -1; + vm->checkpointState.processRestoreStartTimeInNanoseconds = -1; #endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ { diff --git a/test/functional/TestUtilities/src/org/openj9/test/util/TimeUtilities.java b/test/functional/TestUtilities/src/org/openj9/test/util/TimeUtilities.java index d39cb8d3e50..3a12045517b 100644 --- a/test/functional/TestUtilities/src/org/openj9/test/util/TimeUtilities.java +++ b/test/functional/TestUtilities/src/org/openj9/test/util/TimeUtilities.java @@ -21,10 +21,12 @@ *******************************************************************************/ package org.openj9.test.util; +import java.time.Instant; import java.util.ArrayList; import java.util.Date; import java.util.Timer; import java.util.TimerTask; +import java.util.concurrent.TimeUnit; /** * Utility class to check time. @@ -91,6 +93,11 @@ public static boolean checkElapseTime(String testName, long startMillisTime, lon return checkElapseTime(testName, startMillisTime, startNanoTime, minElapsedMillisTime, 0, minElapsedNanoTimeInMillis, 0); } + public static long getCurrentTimeInNanoseconds() { + Instant instant = Instant.now(); + return TimeUnit.SECONDS.toNanos(instant.getEpochSecond()) + instant.getNano(); + } + private volatile boolean tasksPassed = true; private volatile int taskRunning = 0; private volatile int taskStarted = 0; diff --git a/test/functional/cmdLineTests/criu/criu_nonPortable.xml b/test/functional/cmdLineTests/criu/criu_nonPortable.xml index bcd9dbd6e4a..c69ca7b8359 100644 --- a/test/functional/cmdLineTests/criu/criu_nonPortable.xml +++ b/test/functional/cmdLineTests/criu/criu_nonPortable.xml @@ -190,7 +190,7 @@ - bash $SCRIPPATH$ $TEST_RESROOT$ $JAVA_COMMAND$ "$JVM_OPTIONS$ -Xtrace:print={j9vm.684-696,j9vm.699,j9vm.717-743} --add-exports java.base/openj9.internal.criu=ALL-UNNAMED" $MAINCLASS_TIMECHANGE$ testGetLastRestoreTime 1 false false + bash $SCRIPPATH$ $TEST_RESROOT$ $JAVA_COMMAND$ "$JVM_OPTIONS$ -Xtrace:print={j9vm.684-696,j9vm.699,j9vm.717-743,j9vm.746-747} --add-exports java.base/openj9.internal.criu=ALL-UNNAMED" $MAINCLASS_TIMECHANGE$ testGetLastRestoreTime 1 false false Killed PASSED: InternalCRIUSupport.getLastRestoreTime() CRIU is not enabled @@ -205,6 +205,22 @@ User requested Java dump using + + bash $SCRIPPATH$ $TEST_RESROOT$ $JAVA_COMMAND$ "$JVM_OPTIONS$ -Xtrace:print={j9vm.684-696,j9vm.699,j9vm.717-743,j9vm.746-747} --add-exports java.base/openj9.internal.criu=ALL-UNNAMED" $MAINCLASS_TIMECHANGE$ testGetProcessRestoreStartTime 1 false false + Killed + PASSED: InternalCRIUSupport.getProcessRestoreStartTime() + CRIU is not enabled + Operation not permitted + FAILED: InternalCRIUSupport.getProcessRestoreStartTime() + + Thread pid mismatch + do not match expected + Unable to create a thread: + + Could not dump the JVM processes, err=-70 + User requested Java dump using + + bash $SCRIPPATH$ $TEST_RESROOT$ $JAVA_COMMAND$ "$JVM_OPTIONS$ -Xtrace:print={j9jcl.533,j9vm.684-696,j9vm.699,j9vm.717-743} --add-exports java.base/openj9.internal.criu=ALL-UNNAMED" -Xdump:java+system+jit:events=throw+systhrow,filter=org/eclipse/openj9/criu/JVMCheckpointException $MAINCLASS_TIMECHANGE$ testMXBeanUpTime 1 false false Killed diff --git a/test/functional/cmdLineTests/criu/src/org/openj9/criu/TimeChangeTest.java b/test/functional/cmdLineTests/criu/src/org/openj9/criu/TimeChangeTest.java index dbdebff12d2..788adb2b146 100644 --- a/test/functional/cmdLineTests/criu/src/org/openj9/criu/TimeChangeTest.java +++ b/test/functional/cmdLineTests/criu/src/org/openj9/criu/TimeChangeTest.java @@ -59,6 +59,9 @@ public static void main(String args[]) throws InterruptedException { case "testGetLastRestoreTime": tct.testGetLastRestoreTime(); break; + case "testGetProcessRestoreStartTime": + tct.testGetProcessRestoreStartTime(); + break; case "testMXBeanUpTime": tct.testMXBeanUpTime(); break; @@ -228,10 +231,10 @@ private void testGetLastRestoreTime() { + " should be -1 before restore"); } CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - long beforeCheckpoint = System.currentTimeMillis(); + long beforeCheckpoint = TimeUtilities.getCurrentTimeInNanoseconds(); CRIUTestUtils.checkPointJVMNoSetup(criu, CRIUTestUtils.imagePath, false); lastRestoreTime = InternalCRIUSupport.getLastRestoreTime(); - long afterRestore = System.currentTimeMillis(); + long afterRestore = TimeUtilities.getCurrentTimeInNanoseconds(); if (beforeCheckpoint >= lastRestoreTime) { System.out.println("FAILED: InternalCRIUSupport.getLastRestoreTime() - " + lastRestoreTime + " can't be less than the beforeCheckpoint time - " + beforeCheckpoint); @@ -245,6 +248,33 @@ private void testGetLastRestoreTime() { } } + private void testGetProcessRestoreStartTime() { + long processRestoreStartTime = InternalCRIUSupport.getProcessRestoreStartTime(); + if (processRestoreStartTime != -1) { + System.out.println("FAILED: InternalCRIUSupport.getProcessRestoreStartTime() - " + processRestoreStartTime + + " is not -1 before restore"); + } + CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); + long beforeCheckpointTime = TimeUtilities.getCurrentTimeInNanoseconds(); + CRIUTestUtils.checkPointJVMNoSetup(criu, CRIUTestUtils.imagePath, false); + processRestoreStartTime = InternalCRIUSupport.getProcessRestoreStartTime(); + long lastRestoreTime = InternalCRIUSupport.getLastRestoreTime(); + long afterRestoreTime = TimeUtilities.getCurrentTimeInNanoseconds(); + if (beforeCheckpointTime >= processRestoreStartTime) { + System.out.println("FAILED: InternalCRIUSupport.getProcessRestoreStartTime() - " + processRestoreStartTime + + " is less than beforeCheckpointTime - " + beforeCheckpointTime); + } else if (processRestoreStartTime >= lastRestoreTime) { + System.out.println("FAILED: InternalCRIUSupport.getProcessRestoreStartTime() - " + processRestoreStartTime + + " is more than InternalCRIUSupport.getLastRestoreTime() - " + lastRestoreTime); + } else if (processRestoreStartTime >= afterRestoreTime) { + System.out.println("FAILED: InternalCRIUSupport.getProcessRestoreStartTime() - " + processRestoreStartTime + + " is more than afterRestoreTime - " + afterRestoreTime); + } else { + System.out.println("PASSED: InternalCRIUSupport.getProcessRestoreStartTime() - " + processRestoreStartTime + + " is between beforeCheckpointTime - " + beforeCheckpointTime + " and afterRestoreTime - " + afterRestoreTime); + } + } + private void testMXBeanUpTime() { CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); RuntimeMXBean mxb = ManagementFactory.getRuntimeMXBean();