Search in sources :

Example 16 with DurableConfigurationStore

use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.

the class ManagementModeStoreHandlerTest method createManagementModeStoreHandler.

private ManagementModeStoreHandler createManagementModeStoreHandler() {
    _systemConfig.close();
    Map<String, Object> attributes = new HashMap<>(_systemConfigAttributes);
    attributes.put(ConfiguredObject.DESIRED_STATE, State.QUIESCED);
    attributes.remove(ConfiguredObject.TYPE);
    _systemConfig = new AbstractSystemConfig(_taskExecutor, mock(EventLogger.class), mock(Principal.class), attributes) {

        @Override
        protected void onOpen() {
        }

        @Override
        protected DurableConfigurationStore createStoreObject() {
            return _store;
        }

        @Override
        protected ListenableFuture<Void> onClose() {
            return Futures.immediateFuture(null);
        }

        @Override
        @StateTransition(currentState = State.UNINITIALIZED, desiredState = State.QUIESCED)
        protected ListenableFuture<Void> startQuiesced() {
            return Futures.immediateFuture(null);
        }
    };
    _systemConfig.open();
    return new ManagementModeStoreHandler(_store, _systemConfig);
}
Also used : AbstractSystemConfig(org.apache.qpid.server.model.AbstractSystemConfig) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) HashMap(java.util.HashMap) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) StateTransition(org.apache.qpid.server.model.StateTransition) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Example 17 with DurableConfigurationStore

use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.

the class BrokerTestHelper method createVirtualHostNodeMock.

public static VirtualHostNode createVirtualHostNodeMock(final String virtualHostNodeName, final boolean defaultVHN, final AccessControl accessControl, final Broker<?> broker) {
    ConfiguredObjectFactory objectFactory = broker.getObjectFactory();
    VirtualHostNode virtualHostNode = mockWithSystemPrincipalAndAccessControl(VirtualHostNode.class, SYSTEM_PRINCIPAL, accessControl);
    when(virtualHostNode.getName()).thenReturn(virtualHostNodeName);
    when(virtualHostNode.getTaskExecutor()).thenReturn(TASK_EXECUTOR);
    when(virtualHostNode.getChildExecutor()).thenReturn(TASK_EXECUTOR);
    when(virtualHostNode.isDefaultVirtualHostNode()).thenReturn(defaultVHN);
    when(virtualHostNode.getParent()).thenReturn(broker);
    Collection<VirtualHostNode<?>> nodes = broker.getVirtualHostNodes();
    nodes = new ArrayList<>(nodes != null ? nodes : Collections.<VirtualHostNode<?>>emptyList());
    nodes.add(virtualHostNode);
    when(broker.getVirtualHostNodes()).thenReturn(nodes);
    DurableConfigurationStore dcs = mock(DurableConfigurationStore.class);
    when(virtualHostNode.getConfigurationStore()).thenReturn(dcs);
    when(virtualHostNode.getModel()).thenReturn(objectFactory.getModel());
    when(virtualHostNode.getObjectFactory()).thenReturn(objectFactory);
    when(virtualHostNode.getCategoryClass()).thenReturn(VirtualHostNode.class);
    when(virtualHostNode.getTaskExecutor()).thenReturn(TASK_EXECUTOR);
    when(virtualHostNode.getChildExecutor()).thenReturn(TASK_EXECUTOR);
    when(virtualHostNode.createPreferenceStore()).thenReturn(mock(PreferenceStore.class));
    return virtualHostNode;
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) PreferenceStore(org.apache.qpid.server.store.preferences.PreferenceStore)

Example 18 with DurableConfigurationStore

use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.

the class BrokerImplTest method createVhnWithVh.

