[GitHub] trafficserver issue #1481: Log Field % always outputs "-"
GitHub user ericcarlschwartz opened an issue: https://github.com/apache/trafficserver/issues/1481 Log Field % always outputs "-" Have been doing some testing with logging the cache key field % and every log entry seems to simply be "-". Seeing this with 7.1. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #1066: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/1066 ok fixed those up will let the ci stuff build. would we also want to make this change on the origin side? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #1066: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/1066 i'll drop the assert and switch to the countof! --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #1066: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/1066#discussion_r81416106 --- Diff: proxy/http/HttpTransactHeaders.cc --- @@ -812,26 +813,16 @@ HttpTransactHeaders::insert_via_header_in_response(HttpTransact::State *s, HTTPH } char *incoming_via = s->via_string; - int scheme = s->next_hop_scheme; + ink_assert(s->state_machine); - ink_assert(scheme >= 0); - int scheme_len = hdrtoken_index_to_length(scheme); - int32_t hversion = header->version_get().m_version; - - memcpy(via_string, hdrtoken_index_to_wks(scheme), scheme_len); - via_string += scheme_len; - - // Common case (I hope?) - if ((HTTP_MAJOR(hversion) == 1) && HTTP_MINOR(hversion) == 1) { -memcpy(via_string, "/1.1 ", 5); -via_string += 5; - } else { -*via_string++ = '/'; -*via_string++ = '0' + HTTP_MAJOR(hversion); -*via_string++ = '.'; -*via_string++ = '0' + HTTP_MINOR(hversion); + char const *proto_buf[10]; // 10 seems like a reasonable number of protos to print + int retval = s->state_machine->populate_client_protocol(proto_buf, 10); --- End diff -- would be happy to make that change if you think it's better --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #1066: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/1066#discussion_r81416047 --- Diff: proxy/http/HttpTransactHeaders.cc --- @@ -812,26 +813,16 @@ HttpTransactHeaders::insert_via_header_in_response(HttpTransact::State *s, HTTPH } char *incoming_via = s->via_string; - int scheme = s->next_hop_scheme; + ink_assert(s->state_machine); - ink_assert(scheme >= 0); - int scheme_len = hdrtoken_index_to_length(scheme); - int32_t hversion = header->version_get().m_version; - - memcpy(via_string, hdrtoken_index_to_wks(scheme), scheme_len); - via_string += scheme_len; - - // Common case (I hope?) - if ((HTTP_MAJOR(hversion) == 1) && HTTP_MINOR(hversion) == 1) { -memcpy(via_string, "/1.1 ", 5); -via_string += 5; - } else { -*via_string++ = '/'; -*via_string++ = '0' + HTTP_MAJOR(hversion); -*via_string++ = '.'; -*via_string++ = '0' + HTTP_MINOR(hversion); + char const *proto_buf[10]; // 10 seems like a reasonable number of protos to print + int retval = s->state_machine->populate_client_protocol(proto_buf, 10); + for (int i = 0; i < retval; i++) { +memcpy(via_string, proto_buf[i], strlen(proto_buf[i])); --- End diff -- so for http2 we get five entries, the largest of which is six chars. i guess it could be possible to get more in some far off future and we should plan for that. i think limiting the stack size would be a better approach if we want to prevent the string from getting too long --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #1066: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/1066#discussion_r81415664 --- Diff: proxy/http/HttpTransactHeaders.cc --- @@ -812,26 +813,16 @@ HttpTransactHeaders::insert_via_header_in_response(HttpTransact::State *s, HTTPH } char *incoming_via = s->via_string; - int scheme = s->next_hop_scheme; + ink_assert(s->state_machine); --- End diff -- ah you know what i missed that i'd be happy to drop this --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #1066: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/1066 Oh god sorry. I'll get the clang formatting right on the first time someday. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #1066: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/1066 The same request over http/2 has the additional h2 marker as follows: `via: https/1.1 yahoo.com (ApacheTrafficServer), http/1.1 h2 tls/1.2 tcp ipv4 ubuntu (ApacheTrafficServer/7.1.0)` --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #1066: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/1066 As a heads up, this simplifies things a bit, always relying on the HttpSM `populate_client_protocol` call on the client side. This changes our via header even for http/1.1. An old via header that read: `Via: https/1.1 ats2.fp.gq1.yahoo.com (ApacheTrafficServer), http/1.1 ubuntu (ApacheTrafficServer/7.1.0)` Would now read: `Via: https/1.1 ats2.fp.gq1.yahoo.com (ApacheTrafficServer), http/1.1 tls/1.2 tcp ipv4 ubuntu (ApacheTrafficServer/7.1.0)` --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #1066: [TS-4457] Via header always reports http1
GitHub user ericcarlschwartz opened a pull request: https://github.com/apache/trafficserver/pull/1066 [TS-4457] Via header always reports http1 old PR here. I majorly botched the rebase, sorry: https://github.com/apache/trafficserver/pull/954 You can merge this pull request into a Git repository by running: $ git pull https://github.com/ericcarlschwartz/trafficserver TS-4457 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/trafficserver/pull/1066.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1066 commit 8c4f4724bb39e9156cf8810e6757dcf3c5aea837 Author: ericcarlschwartz <eschwartz1...@gmail.com> Date: 2016-09-29T22:43:54Z [TS-4457] Via header always reports http1 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #954: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/954 h sorry this is bad i'm going to close it --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #954: [TS-4457] Via header always reports http1
Github user ericcarlschwartz closed the pull request at: https://github.com/apache/trafficserver/pull/954 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #954: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/954 @shinrich thanks for that info! That's definitely an interesting and useful way to do this using existing code --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #954: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/954 per IRC discussion on 9/1 looks like we want to rework this to rely entirely on result from get_protocol_string? Also @bryancall suggested maybe adding TLS info? How do others feel about that? Pretty sure we could do that with an old change from acacio --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #954: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/954 @jpeach get_protocol_string() for http1.1/1.0 will just return "http". We could use that and then append the major/minor versions to that but I thought keeping the existing code would be clearer/minimize the difference for how it's done for the incoming request --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #954: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/954 @zwoop ah sorry! I must be doing something wrong, when I ran clang format on it just now I didn't get any changes? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #954: [TS-4457] Via header always reports http1
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/954 A bit confused why the linux build here croaked and the FreeBSD one succeeded? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #954: [TS-4457] Via header always reports http1
GitHub user ericcarlschwartz opened a pull request: https://github.com/apache/trafficserver/pull/954 [TS-4457] Via header always reports http1 You can merge this pull request into a Git repository by running: $ git pull https://github.com/ericcarlschwartz/trafficserver TS-4457 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/trafficserver/pull/954.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #954 commit c40d2733886a8e2c3613660894b2d4fbae2cee79 Author: ericcarlschwartz <eschwartz1...@gmail.com> Date: 2016-08-31T22:42:44Z [TS-4457] Via header always reports http1 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #949: [TS-4423] Update Show Location Options
GitHub user ericcarlschwartz opened a pull request: https://github.com/apache/trafficserver/pull/949 [TS-4423] Update Show Location Options You can merge this pull request into a Git repository by running: $ git pull https://github.com/ericcarlschwartz/trafficserver TS-4423 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/trafficserver/pull/949.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #949 commit 773aa27dad8a469847944c83b998bfead88970ee Author: ericcarlschwartz <eschwartz1...@gmail.com> Date: 2016-08-31T22:12:13Z [TS-4423] Update Show Location Options --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #928: [TS-4423] Update Show Location Options
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/928 Ah, my mistake there. Didn't realize it'd autopopulated w/ something bad. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #940: [TS-4530] Enable hostdb.host_file.path by d...
GitHub user ericcarlschwartz opened a pull request: https://github.com/apache/trafficserver/pull/940 [TS-4530] Enable hostdb.host_file.path by default You can merge this pull request into a Git repository by running: $ git pull https://github.com/ericcarlschwartz/trafficserver TS-4530 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/trafficserver/pull/940.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #940 commit ef8759f6372c4a7447c34fe2c3eee0ee87453b28 Author: Eric Schwartz <e...@inducedeuce.corp.gq1.yahoo.com> Date: 2016-08-29T21:19:17Z [TS-4530] Enable hostdb.host_file.path by default --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #928: Ts 4423
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/928 That sounds good to me. Will try to adhere to in the future. I just went with "Update Show Location Options" for this guy --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #928: Ts 4423
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/928 Ah got it, will fix that up! --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver issue #928: Ts 4423
Github user ericcarlschwartz commented on the issue: https://github.com/apache/trafficserver/pull/928 Dropped the merge commit and made an enum instead of magic numbers. What's wrong with the commit message @zwoop? I just grabbed the name from the bug. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #928: Ts 4423
GitHub user ericcarlschwartz opened a pull request: https://github.com/apache/trafficserver/pull/928 Ts 4423 You can merge this pull request into a Git repository by running: $ git pull https://github.com/ericcarlschwartz/trafficserver TS-4423 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/trafficserver/pull/928.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #928 commit 0edb246b0ca21e4151c0d3aa5e6f8e9757809c11 Author: Eric Schwartz <e...@inducedeuce.corp.gq1.yahoo.com> Date: 2016-08-25T20:39:11Z [TS-4423] Don't show function / filename / line numbers on "operational logs" commit 578cd48ceab27e76f21a534d91127e33cb4fff14 Author: Eric Schwartz <e...@inducedeuce.corp.gq1.yahoo.com> Date: 2016-08-25T21:31:16Z Merge branch 'master' of https://github.com/apache/trafficserver into TS-4423 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #843: [TS-4723] ATS CARP Plugin
Github user ericcarlschwartz commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/843#discussion_r76106996 --- Diff: plugins/experimental/carp/CarpConfig.cc --- @@ -0,0 +1,581 @@ +/** @file + + Loads the CARP configuration + + @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. + */ + +// +// Read CARP configuration file +// [Servers] +// host1.yahoo.com:4080 weight=2 # port 4080 on host1.yahoo.com with weight factor of 2 +// host2.yahoo.com# port 80 on host2.yahoo.com with (default) weight factor of 1 +// +// [Values] +// healthcheck={host}:8001/status.html +// healthfreq=30 +// global=on +// + +#include +#include +#include +#include +#include + +#include + +#include "CarpConfig.h" +#include "Common.h" +#include "CarpConfigPool.h" + +using namespace std; + +#define DEFAULT_HEALTH_CHECK_FREQ 30 // 30 second period for health checks +#define DEFAULT_HEALTH_CHECK_PORT 80 // default to makeing healthcheck requests against port 80 +#define DEFAULT_CONFIG_RELOAD_FREQ 30 // 30 seconds used in TSContSchedule +#define DEFAULT_PORT 80 // default to makeing requests against port 80 +#define DEFAULT_WEIGHT 1 // default weight +#define DEFAULT_SCHEME "http" +#define DEFAULT_REPLICATION_FACTOR 1 + +// config section headers +static const char *const SECTION_SERVERS_STR = "[Servers]"; +static const char *const SECTION_VALUES_STR = "[Values]"; + +// key strings +static const char *const KEY_HEALTHCHECK_STR = "healthcheck"; +static const char *const KEY_HEALTHFREQ_STR = "healthfreq"; +static const char *const KEY_RELOADFREQ_STR = "reloadfreq"; +static const char *const KEY_HCTIMEOUT_STR = "hctimeout"; +static const char *const KEY_BLACKLIST_STR = "blacklist"; +static const char *const KEY_WHITELIST_STR = "whitelist"; +static const char *const KEY_MODE_STR = "mode"; +static const char *const KEY_ALLOWFWDPORT_STR = "allowfwdport"; +static const char *const KEY_REPLICATIONFACTOR_STR = "replicationfactor"; + +// parameter strings +static const char *const WEIGHT_EQUALS_STRING = "weight="; +static const char *const GROUP_EQUALS_STRING = "group="; +static const char *const KEY_MODE_PREREMAP_STR = "pre-remap"; +static const char *const KEY_MODE_POSTREMAP_STR = "post-remap"; + + +/**/ +bool +getInt(char** pptr, int *val) --- End diff -- Kept the wrapper function for the bool return value and pointer update but uses strtol internally. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #843: [TS-4723] ATS CARP Plugin
Github user ericcarlschwartz commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/843#discussion_r75949804 --- Diff: plugins/experimental/carp/CarpConfig.cc --- @@ -0,0 +1,581 @@ +/** @file + + Loads the CARP configuration + + @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. + */ + +// +// Read CARP configuration file +// [Servers] +// host1.yahoo.com:4080 weight=2 # port 4080 on host1.yahoo.com with weight factor of 2 +// host2.yahoo.com# port 80 on host2.yahoo.com with (default) weight factor of 1 +// +// [Values] +// healthcheck={host}:8001/status.html +// healthfreq=30 +// global=on +// + +#include +#include +#include +#include +#include + +#include + +#include "CarpConfig.h" +#include "Common.h" +#include "CarpConfigPool.h" + +using namespace std; + +#define DEFAULT_HEALTH_CHECK_FREQ 30 // 30 second period for health checks +#define DEFAULT_HEALTH_CHECK_PORT 80 // default to makeing healthcheck requests against port 80 +#define DEFAULT_CONFIG_RELOAD_FREQ 30 // 30 seconds used in TSContSchedule +#define DEFAULT_PORT 80 // default to makeing requests against port 80 +#define DEFAULT_WEIGHT 1 // default weight +#define DEFAULT_SCHEME "http" +#define DEFAULT_REPLICATION_FACTOR 1 + +// config section headers +static const char *const SECTION_SERVERS_STR = "[Servers]"; +static const char *const SECTION_VALUES_STR = "[Values]"; + +// key strings +static const char *const KEY_HEALTHCHECK_STR = "healthcheck"; +static const char *const KEY_HEALTHFREQ_STR = "healthfreq"; +static const char *const KEY_RELOADFREQ_STR = "reloadfreq"; +static const char *const KEY_HCTIMEOUT_STR = "hctimeout"; +static const char *const KEY_BLACKLIST_STR = "blacklist"; +static const char *const KEY_WHITELIST_STR = "whitelist"; +static const char *const KEY_MODE_STR = "mode"; +static const char *const KEY_ALLOWFWDPORT_STR = "allowfwdport"; +static const char *const KEY_REPLICATIONFACTOR_STR = "replicationfactor"; + +// parameter strings +static const char *const WEIGHT_EQUALS_STRING = "weight="; +static const char *const GROUP_EQUALS_STRING = "group="; +static const char *const KEY_MODE_PREREMAP_STR = "pre-remap"; +static const char *const KEY_MODE_POSTREMAP_STR = "post-remap"; + + +/**/ +bool +getInt(char** pptr, int *val) +{ + bool bReturn = false; + int v=0; + + char* ptr = *pptr; + // skip white space if any + while (*ptr && isspace(*ptr)) ++ptr; + // get digits + if (*ptr) { +while (*ptr && isdigit(*ptr)) { + v *= 10; + v += (*ptr)-'0'; + ++ptr; + bReturn = true; +} + } + if (bReturn) { +*pptr = ptr; +*val = v; + } + + return bReturn; +} + +/**/ +// [http[s]://]host[:port]/path +bool +getHostAndPort(char** pptr,string* sHost,int* iPort, string* sScheme) +{ + bool bReturn = false; + char* ptr = *pptr; + + *iPort = 80; + *sScheme = DEFAULT_SCHEME; + if(strncmp(*pptr,"https",5) == 0) { +*iPort = 443; +*sScheme = "https"; + } + + //skip leading white space + while (*ptr && isspace(*ptr)) ++ptr; + + if (*ptr) { // validate not end of string +if(strncmp(ptr,"http://",7) == 0) { + ptr += 7; +} else if(strncmp(ptr,"https://",8) == 0) { + ptr += 8;
[GitHub] trafficserver pull request #843: [TS-4723] ATS CARP Plugin
Github user ericcarlschwartz commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/843#discussion_r75941557 --- Diff: plugins/experimental/carp/CarpConfig.cc --- @@ -0,0 +1,581 @@ +/** @file + + Loads the CARP configuration + + @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. + */ + +// +// Read CARP configuration file +// [Servers] +// host1.yahoo.com:4080 weight=2 # port 4080 on host1.yahoo.com with weight factor of 2 +// host2.yahoo.com# port 80 on host2.yahoo.com with (default) weight factor of 1 +// +// [Values] +// healthcheck={host}:8001/status.html +// healthfreq=30 +// global=on +// + +#include +#include +#include +#include +#include + +#include + +#include "CarpConfig.h" +#include "Common.h" +#include "CarpConfigPool.h" + +using namespace std; + +#define DEFAULT_HEALTH_CHECK_FREQ 30 // 30 second period for health checks +#define DEFAULT_HEALTH_CHECK_PORT 80 // default to makeing healthcheck requests against port 80 +#define DEFAULT_CONFIG_RELOAD_FREQ 30 // 30 seconds used in TSContSchedule +#define DEFAULT_PORT 80 // default to makeing requests against port 80 +#define DEFAULT_WEIGHT 1 // default weight +#define DEFAULT_SCHEME "http" +#define DEFAULT_REPLICATION_FACTOR 1 + +// config section headers +static const char *const SECTION_SERVERS_STR = "[Servers]"; +static const char *const SECTION_VALUES_STR = "[Values]"; + +// key strings +static const char *const KEY_HEALTHCHECK_STR = "healthcheck"; +static const char *const KEY_HEALTHFREQ_STR = "healthfreq"; +static const char *const KEY_RELOADFREQ_STR = "reloadfreq"; +static const char *const KEY_HCTIMEOUT_STR = "hctimeout"; +static const char *const KEY_BLACKLIST_STR = "blacklist"; +static const char *const KEY_WHITELIST_STR = "whitelist"; +static const char *const KEY_MODE_STR = "mode"; +static const char *const KEY_ALLOWFWDPORT_STR = "allowfwdport"; +static const char *const KEY_REPLICATIONFACTOR_STR = "replicationfactor"; + +// parameter strings +static const char *const WEIGHT_EQUALS_STRING = "weight="; +static const char *const GROUP_EQUALS_STRING = "group="; +static const char *const KEY_MODE_PREREMAP_STR = "pre-remap"; +static const char *const KEY_MODE_POSTREMAP_STR = "post-remap"; + + +/**/ +bool +getInt(char** pptr, int *val) +{ + bool bReturn = false; + int v=0; + + char* ptr = *pptr; + // skip white space if any + while (*ptr && isspace(*ptr)) ++ptr; + // get digits + if (*ptr) { +while (*ptr && isdigit(*ptr)) { + v *= 10; + v += (*ptr)-'0'; + ++ptr; + bReturn = true; +} + } + if (bReturn) { +*pptr = ptr; +*val = v; + } + + return bReturn; +} + +/**/ +// [http[s]://]host[:port]/path +bool +getHostAndPort(char** pptr,string* sHost,int* iPort, string* sScheme) +{ + bool bReturn = false; + char* ptr = *pptr; + + *iPort = 80; + *sScheme = DEFAULT_SCHEME; + if(strncmp(*pptr,"https",5) == 0) { +*iPort = 443; +*sScheme = "https"; + } + + //skip leading white space + while (*ptr && isspace(*ptr)) ++ptr; --- End diff -- I addressed this by always skipping the leading white space. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #843: [TS-4723] ATS CARP Plugin
Github user ericcarlschwartz commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/843#discussion_r75919006 --- Diff: plugins/experimental/carp/carp.cc --- @@ -0,0 +1,713 @@ +/** @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 + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "Common.h" +#include "CarpConfig.h" +#include "CarpConfigPool.h" +#include "CarpHashAlgorithm.h" +#include "UrlComponents.h" + +using namespace std; + +CarpConfigPool* g_CarpConfigPool = NULL; +int g_carpSelectedHostArgIndex = 0; +TSTextLogObject g_logObject = NULL; + +const char *logFileName = "carp"; + +// +// +/* + check for our carp routed header, dump status if requested + */ +static int +processCarpRoutedHeader(TSHttpTxn txnp, TSMBuffer bufp, TSMLoc hdr_loc) +{ + string value; + if (getHeader(bufp, hdr_loc, CARP_ROUTED_HEADER, value)) { // if found header +if (value.compare("1") == 0) { // is loop prevention value + TSDebug(DEBUG_TAG_HOOK, "Found %s header with loop prevention value, not forwarding again", CARP_ROUTED_HEADER.c_str()); + return 0; +} else if (value.compare("dump") == 0) { // is dump status request + TSDebug(DEBUG_TAG_HOOK, "Found %s header with dump request", CARP_ROUTED_HEADER.c_str()); + string status; + g_CarpConfigPool->getGlobalHashAlgo()->dump(status); + TSHttpTxnSetHttpRetStatus(txnp, TS_HTTP_STATUS_MULTI_STATUS); + TSHttpTxnErrorBodySet(txnp, TSstrdup(status.c_str()), status.length(), NULL); + return -1; +} +TSDebug(DEBUG_TAG_HOOK, "Found %s header with unknown value of %s, ignoring", CARP_ROUTED_HEADER.c_str(), value.c_str()); +removeHeader(bufp, hdr_loc, CARP_ROUTED_HEADER); + } + return 1; // all OK +} + +static bool +checkListForSelf(std::vector list) +{ + for (size_t k = 0; k < list.size(); k++) { +if (list[k]->isSelf) return true; + } + return false; +} + +/** + bIsPOSTRemap = false --- Hash request and forward to peer + bIsPOSTRemap = true --- hash request, extract OS sockaddr, insert forwarding header, forward + */ +static int +handleRequestProcessing(TSCont contp, TSEvent event, void *edata, bool bIsPOSTRemap) +{ + TSHttpTxn txnp = (TSHttpTxn) edata; + TSMBuffer bufp; + TSMLoc hdr_loc; + TSMLoc url_loc; + + // get the client request so we can get URL and add header + if (TSHttpTxnClientReqGet(txnp, , _loc) != TS_SUCCESS) { +TSError("carp couldn't get request headers"); +return -1; + } + + int method_len; + const char *method = TSHttpHdrMethodGet(bufp, hdr_loc, _len); + if (NULL == method) { +TSError("carp couldn't get http method"); +TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc); +return -1; + } + if (((method_len == TS_HTTP_LEN_DELETE) && (strncasecmp(method, TS_HTTP_METHOD_DELETE, TS_HTTP_LEN_DELETE) == 0)) || + ((method_len == TS_HTTP_LEN_PURGE) && (strncasecmp(method, TS_HTTP_METHOD_PURGE, TS_HTTP_LEN_PURGE) == 0))) { +TSDebug(DEBUG_TAG_HOOK, "Request method is '%s' so not routing request", string(method,method_len).c_str()); +TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc); +return 0; + } + + if (TSHttpHdrUrlGet(bufp, hdr_loc, _loc) != TS_SUCCESS) { +TSError("carp couldn't get url"); +TS
[GitHub] trafficserver pull request #843: [TS-4723] ATS CARP Plugin
Github user ericcarlschwartz commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/843#discussion_r75918715 --- Diff: plugins/experimental/carp/carp.cc --- @@ -0,0 +1,713 @@ +/** @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 + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "Common.h" +#include "CarpConfig.h" +#include "CarpConfigPool.h" +#include "CarpHashAlgorithm.h" +#include "UrlComponents.h" + +using namespace std; + +CarpConfigPool* g_CarpConfigPool = NULL; +int g_carpSelectedHostArgIndex = 0; +TSTextLogObject g_logObject = NULL; + +const char *logFileName = "carp"; + +// +// +/* + check for our carp routed header, dump status if requested + */ +static int +processCarpRoutedHeader(TSHttpTxn txnp, TSMBuffer bufp, TSMLoc hdr_loc) +{ + string value; + if (getHeader(bufp, hdr_loc, CARP_ROUTED_HEADER, value)) { // if found header +if (value.compare("1") == 0) { // is loop prevention value + TSDebug(DEBUG_TAG_HOOK, "Found %s header with loop prevention value, not forwarding again", CARP_ROUTED_HEADER.c_str()); + return 0; +} else if (value.compare("dump") == 0) { // is dump status request + TSDebug(DEBUG_TAG_HOOK, "Found %s header with dump request", CARP_ROUTED_HEADER.c_str()); + string status; + g_CarpConfigPool->getGlobalHashAlgo()->dump(status); + TSHttpTxnSetHttpRetStatus(txnp, TS_HTTP_STATUS_MULTI_STATUS); + TSHttpTxnErrorBodySet(txnp, TSstrdup(status.c_str()), status.length(), NULL); + return -1; +} +TSDebug(DEBUG_TAG_HOOK, "Found %s header with unknown value of %s, ignoring", CARP_ROUTED_HEADER.c_str(), value.c_str()); +removeHeader(bufp, hdr_loc, CARP_ROUTED_HEADER); + } + return 1; // all OK +} + +static bool +checkListForSelf(std::vector list) +{ + for (size_t k = 0; k < list.size(); k++) { +if (list[k]->isSelf) return true; + } + return false; +} + +/** + bIsPOSTRemap = false --- Hash request and forward to peer + bIsPOSTRemap = true --- hash request, extract OS sockaddr, insert forwarding header, forward + */ +static int +handleRequestProcessing(TSCont contp, TSEvent event, void *edata, bool bIsPOSTRemap) +{ + TSHttpTxn txnp = (TSHttpTxn) edata; + TSMBuffer bufp; + TSMLoc hdr_loc; + TSMLoc url_loc; + + // get the client request so we can get URL and add header + if (TSHttpTxnClientReqGet(txnp, , _loc) != TS_SUCCESS) { +TSError("carp couldn't get request headers"); +return -1; + } + + int method_len; + const char *method = TSHttpHdrMethodGet(bufp, hdr_loc, _len); + if (NULL == method) { +TSError("carp couldn't get http method"); +TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc); +return -1; + } + if (((method_len == TS_HTTP_LEN_DELETE) && (strncasecmp(method, TS_HTTP_METHOD_DELETE, TS_HTTP_LEN_DELETE) == 0)) || + ((method_len == TS_HTTP_LEN_PURGE) && (strncasecmp(method, TS_HTTP_METHOD_PURGE, TS_HTTP_LEN_PURGE) == 0))) { +TSDebug(DEBUG_TAG_HOOK, "Request method is '%s' so not routing request", string(method,method_len).c_str()); +TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc); +return 0; + } + + if (TSHttpHdrUrlGet(bufp, hdr_loc, _loc) != TS_SUCCESS) { +TSError("carp couldn't get url"); +TS
[GitHub] trafficserver pull request #843: [TS-4723] ATS CARP Plugin
Github user ericcarlschwartz commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/843#discussion_r74291077 --- Diff: plugins/experimental/carp/CarpHashAlgorithm.cc --- @@ -0,0 +1,396 @@ +/** @file + + Implements the CARP hash algorithm + + @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 +#include +#include +#include + +#include +#include + +#include "Common.h" +#include "CarpHashAlgorithm.h" + +using namespace std; + +/*/ +void +HashNode::dump(string& s) +{ + stringstream ss; + string sSockaddr; + getStringFromSockaddr(reinterpret_cast( ), sSockaddr); + + ss << scheme << "://" << name << ":"<<listenPort<<" ("<<sSockaddr<<") weight:"<<weight<< (_status ? string(" UP ") : string(" DOWN ")); + if(_statusTime) { +ss << "(" << time(NULL)-_statusTime<< "s ago in "<< _statusLatencyMs << "mS)"; + } + ss << " hits:" << _hits; + ss << " carp_noforwarded:" << _carp_noforwarded; + ss << " carp_forwarded:" << _carp_forwarded; + ss << endl; + s += ss.str(); +} + +/*/ +void +HashAlgorithm::addHost(std::string name, unsigned int port, std::string scheme, double weight, bool self, struct sockaddr_storage fwdAddr) +{ + HashNode* node = new HashNode(name, port, scheme, weight, self, fwdAddr); + TSAssert(NULL != node); + addHost(node); +} + +/*/ +void +HashAlgorithm::addHost(HashNode* node) +{ + if (!node) return; + _hostList.push_back(node); +} + +/*/ +HashNode* +HashAlgorithm::findStatusByNameAndPort(const string& name, unsigned int port, +size_t* index) { + /* + * Todo: This use loop to find the corresponding HashNode + * But the HttpClient and the Hash was related, so we + * could use more easier method to write the status + */ + for (size_t ptr = 0; ptr < _hostList.size(); ptr++) { +if (_hostList[ptr]->listenPort == port +&& _hostList[ptr]->name.compare(name) == 0) { // found it + if (index) { +*index = ptr; + } + return _hostList[ptr]; +} + } + return NULL; +} + +size_t +HashAlgorithm::findHashNodeIndex(HashNode *node) { + for (size_t ptr = 0; ptr < _hostList.size(); ptr++) { +if ( _hostList[ptr] == node) { + return ptr; +} + } + return -1; +} + +/*/ +void +HashAlgorithm::setStatus(const string& name, unsigned int port, bool status, time_t time, uint64_t latencyMs) +{ + TSDebug(DEBUG_TAG_INIT, "HashAlgorithm::setStatus name=%s status=%d", name.c_str(), status); + + HashNode* node = findStatusByNameAndPort(name,port); + if(node) { +node->setStatus(status,time,latencyMs); + } else { +TSError("Carp internal error setStatus host %s not found",name.c_str()); + } +} + +void +HashAlgorithm::setStatus(HashNode * node, bool status, time_t time, uint64_t latencyMs) +{ + TSDebug(DEBUG_TAG_INIT, "HashAlgorithm::setStatus name=%s status=%d", node->name.c_str(), status); + +// HashNode* node = findStatusByNameAndPort(name,port); + if(node) { +node->setSt
[GitHub] trafficserver pull request #843: [TS-4723] ATS CARP Plugin
Github user ericcarlschwartz commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/843#discussion_r74290371 --- Diff: plugins/experimental/carp/CarpConfig.cc --- @@ -0,0 +1,581 @@ +/** @file + + Loads the CARP configuration + + @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. + */ + +// +// Read CARP configuration file +// [Servers] +// host1.yahoo.com:4080 weight=2 # port 4080 on host1.yahoo.com with weight factor of 2 +// host2.yahoo.com# port 80 on host2.yahoo.com with (default) weight factor of 1 +// +// [Values] +// healthcheck={host}:8001/status.html +// healthfreq=30 +// global=on +// + +#include +#include +#include +#include +#include + +#include + +#include "CarpConfig.h" +#include "Common.h" +#include "CarpConfigPool.h" + +using namespace std; + +#define DEFAULT_HEALTH_CHECK_FREQ 30 // 30 second period for health checks +#define DEFAULT_HEALTH_CHECK_PORT 80 // default to makeing healthcheck requests against port 80 +#define DEFAULT_CONFIG_RELOAD_FREQ 30 // 30 seconds used in TSContSchedule +#define DEFAULT_PORT 80 // default to makeing requests against port 80 +#define DEFAULT_WEIGHT 1 // default weight +#define DEFAULT_SCHEME "http" +#define DEFAULT_REPLICATION_FACTOR 1 + +// config section headers +static const char *const SECTION_SERVERS_STR = "[Servers]"; +static const char *const SECTION_VALUES_STR = "[Values]"; + +// key strings +static const char *const KEY_HEALTHCHECK_STR = "healthcheck"; +static const char *const KEY_HEALTHFREQ_STR = "healthfreq"; +static const char *const KEY_RELOADFREQ_STR = "reloadfreq"; +static const char *const KEY_HCTIMEOUT_STR = "hctimeout"; +static const char *const KEY_BLACKLIST_STR = "blacklist"; +static const char *const KEY_WHITELIST_STR = "whitelist"; +static const char *const KEY_MODE_STR = "mode"; +static const char *const KEY_ALLOWFWDPORT_STR = "allowfwdport"; +static const char *const KEY_REPLICATIONFACTOR_STR = "replicationfactor"; + +// parameter strings +static const char *const WEIGHT_EQUALS_STRING = "weight="; +static const char *const GROUP_EQUALS_STRING = "group="; +static const char *const KEY_MODE_PREREMAP_STR = "pre-remap"; +static const char *const KEY_MODE_POSTREMAP_STR = "post-remap"; + + +/**/ +bool +getInt(char** pptr, int *val) +{ + bool bReturn = false; + int v=0; + + char* ptr = *pptr; + // skip white space if any + while (*ptr && isspace(*ptr)) ++ptr; + // get digits + if (*ptr) { +while (*ptr && isdigit(*ptr)) { + v *= 10; + v += (*ptr)-'0'; + ++ptr; + bReturn = true; +} + } + if (bReturn) { +*pptr = ptr; +*val = v; + } + + return bReturn; +} + +/**/ +// [http[s]://]host[:port]/path +bool +getHostAndPort(char** pptr,string* sHost,int* iPort, string* sScheme) +{ + bool bReturn = false; + char* ptr = *pptr; + + *iPort = 80; + *sScheme = DEFAULT_SCHEME; + if(strncmp(*pptr,"https",5) == 0) { +*iPort = 443; +*sScheme = "https"; + } + + //skip leading white space + while (*ptr && isspace(*ptr)) ++ptr; + + if (*ptr) { // validate not end of string +if(strncmp(ptr,"http://",7) == 0) { + ptr += 7; +} else if(strncmp(ptr,"https://",8) == 0) { + ptr += 8; +
[GitHub] trafficserver pull request #843: [TS-4723] ATS CARP Plugin
Github user ericcarlschwartz commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/843#discussion_r74290124 --- Diff: plugins/experimental/carp/CarpConfig.cc --- @@ -0,0 +1,581 @@ +/** @file + + Loads the CARP configuration + + @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. + */ + +// +// Read CARP configuration file +// [Servers] +// host1.yahoo.com:4080 weight=2 # port 4080 on host1.yahoo.com with weight factor of 2 +// host2.yahoo.com# port 80 on host2.yahoo.com with (default) weight factor of 1 +// +// [Values] +// healthcheck={host}:8001/status.html +// healthfreq=30 +// global=on +// + +#include +#include +#include +#include +#include + +#include + +#include "CarpConfig.h" +#include "Common.h" +#include "CarpConfigPool.h" + +using namespace std; + +#define DEFAULT_HEALTH_CHECK_FREQ 30 // 30 second period for health checks +#define DEFAULT_HEALTH_CHECK_PORT 80 // default to makeing healthcheck requests against port 80 +#define DEFAULT_CONFIG_RELOAD_FREQ 30 // 30 seconds used in TSContSchedule +#define DEFAULT_PORT 80 // default to makeing requests against port 80 +#define DEFAULT_WEIGHT 1 // default weight +#define DEFAULT_SCHEME "http" +#define DEFAULT_REPLICATION_FACTOR 1 + +// config section headers +static const char *const SECTION_SERVERS_STR = "[Servers]"; +static const char *const SECTION_VALUES_STR = "[Values]"; + +// key strings +static const char *const KEY_HEALTHCHECK_STR = "healthcheck"; +static const char *const KEY_HEALTHFREQ_STR = "healthfreq"; +static const char *const KEY_RELOADFREQ_STR = "reloadfreq"; +static const char *const KEY_HCTIMEOUT_STR = "hctimeout"; +static const char *const KEY_BLACKLIST_STR = "blacklist"; +static const char *const KEY_WHITELIST_STR = "whitelist"; +static const char *const KEY_MODE_STR = "mode"; +static const char *const KEY_ALLOWFWDPORT_STR = "allowfwdport"; +static const char *const KEY_REPLICATIONFACTOR_STR = "replicationfactor"; + +// parameter strings +static const char *const WEIGHT_EQUALS_STRING = "weight="; +static const char *const GROUP_EQUALS_STRING = "group="; +static const char *const KEY_MODE_PREREMAP_STR = "pre-remap"; +static const char *const KEY_MODE_POSTREMAP_STR = "post-remap"; + + +/**/ +bool +getInt(char** pptr, int *val) --- End diff -- Think it's done with this function because it basically grabs the next integer and advances the pointer and can then be called again with the new pointer to get the next one. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #843: [TS-4723] ATS CARP Plugin
Github user ericcarlschwartz commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/843#discussion_r74289748 --- Diff: plugins/experimental/carp/CarpConfig.cc --- @@ -0,0 +1,581 @@ +/** @file + + Loads the CARP configuration + + @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. + */ + +// +// Read CARP configuration file +// [Servers] +// host1.yahoo.com:4080 weight=2 # port 4080 on host1.yahoo.com with weight factor of 2 +// host2.yahoo.com# port 80 on host2.yahoo.com with (default) weight factor of 1 +// +// [Values] +// healthcheck={host}:8001/status.html +// healthfreq=30 +// global=on +// + +#include +#include +#include +#include +#include + +#include + +#include "CarpConfig.h" +#include "Common.h" +#include "CarpConfigPool.h" + +using namespace std; + +#define DEFAULT_HEALTH_CHECK_FREQ 30 // 30 second period for health checks +#define DEFAULT_HEALTH_CHECK_PORT 80 // default to makeing healthcheck requests against port 80 +#define DEFAULT_CONFIG_RELOAD_FREQ 30 // 30 seconds used in TSContSchedule +#define DEFAULT_PORT 80 // default to makeing requests against port 80 +#define DEFAULT_WEIGHT 1 // default weight +#define DEFAULT_SCHEME "http" +#define DEFAULT_REPLICATION_FACTOR 1 + +// config section headers +static const char *const SECTION_SERVERS_STR = "[Servers]"; +static const char *const SECTION_VALUES_STR = "[Values]"; + +// key strings +static const char *const KEY_HEALTHCHECK_STR = "healthcheck"; +static const char *const KEY_HEALTHFREQ_STR = "healthfreq"; +static const char *const KEY_RELOADFREQ_STR = "reloadfreq"; +static const char *const KEY_HCTIMEOUT_STR = "hctimeout"; +static const char *const KEY_BLACKLIST_STR = "blacklist"; +static const char *const KEY_WHITELIST_STR = "whitelist"; +static const char *const KEY_MODE_STR = "mode"; +static const char *const KEY_ALLOWFWDPORT_STR = "allowfwdport"; +static const char *const KEY_REPLICATIONFACTOR_STR = "replicationfactor"; + +// parameter strings +static const char *const WEIGHT_EQUALS_STRING = "weight="; +static const char *const GROUP_EQUALS_STRING = "group="; +static const char *const KEY_MODE_PREREMAP_STR = "pre-remap"; +static const char *const KEY_MODE_POSTREMAP_STR = "post-remap"; + + +/**/ +bool +getInt(char** pptr, int *val) +{ + bool bReturn = false; + int v=0; + + char* ptr = *pptr; + // skip white space if any + while (*ptr && isspace(*ptr)) ++ptr; + // get digits + if (*ptr) { +while (*ptr && isdigit(*ptr)) { + v *= 10; + v += (*ptr)-'0'; + ++ptr; + bReturn = true; +} + } + if (bReturn) { +*pptr = ptr; +*val = v; + } + + return bReturn; +} + +/**/ +// [http[s]://]host[:port]/path +bool +getHostAndPort(char** pptr,string* sHost,int* iPort, string* sScheme) +{ + bool bReturn = false; + char* ptr = *pptr; + + *iPort = 80; + *sScheme = DEFAULT_SCHEME; + if(strncmp(*pptr,"https",5) == 0) { --- End diff -- ah definitely --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] trafficserver pull request #843: [TS-4723] ATS CARP Plugin
GitHub user ericcarlschwartz opened a pull request: https://github.com/apache/trafficserver/pull/843 [TS-4723] ATS CARP Plugin JIRA: https://issues.apache.org/jira/browse/TS-4723 This is the code for our ATS CARP plugin along with some tests. Two caveats with this code: 1. The makefile is all wrong. I'll definitely fix this before we get it merged. It's just something you can checkout if you want to build on your own machine. I'm not super familiar with automake, so I didn't add this to the Makefile.am in the parent directory or write my own Makefile.am and Makefile.in for this. If someone could send me a doc or help me do that, I'd love to learn. 2. There are some simple unit tests included here along with an api stub for running them. I've noticed the other experimental plugins don't have tests with them. If you'd like me to drop them, I can. Figured I'd include for now. You can merge this pull request into a Git repository by running: $ git pull https://github.com/ericcarlschwartz/trafficserver TS-4723 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/trafficserver/pull/843.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #843 commit caed7922f3aa19c362178aee8e8e995dc62f51e1 Author: Eric Schwartz <e...@goesfoes.corp.gq1.yahoo.com> Date: 2016-08-06T18:10:41Z [TS-4723] ATS CARP Plugin --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---