Search in sources :

Example 66 with IllegalConfigurationException

use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.

the class BDBHAVirtualHostNodeImpl method validateAddress.

private void validateAddress() {
    String address = getAddress();
    URI uri = addressToURI(address);
    if (!PortUtil.isPortAvailable(uri.getHost(), uri.getPort())) {
        throw new IllegalConfigurationException(String.format("Cannot bind to address '%s'. Address is already in use.", address));
    }
}
Also used : IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) URI(java.net.URI)

Example 67 with IllegalConfigurationException

use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.

the class BDBHAVirtualHostNodeImpl method onValidate.

@Override
public void onValidate() {
    super.onValidate();
    PreferenceStoreAttributes preferenceStoreAttributes = getPreferenceStoreAttributes();
    if (!preferenceStoreAttributes.getType().equals(ProvidedPreferenceStoreFactoryService.TYPE)) {
        throw new IllegalConfigurationException(String.format("BDBHAVirtualHostNode only supports Provided preference store but configured '%s'", preferenceStoreAttributes.getType()));
    }
}
Also used : PreferenceStoreAttributes(org.apache.qpid.server.store.preferences.PreferenceStoreAttributes) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException)

Example 68 with IllegalConfigurationException

use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.

the class BDBHAVirtualHostNodeTest method testValidateOnCreateForInvalidStorePath.

public void testValidateOnCreateForInvalidStorePath() throws Exception {
    int node1PortNumber = 0;
    File storeBaseFolder = TestFileUtils.createTestDirectory();
    File file = new File(storeBaseFolder, getTestName());
    file.createNewFile();
    File storePath = new File(file, "test");
    try {
        Map<String, Object> attributes = _helper.createNodeAttributes("node1", "group", "localhost:" + node1PortNumber, "localhost:" + node1PortNumber, "node2", node1PortNumber, node1PortNumber);
        attributes.put(BDBHAVirtualHostNode.STORE_PATH, storePath.getAbsoluteFile());
        try {
            _helper.createAndStartHaVHN(attributes);
            fail("Node creation should fail because of invalid store path");
        } catch (IllegalConfigurationException e) {
            assertEquals("Unexpected exception on attempt to create environment in invalid location", String.format("Store path '%s' is not a folder", storePath.getAbsoluteFile()), e.getMessage());
        }
    } finally {
        FileUtils.delete(storeBaseFolder, true);
    }
}
Also used : IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) File(java.io.File)

Example 69 with IllegalConfigurationException

use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.

the class BDBHAVirtualHostNodeTest method testValidateOnCreateForAlreadyBoundAddress.

public void testValidateOnCreateForAlreadyBoundAddress() throws Exception {
    try (ServerSocket serverSocket = new ServerSocket()) {
        serverSocket.setReuseAddress(true);
        serverSocket.bind(new InetSocketAddress("localhost", 0));
        int node1PortNumber = serverSocket.getLocalPort();
        Map<String, Object> attributes = _helper.createNodeAttributes("node1", "group", "localhost:" + node1PortNumber, "localhost:" + node1PortNumber, "node2", node1PortNumber, node1PortNumber);
        try {
            _helper.createAndStartHaVHN(attributes);
            fail("Node creation should fail because of invalid address");
        } catch (IllegalConfigurationException e) {
            assertEquals("Unexpected exception on attempt to create node with already bound address", String.format("Cannot bind to address '%s'. Address is already in use.", "localhost:" + node1PortNumber), e.getMessage());
        }
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ServerSocket(java.net.ServerSocket) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Example 70 with IllegalConfigurationException

use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.

the class FileBasedGroupProviderImpl method onCreate.

@Override
protected void onCreate() {
    super.onCreate();
    File file = new File(_path);
    if (!file.exists()) {
        File parent = file.getAbsoluteFile().getParentFile();
        if (!parent.exists() && !parent.mkdirs()) {
            throw new IllegalConfigurationException(String.format("Cannot create groups file at '%s'", _path));
        }
        try {
            String posixFileAttributes = getContextValue(String.class, SystemConfig.POSIX_FILE_PERMISSIONS);
            new FileHelper().createNewFile(file, posixFileAttributes);
        } catch (IOException e) {
            throw new IllegalConfigurationException(String.format("Cannot create groups file at '%s'", _path), e);
        }
    }
}
Also used : FileHelper(org.apache.qpid.server.util.FileHelper) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) IOException(java.io.IOException) File(java.io.File)

Aggregations

IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)87 HashMap (java.util.HashMap)31 IOException (java.io.IOException)25 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)20 File (java.io.File)15 UUID (java.util.UUID)12 ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)12 GeneralSecurityException (java.security.GeneralSecurityException)10 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)9 LinkedHashMap (java.util.LinkedHashMap)7 Map (java.util.Map)7 ServerScopedRuntimeException (org.apache.qpid.server.util.ServerScopedRuntimeException)7 AccessControlException (java.security.AccessControlException)6 ArrayList (java.util.ArrayList)6 Protocol (org.apache.qpid.server.model.Protocol)5 UnknownAlternateBindingException (org.apache.qpid.server.virtualhost.UnknownAlternateBindingException)5 MalformedURLException (java.net.MalformedURLException)4 URL (java.net.URL)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 HashSet (java.util.HashSet)4