1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package zeus.actors.graphs;
27
28 import java.util.*;
29 import zeus.util.*;
30 import zeus.concepts.*;
31 import zeus.actors.*;
32 import zeus.actors.rtn.*;
33 import zeus.actors.rtn.util.*;
34
35 public class s2 extends Node {
36 public s2() {
37 super("s2");
38 }
39
40
41 private String node_desc = "entry/COMMIT scheduled task";
42
43
44 public final String getDesc()
45 {return node_desc;}
46
47
48 public final void setDesc(String node_desc)
49 {this.node_desc = node_desc;}
50
51
52
53 protected PlannerQueryStruct bind_data = null;
54
55 protected int exec() {
56 try {
57 Planner table = context.Planner();
58 Engine engine = context.Engine();
59 AuditTable audit = engine.getAuditTable();
60
61 GraphStruct gs = (GraphStruct) input;
62
63 Vector bound_goals = table.bind(gs.goal);
64 bind_data = table.clear_bind(gs.goal);
65
66
67 Goal g0, g1;
68 Vector records;
69 DelegationStruct ds;
70
71 for(int i = 0; i < gs.goal.size(); i++ ) {
72
73 g0 = (Goal)bind_data.goals.elementAt(i);
74
75 g1 = (Goal)bound_goals.elementAt(i);
76
77 audit.addProducerRecords(g1.getProducerRecords());
78 audit.addConsumerRecords(g1.getConsumerRecords());
79
80 audit.add(g0,gs.key,g1.getCost(),false,false,context.whoami(),
81 gs.agent,g0.getEndTime());
82 }
83 for(int i = 0; i < gs.selection.size(); i++ ) {
84 ds = (DelegationStruct)gs.selection.elementAt(i);
85 g0 = (Goal)ds.goals.elementAt(0);
86
87 audit.addProducerRecords(g0.getProducerRecords());
88 audit.addConsumerRecords(g0.getConsumerRecords());
89
90 audit.add(g0,ds.key,g0.getCost(),false,false,ds.agent,
91 context.whoami(),g0.getEndTime());
92 }
93
94 if ( !gs.internal.isEmpty() ){
95 table.book(PlanRecord.FIRM,gs.goal,gs.internal);
96 }
97
98 Core.DEBUG(2,"*** S2 AuditTable State ***");
99 Core.DEBUG(2,audit);
100
101 output = gs;
102
103 return OK;}
104 catch (Exception e) {
105 return FAIL;
106 }
107 }
108
109 protected void reset() {
110
111 Planner table = context.Planner();
112 Engine engine = context.Engine();
113 AuditTable audit = engine.getAuditTable();
114
115 GraphStruct gs = (GraphStruct) input;
116 if ( !gs.internal.isEmpty() )
117 table.book(PlanRecord.TENTATIVE,gs.goal,gs.internal);
118
119 table.reset_bind(gs.goal,bind_data);
120
121 bind_data = null;
122
123
124 Goal g;
125
126 for(int i = 0; i < gs.goal.size(); i++ ) {
127 g = (Goal)gs.goal.elementAt(i);
128 audit.del(g);
129 }
130 DelegationStruct ds;
131 for(int i = 0; i < gs.selection.size(); i++ ) {
132 ds = (DelegationStruct)gs.selection.elementAt(i);
133 g = (Goal)ds.goals.elementAt(0);
134 audit.del(g);
135 }
136 this.finals();
137 }
138 }