You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zy...@apache.org on 2013/03/13 08:10:17 UTC
git commit: TS-1671: remove AlarmListable from overviewRecord
Updated Branches:
refs/heads/master 34b8adc6b -> ae21316cb
TS-1671: remove AlarmListable from overviewRecord
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ae21316c
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ae21316c
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ae21316c
Branch: refs/heads/master
Commit: ae21316cb1ace0afe69c4a3897151934da4618de
Parents: 34b8adc
Author: Yunkai Zhang <qi...@taobao.com>
Authored: Wed Mar 13 15:00:23 2013 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Wed Mar 13 15:03:50 2013 +0800
----------------------------------------------------------------------
CHANGES | 3 +
mgmt/Main.cc | 5 -
mgmt/web2/WebOverview.cc | 261 -----------------------------------------
mgmt/web2/WebOverview.h | 19 ---
4 files changed, 3 insertions(+), 285 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ae21316c/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 31e4062..7f71c51 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 3.3.2
+ *) [TS-1671] remove AlarmListable from overviewRecord
+ Author: Yunkai Zhang <qi...@taobao.com>
+
*) [TS-1740] Improve precision of stats values
Author: Yunkai Zhang <qi...@taobao.com>
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ae21316c/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index 1f9c2ab..4c3a3f6 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -674,11 +674,6 @@ main(int argc, char **argv)
}
#endif /* MGMT_USE_SYSLOG */
- /****************************
- * Register Alarm Callbacks *
- ****************************/
- lmgmt->alarm_keeper->registerCallback(overviewAlarmCallback);
-
// Find out our hostname so we can use it as part of the initialization
setHostnameVar();
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ae21316c/mgmt/web2/WebOverview.cc
----------------------------------------------------------------------
diff --git a/mgmt/web2/WebOverview.cc b/mgmt/web2/WebOverview.cc
index af7cd10..792a896 100644
--- a/mgmt/web2/WebOverview.cc
+++ b/mgmt/web2/WebOverview.cc
@@ -99,73 +99,13 @@ overviewRecord::overviewRecord(unsigned long inet_addr, bool local, ClusterPeerI
overviewRecord::~overviewRecord()
{
- AlarmListable *a;
-
delete[]hostname;
- for (a = nodeAlarms.pop(); a != NULL; a = nodeAlarms.pop()) {
- delete a;
- }
-
if (localNode == false) {
delete[]node_rec_data.recs;
}
}
-// void overviewRecord::getStatus(char**, PowerLampState* , bool*, bool*)
-// Retrieves information about the node
-//
-// hostname - *hostname is set to point to a string containing the hostname
-// for the node represented by the record The storage for
-// this string belongs to this class instance and should
-// not be freed by the caller
-//
-// *up - set to true if the node's manager is up
-// Set to false otherwise
-//
-// *alarms - set to true if there are any pending alarms for this
-// this node. Set to false if there are no pending
-// alarms
-//
-// *proxyUp - set to true is the proxy is up on the node and
-// false otherwise
-//
-void
-overviewRecord::getStatus(char **hostnamePtr, bool * upPtr, bool * alarms, PowerLampState * proxyUpPtr)
-{
- bool found;
- *hostnamePtr = this->hostname;
- *upPtr = this->up;
-
- if (this->up != true) {
- *proxyUpPtr = LAMP_OFF;
- } else {
- if (this->readInteger("proxy.node.proxy_running", &found) != 1) {
- *proxyUpPtr = LAMP_OFF;
- } else {
- if (this->localNode == true) {
- // For the local node, make sure all the cluster connections
- // are up. If not issue a warning lamp
- if (lmgmt->clusterOk() == false) {
- *proxyUpPtr = LAMP_WARNING;
- } else {
- *proxyUpPtr = LAMP_ON;
- }
- } else {
- // We can not currently check remote node
- // cluster info
- *proxyUpPtr = LAMP_ON;
- }
- }
- }
-
- if (nodeAlarms.head == NULL) {
- *alarms = false;
- } else {
- *alarms = true;
- }
-}
-
// void overviewRecord::updateStatus(time_t, ClusterPeerInfo*)
// updates up/down status based on the cluster peer info record
//
@@ -197,27 +137,6 @@ overviewRecord::updateStatus(time_t currentTime, ClusterPeerInfo * cpi)
}
}
-// adds a new alarm to the list of current alarms for the node
-void
-overviewRecord::addAlarm(alarm_t type, char *ip, char *desc)
-{
-
- AlarmListable *alarm;
-
- alarm = new AlarmListable;
- alarm->ip = ip;
- alarm->type = type;
- alarm->desc = desc;
- nodeAlarms.push(alarm);
-}
-
-// adds a new alarm to the list of current alarms for the node
-void
-overviewRecord::addAlarm(AlarmListable * newAlarm)
-{
- nodeAlarms.push(newAlarm);
-}
-
// bool overviewRecord::ipMatch(char* ipStr)
//
// Returns true if the passed in string matches
@@ -232,31 +151,6 @@ overviewRecord::ipMatch(char *ipStr)
}
}
-// Runs throught the list of current alarms on the node
-// and asks the Alarms class if it is valid. If the alarm
-// is expired it is removed from the alarm list
-void
-overviewRecord::checkAlarms()
-{
-
- AlarmListable *current;
- AlarmListable *next;
-
- current = nodeAlarms.head;
- while (current != NULL) {
-
- next = current->link.next;
-
- if (!lmgmt->alarm_keeper->isCurrentAlarm(current->type, current->ip)) {
- // The alarm is no longer current. Dispose of it
- nodeAlarms.remove(current);
- delete current;
- }
-
- current = next;
- }
-}
-
// overview::readCounter, overview::readInteger
//
// Accessor functions for node records. For remote node,
@@ -609,12 +503,6 @@ overviewPage::checkForUpdates()
}
ink_mutex_release(&lmgmt->ccom->mutex);
- // Now check to see if our alarms up to date
- for (int i = 0; i < numHosts; i++) {
- current = (overviewRecord *) sortRecords[i];
- current->checkAlarms();
- }
-
// If we added a new host we must resort sortRecords
if (newHostAdded) {
this->sortHosts();
@@ -648,9 +536,6 @@ overviewPage::addRecord(ClusterPeerInfo * cpi)
overviewRecord *newRec;
- AlarmListable *current;
- AlarmListable *next;
-
ink_assert(cpi != NULL);
newRec = new overviewRecord(cpi->inet_address, false, cpi);
@@ -658,27 +543,6 @@ overviewPage::addRecord(ClusterPeerInfo * cpi)
ink_hash_table_insert(nodeRecords, (InkHashTableKey) cpi->inet_address, (InkHashTableEntry *) newRec);
- // Check to see if we have alarms that need to be added
- //
- // This an inefficient linear search, however there should
- // never be a large number of alarms that do not
- // nodes yet. This should only happen at start up
- //
- current = notFoundAlarms.head;
- while (current != NULL) {
-
- next = current->link.next;
-
- if (newRec->ipMatch(current->ip) == true) {
- // The alarm belongs to this record, remove it and
- // add it to the record
- notFoundAlarms.remove(current);
- newRec->addAlarm(current);
- }
-
- current = next;
- }
-
sortRecords.addEntry(newRec);
numHosts++;
}
@@ -693,8 +557,6 @@ overviewPage::addSelfRecord()
{
overviewRecord *newRec;
- AlarmListable *current;
- AlarmListable *next;
ink_mutex_acquire(&accessLock);
@@ -710,70 +572,11 @@ overviewPage::addSelfRecord()
ink_hash_table_insert(nodeRecords, (InkHashTableKey) this->ourAddr, (InkHashTableEntry *) newRec);
- // Check to see if we have alarms that need to be added
- // They would be listed for IP zero since the alarm
- // manager knows ip address for the local node as NULL
- //
- current = notFoundAlarms.head;
- while (current != NULL) {
-
- next = current->link.next;
-
- if (current->ip == NULL) {
- // The alarm belongs to this record, remove it and
- // add it to the record
- notFoundAlarms.remove(current);
- newRec->addAlarm(current);
- }
-
- current = next;
- }
-
sortRecords.addEntry(newRec);
numHosts++;
ink_mutex_release(&accessLock);
}
-// adds alarm to the node specified by the ip address
-// if ip is NULL, the node is local machine
-void
-overviewPage::addAlarm(alarm_t type, char *ip, char *desc)
-{
-
- unsigned long inetAddr;
- InkHashTableValue lookup;
- overviewRecord *node;
- AlarmListable *alarm;
-
- ink_mutex_acquire(&accessLock);
-
- if (ip == NULL) {
- inetAddr = ourAddr;
- } else {
- inetAddr = inet_addr(ip);
- }
-
- if (ink_hash_table_lookup(nodeRecords, (InkHashTableKey) inetAddr, &lookup)) {
- // We found our entry
- node = (overviewRecord *) lookup;
- node->addAlarm(type, ip, desc);
- } else {
-
- Debug("dashboard", "[overviewRecord::addAlarm] Alarm for node that we have not seen %s\n", ip);
-
- // If we have not seen the node, queue the alarm. The node
- // should appear eventually
- alarm = new AlarmListable;
- alarm->ip = ip;
- alarm->type = type;
- alarm->desc = desc;
- notFoundAlarms.push(alarm);
- }
-
- ink_mutex_release(&accessLock);
-}
-
-
// int overviewPage::getClusterHosts(Expanding Array* hosts)
//
// The names of all the cluster members are inserted
@@ -1610,70 +1413,6 @@ overviewPage::resolvePeerHostname_ml(const char *peerIP)
return returnName;
}
-// resolveAlarm
-//
-// Handles the form submission for alarm resolution
-// uses the form arguments to call resolveAlarm.
-//
-// Takes a hash-table returned by processFormSubmission
-//
-// Note: resolving an alarm is asyncronous with the list of
-// alarms maintained in overviewRecords. That list
-// is only updates when checkAlarms is called
-//
-void
-resolveAlarm(InkHashTable * post_data_ht)
-{
-
- InkHashTableIteratorState htis;
- InkHashTableEntry *hte;
- char *name;
- char *value;
- Tokenizer colonTok(":");
- const char *ipAddr;
- alarm_t alarmType;
-
- for (hte = ink_hash_table_iterator_first(post_data_ht, &htis);
- hte != NULL; hte = ink_hash_table_iterator_next(post_data_ht, &htis)) {
- name = (char *) ink_hash_table_entry_key(post_data_ht, hte);
- value = (char *) ink_hash_table_entry_value(post_data_ht, hte);
- if (strncmp(name, "alarm:", 6) != 0)
- continue;
- if (colonTok.Initialize(value) == 2) {
- alarmType = atoi(colonTok[0]);
- ipAddr = colonTok[1];
- Debug("dashboard", "Resolving alarm %d for %s\n", alarmType, ipAddr);
- if (strcmp("local", ipAddr) == 0)
- ipAddr = NULL;
- if (lmgmt->alarm_keeper->isCurrentAlarm(alarmType, (char *) ipAddr)) {
- Debug("dashboard", "\t Before resolution the alarm is current\n");
- } else {
- Debug("dashboard", "\t Before resolution the alarm is NOT current\n");
- }
- lmgmt->alarm_keeper->resolveAlarm(alarmType, (char *) ipAddr);
- if (lmgmt->alarm_keeper->isCurrentAlarm(alarmType, (char *) ipAddr)) {
- Debug("dashboard", "\t After resolution the alarm is current\n");
- } else {
- Debug("dashboard", "\t After resolution the alarm is NOT current\n");
- }
- }
- }
- overviewGenerator->checkForUpdates();
-}
-
-// wrapper for the Alarm Callback
-void
-overviewAlarmCallback(alarm_t newAlarm, char *ip, char *desc)
-{
- overviewGenerator->addAlarm(newAlarm, ip, desc);
-}
-
-AlarmListable::~AlarmListable()
-{
- ats_free(ip);
- ats_free(desc);
-}
-
// int hostSortFunc(const void* arg1, const void* arg2)
//
// A compare function that we can to qsort that sorts
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ae21316c/mgmt/web2/WebOverview.h
----------------------------------------------------------------------
diff --git a/mgmt/web2/WebOverview.h b/mgmt/web2/WebOverview.h
index 1bbb506..94b48a2 100644
--- a/mgmt/web2/WebOverview.h
+++ b/mgmt/web2/WebOverview.h
@@ -34,7 +34,6 @@
#include "WebHttpMessage.h"
#include "ExpandingArray.h"
#include "ClusterCom.h"
-#include "Alarms.h"
#include "P_RecCore.h"
@@ -71,16 +70,6 @@
// should be returned as a copy (or a const ptr)
// through an accessor function
-class AlarmListable
-{
-public:
- ~AlarmListable();
- alarm_t type;
- char *ip;
- char *desc;
- LINK(AlarmListable, link);
-};
-
enum PowerLampState
{ LAMP_ON, LAMP_OFF, LAMP_WARNING };
@@ -90,8 +79,6 @@ class overviewRecord
public:
overviewRecord(unsigned long inet_addr, bool local, ClusterPeerInfo * cpi = NULL);
~overviewRecord();
- void addAlarm(alarm_t type, char *ip, char *desc);
- void addAlarm(AlarmListable * newAlarm);
void updateStatus(time_t currentTime, ClusterPeerInfo * cpi);
void getStatus(char **hotsname, bool * up, bool * alarms, PowerLampState * proxyUp);
bool ipMatch(char *ipStr); // is this the ip address of this node
@@ -99,8 +86,6 @@ public:
bool localNode;
char *hostname; // FQ hostname of the node
unsigned long inetAddr; // IP address of the node
- DLL<AlarmListable> nodeAlarms; // List of alarms for the node
- void checkAlarms();
bool varStrFromName(const char *varName, char *bufVal, int bufLen);
RecCounter readCounter(const char *name, bool * found);
RecInt readInteger(const char *name, bool * found);
@@ -125,7 +110,6 @@ public:
overviewPage();
~overviewPage();
- void addAlarm(alarm_t newAlarm, char *ip, char *desc);
void checkForUpdates();
char *resolvePeerHostname(const char *peerIP);
char *resolvePeerHostname_ml(const char *peerIP);
@@ -156,7 +140,6 @@ private:
unsigned long ourAddr; // the IP address of this node
ExpandingArray sortRecords; // A second, sorted container for nodeRecords
int numHosts; // number of peers we know about including ourself
- DLL<AlarmListable> notFoundAlarms; // List of alarms for nodes we haven't seen
// Functions to do cluster aggregation
//
@@ -178,8 +161,6 @@ private:
extern overviewPage *overviewGenerator; // global handle to overiewPage?
// defn found in WebOverview.cc
-void overviewAlarmCallback(alarm_t newAlarm, char *ip, char *desc);
-void resolveAlarm(InkHashTable * post_data_ht);
int hostSortFunc(const void *arg1, const void *arg2);
#endif