Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-31300 Clean up roxie metric code #18309

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 1 addition & 79 deletions roxie/ccd/ccdsnmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ interface INamedMetric : extends IInterface
virtual void resetValue() = 0;
};

interface ITimerCallback : extends IInterface
{
virtual void onTimer() = 0;
};

class RelaxedAtomicMetric : implements INamedMetric, public CInterface
{
RelaxedAtomic<unsigned> &counter;
Expand Down Expand Up @@ -123,50 +118,7 @@ class UserMetric : implements INamedMetric, public CInterface

};

class TickProvider : public Thread
{
IArrayOf<ITimerCallback> listeners;
CriticalSection crit;
Semaphore stopped;

void doTicks()
{
CriticalBlock c(crit);
ForEachItemIn(idx, listeners)
{
listeners.item(idx).onTimer();
}
}

public:
TickProvider() : Thread("TickProvider")
{
}
int run()
{
for (;;)
{
if (stopped.wait(10000))
break;
doTicks();
}
return 0;
}

void addListener(ITimerCallback *l)
{
CriticalBlock c(crit);
listeners.append(*LINK(l));
}

void stop()
{
stopped.signal();
join();
}
};

class IntervalMetric : implements INamedMetric, implements ITimerCallback, public CInterface
class IntervalMetric : implements INamedMetric, public CInterface
{
Linked<INamedMetric> base;
CriticalSection crit;
Expand Down Expand Up @@ -197,10 +149,6 @@ class IntervalMetric : implements INamedMetric, implements ITimerCallback, publi
lastSnapshotValue = 0;
value = 0;
}
virtual void onTimer()
{
takeSnapshot();
}
virtual long getValue()
{
takeSnapshot();
Expand Down Expand Up @@ -252,7 +200,6 @@ class CRoxieMetricsManager : implements IRoxieMetricsManager, public CInterface
~CRoxieMetricsManager();

virtual long getValue(const char * name);
void dumpMetrics();
StringBuffer &getMetrics(StringBuffer &xml);
void resetMetrics();

Expand All @@ -264,9 +211,6 @@ class CRoxieMetricsManager : implements IRoxieMetricsManager, public CInterface

private:
MapStringToMyClassViaBase<INamedMetric, INamedMetric> metricMap;
bool started;

TickProvider ticker;
};

void RoxieQueryStats::addMetrics(CRoxieMetricsManager *snmpManager, const char *prefix, unsigned interval)
Expand All @@ -287,7 +231,6 @@ using roxiemem::getDataBuffersActive;

CRoxieMetricsManager::CRoxieMetricsManager()
{
started = false;
unknownQueryStats.addMetrics(this, "unknown", 1000);
loQueryStats.addMetrics(this, "lo", 1000);
hiQueryStats.addMetrics(this, "hi", 1000);
Expand Down Expand Up @@ -321,7 +264,6 @@ CRoxieMetricsManager::CRoxieMetricsManager()
addMetric(flowRequestsSent, 1000);
addMetric(flowPermitsReceived, 1000);
addMetric(dataPacketsSent, 1000);
ticker.start();
}

void CRoxieMetricsManager::doAddMetric(RelaxedAtomic<unsigned> &counter, const char *name, unsigned interval, bool isMinVal)
Expand All @@ -336,7 +278,6 @@ void CRoxieMetricsManager::doAddMetric(INamedMetric *n, const char *name, unsign
StringBuffer fname(name);
fname.append("/s");
IntervalMetric *im = new IntervalMetric(n, interval);
ticker.addListener(im);
metricMap.setValue(fname.str(), im);
im->Release();
}
Expand Down Expand Up @@ -375,25 +316,6 @@ long CRoxieMetricsManager::getValue(const char * name)

CRoxieMetricsManager::~CRoxieMetricsManager()
{
ticker.stop();
if (started)
dumpMetrics();
}

void CRoxieMetricsManager::dumpMetrics()
{
HashIterator metrics(metricMap);
ForEach(metrics)
{
IMapping &cur = metrics.query();
INamedMetric *m = (INamedMetric *) *metricMap.mapToValue(&cur);
if (m->isCumulative())
{
const char *name = (const char *) cur.getKey();
long val = m->getValue();
DBGLOG("TOTALS: %s = %ld", name, val);
}
}
}

StringBuffer &CRoxieMetricsManager::getMetrics(StringBuffer &xml)
Expand Down
1 change: 0 additions & 1 deletion roxie/ccd/ccdsnmp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ extern RoxieQueryStats combinedQueryStats;

interface IRoxieMetricsManager : extends IInterface
{
virtual void dumpMetrics() = 0;
virtual void addUserMetric(const char *name, const char *regex) = 0;
virtual StringBuffer &getMetrics(StringBuffer &) = 0;
virtual void resetMetrics() = 0;
Expand Down
Loading