42 #include <boost/algorithm/string/predicate.hpp>
54 static void init_options() {
56 " This program dumps the given log's metadata.\n\nOptions")
58 (
"block-summary",
boo()->zero_tokens()->default_value(
false),
"Display commit log block information only")
59 (
"display-values",
boo()->zero_tokens()->default_value(
false),
"Display values (assumes they're printable)")
60 (
"linked-logs",
boo()->zero_tokens()->default_value(
false),
"Display valid (non-deleted) linked logs")
66 if (!
has(
"log-dir")) {
73 typedef Meta::list<AppPolicy, FsClientPolicy, DefaultCommPolicy>
Policies;
85 int main(
int argc,
char **argv) {
87 init_with_policies<Policies>(argc, argv);
91 String log_dir = get_str(
"log-dir");
93 int timeout = get_i32(
"dfs-timeout", 15000);
94 bool block_summary = get_bool(
"block-summary");
95 bool linked_logs = get_bool(
"linked-logs");
102 if (log_host.length()) {
103 int log_port = get_i16(
"log-port");
106 dfs_client = std::make_shared<FsBroker::Lib::Client>(conn_manager_ptr, addr, timeout);
109 dfs_client = std::make_shared<FsBroker::Lib::Client>(conn_manager_ptr,
properties);
112 if (!dfs_client->wait_for_connection(timeout)) {
113 HT_ERROR(
"Unable to connect to DFS Broker, exiting...");
119 boost::trim_right_if(log_dir, boost::is_any_of(
"/"));
124 printf(
"LOG %s\n", log_dir.c_str());
125 display_log_block_summary(dfs_client,
"", log_reader.get());
127 else if (linked_logs) {
128 display_log_valid_links(dfs_client, log_dir, log_reader.get());
131 display_log(dfs_client,
"", log_reader.get(),
has(
"display-values"));
149 const uint8_t *ptr, *end;
156 while (log_reader->
next(&base, &len, &header)) {
163 size_t len_saved = len;
165 table_id.
decode(&ptr, &len);
185 if (display_values) {
188 cout <<
" value='" << std::string((
char *)vptr, slen) <<
"'";
217 printf(
"%s/%s\tcluster_id\t%llu\n",
219 printf(
"%s/%s\trevision\t%llu\n",
221 printf(
"%s/%s\tstart-offset\t%llu\n",
223 printf(
"%s/%s\tend-offset\t%llu\n",
227 printf(
"%s/%s\tlength\t%u\n",
230 printf(
"%s/%s\tztype\t%s\n",
233 printf(
"%s/%s\tzlen\t%u\n",
238 printf(
"%s/%s\terror\t%s\n",
252 while (log_reader->
next(&base, &len, &header))
257 for (
const auto &name : linked_logs)
258 std::cout << name <<
"\n";
259 std::cout << std::flush;
std::set< String > StringSet
STL Set managing Strings.
Interface and base of config policy.
static const char MAGIC_DATA[10]
Holds information about an individual block.
PropertiesPtr properties
This singleton map stores all options.
std::string String
A String is simply a typedef to std::string.
Helper class for printing usage banners on the command line.
Declarations for CommitLogReader.
void init(int argc, char *argv[], const Desc *desc=NULL)
Initialize with default policy.
Declarations for TableIdentifier and TableIdentifierManaged.
long long unsigned int Llu
Shortcut for printf formats.
Po::typed_value< String > * str(String *v=0)
bool next_raw_block(CommitLogBlockInfo *, BlockHeaderCommitLog *)
Desc & cmdline_desc(const char *usage)
A macro which definds global functions like get_bool(), get_str(), get_i16() etc. ...
bool has(const String &name)
Check existence of a configuration value.
std::shared_ptr< CommitLogReader > CommitLogReaderPtr
Smart pointer to CommitLogReader.
A class managing one or more serializable ByteStrings.
int main(int argc, char **argv)
const char * get_text(int error)
Returns a descriptive error message.
Encapsulate an internet address.
std::shared_ptr< Client > ClientPtr
Smart pointer to Client.
int error
Error (if any) encountered while reading block
Logging routines and macros.
Compatibility Macros for C/C++.
bool load(const SerializedKey &key)
Parses the opaque key and loads the components into the member variables.
Po::typed_value< bool > * boo(bool *v=0)
Initialization helper for applications.
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
Provides sequential access to blocks in a commit log.
const uint8_t * ptr
The pointer to the serialized data.
static const char * get_compressor_name(uint16_t algo)
Returns string mnemonic for compression type.
void legacy_decode(const uint8_t **bufp, size_t *remainp, BalancePlan *plan)
Declarations for ConnectionManager.
std::shared_ptr< Filesystem > FilesystemPtr
Smart pointer to Filesystem.
size_t decode_length(const uint8_t **dptr) const
Retrieves the decoded length and returns a pointer to the string.
Provides access to internal components of opaque key.
Internet address wrapper classes and utility functions.
Meta::list< MyPolicy, DefaultPolicy > Policies
Declarations for ReactorFactory.
const char * log_dir
Log directory.
This is a generic exception class for Hypertable.
bool next(const uint8_t **blockp, size_t *lenp, BlockHeaderCommitLog *)
uint64_t start_offset
Starting offset of block within fragment file.
Declarations for CommitLog.
uint64_t end_offset
Ending offset of block within fragment file.
std::shared_ptr< ConnectionManager > ConnectionManagerPtr
Smart pointer to ConnectionManager.
void get_linked_logs(StringSet &linked_logs)
Desc & cmdline_hidden_desc()
Get the command line hidden options description (for positional options)
PositionalDesc & cmdline_positional_desc()
Get the command line positional options description.
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
uint8_t * next()
Retrieves the next serialized String in the buffer.
int code() const
Returns the error code.
const char * file_fragment
File name of log fragment within log_dir.