Search in sources :

Example 1 with ReplicatedEnvironmentFacade

use of org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade in project qpid-broker-j by apache.

the class BDBHAVirtualHostNodeImpl method postSetDesignatedPrimary.

// used as post action by field _designatedPrimary
@SuppressWarnings("unused")
private void postSetDesignatedPrimary() {
    ReplicatedEnvironmentFacade environmentFacade = getReplicatedEnvironmentFacade();
    if (environmentFacade != null) {
        resolveFuture(environmentFacade.reapplyDesignatedPrimary(), "Change designated primary did not complete within " + MUTATE_JE_TIMEOUT_MS + "ms. New value " + _designatedPrimary + " will become effective once the JE task thread is free.", "Failed to set designated primary to value " + _designatedPrimary + " on " + this);
        getEventLogger().message(getVirtualHostNodeLogSubject(), HighAvailabilityMessages.DESIGNATED_PRIMARY_CHANGED(String.valueOf(_designatedPrimary)));
    }
}
Also used : ReplicatedEnvironmentFacade(org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade)

Example 2 with ReplicatedEnvironmentFacade

use of org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade in project qpid-broker-j by apache.

the class BDBHAVirtualHostNodeImpl method postSetPriority.

// used as post action by field _priority
@SuppressWarnings("unused")
private void postSetPriority() {
    ReplicatedEnvironmentFacade environmentFacade = getReplicatedEnvironmentFacade();
    if (environmentFacade != null) {
        resolveFuture(environmentFacade.reapplyPriority(), "Change node priority did not complete within " + MUTATE_JE_TIMEOUT_MS + "ms. New value " + _priority + " will become effective once the JE task thread is free.", "Failed to set priority node to value " + _priority + " on " + this);
        getEventLogger().message(getVirtualHostNodeLogSubject(), HighAvailabilityMessages.PRIORITY_CHANGED(String.valueOf(_priority)));
    }
}
Also used : ReplicatedEnvironmentFacade(org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade)

Example 3 with ReplicatedEnvironmentFacade

use of org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade in project qpid-broker-j by apache.

the class BDBHAVirtualHostImpl method onOpen.

@Override
public void onOpen() {
    ReplicatedEnvironmentFacade facade = getReplicatedEnvironmentFacade();
    if (facade != null) {
        facade.setMessageStoreDurability(SyncPolicy.valueOf(getLocalTransactionSynchronizationPolicy()), SyncPolicy.valueOf(getRemoteTransactionSynchronizationPolicy()), ReplicatedEnvironmentFacade.REPLICA_REPLICA_ACKNOWLEDGMENT_POLICY);
    }
    super.onOpen();
}
Also used : ReplicatedEnvironmentFacade(org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade)

Example 4 with ReplicatedEnvironmentFacade

use of org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade in project qpid-broker-j by apache.

the class BDBHAVirtualHostNodeImpl method postSetRole.

// used as post action by field _role
@SuppressWarnings("unused")
private void postSetRole() {
    ReplicatedEnvironmentFacade environmentFacade = getReplicatedEnvironmentFacade();
    if (environmentFacade != null) {
        getEventLogger().message(getGroupLogSubject(), HighAvailabilityMessages.TRANSFER_MASTER(getName(), getAddress()));
        resolveFuture(environmentFacade.transferMasterToSelfAsynchronously(), "Transfer master did not complete within " + MUTATE_JE_TIMEOUT_MS + "ms. Node may still be elected master at a later time.", "Failed to transfer master to " + this);
    } else {
    // Ignored
    }
}
Also used : ReplicatedEnvironmentFacade(org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade)

Example 5 with ReplicatedEnvironmentFacade

use of org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade in project qpid-broker-j by apache.

the class BDBHAVirtualHostNodeImpl method activate.

@Override
protected ListenableFuture<Void> activate() {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Activating virtualhost node " + this);
    }
    // activating the environment does not cause a state change.  Adjust the role
    // so that our observers will see WAITING rather than our previous role in the group.
    // the role will change again after the election at which point it will become master or replica.
    _lastRole.set(NodeRole.WAITING);
    attributeSet(ROLE, _role, NodeRole.WAITING);
    getConfigurationStore().init(this);
    getEventLogger().message(getConfigurationStoreLogSubject(), ConfigStoreMessages.CREATED());
    getEventLogger().message(getConfigurationStoreLogSubject(), ConfigStoreMessages.STORE_LOCATION(getStorePath()));
    ReplicatedEnvironmentFacade environmentFacade = (ReplicatedEnvironmentFacade) getConfigurationStore().getEnvironmentFacade();
    if (environmentFacade == null) {
        throw new IllegalStateException("Environment facade is not created");
    }
    try {
        Set<ReplicationNode> remoteNodes = environmentFacade.getNodes();
        for (ReplicationNode node : remoteNodes) {
            String nodeAddress = node.getHostName() + ":" + node.getPort();
            if (!_permittedNodes.contains(nodeAddress)) {
                getEventLogger().message(getGroupLogSubject(), HighAvailabilityMessages.INTRUDER_DETECTED(node.getName(), nodeAddress));
                shutdownOnIntruder(nodeAddress);
                throw new IllegalStateException("Intruder node detected: " + nodeAddress);
            }
        }
    } catch (DatabaseException dbe) {
        environmentFacade.handleDatabaseException("DB exception while checking for intruder node", dbe);
    }
    if (_environmentFacade.compareAndSet(null, environmentFacade)) {
        environmentFacade.setStateChangeListener(new EnvironmentStateChangeListener());
        environmentFacade.setReplicationGroupListener(new RemoteNodesDiscoverer());
        environmentFacade.setPermittedNodes(_permittedNodes);
    }
    return Futures.immediateFuture(null);
}
Also used : ReplicatedEnvironmentFacade(org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade) RemoteReplicationNode(org.apache.qpid.server.model.RemoteReplicationNode) ReplicationNode(com.sleepycat.je.rep.ReplicationNode) DatabaseException(com.sleepycat.je.DatabaseException)

Aggregations

ReplicatedEnvironmentFacade (org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade)7 DatabaseException (com.sleepycat.je.DatabaseException)1 ReplicationNode (com.sleepycat.je.rep.ReplicationNode)1 File (java.io.File)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 RemoteReplicationNode (org.apache.qpid.server.model.RemoteReplicationNode)1 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)1