0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
OperationStatus.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #include <Common/Compat.h>
23 
24 #include "OperationStatus.h"
25 #include "Utility.h"
26 
27 #include <Common/Error.h>
28 #include <Common/Serialization.h>
29 #include <Common/Status.h>
30 #include <Common/StatusPersister.h>
31 #include <Common/StringExt.h>
32 
33 using namespace Hypertable;
34 using namespace Hypertable::Lib::Master;
35 
37  : OperationEphemeral(context, event, MetaLog::EntityType::OPERATION_STATUS) {
38  HT_INFOF("Status-%lld", (Lld)header.id);
39 }
40 
42  Status status;
43  Timer timer(m_event->header.timeout_ms, true);
44  Utility::status(m_context, timer, status);
45  m_params.set_status(status);
46  complete_ok();
47 }
48 
50  return "OperationStatus";
51 }
52 
54  return String("Status");
55 }
56 
58  return 4 + m_params.encoded_length();
59 }
60 
74 void OperationStatus::encode_result(uint8_t **bufp) const {
76  m_params.encode(bufp);
77 }
const String name() override
Name of operation used for exclusivity.
ContextPtr m_context
Pointer to Master context.
Definition: Operation.h:553
Holds Nagios-style program status information.
Definition: Status.h:42
Abstract base class for ephemeral operations.
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
Declarations for Status.
virtual size_t encoded_length() const
Returns serialized object length.
Definition: Serializable.cc:37
int64_t id
Unique ID of entity.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
EntityHeader header
Entity header
EventPtr m_event
Pointer to client event (if any) that originated the operation.
Definition: Operation.h:556
OperationStatus(ContextPtr &context, EventPtr &event)
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
Definition: Context.h:265
virtual void encode(uint8_t **bufp) const
Writes serialized representation of object to a buffer.
Definition: Serializable.cc:64
bool status(ContextPtr &context, Timer &timer, Status &status)
Runs a status check on the master.
Definition: Utility.cc:408
void encode_i32(uint8_t **bufp, uint32_t val)
Encode a 32-bit integer in little-endian order.
Compatibility Macros for C/C++.
void set_status(const Hypertable::Status &status)
Sets status object.
Definition: Status.h:64
Functions to serialize/deserialize primitives to/from a memory buffer.
size_t encoded_result_length() const override
Length of encoded operation result.
Hypertable definitions
long long int Lld
Shortcut for printf formats.
Definition: String.h:53
Declarations for general-purpose utility functions.
void encode_result(uint8_t **bufp) const override
Encode operation result.
Response::Parameters::Status m_params
#define HT_INFOF(msg,...)
Definition: Logger.h:272
A timer class to keep timeout states across AsyncComm related calls.
Definition: Timer.h:44
Declarations for StatusPersister.
const String label() override
Human readable label for operation.
void execute() override
Executes (carries out) the operation.
void complete_ok(std::vector< MetaLog::EntityPtr > &additional)
Definition: Operation.cc:436
String extensions and helpers: sets, maps, append operators etc.
Error codes, Exception handling, error logging.