private void createVhnWithVh(final BrokerImpl brokerImpl, int nameSuffix, final long totalQueueSize) {
    final Map<String, Object> vhnAttributes = new HashMap<>();
    vhnAttributes.put(VirtualHostNode.TYPE, TestVirtualHostNode.VIRTUAL_HOST_NODE_TYPE);
    vhnAttributes.put(VirtualHostNode.NAME, "testVhn" + nameSuffix);
    final DurableConfigurationStore store = mock(DurableConfigurationStore.class);
    TestVirtualHostNode vhn = new TestVirtualHostNode(brokerImpl, vhnAttributes, store);
    vhn.create();
    final Map<String, Object> vhAttributes = new HashMap<>();
    vhAttributes.put(VirtualHost.TYPE, TestMemoryVirtualHost.VIRTUAL_HOST_TYPE);
    vhAttributes.put(VirtualHost.NAME, "testVh" + nameSuffix);
    TestMemoryVirtualHost vh = new TestMemoryVirtualHost(vhAttributes, vhn) {

        @Override
        public long getTotalDepthOfQueuesBytes() {
            return totalQueueSize;
        }
    };
    vh.create();
}
Also used : TestMemoryVirtualHost(org.apache.qpid.server.virtualhost.TestMemoryVirtualHost) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) TestVirtualHostNode(org.apache.qpid.server.virtualhostnode.TestVirtualHostNode)

Example 19 with DurableConfigurationStore

use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.

the class AbstractStandardVirtualHostNode method onDelete.

@Override
protected ListenableFuture<Void> onDelete() {
    final VirtualHost<?> virtualHost = getVirtualHost();
    final MessageStore messageStore = virtualHost == null ? null : virtualHost.getMessageStore();
    return doAfterAlways(closeVirtualHostIfExists(), () -> {
        if (messageStore != null) {
            messageStore.closeMessageStore();
            messageStore.onDelete(virtualHost);
        }
        if (AbstractStandardVirtualHostNode.this instanceof PreferenceStoreProvider) {
            PreferenceStore preferenceStore = ((PreferenceStoreProvider) AbstractStandardVirtualHostNode.this).getPreferenceStore();
            if (preferenceStore != null) {
                preferenceStore.onDelete();
            }
        }
        DurableConfigurationStore configurationStore = getConfigurationStore();
        if (configurationStore != null) {
            configurationStore.closeConfigurationStore();
            configurationStore.onDelete(AbstractStandardVirtualHostNode.this);
        }
        onCloseOrDelete();
    });
}
Also used : MessageStore(org.apache.qpid.server.store.MessageStore) PreferenceStoreProvider(org.apache.qpid.server.store.preferences.PreferenceStoreProvider) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) PreferenceStore(org.apache.qpid.server.store.preferences.PreferenceStore)

Example 20 with DurableConfigurationStore

use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.

the class AbstractStandardVirtualHostNodeTest method testValidateOnCreateFails_ExistingDefaultVHN.

@Test
public void testValidateOnCreateFails_ExistingDefaultVHN() throws Exception {
    String nodeName = getTestName();
    Map<String, Object> attributes = new HashMap<>();
    attributes.put(TestVirtualHostNode.NAME, nodeName);
    attributes.put(TestVirtualHostNode.DEFAULT_VIRTUAL_HOST_NODE, Boolean.TRUE);
    VirtualHostNode existingDefault = mock(VirtualHostNode.class);
    when(existingDefault.getName()).thenReturn("existingDefault");
    when(_broker.findDefautVirtualHostNode()).thenReturn(existingDefault);
    final DurableConfigurationStore store = mock(DurableConfigurationStore.class);
    AbstractStandardVirtualHostNode node = createTestStandardVirtualHostNode(attributes, store);
    try {
        node.create();
        fail("Exception not thrown");
    } catch (IllegalConfigurationException e) {
        assertTrue("Unexpected exception " + e.getMessage(), e.getMessage().startsWith("The existing virtual host node 'existingDefault' is already the default for the Broker"));
    }
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) HashMap(java.util.HashMap) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) Test(org.junit.Test)

Aggregations

DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)30 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)21 Test (org.junit.Test)18 HashMap (java.util.HashMap)14 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)5 ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)4 AccessControlException (java.security.AccessControlException)3 AccessControl (org.apache.qpid.server.security.AccessControl)3 PreferenceStore (org.apache.qpid.server.store.preferences.PreferenceStore)3 UUID (java.util.UUID)2 AbstractSystemConfig (org.apache.qpid.server.model.AbstractSystemConfig)2 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)2 TestMemoryVirtualHost (org.apache.qpid.server.virtualhost.TestMemoryVirtualHost)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 DatabaseException (com.sleepycat.je.DatabaseException)1 ReplicationGroupAdmin (com.sleepycat.je.rep.util.ReplicationGroupAdmin)1 File (java.io.File)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 ArrayList (java.util.ArrayList)1