Search in sources :

Example 1 with Store

use of com.sun.messaging.jmq.jmsserver.persist.api.Store 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;
}
Also used : Store(com.sun.messaging.jmq.jmsserver.persist.api.Store) TakeoverStoreInfo(com.sun.messaging.jmq.jmsserver.persist.api.TakeoverStoreInfo)

Example 2 with Store

use of com.sun.messaging.jmq.jmsserver.persist.api.Store in project openmq by eclipse-ee4j.

the class ClusterImpl method checkStoredLastConfigServer.

/**
 * Check to see if stored last config server property loaded properly
 *
 * System.exit if the last config server info is corrupted the last refresh timestamp info is corrupted and unable to
 * reset potentially last config server info is corrupted: store LoadPropertyException occurred with key corruption and
 * LastConfigServer property does not in store
 *
 * In future release, the System.exit behavior may be changed to allow administratively repair - eg. through imqbrokerd
 * option to force set last config server info to the current master broker
 */
private void checkStoredLastConfigServer() throws BrokerException {
    Store s = Globals.getStore();
    boolean bad = false;
    boolean potentiallyBad = false;
    LoadException le = s.getLoadPropertyException();
    LoadException savele = null;
    while (le != null) {
        Object o = le.getKey();
        if (o == null || !(o instanceof String)) {
            potentiallyBad = true;
            savele = le;
            le = le.getNextException();
            continue;
        }
        if (((String) o).equals(ClusterGlobals.STORE_PROPERTY_LASTCONFIGSERVER)) {
            logger.log(Logger.ERROR, BrokerResources.E_CLUSTER_LOAD_LASTCONFIGSERVER, le);
            bad = true;
            break;
        }
        if (((String) o).equals(ClusterGlobals.STORE_PROPERTY_LASTREFRESHTIME)) {
            logger.log(Logger.WARNING, BrokerResources.W_CLUSTER_LOAD_LASTREFRESHTIME, le);
            try {
                s.updateProperty(ClusterGlobals.STORE_PROPERTY_LASTREFRESHTIME, Long.valueOf(-1), false);
            } catch (BrokerException e) {
                logger.log(Logger.ERROR, BrokerResources.E_CLUSTER_RESET_LASTREFRESHTIME, e);
                bad = true;
                break;
            }
        }
        le = le.getNextException();
    }
    if (potentiallyBad && !bad) {
        try {
            if (s.getProperty(ClusterGlobals.STORE_PROPERTY_LASTCONFIGSERVER) == null) {
                logger.log(Logger.ERROR, BrokerResources.E_CLUSTER_LOAD_LASTCONFIGSERVER, savele);
                bad = true;
            }
        } catch (BrokerException e) {
            logger.log(Logger.ERROR, e.getMessage(), e);
            logger.log(Logger.ERROR, BrokerResources.E_CLUSTER_LOAD_LASTCONFIGSERVER, savele);
            bad = true;
        }
    }
    if (bad) {
        logger.log(Logger.ERROR, BrokerResources.E_CLUSTER_LOAD_LASTCONFIGSERVER);
        Broker.getBroker().exit(1, Globals.getBrokerResources().getKString(BrokerResources.E_CLUSTER_LOAD_LASTCONFIGSERVER), BrokerEvent.Type.FATAL_ERROR);
    }
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) Store(com.sun.messaging.jmq.jmsserver.persist.api.Store) LoadException(com.sun.messaging.jmq.jmsserver.persist.api.LoadException)

Example 3 with Store

use of com.sun.messaging.jmq.jmsserver.persist.api.Store in project openmq by eclipse-ee4j.

the class HAClusteredBrokerImpl method updateEntry.

/**
 * updates the broker entry (this may be just timestamp or state, sessionid or brokerURL may be changed)
 *
 * @param updateType update type
 * @param oldValue old value depending on updateType
 * @param newValue new value depending on updateType
 * @return current store session UID if requested by updateType
 * @throws IllegalStateException if the information stored with the broker does not match what we expect
 * @throws IllegalAccessException if the broker does not have permission to change the broker (e.g. one broker is
 * updating anothers timestamp).
 */
protected synchronized UID updateEntry(int updateType, Object oldValue, Object newValue) throws Exception {
    if (!local) {
        throw new IllegalAccessException("Can not update entry " + " for broker " + brokerid);
    }
    Store store = Globals.getStore();
    UID ssid = store.updateBrokerInfo(brokerid, updateType, oldValue, newValue);
    try {
        heartbeat = store.getBrokerHeartbeat(brokerid);
    } catch (Exception ex) {
        logger.logStack(logger.WARNING, ex.getMessage() + "[" + brokerid + "]", ex);
    }
    return ssid;
}
Also used : UID(com.sun.messaging.jmq.util.UID) Store(com.sun.messaging.jmq.jmsserver.persist.api.Store) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Example 4 with Store

use of com.sun.messaging.jmq.jmsserver.persist.api.Store in project openmq by eclipse-ee4j.

the class SFSHAClusteredBrokerImpl method updateEntry.

@Override
protected synchronized UID updateEntry(int updateType, Object oldValue, Object newValue) throws Exception {
    if (!local) {
        throw new IllegalAccessException("Can not update entry " + " for broker " + brokerid);
    }
    Store store = Globals.getStore();
    store.updateBrokerInfo(brokerid, updateType, oldValue, newValue);
    return session;
}
Also used : Store(com.sun.messaging.jmq.jmsserver.persist.api.Store)

Example 5 with Store

use of com.sun.messaging.jmq.jmsserver.persist.api.Store 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;
}
Also used : Store(com.sun.messaging.jmq.jmsserver.persist.api.Store) TakeoverStoreInfo(com.sun.messaging.jmq.jmsserver.persist.api.TakeoverStoreInfo)

Aggregations

Store (com.sun.messaging.jmq.jmsserver.persist.api.Store)6 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)3 TakeoverStoreInfo (com.sun.messaging.jmq.jmsserver.persist.api.TakeoverStoreInfo)2 LoadException (com.sun.messaging.jmq.jmsserver.persist.api.LoadException)1 UID (com.sun.messaging.jmq.util.UID)1