trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bc...@apache.org
Subject svn commit: r1201960 - in /trafficserver/plugins/trunk/balancer: ./ LICENSE README balancer.cc hashkey.h resources.h
Date Mon, 14 Nov 2011 23:09:44 GMT
Author: bcall
Date: Mon Nov 14 23:09:44 2011
New Revision: 1201960

URL: http://svn.apache.org/viewvc?rev=1201960&view=rev
Log:
Added plugin to load balance traffic.  Code from Yahoo!.

Added:
    trafficserver/plugins/trunk/balancer/
    trafficserver/plugins/trunk/balancer/LICENSE
    trafficserver/plugins/trunk/balancer/README
    trafficserver/plugins/trunk/balancer/balancer.cc
    trafficserver/plugins/trunk/balancer/hashkey.h
    trafficserver/plugins/trunk/balancer/resources.h

Added: trafficserver/plugins/trunk/balancer/LICENSE
URL: http://svn.apache.org/viewvc/trafficserver/plugins/trunk/balancer/LICENSE?rev=1201960&view=auto
==============================================================================
--- trafficserver/plugins/trunk/balancer/LICENSE (added)
+++ trafficserver/plugins/trunk/balancer/LICENSE Mon Nov 14 23:09:44 2011
@@ -0,0 +1,427 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+
+~~~
+
+Copyright (C) 2009 Yahoo! Inc.
+
+Licensed 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
+
+~~~
+
+Mersenne Twister License
+
+   Copyright (C) 2004, Makoto Matsumoto and Takuji Nishimura,
+   All rights reserved.                          
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+     1. Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+
+     2. Redistributions in binary form must reproduce the above copyright
+        notice, this list of conditions and the following disclaimer in the
+        documentation and/or other materials provided with the distribution.
+
+     3. The names of its contributors may not be used to endorse or promote 
+        products derived from this software without specific prior written 
+        permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+~~~
+
+TK 8.3 License
+
+This software is copyrighted by the Regents of the University of
+California, Sun Microsystems, Inc., and other parties.  The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs.  Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
+
+~~~
+
+BIND license
+
+Copyright (c) 1985, 1989, 1993
+   The Regents of the University of California.  All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name of the University nor the names of its contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+
+
+Portions Copyright (c) 1993 by Digital Equipment Corporation.
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies, and that
+the name of Digital Equipment Corporation not be used in advertising or
+publicity pertaining to distribution of the document or software without
+specific, written prior permission.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
+CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+
+
+Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+Portions Copyright (c) 1996-1999 by Internet Software Consortium.
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+~~~
+
+Copyright (c) 1994-2011 John Bradley Plevyak, All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may be used to endorse or promote products derived
+   from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+~~~
+
+Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
+Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
+Copyright (C) 2005 Ariya Hidayat (ariya@kde.org)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+
+For the strlcat, strlcpy in inktomi++/ink_string.cc:
+
+Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+

