use of org.apache.qpid.server.util.ConnectionScopedRuntimeException in project qpid-broker-j by apache.
the class ReplicatedEnvironmentFacade method setCacheSizeInternal.
void setCacheSizeInternal(long cacheSize) {
final ReplicatedEnvironment environment = _environment.get();
if (environment != null) {
try {
final EnvironmentMutableConfig oldConfig = environment.getMutableConfig();
final EnvironmentMutableConfig newConfig = oldConfig.setCacheSize(cacheSize);
environment.setMutableConfig(newConfig);
LOGGER.debug("Node {} cache size has been changed to {}", _prettyGroupNodeName, cacheSize);
} catch (RuntimeException e) {
RuntimeException handled = handleDatabaseException("Exception on setting cache size", e);
if (handled instanceof ConnectionScopedRuntimeException || handled instanceof ServerScopedRuntimeException) {
throw handled;
}
throw new ConnectionScopedRuntimeException("Cannot set cache size to " + cacheSize + " on node " + _prettyGroupNodeName, e);
}
} else {
throw new ConnectionScopedRuntimeException("Cannot set cache size to " + cacheSize + " on node " + _prettyGroupNodeName + " as environment does not exist");
}
}
use of org.apache.qpid.server.util.ConnectionScopedRuntimeException in project qpid-broker-j by apache.
the class InternalMessage method createReadOnlyHandle.
private static StoredMessage<InternalMessageMetaData> createReadOnlyHandle(final long messageNumber, final boolean persistent, final InternalMessageHeader header, final Object messageBody) {
try (ByteArrayOutputStream bytesOut = new ByteArrayOutputStream()) {
try (ObjectOutputStream os = new ObjectOutputStream(bytesOut)) {
os.writeObject(messageBody);
final byte[] bytes = bytesOut.toByteArray();
final InternalMessageMetaData metaData = InternalMessageMetaData.create(persistent, header, bytes.length);
final int metadataSize = metaData.getStorableSize();
return new StoredMessage<InternalMessageMetaData>() {
@Override
public InternalMessageMetaData getMetaData() {
return metaData;
}
@Override
public long getMessageNumber() {
return messageNumber;
}
@Override
public QpidByteBuffer getContent(final int offset, final int length) {
return QpidByteBuffer.wrap(bytes, offset, length);
}
@Override
public int getContentSize() {
return bytes.length;
}
@Override
public int getMetadataSize() {
return metadataSize;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
@Override
public boolean isInMemory() {
return true;
}
@Override
public boolean flowToDisk() {
return false;
}
@Override
public void reallocate() {
}
};
}
} catch (IOException e) {
throw new ConnectionScopedRuntimeException("Unexpected IO Exception on operation in memory", e);
}
}
Aggregations