| 10 | import org.apache.logging.log4j.Logger; |
| 11 | |
| 12 | public 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) { |
nothing calls this directly
no outgoing calls
no test coverage detected