Added: trafficserver/plugins/trunk/balancer/README
URL: http://svn.apache.org/viewvc/trafficserver/plugins/trunk/balancer/README?rev=1201960&view=auto
==============================================================================
--- trafficserver/plugins/trunk/balancer/README (added)
+++ trafficserver/plugins/trunk/balancer/README Mon Nov 14 23:09:44 2011
@@ -0,0 +1,93 @@
+This is a plugin for Traffic Server, that allows you to
+configure mapping rules. 
+
+To use this plugin, configure a remap.config rule like
+
+   map http://foo.com http://bar.com @plugin=balancer.so @pparam=rotation:news
+
+
+The "To-Url" in the remap.config rule is generally not used, unless the
+lookup completely fails (i.e. this is a backup URL for extreme error
+cases).
+
+
+This is a list of all available options (set via @pparam):
+
+
+    rotation  	  The name of the rotation (e.g. news) [to-host in remap]
+    hash	  What to hash on, url, path, cookie, ip, header (primary)
+    hash2	  Optional, secondary hash, to hash within a multi-host bucket
+    bucketw	  Width of each hash bucket [1]
+
+
+The rotation parameter specifies which rotation to do the lookup
+on. If not specified, we will default to the same name as used in the To
+URL in the remap rule.
+
+The bucket width specifies how many hosts a particular hash bucket
+should contain, for example:
+
+    @pparam=bucketw:2
+
+The hash parameter can be used zero or more times, without it, no hashing
+is done at all. If you have more than one hash keys, they are concatenated
+in the order specified. For example:
+
+    @pparam=hash:ip @pparam=hash:cookie/B
+
+The "header" hash key takes a required extra value, for example:
+
+    @pparam=hash:header/Host
+
+
+For "cookie" hash keys, you can optionally specify an identifier for which
+cookie to use (without it, the entire cookie header is used). For example:
+
+    @pparam=hash:cookie/B
+
+
+The secondary hash ("hash2") is used to provide "stickiness" within a
+bucket that's larger than one host (i.e. bucketw > 1). This allows you to
+(for example) have a primary hash on the URL, where each URL is served by
+some number of servers. A secondary hash on B-cookie would then provide
+user stickiness, so that for a particular URL, a particular user will
+always hit the same server.
+
+If the hashes you've requested (either "hash" or "hash2") can not be
+generated, we default to using the URL instead for the primary hash. For
+the secondary hash, if set, we'll defaul to the src-IP. If these defaults
+are not desirable, make sure that you have at least one hash key that is
+guaranteed to exist (e.g. @pparam=hash:ip).
+
+If no "hash" parameters are specified, no hashing is done. This is the
+default behavior, obviously. In this cash, the "hash2" directive has no
+effect as well.
+
+Finally, a couple of "flag" options (parameters) are available, to control
+some of the lookup mechanisms:
+
+   - @pparam=hostip  will use the IP returned by the lookup
+
+
+RELEASES
+--------
+
+Version 1.3.0 (8/23/10)
+  - Fix off-by-one error when using IPs in the rewrite rules.
+  - More efficient (and correct) management of various request resources.
+
+Version 1.2.2 (6/15/09)
+  - Fixed the build system.
+  - Fixed the package info.
+
+Version 1.2 (5/31/09)
+  - Some code cleanup to make Coverity happy.
+  - Added the @pparam=hostip to use the IP returned from the lookup
+  instead of the host name.
+
+Version 1.1 (5/8/09)
+  - Changed all calls to use lookup() directly.
+  - Fixed a bug with wrong size to MD5 calculations.
+
+Version 1.0 (4/28/09)
+  - Initial version, moderately tested...

