Search in sources :

Example 6 with DurableConfigurationStore

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

the class AbstractStandardVirtualHostNodeTest method testDeleteVHNDeniedByACL.

@Test
public void testDeleteVHNDeniedByACL() throws Exception {
    AccessControl mockAccessControl = mock(AccessControl.class);
    DurableConfigurationStore configStore = configStoreThatProducesNoRecords();
    Map<String, Object> nodeAttributes = new HashMap<>();
    nodeAttributes.put(VirtualHostNode.NAME, TEST_VIRTUAL_HOST_NODE_NAME);
    nodeAttributes.put(VirtualHostNode.ID, _nodeId);
    TestVirtualHostNode node = new TestVirtualHostNode(_broker, nodeAttributes, configStore);
    node.setAccessControl(mockAccessControl);
    node.open();
    node.start();
    when(mockAccessControl.authorise(null, Operation.DELETE, node, Collections.<String, Object>emptyMap())).thenReturn(Result.DENIED);
    try {
        node.delete();
        fail("Exception not throws");
    } catch (AccessControlException ace) {
    // PASS
    }
    assertEquals("Virtual host node state changed unexpectedly", State.ACTIVE, node.getState());
    node.close();
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) HashMap(java.util.HashMap) AccessControlException(java.security.AccessControlException) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AccessControl(org.apache.qpid.server.security.AccessControl) Test(org.junit.Test)

Example 7 with DurableConfigurationStore

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

the class AbstractSystemConfig method initiateStoreAndRecovery.

private Container<?> initiateStoreAndRecovery() throws IOException {
    ConfiguredObjectRecord[] initialRecords = convertToConfigurationRecords(getInitialConfigurationLocation());
    final DurableConfigurationStore store = getConfigurationStore();
    store.init(AbstractSystemConfig.this);
    store.upgradeStoreStructure();
    final List<ConfiguredObjectRecord> records = new ArrayList<>();
    boolean isNew = store.openConfigurationStore(new ConfiguredObjectRecordHandler() {

        @Override
        public void handle(final ConfiguredObjectRecord record) {
            records.add(record);
        }
    }, initialRecords);
    String containerTypeName = getDefaultContainerType();
    for (ConfiguredObjectRecord record : records) {
        if (record.getParents() != null && record.getParents().size() == 1 && getId().equals(record.getParents().get(SystemConfig.class.getSimpleName()))) {
            containerTypeName = record.getType();
            break;
        }
    }
    QpidServiceLoader loader = new QpidServiceLoader();
    final ContainerType<?> containerType = loader.getInstancesByType(ContainerType.class).get(containerTypeName);
    if (containerType != null) {
        if (containerType.getModel() != getModel()) {
            updateModel(containerType.getModel());
        }
        containerType.getRecoverer(this).upgradeAndRecover(records);
    } else {
        throw new IllegalConfigurationException("Unknown container type '" + containerTypeName + "'");
    }
    final Class categoryClass = containerType.getCategoryClass();
    return (Container<?>) getContainer(categoryClass);
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) ArrayList(java.util.ArrayList) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) ConfiguredObjectRecordHandler(org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler)

Example 8 with DurableConfigurationStore

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

the class AbstractVirtualHostNode method postResolve.

@Override
protected void postResolve() {
    super.postResolve();
    DurableConfigurationStore store = getConfigurationStore();
    if (store == null) {
        store = createConfigurationStore();
    }
    _configurationStoreLogSubject = new MessageStoreLogSubject(getName(), store.getClass().getSimpleName());
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) MessageStoreLogSubject(org.apache.qpid.server.logging.subjects.MessageStoreLogSubject)

Example 9 with DurableConfigurationStore

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

the class ProvidedStoreVirtualHostImpl method onValidate.

@Override
public void onValidate() {
    super.onValidate();
    VirtualHostNode<?> virtualHostNode = (VirtualHostNode) getParent();
    DurableConfigurationStore configurationStore = virtualHostNode.getConfigurationStore();
    if (!(configurationStore instanceof MessageStoreProvider)) {
        throw new IllegalConfigurationException(VIRTUAL_HOST_TYPE + " virtual host can only be used where the node's store (" + configurationStore.getClass().getName() + ") is a message store provider. ");
    }
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) MessageStoreProvider(org.apache.qpid.server.store.MessageStoreProvider) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode)

Example 10 with DurableConfigurationStore

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

the class AbstractStandardVirtualHostNode method validateOnCreate.

@Override
protected void validateOnCreate() {
    super.validateOnCreate();
    DurableConfigurationStore store = createConfigurationStore();
    if (store != null) {
        try {
            store.init(this);
        } catch (Exception e) {
            throw new IllegalConfigurationException("Cannot open node configuration store:" + e.getMessage(), e);
        } finally {
            try {
                store.closeConfigurationStore();
            } catch (Exception e) {
                LOGGER.warn("Failed to close database", e);
            }
        }
    }
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) IOException(java.io.IOException)

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