use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class ManagementModeStoreHandler method quiesceEntries.
private Map<UUID, Object> quiesceEntries(final SystemConfig<?> options, List<ConfiguredObjectRecord> records) {
final Map<UUID, Object> quiescedEntries = new HashMap<UUID, Object>();
final int managementModeHttpPortOverride = options.getManagementModeHttpPortOverride();
for (ConfiguredObjectRecord entry : records) {
String entryType = entry.getType();
Map<String, Object> attributes = entry.getAttributes();
boolean quiesce = false;
if (VIRTUAL_HOST_TYPE.equals(entryType) && options.isManagementModeQuiesceVirtualHosts()) {
quiesce = true;
} else if (PORT_TYPE.equals(entryType)) {
if (attributes == null) {
throw new IllegalConfigurationException("Port attributes are not set in " + entry);
}
Set<Protocol> protocols = getPortProtocolsAttribute(attributes);
if (protocols == null) {
quiesce = true;
} else {
for (Protocol protocol : protocols) {
switch(protocol) {
case HTTP:
quiesce = managementModeHttpPortOverride > 0;
break;
default:
quiesce = true;
}
}
}
}
if (quiesce) {
LOGGER.debug("Management mode quiescing entry {}", entry);
// save original state
quiescedEntries.put(entry.getId(), attributes.get(ATTRIBUTE_STATE));
}
}
return quiescedEntries;
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class ManagementModeStoreHandler method createPortsFromCommandLineOptions.
private Map<UUID, ConfiguredObjectRecord> createPortsFromCommandLineOptions(SystemConfig<?> options) {
int managementModeHttpPortOverride = options.getManagementModeHttpPortOverride();
if (managementModeHttpPortOverride < 0) {
throw new IllegalConfigurationException("Invalid http port is specified: " + managementModeHttpPortOverride);
}
Map<UUID, ConfiguredObjectRecord> cliEntries = new HashMap<UUID, ConfiguredObjectRecord>();
if (managementModeHttpPortOverride != 0) {
ConfiguredObjectRecord entry = createCLIPortEntry(managementModeHttpPortOverride, Protocol.HTTP);
cliEntries.put(entry.getId(), entry);
}
return cliEntries;
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class ManagementModeStoreHandler method recoverRecords.
public void recoverRecords(final List<ConfiguredObjectRecord> records) {
boolean b = _systemConfig.getManagementModeHttpPortOverride() > 0;
for (ConfiguredObjectRecord object : records) {
String entryType = object.getType();
Map<String, Object> attributes = object.getAttributes();
boolean quiesce = false;
if (VIRTUAL_HOST_TYPE.equals(entryType) && _systemConfig.isManagementModeQuiesceVirtualHosts()) {
quiesce = true;
} else if (PORT_TYPE.equals(entryType)) {
if (attributes == null) {
throw new IllegalConfigurationException("Port attributes are not set in " + object);
}
Set<Protocol> protocols = getPortProtocolsAttribute(attributes);
if (protocols == null) {
quiesce = true;
} else {
for (Protocol protocol : protocols) {
switch(protocol) {
case HTTP:
quiesce = b;
break;
default:
quiesce = true;
}
}
}
}
if (quiesce) {
LOGGER.debug("Management mode quiescing entry {}", object);
// save original state
_quiescedEntriesOriginalState.put(object.getId(), attributes.get(ATTRIBUTE_STATE));
Map<String, Object> modifiedAttributes = new HashMap<String, Object>(attributes);
modifiedAttributes.put(ATTRIBUTE_STATE, State.QUIESCED);
ConfiguredObjectRecord record = new ConfiguredObjectRecordImpl(object.getId(), object.getType(), modifiedAttributes, object.getParents());
_records.put(record.getId(), record);
} else {
_records.put(object.getId(), object);
}
}
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class AbstractExchange method validateOrCreateAlternateBinding.
private void validateOrCreateAlternateBinding(final Exchange<?> exchange, final boolean mayCreate) {
Object value = exchange.getAttribute(ALTERNATE_BINDING);
if (value instanceof AlternateBinding) {
AlternateBinding alternateBinding = (AlternateBinding) value;
String destinationName = alternateBinding.getDestination();
MessageDestination messageDestination = _virtualHost.getAttainedMessageDestination(destinationName, mayCreate);
if (messageDestination == null) {
throw new UnknownAlternateBindingException(destinationName);
} else if (messageDestination == this) {
throw new IllegalConfigurationException(String.format("Cannot create alternate binding for '%s' : Alternate binding destination cannot refer to self.", getName()));
} else if (isDurable() && !messageDestination.isDurable()) {
throw new IllegalConfigurationException(String.format("Cannot create alternate binding for '%s' : Alternate binding destination '%s' is not durable.", getName(), destinationName));
}
}
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class BDBVirtualHostImplTest method testValidateOnCreateForInvalidStorePath.
public void testValidateOnCreateForInvalidStorePath() throws Exception {
String hostName = getTestName();
File file = new File(_storePath + File.separator + hostName);
assertTrue("Empty file is not created", file.createNewFile());
Map<String, Object> attributes = new HashMap<>();
attributes.put(BDBVirtualHost.ID, UUID.randomUUID());
attributes.put(BDBVirtualHost.TYPE, BDBVirtualHostImpl.VIRTUAL_HOST_TYPE);
attributes.put(BDBVirtualHost.NAME, hostName);
attributes.put(BDBVirtualHost.STORE_PATH, file.getAbsoluteFile());
BDBVirtualHostImpl host = new BDBVirtualHostImpl(attributes, _node);
try {
host.create();
fail("Cannot create DBD virtual host from existing empty file");
} catch (IllegalConfigurationException e) {
assertTrue("Unexpected exception " + e.getMessage(), e.getMessage().startsWith("Cannot open virtual host message store"));
}
}
Aggregations