Search in sources :

Example 31 with ConnectionScopedRuntimeException

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");
    }
}
Also used : ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) ServerScopedRuntimeException(org.apache.qpid.server.util.ServerScopedRuntimeException) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) ServerScopedRuntimeException(org.apache.qpid.server.util.ServerScopedRuntimeException)

Example 32 with ConnectionScopedRuntimeException

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);
    }
}
Also used : StoredMessage(org.apache.qpid.server.store.StoredMessage) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream)

Aggregations

ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)32 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)9 ServerScopedRuntimeException (org.apache.qpid.server.util.ServerScopedRuntimeException)7 AmqpErrorException (org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException)6 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)5 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)4 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)4 AmqpValueSection (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValueSection)4 EncodingRetainingSection (org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSection)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)3 AmqpSequenceSection (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequenceSection)3 DataSection (org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection)3 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)3 Futures.allAsList (com.google.common.util.concurrent.Futures.allAsList)2 ObjectOutputStream (java.io.ObjectOutputStream)2 BufferUnderflowException (java.nio.BufferUnderflowException)2