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 2019/07/22 14:38:57 UTC

[trafficserver] 05/07: Removes the memcached_remap plugin. See #5395

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit f8c8d252c64989bb0ed821f6ce476fd857fc1824
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri Jul 19 13:41:49 2019 -0600

    Removes the memcached_remap plugin. See #5395
---
 configure.ac                                       |   6 -
 plugins/Makefile.am                                |   4 -
 plugins/experimental/memcached_remap/AUTHORS       |   7 -
 plugins/experimental/memcached_remap/Changelog     |   5 -
 plugins/experimental/memcached_remap/Makefile.inc  |  24 ---
 plugins/experimental/memcached_remap/README        | 113 ------------
 .../memcached_remap/memcached_remap.cc             | 192 ---------------------
 plugins/experimental/memcached_remap/sample.py     |  33 ----
 8 files changed, 384 deletions(-)

diff --git a/configure.ac b/configure.ac
index 57b80cf..424bebe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -510,12 +510,6 @@ AC_MSG_RESULT([$enable_experimental_plugins])
 AM_CONDITIONAL([BUILD_EXPERIMENTAL_PLUGINS], [ test "x${enable_experimental_plugins}" = "xyes" ])
 
 #
-# Enable experimental/memcached_remap plugin
-#
-PKG_CHECK_MODULES([LIBMEMCACHED], [libmemcached >= 1.0], [have_libmemcached=yes], [have_libmemcached=no])
-AM_CONDITIONAL([BUILD_MEMCACHED_REMAP_PLUGIN], [test "x${have_libmemcached}" = "xyes"])
-
-#
 # Check Magick++ is available. Enable experimental/webp_transform plugin
 #
 PKG_CHECK_MODULES([LIBMAGICKCPP],[Magick++ >= 7], [
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index d11e100..f942ae7 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -93,10 +93,6 @@ if BUILD_SSL_SESSION_REUSE_PLUGIN
 include experimental/ssl_session_reuse/Makefile.inc
 endif
 
-if BUILD_MEMCACHED_REMAP_PLUGIN
-include experimental/memcached_remap/Makefile.inc
-endif
-
 if BUILD_REMAP_STATS_PLUGIN
 include experimental/remap_stats/Makefile.inc
 endif
diff --git a/plugins/experimental/memcached_remap/AUTHORS b/plugins/experimental/memcached_remap/AUTHORS
deleted file mode 100644
index 945968f..0000000
--- a/plugins/experimental/memcached_remap/AUTHORS
+++ /dev/null
@@ -1,7 +0,0 @@
-Author: opensource@navyaprabha.com
-
-memcached_remap plugin
-
-========= CREDITS ===============
-Eric Balsa <er...@apache.org>
-Original concept via mysql_remap plugin
diff --git a/plugins/experimental/memcached_remap/Changelog b/plugins/experimental/memcached_remap/Changelog
deleted file mode 100644
index 0e9b96d..0000000
--- a/plugins/experimental/memcached_remap/Changelog
+++ /dev/null
@@ -1,5 +0,0 @@
-1.0.0 20-May-2011
-	* Initial Release for 2.1.8-unstable apache release
-1.0.0 14-Oct-2015
-	* added autoconf changes and Makefile.am so this plugin may be built
-		when configure --enable-experimental-plugins is used.
diff --git a/plugins/experimental/memcached_remap/Makefile.inc b/plugins/experimental/memcached_remap/Makefile.inc
deleted file mode 100644
index cb893b0..0000000
--- a/plugins/experimental/memcached_remap/Makefile.inc
+++ /dev/null
@@ -1,24 +0,0 @@
-#  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.
-
-experimental_memcached_remap_memcached_remap_la__CXXFLAGS = $(AM_CXXFLAGS) $(LIBMEMCACHED_CFLAGS)
-
-pkglib_LTLIBRARIES += experimental/memcached_remap/memcached_remap.la
-
-experimental_memcached_remap_memcached_remap_la_SOURCES = \
-  experimental/memcached_remap/memcached_remap.cc
-
-experimental_memcached_remap_memcached_remap_la_LIBADD = $(LIBMEMCACHED_LIBS)
diff --git a/plugins/experimental/memcached_remap/README b/plugins/experimental/memcached_remap/README
deleted file mode 100644
index 248341f..0000000
--- a/plugins/experimental/memcached_remap/README
+++ /dev/null
@@ -1,113 +0,0 @@
-Apache Traffic Server Memcached-based remap plugin
-==============================================
-
-This is a plugin which is based on the mysql_remap code (https://github.com/apache/trafficserver/tree/master/plugins/experimental/mysql_remap)
-that allows us to do dynamic reverse proxy (dynamic remap) based on the
-information present in the memcached database.
-
-                                     (decision via memcached)
-[Browser] <----> [Apache Traffic Server] <----------> [Backend Servers]
-                                     (decision via memcached)
-
-NOTE: memcached is used only as decision making place. All communication
-happens via HTTP between above components
-
-##################
-#   QUICK HOWTO  #
-##################
-
-The following steps are for Fedora-14 System, same will apply to your
-server too (please change things accordingly, if any)
-
-1. Install memcached
-
-sudo yum install memcached python-memcached
-
-2. Compile and Install the memcached_remap plugin
-
-  To build this with the ATS configure script when
-  --enable-experimental-plugins is used, you must
-  have libmemcached version 1.0 or greater installed.
-
-3. Start Traffic Server with logging (to debug any issues)
-
-/usr/local/bin/traffic_server -T "memcached_remap"
-
-3. Start the memcached
-
-sudo service memcached
-
-4. Start apache on port 8080 (change configs accordingly)
-
-sudo service httpd start
-
-5. Add some keys into the memcached for testing (via python shell)
-
-[user@ memcached_remap]$ python
-Python 2.7 (r27:82500, Sep 16 2010, 18:02:00)
-[GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2
-Type "help", "copyright", "credits" or "license" for more information.
->>> import memcache
->>> mc = memcache.Client(['127.0.0.1:11211'], debug=0)
->>> print mc.get("http://localhost:80/")
-http://localhost:8080/
->>> print mc.get("http://localhost:80/")
-http://localhost:8080/
->>> mc.set("http://127.0.0.1:80/", "http://127.0.0.1:8080");
-True
->>> print mc.get("http://127.0.0.1:80/")
-http://127.0.0.1:8080
->>>
-
-6. Do sample query on localhost port 80
-
-[user@ ~]$ curl -v http://127.0.0.1/ -s > /dev/null
-* About to connect() to 127.0.0.1 port 80 (#0)
-*   Trying 127.0.0.1... connected
-* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
-> GET / HTTP/1.1
-> User-Agent: curl/7.21.0 (x86_64-redhat-linux-gnu) libcurl/7.21.0
-> NSS/3.12.8.0 zlib/1.2.5 libidn/1.18 libssh2/1.2.4
-> Host: 127.0.0.1
-> Accept: */*
->
-< HTTP/1.1 200 OK
-< Date: Wed, 09 Mar 2011 15:48:25 GMT
-< Server: ATS/2.1.6-unstable
-< Last-Modified: Sat, 05 Mar 2011 16:15:13 GMT
-< ETag: "618ef-38b-49dbe914322ed"
-< Accept-Ranges: bytes
-< Content-Length: 907
-< Content-Type: text/html; charset=UTF-8
-< Age: 0
-< Connection: keep-alive
-<
-{ [data not shown]
-* Connection #0 to host 127.0.0.1 left intact
-* Closing connection #0
-
-7. Thats it !
-
-################################
-#  SUPPORTED KEYS IN MEMCACHED #
-################################
-
-The advantage of memcached is that, its a hash table.
-
-KEY FORMAT:    [PROTOCOL]://[SERVER]:[PORT]/
---------------------------------------------
-(Even ending / is important!)
-
-PROTOCOL can be any word in a-z, A-Z chars
-SERVER   can be any string which isn't a colon character
-PORT     should be a number
-/        should end with a slash
-
-VALUE FORMAT:  [PROTOCOL]://[SERVER]:[PORT]/
---------------------------------------------
-(Even ending / is important!)
-
-PROTOCOL can be any word created from a-z, A-Z chars
-SERVER   can be any string which isn't a colon character
-PORT     should be a number
-/        should end with a slash
diff --git a/plugins/experimental/memcached_remap/memcached_remap.cc b/plugins/experimental/memcached_remap/memcached_remap.cc
deleted file mode 100644
index e6b2834..0000000
--- a/plugins/experimental/memcached_remap/memcached_remap.cc
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
-  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 <ts/ts.h>
-#include <ts/remap.h>
-#include <cstdio>
-#include <cstring>
-#include <unistd.h>
-
-#include <libmemcached/memcached.h>
-
-// global settings
-static const char *PLUGIN_NAME = "memcached_remap";
-
-// memcached related global variables
-memcached_server_st *servers;
-memcached_st *memc;
-
-bool
-do_memcached_remap(TSCont contp, TSHttpTxn txnp)
-{
-  TSMBuffer reqp;
-  TSMLoc hdr_loc, url_loc, field_loc;
-  bool ret_val = false;
-
-  const char *request_host;
-  int request_host_length = 0;
-  const char *request_scheme;
-  int request_scheme_length = 0;
-  int request_port          = 80;
-  char ikey[1024];
-  char *m_result = nullptr;
-  size_t oval_length;
-  uint32_t flags;
-  memcached_return_t lrc;
-
-  if (TSHttpTxnClientReqGet((TSHttpTxn)txnp, &reqp, &hdr_loc) != TS_SUCCESS) {
-    TSDebug(PLUGIN_NAME, "could not get request data");
-    return false;
-  }
-
-  if (TSHttpHdrUrlGet(reqp, hdr_loc, &url_loc) != TS_SUCCESS) {
-    TSDebug(PLUGIN_NAME, "couldn't retrieve request url");
-    goto release_hdr;
-  }
-
-  field_loc = TSMimeHdrFieldFind(reqp, hdr_loc, TS_MIME_FIELD_HOST, TS_MIME_LEN_HOST);
-
-  if (!field_loc) {
-    TSDebug(PLUGIN_NAME, "couldn't retrieve request HOST header");
-    goto release_url;
-  }
-
-  request_host = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field_loc, -1, &request_host_length);
-  if (request_host == nullptr || strlen(request_host) < 1) {
-    TSDebug(PLUGIN_NAME, "couldn't find request HOST header");
-    goto release_field;
-  }
-
-  request_scheme = TSUrlSchemeGet(reqp, url_loc, &request_scheme_length);
-  request_port   = TSUrlPortGet(reqp, url_loc);
-
-  TSDebug(PLUGIN_NAME, "      +++++MEMCACHED REMAP+++++      ");
-
-  TSDebug(PLUGIN_NAME, "\nINCOMING REQUEST ->\n ::: from_scheme_desc: %.*s\n ::: from_hostname: %.*s\n ::: from_port: %d",
-          request_scheme_length, request_scheme, request_host_length, request_host, request_port);
-
-  snprintf(ikey, 1024, "%.*s://%.*s:%d/", request_scheme_length, request_scheme, request_host_length, request_host, request_port);
-
-  TSDebug(PLUGIN_NAME, "querying for the key %s", ikey);
-  m_result = memcached_get(memc, ikey, strlen(ikey), &oval_length, &flags, &lrc);
-
-  char oscheme[1024], ohost[1024];
-  int oport;
-
-  if (lrc == MEMCACHED_SUCCESS) {
-    TSDebug(PLUGIN_NAME, "got the response from server : %s", m_result);
-    TSDebug(PLUGIN_NAME, "scanf result : %d", sscanf(m_result, "%[a-zA-Z]://%[^:]:%d", oscheme, ohost, &oport));
-    if (sscanf(m_result, "%[a-zA-Z]://%[^:]:%d", oscheme, ohost, &oport) == 3) {
-      if (m_result)
-        free(m_result);
-      TSDebug(PLUGIN_NAME, "\nOUTGOING REQUEST ->\n ::: to_scheme_desc: %s\n ::: to_hostname: %s\n ::: to_port: %d", oscheme, ohost,
-              oport);
-      TSMimeHdrFieldValueStringSet(reqp, hdr_loc, field_loc, 0, ohost, -1);
-      TSUrlHostSet(reqp, url_loc, ohost, -1);
-      TSUrlSchemeSet(reqp, url_loc, oscheme, -1);
-      TSUrlPortSet(reqp, url_loc, oport);
-      ret_val = true;
-    } else {
-      if (m_result)
-        free(m_result);
-      goto not_found;
-    }
-  } else {
-    TSDebug(PLUGIN_NAME, "didn't get any response from the server %d, %d, %d", lrc, flags, (int)oval_length);
-    goto not_found;
-  }
-
-  goto release_field; // free the result set after processed
-
-not_found:
-  // lets build up a nice 404 message for someone
-  if (!ret_val) {
-    TSHttpHdrStatusSet(reqp, hdr_loc, TS_HTTP_STATUS_NOT_FOUND);
-    TSHttpTxnStatusSet(txnp, TS_HTTP_STATUS_NOT_FOUND);
-  }
-release_field:
-  if (field_loc) {
-    TSHandleMLocRelease(reqp, hdr_loc, field_loc);
-  }
-release_url:
-  if (url_loc) {
-    TSHandleMLocRelease(reqp, hdr_loc, url_loc);
-  }
-release_hdr:
-  if (hdr_loc) {
-    TSHandleMLocRelease(reqp, TS_NULL_MLOC, hdr_loc);
-  }
-
-  return ret_val;
-}
-
-static int
-memcached_remap(TSCont contp, TSEvent event, void *edata)
-{
-  TSHttpTxn txnp   = (TSHttpTxn)edata;
-  TSEvent reenable = TS_EVENT_HTTP_CONTINUE;
-
-  if (event == TS_EVENT_HTTP_READ_REQUEST_HDR) {
-    TSDebug(PLUGIN_NAME, "Reading Request");
-    TSSkipRemappingSet(txnp, 1);
-    if (!do_memcached_remap(contp, txnp)) {
-      reenable = TS_EVENT_HTTP_ERROR;
-    }
-  }
-
-  TSHttpTxnReenable(txnp, reenable);
-  return 1;
-}
-
-void
-TSPluginInit(int argc, const char *argv[])
-{
-  TSPluginRegistrationInfo info;
-  memcached_return_t rc;
-
-  info.plugin_name   = const_cast<char *>(PLUGIN_NAME);
-  info.vendor_name   = const_cast<char *>("Apache Software Foundation");
-  info.support_email = const_cast<char *>("dev@trafficserver.apache.org");
-
-  TSDebug(PLUGIN_NAME, "about to init memcached");
-  if (TSPluginRegister(&info) != TS_SUCCESS) {
-    TSError("[memcached_remap] Plugin registration failed");
-    return;
-  }
-
-  memc = memcached_create(NULL);
-
-  servers = memcached_server_list_append(NULL, "localhost", 11211, &rc);
-  if (rc != MEMCACHED_SUCCESS) {
-    TSError("[memcached_remap] Plugin registration failed while adding servers.\n");
-    return;
-  }
-
-  rc = memcached_server_push(memc, servers);
-  if (rc != MEMCACHED_SUCCESS) {
-    TSError("[memcached_remap] Plugin registration failed while adding to pool.\n");
-    return;
-  }
-
-  TSCont cont = TSContCreate(memcached_remap, TSMutexCreate());
-
-  TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, cont);
-
-  TSDebug(PLUGIN_NAME, "plugin is successfully initialized [plugin mode]");
-  return;
-}
diff --git a/plugins/experimental/memcached_remap/sample.py b/plugins/experimental/memcached_remap/sample.py
deleted file mode 100755
index 01466cd..0000000
--- a/plugins/experimental/memcached_remap/sample.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/python
-#
-# 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.
-
-# Author: opensource@navyaprabha.com
-# Description: Sample script to add keys to memcached for use with YTS/memcached_remap plugin
-
-import memcache
-
-# connect to local server
-mc = memcache.Client(['127.0.0.1:11211'], debug=0)
-
-# Add couple of keys
-mc.set("http://127.0.0.1:80/", "http://127.0.0.1:8080")
-mc.set("http://localhost:80/", "http://localhost:8080")
-
-# Print the keys that are saved
-print "response-1 is '%s'" % (mc.get("http://127.0.0.1:80/"))
-print "response-2 is '%s'" % (mc.get("http://localhost:80/"))