-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d563329
commit 5a804c2
Showing
25 changed files
with
1,221 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
demos/_java_serverless_lib/core/src/main/java/io/serverless_lib/CracManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package io.serverless_lib; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.context.ConfigurableApplicationContext; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.boot.ApplicationArguments; | ||
import org.springframework.boot.DefaultApplicationArguments; | ||
import org.springframework.core.env.Environment; | ||
import process_rpc_proto.ProcessRpcProto.UpdateCheckpoint; | ||
|
||
public class CracManager implements org.crac.Resource | ||
// DisposableBean | ||
{ | ||
boolean checkpointed = false; | ||
|
||
@Autowired | ||
UdsBackend uds; | ||
|
||
@EventListener | ||
public void bootArgCheckOk(BootArgCheckOkEvent e) { | ||
// /-----------------------\ | ||
// /-------------------------------------- | # Agent | | ||
// | \-----------------------/ | ||
// /----------------------\ | ||
// | # CracManager | | ||
// | // first time init | | ||
// | checkpointed = false | | ||
// \----------------------/ | ||
// | | ||
// | bootArgCheckOk | ||
// | if (!checkpointed) ----- uds call -----> | | ||
// | | ||
// | <----------------------------------------/ take snapshot | ||
// | | ||
// | beforeCheckpoint | ||
// \ checkpointed = true--------------------> | | ||
// | | ||
// /----------------------\ <-------------------------/ restart by crac | ||
// | # CracManager | | ||
// | // criu init | | ||
// | checkpointed = true | | ||
// \----------------------/ | ||
|
||
// register crac | ||
org.crac.Core.getGlobalContext().register(this); | ||
|
||
if (!checkpointed) { | ||
System.out.println("CracManager requires for snapshot."); | ||
uds.send(new UdsPack(UpdateCheckpoint.newBuilder().build(),0)); | ||
// TODO: change to rpc | ||
checkpointed = true; | ||
} | ||
} | ||
|
||
@Override | ||
public void beforeCheckpoint(org.crac.Context<? extends org.crac.Resource> context) throws Exception { | ||
// Prepare for checkpoint | ||
System.out.println("CracManager before checkpoint."); | ||
// close the uds | ||
uds.close(); | ||
} | ||
|
||
@Override | ||
public void afterRestore(org.crac.Context<? extends org.crac.Resource> context) throws Exception { | ||
// Handle after restore | ||
System.out.println("CracManager after restore."); | ||
uds.start(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.