-1

I want to stress test application resilience and verify the data is consistent given frequent power shutdowns.

As the goal is to test persistent state only the app itself is technically not required to be stopped immediately e.g. if there is a way to detach the file system somehow, or freeze writing and make a copy of the state that would do, any way without resorting to killing the process either from inside as System.exit or a sigkill from outside.

kassie
  • 727
  • 4
  • 11
  • 24
  • 1
    What do you perceive the difference to be between this and, say, a sigkill? – Michael Jul 24 '19 at 13:15
  • If you mean the difference between killing an application running inside a docker container and killing a standalone jvm process then it's the convenience of running the app. – kassie Jul 24 '19 at 20:55

1 Answers1

1

System.exit(1); is functionally identical to what happens when the JVM receives a KILL signal from the operating system. However, ShutdownHooks will still execute.

Runtime.getRuntime().halt(1) will halt the JVM immediately, as if the operating system had killed the process without warning.

However, neither is fully equivalent to a sudden loss of power, which would also kill the operating system, possibly causing OS-buffered disk writes to be lost.

meriton
  • 68,356
  • 14
  • 108
  • 175
  • I realised I formulated the question not for what I wanted to ask. Updated, and thanks for the answer anyway! – kassie Jul 24 '19 at 21:08