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

svn commit: r1501945 - in /qpid/branches/linearstore/qpid/cpp/src: linearstore.cmake qpid/linearstore/jrnl/utils/ qpid/linearstore/jrnl/utils/file_hdr.c qpid/linearstore/jrnl/utils/file_hdr.h qpid/linearstore/jrnl/utils/rec_hdr.h

Author: tross
Date: Wed Jul 10 19:59:05 2013
New Revision: 1501945

URL: http://svn.apache.org/r1501945
Log:
QPID-4984 - Added a utilities library for linearstore and its tools.

Added:
    qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/
    qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c   (with props)
    qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h   (with props)
    qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h   (with props)
Modified:
    qpid/branches/linearstore/qpid/cpp/src/linearstore.cmake

Modified: qpid/branches/linearstore/qpid/cpp/src/linearstore.cmake
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/linearstore.cmake?rev=1501945&r1=1501944&r2=1501945&view=diff
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/linearstore.cmake (original)
+++ qpid/branches/linearstore/qpid/cpp/src/linearstore.cmake Wed Jul 10 19:59:05 2013
@@ -118,6 +118,10 @@ if (BUILD_LINEARSTORE)
         qpid/linearstore/TxnCtxt.cpp
     )
 
+    set (util_SOURCES
+        qpid/linearstore/jrnl/utils/file_hdr.c
+    )
+
     # linearstore include directories
     get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
     set (legacy_include_DIRECTORIES
@@ -132,6 +136,14 @@ if (BUILD_LINEARSTORE)
              "#include <${DB_INCLUDE_DIR}/db_cxx.h>\n")
     endif()
 
+    add_library (linearstoreutils SHARED
+        ${util_SOURCES}
+    )
+
+    target_link_libraries (linearstoreutils
+        rt
+    )
+
     add_library (linearstore MODULE
         ${legacy_jrnl_SOURCES}
         ${legacy_store_SOURCES}
@@ -148,7 +160,7 @@ if (BUILD_LINEARSTORE)
     target_link_libraries (linearstore
         aio
         uuid
-        qpidcommon qpidtypes qpidbroker
+        qpidcommon qpidtypes qpidbroker linearstoreutils
         ${DB_LIBRARY}
     )
 

Added: 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=1501945&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c Wed Jul 10 19:59:05 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 "file_hdr.h"
+#include <time.h>
+
+int set_time_now(file_hdr_t *fh)
+{
+    struct timespec ts;
+    int    err;
+
+    if (err = clock_gettime(CLOCK_REALTIME, &ts))
+        return err;
+    fh->_ts_sec = ts.tv_sec;
+    fh->_ts_nsec = ts.tv_nsec;
+}
+
+
+void set_time(file_hdr_t *fh, struct timespec *ts)
+{
+    fh->_ts_sec  = ts->tv_sec;
+    fh->_ts_nsec = ts->tv_nsec;
+}
+
+

Propchange: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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=1501945&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h Wed Jul 10 19:59:05 2013
@@ -0,0 +1,106 @@
+#ifndef QPID_LEGACYSTORE_JRNL_FILE_HDR_H
+#define QPID_LEGACYSTORE_JRNL_FILE_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 file_hdr.h
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * File containing code for class mrg::journal::file_hdr (file
+ * record header), used to start a journal file. It contains some
+ * file metadata and information to aid journal recovery.
+ *
+ * \author Kim van der Riet
+ */
+
+#include <time.h>
+#include "rec_hdr.h"
+
+#pragma pack(1)
+
+/**
+ * \brief Struct for data common to the head of all journal files. In addition to
+ * the common data, this includes the record ID and offset of the first record in
+ * the file.
+ *
+ * This header precedes all data in journal files and occupies the first complete
+ * block in the file. The record ID and offset are updated on each overwrite of the
+ * file.
+ *
+ * File header info in binary format (48 bytes):
+ * <pre>
+ *   0                           7
+ * +---+---+---+---+---+---+---+---+  -+
+ * |     magic     | v | 0 | flags |   |
+ * +---+---+---+---+---+---+---+---+   | struct hdr
+ * |       first rid in file       |   |
+ * +---+---+---+---+---+---+---+---+  -+
+ * |              fro              |
+ * +---+---+---+---+---+---+---+---+
+ * |           timestamp (sec)     |
+ * +---+---+---+---+---+---+---+---+
+ * |           timestamp (ns)      |
+ * +---+---+---+---+---+---+---+---+
+ * |  file-count   |    reserved   |
+ * +---+---+---+---+---+---+---+---+
+ * |           file-size           |
+ * +---+---+---+---+---+---+---+---+
+ * |          file-number          |
+ * +---+---+---+---+---+---+---+---+
+ * | n-len |  File Name...         |
+ * +-------+                       |
+ * |                               |
+ * +---+---+---+---+---+---+---+---+
+ *
+ * v = file version (If the format or encoding of this file changes, then this
+ *     number should be incremented)
+ * fro = First record offset, offset from start of file to first record header
+ * file-count  = Number of files in use for the journal at the time this header is written
+ * file-size   = Size of the file in octets
+ * file-number = Incrementing serial number indicating file order within a journal
+ * n-len = Length of the queue name in octets.
+ * </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 file_hdr_t {
+    rec_hdr_t _rhdr;
+    uint64_t  _fro;
+    uint64_t  _ts_sec;
+    uint64_t  _ts_nsec;
+    uint32_t  _file_count;
+    uint32_t  _reserved;
+    uint64_t  _file_size;
+    uint64_t  _file_number;
+    uint16_t  _name_length;
+} file_hdr_t;
+
+int  set_time_now(file_hdr_t *fh);
+void set_time(file_hdr_t *fh, struct timespec *ts);
+
+#pragma pack()
+
+#endif // ifndef QPID_LEGACYSTORE_JRNL_FILE_HDR_H

Propchange: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL

Added: 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=1501945&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h Wed Jul 10 19:59:05 2013
@@ -0,0 +1,75 @@
+#ifndef QPID_LEGACYSTORE_JRNL_REC_HDR_H
+#define QPID_LEGACYSTORE_JRNL_REC_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 rec_hdr.h
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * File containing code for class mrg::journal::rec_hdr (record header),
+ * which is a common initial header used for all journal record structures
+ * except the record tail (rec_tail).
+ *
+ * \author Kim van der Riet
+ */
+
+#include <stdint.h>
+#include "qpid/legacystore/jrnl/jcfg.h"
+#include <sys/types.h>
+
+#pragma pack(1)
+
+/**
+ * \brief Struct for data common to the head of all journal files and records.
+ * This includes identification for the file type, the encoding version, endian
+ * indicator and a record ID.
+ *
+ * File header info in binary format (16 bytes):
+ * <pre>
+ *   0                           7
+ * +---+---+---+---+---+---+---+---+
+ * |     magic     | v | 0 | flags |
+ * +---+---+---+---+---+---+---+---+
+ * |              rid              |
+ * +---+---+---+---+---+---+---+---+
+ * v = file version (If the format or encoding of this file changes, then this
+ *     number should be incremented)
+ * 0 = reserved
+ * </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 rec_hdr_t {
+    uint32_t _magic;       ///< File type identifier (magic number)
+    uint8_t  _version;     ///< File encoding version
+    uint8_t  _zero;        ///< Flag for determining endianness
+    uint16_t _uflag;       ///< User-defined flags
+    uint64_t _rid;         ///< Record ID (rotating 64-bit counter)
+} rec_hdr_t;
+
+#pragma pack()
+
+#endif // ifndef QPID_LEGACYSTORE_JRNL_REC_HDR_H

Propchange: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL



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