1/*
2 * rw_request_hash.h
3 *
4 * Copyright (C) 2016 Aerospike, Inc.
5 *
6 * Portions may be licensed to Aerospike, Inc. under one or more contributor
7 * license agreements.
8 *
9 * This program is free software: you can redistribute it and/or modify it under
10 * the terms of the GNU Affero General Public License as published by the Free
11 * Software Foundation, either version 3 of the License, or (at your option) any
12 * later version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see http://www.gnu.org/licenses/
21 */
22
23#pragma once
24
25//==========================================================
26// Includes.
27//
28
29#include <stdint.h>
30
31#include "citrusleaf/cf_digest.h"
32
33#include "base/transaction.h"
34
35
36//==========================================================
37// Forward declarations.
38//
39
40struct as_transaction_s;
41struct rw_request_s;
42
43
44//==========================================================
45// Typedefs & constants.
46//
47
48typedef enum {
49 // These values go on the wire, so mind backward compatibility if changing.
50 RW_FIELD_OP,
51 RW_FIELD_RESULT,
52 RW_FIELD_NAMESPACE,
53 RW_FIELD_NS_ID,
54 RW_FIELD_GENERATION,
55 RW_FIELD_DIGEST,
56 RW_FIELD_RECORD,
57 RW_FIELD_UNUSED_7,
58 RW_FIELD_CLUSTER_KEY,
59 RW_FIELD_OLD_RECORD, // TODO - old pickle - deprecate in "six months"
60 RW_FIELD_TID,
61 RW_FIELD_VOID_TIME, // TODO - old pickle - deprecate in "six months"
62 RW_FIELD_INFO,
63 RW_FIELD_UNUSED_13,
64 RW_FIELD_UNUSED_14,
65 RW_FIELD_UNUSED_15,
66 RW_FIELD_LAST_UPDATE_TIME,
67 RW_FIELD_SET_NAME, // TODO - old pickle - deprecate in "six months"
68 RW_FIELD_KEY, // TODO - old pickle - deprecate in "six months"
69 RW_FIELD_REGIME,
70
71 NUM_RW_FIELDS
72} rw_msg_field;
73
74#define RW_OP_WRITE 1 // TODO - old pickle - deprecate in "six months"
75#define RW_OP_WRITE_ACK 2
76#define RW_OP_DUP 3
77#define RW_OP_DUP_ACK 4
78#define RW_OP_REPL_CONFIRM 5
79#define RW_OP_REPL_PING 6
80#define RW_OP_REPL_PING_ACK 7
81#define RW_OP_REPL_WRITE 8
82
83#define RW_INFO_XDR 0x0001
84#define RW_INFO_NO_REPL_ACK 0x0002
85#define RW_INFO_UNUSED_4 0x0004 // was nsup delete
86#define RW_INFO_UNUSED_8 0x0008 // was LDT dummy (no data)
87#define RW_INFO_UNUSED_10 0x0010 // was LDT parent record
88#define RW_INFO_UNUSED_20 0x0020 // was LDT subrecord
89#define RW_INFO_UNUSED_40 0x0040 // was LDT ESR
90#define RW_INFO_SINDEX_TOUCHED 0x0080 // sindex was touched
91#define RW_INFO_UNUSED_100 0x0100 // was LDT multi-op message
92#define RW_INFO_UNREPLICATED 0x0200 // enterprise only
93#define RW_INFO_TOMBSTONE 0x0400 // enterprise only
94
95typedef struct rw_request_hkey_s {
96 uint32_t ns_id;
97 cf_digest keyd;
98} __attribute__((__packed__)) rw_request_hkey;
99
100
101//==========================================================
102// Public API.
103//
104
105void as_rw_init();
106
107uint32_t rw_request_hash_count();
108transaction_status rw_request_hash_insert(rw_request_hkey* hkey, struct rw_request_s* rw, struct as_transaction_s* tr);
109void rw_request_hash_delete(rw_request_hkey* hkey, struct rw_request_s* rw);
110struct rw_request_s* rw_request_hash_get(rw_request_hkey* hkey);
111
112void rw_request_hash_dump();
113