Package org.apache.qpid.server.store.berkeleydb.keys

Examples of org.apache.qpid.server.store.berkeleydb.keys.MessageContentKey_5


{
    public MessageContentKey entryToObject(TupleInput tupleInput)
    {
        long messageId = tupleInput.readLong();
        int offset = tupleInput.readInt();
        return new MessageContentKey_5(messageId, offset);
    }
View Full Code Here


        return new MessageContentKey_5(messageId, offset);
    }

    public void objectToEntry(MessageContentKey object, TupleOutput tupleOutput)
    {
        final MessageContentKey_5 mk = (MessageContentKey_5) object;
        tupleOutput.writeLong(mk.getMessageId());
        tupleOutput.writeInt(mk.getOffset());
    }
View Full Code Here

            }

            //now remove the content data from the store if there is any.

            DatabaseEntry contentKeyEntry = new DatabaseEntry();
            MessageContentKey_5 mck = new MessageContentKey_5(messageId,0);

            TupleBinding<MessageContentKey> contentKeyTupleBinding = new MessageContentKeyTB_5();
            contentKeyTupleBinding.objectToEntry(mck, contentKeyEntry);

            //Use a partial record for the value to prevent retrieving the
            //data itself as we only need the key to identify what to remove.
            DatabaseEntry value = new DatabaseEntry();
            value.setPartial(0, 0, true);

            cursor = _messageContentDb.openCursor(tx, null);

            status = cursor.getSearchKeyRange(contentKeyEntry, value, LockMode.RMW);
            while (status == OperationStatus.SUCCESS)
            {
                mck = (MessageContentKey_5) contentKeyTupleBinding.entryToObject(contentKeyEntry);
               
                if(mck.getMessageId() != messageId)
                {
                    //we have exhausted all chunks for this message id, break
                    break;
                }
                else
                {
                    status = cursor.delete();
                   
                    if(status == OperationStatus.NOTFOUND)
                    {
                        cursor.close();
                        cursor = null;
                       
                        tx.abort();
                        throw new AMQStoreException("Content chunk offset" + mck.getOffset() + " not found for message " + messageId);
                    }
                   
                    if (_log.isDebugEnabled())
                    {
                        _log.debug("Deleted content chunk offset " + mck.getOffset() + " for message " + messageId);
                    }
                }
               
                status = cursor.getNext(contentKeyEntry, value, LockMode.RMW);
            }
View Full Code Here

    protected void addContent(final com.sleepycat.je.Transaction tx, Long messageId, int offset,
                                      ByteBuffer contentBody) throws AMQStoreException
    {
        DatabaseEntry key = new DatabaseEntry();
        TupleBinding<MessageContentKey> keyBinding = new MessageContentKeyTB_5();
        keyBinding.objectToEntry(new MessageContentKey_5(messageId, offset), key);
        DatabaseEntry value = new DatabaseEntry();
        TupleBinding<ByteBuffer> messageBinding = new ContentTB();
        messageBinding.objectToEntry(contentBody, value);
        try
        {
View Full Code Here

    public int getContent(Long messageId, int offset, ByteBuffer dst) throws AMQStoreException
    {   
        DatabaseEntry contentKeyEntry = new DatabaseEntry();
       
        //Start from 0 offset and search for the starting chunk.
        MessageContentKey_5 mck = new MessageContentKey_5(messageId, 0);
        TupleBinding<MessageContentKey> contentKeyTupleBinding = new MessageContentKeyTB_5();
        contentKeyTupleBinding.objectToEntry(mck, contentKeyEntry);
        DatabaseEntry value = new DatabaseEntry();
        TupleBinding<ByteBuffer> contentTupleBinding = new ContentTB();
       
        if (_log.isDebugEnabled())
        {
            _log.debug("Message Id: " + messageId + " Getting content body from offset: " + offset);
        }

        int written = 0;
        int seenSoFar = 0;
       
        Cursor cursor = null;
        try
        {
            cursor = _messageContentDb.openCursor(null, null);
           
            OperationStatus status = cursor.getSearchKeyRange(contentKeyEntry, value, LockMode.READ_UNCOMMITTED);

            while (status == OperationStatus.SUCCESS)
            {
                mck = (MessageContentKey_5) contentKeyTupleBinding.entryToObject(contentKeyEntry);
                long id = mck.getMessageId();
               
                if(id != messageId)
                {
                    //we have exhausted all chunks for this message id, break
                    break;
                }
               
                int offsetInMessage = mck.getOffset();
                ByteBuffer buf = (ByteBuffer) contentTupleBinding.entryToObject(value);
               
                final int size = (int) buf.limit();
               
                seenSoFar += size;
View Full Code Here

                //determine the content size
                ByteBuffer content = (ByteBuffer) contentTB.entryToObject(value);
                int contentSize = content.limit();

                //create the new key: id + previously seen data count
                MessageContentKey_5 newKey = new MessageContentKey_5(msgId, _bytesSeenSoFar);
                DatabaseEntry newKeyEntry = new DatabaseEntry();
                newContentKeyTupleBinding.objectToEntry(newKey, newKeyEntry);

                DatabaseEntry newValueEntry = new DatabaseEntry();
                contentTB.objectToEntry(content, newValueEntry);
View Full Code Here

            //determine the content size
            ByteBuffer content = (ByteBuffer) _contentTB.entryToObject(value);
            int contentSize = content.limit();

            //create the new key: id + previously seen data count
            MessageContentKey_5 newKey = new MessageContentKey_5(msgId, _bytesSeenSoFar);
            DatabaseEntry newKeyEntry = new DatabaseEntry();
            _newContentKeyTupleBinding.objectToEntry(newKey, newKeyEntry);

            DatabaseEntry newValueEntry = new DatabaseEntry();
            _contentTB.objectToEntry(content, newValueEntry);
View Full Code Here

{
    public MessageContentKey entryToObject(TupleInput tupleInput)
    {
        long messageId = tupleInput.readLong();
        int offset = tupleInput.readInt();
        return new MessageContentKey_5(messageId, offset);
    }
View Full Code Here

        return new MessageContentKey_5(messageId, offset);
    }

    public void objectToEntry(MessageContentKey object, TupleOutput tupleOutput)
    {
        final MessageContentKey_5 mk = (MessageContentKey_5) object;
        tupleOutput.writeLong(mk.getMessageId());
        tupleOutput.writeInt(mk.getOffset());
    }
View Full Code Here

                    int offset = 0;
                    do
                    {
                        DatabaseEntry contentKeyEntry = new DatabaseEntry();
                        MessageContentKey_5 mck = new MessageContentKey_5(messageId,offset);
                        TupleBinding<MessageContentKey> contentKeyTupleBinding = new MessageContentKeyTB_5();
                        contentKeyTupleBinding.objectToEntry(mck, contentKeyEntry);
                        //Use a partial record for the value to prevent retrieving the
                        //data itself as we only need the key to identify what to remove.
                        DatabaseEntry value = new DatabaseEntry();
                        value.setPartial(0, 4, true);

                        status = _messageContentDb.get(null,contentKeyEntry, value, LockMode.READ_COMMITTED);

                        if(status == OperationStatus.SUCCESS)
                        {

                            offset += IntegerBinding.entryToInt(value);
                            _messageContentDb.delete(tx, contentKeyEntry);
                            if (_log.isDebugEnabled())
                            {
                                _log.debug("Deleted content chunk offset " + mck.getOffset() + " for message " + messageId);
                            }
                        }
                    }
                    while (status == OperationStatus.SUCCESS);
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.store.berkeleydb.keys.MessageContentKey_5

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.