use of com.sun.messaging.jmq.jmsserver.persist.api.TakeoverStoreInfo in project openmq by eclipse-ee4j.
the class RepHAClusteredBrokerImpl method takeover.
/**
* Attempt to take over the persistent state of the broker.
*
* @param force force the takeover
* @param tracker for tracking takingover stages
* @throws IllegalStateException if this broker can not takeover.
* @return data associated with previous broker
*/
@Override
public TakeoverStoreInfo takeover(boolean force, Object extraInfo, TakingoverTracker tracker) throws BrokerException {
String targetRepHostPort = (String) extraInfo;
Store store = Globals.getStore();
TakeoverStoreInfo o = store.takeoverBrokerStore(getInstanceName(), tracker.getDownStoreSessionUID(), targetRepHostPort, tracker);
((RepHAClusterManagerImpl) parent).addSupportedStoreSessionUID(tracker.getStoreSessionUID());
return o;
}
use of com.sun.messaging.jmq.jmsserver.persist.api.TakeoverStoreInfo in project openmq by eclipse-ee4j.
the class HAClusteredBrokerImpl method takeover.
/**
* attempt to take over the persistent state of the broker
*
* @throws IllegalStateException if this broker can not takeover.
* @return data associated with previous broker
*/
@Override
public TakeoverStoreInfo takeover(boolean force, Object extraInfo, TakingoverTracker tracker) throws BrokerException {
int delay = Globals.getConfig().getIntProperty(Globals.IMQ + ".cluster.takeover.delay.interval", 0);
if (delay > 0) {
try {
Thread.sleep(delay * 1000L);
} catch (InterruptedException e) {
}
}
boolean gotLock = false;
boolean sucessful = false;
BrokerState curstate = getState();
if (!force) {
checkCanTakeoverState(curstate, brokerid);
}
long newtime = System.currentTimeMillis();
BrokerState newstate = BrokerState.FAILOVER_PENDING;
Globals.getStore().getTakeOverLock(parent.getLocalBrokerName(), brokerid, tracker.getLastHeartbeat(), curstate, newtime, newstate, force, tracker);
gotLock = true;
state = newstate;
logger.log(Logger.DEBUG, "state = FAILOVER_PENDING " + brokerid);
parent.brokerChanged(ClusterReason.STATE_CHANGED, brokerid, curstate, newstate, null, null);
TakeoverStoreInfo o = null;
try {
// OK, explicitly retrieve old state from disk
logger.log(Logger.DEBUG, "state = FAILOVER_STARTED " + brokerid);
setState(BrokerState.FAILOVER_STARTED);
o = Globals.getStore().takeOverBrokerStore(parent.getLocalBrokerName(), brokerid, tracker);
logger.log(Logger.DEBUG, "state = FAILOVER_COMPLETE " + brokerid);
// fix for bug 6319711
// higher level processing needs to set
// failover complete AFTER routing is finished
// REMOTE: setState(BrokerState.FAILOVER_COMPLETE);
sucessful = true;
} catch (IllegalAccessException ex) {
throw new RuntimeException("Internal error, shouldnt happen", ex);
} finally {
if (gotLock && !sucessful) {
try {
setStateFailoverFailed(tracker.getBrokerSessionUID());
} catch (Exception ex) {
logger.log(logger.INFO, "Unable to set state to failed for broker " + this + ": " + ex.getMessage(), ex);
}
logger.log(Logger.WARNING, "Failed to takeover :" + brokerid + " state expected is " + curstate);
}
}
heartbeat = newtime;
parent.addSupportedStoreSessionUID(session);
takeoverBroker = parent.getLocalBrokerName();
return o;
}
use of com.sun.messaging.jmq.jmsserver.persist.api.TakeoverStoreInfo in project openmq by eclipse-ee4j.
the class SFSHAClusteredBrokerImpl method takeover.
/**
* @param force force the takeover
* @param tracker for tracking takingover stages
* @throws IllegalStateException if this broker can not takeover.
* @return data associated with previous broker
*/
@Override
public TakeoverStoreInfo takeover(boolean force, Object extraInfo, TakingoverTracker tracker) throws BrokerException {
Store store = Globals.getStore();
BrokerState curstate = getState();
store.getTakeOverLock(parent.getLocalBrokerName(), brokerid, 0L, curstate, 0L, null, force, tracker);
TakeoverStoreInfo o = store.takeoverBrokerStore(brokerid, tracker.getStoreSessionUID(), null, tracker);
parent.addSupportedStoreSessionUID(tracker.getStoreSessionUID());
return o;
}
Aggregations