• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

P_ClusterLoadMonitor.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 
00025 /****************************************************************************
00026 
00027   ClusterLoadMonitor.h
00028 ****************************************************************************/
00029 
00030 #ifndef _P_ClusterLoadMonitor_h
00031 #define _P_ClusterLoadMonitor_h
00032 
00033 #include "P_Cluster.h"
00034 
00035 //***************************************************************************
00036 // ClusterLoadMonitor class -- Compute cluster interconnect load metric
00037 //***************************************************************************
00038 class ClusterLoadMonitor:public Continuation
00039 {
00040 public:
00041   /////////////////////////////////////
00042   // Defined by records.config
00043   /////////////////////////////////////
00044   static int cf_monitor_enabled;
00045   static int cf_ping_message_send_msec_interval;
00046   static int cf_num_ping_response_buckets;
00047   static int cf_msecs_per_ping_response_bucket;
00048   static int cf_ping_latency_threshold_msecs;
00049   static int cf_cluster_load_compute_msec_interval;
00050   static int cf_cluster_periodic_msec_interval;
00051   static int cf_ping_history_buf_length;
00052   static int cf_cluster_load_clear_duration;
00053   static int cf_cluster_load_exceed_duration;
00054 
00055   struct cluster_load_ping_msg
00056   {
00057     int magicno;
00058     int version;
00059     int sequence_number;
00060     ink_hrtime send_time;
00061     ClusterLoadMonitor *monitor;
00062 
00063     enum
00064     {
00065       CL_MSG_MAGICNO = 0x12ABCDEF,
00066       CL_MSG_VERSION = 1
00067     };
00068       cluster_load_ping_msg(ClusterLoadMonitor * m = 0)
00069   :  magicno(CL_MSG_MAGICNO), version(CL_MSG_VERSION), sequence_number(0), send_time(0), monitor(m) {
00070     }
00071   };
00072 
00073   static void cluster_load_ping_rethandler(ClusterHandler *, void *, int);
00074 
00075 public:
00076   ClusterLoadMonitor(ClusterHandler * ch);
00077   void init();
00078   ~ClusterLoadMonitor();
00079   void cancel_monitor();
00080   bool is_cluster_overloaded();
00081 
00082 private:
00083   void compute_cluster_load();
00084   void note_ping_response_time(ink_hrtime, int);
00085   void recv_cluster_load_msg(cluster_load_ping_msg *);
00086   void send_cluster_load_msg(ink_hrtime);
00087   int cluster_load_periodic(int, Event *);
00088 
00089 private:
00090   ////////////////////////////////////////////////////
00091   // Copy of global configuration (records.config)
00092   ////////////////////////////////////////////////////
00093   int ping_message_send_msec_interval;
00094   int num_ping_response_buckets;
00095   int msecs_per_ping_response_bucket;
00096   int ping_latency_threshold_msecs;
00097   int cluster_load_compute_msec_interval;
00098   int cluster_periodic_msec_interval;
00099   int ping_history_buf_length;
00100   int cluster_load_clear_duration;
00101   int cluster_load_exceed_duration;
00102 
00103   // Class specific data
00104   ClusterHandler *ch;
00105   int *ping_response_buckets;
00106   ink_hrtime *ping_response_history_buf;
00107   int ping_history_buf_head;
00108   Action *periodic_action;
00109 
00110   int cluster_overloaded;
00111   int cancel_periodic;
00112   ink_hrtime last_ping_message_sent;
00113   ink_hrtime last_cluster_load_compute;
00114   int cluster_load_msg_sequence_number;
00115   int cluster_load_msg_start_sequence_number;
00116 };
00117 
00118 #endif /* _ClusterLoadMonitor_h */

Generated by  doxygen 1.7.1