Added: trafficserver/plugins/trunk/balancer/balancer.cc
URL: http://svn.apache.org/viewvc/trafficserver/plugins/trunk/balancer/balancer.cc?rev=1201960&view=auto
==============================================================================
--- trafficserver/plugins/trunk/balancer/balancer.cc (added)
+++ trafficserver/plugins/trunk/balancer/balancer.cc Mon Nov 14 23:09:44 2011
@@ -0,0 +1,400 @@
+//////////////////////////////////////////////////////////////////////////////////////////////
+// Plugin to do routing decisions
+// -----------
+//
+// To use this plugin, configure a remap.config rule like
+//
+//   map http://foo.com http://bar.com @plugin=balancer.so @pparam=rotation:news1
+//
+// For full description of all available options, please visit the Twiki or Dist docs.
+//
+//
+// Note that the path to the plugin itself must be absolute, and by default it is
+//
+//
+
+
+#include <netdb.h>
+
+#include <string>
+
+#include <RemapAPI.h>
+#include <InkAPI.h>
+
+#include "resources.h"
+#include "hashkey.h"
+
+
+static int MAX_HASH_KEY_VALUES = 16;
+static int MD5_DIGEST_LENGTH = 16;
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Class encapsulating one configuration / setup.
+//
+struct KeyData
+{
+  const void* data;
+  int len;
+};
+
+class BalancerInstance
+{
+public:
+  BalancerInstance(HashKey* hash=NULL, HashKey* hash2=NULL) :
+    _first_hash(hash), _second_hash(hash2),  _bucket_hosts(0), _rotation(NULL),
+    _host_ip(false)
+  { };
+
+  ~BalancerInstance()
+  {
+    HashKey* tmp;
+
+    while (_first_hash) {
+      tmp = _first_hash->next;
+      delete _first_hash;
+      _first_hash = tmp;
+    }
+    if (_rotation)
+      INKfree(_rotation);
+  };
+
+  // Some simple setters and getters
+  void set_host_ip() { _host_ip = true; };
+  bool host_ip() const { return _host_ip; };
+
+  char* rotation() const { return _rotation; };
+  void set_rotation(const std::string& rot) {
+    if (rot.size() > 255) {
+      INKError("Rotation name is too long");
+      return;
+    }
+    _rotation = INKstrdup(rot.c_str());
+  }
+
+  int bucket_hosts() const { return _bucket_hosts; };
+  void set_bucket_hosts(const std::string& width) {
+    _bucket_hosts = atoi(width.c_str());
+  }
+
+  bool has_primary_hash() const { return (_first_hash != NULL); }
+  bool has_secondary_hash() const { return (_second_hash != NULL); }
+  void append_hash(HashKey* hash, bool secondary = false) {
+    if (secondary) {
+      if (_second_hash) {
+        _second_hash->append(hash);
+      } else {
+        _second_hash = hash;
+      }
+    } else {
+      if (_first_hash) {
+        _first_hash->append(hash);
+      } else {
+        _first_hash = hash;
+      }
+    }
+  };
+
+  void make_hash_key(char* id, bool secondary, Resources& resr) {
+    HashKey* hk = secondary ? _second_hash : _first_hash;
+
+    if (hk) {
+      KeyData keys[MAX_HASH_KEY_VALUES];
+      int ix = 0;
+      int key_len = 0;
+
+      do {
+        keys[ix].len = hk->key(&(keys[ix].data), resr);
+        if (keys[ix].len > 0)
+          key_len += keys[ix].len;
+        ++ix;
+      } while ((hk = hk->next));
+
+      // Now create the buffer and copy over all the hash values.
+      if (key_len > 0) {
+        char buf[key_len + 1];
+        char* p = buf;
+
+        hk = secondary ? _second_hash : _first_hash;
+        for (int i = 0; i < ix; ++i) {
+          if ((keys[i].len > 0) && keys[i].data) {
+            memcpy(p, keys[i].data, keys[i].len);
+            p += keys[i].len;
+          }
+          hk->free_key(keys[i].data, keys[i].len, resr); // Cleanup some private data
(possibly)
+          hk = hk->next;
+        }
+        *p = '\0';
+        if (INKIsDebugTagSet("balancer")) {
+          INKDebug("balancer", "Making %s hash ID's using %s", secondary ? "secondary" :
"primary", buf);
+        }
+        ycrMD5_r(buf, key_len, id);
+      } else {
+        if (secondary) {
+          // Secondary ID defaults to IP (if none of the specified hashes computes)
+          char buf[4];
+
+          *buf = resr.getRRI()->client_ip; // ToDo: this only works for IPv4
+
+          INKDebug("balancer", "Making secondary hash ID's using IP (default) = %s", buf);
+          ycrMD5_r(buf, key_len, id);
+        } else {
+          // Primary ID defaults to URL (if none of the specified hashes computes)
+          char buf[resr.getRRI()->orig_url_size + 1];
+
+          memcpy(buf, resr.getRRI()->orig_url, resr.getRRI()->orig_url_size);
+          buf[resr.getRRI()->orig_url_size] = '\0';
+          INKDebug("balancer", "Making primary hash ID's using URL (default) = %s", buf);
+          ycrMD5_r(buf, key_len, id);
+        }
+      }
+    } else {
+      *id = '\0';
+    }
+  }
+
+
+private:
+  HashKey* _first_hash;
+  HashKey* _second_hash;
+  int _bucket_hosts;
+  char* _rotation;
+  bool _host_ip;
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Initialize the plugin.
+//
+int
+tsremap_init(TSREMAP_INTERFACE *api_info, char *errbuf, int errbuf_size)
+{
+  if (!api_info) {
+    strncpy(errbuf, "[tsremap_init] - Invalid TSREMAP_INTERFACE argument", errbuf_size -
1);
+    return -1;
+  }
+
+  if (api_info->size < sizeof(TSREMAP_INTERFACE)) {
+    strncpy(errbuf, "[tsremap_init] - Incorrect size of TSREMAP_INTERFACE structure", errbuf_size
- 1);
+    return -2;
+  }
+
+  if (api_info->tsremap_version < TSREMAP_VERSION) {
+    snprintf(errbuf, errbuf_size - 1, "[tsremap_init] - Incorrect API version %ld.%ld",
+             api_info->tsremap_version >> 16, (api_info->tsremap_version &
0xffff));
+    return -3;
+  }
+
+  INKDebug("balancer", "plugin is succesfully initialized");
+  return 0;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// One instance per remap.config invocation.
+//
+int
+tsremap_new_instance(int argc, char *argv[], ihandle *ih, char *errbuf, int errbuf_size)
+{
+  BalancerInstance* ri = new BalancerInstance;
+
+  *ih = static_cast<ihandle>(ri);
+
+  if (ri == NULL) {
+    INKError("Unable to create remap instance");
+    return -5;
+  }
+
+  for (int ix=2; ix < argc; ++ix) {
+    std::string arg = argv[ix];
+
+    // Check "flags" first, they take no additional arguments
+    if (arg.compare(0, 6, "hostip") ==  0) {
+      ri->set_host_ip();
+    } else {
+      std::string::size_type sep = arg.find_first_of(":");
+
+      if (sep == std::string::npos) {
+        INKError("Malformed options in balancer: %s", argv[ix]);
+      } else {
+        std::string arg_val = arg.substr(sep + 1, std::string::npos);
+
+        if (arg.compare(0, 8, "rotation") == 0) {
+          ri->set_rotation(arg_val);
+        } else if (arg.compare(0, 7, "bucketw") == 0) {
+          ri->set_bucket_hosts(arg_val);
+        } else if (arg.compare(0, 4, "hash") == 0) {
+          bool secondary = !arg.compare(0, 5, "hash2");
+
+          if (arg_val.compare(0, 3, "url") == 0) {
+            URLHashKey* hk = new URLHashKey();
+
+            if (NULL == hk) {
+              INKError("Couldn't create balancer URL hash key");
+            } else {
+              ri->append_hash(hk, secondary);
+            }
+          } else if (arg_val.compare(0, 4, "path") == 0) {
+            PathHashKey* hk = new PathHashKey();
+
+            if (NULL == hk) {
+              INKError("Couldn't create balancer path hash key");
+            } else {
+              ri->append_hash(hk, secondary);
+            }
+          } else if (arg_val.compare(0, 2, "ip") == 0) {
+            IPHashKey* hk = new IPHashKey();
+
+            if (NULL == hk) {
+              INKError("Couldn't create balancer IP hash key");
+            } else {
+              ri->append_hash(hk, secondary);
+            }
+          } else {
+            // The hash parameter can take a second argument
+            std::string::size_type sep2 = arg_val.find_first_of("/");
+
+            if (sep2 == std::string::npos) {
+              INKError("Malformed hash options in balancer: %s", argv[ix]);
+            } else {
+              std::string arg_val2 = arg_val.substr(sep2 + 1, std::string::npos);
+
+              if (arg_val.compare(0, 6, "cookie") == 0) {
+                CookieHashKey* hk = new CookieHashKey(arg_val2);
+
+                if (NULL == hk) {
+                  INKError("Couldn't create balancer cookie hash key");
+                } else {
+                  ri->append_hash(hk, secondary);
+                }
+              } else if (arg_val.compare(0, 6, "header") == 0) {
+                HeaderHashKey* hk = new HeaderHashKey(arg_val2);
+
+                if (NULL == hk) {
+                  INKError("Couldn't create balancer header hash key");
+                } else {
+                  ri->append_hash(hk, secondary);
+                }
+              } else {
+                INKError("Unknown balancer hash option: %s", argv[ix]);
+              }
+            }
+          }
+        } else {
+          INKError("Unknown balancer option: %s", argv[ix]);
+        }
+      }
+    }
+  }
+
+  return 0;
+}
+
+void
+tsremap_delete_instance(ihandle ih)
+{
+  BalancerInstance* ri = static_cast<BalancerInstance*>(ih);
+
+  delete ri;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// This is the main "entry" point for the plugin, called for every request.
+//
+int
+tsremap_remap(ihandle ih, rhandle rh, REMAP_REQUEST_INFO *rri)
+{
+  BalancerInstance* balancer;
+  int error = 0;
+  int port = 0;
+  char resbuf[256 + 256 * sizeof(in_addr_t)];
+  struct hostent* res = NULL;
+  char rotation[256];
+  char *rot;
+
+  if (NULL == ih) {
+    INKDebug("balancer", "Falling back to default URL on remap without rules");
+    return 0;
+  }
+  balancer = static_cast<BalancerInstance*>(ih);
+
+  // Get the rotation name to use.
+
+  if (balancer->rotation()) {
+    rot = balancer->rotation();
+  } else {
+    if (rri->remap_from_host_size > 255) {
+      memcpy(rotation, rri->remap_from_host, 255);
+      rotation[255] = '\0';
+    } else {
+      memcpy(rotation, rri->remap_from_host, rri->remap_from_host_size);
+      rotation[rri->remap_from_host_size] = '\0';
+    }
+    rot = rotation;
+  }
+
+  // Setup the basic info
+  memset(&balancer_info, 0, sizeof(balancer_info));
+  balancer_info.flags = BALANCER_LOOKUP_NOCHECK;   // Make sure we don't trigger a balancer
health check
+  balancer_info.errp = &balancer_error;
+  balancer_info.port = &balancer_port;
+  balancer_info.resbuf = &balancer_resbuf;
+  balancer_info.resbuf_len = sizeof(balancer_resbuf);
+
+  if (balancer->has_primary_hash()) {
+    char id1[MD5_DIGEST_LENGTH+1];
+    Resources resr((INKHttpTxn)rh, rri);
+    
+    balancer_info.num_bucket_hosts = balancer->bucket_hosts();
+
+    balancer->make_hash_key(id1, false, resr);
+    balancer_info.primary_id = id1;
+    balancer_info.primary_id_len = MD5_DIGEST_LENGTH;
+
+    if (balancer->has_secondary_hash()) {
+      char id2[MD5_DIGEST_LENGTH+1];
+
+      balancer->make_hash_key(id2, true, resr);
+      balancer_info.secondary_id = id2;
+      balancer_info.secondary_id_len = MD5_DIGEST_LENGTH;
+
+      INKDebug("balancer", "Calling balancer_lookup(\"%s\") with primary and secondary hash",
rot);
+      res = balancer_lookup(rot, &balancer_info);
+    } else {
+      INKDebug("balancer", "Calling balancer_lookup(\"%s\") with primary hash", rot);
+      res = balancer_lookup(rot, &balancer_info);
+    }
+  } else {
+    INKDebug("balancer", "Calling balancer_lookup(\"%s\") without hash", rot);
+    res = balancer_lookup(rot, &balancer_info);
+  }
+
+  // Check (and use) the balancer lookup results
+  if (!res) {
+    INKDebug("balancer", "BALANCER has no data for %s, using To-URL (error is %d)", rot,
balancer_error);
+    return 0;
+  } else {
+    if ((balancer_port > 0) && (balancer_port != rri->remap_to_port)) {
+      rri->new_port = balancer_port;
+      INKDebug("balancer", "Changing request to port %d", balancer_port);
+    }
+    if (balancer->host_ip()) {
+      unsigned char *ip = (unsigned char*)res->h_addr;
+
+      rri->new_host_size = snprintf(rri->new_host, 16, "%d.%d.%d.%d", ip[0], ip[1],
ip[2], ip[3]);
+      INKDebug("balancer", "Setting real-host IP to %.*s (IP for %s)", rri->new_host_size,
rri->new_host, res->h_name);
+    } else {
+      INKDebug("balancer", "Setting real-host to %s", res->h_name);
+      rri->new_host_size = strlen(res->h_name);
+      if (rri->new_host_size > TSREMAP_RRI_MAX_HOST_SIZE)
+        rri->new_host_size = TSREMAP_RRI_MAX_HOST_SIZE;
+      memcpy(rri->new_host, res->h_name, rri->new_host_size);
+    }
+
+    return 1;
+  }
+
+  // Shouldn't happen
+  return 0;
+}

Added: trafficserver/plugins/trunk/balancer/hashkey.h
URL: http://svn.apache.org/viewvc/trafficserver/plugins/trunk/balancer/hashkey.h?rev=1201960&view=auto
==============================================================================
--- trafficserver/plugins/trunk/balancer/hashkey.h (added)
+++ trafficserver/plugins/trunk/balancer/hashkey.h Mon Nov 14 23:09:44 2011
@@ -0,0 +1,231 @@
+//////////////////////////////////////////////////////////////////////////////////////////////
+// 
+// Implement the classes for the various types of hash keys we support.
+//
+#ifndef __HASHKEY_H__
+#define __HASHKEY_H__ 1
+
+
+#include <string>
+
+#include <RemapAPI.h>
+#include <InkAPI.h>
+
+#include "resources.h"
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Base class for all HashKeys
+//
+class HashKey
+{
+public:
+  HashKey() :
+    next(NULL)
+  { }
+
+  virtual ~HashKey()
+  { }
+
+
+  // Return the number of bytes of data to use from the data pointer. If we
+  // return (-1), no data is available for this particular request.
+  virtual int key(const void** data, Resources& resr) const = 0;
+
+  virtual void free_key(const void* data, int len, Resources& resr) const {
+    // No-op by default
+  }
+
+  void append(HashKey* hash) {
+    INKReleaseAssert(hash->next == NULL);
+
+    if (NULL == next) {
+      next = hash;
+    } else {
+      HashKey* tmp = next;
+
+      while (tmp->next)
+        tmp = next->next;
+
+      tmp->next = hash;
+    }
+  }
+
+  HashKey* next;
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Class for a URL based Hash Key. Set the data pointer to the full URL.
+//
+class URLHashKey : public HashKey
+{
+ public:
+  int
+  key(const void** data, Resources& resr) const {
+    *data = resr.getRRI()->orig_url;
+    return resr.getRRI()->orig_url_size;
+  }
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Class for a Path based Hash Key. Set the data pointer to the path only.
+//
+class PathHashKey : public HashKey
+{
+ public:
+  int
+  key(const void** data, Resources& resr) const {
+    *data = resr.getRRI()->request_path;
+    return resr.getRRI()->request_path_size;
+  }
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Class for a Cookie based Hash Key. Set the data pointer to the Cookie
+// selected, or NULL if not available.
+//
+class CookieHashKey : public HashKey
+{
+ public:
+  CookieHashKey(const std::string cookie) {
+    std::string::size_type dot = cookie.find_first_of(".");
+
+    if (dot != std::string::npos) {
+      std::string tmp;
+
+      tmp = cookie.substr(0, dot);
+      _main = INKstrdup(tmp.c_str());
+      _main_len = dot;
+      tmp = cookie.substr(dot + 1);
+      if (tmp.size() > 0) {
+        _sub = INKstrdup(tmp.c_str());
+        _sub_len = cookie.size() - dot - 1;
+      } else {
+        _sub = NULL;
+        _sub_len = 1;
+      }
+    } else {
+      _main = INKstrdup(cookie.c_str());
+      _main_len = cookie.size();
+      _sub = NULL;
+      _sub_len = 0;
+    }
+  }
+
+  ~CookieHashKey() {
+    if (_main)
+      INKfree(const_cast<char*>(_main));
+    if (_sub)
+      INKfree(const_cast<char*>(_sub));
+  }
+
+  int
+  key(const void** data, Resources& resr) const {
+    if (_main) {
+      if (resr.getJar()) {
+        const char* cookie;
+
+        if (_sub) {
+          cookie = // TODO - get sub cookie
+        } else {
+          cookie = // TODO - get full cookie
+        }
+        if (cookie) {
+          *data = cookie;
+          return strlen(cookie);
+        }
+      }
+    } else {
+      if (resr.getRRI()->request_cookie_size > 0) {
+        *data = resr.getRRI()->request_cookie;
+        return resr.getRRI()->request_cookie_size;
+      }
+    }
+
+    // Nothing found
+    *data = NULL;
+    return -1;
+  }
+
+ private:
+  const char* _main;
+  const char* _sub;
+  int _main_len, _sub_len;
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Class for a IP based Hash Key. Set the data pointer to the IP (in network
+// byte order).
+//
+class IPHashKey : public HashKey
+{
+ public:
+  int
+  key(const void** data, Resources& resr) const {
+    *data = &(resr.getRRI()->client_ip);
+    return 4; // ToDo: This only works with IPV4, obviously
+  }
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Class for a Header based Hash Key. Set the data pointer to the Header, or
+// NULL if not available.
+//
+class HeaderHashKey : public HashKey
+{
+ public:
+  HeaderHashKey(const std::string header) {
+    _header = INKstrdup(header.c_str());
+    _header_len = header.size();
+  }
+
+  ~HeaderHashKey() {
+    if (_header)
+      INKfree(const_cast<char*>(_header));
+  }
+
+  int
+  key(const void** data, Resources& resr) const {
+    INKMBuffer bufp = resr.getBufp();
+    INKMLoc hdrLoc = resr.getHdrLoc();
+    INKMLoc fieldLoc;
+    const char* val;
+    int len = -1;
+
+    // Note that hdrLoc is freed as part of the Resources dtor, and we free the "string"
value
+    // in the free_key() implementation (after we're done with it).
+    if (bufp && hdrLoc && (fieldLoc = INKMimeHdrFieldFind(bufp, hdrLoc, _header,
_header_len))) {
+      if (INK_ERROR != INKMimeHdrFieldValueStringGet(bufp, hdrLoc, fieldLoc, 0, &val,
&len)) {
+        *data = val;
+      } else {
+        *data = NULL;
+      }
+      INKHandleMLocRelease(bufp, hdrLoc, fieldLoc);
+    } else {
+      *data = NULL;
+    }
+
+    return len;
+  }
+
+  void free_key(const void* data, int len, Resources& resr) const {
+    INKMBuffer bufp = resr.getBufp();
+    INKMLoc hdrLoc = resr.getHdrLoc();
+
+    if (bufp && hdrLoc)
+      INKHandleStringRelease(bufp, hdrLoc, (const char*)data);
+  }
+
+ private:
+  const char* _header;
+  int _header_len;
+};
+
+
+#endif // __HASHKEY_H
+

Added: trafficserver/plugins/trunk/balancer/resources.h
URL: http://svn.apache.org/viewvc/trafficserver/plugins/trunk/balancer/resources.h?rev=1201960&view=auto
==============================================================================
--- trafficserver/plugins/trunk/balancer/resources.h (added)
+++ trafficserver/plugins/trunk/balancer/resources.h Mon Nov 14 23:09:44 2011
@@ -0,0 +1,88 @@
+//////////////////////////////////////////////////////////////////////////////////////////////
+// 
+// Implement the resource class (per request), for optimal processing speed.
+//
+#ifndef __RESOURCES_H__
+#define __RESOURCES_H__ 1
+
+
+#include <RemapAPI.h>
+#include <InkAPI.h>
+
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Class declaration
+//
+class Resources
+{
+public:
+  Resources(INKHttpTxn txnp, TSRemapRequestInfo *rri) :
+    _txnp(txnp), _rri(rri), _jar(NULL), _bufp(NULL), _hdrLoc(NULL)
+  { }
+
+  ~Resources() {
+    if (_hdrLoc) {
+      INKDebug("balancer", "Releasing the client request headers");
+      INKHandleMLocRelease(_bufp, INK_NULL_MLOC, _hdrLoc);
+    }
+
+    if (_jar) {
+      INKDebug("balancer", "Destroying the cookie jar");
+      // TODO - destroy cookies
+    }
+  }
+
+  const INKHttpTxn getTxnp() const { return _txnp; }
+    
+  const TSRemapRequestInfo* getRRI() const { return _rri; }
+
+  const cookiejar_t
+  getJar() {
+    if (_jar)
+      return _jar;
+
+    // Setup the cookie jar for all processing
+    if (_rri->request_cookie_size > 0) {
+      char cookie_hdr[_rri->request_cookie_size + 1];
+
+      memcpy(cookie_hdr, _rri->request_cookie, _rri->request_cookie_size);
+      cookie_hdr[_rri->request_cookie_size] = '\0';
+      _jar = // TODO - create cookies
+      INKDebug("balancer", "Creating the cookie jar");
+    }
+
+    return _jar;
+  }
+
+  const INKMBuffer
+  getBufp() {
+    if (_bufp) {
+      return _bufp;
+    } else {
+      if (!_txnp || !INKHttpTxnClientReqGet(_txnp, &_bufp, &_hdrLoc)) {
+        _bufp = NULL;
+        _hdrLoc = NULL;
+      }
+      return _bufp;
+    }
+  }
+
+  const INKMLoc
+  getHdrLoc() {
+    if (!_bufp || !_hdrLoc)
+      (void)getBufp();
+
+    return _hdrLoc;
+  }
+
+private:
+  INKHttpTxn _txnp;
+  TSRemapRequestInfo* _rri;
+  cookiejar_t _jar;
+  INKMBuffer _bufp;
+  INKMLoc _hdrLoc;
+};
+
+
+#endif // __HASHKEY_H



Mime
View raw message