Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

TS-1270 add force local cache control in clustering mode

  • Loading branch information...
commit 5a48e53cf2a5e292ad78388625bb0d7cded43bc9 1 parent 00953ff
Chen Bin authored mingzym committed
View
2  CHANGES
@@ -1,6 +1,8 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 3.3.0
+ *) [TS-1270] add force local cache control in clustering mode
+
*) [TS-1386] thread hang in cluster type=1, which will trigger the
throttling
View
1  contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
@@ -423,6 +423,7 @@ The Apache Traffic Server Administration Manual will explain what these strings
proxy.config.http.cache.ignore_accept_mismatch
proxy.config.http.cache.ignore_authentication
proxy.config.http.cache.ignore_client_cc_max_age
+ proxy.config.http.cache.cluster_cache_local
proxy.config.http.cache.ignore_client_no_cache
proxy.config.http.cache.ignore_server_no_cache
proxy.config.http.cache.ims_on_client_no_cache
View
14 iocore/cache/Cache.cc
@@ -2794,11 +2794,11 @@ ink_cache_init(ModuleVersion v)
#ifdef NON_MODULAR
//----------------------------------------------------------------------------
Action *
-CacheProcessor::open_read(Continuation *cont, URL *url, CacheHTTPHdr *request,
+CacheProcessor::open_read(Continuation *cont, URL *url, bool cluster_cache_local, CacheHTTPHdr *request,
CacheLookupHttpConfig *params, time_t pin_in_cache, CacheFragType type)
{
#ifdef CLUSTER_CACHE
- if (cache_clustering_enabled > 0) {
+ if (cache_clustering_enabled > 0 && !cluster_cache_local) {
return open_read_internal(CACHE_OPEN_READ_LONG, cont, (MIOBuffer *) 0,
url, request, params, (CacheKey *) 0, pin_in_cache, type, (char *) 0, 0);
}
@@ -2809,11 +2809,11 @@ CacheProcessor::open_read(Continuation *cont, URL *url, CacheHTTPHdr *request,
//----------------------------------------------------------------------------
Action *
-CacheProcessor::open_write(Continuation *cont, int expected_size, URL *url,
+CacheProcessor::open_write(Continuation *cont, int expected_size, URL *url, bool cluster_cache_local,
CacheHTTPHdr *request, CacheHTTPInfo *old_info, time_t pin_in_cache, CacheFragType type)
{
#ifdef CLUSTER_CACHE
- if (cache_clustering_enabled > 0) {
+ if (cache_clustering_enabled > 0 && !cluster_cache_local) {
INK_MD5 url_md5;
Cache::generate_key(&url_md5, url, request);
ClusterMachine *m = cluster_machine_at_depth(cache_hash(url_md5));
@@ -2836,7 +2836,7 @@ CacheProcessor::open_write(Continuation *cont, int expected_size, URL *url,
// Note: this should not be called from from the cluster processor, or bad
// recursion could occur. This is merely a convenience wrapper.
Action *
-CacheProcessor::remove(Continuation *cont, URL *url, CacheFragType frag_type)
+CacheProcessor::remove(Continuation *cont, URL *url, bool cluster_cache_local, CacheFragType frag_type)
{
INK_MD5 md5;
int len = 0;
@@ -2847,9 +2847,9 @@ CacheProcessor::remove(Continuation *cont, URL *url, CacheFragType frag_type)
Debug("cache_remove", "[CacheProcessor::remove] Issuing cache delete for %s", url->string_get_ref());
#ifdef CLUSTER_CACHE
- if (cache_clustering_enabled > 0) {
+ if (cache_clustering_enabled > 0 && !cluster_cache_local) {
// Remove from cluster
- return remove(cont, &md5, frag_type, true, false, const_cast<char *>(hostname), len);
+ return remove(cont, &md5, cluster_cache_local, frag_type, true, false, const_cast<char *>(hostname), len);
}
#endif
View
7 iocore/cache/CachePages.cc
@@ -27,6 +27,7 @@
#include "api/ts/ts.h"
#include "Show.h"
#include "I_Tasks.h"
+#include "CacheControl.h"
struct ShowCache: public ShowCont {
enum scan_type {
@@ -420,7 +421,7 @@ ShowCache::lookup_url(int event, Event *e) {
url.MD5_get(&md5);
const char *hostname = url.host_get(&len);
SET_HANDLER(&ShowCache::handleCacheEvent);
- Action *lookup_result = cacheProcessor.open_read(this, &md5, CACHE_FRAG_TYPE_HTTP, (char *) hostname, len);
+ Action *lookup_result = cacheProcessor.open_read(this, &md5, getClusterCacheLocal(&url, (char *)hostname), CACHE_FRAG_TYPE_HTTP, (char *) hostname, len);
if (!lookup_result)
lookup_result = ACTION_IO_ERROR;
if (lookup_result == ACTION_RESULT_DONE)
@@ -458,7 +459,9 @@ ShowCache::delete_url(int event, Event *e)
// increment the index so that the next time
// delete_url is called you delete the next url
urlstrs_index++;
- cacheProcessor.remove(this, &url, CACHE_FRAG_TYPE_HTTP);
+ int len;
+ const char *hostname = url.host_get(&len);
+ cacheProcessor.remove(this, &url, getClusterCacheLocal(&url, (char *)hostname), CACHE_FRAG_TYPE_HTTP);
return EVENT_DONE;
}
View
24 iocore/cache/CacheTest.cc
@@ -286,41 +286,41 @@ EXCLUSIVE_REGRESSION_TEST(cache)(RegressionTest *t, int atype, int *pstatus) {
EThread *thread = this_ethread();
CACHE_SM(t, write_test, { cacheProcessor.open_write(
- this, &key, CACHE_FRAG_TYPE_NONE, 100,
+ this, &key, false, CACHE_FRAG_TYPE_NONE, 100,
CACHE_WRITE_OPT_SYNC); } );
write_test.expect_initial_event = CACHE_EVENT_OPEN_WRITE;
write_test.expect_event = VC_EVENT_WRITE_COMPLETE;
write_test.nbytes = 100;
rand_CacheKey(&write_test.key, thread->mutex);
- CACHE_SM(t, lookup_test, { cacheProcessor.lookup(this, &key); } );
+ CACHE_SM(t, lookup_test, { cacheProcessor.lookup(this, &key, false); } );
lookup_test.expect_event = CACHE_EVENT_LOOKUP;
lookup_test.key = write_test.key;
- CACHE_SM(t, read_test, { cacheProcessor.open_read(this, &key); } );
+ CACHE_SM(t, read_test, { cacheProcessor.open_read(this, &key, false); } );
read_test.expect_initial_event = CACHE_EVENT_OPEN_READ;
read_test.expect_event = VC_EVENT_READ_COMPLETE;
read_test.nbytes = 100;
read_test.key = write_test.key;
- CACHE_SM(t, remove_test, { cacheProcessor.remove(this, &key); } );
+ CACHE_SM(t, remove_test, { cacheProcessor.remove(this, &key, false); } );
remove_test.expect_event = CACHE_EVENT_REMOVE;
remove_test.key = write_test.key;
- CACHE_SM(t, lookup_fail_test, { cacheProcessor.lookup(this, &key); } );
+ CACHE_SM(t, lookup_fail_test, { cacheProcessor.lookup(this, &key, false); } );
lookup_fail_test.expect_event = CACHE_EVENT_LOOKUP_FAILED;
lookup_fail_test.key = write_test.key;
- CACHE_SM(t, read_fail_test, { cacheProcessor.open_read(this, &key); } );
+ CACHE_SM(t, read_fail_test, { cacheProcessor.open_read(this, &key, false); } );
read_fail_test.expect_event = CACHE_EVENT_OPEN_READ_FAILED;
read_fail_test.key = write_test.key;
- CACHE_SM(t, remove_fail_test, { cacheProcessor.remove(this, &key); } );
+ CACHE_SM(t, remove_fail_test, { cacheProcessor.remove(this, &key, false); } );
remove_fail_test.expect_event = CACHE_EVENT_REMOVE_FAILED;
rand_CacheKey(&remove_fail_test.key, thread->mutex);
CACHE_SM(t, replace_write_test, {
- cacheProcessor.open_write(this, &key, CACHE_FRAG_TYPE_NONE, 100,
+ cacheProcessor.open_write(this, &key, false, CACHE_FRAG_TYPE_NONE, 100,
CACHE_WRITE_OPT_SYNC);
}
int open_write_callout() {
@@ -335,7 +335,7 @@ EXCLUSIVE_REGRESSION_TEST(cache)(RegressionTest *t, int atype, int *pstatus) {
rand_CacheKey(&replace_write_test.key, thread->mutex);
CACHE_SM(t, replace_test, {
- cacheProcessor.open_write(this, &key, CACHE_FRAG_TYPE_NONE, 100,
+ cacheProcessor.open_write(this, &key, false, CACHE_FRAG_TYPE_NONE, 100,
CACHE_WRITE_OPT_OVERWRITE_SYNC);
}
int open_write_callout() {
@@ -357,7 +357,7 @@ EXCLUSIVE_REGRESSION_TEST(cache)(RegressionTest *t, int atype, int *pstatus) {
replace_test.content_salt = 1;
CACHE_SM(t, replace_read_test, {
- cacheProcessor.open_read(this, &key);
+ cacheProcessor.open_read(this, &key, false);
}
int open_read_callout() {
CacheTestHeader *h = 0;
@@ -376,7 +376,7 @@ EXCLUSIVE_REGRESSION_TEST(cache)(RegressionTest *t, int atype, int *pstatus) {
replace_read_test.content_salt = 1;
CACHE_SM(t, large_write_test, { cacheProcessor.open_write(
- this, &key, CACHE_FRAG_TYPE_NONE, 100,
+ this, &key, false, CACHE_FRAG_TYPE_NONE, 100,
CACHE_WRITE_OPT_SYNC); } );
large_write_test.expect_initial_event = CACHE_EVENT_OPEN_WRITE;
large_write_test.expect_event = VC_EVENT_WRITE_COMPLETE;
@@ -384,7 +384,7 @@ EXCLUSIVE_REGRESSION_TEST(cache)(RegressionTest *t, int atype, int *pstatus) {
rand_CacheKey(&large_write_test.key, thread->mutex);
CACHE_SM(t, pread_test, {
- cacheProcessor.open_read(this, &key);
+ cacheProcessor.open_read(this, &key, false);
}
int open_read_callout() {
cvio = cache_vc->do_io_pread(this, nbytes, buffer, 7000000);
View
2  iocore/cache/CacheVol.cc
@@ -307,7 +307,7 @@ CacheVC::scanObject(int event, Event * e)
ink_debug_assert(hostinfo_copied);
SET_HANDLER(&CacheVC::scanRemoveDone);
// force remove even if there is a writer
- cacheProcessor.remove(this, &doc->first_key, CACHE_FRAG_TYPE_HTTP, true, false, (char *) hname, hlen);
+ cacheProcessor.remove(this, &doc->first_key, true, CACHE_FRAG_TYPE_HTTP, true, false, (char *) hname, hlen);
return EVENT_CONT;
} else {
offset = (char *) doc - buf->data();
View
17 iocore/cache/I_Cache.h
@@ -76,16 +76,17 @@ struct CacheProcessor:public Processor
int dir_check(bool fix);
int db_check(bool fix);
- inkcoreapi Action *lookup(Continuation *cont, CacheKey *key,
+ inkcoreapi Action *lookup(Continuation *cont, CacheKey *key, bool cluster_cache_local,
bool local_only = false,
CacheFragType frag_type = CACHE_FRAG_TYPE_NONE, char *hostname = 0, int host_len = 0);
- inkcoreapi Action *open_read(Continuation *cont, CacheKey *key,
+ inkcoreapi Action *open_read(Continuation *cont, CacheKey *key, bool cluster_cache_local,
CacheFragType frag_type = CACHE_FRAG_TYPE_NONE, char *hostname = 0, int host_len = 0);
Action *open_read_buffer(Continuation *cont, MIOBuffer *buf, CacheKey *key,
CacheFragType frag_type = CACHE_FRAG_TYPE_NONE, char *hostname = 0, int host_len = 0);
inkcoreapi Action *open_write(Continuation *cont,
CacheKey *key,
+ bool cluster_cache_local,
CacheFragType frag_type = CACHE_FRAG_TYPE_NONE,
int expected_size = CACHE_EXPECTED_SIZE,
int options = 0,
@@ -98,36 +99,38 @@ struct CacheProcessor:public Processor
time_t pin_in_cache = (time_t) 0,
char *hostname = 0, int host_len = 0);
inkcoreapi Action *remove(Continuation *cont, CacheKey *key,
+ bool cluster_cache_local,
CacheFragType frag_type = CACHE_FRAG_TYPE_NONE,
bool rm_user_agents = true, bool rm_link = false,
char *hostname = 0, int host_len = 0);
Action *scan(Continuation *cont, char *hostname = 0, int host_len = 0, int KB_per_second = SCAN_KB_PER_SECOND);
#ifdef HTTP_CACHE
- Action *lookup(Continuation *cont, URL *url, bool local_only = false,
+ Action *lookup(Continuation *cont, URL *url, bool cluster_cache_local, bool local_only = false,
CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP);
inkcoreapi Action *open_read(Continuation *cont, URL *url,
+ bool cluster_cache_local,
CacheHTTPHdr *request,
CacheLookupHttpConfig *params,
time_t pin_in_cache = (time_t) 0, CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP);
Action *open_read_buffer(Continuation *cont, MIOBuffer *buf, URL *url,
CacheHTTPHdr *request,
CacheLookupHttpConfig *params, CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP);
- Action *open_write(Continuation *cont, int expected_size, URL *url,
+ Action *open_write(Continuation *cont, int expected_size, URL *url, bool cluster_cache_local,
CacheHTTPHdr *request, CacheHTTPInfo *old_info,
time_t pin_in_cache = (time_t) 0, CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP);
Action *open_write_buffer(Continuation *cont, MIOBuffer *buf, URL *url,
CacheHTTPHdr *request, CacheHTTPHdr *response,
CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP);
- Action *remove(Continuation *cont, URL *url, CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP);
+ Action *remove(Continuation *cont, URL *url, bool cluster_cache_local, CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP);
Action *open_read_internal(int, Continuation *, MIOBuffer *, CacheURL *,
CacheHTTPHdr *, CacheLookupHttpConfig *,
CacheKey *, time_t, CacheFragType type, char *hostname, int host_len);
#endif
- Action *link(Continuation *cont, CacheKey *from, CacheKey *to,
+ Action *link(Continuation *cont, CacheKey *from, CacheKey *to, bool cluster_cache_local,
CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP, char *hostname = 0, int host_len = 0);
- Action *deref(Continuation *cont, CacheKey *key,
+ Action *deref(Continuation *cont, CacheKey *key, bool cluster_cache_local,
CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP, char *hostname = 0, int host_len = 0);
static int IsCacheEnabled();
View
28 iocore/cache/P_CacheInternal.h
@@ -1100,13 +1100,13 @@ cache_hash(INK_MD5 & md5)
#endif
TS_INLINE Action *
-CacheProcessor::lookup(Continuation *cont, CacheKey *key, bool local_only,
+CacheProcessor::lookup(Continuation *cont, CacheKey *key, bool cluster_cache_local, bool local_only,
CacheFragType frag_type, char *hostname, int host_len)
{
(void) local_only;
#ifdef CLUSTER_CACHE
// Try to send remote, if not possible, handle locally
- if ((cache_clustering_enabled > 0) && !local_only) {
+ if ((cache_clustering_enabled > 0) && !cluster_cache_local && !local_only) {
Action *a = Cluster_lookup(cont, key, frag_type, hostname, host_len);
if (a) {
return a;
@@ -1117,10 +1117,10 @@ CacheProcessor::lookup(Continuation *cont, CacheKey *key, bool local_only,
}
TS_INLINE inkcoreapi Action *
-CacheProcessor::open_read(Continuation *cont, CacheKey *key, CacheFragType frag_type, char *hostname, int host_len)
+CacheProcessor::open_read(Continuation *cont, CacheKey *key, bool cluster_cache_local, CacheFragType frag_type, char *hostname, int host_len)
{
#ifdef CLUSTER_CACHE
- if (cache_clustering_enabled > 0) {
+ if (cache_clustering_enabled > 0 && !cluster_cache_local) {
return open_read_internal(CACHE_OPEN_READ, cont, (MIOBuffer *) 0,
(CacheURL *) 0, (CacheHTTPHdr *) 0,
(CacheLookupHttpConfig *) 0, key, 0, frag_type, hostname, host_len);
@@ -1146,13 +1146,13 @@ CacheProcessor::open_read_buffer(Continuation *cont, MIOBuffer *buf, CacheKey *k
TS_INLINE inkcoreapi Action *
-CacheProcessor::open_write(Continuation *cont, CacheKey *key, CacheFragType frag_type,
+CacheProcessor::open_write(Continuation *cont, CacheKey *key, bool cluster_cache_local, CacheFragType frag_type,
int expected_size, int options, time_t pin_in_cache,
char *hostname, int host_len)
{
(void) expected_size;
#ifdef CLUSTER_CACHE
- if (cache_clustering_enabled > 0) {
+ if (cache_clustering_enabled > 0 && !cluster_cache_local) {
ClusterMachine *m = cluster_machine_at_depth(cache_hash(*key));
if (m)
return Cluster_write(cont, expected_size, (MIOBuffer *) 0, m,
@@ -1182,12 +1182,12 @@ CacheProcessor::open_write_buffer(Continuation *cont, MIOBuffer *buf, CacheKey *
}
TS_INLINE Action *
-CacheProcessor::remove(Continuation *cont, CacheKey *key, CacheFragType frag_type,
+CacheProcessor::remove(Continuation *cont, CacheKey *key, bool cluster_cache_local, CacheFragType frag_type,
bool rm_user_agents, bool rm_link, char *hostname, int host_len)
{
Debug("cache_remove", "[CacheProcessor::remove] Issuing cache delete for %u", cache_hash(*key));
#ifdef CLUSTER_CACHE
- if (cache_clustering_enabled > 0) {
+ if (cache_clustering_enabled > 0 && !cluster_cache_local) {
ClusterMachine *m = cluster_machine_at_depth(cache_hash(*key));
if (m) {
@@ -1206,7 +1206,7 @@ scan(Continuation *cont, char *hostname = 0, int host_len = 0, int KB_per_second
#ifdef HTTP_CACHE
TS_INLINE Action *
-CacheProcessor::lookup(Continuation *cont, URL *url, bool local_only, CacheFragType frag_type)
+CacheProcessor::lookup(Continuation *cont, URL *url, bool cluster_cache_local, bool local_only, CacheFragType frag_type)
{
(void) local_only;
INK_MD5 md5;
@@ -1214,7 +1214,7 @@ CacheProcessor::lookup(Continuation *cont, URL *url, bool local_only, CacheFragT
int host_len = 0;
const char *hostname = url->host_get(&host_len);
- return lookup(cont, &md5, local_only, frag_type, (char *) hostname, host_len);
+ return lookup(cont, &md5, cluster_cache_local, local_only, frag_type, (char *) hostname, host_len);
}
TS_INLINE Action *
@@ -1282,10 +1282,10 @@ CacheProcessor::open_read_internal(int opcode,
#ifdef CLUSTER_CACHE
TS_INLINE Action *
-CacheProcessor::link(Continuation *cont, CacheKey *from, CacheKey *to,
+CacheProcessor::link(Continuation *cont, CacheKey *from, CacheKey *to, bool cluster_cache_local,
CacheFragType type, char *hostname, int host_len)
{
- if (cache_clustering_enabled > 0) {
+ if (cache_clustering_enabled > 0 && !cluster_cache_local) {
// Use INK_MD5 in "from" to determine target machine
ClusterMachine *m = cluster_machine_at_depth(cache_hash(*from));
if (m) {
@@ -1296,9 +1296,9 @@ CacheProcessor::link(Continuation *cont, CacheKey *from, CacheKey *to,
}
TS_INLINE Action *
-CacheProcessor::deref(Continuation *cont, CacheKey *key, CacheFragType type, char *hostname, int host_len)
+CacheProcessor::deref(Continuation *cont, CacheKey *key, bool cluster_cache_local, CacheFragType type, char *hostname, int host_len)
{
- if (cache_clustering_enabled > 0) {
+ if (cache_clustering_enabled > 0 && !cluster_cache_local) {
ClusterMachine *m = cluster_machine_at_depth(cache_hash(*key));
if (m) {
return Cluster_deref(m, cont, key, type, hostname, host_len);
View
2  mgmt/RecordsConfig.cc
@@ -639,6 +639,8 @@ RecordElement RecordsConfig[] = {
// #################
{RECT_CONFIG, "proxy.config.http.cache.http", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
,
+ {RECT_CONFIG, "proxy.config.http.cache.cluster_cache_local", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
+ ,
{RECT_CONFIG, "proxy.config.http.cache.ignore_client_no_cache", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
,
{RECT_CONFIG, "proxy.config.http.cache.ignore_client_cc_max_age", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
View
4 mgmt/api/CfgContextImpl.cc
@@ -152,6 +152,9 @@ CacheObj::formatEleToRule()
case TS_CACHE_IGNORE_NO_CACHE:
ink_strlcat(buf, "action=ignore-no-cache ", sizeof(buf));
break;
+ case TS_CACHE_CLUSTER_CACHE_LOCAL:
+ ink_strlcat(buf, "action=cluster-cache-local ", sizeof(buf));
+ break;
case TS_CACHE_IGNORE_CLIENT_NO_CACHE:
ink_strlcat(buf, "action=ignore-client-no-cache ", sizeof(buf));
break;
@@ -213,6 +216,7 @@ bool CacheObj::isValid()
switch (m_ele->cfg_ele.type) {
case TS_CACHE_NEVER:
case TS_CACHE_IGNORE_NO_CACHE:
+ case TS_CACHE_CLUSTER_CACHE_LOCAL:
case TS_CACHE_IGNORE_CLIENT_NO_CACHE:
case TS_CACHE_IGNORE_SERVER_NO_CACHE:
case TS_CACHE_AUTH_CONTENT:
View
4 mgmt/api/CfgContextUtils.cc
@@ -1919,6 +1919,7 @@ create_ele_obj_from_rule_node(Rule * rule)
switch (rule_type) {
case TS_CACHE_NEVER: /* all cache rules use same constructor */
case TS_CACHE_IGNORE_NO_CACHE:
+ case TS_CACHE_CLUSTER_CACHE_LOCAL:
case TS_CACHE_IGNORE_CLIENT_NO_CACHE:
case TS_CACHE_IGNORE_SERVER_NO_CACHE:
case TS_CACHE_PIN_IN_CACHE:
@@ -2006,6 +2007,7 @@ create_ele_obj_from_ele(TSCfgEle * ele)
switch (ele->type) {
case TS_CACHE_NEVER: /* cache.config */
case TS_CACHE_IGNORE_NO_CACHE: // fall-through
+ case TS_CACHE_CLUSTER_CACHE_LOCAL:
case TS_CACHE_IGNORE_CLIENT_NO_CACHE: // fall-through
case TS_CACHE_IGNORE_SERVER_NO_CACHE: // fall-through
case TS_CACHE_PIN_IN_CACHE: // fall-through
@@ -2112,6 +2114,8 @@ get_rule_type(TokenList * token_list, TSFileNameT file)
return TS_CACHE_NEVER;
} else if (strcmp(tok->value, "ignore-no-cache") == 0) {
return TS_CACHE_IGNORE_NO_CACHE;
+ } else if (strcmp(tok->value, "cluster-cache-local") == 0) {
+ return TS_CACHE_CLUSTER_CACHE_LOCAL;
} else if (strcmp(tok->value, "ignore-client-no-cache") == 0) {
return TS_CACHE_IGNORE_CLIENT_NO_CACHE;
} else if (strcmp(tok->value, "ignore-server-no-cache") == 0) {
View
1  mgmt/api/INKMgmtAPI.cc
@@ -880,6 +880,7 @@ TSCacheEleCreate(TSRuleTypeT type)
if (type != TS_CACHE_NEVER &&
type != TS_CACHE_IGNORE_NO_CACHE &&
+ type != TS_CACHE_CLUSTER_CACHE_LOCAL &&
type != TS_CACHE_IGNORE_CLIENT_NO_CACHE &&
type != TS_CACHE_IGNORE_SERVER_NO_CACHE &&
type != TS_CACHE_PIN_IN_CACHE &&
View
1  mgmt/api/include/mgmtapi.h
@@ -391,6 +391,7 @@ extern "C"
{
TS_CACHE_NEVER, /* cache.config */
TS_CACHE_IGNORE_NO_CACHE,
+ TS_CACHE_CLUSTER_CACHE_LOCAL,
TS_CACHE_IGNORE_CLIENT_NO_CACHE,
TS_CACHE_IGNORE_SERVER_NO_CACHE,
TS_CACHE_PIN_IN_CACHE,
View
3  mgmt/api/remote/APITestCliRemote.cc
@@ -400,6 +400,9 @@ print_cache_ele(TSCacheEle * ele)
case TS_CACHE_IGNORE_NO_CACHE:
snprintf(buf + buf_pos, sizeof(buf) - buf_pos, "action=ignore-no-cache");
break;
+ case TS_CACHE_CLUSTER_CACHE_LOCAL:
+ snprintf(buf + buf_pos, sizeof(buf) - buf_pos, "action=cluster-cache-local");
+ break;
case TS_CACHE_IGNORE_CLIENT_NO_CACHE:
snprintf(buf + buf_pos, sizeof(buf) - buf_pos, "action=ignore-server-no-cache");
break;
View
3  mgmt/cli/ConfigCmd.cc
@@ -1458,6 +1458,9 @@ Cmd_ConfigCache(ClientData clientData, Tcl_Interp * interp, int argc, const char
case CMD_CONFIG_CACHE_HTTP:
return (Cli_RecordOnOff_Action((argc == 3), "proxy.config.http.cache.http", argtable->arg_string));
+ case CMD_CONFIG_CACHE_CLUSTER_BYPASS:
+ return (Cli_RecordOnOff_Action((argc == 3),
+ "proxy.config.http.cache.cluster_cache_local", argtable->arg_string));
case CMD_CONFIG_CACHE_IGNORE_BYPASS:
return (Cli_RecordOnOff_Action((argc == 3),
"proxy.config.http.cache.ignore_client_no_cache", argtable->arg_string));
View
1  mgmt/cli/ConfigCmd.h
@@ -153,6 +153,7 @@ typedef enum
CMD_CONFIG_CACHE_ON,
CMD_CONFIG_CACHE_OFF,
CMD_CONFIG_CACHE_HTTP,
+ CMD_CONFIG_CACHE_CLUSTER_BYPASS,
CMD_CONFIG_CACHE_IGNORE_BYPASS,
CMD_CONFIG_CACHE_MAX_OBJECT_SIZE,
CMD_CONFIG_CACHE_MAX_ALTERNATES,
View
12 mgmt/cli/cli_detailed_command_list.txt
@@ -415,6 +415,7 @@ cache Cache Configuration
ts> show:cache
HTTP Caching ------------------- on (proxy.config.http.cache.http)
+ Ignore User Requests To Bypass Cluster --- off (proxy.config.http.cache.cluster_cache_local)
Ignore User Requests To Bypass Cache --- off (proxy.config.http.cache.ignore_client_no_cache)
Maximum HTTP Object Size --- NONE (proxy.config.cache.max_doc_size)
@@ -1066,6 +1067,17 @@ cache Cache Configuration
on
ts#
+ syntax: config:cache cluster-bypass <on | off>
+ args: <on | off> turn cluster-bypass on/off.
+
+ ts# config:cache cluster-bypass on (proxy.config.http.cache.cluster_cache_local)
+ +OK
+ ts#
+
+ ts# config:cache cluster-bypass
+ on
+ ts#
+
syntax: config:cache ignore-bypass <on | off>
args: <on | off> turn ignore-bypass on/off.
View
34 proxy/CacheControl.cc
@@ -61,6 +61,7 @@ static const char *CC_directive_str[CC_NUM_TYPES] = {
"NEVER_CACHE",
"STANDARD_CACHE",
"IGNORE_NO_CACHE",
+ "CLUSTER_CACHE_LOCAL",
"IGNORE_CLIENT_NO_CACHE",
"IGNORE_SERVER_NO_CACHE",
"PIN_IN_CACHE",
@@ -184,6 +185,10 @@ getCacheControl(CacheControlResult *result, HttpRequestData *rdata, OverridableH
rdata->tag = tag;
CacheControlTable->Match(rdata, result);
+ if (h_txn_conf->cache_cluster_cache_local) {
+ result->cluster_cache_local = true;
+ }
+
if (h_txn_conf->cache_ignore_client_no_cache) {
result->ignore_client_no_cache = true;
}
@@ -197,6 +202,20 @@ getCacheControl(CacheControlResult *result, HttpRequestData *rdata, OverridableH
}
}
+bool
+getClusterCacheLocal(URL *url, char *hostname)
+{
+ HttpRequestData rdata;
+ CacheControlResult result;
+ HTTPHdr req_hdr;
+
+ req_hdr.create(HTTP_TYPE_REQUEST, NULL);
+ req_hdr.url_set(url);
+ rdata.hdr = &req_hdr;
+ CacheControlTable->Match(&rdata, &result);
+ req_hdr.clear();
+ return result.cluster_cache_local;
+}
//
// End API functions
//
@@ -209,8 +228,8 @@ getCacheControl(CacheControlResult *result, HttpRequestData *rdata, OverridableH
void
CacheControlResult::Print()
{
- printf("\t reval: %d, never-cache: %d, pin: %d, ignore-c: %d ignore-s: %d\n",
- revalidate_after, never_cache, pin_in_cache_for, ignore_client_no_cache, ignore_server_no_cache);
+ printf("\t reval: %d, never-cache: %d, pin: %d, cluster-cache-c: %d ignore-c: %d ignore-s: %d\n",
+ revalidate_after, never_cache, pin_in_cache_for, cluster_cache_local, ignore_client_no_cache, ignore_server_no_cache);
}
// void CacheControlRecord::Print()
@@ -230,6 +249,7 @@ CacheControlRecord::Print()
case CC_TTL_IN_CACHE:
printf("\t\tDirective: %s : %d\n", CC_directive_str[CC_TTL_IN_CACHE], this->time_arg);
break;
+ case CC_CLUSTER_CACHE_LOCAL:
case CC_IGNORE_CLIENT_NO_CACHE:
case CC_IGNORE_SERVER_NO_CACHE:
case CC_NEVER_CACHE:
@@ -321,6 +341,9 @@ CacheControlRecord::Init(matcher_line * line_info)
} else if (strcasecmp(val, "ignore-no-cache") == 0) {
directive = CC_IGNORE_NO_CACHE;
d_found = true;
+ } else if (strcasecmp(val, "cluster-cache-local") == 0) {
+ directive = CC_CLUSTER_CACHE_LOCAL;;
+ d_found = true;
} else if (strcasecmp(val, "ignore-client-no-cache") == 0) {
directive = CC_IGNORE_CLIENT_NO_CACHE;
d_found = true;
@@ -442,6 +465,13 @@ CacheControlRecord::UpdateMatch(CacheControlResult * result, RD * rdata)
match = true;
}
break;
+ case CC_CLUSTER_CACHE_LOCAL:
+ if (this->CheckForMatch(h_rdata, result->cluster_cache_local_line) == true) {
+ result->cluster_cache_local = true;
+ result->cluster_cache_local_line = this->line_num;
+ match = true;
+ }
+ break;
case CC_PIN_IN_CACHE:
if (this->CheckForMatch(h_rdata, result->pin_line) == true) {
result->pin_in_cache_for = time_arg;
View
6 proxy/CacheControl.h
@@ -53,6 +53,7 @@ enum CacheControlType
CC_NEVER_CACHE,
CC_STANDARD_CACHE,
CC_IGNORE_NO_CACHE,
+ CC_CLUSTER_CACHE_LOCAL,
CC_IGNORE_CLIENT_NO_CACHE,
//CC_IGNORE_SERVER_NO_CACHE,CC_PIN_IN_CACHE, CC_TTL_IN_CACHE, CC_CACHE_AUTH_CONTENT, CC_NUM_TYPES
CC_IGNORE_SERVER_NO_CACHE,
@@ -78,6 +79,7 @@ class CacheControlResult
int pin_in_cache_for;
int ttl_in_cache;
bool never_cache;
+ bool cluster_cache_local;
bool ignore_client_no_cache;
bool ignore_server_no_cache;
bool ignore_client_cc_max_age;
@@ -96,6 +98,7 @@ class CacheControlResult
int never_line;
int pin_line;
int ttl_line;
+ int cluster_cache_local_line;
int ignore_client_line;
int ignore_server_line;
// int cache_auth_line;
@@ -107,6 +110,7 @@ CacheControlResult::CacheControlResult()
pin_in_cache_for(CC_UNSET_TIME),
ttl_in_cache(CC_UNSET_TIME),
never_cache(false),
+ cluster_cache_local(false),
ignore_client_no_cache(false),
ignore_server_no_cache(false),
ignore_client_cc_max_age(true),
@@ -116,6 +120,7 @@ CacheControlResult::CacheControlResult()
never_line(-1),
pin_line(-1),
ttl_line(-1),
+ cluster_cache_local_line(-1),
ignore_client_line(-1),
ignore_server_line(-1)
//cache_auth_line(-1)
@@ -148,6 +153,7 @@ struct OverridableHttpConfigParams;
inkcoreapi void getCacheControl(CacheControlResult *result, HttpRequestData * rdata,
OverridableHttpConfigParams *h_txn_conf, char *tag = NULL);
+inkcoreapi bool getClusterCacheLocal(URL *url, char *hostname);
inkcoreapi bool host_rule_in_CacheControlTable();
inkcoreapi bool ip_rule_in_CacheControlTable();
View
4 proxy/ICP.cc
@@ -490,10 +490,10 @@ ICPPeerReadCont::ICPPeerQueryCont(int event, Event * e)
// Note: _cache_lookup_local is ignored in this case, since
// cache clustering is not used with stale lookup.
//////////////////////////////////////////////////////////////
- a = cacheProcessor.open_read(this, &_state->_cachelookupURL,
+ a = cacheProcessor.open_read(this, &_state->_cachelookupURL, false,
&gclient_request, &global_cache_lookup_config, (time_t) 0);
} else {
- a = cacheProcessor.lookup(this, &_state->_cachelookupURL, _state->_cache_lookup_local);
+ a = cacheProcessor.lookup(this, &_state->_cachelookupURL, false, _state->_cache_lookup_local);
}
if (!a) {
a = ACTION_IO_ERROR;
View
11 proxy/InkAPI.cc
@@ -6606,7 +6606,7 @@ TSCacheRead(TSCont contp, TSCacheKey key)
CacheInfo *info = (CacheInfo *) key;
Continuation *i = (INKContInternal *) contp;
- return (TSAction)cacheProcessor.open_read(i, &info->cache_key, info->frag_type, info->hostname, info->len);
+ return (TSAction)cacheProcessor.open_read(i, &info->cache_key, true, info->frag_type, info->hostname, info->len);
}
TSAction
@@ -6620,7 +6620,7 @@ TSCacheWrite(TSCont contp, TSCacheKey key)
CacheInfo *info = (CacheInfo *) key;
Continuation *i = (INKContInternal *) contp;
- return (TSAction)cacheProcessor.open_write(i, &info->cache_key, info->frag_type, 0, false, info->pin_in_cache,
+ return (TSAction)cacheProcessor.open_write(i, &info->cache_key, true, info->frag_type, 0, false, info->pin_in_cache,
info->hostname, info->len);
}
@@ -6635,7 +6635,7 @@ TSCacheRemove(TSCont contp, TSCacheKey key)
CacheInfo *info = (CacheInfo *) key;
INKContInternal *i = (INKContInternal *) contp;
- return (TSAction)cacheProcessor.remove(i, &info->cache_key, info->frag_type, true, false, info->hostname, info->len);
+ return (TSAction)cacheProcessor.remove(i, &info->cache_key, true, info->frag_type, true, false, info->hostname, info->len);
}
TSAction
@@ -7435,6 +7435,9 @@ _conf_to_memberp(TSOverridableConfigKey conf, HttpSM* sm, OverridableDataType *t
case TS_CONFIG_HTTP_CACHE_HTTP:
ret = &sm->t_state.txn_conf->cache_http;
break;
+ case TS_CONFIG_HTTP_CACHE_CLUSTER_CACHE_LOCAL:
+ ret = &sm->t_state.txn_conf->cache_cluster_cache_local;
+ break;
case TS_CONFIG_HTTP_CACHE_IGNORE_CLIENT_NO_CACHE:
ret = &sm->t_state.txn_conf->cache_ignore_client_no_cache;
break;
@@ -7946,6 +7949,8 @@ TSHttpTxnConfigFind(const char* name, int length, TSOverridableConfigKey *conf,
case 46:
switch (name[length-1]) {
case 'e':
+ if (!strncmp(name, "proxy.config.http.cache.cluster_cache_local", length))
+ cnf = TS_CONFIG_HTTP_CACHE_CLUSTER_CACHE_LOCAL;
if (!strncmp(name, "proxy.config.http.cache.ignore_client_no_cache", length))
cnf = TS_CONFIG_HTTP_CACHE_IGNORE_CLIENT_NO_CACHE;
else if (!strncmp(name, "proxy.config.http.cache.ims_on_client_no_cache", length))
View
1  proxy/InkAPITest.cc
@@ -7362,6 +7362,7 @@ const char *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY] = {
"proxy.config.http.server_tcp_init_cwnd",
"proxy.config.http.send_http11_requests",
"proxy.config.http.cache.http",
+ "proxy.config.http.cache.cluster_cache_local",
"proxy.config.http.cache.ignore_client_no_cache",
"proxy.config.http.cache.ignore_client_cc_max_age",
"proxy.config.http.cache.ims_on_client_no_cache",
View
2  proxy/Prefetch.cc
@@ -1394,7 +1394,7 @@ PrefetchBlaster::handleEvent(int event, void *data)
//if (cache_lookup_necessary) do:
initCacheLookupConfig();
- cacheProcessor.open_read(this, request->url_get(), request, &cache_lookup_config, 0);
+ cacheProcessor.open_read(this, request->url_get(), false, request, &cache_lookup_config, 0);
break;
}
View
8 proxy/TestProxy.cc
@@ -212,7 +212,7 @@ struct TestProxy:Continuation
SET_HANDLER(cacheCheckEvent);
url_struct = new URL((const char *) url_str, sizeof(url_str), true);
hostdbinfo = info;
- cacheProcessor.lookup(this, url_struct);
+ cacheProcessor.lookup(this, url_struct, false);
// SET_HANDLER(connectEvent);
// netProcessor.connect(this,info->ip,port,host);
return EVENT_DONE;
@@ -225,12 +225,12 @@ struct TestProxy:Continuation
cout << "Removing object from the cache\n";
SET_HANDLER(NULL);
amode = 0;
- cacheProcessor.remove(&(((CacheObjInfoVector *) data)->data[0]));
+ cacheProcessor.remove(&(((CacheObjInfoVector *) data)->data[0]), false);
return done();
} else {
cout << "Serving the object from cache\n";
SET_HANDLER(cacheReadEvent);
- cacheProcessor.open_read(this, &(((CacheObjInfoVector *) data)->data[0]));
+ cacheProcessor.open_read(this, &(((CacheObjInfoVector *) data)->data[0]), false);
return EVENT_CONT;
}
} else if (event == CACHE_EVENT_LOOKUP_FAILED) {
@@ -240,7 +240,7 @@ struct TestProxy:Continuation
request_header = new HttpHeader;
request_header->m_url = *url_struct;
objinfo->request = *request_header;
- cacheProcessor.open_write(this, objinfo, CACHE_UNKNOWN_SIZE);
+ cacheProcessor.open_write(this, objinfo, false, CACHE_UNKNOWN_SIZE);
return EVENT_DONE;
} else {
printf("TestProxy cacheCheckEvent error %d\n", event);
View
1  proxy/api/ts/ts.h.in
@@ -572,6 +572,7 @@ extern "C"
TS_CONFIG_HTTP_SERVER_TCP_INIT_CWND,
TS_CONFIG_HTTP_SEND_HTTP11_REQUESTS,
TS_CONFIG_HTTP_CACHE_HTTP,
+ TS_CONFIG_HTTP_CACHE_CLUSTER_CACHE_LOCAL,
TS_CONFIG_HTTP_CACHE_IGNORE_CLIENT_NO_CACHE,
TS_CONFIG_HTTP_CACHE_IGNORE_CLIENT_CC_MAX_AGE,
TS_CONFIG_HTTP_CACHE_IMS_ON_CLIENT_NO_CACHE,
View
3  proxy/http/HttpCacheSM.cc
@@ -212,7 +212,7 @@ HttpCacheSM::do_cache_open_read()
}
//Initialising read-while-write-inprogress flag
this->readwhilewrite_inprogress = false;
- Action *action_handle = cacheProcessor.open_read(this, this->lookup_url, this->read_request_hdr, this->read_config,
+ Action *action_handle = cacheProcessor.open_read(this, this->lookup_url, master_sm->t_state.cache_control.cluster_cache_local, this->read_request_hdr, this->read_config,
this->read_pin_in_cache);
if (action_handle != ACTION_RESULT_DONE) {
@@ -301,6 +301,7 @@ HttpCacheSM::open_write(URL * url, HTTPHdr * request, CacheHTTPInfo * old_info,
Action *action_handle = cacheProcessor.open_write(this,
0,
url,
+ master_sm->t_state.cache_control.cluster_cache_local,
request,
// INKqa11166
allow_multiple ? (CacheHTTPInfo *) CACHE_ALLOW_MULTIPLE_WRITES :
View
2  proxy/http/HttpConfig.cc
@@ -1272,6 +1272,7 @@ HttpConfig::startup()
HttpEstablishStaticConfigLongLong(c.max_cache_open_write_retries, "proxy.config.http.cache.max_open_write_retries");
HttpEstablishStaticConfigByte(c.oride.cache_http, "proxy.config.http.cache.http");
+ HttpEstablishStaticConfigByte(c.oride.cache_cluster_cache_local, "proxy.config.http.cache.cluster_cache_local");
HttpEstablishStaticConfigByte(c.oride.cache_ignore_client_no_cache, "proxy.config.http.cache.ignore_client_no_cache");
HttpEstablishStaticConfigByte(c.oride.cache_ignore_client_cc_max_age, "proxy.config.http.cache.ignore_client_cc_max_age");
HttpEstablishStaticConfigByte(c.oride.cache_ims_on_client_no_cache, "proxy.config.http.cache.ims_on_client_no_cache");
@@ -1539,6 +1540,7 @@ HttpConfig::reconfigure()
params->max_cache_open_write_retries = m_master.max_cache_open_write_retries;
params->oride.cache_http = INT_TO_BOOL(m_master.oride.cache_http);
+ params->oride.cache_cluster_cache_local = INT_TO_BOOL(m_master.oride.cache_cluster_cache_local);
params->oride.cache_ignore_client_no_cache = INT_TO_BOOL(m_master.oride.cache_ignore_client_no_cache);
params->oride.cache_ignore_client_cc_max_age = INT_TO_BOOL(m_master.oride.cache_ignore_client_cc_max_age);
params->oride.cache_ims_on_client_no_cache = INT_TO_BOOL(m_master.oride.cache_ims_on_client_no_cache);
View
3  proxy/http/HttpConfig.h
@@ -409,7 +409,7 @@ struct OverridableHttpConfigParams {
anonymize_remove_cookie(0), anonymize_remove_client_ip(0), anonymize_insert_client_ip(1),
proxy_response_server_enabled(0), insert_squid_x_forwarded_for(0),
send_http11_requests(3), // SEND_HTTP11_IF_REQUEST_11_AND_HOSTDB
- cache_http(0), cache_ignore_client_no_cache(0), cache_ignore_client_cc_max_age(1),
+ cache_http(0), cache_cluster_cache_local(0), cache_ignore_client_no_cache(0), cache_ignore_client_cc_max_age(1),
cache_ims_on_client_no_cache(0), cache_ignore_server_no_cache(0), cache_responses_to_cookies(0),
cache_ignore_auth(0), cache_urls_that_look_dynamic(0), cache_required_headers(0), // CACHE_REQUIRED_HEADERS_NONE
insert_request_via_string(0), insert_response_via_string(0), doc_in_cache_skip_dns(1),
@@ -488,6 +488,7 @@ struct OverridableHttpConfigParams {
// cache control //
///////////////////
MgmtByte cache_http;
+ MgmtByte cache_cluster_cache_local;
MgmtByte cache_ignore_client_no_cache;
MgmtByte cache_ignore_client_cc_max_age;
MgmtByte cache_ims_on_client_no_cache;
View
2  proxy/http/HttpSM.cc
@@ -4183,7 +4183,7 @@ HttpSM::do_cache_delete_all_alts(Continuation * cont)
Action *cache_action_handle = NULL;
- cache_action_handle = cacheProcessor.remove(cont, t_state.cache_info.lookup_url);
+ cache_action_handle = cacheProcessor.remove(cont, t_state.cache_info.lookup_url, t_state.cache_control.cluster_cache_local);
if (cont != NULL) {
if (cache_action_handle != ACTION_RESULT_DONE) {
ink_assert(!pending_action);
Please sign in to comment.
Something went wrong with that request. Please try again.