Project CRaC implementation in java

               CRaC – Coordinated Restore at Checkpoint). It is an OpenJDK project which helps to check the java applications in a particular point and restore it.

How it works??

Just run Java Virtual Machine with application. CRaC makes the user to take snapshot and store its state.

How to create a java application with CRaC:

  • First set the environment: check the Java Virtual Machine whether it suitable for CRaC.
  • Write a class Main24 with main() function.
  • Print a message “Let us start the application”. Using try, catch block make a thread to sleep for some time.
  • Again, print a message that “initial setup is completed.let us wait for checkpoints” and create a check point.
  • At last, print “ let us continue the work”
Program:

public class Main24 {

    public static void main(String[] args) {

        System.out.println("Let us start the Application....");

        try {

            Thread.sleep(200);

        } catch (InterruptedException e) {

            e.printStackTrace();

        }

        System.out.println("Initial setup is completed.Let us Wait for checkpoints...");

        // Simulate a long-running operation

        while (true) {

            try {

                Thread.sleep(500);

            } catch (InterruptedException e) {

                e.printStackTrace();

            }

            System.out.println("let us Continue the work...");

        }

    }

}

Output:

C:\raji\blog>javac Main24.java

C:\raji\blog>java Main24

Let us start the Application....

Initial setup is completed.Let us Wait for checkpoints...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

let us Continue the work...

This is the way of creating a simple CRaC application in java programming.

No comments:

Post a Comment