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));
}
}
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()));
}
}
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);
}
}
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());
}
}
}
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);
}
}
}
Aggregations