MCPcopy Create free account
hub / github.com/e2wugui/zeze / Procedure

Class Procedure

ZezeJava/ZezeJava/src/main/java/Zeze/Raft/RocksRaft/Procedure.java:12–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10import org.apache.logging.log4j.Logger;
11
12public class Procedure {
13 private static final Logger logger = LogManager.getLogger(Procedure.class);
14
15 private Rocks rocks;
16 private FuncLong func;
17
18 public RaftRpc<?, ?> uniqueRequest;
19 public Protocol<?> autoResponse;
20
21 public final void setAutoResponseResultCode(long code) {
22 if (null != autoResponse)
23 autoResponse.setResultCode(code);
24 }
25
26 public Procedure() {
27 }
28
29 public Procedure(Rocks rocks, FuncLong func) {
30 this.rocks = rocks;
31 this.func = func;
32 }
33
34 public final Rocks getRocks() {
35 return rocks;
36 }
37
38 public final void setRocks(Rocks value) {
39 rocks = value;
40 }
41
42 public final FuncLong getFunc() {
43 return func;
44 }
45
46 public final void setFunc(FuncLong value) {
47 func = value;
48 }
49
50 protected long process() throws Exception {
51 var func = this.func;
52 if (func != null)
53 return func.call();
54 return Zeze.Transaction.Procedure.NotImplement;
55 }
56
57 public final long call() throws Exception {
58 var currentT = Transaction.getCurrent();
59 if (currentT == null) {
60 try {
61 return Transaction.create().perform(this);
62 } finally {
63 Transaction.destroy();
64 }
65 }
66 currentT.begin();
67 try {
68 var result = process();
69 if (result == 0) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected