Skip to content

Commit

Permalink
Skip over RS_METRICS entries where version != 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sjhalaz authored and Doug Judd committed Jul 13, 2011
1 parent 3531fb8 commit 7ae4fd7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
23 changes: 17 additions & 6 deletions src/cc/Hypertable/Master/RangeMetrics.cc
Expand Up @@ -24,6 +24,7 @@
#include <boost/algorithm/string.hpp>

#include "Common/Error.h"
#include "Common/Logger.h"
#include "Common/StringExt.h"

#include "Hypertable/Lib/Key.h"
Expand All @@ -43,15 +44,16 @@ void RangeMeasurement::parse_measurement(const char *measurement, size_t len) {
vector<String> splits;
String str(measurement, len);
boost::split(splits, str, boost::is_any_of(":,"));
version = atoi(splits[0].c_str());

if (version != 2)
HT_THROW(Error::NOT_IMPLEMENTED, (String) "ServerMetrics version=" + version
+ " expected 2");

if (splits.size() != 11)
HT_THROW(Error::PROTOCOL_ERROR, (String) "Measurement string '" + str
+ "' has " + (int)(splits.size()) + (String)" components, expected 11.");

version = atoi(splits[0].c_str());
if (version != 2)
HT_THROW(Error::NOT_IMPLEMENTED, (String) "ServerMetrics version=" + version
+ " expected 2");
timestamp = strtoll(splits[1].c_str(), 0, 0);
disk_used = strtoll(splits[2].c_str(), 0, 0);
memory_used = strtoll(splits[3].c_str(), 0, 0);
Expand All @@ -71,8 +73,17 @@ RangeMetrics::RangeMetrics(const char *server_id, const char *table_id,
}

void RangeMetrics::add_measurement(const char *measurement, size_t len) {
RangeMeasurement rm(measurement, len);
m_measurements.push_back(rm);
try {
RangeMeasurement rm(measurement, len);
m_measurements.push_back(rm);
}
catch (Exception &e) {
if (e.code() == Error::NOT_IMPLEMENTED) {
HT_WARN_OUT << e << HT_END;
}
else
HT_THROW(e.code(), e.what());
}
}

void RangeMetrics::set_last_move(const char *move, size_t len) {
Expand Down
23 changes: 17 additions & 6 deletions src/cc/Hypertable/Master/ServerMetrics.cc
Expand Up @@ -24,6 +24,7 @@
#include <boost/algorithm/string.hpp>

#include "Common/Error.h"
#include "Common/Logger.h"

#include "ServerMetrics.h"

Expand All @@ -40,14 +41,15 @@ void ServerMeasurement::parse_measurement(const char *measurement, size_t len) {
String str(measurement, len);
boost::split(splits, str, boost::is_any_of(":,"));

if (splits.size() != 12)
HT_THROW(Error::PROTOCOL_ERROR, (String) "Measurement string '" + str
+ "' has " + (int)(splits.size()) + (String)" components, expected 12.");

version = atoi(splits[0].c_str());
if (version != 2)
HT_THROW(Error::NOT_IMPLEMENTED, (String) "ServerMetrics version=" + version
+ " expected 2");

if (splits.size() != 12)
HT_THROW(Error::PROTOCOL_ERROR, (String) "Measurement string '" + str
+ "' has " + (int)(splits.size()) + (String)" components, expected 12.");

timestamp = strtoll(splits[1].c_str(), 0, 0);
loadavg = strtod(splits[2].c_str(), 0);
disk_bytes_read_rate = strtod(splits[3].c_str(), 0);
Expand All @@ -62,7 +64,16 @@ void ServerMeasurement::parse_measurement(const char *measurement, size_t len) {
}

void ServerMetrics::add_measurement(const char *measurement, size_t len) {
ServerMeasurement sm(measurement, len);
m_measurements.push_back(sm);
try {
ServerMeasurement sm(measurement, len);
m_measurements.push_back(sm);
}
catch (Exception &e) {
if (e.code() == Error::NOT_IMPLEMENTED) {
HT_WARN_OUT << e << HT_END;
}
else
HT_THROW(e.code(), e.what());
}
}

0 comments on commit 7ae4fd7

Please sign in to comment.