File tree Expand file tree Collapse file tree 4 files changed +18
-7
lines changed
framework/src/main/java/org/tron/core/services/event Expand file tree Collapse file tree 4 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -42,11 +42,16 @@ public void init() {
4242 }
4343
4444 public void close () {
45- executor .shutdown ();
46- logger .info ("Event load service close." );
45+ try {
46+ load ();
47+ executor .shutdown ();
48+ logger .info ("Event load service close." );
49+ } catch (Exception e ) {
50+ logger .warn ("Stop event load service fail. {}" , e .getMessage ());
51+ }
4752 }
4853
49- public void load () throws Exception {
54+ public synchronized void load () throws Exception {
5055 long cacheHeadNum = BlockEventCache .getHead ().getBlockId ().getNum ();
5156 long tmpNum = manager .getDynamicPropertiesStore ().getLatestBlockHeaderNumber ();
5257 if (cacheHeadNum >= tmpNum ) {
Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ public class EventService {
1818 @ Autowired
1919 private HistoryEventService historyEventService ;
2020
21+ @ Autowired
22+ private SolidEventService solidEventService ;
23+
2124 @ Autowired
2225 private Manager manager ;
2326
@@ -54,8 +57,9 @@ public void init() {
5457 }
5558
5659 public void close () {
57- realtimeEventService .close ();
58- blockEventLoad .close ();
5960 historyEventService .close ();
61+ blockEventLoad .close ();
62+ realtimeEventService .close ();
63+ solidEventService .close ();
6064 }
6165}
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ public void init() {
4545 }
4646
4747 public void close () {
48+ work ();
4849 executor .shutdown ();
4950 logger .info ("Realtime event service close." );
5051 }
@@ -57,7 +58,7 @@ public void add(Event event) {
5758 queue .offer (event );
5859 }
5960
60- public void work () {
61+ public synchronized void work () {
6162 while (queue .size () > 0 ) {
6263 Event event = queue .poll ();
6364 flush (event .getBlockEvent (), event .isRemove ());
Original file line number Diff line number Diff line change @@ -37,11 +37,12 @@ public void init() {
3737 }
3838
3939 public void close () {
40+ work ();
4041 executor .shutdown ();
4142 logger .info ("Solid event service close." );
4243 }
4344
44- public void work () {
45+ public synchronized void work () {
4546 BlockCapsule .BlockId solidId = BlockEventCache .getSolidId ();
4647 if (solidId .getNum () <= BlockEventCache .getSolidNum ()) {
4748 return ;
You can’t perform that action at this time.
0 commit comments