-
Notifications
You must be signed in to change notification settings - Fork 33
/
BrokerStateHandler.java
699 lines (602 loc) · 26.7 KB
/
BrokerStateHandler.java
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
/*
* Copyright (c) 2000, 2017 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package com.sun.messaging.jmq.jmsserver;
import com.sun.messaging.jmq.jmsserver.cluster.api.*;
import com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAClusteredBroker;
import com.sun.messaging.jmq.jmsservice.BrokerEvent;
import com.sun.messaging.jmq.jmsserver.service.*;
import com.sun.messaging.jmq.jmsserver.resources.*;
import com.sun.messaging.jmq.util.log.*;
import com.sun.messaging.jmq.io.MQAddress;
import com.sun.messaging.jmq.util.GoodbyeReason;
import com.sun.messaging.jmq.util.admin.MessageType;
import com.sun.messaging.jmq.jmsserver.core.BrokerAddress;
import com.sun.messaging.jmq.jmsserver.common.handlers.InfoRequestHandler;
import com.sun.messaging.jmq.jmsserver.util.BrokerException;
import com.sun.messaging.jmq.jmsserver.util.OperationNotAllowedException;
import com.sun.messaging.jmq.util.MQThread;
import com.sun.messaging.jmq.jmsserver.management.agent.Agent;
import com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection;
import com.sun.messaging.jmq.jmsserver.data.handlers.admin.ExclusiveRequest;
import com.sun.messaging.jmq.util.DiagManager;
import com.sun.messaging.jmq.util.ServiceType;
import com.sun.messaging.jmq.util.UID;
import com.sun.messaging.jmq.io.Status;
import com.sun.messaging.bridge.api.BridgeServiceManager;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
/**
* Class which handles shutting down and quiescing a broker.
* <P>
* <b>XXX</b> tasks to do:
* <UL>
* <LI>shutdown timeout</LI>
* <LI>Wait for queisce to complete</LI>
* <LI>handle dont takeover flag</LI>
* </UL>
*/
public class BrokerStateHandler {
private Logger logger = Globals.getLogger();
private BrokerResources br = Globals.getBrokerResources();
private static final Object exclusiveRequestLock = new Object();
private static ExclusiveRequest exclusiveRequestInProgress = null;
private static boolean shuttingDown = false;
private static boolean shutdownStarted = false;
private static Thread shutdownThread = null;
private static boolean storeShutdownStage0 = false;
private static boolean storeShutdownStage1 = false;
private static boolean storeShutdownStage2 = false;
QuiesceRunnable qrun = null;
// boolean prepared = false;
long targetShutdownTime = 0;
private static int restartCode = Globals.getConfig().getIntProperty(Globals.IMQ + ".restart.code", 255);
ClusterListener cl = new StateMonitorListener();
private FaultInjection fi = null;
public BrokerStateHandler() {
Globals.getClusterManager().addEventListener(cl);
fi = FaultInjection.getInjection();
}
public static final boolean isShuttingDown() {
return shuttingDown;
}
public static final void setShuttingDown(boolean b) {
shuttingDown = b;
}
public static final boolean isShutdownStarted() {
return shutdownStarted;
}
static final void setShutdownStarted(boolean b) {
shutdownStarted = b;
}
public static final boolean isStoreShutdownStage0() {
return storeShutdownStage0;
}
public static final boolean isStoreShutdownStage1() {
return storeShutdownStage1;
}
public static final boolean isStoreShutdownStage2() {
return storeShutdownStage2;
}
public static final Thread getShutdownThread() {
return shutdownThread;
}
public void destroy() {
Globals.getClusterManager().addEventListener(cl);
}
public static int getRestartCode() {
return restartCode;
}
public long getShutdownRemaining() {
if (targetShutdownTime == 0) {
return -1;
}
long remaining = targetShutdownTime - System.currentTimeMillis();
if (remaining < 0) {
remaining = 0;
}
return remaining;
}
public void takeoverBroker(String brokerID, Object extraInfo, boolean force) throws BrokerException {
ClusterManager cm = Globals.getClusterManager();
if (!cm.isHA()) {
throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.X_NO_ADMIN_TAKEOVER_SUPPORT));
} else {
Object extraInfo2 = null;
HAClusteredBroker hcb = null;
if (Globals.getJDBCHAEnabled()) {
hcb = (HAClusteredBroker) cm.getBroker(brokerID);
}
if (hcb == null) {
throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.X_UNKNOWN_BROKERID, brokerID));
}
if (hcb.isLocalBroker()) {
throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.X_CANNOT_TAKEOVER_SELF));
}
Globals.getHAMonitorService().takeoverBroker(hcb, extraInfo, extraInfo2, force);
}
}
/**
* @return the host:port of the broker that takes over this broker
*/
public String takeoverME(String brokerID, Long syncTimeout, Connection conn) throws BrokerException {
throw new OperationNotAllowedException(Globals.getBrokerResources().getKString(BrokerResources.X_NO_ADMIN_TAKEOVER_SUPPORT),
MessageType.getString(MessageType.MIGRATESTORE_BROKER));
}
public static void setExclusiveRequestLock(ExclusiveRequest req) throws BrokerException {
synchronized (exclusiveRequestLock) {
if (req != null) {
if (exclusiveRequestInProgress != null) {
throw new BrokerException(exclusiveRequestInProgress.toString(true), Status.CONFLICT);
}
exclusiveRequestInProgress = req;
return;
}
}
}
public static void unsetExclusiveRequestLock(ExclusiveRequest req) {
synchronized (exclusiveRequestLock) {
if (exclusiveRequestInProgress == null) {
return;
}
if (exclusiveRequestInProgress == req) {
exclusiveRequestInProgress = null;
}
}
}
/**
* Stop allowing new jms connections to the broker. This allows an administrator to "drain" the broker before shutting
* it down to prevent the loss of non-persistent state.
*
* @throws IllegalStateException
*/
public void quiesce() throws BrokerException {
if (qrun != null) {
// throw exception
throw new IllegalStateException("Already Quiescing");
}
synchronized (this) {
qrun = new QuiesceRunnable();
}
Thread thr = new MQThread(qrun, "quiesce thread");
thr.start();
}
/**
* Start allowing new jms connections to the broker. This allows an administrator to stop the "drain" the broker before
* shutting it down to prevent the loss of non-persistent state.
*/
public void stopQuiesce() throws BrokerException {
try {
// if we are in the process of quiescing, stop it
// then un-quiesce
QuiesceRunnable qr = null;
synchronized (this) {
qr = qrun;
}
if (qr != null)
{
qr.breakQuiesce(); // stop quiesce
// now, unquiesce
}
// stop accepting new jms threads
ServiceManager sm = Globals.getServiceManager();
sm.startNewConnections(ServiceType.NORMAL);
ClusteredBroker cb = Globals.getClusterManager().getLocalBroker();
cb.setState(BrokerState.OPERATING);
logger.log(Logger.INFO, BrokerResources.I_UNQUIESCE_DONE);
} catch (Exception ex) {
Globals.getLogger().logStack(Logger.WARNING, BrokerResources.E_INTERNAL_BROKER_ERROR, "exception during unquiesce", ex);
throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.E_INTERNAL_BROKER_ERROR, "unable to unquiesce"), ex);
}
}
/**
* shutdown down the broker at the specific time.
*
* @param time milliseconds delay before starting shutdown or 0 if no delay
* @param requestedBy why is the broker shutting down
* @param exitCode exitcode to use on shutdown
* @param threadOff if true, run in a seperate thread
*/
public void initiateShutdown(String requestedBy, long time, boolean triggerFailover, int exitCode, boolean threadOff) {
initiateShutdown(requestedBy, time, triggerFailover, exitCode, threadOff, true, true);
}
public void initiateShutdown(String requestedBy, long time, boolean triggerFailover, int exitCode, boolean threadOff, boolean exit, boolean cleanupJMX) {
synchronized (this) {
if (shutdownStarted) {
if (targetShutdownTime > 0) {
if (time > 0) {
targetShutdownTime = System.currentTimeMillis() + time;
} else {
targetShutdownTime = 0;
}
this.notifyAll();
}
return;
}
shutdownStarted = true;
}
Agent agent = Globals.getAgent();
if (agent != null) {
agent.notifyShutdownStart();
}
if (time > 0) {
targetShutdownTime = System.currentTimeMillis() + time;
} else {
targetShutdownTime = 0;
}
ShutdownRunnable runner = new ShutdownRunnable(requestedBy, triggerFailover, exitCode, cleanupJMX);
if (threadOff) {
Thread thr = new MQThread(runner, "shutdown thread");
thr.setDaemon(false);
thr.start();
} else {
int shutdown = runner.shutdown(); // run in current thread
if (exit) {
System.exit(shutdown);
}
}
}
public class QuiesceRunnable implements Runnable {
boolean breakQuiesce = false;
public QuiesceRunnable() throws BrokerException {
logger.log(Logger.INFO, BrokerResources.I_QUIESCE_START);
Agent agent = Globals.getAgent();
if (agent != null) {
agent.notifyQuiesceStart();
}
try {
ClusteredBroker cb = Globals.getClusterManager().getLocalBroker();
cb.setState(BrokerState.QUIESCE_STARTED);
// stop accepting new jms threads
ServiceManager sm = Globals.getServiceManager();
sm.stopNewConnections(ServiceType.NORMAL);
} catch (Exception ex) {
throw new BrokerException(BrokerResources.X_QUIESCE_FAILED, ex);
}
}
@Override
public void run() {
try {
// ok, now wait until connection count goes to 0 and
// message count goes to 0
// we are going to poll (vs trying to get a notification) because
// I dont want to worry about a possible deadlock
synchronized (this) {
while (!breakQuiesce) {
// XXX - check state
// if OK, break
ServiceManager smgr = Globals.getServiceManager();
int ccnt = smgr.getConnectionCount(ServiceType.NORMAL);
int msgcnt = Globals.getDestinationList().totalCountNonPersist();
if (ccnt == 0 && msgcnt == 0) {
break;
}
logger.log(logger.INFO, br.getKString(BrokerResources.I_MONITOR_QUIESCING, ccnt, msgcnt));
this.wait(10 * 1000);
}
}
if (!breakQuiesce) {
ClusteredBroker cb = Globals.getClusterManager().getLocalBroker();
cb.setState(BrokerState.QUIESCE_COMPLETED);
}
logger.log(Logger.INFO, BrokerResources.I_QUIESCE_DONE);
synchronized (this) {
qrun = null; // we are done
}
Agent agent = Globals.getAgent();
if (agent != null) {
agent.notifyQuiesceComplete();
}
} catch (Exception ex) {
Globals.getLogger().logStack(Logger.WARNING, BrokerResources.E_INTERNAL_BROKER_ERROR, "quiescing broker ", ex);
}
}
public synchronized void breakQuiesce() {
breakQuiesce = true;
notifyAll();
}
}
public void prepareShutdown(boolean failover, boolean force) {
prepareShutdown(failover, force, null);
}
private void prepareShutdown(boolean failover, boolean force, BrokerAddress excludedBroker) {
// prepared = true;
BridgeServiceManager bridgeManager = Globals.getBridgeServiceManager();
if (bridgeManager != null) {
try {
Globals.getLogger().log(Logger.INFO, Globals.getBrokerResources().I_STOP_BRIDGE_SERVICE_MANAGER);
bridgeManager.stop();
Globals.setBridgeServiceManager(null);
Globals.getLogger().log(Logger.INFO, Globals.getBrokerResources().I_STOPPED_BRIDGE_SERVICE_MANAGER);
} catch (Throwable t) {
logger.logStack(Logger.WARNING, Globals.getBrokerResources().W_STOP_BRIDGE_SERVICE_MANAGER_FAILED, t);
}
}
if (Globals.getMemManager() != null) {
Globals.getMemManager().stopManagement();
}
// First stop creating new destinations
if (excludedBroker == null) {
Globals.getDestinationList().shutdown();
}
// Next, close all the connections with clustered brokers
// so that we don't get stuck processing remote events..
// XXX - tell cluster whether or not failover should happen
Globals.getClusterBroadcast().stopClusterIO(failover, force, excludedBroker);
}
private void shutdownServices(String requestedBy, int exitCode, Connection excludedConn) throws BrokerException {
ServiceManager sm = Globals.getServiceManager();
ConnectionManager cmgr = Globals.getConnectionManager();
Globals.getLogger().logToAll(Logger.INFO, BrokerResources.I_BROADCAST_GOODBYE);
int id = GoodbyeReason.SHUTDOWN_BKR;
String msg = Globals.getBrokerResources().getKString(BrokerResources.M_ADMIN_REQ_SHUTDOWN, requestedBy);
if (exitCode == getRestartCode()) {
id = GoodbyeReason.RESTART_BKR;
msg = Globals.getBrokerResources().getKString(BrokerResources.M_ADMIN_REQ_RESTART, requestedBy);
}
cmgr.broadcastGoodbye(id, msg, excludedConn);
Globals.getLogger().logToAll(Logger.INFO, BrokerResources.I_FLUSH_GOODBYE);
cmgr.flushControlMessages(1000);
// XXX - should be notify other brokers we are going down ?
sm.stopAllActiveServices(true, (excludedConn == null ? null : excludedConn.getService().getName()));
}
public class ShutdownRunnable implements Runnable {
String requestedBy = "unknown";
// long targetTime = 0;
int exitCode = 0;
boolean failover = false;
boolean cleanupJMX = false;
public ShutdownRunnable(String who, boolean trigger, int exitCode, boolean cleanupJMX) {
logger.log(Logger.DEBUG, "Shutdown requested by " + who);
requestedBy = who;
// this.targetTime = target;
this.failover = trigger;
this.exitCode = exitCode;
this.cleanupJMX = cleanupJMX;
}
@Override
public void run() {
int exit = shutdown();
Broker.getBroker().exit(exit, Globals.getBrokerResources().getKString(BrokerResources.I_SHUTDOWN_REQ, requestedBy),
(exitCode == getRestartCode()) ? BrokerEvent.Type.RESTART : BrokerEvent.Type.SHUTDOWN);
}
public int shutdown() {
ClusteredBroker cb = null;
BrokerState state = null;
try {
shutdownThread = Thread.currentThread();
storeShutdownStage0 = true;
cb = Globals.getClusterManager().getLocalBroker();
try {
state = cb.getState();
if (state != BrokerState.FAILOVER_STARTED && state != BrokerState.FAILOVER_PENDING && state != BrokerState.FAILOVER_COMPLETE) {
cb.setState(BrokerState.SHUTDOWN_STARTED);
}
} catch (Throwable t) {
// Just log the error & continue
Globals.getLogger().logStack(Logger.WARNING, BrokerResources.E_SHUTDOWN, t);
}
storeShutdownStage1 = true;
storeShutdownStage0 = false;
if (getShutdownRemaining() > 0) {
logger.log(Logger.INFO, BrokerResources.I_SHUTDOWN_IN_SEC, String.valueOf(getShutdownRemaining() / 1000),
String.valueOf(getShutdownRemaining()));
// notify client
List l = Globals.getConnectionManager().getConnectionList(null);
Iterator itr = l.iterator();
while (itr.hasNext()) {
IMQConnection c = (IMQConnection) itr.next();
if (!c.isAdminConnection() && c.getClientProtocolVersion() >= Connection.HAWK_PROTOCOL) {
InfoRequestHandler.sendInfoPacket(InfoRequestHandler.REQUEST_STATUS_INFO, c, 0);
}
}
synchronized (BrokerStateHandler.this) {
try {
logger.log(Logger.INFO, BrokerResources.I_SHUTDOWN_AT, (new Date(targetShutdownTime)).toString());
BrokerStateHandler.this.wait(getShutdownRemaining());
} catch (Exception ex) {
}
}
}
// XXX should this be updated to include why ???
Globals.getLogger().logToAll(Logger.INFO,
Globals.getBrokerResources().getKString(BrokerResources.I_SHUTDOWN_BROKER) + "[" + requestedBy + ":" + Thread.currentThread() + "]");
if (Broker.getBroker().getDiagInterval() == 0) {
// Log diagnostics at shutdown
Globals.getLogger().log(Logger.INFO, DiagManager.allToString());
}
shuttingDown = true;
shutdownStarted = true;
prepareShutdown(failover, false); // in case not called yet
ServiceManager sm = Globals.getServiceManager();
sm.stopNewConnections(ServiceType.ADMIN);
shutdownServices(requestedBy, exitCode, null);
// stop JMX connectors
if (cleanupJMX) {
Agent agent = Globals.getAgent();
if (agent != null) {
agent.stop();
agent.unloadMBeans();
}
} else {
Globals.getLogger().log(Logger.INFO, BrokerResources.I_JMX_NO_SHUTDOWN);
}
} catch (Exception ex) {
Globals.getLogger().logStack(Logger.WARNING, BrokerResources.E_SHUTDOWN, ex);
// XXX do we do this if we are already in the exit thread ???
return 1;
} finally {
storeShutdownStage2 = true;
storeShutdownStage1 = false;
try {
if (cb != null
&& (state != BrokerState.FAILOVER_STARTED && state != BrokerState.FAILOVER_PENDING && state != BrokerState.FAILOVER_COMPLETE)) {
try {
if (failover) {
cb.setState(BrokerState.SHUTDOWN_FAILOVER);
} else {
cb.setState(BrokerState.SHUTDOWN_COMPLETE);
}
} catch (Throwable t) {
// Just log the error & continue
Globals.getLogger().logStack(Logger.WARNING, BrokerResources.E_SHUTDOWN, t);
}
}
storeShutdownStage2 = false;
storeShutdownStage1 = true;
// close down the persistence database
Globals.releaseStore();
} catch (Exception ex) {
Globals.getLogger().logStack(Logger.WARNING, BrokerResources.E_SHUTDOWN, ex);
// XXX do we do this if we are already in the exit thread ???
return 1;
}
}
Globals.getPortMapper().destroy();
Globals.getLogger().logToAll(Logger.INFO, BrokerResources.I_SHUTDOWN_COMPLETE);
if (exitCode == getRestartCode()) {
Globals.getLogger().log(Logger.INFO, BrokerResources.I_BROKER_RESTART);
if (fi.FAULT_INJECTION) {
fi.checkFaultAndSleep(FaultInjection.FAULT_RESTART_EXIT_SLEEP, null, true);
}
}
// XXX do we do this if we are already in the exit thread ???
return exitCode;
}
}
/**
* listener who handles sending cluster info back to the client
*/
static class StateMonitorListener implements ClusterListener {
// send cluster information to all 4.0 or later clients
void notifyClients() {
List l = Globals.getConnectionManager().getConnectionList(null);
Iterator itr = l.iterator();
while (itr.hasNext()) {
IMQConnection c = (IMQConnection) itr.next();
if (!c.isAdminConnection() && c.getClientProtocolVersion() >= Connection.HAWK_PROTOCOL) {
InfoRequestHandler.sendInfoPacket(InfoRequestHandler.REQUEST_CLUSTER_INFO, c, 0);
}
}
}
/**
* Called to notify ClusterListeners when the cluster service configuration. Configuration changes include:
* <UL>
* <LI>cluster service port</LI>
* <LI>cluster service hostname</LI>
* <LI>cluster service transport</LI>
* </UL>
* <P>
*
* @param name the name of the changed property
* @param value the new value of the changed property
*/
@Override
public void clusterPropertyChanged(String name, String value) {
// we dont care
}
/**
* Called when a new broker has been added.
*
* @param brokerSession uid associated with the added broker
* @param broker the new broker added.
*/
@Override
public void brokerAdded(ClusteredBroker broker, UID brokerSession) {
notifyClients();
}
/**
* Called when a broker has been removed.
*
* @param broker the broker removed.
* @param brokerSession uid associated with the removed broker
*/
@Override
public void brokerRemoved(ClusteredBroker broker, UID brokerSession) {
notifyClients();
}
/**
* Called when the broker who is the master broker changes (because of a reload properties).
*
* @param oldMaster the previous master broker.
* @param newMaster the new master broker.
*/
@Override
public void masterBrokerChanged(ClusteredBroker oldMaster, ClusteredBroker newMaster) {
// we dont care
}
/**
* Called when the status of a broker has changed. The status may not be accurate if a previous listener updated the
* status for this specific broker.
*
* @param brokerid the name of the broker updated.
* @param oldStatus the previous status.
* @param brokerSession uid associated with the change
* @param newStatus the new status.
* @param userData data associated with the state change
*/
@Override
public void brokerStatusChanged(String brokerid, int oldStatus, int newStatus, UID brokerSession, Object userData) {
if (!Globals.getDestinationList().isPartitionMigratable()) {
return;
}
ClusteredBroker cb = Globals.getClusterManager().getBroker(brokerid);
if (cb.isLocalBroker()) {
return;
}
if (BrokerStatus.getBrokerLinkIsUp(oldStatus) && BrokerStatus.getBrokerLinkIsDown(newStatus)) {
Globals.getDestinationList().registerPartitionArrivalCheckEvent();
}
}
/**
* Called when the state of a broker has changed. The state may not be accurate if a previous listener updated the state
* for this specific broker.
*
* @param brokerid the name of the broker updated.
* @param oldState the previous state.
* @param newState the new state.
*/
@Override
public void brokerStateChanged(String brokerid, BrokerState oldState, BrokerState newState) {
// we dont care
}
/**
* Called when the version of a broker has changed. The state may not be accurate if a previous listener updated the
* version for this specific broker.
*
* @param brokerid the name of the broker updated.
* @param oldVersion the previous version.
* @param newVersion the new version.
*/
@Override
public void brokerVersionChanged(String brokerid, int oldVersion, int newVersion) {
// we dont care
}
/**
* Called when the url address of a broker has changed. The address may not be accurate if a previous listener updated
* the address for this specific broker.
*
* @param brokerid the name of the broker updated.
* @param newAddress the previous address.
* @param oldAddress the new address.
*/
@Override
public void brokerURLChanged(String brokerid, MQAddress oldAddress, MQAddress newAddress) {
notifyClients();
}
}
}