You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kp...@apache.org on 2013/07/10 23:37:56 UTC

svn commit: r1502018 - in /qpid/branches/linearstore/qpid/cpp/src: ./ qpid/linearstore/jrnl/utils/

Author: kpvdr
Date: Wed Jul 10 21:37:55 2013
New Revision: 1502018

URL: http://svn.apache.org/r1502018
Log:
QPID-4984: Continuing work on the linearstoreutils lib

Added:
    qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c
    qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h
    qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c
    qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h
    qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h
Modified:
    qpid/branches/linearstore/qpid/cpp/src/linearstore.cmake
    qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c
    qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h
    qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h

Modified: qpid/branches/linearstore/qpid/cpp/src/linearstore.cmake
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/linearstore.cmake?rev=1502018&r1=1502017&r2=1502018&view=diff
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/linearstore.cmake (original)
+++ qpid/branches/linearstore/qpid/cpp/src/linearstore.cmake Wed Jul 10 21:37:55 2013
@@ -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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c?rev=1502018&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c Wed Jul 10 21:37:55 2013
@@ -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);
+}

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h?rev=1502018&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h Wed Jul 10 21:37:55 2013
@@ -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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c?rev=1502018&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c Wed Jul 10 21:37:55 2013
@@ -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);
+}

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h?rev=1502018&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h Wed Jul 10 21:37:55 2013
@@ -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

Modified: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c?rev=1502018&r1=1502017&r2=1502018&view=diff
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c (original)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c Wed Jul 10 21:37:55 2013
@@ -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;
 }
 
 

Modified: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h?rev=1502018&r1=1502017&r2=1502018&view=diff
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h (original)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h Wed Jul 10 21:37:55 2013
@@ -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 tim
 
 #pragma pack()
 
-#endif // ifndef QPID_LEGACYSTORE_JRNL_FILE_HDR_H
+#endif // ifndef QPID_LINEARSTORE_JRNL_UTILS_FILE_HDR_H

Modified: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h?rev=1502018&r1=1502017&r2=1502018&view=diff
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h (original)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h Wed Jul 10 21:37:55 2013
@@ -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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h?rev=1502018&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h Wed Jul 10 21:37:55 2013
@@ -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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org