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 20:20:20 UTC

svn commit: r1501895 [9/10] - in /qpid/branches/linearstore/qpid/cpp/src: ./ qpid/linearstore/ qpid/linearstore/jrnl/

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.cpp?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.cpp (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.cpp Wed Jul 10 18:20:19 2013
@@ -0,0 +1,125 @@
+/*
+ *
+ * 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 rrfc.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * File containing code for class mrg::journal::rrfc (rotating
+ * file controller). See comments in file rrfc.h for details.
+ *
+ * \author Kim van der Riet
+ */
+
+
+#include "qpid/legacystore/jrnl/rrfc.h"
+
+#include <cerrno>
+#include <fcntl.h>
+#include <unistd.h>
+#include "qpid/legacystore/jrnl/jerrno.h"
+#include "qpid/legacystore/jrnl/jexception.h"
+
+namespace mrg
+{
+namespace journal
+{
+
+rrfc::rrfc(const lpmgr* lpmp): rfc(lpmp), _fh(-1), _valid(false)
+{}
+
+rrfc::~rrfc()
+{
+    close_fh();
+}
+
+void
+rrfc::finalize()
+{
+    unset_findex();
+    rfc::finalize();
+}
+
+void
+rrfc::set_findex(const u_int16_t fc_index)
+{
+    rfc::set_findex(fc_index);
+    open_fh(_curr_fc->fname());
+}
+
+void
+rrfc::unset_findex()
+{
+    set_invalid();
+    close_fh();
+    rfc::unset_findex();
+}
+
+iores
+rrfc::rotate()
+{
+    if (!_lpmp->num_jfiles())
+        throw jexception(jerrno::JERR__NINIT, "rrfc", "rotate");
+    u_int16_t next_fc_index = _fc_index + 1;
+    if (next_fc_index == _lpmp->num_jfiles())
+        next_fc_index = 0;
+    set_findex(next_fc_index);
+    return RHM_IORES_SUCCESS;
+}
+
+std::string
+rrfc::status_str() const
+{
+    std::ostringstream oss;
+    oss << "rrfc: " << rfc::status_str();
+    if (is_active())
+        oss << " fcntl[" << _fc_index << "]: " << _curr_fc->status_str();
+    return oss.str();
+}
+
+// === protected functions ===
+
+void
+rrfc::open_fh(const std::string& fn)
+{
+    close_fh();
+    _fh = ::open(fn.c_str(), O_RDONLY | O_DIRECT);
+    if (_fh < 0)
+    {
+        std::ostringstream oss;
+        oss << "file=\"" << fn << "\"" << FORMAT_SYSERR(errno);
+        throw jexception(jerrno::JERR_RRFC_OPENRD, oss.str(), "rrfc", "open_fh");
+    }
+}
+
+void
+rrfc::close_fh()
+{
+    if (_fh >= 0)
+    {
+        ::close(_fh);
+        _fh = -1;
+    }
+}
+
+} // namespace journal
+} // namespace mrg

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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.h
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.h?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.h (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.h Wed Jul 10 18:20:19 2013
@@ -0,0 +1,179 @@
+/*
+ *
+ * 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 rrfc.h
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * File containing code for class mrg::journal::rrfc (rotating
+ * file controller). See class documentation for details.
+ *
+ * \author Kim van der Riet
+ */
+
+#ifndef QPID_LEGACYSTORE_JRNL_RRFC_H
+#define QPID_LEGACYSTORE_JRNL_RRFC_H
+
+namespace mrg
+{
+namespace journal
+{
+class rrfc;
+}
+}
+
+#include "qpid/legacystore/jrnl/fcntl.h"
+#include "qpid/legacystore/jrnl/rfc.h"
+
+namespace mrg
+{
+namespace journal
+{
+
+    /**
+    * \class rrfc
+    * \brief Read Rotating File Controller (rrfc) - Subclassed from pure virtual class rfc. Used to control the read
+    *     pipeline in a rotating file buffer or journal. See class rfc for further details.
+    *
+    * The states that exist in this class are identical to class rfc from which it inherits, but in addition, the value
+    * of the read file handle _fh is also considered. The calls to set_findex also opens the file handle _fh to the
+    * active file for reading. Similarly, unset_findex() closes this file handle.
+    *
+    * <pre>
+    *                                                                   is_init()  is_active()
+    *                  +===+                    _lpmp.is_init() == false
+    *      +---------->|   |     Uninitialized: _curr_fc == 0               F           F
+    *      |       +-->+===+ --+                _fh == -1
+    *      |       |           |
+    *      |       |           |
+    *      |   finalize()   initialize()
+    *      |       |           |
+    *      |       |           |
+    *      |       +-- +===+<--+                _lpmp.is_init() == true
+    *  finalize()      |   |     Inactive:      _curr_fc == 0               T           F
+    *      |       +-->+===+ --+                _fh == -1
+    *      |       |           |
+    *      |       |           |
+    *      | unset_findex() set_findex()
+    *      |       |           |
+    *      |       |           |
+    *      |       +-- +===+<--+                _lpmp.is_init() == true
+    *      +---------- |   |     Active:        _curr_fc != 0               T           T
+    *                  +===+                    _fh >= 0
+    * </pre>
+    *
+    * In adition to the states above, class rrfc contains a validity flag. This is operated indepenedently of the state
+    * machine. This flag (_valid) indicates when the read buffers are valid for reading. This is not strictly a state,
+    * but simply a flag used to keep track of the status, and is set/unset with calls to set_valid() and set_invalid()
+    * respectively.
+    */
+    class rrfc : public rfc
+    {
+    protected:
+        int _fh;                ///< Read file handle
+        bool _valid;            ///< Flag is true when read pages contain vailid data
+
+    public:
+        rrfc(const lpmgr* lpmp);
+        virtual ~rrfc();
+
+        /**
+        * \brief Initialize the controller, moving from state Uninitialized to Initialized. The main function of
+        *     initialize() is to set the number of files and the pointer to the fcntl array.
+        */
+        inline void initialize() { rfc::initialize(); _valid = false; }
+
+        /**
+        * \brief Reset the controller to Uninitialized state, usually called when the journal is stopped. Once called,
+        *     initialize() must be called to reuse an instance.
+        */
+        void finalize();
+
+        /**
+        * \brief Opens the file handle for reading a particular fid. Moves to state open.
+        */
+        void set_findex(const u_int16_t fc_index);
+
+        /**
+        * \brief Closes the read file handle and nulls the active fcntl pointer. Moves to state closed.
+        */
+        void unset_findex();
+
+        /**
+        * \brief Check the state: true = open; false = closed.
+        */
+        inline bool is_active() const { return _curr_fc != 0 && _fh >= 0; }
+
+        /**
+        * \brief Sets the validity flag which indicates that the read buffers contain valid data for reading.
+        */
+        inline void set_invalid() { _valid = false; }
+
+        /**
+        * \brief Resets the validity flag wich indicates that the read buffers are no longer synchronized and cannot
+        *     be read whithout resynchronization.
+        */
+        inline void set_valid() { _valid = true; }
+
+        /**
+        * \brief Checks the read buffer validity status: true = valid, can be read; false = invalid, synchronization
+        *     required.
+        */
+        inline bool is_valid() const { return _valid; }
+
+        /**
+        * \brief Rotate active file controller to next file in rotating file group.
+        * \exception jerrno::JERR__NINIT if called before calling initialize().
+        */
+        iores rotate();
+
+        inline int fh() const { return _fh; }
+
+        inline u_int32_t subm_cnt_dblks() const { return _curr_fc->rd_subm_cnt_dblks(); }
+        inline std::size_t subm_offs() const { return _curr_fc->rd_subm_offs(); }
+        inline u_int32_t add_subm_cnt_dblks(u_int32_t a) { return _curr_fc->add_rd_subm_cnt_dblks(a); }
+
+        inline u_int32_t cmpl_cnt_dblks() const { return _curr_fc->rd_cmpl_cnt_dblks(); }
+        inline std::size_t cmpl_offs() const { return _curr_fc->rd_cmpl_offs(); }
+        inline u_int32_t add_cmpl_cnt_dblks(u_int32_t a) { return _curr_fc->add_rd_cmpl_cnt_dblks(a); }
+
+        inline bool is_void() const { return _curr_fc->rd_void(); }
+        inline bool is_empty() const { return _curr_fc->rd_empty(); }
+        inline u_int32_t remaining_dblks() const { return _curr_fc->rd_remaining_dblks(); }
+        inline bool is_full() const { return _curr_fc->is_rd_full(); }
+        inline bool is_compl() const { return _curr_fc->is_rd_compl(); }
+        inline u_int32_t aio_outstanding_dblks() const { return _curr_fc->rd_aio_outstanding_dblks(); }
+        inline bool file_rotate() const { return _curr_fc->rd_file_rotate(); }
+        inline bool is_wr_aio_outstanding() const { return _curr_fc->wr_aio_outstanding_dblks() > 0; }
+
+        // Debug aid
+        std::string status_str() const;
+
+    protected:
+        void open_fh(const std::string& fn);
+        void close_fh();
+    }; // class rrfc
+
+} // namespace journal
+} // namespace mrg
+
+#endif // ifndef QPID_LEGACYSTORE_JRNL_RRFC_H

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

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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/slock.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/slock.cpp?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/slock.cpp (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/slock.cpp Wed Jul 10 18:20:19 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.
+ *
+ */
+
+/**
+ * \file slock.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * File containing code for class mrg::journal::slock (scoped lock). See
+ * comments in file slock.h for details.
+ *
+ * \author Kim van der Riet
+ */
+
+#include "qpid/legacystore/jrnl/slock.h"

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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/slock.h
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/slock.h?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/slock.h (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/slock.h Wed Jul 10 18:20:19 2013
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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 slock.h
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * Messaging journal scoped lock class mrg::journal::slock and scoped try-lock
+ * class mrg::journal::stlock.
+ *
+ * \author Kim van der Riet
+ */
+
+#ifndef QPID_LEGACYSTORE_JRNL_SLOCK_H
+#define QPID_LEGACYSTORE_JRNL_SLOCK_H
+
+#include "qpid/legacystore/jrnl/jexception.h"
+#include "qpid/legacystore/jrnl/smutex.h"
+#include <pthread.h>
+
+namespace mrg
+{
+namespace journal
+{
+
+    // Ultra-simple scoped lock class, auto-releases mutex when it goes out-of-scope
+    class slock
+    {
+    protected:
+        const smutex& _sm;
+    public:
+        inline slock(const smutex& sm) : _sm(sm)
+        {
+            PTHREAD_CHK(::pthread_mutex_lock(_sm.get()), "::pthread_mutex_lock", "slock", "slock");
+        }
+        inline ~slock()
+        {
+            PTHREAD_CHK(::pthread_mutex_unlock(_sm.get()), "::pthread_mutex_unlock", "slock", "~slock");
+        }
+    };
+
+    // Ultra-simple scoped try-lock class, auto-releases mutex when it goes out-of-scope
+    class stlock
+    {
+    protected:
+        const smutex& _sm;
+        bool _locked;
+    public:
+        inline stlock(const smutex& sm) : _sm(sm), _locked(false)
+        {
+            int ret = ::pthread_mutex_trylock(_sm.get());
+            _locked = (ret == 0); // check if lock obtained
+            if (!_locked && ret != EBUSY) PTHREAD_CHK(ret, "::pthread_mutex_trylock", "stlock", "stlock");
+        }
+        inline ~stlock()
+        {
+            if (_locked)
+                PTHREAD_CHK(::pthread_mutex_unlock(_sm.get()), "::pthread_mutex_unlock", "stlock", "~stlock");
+        }
+        inline bool locked() const { return _locked; }
+    };
+
+} // namespace journal
+} // namespace mrg
+
+#endif // ifndef QPID_LEGACYSTORE_JRNL_SLOCK_H

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

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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/smutex.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/smutex.cpp?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/smutex.cpp (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/smutex.cpp Wed Jul 10 18:20:19 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.
+ *
+ */
+
+/**
+ * \file smutex.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * File containing code for class mrg::journal::smutex (scoped mutex). See
+ * comments in file smutex.h for details.
+ *
+ * \author Kim van der Riet
+ */
+
+#include "qpid/legacystore/jrnl/smutex.h"

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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/smutex.h
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/smutex.h?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/smutex.h (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/smutex.h Wed Jul 10 18:20:19 2013
@@ -0,0 +1,64 @@
+/*
+ *
+ * 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 smutex.h
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * Messaging journal scoped mutex class mrg::journal::smutex.
+ *
+ * \author Kim van der Riet
+ */
+
+
+#ifndef QPID_LEGACYSTORE_JRNL_SMUTEX_H
+#define QPID_LEGACYSTORE_JRNL_SMUTEX_H
+
+#include "qpid/legacystore/jrnl/jexception.h"
+#include <pthread.h>
+
+namespace mrg
+{
+namespace journal
+{
+
+    // Ultra-simple scoped mutex class that allows a posix mutex to be initialized and destroyed with error checks
+    class smutex
+    {
+    protected:
+        mutable pthread_mutex_t _m;
+    public:
+        inline smutex()
+        {
+            PTHREAD_CHK(::pthread_mutex_init(&_m, 0), "::pthread_mutex_init", "smutex", "smutex");
+        }
+        inline virtual ~smutex()
+        {
+            PTHREAD_CHK(::pthread_mutex_destroy(&_m), "::pthread_mutex_destroy", "smutex", "~smutex");
+        }
+        inline pthread_mutex_t* get() const { return &_m; }
+    };
+
+} // namespace journal
+} // namespace mrg
+
+#endif // ifndef QPID_LEGACYSTORE_JRNL_SMUTEX_H

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

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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.cpp?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.cpp (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.cpp Wed Jul 10 18:20:19 2013
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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 time_ns.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * Messaging journal time struct mrg::journal::time_ns, derived from
+ * the timespec struct and provided with helper functions.
+ *
+ * \author Kim van der Riet
+ */
+
+#include "qpid/legacystore/jrnl/time_ns.h"
+
+#include <sstream>
+
+namespace mrg
+{
+namespace journal
+{
+
+const std::string
+time_ns::str(int precision) const
+{
+    const double t = tv_sec + (tv_nsec/1e9);
+    std::ostringstream oss;
+    oss.setf(std::ios::fixed, std::ios::floatfield);
+    oss.precision(precision);
+    oss << t;
+    return oss.str();
+}
+
+
+} // namespace journal
+} // namespace mrg

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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.h
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.h?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.h (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.h Wed Jul 10 18:20:19 2013
@@ -0,0 +1,105 @@
+/*
+ *
+ * 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 time_ns.h
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * Messaging journal time struct mrg::journal::time_ns, derived from
+ * the timespec struct and provided with helper functions.
+ *
+ * \author Kim van der Riet
+ */
+
+#ifndef QPID_LEGACYSTORE_JRNL_TIME_NS_H
+#define QPID_LEGACYSTORE_JRNL_TIME_NS_H
+
+#include <cerrno>
+#include <ctime>
+#include <string>
+
+namespace mrg
+{
+namespace journal
+{
+
+struct time_ns : public timespec
+{
+    inline time_ns() { tv_sec = 0; tv_nsec = 0; }
+    inline time_ns(const std::time_t sec, const long nsec = 0) { tv_sec = sec; tv_nsec = nsec; }
+    inline time_ns(const time_ns& t) { tv_sec = t.tv_sec; tv_nsec = t.tv_nsec; }
+
+    inline void set_zero() { tv_sec = 0; tv_nsec = 0; }
+    inline bool is_zero() const { return tv_sec == 0 && tv_nsec == 0; }
+    inline int now() { if(::clock_gettime(CLOCK_REALTIME, this)) return errno; return 0; }
+    const std::string str(int precision = 6) const;
+
+    inline time_ns& operator=(const time_ns& rhs)
+        { tv_sec = rhs.tv_sec; tv_nsec = rhs.tv_nsec; return *this; }
+    inline time_ns& operator+=(const time_ns& rhs)
+    {
+        tv_nsec += rhs.tv_nsec;
+        if (tv_nsec >= 1000000000L) { tv_sec++; tv_nsec -= 1000000000L; }
+        tv_sec += rhs.tv_sec;
+        return *this;
+    }
+    inline time_ns& operator+=(const long ns)
+    {
+        tv_nsec += ns;
+        if (tv_nsec >= 1000000000L) { tv_sec++; tv_nsec -= 1000000000L; }
+        return *this;
+    }
+    inline time_ns& operator-=(const long ns)
+    {
+        tv_nsec -= ns;
+        if (tv_nsec < 0) { tv_sec--; tv_nsec += 1000000000L; }
+        return *this;
+    }
+    inline time_ns& operator-=(const time_ns& rhs)
+    {
+        tv_nsec -= rhs.tv_nsec;
+        if (tv_nsec < 0) { tv_sec--; tv_nsec += 1000000000L; }
+        tv_sec -= rhs.tv_sec;
+        return *this;
+    }
+    inline const time_ns operator+(const time_ns& rhs)
+        { time_ns t(*this); t += rhs; return t; }
+    inline const time_ns operator-(const time_ns& rhs)
+        { time_ns t(*this); t -= rhs; return t; }
+    inline bool operator==(const time_ns& rhs)
+       { return tv_sec == rhs.tv_sec && tv_nsec == rhs.tv_nsec; }
+    inline bool operator!=(const time_ns& rhs)
+       { return tv_sec != rhs.tv_sec || tv_nsec != rhs.tv_nsec; }
+    inline bool operator>(const time_ns& rhs)
+       { if(tv_sec == rhs.tv_sec) return tv_nsec > rhs.tv_nsec; return tv_sec > rhs.tv_sec; }
+    inline bool operator>=(const time_ns& rhs)
+       { if(tv_sec == rhs.tv_sec) return tv_nsec >= rhs.tv_nsec; return tv_sec >= rhs.tv_sec; }
+    inline bool operator<(const time_ns& rhs)
+       { if(tv_sec == rhs.tv_sec) return tv_nsec < rhs.tv_nsec; return tv_sec < rhs.tv_sec; }
+    inline bool operator<=(const time_ns& rhs)
+       { if(tv_sec == rhs.tv_sec) return tv_nsec <= rhs.tv_nsec; return tv_sec <= rhs.tv_sec; }
+};
+
+} // namespace journal
+} // namespace mrg
+
+#endif // ifndef QPID_LEGACYSTORE_JRNL_TIME_NS_H

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

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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_hdr.h
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_hdr.h?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_hdr.h (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_hdr.h Wed Jul 10 18:20:19 2013
@@ -0,0 +1,125 @@
+/*
+ *
+ * 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
+ */
+
+#ifndef QPID_LEGACYSTORE_JRNL_TXN_HDR_H
+#define QPID_LEGACYSTORE_JRNL_TXN_HDR_H
+
+#include <cstddef>
+#include "qpid/legacystore/jrnl/rec_hdr.h"
+
+namespace mrg
+{
+namespace journal
+{
+
+#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.
+    */
+    struct txn_hdr : rec_hdr
+    {
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+        u_int32_t _filler0;     ///< Big-endian filler for 32-bit size_t
+#endif
+        std::size_t _xidsize;        ///< XID size
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+        u_int32_t _filler0;     ///< Little-endian filler for 32-bit size_t
+#endif
+
+        /**
+        * \brief Default constructor, which sets all values to 0.
+        */
+        txn_hdr(): rec_hdr(),
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+            _filler0(0),
+#endif
+            _xidsize(0)
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+            , _filler0(0)
+#endif
+        {}
+
+        /**
+        * \brief Convenience constructor which initializes values during construction.
+        */
+        txn_hdr(const u_int32_t magic, const u_int8_t version, const u_int64_t rid,
+                const std::size_t xidsize, const bool owi): rec_hdr(magic, version, rid, owi),
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+            _filler0(0),
+#endif
+            _xidsize(xidsize)
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+            , _filler0(0)
+#endif
+        {}
+
+        /**
+        * \brief Returns the size of the header in bytes.
+        */
+        inline static std::size_t size() { return sizeof(txn_hdr); }
+    };
+
+#pragma pack()
+
+} // namespace journal
+} // namespace mrg
+
+#endif // ifndef QPID_LEGACYSTORE_JRNL_TXN_HDR_H

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

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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.cpp?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.cpp (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.cpp Wed Jul 10 18:20:19 2013
@@ -0,0 +1,256 @@
+/*
+ *
+ * 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_map.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * File containing code for class mrg::journal::txn_map (transaction map). See
+ * comments in file txn_map.h for details.
+ *
+ * \author Kim van der Riet
+ */
+
+#include "qpid/legacystore/jrnl/txn_map.h"
+
+#include <iomanip>
+#include "qpid/legacystore/jrnl/jerrno.h"
+#include "qpid/legacystore/jrnl/jexception.h"
+#include "qpid/legacystore/jrnl/slock.h"
+#include <sstream>
+
+namespace mrg
+{
+namespace journal
+{
+
+// return/error codes
+int16_t txn_map::TMAP_RID_NOT_FOUND = -2;
+int16_t txn_map::TMAP_XID_NOT_FOUND = -1;
+int16_t txn_map::TMAP_OK = 0;
+int16_t txn_map::TMAP_NOT_SYNCED = 0;
+int16_t txn_map::TMAP_SYNCED = 1;
+
+txn_data_struct::txn_data_struct(const u_int64_t rid, const u_int64_t drid, const u_int16_t pfid,
+		const bool enq_flag, const bool commit_flag):
+        _rid(rid),
+        _drid(drid),
+        _pfid(pfid),
+        _enq_flag(enq_flag),
+        _commit_flag(commit_flag),
+        _aio_compl(false)
+{}
+
+txn_map::txn_map():
+        _map(),
+        _pfid_txn_cnt()
+{}
+
+txn_map::~txn_map() {}
+
+void
+txn_map::set_num_jfiles(const u_int16_t num_jfiles)
+{
+    _pfid_txn_cnt.resize(num_jfiles, 0);
+}
+
+u_int32_t
+txn_map::get_txn_pfid_cnt(const u_int16_t pfid) const
+{
+    return _pfid_txn_cnt.at(pfid);
+}
+
+bool
+txn_map::insert_txn_data(const std::string& xid, const txn_data& td)
+{
+    bool ok = true;
+    slock s(_mutex);
+    xmap_itr itr = _map.find(xid);
+    if (itr == _map.end()) // not found in map
+    {
+        txn_data_list list;
+        list.push_back(td);
+        std::pair<xmap_itr, bool> ret = _map.insert(xmap_param(xid, list));
+        if (!ret.second) // duplicate
+            ok = false;
+    }
+    else
+        itr->second.push_back(td);
+    _pfid_txn_cnt.at(td._pfid)++;
+    return ok;
+}
+
+const txn_data_list
+txn_map::get_tdata_list(const std::string& xid)
+{
+    slock s(_mutex);
+    return get_tdata_list_nolock(xid);
+}
+
+const txn_data_list
+txn_map::get_tdata_list_nolock(const std::string& xid)
+{
+    xmap_itr itr = _map.find(xid);
+    if (itr == _map.end()) // not found in map
+        return _empty_data_list;
+    return itr->second;
+}
+
+const txn_data_list
+txn_map::get_remove_tdata_list(const std::string& xid)
+{
+    slock s(_mutex);
+    xmap_itr itr = _map.find(xid);
+    if (itr == _map.end()) // not found in map
+        return _empty_data_list;
+    txn_data_list list = itr->second;
+    _map.erase(itr);
+    for (tdl_itr i=list.begin(); i!=list.end(); i++)
+        _pfid_txn_cnt.at(i->_pfid)--;
+    return list;
+}
+
+bool
+txn_map::in_map(const std::string& xid)
+{
+    slock s(_mutex);
+    xmap_itr itr= _map.find(xid);
+    return itr != _map.end();
+}
+
+u_int32_t
+txn_map::enq_cnt()
+{
+    return cnt(true);
+}
+
+u_int32_t
+txn_map::deq_cnt()
+{
+    return cnt(true);
+}
+
+u_int32_t
+txn_map::cnt(const bool enq_flag)
+{
+    slock s(_mutex);
+    u_int32_t c = 0;
+    for (xmap_itr i = _map.begin(); i != _map.end(); i++)
+    {
+        for (tdl_itr j = i->second.begin(); j < i->second.end(); j++)
+        {
+            if (j->_enq_flag == enq_flag)
+                c++;
+        }
+    }
+    return c;
+}
+
+int16_t
+txn_map::is_txn_synced(const std::string& xid)
+{
+    slock s(_mutex);
+    xmap_itr itr = _map.find(xid);
+    if (itr == _map.end()) // not found in map
+        return TMAP_XID_NOT_FOUND;
+    bool is_synced = true;
+    for (tdl_itr litr = itr->second.begin(); litr < itr->second.end(); litr++)
+    {
+        if (!litr->_aio_compl)
+        {
+            is_synced = false;
+            break;
+        }
+    }
+    return is_synced ? TMAP_SYNCED : TMAP_NOT_SYNCED;
+}
+
+int16_t
+txn_map::set_aio_compl(const std::string& xid, const u_int64_t rid)
+{
+    slock s(_mutex);
+    xmap_itr itr = _map.find(xid);
+    if (itr == _map.end()) // xid not found in map
+        return TMAP_XID_NOT_FOUND;
+    for (tdl_itr litr = itr->second.begin(); litr < itr->second.end(); litr++)
+    {
+        if (litr->_rid == rid)
+        {
+            litr->_aio_compl = true;
+            return TMAP_OK; // rid found
+        }
+    }
+    // xid present, but rid not found
+    return TMAP_RID_NOT_FOUND;
+}
+
+bool
+txn_map::data_exists(const std::string& xid, const u_int64_t rid)
+{
+    bool found = false;
+    {
+        slock s(_mutex);
+        txn_data_list tdl = get_tdata_list_nolock(xid);
+        tdl_itr itr = tdl.begin();
+        while (itr != tdl.end() && !found)
+        {
+            found = itr->_rid == rid;
+            itr++;
+        }
+    }
+    return found;
+}
+
+bool
+txn_map::is_enq(const u_int64_t rid)
+{
+    bool found = false;
+    {
+        slock s(_mutex);
+        for (xmap_itr i = _map.begin(); i != _map.end() && !found; i++)
+        {
+            txn_data_list list = i->second;
+            for (tdl_itr j = list.begin(); j < list.end() && !found; j++)
+            {
+                if (j->_enq_flag)
+                    found = j->_rid == rid;
+                else
+                    found = j->_drid == rid;
+            }
+        }
+    }
+    return found;
+}
+
+void
+txn_map::xid_list(std::vector<std::string>& xv)
+{
+    xv.clear();
+    {
+        slock s(_mutex);
+        for (xmap_itr itr = _map.begin(); itr != _map.end(); itr++)
+            xv.push_back(itr->first);
+    }
+}
+
+} // namespace journal
+} // namespace mrg

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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.h
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.h?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.h (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.h Wed Jul 10 18:20:19 2013
@@ -0,0 +1,159 @@
+/*
+ *
+ * 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_map.h
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * File containing code for class mrg::journal::txn_map (transaction map).
+ * See class documentation for details.
+ *
+ * \author Kim van der Riet
+ */
+
+#ifndef QPID_LEGACYSTORE_JRNL_TXN_MAP_H
+#define QPID_LEGACYSTORE_JRNL_TXN_MAP_H
+
+namespace mrg
+{
+namespace journal
+{
+    class txn_map;
+}
+}
+
+#include "qpid/legacystore/jrnl/smutex.h"
+#include <map>
+#include <pthread.h>
+#include <string>
+#include <sys/types.h>
+#include <vector>
+
+namespace mrg
+{
+namespace journal
+{
+
+    /**
+    * \struct txn_data_struct
+    * \brief Struct encapsulating transaction data necessary for processing a transaction
+    *     in the journal once it is closed with either a commit or abort.
+    */
+    struct txn_data_struct
+    {
+        u_int64_t _rid;     ///< Record id for this operation
+        u_int64_t _drid;    ///< Dequeue record id for this operation
+        u_int16_t _pfid;    ///< Physical file id, to be used when transferring to emap on commit
+        bool _enq_flag;     ///< If true, enq op, otherwise deq op
+        bool _commit_flag;  ///< (2PC transactions) Records 2PC complete c/a mode
+        bool _aio_compl;    ///< Initially false, set to true when record AIO returns
+        txn_data_struct(const u_int64_t rid, const u_int64_t drid, const u_int16_t pfid,
+                const bool enq_flag, const bool commit_flag = false);
+    };
+    typedef txn_data_struct txn_data;
+    typedef std::vector<txn_data> txn_data_list;
+    typedef txn_data_list::iterator tdl_itr;
+
+    /**
+    * \class txn_map
+    * \brief Class for storing transaction data for each open (ie not committed or aborted)
+    *     xid in the store. If aborted, records are discarded; if committed, they are
+    *     transferred to the enqueue map.
+    *
+    * The data is encapsulated by struct txn_data_struct. A vector containing the information
+    * for each operation included as part of the same transaction is mapped against the
+    * xid.
+    *
+    * The aio_compl flag is set true as each AIO write operation for the enqueue or dequeue
+    * returns. Checking that all of these flags are true for a given xid is the mechanism
+    * used to determine if the transaction is syncronized (through method is_txn_synced()).
+    *
+    * On transaction commit, then each operation is handled as follows:
+    *
+    * If an enqueue (_enq_flag is true), then the rid and pfid are transferred to the enq_map.
+    * If a dequeue (_enq_flag is false), then the rid stored in the drid field is used to
+    * remove the corresponding record from the enq_map.
+    *
+    * On transaction abort, then each operation is handled as follows:
+    *
+    * If an enqueue (_enq_flag is true), then the data is simply discarded.
+    * If a dequeue (_enq_flag is false), then the lock for the corresponding enqueue in enq_map
+    * (if not a part of the same transaction) is removed, and the data discarded.
+    *
+    * <pre>
+    *   key      data
+    *
+    *   xid1 --- vector< [ rid, drid, pfid, enq_flag, commit_flag, aio_compl ] >
+    *   xid2 --- vector< [ rid, drid, pfid, enq_flag, commit_flag, aio_compl ] >
+    *   xid3 --- vector< [ rid, drid, pfid, enq_flag, commit_flag, aio_compl ] >
+    *   ...
+    * </pre>
+    */
+    class txn_map
+    {
+    public:
+        // return/error codes
+        static int16_t TMAP_RID_NOT_FOUND;
+        static int16_t TMAP_XID_NOT_FOUND;
+        static int16_t TMAP_OK;
+        static int16_t TMAP_NOT_SYNCED;
+        static int16_t TMAP_SYNCED;
+
+    private:
+        typedef std::pair<std::string, txn_data_list> xmap_param;
+        typedef std::map<std::string, txn_data_list> xmap;
+        typedef xmap::iterator xmap_itr;
+
+        xmap _map;
+        smutex _mutex;
+        std::vector<u_int32_t> _pfid_txn_cnt;
+        const txn_data_list _empty_data_list;
+
+    public:
+        txn_map();
+        virtual ~txn_map();
+
+        void set_num_jfiles(const u_int16_t num_jfiles);
+        u_int32_t get_txn_pfid_cnt(const u_int16_t pfid) const;
+        bool insert_txn_data(const std::string& xid, const txn_data& td);
+        const txn_data_list get_tdata_list(const std::string& xid);
+        const txn_data_list get_remove_tdata_list(const std::string& xid);
+        bool in_map(const std::string& xid);
+        u_int32_t enq_cnt();
+        u_int32_t deq_cnt();
+        int16_t is_txn_synced(const std::string& xid); // -1=xid not found; 0=not synced; 1=synced
+        int16_t set_aio_compl(const std::string& xid, const u_int64_t rid); // -2=rid not found; -1=xid not found; 0=done
+        bool data_exists(const std::string& xid, const u_int64_t rid);
+        bool is_enq(const u_int64_t rid);
+        inline void clear() { _map.clear(); }
+        inline bool empty() const { return _map.empty(); }
+        inline size_t size() const { return _map.size(); }
+        void xid_list(std::vector<std::string>& xv);
+    private:
+        u_int32_t cnt(const bool enq_flag);
+        const txn_data_list get_tdata_list_nolock(const std::string& xid);
+    };
+
+} // namespace journal
+} // namespace mrg
+
+#endif // ifndef QPID_LEGACYSTORE_JRNL_TXN_MAP_H

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

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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.cpp?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.cpp (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.cpp Wed Jul 10 18:20:19 2013
@@ -0,0 +1,447 @@
+/*
+ *
+ * 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_rec.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains the code for the mrg::journal::txn_rec (journal dequeue
+ * record) class. See comments in file txn_rec.h for details.
+ *
+ * \author Kim van der Riet
+ */
+
+#include "qpid/legacystore/jrnl/txn_rec.h"
+
+#include <cassert>
+#include <cerrno>
+#include <cstdlib>
+#include <cstring>
+#include <iomanip>
+#include "qpid/legacystore/jrnl/jerrno.h"
+#include "qpid/legacystore/jrnl/jexception.h"
+#include <sstream>
+
+namespace mrg
+{
+namespace journal
+{
+
+txn_rec::txn_rec():
+        _txn_hdr(),
+        _xidp(0),
+        _buff(0),
+        _txn_tail()
+{
+    _txn_hdr._version = RHM_JDAT_VERSION;
+}
+
+txn_rec::txn_rec(const u_int32_t magic, const u_int64_t rid, const void* const xidp,
+        const std::size_t xidlen, const bool owi):
+        _txn_hdr(magic, RHM_JDAT_VERSION, rid, xidlen, owi),
+        _xidp(xidp),
+        _buff(0),
+        _txn_tail(_txn_hdr)
+{}
+
+txn_rec::~txn_rec()
+{
+    clean();
+}
+
+void
+txn_rec::reset(const u_int32_t magic)
+{
+    _txn_hdr._magic = magic;
+    _txn_hdr._rid = 0;
+    _txn_hdr._xidsize = 0;
+    _xidp = 0;
+    _buff = 0;
+    _txn_tail._xmagic = ~magic;
+    _txn_tail._rid = 0;
+}
+
+void
+txn_rec::reset(const u_int32_t magic, const  u_int64_t rid, const void* const xidp,
+        const std::size_t xidlen, const bool owi)
+{
+    _txn_hdr._magic = magic;
+    _txn_hdr._rid = rid;
+    _txn_hdr.set_owi(owi);
+    _txn_hdr._xidsize = xidlen;
+    _xidp = xidp;
+    _buff = 0;
+    _txn_tail._xmagic = ~magic;
+    _txn_tail._rid = rid;
+}
+
+u_int32_t
+txn_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
+{
+    assert(wptr != 0);
+    assert(max_size_dblks > 0);
+    assert(_xidp != 0 && _txn_hdr._xidsize > 0);
+
+    std::size_t rec_offs = rec_offs_dblks * JRNL_DBLK_SIZE;
+    std::size_t rem = max_size_dblks * JRNL_DBLK_SIZE;
+    std::size_t wr_cnt = 0;
+    if (rec_offs_dblks) // Continuation of split dequeue record (over 2 or more pages)
+    {
+        if (size_dblks(rec_size()) - rec_offs_dblks > max_size_dblks) // Further split required
+        {
+            rec_offs -= sizeof(_txn_hdr);
+            std::size_t wsize = _txn_hdr._xidsize > rec_offs ? _txn_hdr._xidsize - rec_offs : 0;
+            std::size_t wsize2 = wsize;
+            if (wsize)
+            {
+                if (wsize > rem)
+                    wsize = rem;
+                std::memcpy(wptr, (const char*)_xidp + rec_offs, wsize);
+                wr_cnt += wsize;
+                rem -= wsize;
+            }
+            rec_offs -= _txn_hdr._xidsize - wsize2;
+            if (rem)
+            {
+                wsize = sizeof(_txn_tail) > rec_offs ? sizeof(_txn_tail) - rec_offs : 0;
+                wsize2 = wsize;
+                if (wsize)
+                {
+                    if (wsize > rem)
+                        wsize = rem;
+                    std::memcpy((char*)wptr + wr_cnt, (char*)&_txn_tail + rec_offs, wsize);
+                    wr_cnt += wsize;
+                    rem -= wsize;
+                }
+                rec_offs -= sizeof(_txn_tail) - wsize2;
+            }
+            assert(rem == 0);
+            assert(rec_offs == 0);
+        }
+        else // No further split required
+        {
+            rec_offs -= sizeof(_txn_hdr);
+            std::size_t wsize = _txn_hdr._xidsize > rec_offs ? _txn_hdr._xidsize - rec_offs : 0;
+            if (wsize)
+            {
+                std::memcpy(wptr, (const char*)_xidp + rec_offs, wsize);
+                wr_cnt += wsize;
+            }
+            rec_offs -= _txn_hdr._xidsize - wsize;
+            wsize = sizeof(_txn_tail) > rec_offs ? sizeof(_txn_tail) - rec_offs : 0;
+            if (wsize)
+            {
+                std::memcpy((char*)wptr + wr_cnt, (char*)&_txn_tail + rec_offs, wsize);
+                wr_cnt += wsize;
+#ifdef RHM_CLEAN
+                std::size_t rec_offs = rec_offs_dblks * JRNL_DBLK_SIZE;
+                std::size_t dblk_rec_size = size_dblks(rec_size() - rec_offs) * JRNL_DBLK_SIZE;
+                std::memset((char*)wptr + wr_cnt, RHM_CLEAN_CHAR, dblk_rec_size - wr_cnt);
+#endif
+            }
+            rec_offs -= sizeof(_txn_tail) - wsize;
+            assert(rec_offs == 0);
+        }
+    }
+    else // Start at beginning of data record
+    {
+        // Assumption: the header will always fit into the first dblk
+        std::memcpy(wptr, (void*)&_txn_hdr, sizeof(_txn_hdr));
+        wr_cnt = sizeof(_txn_hdr);
+        if (size_dblks(rec_size()) > max_size_dblks) // Split required
+        {
+            std::size_t wsize;
+            rem -= sizeof(_txn_hdr);
+            if (rem)
+            {
+                wsize = rem >= _txn_hdr._xidsize ? _txn_hdr._xidsize : rem;
+                std::memcpy((char*)wptr + wr_cnt, _xidp, wsize);
+                wr_cnt += wsize;
+                rem -= wsize;
+            }
+            if (rem)
+            {
+                wsize = rem >= sizeof(_txn_tail) ? sizeof(_txn_tail) : rem;
+                std::memcpy((char*)wptr + wr_cnt, (void*)&_txn_tail, wsize);
+                wr_cnt += wsize;
+                rem -= wsize;
+            }
+            assert(rem == 0);
+        }
+        else // No split required
+        {
+            std::memcpy((char*)wptr + wr_cnt, _xidp, _txn_hdr._xidsize);
+            wr_cnt += _txn_hdr._xidsize;
+            std::memcpy((char*)wptr + wr_cnt, (void*)&_txn_tail, sizeof(_txn_tail));
+            wr_cnt += sizeof(_txn_tail);
+#ifdef RHM_CLEAN
+            std::size_t dblk_rec_size = size_dblks(rec_size()) * JRNL_DBLK_SIZE;
+            std::memset((char*)wptr + wr_cnt, RHM_CLEAN_CHAR, dblk_rec_size - wr_cnt);
+#endif
+        }
+    }
+    return size_dblks(wr_cnt);
+}
+
+u_int32_t
+txn_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
+{
+    assert(rptr != 0);
+    assert(max_size_dblks > 0);
+
+    std::size_t rd_cnt = 0;
+    if (rec_offs_dblks) // Continuation of record on new page
+    {
+        const u_int32_t hdr_xid_dblks = size_dblks(txn_hdr::size() + _txn_hdr._xidsize);
+        const u_int32_t hdr_xid_tail_dblks = size_dblks(txn_hdr::size() +  _txn_hdr._xidsize +
+                rec_tail::size());
+        const std::size_t rec_offs = rec_offs_dblks * JRNL_DBLK_SIZE;
+
+        if (hdr_xid_tail_dblks - rec_offs_dblks <= max_size_dblks)
+        {
+            // Remainder of xid fits within this page
+            if (rec_offs - txn_hdr::size() < _txn_hdr._xidsize)
+            {
+                // Part of xid still outstanding, copy remainder of xid and tail
+                const std::size_t xid_offs = rec_offs - txn_hdr::size();
+                const std::size_t xid_rem = _txn_hdr._xidsize - xid_offs;
+                std::memcpy((char*)_buff + xid_offs, rptr, xid_rem);
+                rd_cnt = xid_rem;
+                std::memcpy((void*)&_txn_tail, ((char*)rptr + rd_cnt), sizeof(_txn_tail));
+                chk_tail();
+                rd_cnt += sizeof(_txn_tail);
+            }
+            else
+            {
+                // Tail or part of tail only outstanding, complete tail
+                const std::size_t tail_offs = rec_offs - txn_hdr::size() - _txn_hdr._xidsize;
+                const std::size_t tail_rem = rec_tail::size() - tail_offs;
+                std::memcpy((char*)&_txn_tail + tail_offs, rptr, tail_rem);
+                chk_tail();
+                rd_cnt = tail_rem;
+            }
+        }
+        else if (hdr_xid_dblks - rec_offs_dblks <= max_size_dblks)
+        {
+            // Remainder of xid fits within this page, tail split
+            const std::size_t xid_offs = rec_offs - txn_hdr::size();
+            const std::size_t xid_rem = _txn_hdr._xidsize - xid_offs;
+            std::memcpy((char*)_buff + xid_offs, rptr, xid_rem);
+            rd_cnt += xid_rem;
+            const std::size_t tail_rem = (max_size_dblks * JRNL_DBLK_SIZE) - rd_cnt;
+            if (tail_rem)
+            {
+                std::memcpy((void*)&_txn_tail, ((char*)rptr + xid_rem), tail_rem);
+                rd_cnt += tail_rem;
+            }
+        }
+        else
+        {
+            // Remainder of xid split
+            const std::size_t xid_cp_size = (max_size_dblks * JRNL_DBLK_SIZE);
+            std::memcpy((char*)_buff + rec_offs - txn_hdr::size(), rptr, xid_cp_size);
+            rd_cnt += xid_cp_size;
+        }
+    }
+    else // Start of record
+    {
+        // Get and check header
+        _txn_hdr.hdr_copy(h);
+        rd_cnt = sizeof(rec_hdr);
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+        rd_cnt += sizeof(u_int32_t); // Filler 0
+#endif
+        _txn_hdr._xidsize = *(std::size_t*)((char*)rptr + rd_cnt);
+        rd_cnt = _txn_hdr.size();
+        chk_hdr();
+        _buff = std::malloc(_txn_hdr._xidsize);
+        MALLOC_CHK(_buff, "_buff", "txn_rec", "decode");
+        const u_int32_t hdr_xid_dblks = size_dblks(txn_hdr::size() + _txn_hdr._xidsize);
+        const u_int32_t hdr_xid_tail_dblks = size_dblks(txn_hdr::size() + _txn_hdr._xidsize +
+                rec_tail::size());
+
+        // Check if record (header + xid + tail) fits within this page, we can check the
+        // tail before the expense of copying data to memory
+        if (hdr_xid_tail_dblks <= max_size_dblks)
+        {
+            // Entire header, xid and tail fits within this page
+            std::memcpy(_buff, (char*)rptr + rd_cnt, _txn_hdr._xidsize);
+            rd_cnt += _txn_hdr._xidsize;
+            std::memcpy((void*)&_txn_tail, (char*)rptr + rd_cnt, sizeof(_txn_tail));
+            rd_cnt += sizeof(_txn_tail);
+            chk_tail();
+        }
+        else if (hdr_xid_dblks <= max_size_dblks)
+        {
+            // Entire header and xid fit within this page, tail split
+            std::memcpy(_buff, (char*)rptr + rd_cnt, _txn_hdr._xidsize);
+            rd_cnt += _txn_hdr._xidsize;
+            const std::size_t tail_rem = (max_size_dblks * JRNL_DBLK_SIZE) - rd_cnt;
+            if (tail_rem)
+            {
+                std::memcpy((void*)&_txn_tail, (char*)rptr + rd_cnt, tail_rem);
+                rd_cnt += tail_rem;
+            }
+        }
+        else
+        {
+            // Header fits within this page, xid split
+            const std::size_t xid_cp_size = (max_size_dblks * JRNL_DBLK_SIZE) - rd_cnt;
+            std::memcpy(_buff, (char*)rptr + rd_cnt, xid_cp_size);
+            rd_cnt += xid_cp_size;
+        }
+    }
+    return size_dblks(rd_cnt);
+}
+
+bool
+txn_rec::rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs)
+{
+    if (rec_offs == 0)
+    {
+        // Read header, allocate for xid
+        _txn_hdr.hdr_copy(h);
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+        ifsp->ignore(sizeof(u_int32_t)); // _filler0
+#endif
+        ifsp->read((char*)&_txn_hdr._xidsize, sizeof(std::size_t));
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+        ifsp->ignore(sizeof(u_int32_t)); // _filler0
+#endif
+        rec_offs = sizeof(_txn_hdr);
+        _buff = std::malloc(_txn_hdr._xidsize);
+        MALLOC_CHK(_buff, "_buff", "txn_rec", "rcv_decode");
+    }
+    if (rec_offs < sizeof(_txn_hdr) + _txn_hdr._xidsize)
+    {
+        // Read xid (or continue reading xid)
+        std::size_t offs = rec_offs - sizeof(_txn_hdr);
+        ifsp->read((char*)_buff + offs, _txn_hdr._xidsize - offs);
+        std::size_t size_read = ifsp->gcount();
+        rec_offs += size_read;
+        if (size_read < _txn_hdr._xidsize - offs)
+        {
+            assert(ifsp->eof());
+            // As we may have read past eof, turn off fail bit
+            ifsp->clear(ifsp->rdstate()&(~std::ifstream::failbit));
+            assert(!ifsp->fail() && !ifsp->bad());
+            return false;
+        }
+    }
+    if (rec_offs < sizeof(_txn_hdr) + _txn_hdr._xidsize + sizeof(rec_tail))
+    {
+        // Read tail (or continue reading tail)
+        std::size_t offs = rec_offs - sizeof(_txn_hdr) - _txn_hdr._xidsize;
+        ifsp->read((char*)&_txn_tail + offs, sizeof(rec_tail) - offs);
+        std::size_t size_read = ifsp->gcount();
+        rec_offs += size_read;
+        if (size_read < sizeof(rec_tail) - offs)
+        {
+            assert(ifsp->eof());
+            // As we may have read past eof, turn off fail bit
+            ifsp->clear(ifsp->rdstate()&(~std::ifstream::failbit));
+            assert(!ifsp->fail() && !ifsp->bad());
+            return false;
+        }
+    }
+    ifsp->ignore(rec_size_dblks() * JRNL_DBLK_SIZE - rec_size());
+    chk_tail(); // Throws if tail invalid or record incomplete
+    assert(!ifsp->fail() && !ifsp->bad());
+    return true;
+}
+
+std::size_t
+txn_rec::get_xid(void** const xidpp)
+{
+    if (!_buff)
+    {
+        *xidpp = 0;
+        return 0;
+    }
+    *xidpp = _buff;
+    return _txn_hdr._xidsize;
+}
+
+std::string&
+txn_rec::str(std::string& str) const
+{
+    std::ostringstream oss;
+    if (_txn_hdr._magic == RHM_JDAT_TXA_MAGIC)
+        oss << "dtxa_rec: m=" << _txn_hdr._magic;
+    else
+        oss << "dtxc_rec: m=" << _txn_hdr._magic;
+    oss << " v=" << (int)_txn_hdr._version;
+    oss << " rid=" << _txn_hdr._rid;
+    oss << " xid=\"" << _xidp << "\"";
+    str.append(oss.str());
+    return str;
+}
+
+std::size_t
+txn_rec::xid_size() const
+{
+    return _txn_hdr._xidsize;
+}
+
+std::size_t
+txn_rec::rec_size() const
+{
+    return txn_hdr::size() + _txn_hdr._xidsize + rec_tail::size();
+}
+
+void
+txn_rec::chk_hdr() const
+{
+    jrec::chk_hdr(_txn_hdr);
+    if (_txn_hdr._magic != RHM_JDAT_TXA_MAGIC && _txn_hdr._magic != RHM_JDAT_TXC_MAGIC)
+    {
+        std::ostringstream oss;
+        oss << std::hex << std::setfill('0');
+        oss << "dtx magic: rid=0x" << std::setw(16) << _txn_hdr._rid;
+        oss << ": expected=(0x" << std::setw(8) << RHM_JDAT_TXA_MAGIC;
+        oss << " or 0x" << RHM_JDAT_TXC_MAGIC;
+        oss << ") read=0x" << std::setw(2) << (int)_txn_hdr._magic;
+        throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "txn_rec", "chk_hdr");
+    }
+}
+
+void
+txn_rec::chk_hdr(u_int64_t rid) const
+{
+    chk_hdr();
+    jrec::chk_rid(_txn_hdr, rid);
+}
+
+void
+txn_rec::chk_tail() const
+{
+    jrec::chk_tail(_txn_tail, _txn_hdr);
+}
+
+void
+txn_rec::clean()
+{
+    // clean up allocated memory here
+}
+
+} // namespace journal
+} // namespace mrg

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

Added: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.h
URL: http://svn.apache.org/viewvc/qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.h?rev=1501895&view=auto
==============================================================================
--- qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.h (added)
+++ qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.h Wed Jul 10 18:20:19 2013
@@ -0,0 +1,101 @@
+/*
+ *
+ * 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_rec.h
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains the code for the mrg::journal::txn_rec (journal data
+ * record) class. See class documentation for details.
+ *
+ * \author Kim van der Riet
+ */
+
+#ifndef QPID_LEGACYSTORE_JRNL_TXN_REC_H
+#define QPID_LEGACYSTORE_JRNL_TXN_REC_H
+
+namespace mrg
+{
+namespace journal
+{
+class txn_rec;
+}
+}
+
+#include <cstddef>
+#include "qpid/legacystore/jrnl/jrec.h"
+#include "qpid/legacystore/jrnl/txn_hdr.h"
+
+namespace mrg
+{
+namespace journal
+{
+
+    /**
+    * \class txn_rec
+    * \brief Class to handle a single journal DTX commit or abort record.
+    */
+    class txn_rec : public jrec
+    {
+    private:
+        txn_hdr _txn_hdr;       ///< transaction header
+        const void* _xidp;      ///< xid pointer for encoding (writing to disk)
+        void* _buff;            ///< Pointer to buffer to receive data read from disk
+        rec_tail _txn_tail;     ///< Record tail
+
+    public:
+        // constructor used for read operations and xid must have memory allocated
+        txn_rec();
+        // constructor used for write operations, where xid already exists
+        txn_rec(const u_int32_t magic, const u_int64_t rid, const void* const xidp,
+                const std::size_t xidlen, const bool owi);
+        virtual ~txn_rec();
+
+        // Prepare instance for use in reading data from journal
+        void reset(const u_int32_t magic);
+        // Prepare instance for use in writing data to journal
+        void reset(const u_int32_t magic, const  u_int64_t rid, const void* const xidp,
+                const std::size_t xidlen, const bool owi);
+        u_int32_t encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks);
+        u_int32_t decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks,
+                u_int32_t max_size_dblks);
+        // Decode used for recover
+        bool rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs);
+
+        std::size_t get_xid(void** const xidpp);
+        std::string& str(std::string& str) const;
+        inline std::size_t data_size() const { return 0; } // This record never carries data
+        std::size_t xid_size() const;
+        std::size_t rec_size() const;
+        inline u_int64_t rid() const { return _txn_hdr._rid; }
+
+    private:
+        void chk_hdr() const;
+        void chk_hdr(u_int64_t rid) const;
+        void chk_tail() const;
+        virtual void clean();
+    }; // class txn_rec
+
+} // namespace journal
+} // namespace mrg
+
+#endif // ifndef QPID_LEGACYSTORE_JRNL_TXN_REC_H

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

Propchange: qpid/branches/linearstore/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.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