Search in sources :

Example 6 with ReplicatedEnvironmentFacade

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

the class BDBHAVirtualHostNodeImpl method postSetQuorumOverride.

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

Example 7 with ReplicatedEnvironmentFacade

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

the class BDBHAVirtualHostNodeTest method testCreateAndActivateVirtualHostNode.

public void testCreateAndActivateVirtualHostNode() throws Exception {
    int node1PortNumber = _portHelper.getNextAvailable();
    String helperAddress = "localhost:" + node1PortNumber;
    String groupName = "group";
    String nodeName = "node1";
    Map<String, Object> attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber);
    String messageStorePath = (String) attributes.get(BDBHAVirtualHostNode.STORE_PATH);
    String repStreamTimeout = "2 h";
    Map<String, String> context = (Map<String, String>) attributes.get(BDBHAVirtualHostNode.CONTEXT);
    context.put(ReplicationConfig.REP_STREAM_TIMEOUT, repStreamTimeout);
    context.put(EnvironmentConfig.ENV_IS_TRANSACTIONAL, "false");
    try {
        _helper.createHaVHN(attributes);
        fail("Exception was not thrown.");
    } catch (RuntimeException e) {
        assertTrue("Unexpected Exception being thrown.", e.getCause() instanceof IllegalArgumentException);
    }
    context.put(EnvironmentConfig.ENV_IS_TRANSACTIONAL, "true");
    BDBHAVirtualHostNode<?> node = _helper.createHaVHN(attributes);
    node.start();
    _helper.assertNodeRole(node, NodeRole.MASTER, NodeRole.REPLICA);
    assertEquals("Unexpected node state", State.ACTIVE, node.getState());
    DurableConfigurationStore store = node.getConfigurationStore();
    assertNotNull(store);
    BDBConfigurationStore bdbConfigurationStore = (BDBConfigurationStore) store;
    ReplicatedEnvironmentFacade environmentFacade = (ReplicatedEnvironmentFacade) bdbConfigurationStore.getEnvironmentFacade();
    assertEquals(nodeName, environmentFacade.getNodeName());
    assertEquals(groupName, environmentFacade.getGroupName());
    assertEquals(helperAddress, environmentFacade.getHostPort());
    assertEquals(helperAddress, environmentFacade.getHelperHostPort());
    assertEquals("SYNC,NO_SYNC,SIMPLE_MAJORITY", environmentFacade.getMessageStoreDurability().toString());
    _helper.awaitForVirtualhost(node);
    VirtualHost<?> virtualHost = node.getVirtualHost();
    assertNotNull("Virtual host child was not added", virtualHost);
    assertEquals("Unexpected virtual host name", groupName, virtualHost.getName());
    assertEquals("Unexpected virtual host store", bdbConfigurationStore.getMessageStore(), virtualHost.getMessageStore());
    assertEquals("Unexpected virtual host state", State.ACTIVE, virtualHost.getState());
    node.stop();
    assertEquals("Unexpected state returned after stop", State.STOPPED, node.getState());
    assertEquals("Unexpected state", State.STOPPED, node.getState());
    assertNull("Virtual host is not destroyed", node.getVirtualHost());
    node.delete();
    assertEquals("Unexpected state returned after delete", State.DELETED, node.getState());
    assertEquals("Unexpected state", State.DELETED, node.getState());
    assertFalse("Store still exists " + messageStorePath, new File(messageStorePath).exists());
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) ReplicatedEnvironmentFacade(org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File)

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