diff options
| author | Kim van der Riet <kpvdr@apache.org> | 2013-07-10 21:37:55 +0000 |
|---|---|---|
| committer | Kim van der Riet <kpvdr@apache.org> | 2013-07-10 21:37:55 +0000 |
| commit | ce77e05f958a3ebbf8510d79de88a86e58eb6f26 (patch) | |
| tree | 8437561571345322f7317a1559b8a60d7219bc48 /qpid/cpp | |
| parent | 8c70b4b9c73c30dfe8f966d26b2375a8c4f98e83 (diff) | |
| download | qpid-python-ce77e05f958a3ebbf8510d79de88a86e58eb6f26.tar.gz | |
QPID-4984: Continuing work on the linearstoreutils lib
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/linearstore@1502018 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
| -rw-r--r-- | qpid/cpp/src/linearstore.cmake | 2 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c | 33 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h | 87 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c | 43 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h | 86 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c | 2 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h | 6 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h | 10 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h | 77 |
9 files changed, 337 insertions, 9 deletions
diff --git a/qpid/cpp/src/linearstore.cmake b/qpid/cpp/src/linearstore.cmake index ea6c0d1f4d..c3946c1a8a 100644 --- a/qpid/cpp/src/linearstore.cmake +++ b/qpid/cpp/src/linearstore.cmake @@ -120,6 +120,8 @@ if (BUILD_LINEARSTORE) set (util_SOURCES qpid/linearstore/jrnl/utils/file_hdr.c + qpid/linearstore/jrnl/utils/enq_hdr.c + qpid/linearstore/jrnl/utils/deq_hdr.c ) # linearstore include directories diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c b/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c new file mode 100644 index 0000000000..dbdb88140c --- /dev/null +++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c @@ -0,0 +1,33 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "deq_hdr.h" + +static const uint16_t DEQ_HDR_TXNCMPLCOMMIT_MASK = 0x10; + +bool is_txn_coml_commit(deq_hdr_t *dh) { + return dh->_rhdr._uflag & DEQ_HDR_TXNCMPLCOMMIT_MASK; +} + +void set_txn_coml_commit(deq_hdr_t *dh, const bool commit) { + dh->_rhdr._uflag = commit ? dh->_rhdr._uflag | DEQ_HDR_TXNCMPLCOMMIT_MASK : + dh->_rhdr._uflag & (~DEQ_HDR_TXNCMPLCOMMIT_MASK); +} diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h new file mode 100644 index 0000000000..73f99f98f2 --- /dev/null +++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h @@ -0,0 +1,87 @@ +#ifndef QPID_LINEARSTORE_JRNL_UTILS_DEQ_HDR_H +#define QPID_LINEARSTORE_JRNL_UTILS_DEQ_HDR_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +/** + * \file deq_hdr.h + * + * Qpid asynchronous store plugin library + * + * File containing code for class mrg::journal::deq_hdr (dequeue record), + * used to dequeue a previously enqueued record. + * + * \author Kim van der Riet + */ + +#include <stdbool.h> +#include "rec_hdr.h" + +#pragma pack(1) + +/** +* \brief Struct for dequeue record. +* +* Struct for dequeue record. If this record has a non-zero xidsize field (i.e., there is a +* valid XID), then this header is followed by the XID of xidsize bytes and a rec_tail. If, +* on the other hand, this record has a zero xidsize (i.e., there is no XID), then the rec_tail +* is absent. +* +* Note that this record had its own rid distinct from the rid of the record it is dequeueing. +* The rid field below is the rid of the dequeue record itself; the deq-rid field is the rid of a +* previous enqueue record being dequeued by this record. +* +* Record header info in binary format (32 bytes): +* <pre> +* 0 7 +* +---+---+---+---+---+---+---+---+ -+ +* | magic | v | e | flags | | +* +---+---+---+---+---+---+---+---+ | struct hdr +* | rid | | +* +---+---+---+---+---+---+---+---+ -+ +* | deq-rid | +* +---+---+---+---+---+---+---+---+ +* | xidsize | +* +---+---+---+---+---+---+---+---+ +* v = file version (If the format or encoding of this file changes, then this +* number should be incremented) +* e = endian flag, false (0x00) for little endian, true (0x01) for big endian +* </pre> +* +* Note that journal files should be transferable between 32- and 64-bit +* hardware of the same endianness, but not between hardware of opposite +* entianness without some sort of binary conversion utility. Thus buffering +* will be needed for types that change size between 32- and 64-bit compiles. +*/ +typedef struct deq_hdr_t { + rec_hdr_t _rhdr; + uint64_t _deq_rid; ///< Record ID of dequeued record + uint64_t _xidsize; ///< XID size +} deq_hdr_t; + +static const uint16_t DEQ_HDR_TXNCMPLCOMMIT_MASK; + +bool is_txn_coml_commit(deq_hdr_t *dh); +void set_txn_coml_commit(deq_hdr_t *dh, const bool commit); + +#pragma pack() + +#endif // ifndef QPID_LINEARSTORE_JRNL_UTILS_DEQ_HDR_H diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c b/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c new file mode 100644 index 0000000000..586c37821a --- /dev/null +++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c @@ -0,0 +1,43 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "enq_hdr.h" + +static const uint16_t ENQ_HDR_TRANSIENT_MASK = 0x10; +static const uint16_t ENQ_HDR_EXTERNAL_MASK = 0x20; + +bool is_transient(enq_hdr_t *eh) { + return eh->_rhdr._uflag & ENQ_HDR_TRANSIENT_MASK; +} + +void set_transient(enq_hdr_t *eh, const bool transient) { + eh->_rhdr._uflag = transient ? eh->_rhdr._uflag | ENQ_HDR_TRANSIENT_MASK : + eh->_rhdr._uflag & (~ENQ_HDR_TRANSIENT_MASK); +} + +bool is_external(enq_hdr_t *eh) { + return eh->_rhdr._uflag & ENQ_HDR_EXTERNAL_MASK; +} + +void set_external(enq_hdr_t *eh, const bool external) { + eh->_rhdr._uflag = external ? eh->_rhdr._uflag | ENQ_HDR_EXTERNAL_MASK : + eh->_rhdr._uflag & (~ENQ_HDR_EXTERNAL_MASK); +} diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h new file mode 100644 index 0000000000..f0d052c1f3 --- /dev/null +++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h @@ -0,0 +1,86 @@ +#ifndef QPID_LINEARSTORE_JRNL_UTILS_ENQ_HDR_H +#define QPID_LINEARSTORE_JRNL_UTILS_ENQ_HDR_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +/** + * \file enq_hdr.h + * + * Qpid asynchronous store plugin library + * + * File containing code for class mrg::journal::enq_hdr (enueue header), + * used to start an enqueue record in the journal. + * + * \author Kim van der Riet + */ + +#include <stdbool.h> +#include "rec_hdr.h" + +#pragma pack(1) + + /** + * \brief Struct for enqueue record. + * + * Struct for enqueue record. In addition to the common data, this header includes both the + * xid and data blob sizes. + * + * This header precedes all enqueue data in journal files. + * + * Record header info in binary format (32 bytes): + * <pre> + * 0 7 + * +---+---+---+---+---+---+---+---+ -+ + * | magic | v | e | flags | | + * +---+---+---+---+---+---+---+---+ | struct hdr + * | rid | | + * +---+---+---+---+---+---+---+---+ -+ + * | xidsize | + * +---+---+---+---+---+---+---+---+ + * | dsize | + * +---+---+---+---+---+---+---+---+ + * v = file version (If the format or encoding of this file changes, then this + * number should be incremented) + * e = endian flag, false (0x00) for little endian, true (0x01) for big endian + * </pre> + * + * Note that journal files should be transferable between 32- and 64-bit + * hardware of the same endianness, but not between hardware of opposite + * entianness without some sort of binary conversion utility. Thus buffering + * will be needed for types that change size between 32- and 64-bit compiles. + */ +typedef struct enq_hdr_t { + rec_hdr_t _rhdr; + uint64_t _xidsize; ///< XID size + uint64_t _dsize; ///< Record data size +} enq_hdr_t; + +static const uint16_t ENQ_HDR_TRANSIENT_MASK; +static const uint16_t ENQ_HDR_EXTERNAL_MASK; + +bool is_transient(enq_hdr_t *eh); +void set_transient(enq_hdr_t *eh, const bool transient); +bool is_external(enq_hdr_t *eh); +void set_external(enq_hdr_t *eh, const bool external); + +#pragma pack() + +#endif // ifndef QPID_LINEARSTORE_JRNL_UTILS_ENQ_HDR_H diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c b/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c index af546c034d..2b6bd37c39 100644 --- a/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c +++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c @@ -20,7 +20,6 @@ */ #include "file_hdr.h" -#include <time.h> int set_time_now(file_hdr_t *fh) { @@ -31,6 +30,7 @@ int set_time_now(file_hdr_t *fh) return err; fh->_ts_sec = ts.tv_sec; fh->_ts_nsec = ts.tv_nsec; + return 0; } diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h index af7e888ad3..ed3e67cc50 100644 --- a/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h +++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h @@ -1,5 +1,5 @@ -#ifndef QPID_LEGACYSTORE_JRNL_FILE_HDR_H -#define QPID_LEGACYSTORE_JRNL_FILE_HDR_H +#ifndef QPID_LINEARSTORE_JRNL_UTILS_FILE_HDR_H +#define QPID_LINEARSTORE_JRNL_UTILS_FILE_HDR_H /* * * Licensed to the Apache Software Foundation (ASF) under one @@ -103,4 +103,4 @@ void set_time(file_hdr_t *fh, struct timespec *ts); #pragma pack() -#endif // ifndef QPID_LEGACYSTORE_JRNL_FILE_HDR_H +#endif // ifndef QPID_LINEARSTORE_JRNL_UTILS_FILE_HDR_H diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h index c8f8c8f9d1..d176bb2301 100644 --- a/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h +++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h @@ -1,5 +1,5 @@ -#ifndef QPID_LEGACYSTORE_JRNL_REC_HDR_H -#define QPID_LEGACYSTORE_JRNL_REC_HDR_H +#ifndef QPID_LINEARSTORE_JRNL_UTILS_REC_HDR_H +#define QPID_LINEARSTORE_JRNL_UTILS_REC_HDR_H /* * * Licensed to the Apache Software Foundation (ASF) under one @@ -34,8 +34,8 @@ */ #include <stdint.h> -#include "qpid/legacystore/jrnl/jcfg.h" -#include <sys/types.h> +/*#include "qpid/legacystore/jrnl/jcfg.h"*/ +/*#include <sys/types.h>*/ #pragma pack(1) @@ -72,4 +72,4 @@ typedef struct rec_hdr_t { #pragma pack() -#endif // ifndef QPID_LEGACYSTORE_JRNL_REC_HDR_H +#endif // ifndef QPID_LINEARSTORE_JRNL_UTILS_REC_HDR_H diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h new file mode 100644 index 0000000000..25acb0a940 --- /dev/null +++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h @@ -0,0 +1,77 @@ +#ifndef QPID_LINEARSTORE_JRNL_UTILS_TXN_HDR_H +#define QPID_LINEARSTORE_JRNL_UTILS_TXN_HDR_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +/** + * \file txn_hdr.h + * + * Qpid asynchronous store plugin library + * + * File containing code for class mrg::journal::txn_hdr (transaction + * record header), used to start a transaction (commit or abort) record. + * + * \author Kim van der Riet + */ + +#include "rec_hdr.h" + +#pragma pack(1) + +/** +* \brief Struct for transaction commit and abort records. +* +* Struct for DTX commit and abort records. Only the magic distinguishes between them. Since +* this record must be used in the context of a valid XID, the xidsize field must not be zero. +* Immediately following this record is the XID itself which is xidsize bytes long, followed by +* a rec_tail. +* +* Note that this record had its own rid distinct from the rids of the record(s) making up the +* transaction it is committing or aborting. +* +* Record header info in binary format (24 bytes): +* <pre> +* 0 7 +* +---+---+---+---+---+---+---+---+ -+ +* | magic | v | e | flags | | +* +---+---+---+---+---+---+---+---+ | struct hdr +* | rid | | +* +---+---+---+---+---+---+---+---+ -+ +* | xidsize | +* +---+---+---+---+---+---+---+---+ +* v = file version (If the format or encoding of this file changes, then this +* number should be incremented) +* e = endian flag, false (0x00) for little endian, true (0x01) for big endian +* </pre> +* +* Note that journal files should be transferable between 32- and 64-bit +* hardware of the same endianness, but not between hardware of opposite +* entianness without some sort of binary conversion utility. Thus buffering +* will be needed for types that change size between 32- and 64-bit compiles. +*/ +typedef struct txn_hdr_t { + rec_hdr_t _rhdr; + uint64_t _xidsize; ///< XID size +} txn_hdr_t; + +#pragma pack() + +#endif // ifndef QPID_LINEARSTORE_JRNL_UTILS_TXN_HDR_H |
