You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2011/01/12 00:09:17 UTC

svn commit: r1057918 - in /trafficserver/traffic/trunk: lib/ts/libts.h proxy/mgmt2/cli/CliUtils.cc proxy/mgmt2/cli/clientCLI.cc proxy/mgmt2/cli/clientCLI.h proxy/mgmt2/cop/Makefile.am proxy/mgmt2/cop/TrafficCop.cc

Author: zwoop
Date: Tue Jan 11 23:09:17 2011
New Revision: 1057918

URL: http://svn.apache.org/viewvc?rev=1057918&view=rev
Log:
TS-491 Added the CLI interface to TrafficCop

Modified:
    trafficserver/traffic/trunk/lib/ts/libts.h
    trafficserver/traffic/trunk/proxy/mgmt2/cli/CliUtils.cc
    trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.cc
    trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.h
    trafficserver/traffic/trunk/proxy/mgmt2/cop/Makefile.am
    trafficserver/traffic/trunk/proxy/mgmt2/cop/TrafficCop.cc

Modified: trafficserver/traffic/trunk/lib/ts/libts.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/libts.h?rev=1057918&r1=1057917&r2=1057918&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/libts.h (original)
+++ trafficserver/traffic/trunk/lib/ts/libts.h Tue Jan 11 23:09:17 2011
@@ -95,7 +95,6 @@
 #include "RawHashTable.h"
 #include "Regex.h"
 #include "Resource.h"
-#include "SimpleDBM.h"
 #include "SimpleTokenizer.h"
 #include "TextBuffer.h"
 #include "Tokenizer.h"

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cli/CliUtils.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cli/CliUtils.cc?rev=1057918&r1=1057917&r2=1057918&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cli/CliUtils.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cli/CliUtils.cc Tue Jan 11 23:09:17 2011
@@ -300,12 +300,9 @@ cli_write_timeout(int fd, const char *da
 int
 GetTSDirectory(char *ts_path, size_t ts_path_len)
 {
-
   ink_strncpy(ts_path, Layout::get()->bindir, ts_path_len);
-
   if (access(ts_path, R_OK) == -1) {
-    printf("unable to stat() '%s': %d, %s\n",
-              ts_path, errno, strerror(errno));
+    printf("unable to stat() '%s': %d, %s\n", ts_path, errno, strerror(errno));
     printf(" Please set correct path in env variable TS_ROOT \n");
     return -1;
   }

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.cc?rev=1057918&r1=1057917&r2=1057918&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.cc Tue Jan 11 23:09:17 2011
@@ -59,30 +59,9 @@ clientCLI::clientCLI(void)
   cliPort = clientCLI::defaultCliPort;
 #endif
   //coverity[uninit_member]
-}                               // end clientCLI(const char*)
-
-//
-// Default destructor
-//
-clientCLI::~clientCLI(void)
-{                               // nothing
-}                               // end ~clientCLI()
-
-#ifndef _WIN32
-int
-clientCLI::GetTSDirectory(char *ts_path, size_t ts_path_len)
-{
-
-  ink_strncpy(ts_path, Layout::get()->bindir, ts_path_len);
-  if (access(ts_path, R_OK) == -1) {
-    fprintf(stderr,"unable to access() '%s': %d, %s\n", ts_path, errno, strerror(errno));
-    fprintf(stderr," Please set correct path in env variable TS_ROOT \n");
-    return -1;
-  }
-
-  return 0;
 }
 
+#ifndef _WIN32
 void
 clientCLI::setSockPath(const char *path)
 {

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.h?rev=1057918&r1=1057917&r2=1057918&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.h (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.h Tue Jan 11 23:09:17 2011
@@ -53,11 +53,10 @@ public:
 
   static const char *CliResultStr[];
 
-    clientCLI(void);
-   ~clientCLI(void);
+  clientCLI(void);
+  ~clientCLI(void) {}
 
 #ifndef _WIN32
-   int GetTSDirectory(char *ts_path, size_t ts_path_len);
    void setSockPath(const char *path);
 #else
   void setCliPort(int port);
@@ -71,14 +70,6 @@ public:
   /* read response from manager */
   int readResponse(textBuffer * output, ink_hrtime timeout = -1);
 
-  /* get the Traffic Server version string          */
-  /*   - no need to connect before calling this     */
-  /*   - caller needs to free() the returned string */
-  char *getTSVersion(void)
-  {
-    return strdup(PACKAGE_VERSION);
-  }
-
   /* connects to manager using:
      - UNIX domain socket on UNIX
      - named pipe on NT */

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cop/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cop/Makefile.am?rev=1057918&r1=1057917&r2=1057918&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cop/Makefile.am (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cop/Makefile.am Tue Jan 11 23:09:17 2011
@@ -17,7 +17,8 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
-AM_CPPFLAGS = $(iocore_include_dirs)
+AM_CPPFLAGS = $(iocore_include_dirs) \
+  -I$(top_srcdir)/proxy/mgmt2/cli
 
 MGMT_DEFS = @MGMT_DEFS@
 DEFS += $(MGMT_DEFS)
@@ -27,6 +28,7 @@ bin_PROGRAMS = traffic_cop
 traffic_cop_SOURCES = TrafficCop.cc
 traffic_cop_LDFLAGS = @EXTRA_CXX_LDFLAGS@
 traffic_cop_LDADD = \
+  $(top_builddir)/proxy/mgmt2/cli/libcli_tl.a \
   $(top_builddir)/lib/ts/libts.a \
   $(top_builddir)/iocore/utils/libinkutils.a \
   @LIBTCL@ \

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cop/TrafficCop.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cop/TrafficCop.cc?rev=1057918&r1=1057917&r2=1057918&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cop/TrafficCop.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cop/TrafficCop.cc Tue Jan 11 23:09:17 2011
@@ -24,6 +24,7 @@
 #include "libts.h"
 #include "I_Layout.h"
 #include "I_Version.h"
+#include "clientCLI.h"
 
 #if defined(linux)
 #include "sys/utsname.h"
@@ -1254,7 +1255,6 @@ heartbeat_manager()
   cop_log(COP_DEBUG, "Entering heartbeat_manager()\n");
 #endif
   err = test_rs_port();
-
   if (err < 0) {
     manager_failures += 1;
     cop_log(COP_WARNING, "manager heartbeat [variable] failed [%d]\n", manager_failures);
@@ -1660,6 +1660,9 @@ check(void *arg)
 
       child_pid = child_status = 0;
     }
+    // Get a new CLI
+    clientCLI *cli = new clientCLI();
+
     // Re-read the config file information
     read_config();
 
@@ -1669,6 +1672,9 @@ check(void *arg)
     // Check to see if we're running out of free memory
     check_memory();
 
+    // Get rid of the CLI
+    delete cli;
+
     // Pause to catch our breath. (10 seconds).
     // Use 'millisleep()' because normal 'sleep()' interferes with
     // the SIGALRM signal which we use to heartbeat the cop.