trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject svn commit: r1061008 - in /trafficserver/traffic/trunk/mgmt: Makefile.am api/include/INKMgmtAPI.h cli/CliMain.cc cli/Makefile.am cli2/Makefile.am cli2/TrafficLine.cc
Date Wed, 19 Jan 2011 21:34:58 GMT
Author: zwoop
Date: Wed Jan 19 21:34:57 2011
New Revision: 1061008

URL: http://svn.apache.org/viewvc?rev=1061008&view=rev
Log:
TS-638 Moved traffic_line over to cli2, mostly functional

Added:
    trafficserver/traffic/trunk/mgmt/cli2/TrafficLine.cc
Removed:
    trafficserver/traffic/trunk/mgmt/cli/CliMain.cc
Modified:
    trafficserver/traffic/trunk/mgmt/Makefile.am
    trafficserver/traffic/trunk/mgmt/api/include/INKMgmtAPI.h
    trafficserver/traffic/trunk/mgmt/cli/Makefile.am
    trafficserver/traffic/trunk/mgmt/cli2/Makefile.am

Modified: trafficserver/traffic/trunk/mgmt/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/Makefile.am?rev=1061008&r1=1061007&r2=1061008&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/Makefile.am (original)
+++ trafficserver/traffic/trunk/mgmt/Makefile.am Wed Jan 19 21:34:57 2011
@@ -18,9 +18,9 @@
 #  limitations under the License.
 
 if BUILD_WEBUI
-SUBDIRS = cli cluster preparse tools utils web2 html2 stats api $(CLI_DIR)
+SUBDIRS = cluster preparse tools utils web2 html2 stats api $(CLI_DIR)
 else
-SUBDIRS = cli cluster preparse tools utils web2 stats api $(CLI_DIR)
+SUBDIRS = cluster preparse tools utils web2 stats api $(CLI_DIR)
 endif
 
 DIST_SUBDIRS = $(SUBDIRS)
@@ -99,7 +99,6 @@ traffic_manager_LDADD = \
   preparse/libpreparse.a \
   stats/libstats.a \
   web2/libweb.a \
-  cli/libcli_lm.a \
   api/libmgmtapilocal.a \
   utils/libutils_lm.a \
   $(top_builddir)/proxy/hdrs/libhdrs.a \

Modified: trafficserver/traffic/trunk/mgmt/api/include/INKMgmtAPI.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/api/include/INKMgmtAPI.h?rev=1061008&r1=1061007&r2=1061008&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/api/include/INKMgmtAPI.h (original)
+++ trafficserver/traffic/trunk/mgmt/api/include/INKMgmtAPI.h Wed Jan 19 21:34:57 2011
@@ -269,6 +269,7 @@ extern "C"
     INK_ICP_UNDEFINED
   } INKIcpT;
 
