sync code

This commit is contained in:
Ned Wright
2024-09-17 10:53:09 +00:00
parent 3fe0b42fcd
commit 586150fe4f
143 changed files with 1886 additions and 380 deletions

View File

@@ -36,6 +36,7 @@ class I_Intelligence_IS_V2
{
public:
virtual bool sendInvalidation(const Intelligence::Invalidation &invalidation) const = 0;
virtual bool isIntelligenceHealthy() const = 0;
virtual Maybe<uint> registerInvalidation(
const Intelligence::Invalidation &invalidation,
const std::function<void(const Intelligence::Invalidation &)> &callback

View File

@@ -48,6 +48,8 @@ public:
return addRestCall(oper, uri, std::make_unique<SpecificRestInit<T>>());
}
virtual bool addGetCall(const std::string &uri, const std::function<std::string()> &callback) = 0;
virtual uint16_t getListeningPort() const = 0;
protected:

View File

@@ -24,6 +24,7 @@ public:
using Response = Intelligence::Response;
MOCK_CONST_METHOD1(sendInvalidation, bool(const Invalidation &invalidation));
MOCK_CONST_METHOD0(isIntelligenceHealthy, bool(void));
MOCK_METHOD2(registerInvalidation, Maybe<uint>(const Invalidation &invalidation, const InvalidationCb &callback));
MOCK_METHOD1(unregisterInvalidation, void(uint id));
MOCK_CONST_METHOD5(

View File

@@ -9,6 +9,7 @@ class MockRestApi : public Singleton::Provide<I_RestApi>::From<MockProvider<I_Re
{
public:
MOCK_CONST_METHOD0(getListeningPort, uint16_t());
MOCK_METHOD2(addGetCall, bool(const std::string &, const std::function<std::string()> &));
// You can't mock a function with an R-value reference. So mock a slightly different one
MOCK_METHOD3(mockRestCall, bool(RestAction, const std::string &, const std::unique_ptr<RestInit> &));

View File

@@ -34,7 +34,7 @@ DEFINE_FLAG(D_INFRA, D_ALL)
DEFINE_FLAG(D_SIGNAL_HANDLER, D_INFRA)
DEFINE_FLAG(D_TENANT_MANAGER, D_INFRA)
DEFINE_FLAG(D_MONITORING, D_INFRA)
DEFINE_FLAG(D_HEALTH_CHECK_MANAGER, D_INFRA)
DEFINE_FLAG(D_SERVICE_HEALTH_STATUS, D_INFRA)
DEFINE_FLAG(D_REPORT, D_INFRA)
DEFINE_FLAG(D_REPORT_BULK, D_REPORT)
DEFINE_FLAG(D_TRACE, D_INFRA)
@@ -137,6 +137,7 @@ DEFINE_FLAG(D_COMPONENT, D_ALL)
DEFINE_FLAG(D_HTTP_MANAGER, D_COMPONENT)
DEFINE_FLAG(D_ORCHESTRATOR, D_COMPONENT)
DEFINE_FLAG(D_HEALTH_CHECK_MANAGER, D_ORCHESTRATOR)
DEFINE_FLAG(D_HEALTH_CHECK, D_ORCHESTRATOR)
DEFINE_FLAG(D_AGENT_DETAILS, D_ORCHESTRATOR)
DEFINE_FLAG(D_LOCAL_POLICY, D_ORCHESTRATOR)
@@ -166,7 +167,6 @@ DEFINE_FLAG(D_COMPONENT, D_ALL)
DEFINE_FLAG(D_IOT_QUERY_INTELLIGENCE, D_IOT_AUXILIARY)
DEFINE_FLAG(D_IOT_SAVE_PERSISTENT, D_IOT_AUXILIARY)
DEFINE_FLAG(D_IOT_DOCKER, D_IOT_AUXILIARY)
DEFINE_FLAG(D_IOT_REST_AUTHENTICATION, D_IOT_AUXILIARY)
DEFINE_FLAG(D_IOT_ENFORCE, D_IOT_NEXT)
DEFINE_FLAG(D_IOT_ENFORCE_POLICY, D_IOT_ENFORCE)
DEFINE_FLAG(D_IOT_ENFORCE_ASSETS, D_IOT_ENFORCE)

View File

@@ -16,7 +16,9 @@
#include <chrono>
#include <vector>
#include <map>
#include "metric/metric_metadata.h"
#include "metric/metric_calc.h"
#include "metric/all_metric_event.h"
#include "i_mainloop.h"
@@ -26,6 +28,7 @@
#include "i_messaging.h"
#include "i_rest_api.h"
#include "report/report_enums.h"
#include "flags.h"
namespace MetricCalculations
{
@@ -38,6 +41,10 @@ namespace MetricCalculations
template <typename PrintableKey, typename Metric> class MetricMap;
} // MetricCalculations
MetricMetadata::DotName operator"" _dot(const char *, std::size_t);
MetricMetadata::Units operator"" _unit(const char *, std::size_t);
MetricMetadata::Description operator"" _desc(const char *, std::size_t);
class LogRest;
class GenericMetric
@@ -51,6 +58,8 @@ class GenericMetric
public Listener<AllMetricEvent>
{
public:
enum class Stream { FOG, DEBUG, PROMETHEUS, AIOPS, COUNT };
void
init(
const std::string &_metric_name,
@@ -79,7 +88,8 @@ public:
static std::string getName() { return "GenericMetric"; }
std::string generateReport(bool with_reset);
std::string generateReport() const;
void resetMetrics();
void upon(const AllMetricEvent &) override;
std::string respond(const AllMetricEvent &event) override;
std::string getListenerName() const override;
@@ -87,6 +97,9 @@ public:
std::string getMetricName() const;
std::chrono::seconds getReportInterval() const;
void turnOnStream(Stream stream) { active_streams.setFlag(stream); }
void turnOffStream(Stream stream) { active_streams.unsetFlag(stream); }
protected:
virtual void sendLog(const LogRest &metric_client_rest) const;
@@ -98,6 +111,7 @@ private:
void handleMetricStreamSending();
void generateLog();
void generateDebug();
I_MainLoop *i_mainloop;
I_TimeGet *i_time;
@@ -107,12 +121,14 @@ private:
ReportIS::Audience audience;
std::chrono::seconds report_interval;
std::vector<MetricCalc *> calcs;
Flags<Stream> active_streams;
bool reset;
bool force_buffering = false;
Context ctx;
};
#include "metric/counter.h"
#include "metric/no_reset_counter.h"
#include "metric/max.h"
#include "metric/min.h"
#include "metric/average.h"

View File

@@ -25,12 +25,18 @@ template <typename T>
class Average : public MetricCalc
{
public:
Average(GenericMetric *metric, const std::string &title) : MetricCalc(metric, title), sum(0), count(0) {}
template <typename ... Args>
Average(GenericMetric *metric, const std::string &title, const Args & ... args)
:
MetricCalc(metric, title, args ...),
sum(0),
count(0)
{
}
void
report(const T &new_value)
{
was_once_reported = true;
sum += new_value;
count++;
}
@@ -38,7 +44,6 @@ public:
void
reset() override
{
was_once_reported = false;
sum = 0;
count = 0;
}
@@ -46,19 +51,19 @@ public:
double
getAverage() const
{
return (was_once_reported) ? double(sum)/count : 0;
return (count > 0) ? double(sum)/count : 0;
}
void
save(cereal::JSONOutputArchive &ar) const override
{
ar(cereal::make_nvp(calc_title, getAverage()));
ar(cereal::make_nvp(getMetricName(), getAverage()));
}
LogField
getLogField() const override
{
return LogField(calc_title, static_cast<uint64_t>(getAverage()));
return LogField(getMetricName(), static_cast<uint64_t>(getAverage()));
}
private:

View File

@@ -24,12 +24,17 @@ namespace MetricCalculations
class Counter : public MetricCalc
{
public:
Counter(GenericMetric *metric, const std::string &title) : MetricCalc(metric, title), counter(0) {}
template <typename ... Args>
Counter(GenericMetric *metric, const std::string &title, const Args & ... args)
:
MetricCalc(metric, title, args ...),
counter(0)
{
}
void
reset() override
{
was_once_reported = false;
counter = 0;
}
@@ -42,20 +47,19 @@ public:
void
save(cereal::JSONOutputArchive &ar) const override
{
ar(cereal::make_nvp(calc_title, getCounter()));
ar(cereal::make_nvp(getMetricName(), getCounter()));
}
void
report(const uint64_t &new_value)
{
was_once_reported = true;
counter += new_value;
}
LogField
getLogField() const override
{
return LogField(calc_title, static_cast<uint64_t>(getCounter()));
return LogField(getMetricName(), static_cast<uint64_t>(getCounter()));
}
private:

View File

@@ -25,12 +25,16 @@ template <typename T>
class LastReportedValue : public MetricCalc
{
public:
LastReportedValue(GenericMetric *metric, const std::string &title) : MetricCalc(metric, title) {}
template <typename ... Args>
LastReportedValue(GenericMetric *metric, const std::string &title, const Args & ... args)
:
MetricCalc(metric, title, args ...)
{
}
void
reset() override
{
was_once_reported = false;
last_reported = T();
}
@@ -43,24 +47,23 @@ public:
void
save(cereal::JSONOutputArchive &ar) const override
{
ar(cereal::make_nvp(calc_title, getLastReportedValue()));
ar(cereal::make_nvp(getMetricName(), getLastReportedValue()));
}
void
report(const T &new_value)
{
was_once_reported = true;
last_reported = new_value;
}
LogField
getLogField() const override
{
return LogField(calc_title, static_cast<uint64_t>(getLastReportedValue()));
return LogField(getMetricName(), static_cast<uint64_t>(getLastReportedValue()));
}
private:
T last_reported;
T last_reported{};
};
} // namespace MetricCalculations

View File

@@ -25,23 +25,29 @@ template <typename T>
class Max : public MetricCalc
{
public:
Max(GenericMetric *metric, const std::string &title) : Max(metric, title, std::numeric_limits<T>::min()) {}
Max(GenericMetric *metric, const std::string &title, T min_val)
Max(GenericMetric *metric, const std::string &title) : Max(metric, title, 0) {}
template<typename ... Args>
Max(GenericMetric *metric, const std::string &title, T min_val, const Args & ... args)
:
MetricCalc(metric, title), max(min_val), reset_value(min_val) {}
MetricCalc(metric, title, args ...),
max(min_val),
reset_value(min_val)
{
}
void
report(const T &new_value)
{
was_once_reported = true;
if (new_value > max) max = new_value;
if (new_value > max || first) max = new_value;
first = false;
}
void
reset() override
{
was_once_reported = false;
max = reset_value;
first = true;
}
T
@@ -53,18 +59,19 @@ public:
void
save(cereal::JSONOutputArchive &ar) const override
{
ar(cereal::make_nvp(calc_title, max));
ar(cereal::make_nvp(getMetricName(), max));
}
LogField
getLogField() const override
{
return LogField(calc_title, static_cast<uint64_t>(getMax()));
return LogField(getMetricName(), static_cast<uint64_t>(getMax()));
}
private:
T max;
T reset_value;
bool first = true;
};
} // namespace MetricCalculations

View File

@@ -24,19 +24,53 @@
class GenericMetric;
enum class MetricType { GAUGE, COUNTER };
class MetricCalc
{
public:
MetricCalc(GenericMetric *metric, const std::string &calc_title);
template<typename ... Args>
MetricCalc(GenericMetric *metric, const std::string &calc_title, const Args & ... args)
{
setMetadata("BaseName", calc_title);
addMetric(metric);
parseMetadata(args ...);
}
virtual void reset() = 0;
virtual void save(cereal::JSONOutputArchive &) const = 0;
virtual LogField getLogField() const = 0;
bool wasOnceReported() const { return was_once_reported; }
std::string getMetricName() const { return getMetadata("BaseName"); }
std::string getMetricDotName() const { return getMetadata("DotName"); }
std::string getMetircUnits() const { return getMetadata("Units"); }
std::string getMetircDescription() const { return getMetadata("Description"); }
std::string getMetadata(const std::string &metadata) const;
virtual MetricType getMetricType() const { return MetricType::GAUGE; }
void setMetricDotName(const std::string &name) { setMetadata("DotName", name); }
void setMetircUnits(const std::string &units) { setMetadata("Units", units); }
void setMetircDescription(const std::string &description) { setMetadata("Description", description); }
void setMetadata(const std::string &metadata, const std::string &value);
protected:
bool was_once_reported = false;
std::string calc_title;
void addMetric(GenericMetric *metric);
template <typename Metadata, typename ... OtherMetadata>
void
parseMetadata(const Metadata &metadata, const OtherMetadata & ... other_metadata)
{
parseMetadata(metadata);
parseMetadata(other_metadata ...);
}
void parseMetadata(const MetricMetadata::DotName &name) { setMetricDotName(name.val); }
void parseMetadata(const MetricMetadata::Units &units) { setMetircUnits(units.val); }
void parseMetadata(const MetricMetadata::Description &description) { setMetircDescription(description.val); }
void parseMetadata() {}
private:
std::map<std::string, std::string> metadata;
};
#endif // __METRIC_CALC_H__

View File

@@ -46,6 +46,14 @@ class MetricMap : public MetricCalc
void clear() { inner_map.clear(); }
MetricType
getMetricType() const
{
auto first = begin();
if (first == end()) return MetricType::GAUGE;
return first->second.getMetricType();
}
typename std::map<std::string, Metric>::const_iterator begin() const { return inner_map.begin(); }
typename std::map<std::string, Metric>::const_iterator end() const { return inner_map.end(); }
@@ -54,27 +62,31 @@ class MetricMap : public MetricCalc
};
public:
MetricMap(GenericMetric *metric, const std::string &title) : MetricCalc(metric, title) {}
template <typename ... Args>
MetricMap(GenericMetric *metric, const std::string &title, const Args & ... args)
:
MetricCalc(metric, title, args ...)
{
}
void
reset() override
{
was_once_reported = false;
metric_map.clear();
if (getMetricType() == MetricType::GAUGE) metric_map.clear();
}
void
save(cereal::JSONOutputArchive &ar) const override
{
ar(cereal::make_nvp(calc_title, metric_map));
ar(cereal::make_nvp(getMetricName(), metric_map));
}
MetricType getMetricType() const override { return metric_map.getMetricType(); }
template <typename ... Values>
void
report(const PrintableKey &key, const Values & ... new_values)
{
was_once_reported = true;
std::stringstream string_key;
string_key << key;
auto metric = metric_map.emplace(string_key.str(), Metric(nullptr, string_key.str())).first;
@@ -84,7 +96,7 @@ public:
LogField
getLogField() const override
{
LogField field(calc_title);
LogField field(getMetricName());
for (auto &metric : metric_map) {
field.addFields(metric.second.getLogField());

View File

@@ -0,0 +1,43 @@
// Copyright (C) 2022 Check Point Software Technologies Ltd. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __METRIC_METADATA_H__
#define __METRIC_METADATA_H__
#ifndef __GENERIC_METRIC_H__
#error metric/metric_metadata.h should not be included directly
#endif // __GENERIC_METRIC_H_
#include <string>
namespace MetricMetadata
{
struct DotName
{
std::string val;
};
struct Units
{
std::string val;
};
struct Description
{
std::string val;
};
} //MetricMetadata
#endif // __METRIC_METADATA_H__

View File

@@ -25,21 +25,29 @@ template <typename T>
class Min : public MetricCalc
{
public:
Min(GenericMetric *metric, const std::string &title) : Min(metric, title, std::numeric_limits<T>::max()) {}
Min(GenericMetric *metric, const std::string &title, T max_val) : MetricCalc(metric, title), min(max_val) {}
Min(GenericMetric *metric, const std::string &title) : Min(metric, title, 0) {}
template<typename ... Args>
Min(GenericMetric *metric, const std::string &title, T max_val, const Args & ... args)
:
MetricCalc(metric, title, args ...),
min(max_val),
reset_value(max_val)
{
}
void
report(const T &new_value)
{
was_once_reported = true;
if (new_value < min) min = new_value;
if (new_value < min || first) min = new_value;
first = false;
}
void
reset() override
{
was_once_reported = false;
min = std::numeric_limits<T>::max();
min = reset_value;
first = true;
}
T
@@ -51,17 +59,19 @@ public:
void
save(cereal::JSONOutputArchive &ar) const override
{
ar(cereal::make_nvp(calc_title, min));
ar(cereal::make_nvp(getMetricName(), min));
}
LogField
getLogField() const override
{
return LogField(calc_title, static_cast<uint64_t>(getMin()));
return LogField(getMetricName(), static_cast<uint64_t>(getMin()));
}
private:
T min;
T reset_value;
bool first = true;
};
} // namespace MetricCalculations

View File

@@ -0,0 +1,68 @@
// Copyright (C) 2022 Check Point Software Technologies Ltd. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __NO_RESET_COUNTER_H__
#define __NO_RESET_COUNTER_H__
#ifndef __GENERIC_METRIC_H__
#error metric/no_reset_counter.h should not be included directly
#endif // __GENERIC_METRIC_H_
namespace MetricCalculations
{
class NoResetCounter : public MetricCalc
{
public:
template <typename ... Args>
NoResetCounter(GenericMetric *metric, const std::string &title, const Args & ... args)
:
MetricCalc(metric, title, args ...),
counter(0)
{
}
void reset() override {}
MetricType getMetricType() const override { return MetricType::COUNTER; }
uint64_t
getCounter() const
{
return counter;
}
void
save(cereal::JSONOutputArchive &ar) const override
{
ar(cereal::make_nvp(getMetricName(), getCounter()));
}
void
report(const uint64_t &new_value)
{
counter += new_value;
}
LogField
getLogField() const override
{
return LogField(getMetricName(), static_cast<uint64_t>(getCounter()));
}
private:
uint64_t counter;
};
} // namespace MetricCalculations
#endif // __NO_RESET_COUNTER_H__

View File

@@ -28,12 +28,17 @@ template <typename T, uint N>
class TopValues : public MetricCalc
{
public:
TopValues(GenericMetric *metric, const std::string &title) : MetricCalc(metric, title) { values.reserve(N); }
template <typename ... Args>
TopValues(GenericMetric *metric, const std::string &title, const Args & ... args)
:
MetricCalc(metric, title, args ...)
{
values.reserve(N);
}
void
report(const T &new_value)
{
was_once_reported = true;
if (values.size() < N) {
values.push_back(new_value);
return;
@@ -51,7 +56,6 @@ public:
void
reset() override
{
was_once_reported = false;
values.clear();
}
@@ -66,13 +70,13 @@ public:
void
save(cereal::JSONOutputArchive &ar) const override
{
ar(cereal::make_nvp(calc_title, getTopValues()));
ar(cereal::make_nvp(getMetricName(), getTopValues()));
}
LogField
getLogField() const override
{
return LogField(calc_title, getTopValues());
return LogField(getMetricName(), getTopValues());
}
private:

View File

@@ -162,7 +162,9 @@ class LogField : Singleton::Consume<I_Environment>
void
addFields(const LogField &)
{
dbgAssert(false) << "Trying to add a log field to a 'type'ed field";
dbgAssert(false)
<< AlertInfo(AlertTeam::CORE, "report i/s")
<< "Trying to add a log field to a 'type'ed field";
}
// LCOV_EXCL_STOP

View File

@@ -26,7 +26,7 @@ public:
void
setBulkSize(uint size)
{
dbgAssert(size > 0) << "Bulk size must be larger than 0";
dbgAssert(size > 0) << AlertInfo(AlertTeam::CORE, "report i/s") << "Bulk size must be larger than 0";
dbgDebug(D_REPORT_BULK) << "Bulk size is set to " << size;
bulk_size = size;
}

View File

@@ -0,0 +1,130 @@
// Copyright (C) 2022 Check Point Software Technologies Ltd. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __REPORT_MESSAGING_H__
#define __REPORT_MESSAGING_H__
#include "singleton.h"
#include "i_time_get.h"
#include "i_messaging.h"
#include "report/report.h"
class ReportMessaging
:
Singleton::Consume<I_Messaging>,
Singleton::Consume<I_TimeGet>
{
public:
template <typename ...Args, typename T>
ReportMessaging(
const std::string &title,
const ReportIS::AudienceTeam &audience_team,
const T &obj,
Args ...args)
:
ReportMessaging(
title,
audience_team,
obj,
MessageCategory::GENERIC,
std::forward<Args>(args)...
)
{
}
template <typename ...Args, typename T>
ReportMessaging(
const std::string &title,
const ReportIS::AudienceTeam &audience_team,
const T &obj,
const MessageCategory &message_type,
Args ...args)
:
ReportMessaging(
title,
audience_team,
ReportIS::Severity::INFO,
ReportIS::Priority::LOW,
obj,
message_type,
std::forward<Args>(args)...
)
{
}
template <typename ...Args, typename T>
ReportMessaging(
const std::string &title,
const ReportIS::AudienceTeam &audience_team,
const ReportIS::Severity &severity,
const ReportIS::Priority &priority,
const T &obj,
Args ...args)
:
ReportMessaging(
title,
audience_team,
severity,
priority,
obj,
MessageCategory::GENERIC,
std::forward<Args>(args)...
)
{
}
template <typename ...Args, typename T>
ReportMessaging(
const std::string &title,
const ReportIS::AudienceTeam &audience_team,
const ReportIS::Severity &severity,
const ReportIS::Priority &priority,
const T &obj,
const MessageCategory &message_type,
Args ...args)
:
report(
title,
Singleton::Consume<I_TimeGet>::by<ReportMessaging>()->getWalltime(),
ReportIS::Type::EVENT,
ReportIS::Level::LOG,
ReportIS::LogLevel::INFO,
ReportIS::Audience::INTERNAL,
audience_team,
severity,
priority,
std::chrono::seconds(0),
std::forward<Args>(args)...
),
message_type_tag(message_type)
{
report << LogField("eventObject", obj);
}
~ReportMessaging();
ReportMessaging & operator<<(const LogField &field);
Maybe<void, HTTPResponse> sendReportSynchronously();
void setForceBuffering(bool _force_buffering);
private:
Report report;
bool is_async_message = true;
bool force_buffering = false;
MessageCategory message_type_tag;
};
#endif // __REPORT_MESSAGING_H__

View File

@@ -0,0 +1,43 @@
// Copyright (C) 2022 Check Point Software Technologies Ltd. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __SERVICE_HEALTH_UPDATE_EVENT_H__
#define __SERVICE_HEALTH_UPDATE_EVENT_H__
#include "event.h"
#include "singleton.h"
#include "config.h"
#include "debug.h"
#include "customized_cereal_map.h"
class ServiceHealthUpdateEvent : public Event<ServiceHealthUpdateEvent>
{
public:
ServiceHealthUpdateEvent() {}
ServiceHealthUpdateEvent(
const std::string &_component,
const std::string &_error)
:
component(_component),
error(_error) {}
bool isHealthyUpdate() const { return component.empty(); }
const std::string & getComponent() const { return component; }
const std::string & getError() const { return error; }
private:
std::string component = "";
std::string error = "";
};
#endif // __SERVICE_HEALTH_UPDATE_EVENT_H__

View File

@@ -48,7 +48,10 @@ Opaque &
I_Table::getState()
{
Opaque *ptr = static_cast<Opaque *>(getState(typeid(Opaque)));
dbgAssert(ptr != nullptr) << "Trying to access a non existing opaque " << typeid(Opaque).name();
dbgAssert(ptr != nullptr)
<< AlertInfo(AlertTeam::CORE, "table")
<< "Trying to access a non existing opaque "
<< typeid(Opaque).name();
return *ptr;
}

View File

@@ -48,6 +48,8 @@ std::string convertToHumanReadable(uint64_t size_in_bytes);
std::string getFileName(const std::string &path);
bool copyDirectory(const std::string &src_dir_path, const std::string &dst_dir_path);
}// namespace Filesystem
namespace Regex

View File

@@ -88,6 +88,7 @@ public:
operator==(const IPAddr &other) const
{
dbgAssert(type!=IPType::UNINITIALIZED && other.type!=IPType::UNINITIALIZED)
<< AlertInfo(AlertTeam::CORE, "connkey")
<< "Called on an uninitialized IPType object";
// Always compairing as if IPv6, in case of Ipv4 the rest of the address is zeroed out.
int ip_len = (other.type == IPType::V4) ? sizeof(v4.s_addr) : sizeof(v6.s6_addr);
@@ -307,7 +308,9 @@ public:
IPType
getType() const
{
dbgAssert(src.type == dst.type) << "Mismatch in connection types (Src and Dst types are not identical)";
dbgAssert(src.type == dst.type)
<< AlertInfo(AlertTeam::CORE, "connkey")
<< "Mismatch in connection types (Src and Dst types are not identical)";
return src.type;
}

View File

@@ -27,13 +27,13 @@ public:
operator T &()
{
dbgAssert(is_active) << "Tried to access a non-existing variable";
dbgAssert(is_active) << AlertInfo(AlertTeam::CORE, "rest i/s") << "Tried to access a non-existing variable";
return val;
}
operator const T &() const
{
dbgAssert(is_active) << "Tried to access a non-existing variable";
dbgAssert(is_active) << AlertInfo(AlertTeam::CORE, "rest i/s") << "Tried to access a non-existing variable";
return val;
}