16
16
17
17
package com .hedera .node .app .statedumpers .scheduledtransactions ;
18
18
19
+ import static com .hedera .node .app .service .mono .pbj .PbjConverter .fromPbj ;
19
20
import static com .hedera .node .app .service .mono .statedumpers .associations .BBMTokenAssociation .entityIdFrom ;
20
21
import static com .hedera .node .app .service .mono .statedumpers .scheduledtransactions .ScheduledTransactionsDumpUtils .reportOnScheduledTransactionsByEquality ;
21
22
import static com .hedera .node .app .service .mono .statedumpers .scheduledtransactions .ScheduledTransactionsDumpUtils .reportOnScheduledTransactionsByExpiry ;
22
23
import static com .hedera .node .app .service .mono .statedumpers .scheduledtransactions .ScheduledTransactionsDumpUtils .reportOnScheduledTransactionsById ;
24
+ import static com .hedera .node .app .service .schedule .impl .handlers .HandlerUtility .childAsOrdinary ;
23
25
import static com .swirlds .common .threading .manager .AdHocThreadManager .getStaticThreadManager ;
24
26
25
27
import com .hedera .hapi .node .base .ScheduleID ;
28
30
import com .hedera .hapi .node .state .schedule .Schedule ;
29
31
import com .hedera .hapi .node .state .schedule .ScheduleList ;
30
32
import com .hedera .node .app .service .mono .legacy .core .jproto .JKey ;
31
- import com .hedera .node .app .service .mono .pbj .PbjConverter ;
32
33
import com .hedera .node .app .service .mono .state .adapters .VirtualMapLike ;
33
34
import com .hedera .node .app .service .mono .state .submerkle .RichInstant ;
34
35
import com .hedera .node .app .service .mono .statedumpers .DumpCheckpoint ;
52
53
import java .util .Optional ;
53
54
import java .util .TreeMap ;
54
55
import java .util .concurrent .ConcurrentLinkedQueue ;
55
- import java .util .concurrent .CopyOnWriteArrayList ;
56
56
57
57
public class ScheduledTransactionsDumpUtils {
58
58
@@ -63,38 +63,52 @@ public static void dumpModScheduledTransactions(
63
63
@ NonNull final VirtualMap <OnDiskKey <ProtoLong >, OnDiskValue <ScheduleList >> byExpiry ,
64
64
@ NonNull final DumpCheckpoint checkpoint ) {
65
65
try (@ NonNull final var writer = new Writer (path )) {
66
- final var dumpableScheduledTransactionsById = gatherModScheduledTransactionsById ( scheduledTransactions );
67
- reportOnScheduledTransactionsById ( writer , dumpableScheduledTransactionsById );
68
- System . out . printf (
69
- "=== mod scheduled transactions report is %d bytes at checkpoint %s%n" ,
70
- writer . getSize (), checkpoint . name ());
71
- final var byEqualityDump = gatherModScheduledTransactionsByEquality ( byEquality );
72
- reportOnScheduledTransactionsByEquality ( writer , byEqualityDump );
66
+ System . out . printf ( "=== Dumping schedule transactions %n ======" );
67
+
68
+ final var byId = gatherModScheduledTransactionsById ( scheduledTransactions );
69
+ reportOnScheduledTransactionsById ( writer , byId );
70
+ System . out . println (
71
+ "Size of byId in State : " + scheduledTransactions . size () + " and gathered : " + byId . size () );
72
+
73
73
// Not sure how to compare Equality Virtual map in mono and mod
74
74
final var byExpiryDump = gatherModScheduledTransactionsByExpiry (byExpiry );
75
75
reportOnScheduledTransactionsByExpiry (writer , byExpiryDump );
76
- System .out .printf (
77
- "=== mod scheduled transactions by expiry report is %d bytes at checkpoint %s%n" ,
78
- writer .getSize (), checkpoint .name ());
76
+ System .out .println (
77
+ "Size of byExpiry in State : " + byExpiry .size () + " and gathered : " + byExpiryDump .size ());
78
+
79
+ try {
80
+ final var byEqualityDump = gatherModScheduledTransactionsByEquality (byEquality );
81
+ reportOnScheduledTransactionsByEquality (writer , byEqualityDump );
82
+ System .out .println ("Size of byEquality in State : " + byEquality .size () + " and gathered : "
83
+ + byEqualityDump .size ());
84
+ } catch (Exception e ) {
85
+ e .printStackTrace ();
86
+ System .out .println ("Error in gathering byEqualityDump" );
87
+ }
79
88
}
80
89
}
81
90
82
91
private static List <BBMScheduledEqualityValue > gatherModScheduledTransactionsByEquality (
83
92
final VirtualMap <OnDiskKey <ProtoBytes >, OnDiskValue <ScheduleList >> source ) {
84
93
final List <BBMScheduledEqualityValue > r = new ArrayList <>();
85
- final var scheduledTransactions = new CopyOnWriteArrayList <BBMScheduledEqualityValue >();
94
+ final var scheduledTransactions = new ConcurrentLinkedQueue <BBMScheduledEqualityValue >();
86
95
87
96
try {
88
97
VirtualMapLike .from (source )
89
98
.extractVirtualMapDataC (
90
99
getStaticThreadManager (),
91
100
p -> scheduledTransactions .add (
92
101
fromMod (p .key ().getKey (), p .value ().getValue ())),
93
- 8 );
102
+ 1 );
94
103
} catch (final InterruptedException ex ) {
95
104
System .err .println ("*** Traversal of scheduledTransactions by equality virtual map interrupted!" );
96
105
Thread .currentThread ().interrupt ();
97
106
}
107
+
108
+ while (!scheduledTransactions .isEmpty ()) {
109
+ final var mapping = scheduledTransactions .poll ();
110
+ r .add (mapping );
111
+ }
98
112
return r ;
99
113
}
100
114
@@ -132,11 +146,8 @@ private static Map<BBMScheduledId, BBMScheduledTransaction> gatherModScheduledTr
132
146
VirtualMapLike .from (source )
133
147
.extractVirtualMapDataC (
134
148
getStaticThreadManager (),
135
- p -> {
136
- scheduledTransactions .add (Pair .of (
137
- fromMod (p .key ().getKey ()),
138
- fromMod (p .value ().getValue ())));
139
- },
149
+ p -> scheduledTransactions .add (Pair .of (
150
+ fromMod (p .key ().getKey ()), fromMod (p .value ().getValue ()))),
140
151
8 );
141
152
} catch (final InterruptedException ex ) {
142
153
System .err .println ("*** Traversal of scheduledTransactions virtual map interrupted!" );
@@ -194,9 +205,9 @@ static BBMScheduledTransaction fromMod(@NonNull final Schedule value) {
194
205
RichInstant .fromJava (Instant .ofEpochSecond (value .calculatedExpirationSecond ())),
195
206
RichInstant .fromJava (Instant .ofEpochSecond (
196
207
value .resolutionTime ().seconds (), value .resolutionTime ().nanos ())),
197
- PbjConverter . fromPbj (value .originalCreateTransaction ()).toByteArray (),
198
- PbjConverter . fromPbj (value . originalCreateTransaction ( )),
199
- PbjConverter . fromPbj (value .scheduledTransaction ()),
208
+ fromPbj (value .originalCreateTransaction ()).toByteArray (),
209
+ fromPbj (childAsOrdinary ( value )),
210
+ fromPbj (value .scheduledTransaction ()),
200
211
value .signatories ().stream ().map (k -> toPrimitiveKey (k )).toList ());
201
212
}
202
213
0 commit comments