libfoedus-core
FOEDUS Core Library
xct_access.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
19 
20 #include <ostream>
21 
23 #include "foedus/log/log_type.hpp"
25 #include "foedus/storage/page.hpp"
28 #include "foedus/xct/xct_id.hpp"
29 
30 namespace foedus {
31 namespace xct {
32 std::ostream& operator<<(std::ostream& o, const PointerAccess& v) {
33  o << "<PointerAccess><address>" << v.address_ << "</address>"
34  << "<observed>" << assorted::Hex(v.observed_.word) << "</observed></PointerAccess>";
35  return o;
36 }
37 
38 std::ostream& operator<<(std::ostream& o, const PageVersionAccess& v) {
39  o << "<PageVersionAccess><address>" << v.address_ << "</address>"
40  << "<observed>" << v.observed_ << "</observed></PageVersionAccess>";
41  return o;
42 }
43 
44 std::ostream& operator<<(std::ostream& o, const ReadXctAccess& v) {
45  o << "<ReadXctAccess><storage>" << v.storage_id_ << "</storage>"
46 // << "<current_lock_position_>" << v.current_lock_position_ << "</current_lock_position_>"
47  << "<ordinal_>" << v.ordinal_ << "</ordinal_>"
48  << "<observed_owner_id>" << v.observed_owner_id_ << "</observed_owner_id>"
49  << "<record_address>" << v.owner_id_address_ << "</record_address>"
50  << "<current_owner_id>" << *v.owner_id_address_ << "</current_owner_id>"
51  << "<owner_lock_id>" << v.owner_lock_id_ << "</owner_lock_id><log>";
52  if (v.related_write_) {
53  o << "<HasRelatedWrite />"; // does not output its content to avoid circle
54  }
55  o << "</ReadXctAccess>";
56  return o;
57 }
58 
59 std::ostream& operator<<(std::ostream& o, const WriteXctAccess& v) {
60  o << "<WriteAccess><storage>" << v.storage_id_ << "</storage>"
61  << "<record_address>" << v.owner_id_address_ << "</record_address>"
62 // << "<current_lock_position_>" << v.current_lock_position_ << "</current_lock_position_>"
63  << "<ordinal_>" << v.ordinal_ << "</ordinal_>"
64  << "<current_owner_id>" << *(v.owner_id_address_) << "</current_owner_id><log>"
65  << "<owner_lock_id>" << v.owner_lock_id_ << "</owner_lock_id><log>";
67  o << "</log>";
68  if (v.related_read_) {
69  o << "<HasRelatedRead />"; // does not output its content to avoid circle
70  }
71  o << "</WriteAccess>";
72  return o;
73 }
74 
75 std::ostream& operator<<(std::ostream& o, const LockFreeReadXctAccess& v) {
76  o << "<LockFreeReadXctAccess>"
77  << "<storage>" << v.storage_id_ << "</storage>"
78  << "<observed_owner_id>" << v.observed_owner_id_ << "</observed_owner_id>"
79  << "<record_address>" << v.owner_id_address_ << "</record_address>"
80  << "<current_owner_id>" << *v.owner_id_address_ << "</current_owner_id>";
81  o << "</LockFreeReadXctAccess>";
82  return o;
83 }
84 
85 std::ostream& operator<<(std::ostream& o, const LockFreeWriteXctAccess& v) {
86  o << "<LockFreeWriteXctAccess>"
87  << "<storage>" << v.storage_id_ << "</storage>";
89  o << "</LockFreeWriteXctAccess>";
90  return o;
91 }
92 
94  const memory::GlobalVolatilePageResolver& resolver,
95  RwLockableXctId* owner_id_address) {
96  UniversalLockId owner_lock_id = xct_id_to_universal_lock_id(resolver, owner_id_address);
97  set_owner_id_and_lock_id(owner_id_address, owner_lock_id);
98 }
99 
100 } // namespace xct
101 } // namespace foedus
ReadXctAccess * related_read_
Definition: xct_access.hpp:178
log::RecordLogType * log_entry_
Pointer to the log entry in private log buffer for this write opereation.
Definition: xct_access.hpp:175
RwLockableXctId * owner_id_address_
Pointer to the TID we protect against.
Definition: xct_access.hpp:210
std::ostream & operator<<(std::ostream &o, const LockEntry &v)
Debugging.
Represents a record of special read-access during a transaction without any need for locking...
Definition: xct_access.hpp:200
const storage::PageVersion * address_
Address to the page version.
Definition: xct_access.hpp:76
uint32_t ordinal_
Indicates the ordinal among ReadXctAccess/WriteXctAccess of this transaction.
Definition: xct_access.hpp:96
XctId observed_owner_id_
Transaction ID of the record observed as of the access.
Definition: xct_access.hpp:143
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Represents a record of write-access during a transaction.
Definition: xct_access.hpp:168
const storage::VolatilePagePointer * address_
Address of the volatile pointer.
Definition: xct_access.hpp:52
storage::VolatilePagePointer observed_
Value of the volatile pointer as of the access.
Definition: xct_access.hpp:55
storage::PageVersionStatus observed_
Value of the page version as of the access.
Definition: xct_access.hpp:79
Represents a record of read-access during a transaction.
Definition: xct_access.hpp:139
Represents a record of special write-access during a transaction without any need for locking...
Definition: xct_access.hpp:228
XctId observed_owner_id_
XID value we observed.
Definition: xct_access.hpp:204
uintptr_t UniversalLockId
Universally ordered identifier of each lock.
Definition: xct_id.hpp:134
The MCS reader-writer lock variant of LockableXctId.
Definition: xct_id.hpp:1132
UniversalLockId xct_id_to_universal_lock_id(const memory::GlobalVolatilePageResolver &resolver, RwLockableXctId *lock)
Definition: xct_id.hpp:1226
storage::StorageId storage_id_
The storage we accessed.
Definition: xct_access.hpp:207
Definitions of IDs in this package and a few related constant values.
void set_owner_id_resolve_lock_id(const memory::GlobalVolatilePageResolver &resolver, RwLockableXctId *owner_id_address)
Calculate owner_lock_id using the resolver.
Definition: xct_access.cpp:93
RwLockableXctId * owner_id_address_
Pointer to the accessed record.
Definition: xct_access.hpp:102
storage::StorageId storage_id_
The storage we accessed.
Definition: xct_access.hpp:85
WriteXctAccess * related_write_
An optional member that points to a write access related to this read.
Definition: xct_access.hpp:153
void invoke_ostream(const void *buffer, std::ostream *ptr)
Invokes the ostream operator for the given log type defined in log_type.xmacro.
Convenient way of writing hex integers to stream.
Resolves an offset in a volatile page pool to an actual pointer and vice versa.
log::RecordLogType * log_entry_
Pointer to the log entry in private log buffer for this write opereation.
Definition: xct_access.hpp:235
Represents a record of following a page pointer during a transaction.
Definition: xct_access.hpp:48
UniversalLockId owner_lock_id_
Universal Lock ID of the lock in the record.
Definition: xct_access.hpp:105
Represents a record of reading a page during a transaction.
Definition: xct_access.hpp:72
void set_owner_id_and_lock_id(RwLockableXctId *owner_id_address, UniversalLockId owner_lock_id)
Setter for owner_id_address_/owner_lock_id_.
Definition: xct_access.hpp:111
storage::StorageId storage_id_
The storage we accessed.
Definition: xct_access.hpp:232