Repository: trafficserver Updated Branches: refs/heads/master e427342b9 -> 08e27ba98
TS-2118: add the memcached_remap plugin to the build Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/08e27ba9 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/08e27ba9 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/08e27ba9 Branch: refs/heads/master Commit: 08e27ba984b11610e4544da6be8e1270d66e1f5f Parents: e427342 Author: John Rushford <[email protected]> Authored: Thu Oct 15 08:22:15 2015 -0700 Committer: James Peach <[email protected]> Committed: Thu Oct 15 08:22:15 2015 -0700 ---------------------------------------------------------------------- configure.ac | 7 +++++ plugins/experimental/Makefile.am | 1 + plugins/experimental/memcached_remap/Changelog | 3 +++ .../experimental/memcached_remap/Makefile.am | 28 ++++++++++++++++++++ plugins/experimental/memcached_remap/README | 13 ++++++--- .../memcached_remap/memcached_remap.cc | 12 ++++----- 6 files changed, 54 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/08e27ba9/configure.ac ---------------------------------------------------------------------- diff --git a/configure.ac b/configure.ac index 1dfffd3..b39e56e 100644 --- a/configure.ac +++ b/configure.ac @@ -408,6 +408,12 @@ 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"]) + +# # Example plugins. The example plugins are always built, but not always installed. Installing # them is useful for QA, but not useful for most users, so we default this to disabled. # @@ -1905,6 +1911,7 @@ AS_IF([test "x$enable_experimental_plugins" = "xyes"], [ plugins/experimental/header_normalize/Makefile plugins/experimental/healthchecks/Makefile plugins/experimental/hipes/Makefile + plugins/experimental/memcached_remap/Makefile plugins/experimental/metalink/Makefile plugins/experimental/mysql_remap/Makefile plugins/experimental/regex_revalidate/Makefile http://git-wip-us.apache.org/repos/asf/trafficserver/blob/08e27ba9/plugins/experimental/Makefile.am ---------------------------------------------------------------------- diff --git a/plugins/experimental/Makefile.am b/plugins/experimental/Makefile.am index f7e0e94..98f8293 100644 --- a/plugins/experimental/Makefile.am +++ b/plugins/experimental/Makefile.am @@ -32,6 +32,7 @@ SUBDIRS = \ healthchecks \ hipes \ metalink \ + memcached_remap \ regex_revalidate \ remap_stats \ s3_auth \ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/08e27ba9/plugins/experimental/memcached_remap/Changelog ---------------------------------------------------------------------- diff --git a/plugins/experimental/memcached_remap/Changelog b/plugins/experimental/memcached_remap/Changelog index 3d16c80..0e9b96d 100644 --- a/plugins/experimental/memcached_remap/Changelog +++ b/plugins/experimental/memcached_remap/Changelog @@ -1,2 +1,5 @@ 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. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/08e27ba9/plugins/experimental/memcached_remap/Makefile.am ---------------------------------------------------------------------- diff --git a/plugins/experimental/memcached_remap/Makefile.am b/plugins/experimental/memcached_remap/Makefile.am new file mode 100644 index 0000000..0ac0e91 --- /dev/null +++ b/plugins/experimental/memcached_remap/Makefile.am @@ -0,0 +1,28 @@ +# 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 $(top_srcdir)/build/plugins.mk + +if BUILD_MEMCACHED_REMAP_PLUGIN + +AM_CXXFLAGS += $(LIBMEMCACHED_CFLAGS) + +pkglib_LTLIBRARIES = memcached_remap.la +memcached_remap_la_SOURCES = memcached_remap.cc +memcached_remap_la_LDFLAGS = $(TS_PLUGIN_LDFLAGS) +memcached_remap_la_LIBADD = $(LIBMEMCACHED_LIBS) + +endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/08e27ba9/plugins/experimental/memcached_remap/README ---------------------------------------------------------------------- diff --git a/plugins/experimental/memcached_remap/README b/plugins/experimental/memcached_remap/README index 11de80c..449060d 100644 --- a/plugins/experimental/memcached_remap/README +++ b/plugins/experimental/memcached_remap/README @@ -23,6 +23,11 @@ server too (please change things accordingly, if any) sudo yum install memcached python-memcached +NOTE 14-OCT-2015: + To build this with the ATS configure script when + --enable-experimental-plugins is used, you must + have libmemcached version 1.0 or greater installed. + 2. Compile and Install the memcached_remap plugin [user@ memcached_remap]$ gmake @@ -53,7 +58,7 @@ 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) +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 @@ -66,7 +71,7 @@ http://localhost: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 @@ -79,7 +84,7 @@ http://127.0.0.1:8080 > 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 @@ -90,7 +95,7 @@ http://127.0.0.1:8080 < 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 http://git-wip-us.apache.org/repos/asf/trafficserver/blob/08e27ba9/plugins/experimental/memcached_remap/memcached_remap.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/memcached_remap/memcached_remap.cc b/plugins/experimental/memcached_remap/memcached_remap.cc index 8bff79a..05046ff 100644 --- a/plugins/experimental/memcached_remap/memcached_remap.cc +++ b/plugins/experimental/memcached_remap/memcached_remap.cc @@ -84,15 +84,15 @@ do_memcached_remap(TSCont contp, TSHttpTxn txnp) 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\n", ikey); + 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\n", m_result); - TSDebug(PLUGIN_NAME, "scanf result : %d\n", sscanf(m_result, "%[a-zA-Z]://%[^:]:%d", oscheme, ohost, &oport)); + 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); @@ -109,7 +109,7 @@ do_memcached_remap(TSCont contp, TSHttpTxn txnp) goto not_found; } } else { - TSDebug(PLUGIN_NAME, "didn't get any response from the server %d, %d, %d\n", lrc, flags, oval_length); + TSDebug(PLUGIN_NAME, "didn't get any response from the server %d, %d, %d", lrc, flags, (int)oval_length); goto not_found; } @@ -171,9 +171,9 @@ TSPluginInit(int argc, const char *argv[]) info.vendor_name = const_cast<char *>("Apache Software Foundation"); info.support_email = const_cast<char *>("[email protected]"); - TSDebug(PLUGIN_NAME, "about to init memcached\n"); + TSDebug(PLUGIN_NAME, "about to init memcached"); if (TSPluginRegister(&info) != TS_SUCCESS) { - TSError("[memcached_remap] Plugin registration failed.\n"); + TSError("[memcached_remap] Plugin registration failed."); return; }