+  /* TODO: This should be removed */
   typedef enum                  /* access privileges to news articles cached by Traffic Server
 */
   {
     INK_IP_ALLOW_ALLOW,

Modified: trafficserver/traffic/trunk/mgmt/cli/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/cli/Makefile.am?rev=1061008&r1=1061007&r2=1061008&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/cli/Makefile.am (original)
+++ trafficserver/traffic/trunk/mgmt/cli/Makefile.am Wed Jan 19 21:34:57 2011
@@ -32,8 +32,6 @@ DEFS += $(MGMT_DEFS)
 
 noinst_LIBRARIES = libcli_lm.a libcli_tl.a
 
-bin_PROGRAMS = traffic_line
-
 libcli_tl_a_SOURCES = \
   clientCLI.cc \
   clientCLI.h \
@@ -57,16 +55,3 @@ libcli_lm_a_SOURCES = \
   CliUtils.h \
   FSM.cc \
   FSM.h
-
-traffic_line_SOURCES = \
-  clientCLI.h \
-  CliMain.cc
-
-traffic_line_LDFLAGS = @EXTRA_CXX_LDFLAGS@
-traffic_line_LDADD = \
-  libcli_tl.a \
-  $(top_builddir)/lib/ts/libts.a \
-  $(top_builddir)/lib/records/libreclocal.a \
-  $(top_builddir)/iocore/utils/libinkutils.a \
-  @LIBTHREAD@ @LIBSOCKET@ @LIBNSL@ @LIBRESOLV@ \
-  @LIBTCL@ @LIBRT@ @LIBDL@ @LIBICONV@ @LIBEXECINFO@

Modified: trafficserver/traffic/trunk/mgmt/cli2/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/cli2/Makefile.am?rev=1061008&r1=1061007&r2=1061008&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/cli2/Makefile.am (original)
+++ trafficserver/traffic/trunk/mgmt/cli2/Makefile.am Wed Jan 19 21:34:57 2011
@@ -25,7 +25,7 @@ AM_CPPFLAGS = \
   -I$(top_srcdir)/mgmt/tools
 
 
-bin_PROGRAMS = traffic_shell
+bin_PROGRAMS = traffic_shell traffic_line
 traffic_shell_SOURCES = \
   cliAppInit.cc \
   CliCreateCommands.h \
@@ -38,6 +38,9 @@ traffic_shell_SOURCES = \
   hashtable.h \
   ShowCmd.h
 
+traffic_line_SOURCES = \
+  TrafficLine.cc
+
 noinst_LIBRARIES = libtrafficshell.a
 libtrafficshell_a_SOURCES = \
   CliCreateCommands.cc \
@@ -69,7 +72,6 @@ libtrafficshell_a_SOURCES = \
   UtilCmds.h
 
 traffic_shell_LDFLAGS =	$(EXTRA_CXX_LDFLAGS)
-
 traffic_shell_LDADD = \
   libtrafficshell.a \
   $(top_builddir)/mgmt/api/remote/libmgmtapiremote.a \
@@ -85,3 +87,11 @@ traffic_shell_LDADD = \
   @LIBEXPAT@ @LIBSSL@ \
   @LIBTHREAD@ @LIBSOCKET@ @LIBNSL@ @LIBRESOLV@ \
   @LIBRT@ @LIBEXECINFO@ @LIBPCRE@
+
+
+traffic_line_LDFLAGS = @EXTRA_CXX_LDFLAGS@
+traffic_line_LDADD = \
+  $(top_builddir)/mgmt/api/remote/libmgmtapiremote.a \
+  $(top_builddir)/iocore/utils/libinkutils.a \
+  $(top_builddir)/lib/ts/libts.a \
+  @LIBTHREAD@ @LIBSOCKET@ @LIBNSL@ @LIBTCL@ @LIBICONV@ @LIBRT@ @LIBDL@ @LIBSSL@ 

Added: trafficserver/traffic/trunk/mgmt/cli2/TrafficLine.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/cli2/TrafficLine.cc?rev=1061008&view=auto
==============================================================================
--- trafficserver/traffic/trunk/mgmt/cli2/TrafficLine.cc (added)
+++ trafficserver/traffic/trunk/mgmt/cli2/TrafficLine.cc Wed Jan 19 21:34:57 2011
@@ -0,0 +1,159 @@
+/** @file
+
+  A brief file description
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with 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.
+ */
+
+#include "libts.h"
+
+#include "ink_args.h"
+#include "I_Layout.h"
+#include "I_Version.h"
+#include "Tokenizer.h"
+#include "TextBuffer.h"
+#include "INKMgmtAPI.h"
+
+static const char *programName;
+
+static char readVar[1024];
+static char setVar[1024];
+static char varValue[1024];
+static int reRead;
+static int Shutdown;
+static int BounceCluster;
+static int BounceLocal;
+static int QueryDeadhosts;
+static int Startup;
+static int ShutdownMgmtCluster;
+static int ShutdownMgmtLocal;
+static int ClearCluster;
+static int ClearNode;
+static int VersionFlag;
+
+static INKError
+handleArgInvocation()
+{
+  if (reRead == 1) {
+    return INKReconfigure();
+  } else if (ShutdownMgmtCluster == 1) {
+    return INKRestart(true);
+  } else if (ShutdownMgmtLocal == 1) {
+    return INKRestart(false);
+  } else if (Shutdown == 1) {
+    return INKProxyStateSet(INK_PROXY_OFF, INK_CACHE_CLEAR_OFF);
+  } else if (BounceCluster == 1) {
+  } else if (BounceLocal == 1) {
+  } else if (Startup == 1) {
+    return INKProxyStateSet(INK_PROXY_ON, INK_CACHE_CLEAR_OFF);
+  } else if (ClearCluster == 1) {
+  } else if (ClearNode == 1) {
+  } else if (QueryDeadhosts == 1) {
+  } else if (*readVar != '\0') {        // Handle a value read
+    if (*setVar != '\0' || *varValue != '\0') {
+      fprintf(stderr, "%s: Invalid Argument Combination: Can not read and set values at the
same time\n", programName);
+      return INK_ERR_FAIL;
+    } else {
+    }
+  } else if (*setVar != '\0') { // Setting a variable
+    if (*varValue == '\0') {
+      fprintf(stderr, "%s: Set requires a -v argument\n", programName);
+      return INK_ERR_FAIL;
+    } else {
+    }
+  } else if (*varValue != '\0') {       // We have a value but no variable to set
+    fprintf(stderr, "%s: Must specify variable to set with -s when using -v\n", programName);
+    return INK_ERR_FAIL;
+  }
+
+  fprintf(stderr, "%s: No arguments specified\n", programName);
+  return INK_ERR_FAIL;
+}
+
+int
+main(int argc, char **argv)
+{
+  NOWARN_UNUSED(argc);
+  AppVersionInfo appVersionInfo;
+  INKError status;
+
+  programName = argv[0];
+
+  readVar[0] = '\0';
+  setVar[0] = '\0';
+  varValue[0] = '\0';
+  reRead = 0;
+  Shutdown = 0;
+  BounceCluster = 0;
+  BounceLocal = 0;
+  QueryDeadhosts = 0;
+  Startup = 0;
+  ShutdownMgmtCluster = 0;
+  ShutdownMgmtLocal = 0;
+  ClearCluster = 0;
+  ClearNode = 0;
+  VersionFlag = 0;
+
+  // build the application information structure
+  appVersionInfo.setup(PACKAGE_NAME,"traffic_line", PACKAGE_VERSION, __DATE__, __TIME__,
BUILD_MACHINE, BUILD_PERSON, "");
+
+/* Argument description table used to describe how to parse command line args, */
+/* see 'ink_args.h' for meanings of the various fields */
+  ArgumentDescription argument_descriptions[] = {
+    {"query_deadhosts", 'q', "Query congested sites", "F", &QueryDeadhosts, NULL, NULL},
+    {"read_var", 'r', "Read Variable", "S1024", &readVar, NULL, NULL},
+    {"set_var", 's', "Set Variable (requires -v option)", "S1024", &setVar, NULL, NULL},
+    {"value", 'v', "Set Value (used with -s option)", "S1024", &varValue, NULL, NULL},
+    {"help", 'h', "Help", NULL, NULL, NULL, usage},
+    {"reread_config", 'x', "Reread Config Files", "F", &reRead, NULL, NULL},
+    {"restart_cluster", 'M', "Restart traffic_manager (cluster wide)", "F", &ShutdownMgmtCluster,
NULL, NULL},
+    {"restart_local", 'L', "Restart traffic_manager (local node)", "F", &ShutdownMgmtLocal,
NULL, NULL},
+    {"shutdown", 'S', "Shutdown traffic_server (local node)", "F", &Shutdown, NULL, NULL},
+    {"startup", 'U', "Start traffic_server (local node)", "F", &Startup, NULL, NULL},
+    {"bounce_cluster", 'B', "Bounce traffic_server (cluster wide)", "F", &BounceCluster,
NULL, NULL},
+    {"bounce_local", 'b', "Bounce local traffic_server", "F", &BounceLocal, NULL, NULL},
+    {"clear_cluster", 'C', "Clear Statistics (cluster wide)", "F", &ClearCluster, NULL,
NULL},
+    {"clear_node", 'c', "Clear Statistics (local node)", "F", &ClearNode, NULL, NULL},
+    {"version", 'V', "Print Version Id", "T", &VersionFlag, NULL, NULL},
+  };
+
+  // Process command line arguments and dump into variables
+  process_args(argument_descriptions, SIZE(argument_descriptions), argv);
+
+  // check for the version number request
+  if (VersionFlag) {
+    ink_fputln(stderr, appVersionInfo.FullVersionInfoStr);
+    exit(0);
+  }
+
+  // Connect to Local Manager
+  Layout::create();
+  INKInit(Layout::get()->runtimedir, static_cast<TSInitOptionT>(TS_MGMT_OPT_NO_EVENTS
| TS_MGMT_OPT_NO_SOCK_TESTS));
+
+  // Do it
+  status = handleArgInvocation();
+
+  // Done with the mgmt API.
+  INKTerminate();
+  if (INK_ERR_OKAY != status) {
+    fprintf(stderr, "error: the requested command failed\n");
+    exit(1);
+  }
+  exit(0);
+}



Mime
View raw message