1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under both the GPLv2 (found in the
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
#include <climits>
#include <cstdint>
#include <iostream>
#include <utility>
#include "include/org_rocksdb_test_TestableEventListener.h"
#include "rocksdb/listener.h"
#include "rocksdb/status.h"
#include "rocksdb/table_properties.h"
using ROCKSDB_NAMESPACE::BackgroundErrorReason;
using ROCKSDB_NAMESPACE::CompactionJobInfo;
using ROCKSDB_NAMESPACE::CompactionJobStats;
using ROCKSDB_NAMESPACE::CompactionReason;
using ROCKSDB_NAMESPACE::CompressionType;
using ROCKSDB_NAMESPACE::ExternalFileIngestionInfo;
using ROCKSDB_NAMESPACE::FileOperationInfo;
using ROCKSDB_NAMESPACE::FileOperationType;
using ROCKSDB_NAMESPACE::FlushJobInfo;
using ROCKSDB_NAMESPACE::FlushReason;
using ROCKSDB_NAMESPACE::MemTableInfo;
using ROCKSDB_NAMESPACE::Status;
using ROCKSDB_NAMESPACE::TableFileCreationBriefInfo;
using ROCKSDB_NAMESPACE::TableFileCreationInfo;
using ROCKSDB_NAMESPACE::TableFileCreationReason;
using ROCKSDB_NAMESPACE::TableFileDeletionInfo;
using ROCKSDB_NAMESPACE::TableProperties;
using ROCKSDB_NAMESPACE::WriteStallCondition;
using ROCKSDB_NAMESPACE::WriteStallInfo;
static TableProperties newTablePropertiesForTest() {
TableProperties table_properties;
table_properties.data_size = UINT64_MAX;
table_properties.index_size = UINT64_MAX;
table_properties.index_partitions = UINT64_MAX;
table_properties.top_level_index_size = UINT64_MAX;
table_properties.index_key_is_user_key = UINT64_MAX;
table_properties.index_value_is_delta_encoded = UINT64_MAX;
table_properties.filter_size = UINT64_MAX;
table_properties.raw_key_size = UINT64_MAX;
table_properties.raw_value_size = UINT64_MAX;
table_properties.num_data_blocks = UINT64_MAX;
table_properties.num_entries = UINT64_MAX;
table_properties.num_deletions = UINT64_MAX;
table_properties.num_merge_operands = UINT64_MAX;
table_properties.num_range_deletions = UINT64_MAX;
table_properties.format_version = UINT64_MAX;
table_properties.fixed_key_len = UINT64_MAX;
table_properties.column_family_id = UINT64_MAX;
table_properties.creation_time = UINT64_MAX;
table_properties.oldest_key_time = UINT64_MAX;
table_properties.file_creation_time = UINT64_MAX;
table_properties.slow_compression_estimated_data_size = UINT64_MAX;
table_properties.fast_compression_estimated_data_size = UINT64_MAX;
table_properties.external_sst_file_global_seqno_offset = UINT64_MAX;
table_properties.db_id = "dbId";
table_properties.db_session_id = "sessionId";
table_properties.column_family_name = "columnFamilyName";
table_properties.filter_policy_name = "filterPolicyName";
table_properties.comparator_name = "comparatorName";
table_properties.merge_operator_name = "mergeOperatorName";
table_properties.prefix_extractor_name = "prefixExtractorName";
table_properties.property_collectors_names = "propertyCollectorsNames";
table_properties.compression_name = "compressionName";
table_properties.compression_options = "compressionOptions";
table_properties.user_collected_properties = {{"key", "value"}};
table_properties.readable_properties = {{"key", "value"}};
return table_properties;
}
/*
* Class: org_rocksdb_test_TestableEventListener
* Method: invokeAllCallbacks
* Signature: (J)V
*/
void Java_org_rocksdb_test_TestableEventListener_invokeAllCallbacks(
JNIEnv *, jclass, jlong jhandle) {
const auto &el =
*reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::EventListener> *>(
jhandle);
TableProperties table_properties = newTablePropertiesForTest();
FlushJobInfo flush_job_info;
flush_job_info.cf_id = INT_MAX;
flush_job_info.cf_name = "testColumnFamily";
flush_job_info.file_path = "/file/path";
flush_job_info.file_number = UINT64_MAX;
flush_job_info.oldest_blob_file_number = UINT64_MAX;
flush_job_info.thread_id = UINT64_MAX;
flush_job_info.job_id = INT_MAX;
flush_job_info.triggered_writes_slowdown = true;
flush_job_info.triggered_writes_stop = true;
flush_job_info.smallest_seqno = UINT64_MAX;
flush_job_info.largest_seqno = UINT64_MAX;
flush_job_info.table_properties = table_properties;
flush_job_info.flush_reason = FlushReason::kManualFlush;
el->OnFlushCompleted(nullptr, flush_job_info);
el->OnFlushBegin(nullptr, flush_job_info);
Status status = Status::Incomplete(Status::SubCode::kNoSpace);
TableFileDeletionInfo file_deletion_info;
file_deletion_info.db_name = "dbName";
file_deletion_info.file_path = "/file/path";
file_deletion_info.job_id = INT_MAX;
file_deletion_info.status = status;
el->OnTableFileDeleted(file_deletion_info);
CompactionJobInfo compaction_job_info;
compaction_job_info.cf_id = UINT32_MAX;
compaction_job_info.cf_name = "compactionColumnFamily";
compaction_job_info.status = status;
compaction_job_info.thread_id = UINT64_MAX;
compaction_job_info.job_id = INT_MAX;
compaction_job_info.base_input_level = INT_MAX;
compaction_job_info.output_level = INT_MAX;
compaction_job_info.input_files = {"inputFile.sst"};
compaction_job_info.input_file_infos = {};
compaction_job_info.output_files = {"outputFile.sst"};
compaction_job_info.output_file_infos = {};
compaction_job_info.table_properties = {
{"tableProperties", std::shared_ptr<TableProperties>(
&table_properties, [](TableProperties *) {})}};
compaction_job_info.compaction_reason = CompactionReason::kFlush;
compaction_job_info.compression = CompressionType::kSnappyCompression;
compaction_job_info.stats = CompactionJobStats();
el->OnCompactionBegin(nullptr, compaction_job_info);
el->OnCompactionCompleted(nullptr, compaction_job_info);
TableFileCreationInfo file_creation_info;
file_creation_info.file_size = UINT64_MAX;
file_creation_info.table_properties = table_properties;
file_creation_info.status = status;
file_creation_info.file_checksum = "fileChecksum";
file_creation_info.file_checksum_func_name = "fileChecksumFuncName";
file_creation_info.db_name = "dbName";
file_creation_info.cf_name = "columnFamilyName";
file_creation_info.file_path = "/file/path";
file_creation_info.job_id = INT_MAX;
file_creation_info.reason = TableFileCreationReason::kMisc;
el->OnTableFileCreated(file_creation_info);
TableFileCreationBriefInfo file_creation_brief_info;
file_creation_brief_info.db_name = "dbName";
file_creation_brief_info.cf_name = "columnFamilyName";
file_creation_brief_info.file_path = "/file/path";
file_creation_brief_info.job_id = INT_MAX;
file_creation_brief_info.reason = TableFileCreationReason::kMisc;
el->OnTableFileCreationStarted(file_creation_brief_info);
MemTableInfo mem_table_info;
mem_table_info.cf_name = "columnFamilyName";
mem_table_info.first_seqno = UINT64_MAX;
mem_table_info.earliest_seqno = UINT64_MAX;
mem_table_info.num_entries = UINT64_MAX;
mem_table_info.num_deletes = UINT64_MAX;
el->OnMemTableSealed(mem_table_info);
el->OnColumnFamilyHandleDeletionStarted(nullptr);
ExternalFileIngestionInfo file_ingestion_info;
file_ingestion_info.cf_name = "columnFamilyName";
file_ingestion_info.external_file_path = "/external/file/path";
file_ingestion_info.internal_file_path = "/internal/file/path";
file_ingestion_info.global_seqno = UINT64_MAX;
file_ingestion_info.table_properties = table_properties;
el->OnExternalFileIngested(nullptr, file_ingestion_info);
el->OnBackgroundError(BackgroundErrorReason::kFlush, &status);
WriteStallInfo write_stall_info;
write_stall_info.cf_name = "columnFamilyName";
write_stall_info.condition.cur = WriteStallCondition::kDelayed;
write_stall_info.condition.prev = WriteStallCondition::kStopped;
el->OnStallConditionsChanged(write_stall_info);
const std::string file_path = "/file/path";
const auto start_timestamp =
std::make_pair(std::chrono::time_point<std::chrono::system_clock,
std::chrono::nanoseconds>(
std::chrono::nanoseconds(1600699420000000000ll)),
std::chrono::time_point<std::chrono::steady_clock,
std::chrono::nanoseconds>(
std::chrono::nanoseconds(1600699420000000000ll)));
const auto finish_timestamp =
std::chrono::time_point<std::chrono::steady_clock,
std::chrono::nanoseconds>(
std::chrono::nanoseconds(1600699425000000000ll));
FileOperationInfo op_info =
FileOperationInfo(FileOperationType::kRead, file_path, start_timestamp,
finish_timestamp, status);
op_info.offset = UINT64_MAX;
op_info.length = SIZE_MAX;
el->OnFileReadFinish(op_info);
el->OnFileWriteFinish(op_info);
el->OnFileFlushFinish(op_info);
el->OnFileSyncFinish(op_info);
el->OnFileRangeSyncFinish(op_info);
el->OnFileTruncateFinish(op_info);
el->OnFileCloseFinish(op_info);
el->ShouldBeNotifiedOnFileIO();
bool auto_recovery;
el->OnErrorRecoveryBegin(BackgroundErrorReason::kFlush, status,
&auto_recovery);
el->OnErrorRecoveryCompleted(status);
}
|