trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject trafficserver git commit: Move CacheProcessor inlines to Cache.cc
Date Mon, 20 Apr 2015 15:45:21 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/master cd9c8a3b5 -> cd8fbec58


Move CacheProcessor inlines to Cache.cc

No functional changes here. Moving the CacheProcessor implementation
into Cache.cc makes the code easier to find and easier to refactor
in subsequent patches.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/cd8fbec5
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/cd8fbec5
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/cd8fbec5

Branch: refs/heads/master
Commit: cd8fbec5859eb9a0ecb829c6eb490739b27815ff
Parents: cd9c8a3
Author: James Peach <jpeach@apache.org>
Authored: Mon Apr 20 08:43:54 2015 -0700
Committer: James Peach <jpeach@apache.org>
Committed: Mon Apr 20 08:43:54 2015 -0700

----------------------------------------------------------------------
 iocore/cache/Cache.cc          | 159 +++++++++++++++++++++++++++++++++++
 iocore/cache/P_CacheInternal.h | 160 +-----------------------------------
 proxy/Makefile.am              |   2 +-
 3 files changed, 161 insertions(+), 160 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cd8fbec5/iocore/cache/Cache.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index 9e9eab9..f41e027 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -1175,6 +1175,165 @@ CacheProcessor::db_check(bool afix)
   return 0;
 }
 
+Action *
+CacheProcessor::lookup(Continuation *cont, CacheKey *key, bool cluster_cache_local ATS_UNUSED,
bool local_only ATS_UNUSED,
+                       CacheFragType frag_type, char *hostname, int host_len)
+{
+#ifdef CLUSTER_CACHE
+  // Try to send remote, if not possible, handle locally
+  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;
+    }
+  }
+#endif
+  return caches[frag_type]->lookup(cont, key, frag_type, hostname, host_len);
+}
+
+inkcoreapi Action *
+CacheProcessor::open_read(Continuation *cont, CacheKey *key, bool cluster_cache_local ATS_UNUSED,
CacheFragType frag_type,
+                          char *hostname, int host_len)
+{
+#ifdef CLUSTER_CACHE
+  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);
+  }
+#endif
+  return caches[frag_type]->open_read(cont, key, frag_type, hostname, host_len);
+}
+
+inkcoreapi Action *
+CacheProcessor::open_write(Continuation *cont, CacheKey *key, bool cluster_cache_local ATS_UNUSED,
CacheFragType frag_type,
+                           int expected_size ATS_UNUSED, int options, time_t pin_in_cache,
char *hostname, int host_len)
+{
+#ifdef CLUSTER_CACHE
+  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, key, frag_type, options,
pin_in_cache, CACHE_OPEN_WRITE, key,
+                           (CacheURL *)0, (CacheHTTPHdr *)0, (CacheHTTPInfo *)0, hostname,
host_len);
+  }
+#endif
+  return caches[frag_type]->open_write(cont, key, frag_type, options, pin_in_cache, hostname,
host_len);
+}
+
+Action *
+CacheProcessor::remove(Continuation *cont, CacheKey *key, bool cluster_cache_local ATS_UNUSED,
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 && !cluster_cache_local) {
+    ClusterMachine *m = cluster_machine_at_depth(cache_hash(*key));
+
+    if (m) {
+      return Cluster_remove(m, cont, key, rm_user_agents, rm_link, frag_type, hostname, host_len);
+    }
+  }
+#endif
+  return caches[frag_type]->remove(cont, key, frag_type, rm_user_agents, rm_link, hostname,
host_len);
+}
+
+#if 0
+Action *
+scan(Continuation *cont, char *hostname = 0, int host_len = 0, int KB_per_second = 2500)
+{
+  return caches[CACHE_FRAG_TYPE_HTTP]->scan(cont, hostname, host_len, KB_per_second);
+}
+#endif
+
+#ifdef HTTP_CACHE
+Action *
+CacheProcessor::lookup(Continuation *cont, URL *url, bool cluster_cache_local, bool local_only,
CacheFragType frag_type)
+{
+  (void)local_only;
+  INK_MD5 md5;
+  url->hash_get(&md5);
+  int host_len = 0;
+  const char *hostname = url->host_get(&host_len);
+
+  return lookup(cont, &md5, cluster_cache_local, local_only, frag_type, (char *)hostname,
host_len);
+}
+
+#endif
+
+
+#ifdef CLUSTER_CACHE
+Action *
+CacheProcessor::open_read_internal(int opcode, Continuation *cont, MIOBuffer *buf, CacheURL
*url, CacheHTTPHdr *request,
+                                   CacheLookupHttpConfig *params, CacheKey *key, time_t pin_in_cache,
CacheFragType frag_type,
+                                   char *hostname, int host_len)
+{
+  INK_MD5 url_md5;
+  if ((opcode == CACHE_OPEN_READ_LONG) || (opcode == CACHE_OPEN_READ_BUFFER_LONG)) {
+    Cache::generate_key(&url_md5, url);
+  } else {
+    url_md5 = *key;
+  }
+  ClusterMachine *m = cluster_machine_at_depth(cache_hash(url_md5));
+
+  if (m) {
+    return Cluster_read(m, opcode, cont, buf, url, request, params, key, pin_in_cache, frag_type,
hostname, host_len);
+  } else {
+    if ((opcode == CACHE_OPEN_READ_LONG) || (opcode == CACHE_OPEN_READ_BUFFER_LONG)) {
+      return caches[frag_type]->open_read(cont, &url_md5, request, params, frag_type,
hostname, host_len);
+    } else {
+      return caches[frag_type]->open_read(cont, key, frag_type, hostname, host_len);
+    }
+  }
+}
+#endif
+
+#ifdef CLUSTER_CACHE
+Action *
+CacheProcessor::link(Continuation *cont, CacheKey *from, CacheKey *to, bool cluster_cache_local,
CacheFragType type, char *hostname,
+                     int host_len)
+{
+  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) {
+      return Cluster_link(m, cont, from, to, type, hostname, host_len);
+    }
+  }
+  return caches[type]->link(cont, from, to, type, hostname, host_len);
+}
+
+Action *
+CacheProcessor::deref(Continuation *cont, CacheKey *key, bool cluster_cache_local, CacheFragType
type, char *hostname, int host_len)
+{
+  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);
+    }
+  }
+  return caches[type]->deref(cont, key, type, hostname, host_len);
+}
+#endif
+
+Action *
+CacheProcessor::scan(Continuation *cont, char *hostname, int host_len, int KB_per_second)
+{
+  return caches[CACHE_FRAG_TYPE_HTTP]->scan(cont, hostname, host_len, KB_per_second);
+}
+
+int
+CacheProcessor::IsCacheEnabled()
+{
+  return CacheProcessor::initialized;
+}
+
+bool
+CacheProcessor::IsCacheReady(CacheFragType type)
+{
+  if (IsCacheEnabled() != CACHE_INITIALIZED)
+    return 0;
+  return (bool)(cache_ready & (1 << type));
+}
+
 int
 Vol::db_check(bool /* fix ATS_UNUSED */)
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cd8fbec5/iocore/cache/P_CacheInternal.h
----------------------------------------------------------------------
diff --git a/iocore/cache/P_CacheInternal.h b/iocore/cache/P_CacheInternal.h
index 569182d..dadeffe 100644
--- a/iocore/cache/P_CacheInternal.h
+++ b/iocore/cache/P_CacheInternal.h
@@ -1105,6 +1105,7 @@ cache_hash(INK_MD5 &md5)
 #ifdef HTTP_CACHE
 #define CLUSTER_CACHE
 #endif
+
 #ifdef CLUSTER_CACHE
 #include "P_Net.h"
 #include "P_ClusterInternal.h"
@@ -1113,165 +1114,6 @@ cache_hash(INK_MD5 &md5)
 #include "P_ClusterInline.h"
 #endif
 
-TS_INLINE Action *
-CacheProcessor::lookup(Continuation *cont, CacheKey *key, bool cluster_cache_local ATS_UNUSED,
bool local_only ATS_UNUSED,
-                       CacheFragType frag_type, char *hostname, int host_len)
-{
-#ifdef CLUSTER_CACHE
-  // Try to send remote, if not possible, handle locally
-  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;
-    }
-  }
-#endif
-  return caches[frag_type]->lookup(cont, key, frag_type, hostname, host_len);
-}
-
-TS_INLINE inkcoreapi Action *
-CacheProcessor::open_read(Continuation *cont, CacheKey *key, bool cluster_cache_local ATS_UNUSED,
CacheFragType frag_type,
-                          char *hostname, int host_len)
-{
-#ifdef CLUSTER_CACHE
-  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);
-  }
-#endif
-  return caches[frag_type]->open_read(cont, key, frag_type, hostname, host_len);
-}
-
-TS_INLINE inkcoreapi Action *
-CacheProcessor::open_write(Continuation *cont, CacheKey *key, bool cluster_cache_local ATS_UNUSED,
CacheFragType frag_type,
-                           int expected_size ATS_UNUSED, int options, time_t pin_in_cache,
char *hostname, int host_len)
-{
-#ifdef CLUSTER_CACHE
-  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, key, frag_type, options,
pin_in_cache, CACHE_OPEN_WRITE, key,
-                           (CacheURL *)0, (CacheHTTPHdr *)0, (CacheHTTPInfo *)0, hostname,
host_len);
-  }
-#endif
-  return caches[frag_type]->open_write(cont, key, frag_type, options, pin_in_cache, hostname,
host_len);
-}
-
-TS_INLINE Action *
-CacheProcessor::remove(Continuation *cont, CacheKey *key, bool cluster_cache_local ATS_UNUSED,
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 && !cluster_cache_local) {
-    ClusterMachine *m = cluster_machine_at_depth(cache_hash(*key));
-
-    if (m) {
-      return Cluster_remove(m, cont, key, rm_user_agents, rm_link, frag_type, hostname, host_len);
-    }
-  }
-#endif
-  return caches[frag_type]->remove(cont, key, frag_type, rm_user_agents, rm_link, hostname,
host_len);
-}
-
-#if 0
-TS_INLINE Action *
-scan(Continuation *cont, char *hostname = 0, int host_len = 0, int KB_per_second = 2500)
-{
-  return caches[CACHE_FRAG_TYPE_HTTP]->scan(cont, hostname, host_len, KB_per_second);
-}
-#endif
-
-#ifdef HTTP_CACHE
-TS_INLINE Action *
-CacheProcessor::lookup(Continuation *cont, URL *url, bool cluster_cache_local, bool local_only,
CacheFragType frag_type)
-{
-  (void)local_only;
-  INK_MD5 md5;
-  url->hash_get(&md5);
-  int host_len = 0;
-  const char *hostname = url->host_get(&host_len);
-
-  return lookup(cont, &md5, cluster_cache_local, local_only, frag_type, (char *)hostname,
host_len);
-}
-
-#endif
-
-
-#ifdef CLUSTER_CACHE
-TS_INLINE Action *
-CacheProcessor::open_read_internal(int opcode, Continuation *cont, MIOBuffer *buf, CacheURL
*url, CacheHTTPHdr *request,
-                                   CacheLookupHttpConfig *params, CacheKey *key, time_t pin_in_cache,
CacheFragType frag_type,
-                                   char *hostname, int host_len)
-{
-  INK_MD5 url_md5;
-  if ((opcode == CACHE_OPEN_READ_LONG) || (opcode == CACHE_OPEN_READ_BUFFER_LONG)) {
-    Cache::generate_key(&url_md5, url);
-  } else {
-    url_md5 = *key;
-  }
-  ClusterMachine *m = cluster_machine_at_depth(cache_hash(url_md5));
-
-  if (m) {
-    return Cluster_read(m, opcode, cont, buf, url, request, params, key, pin_in_cache, frag_type,
hostname, host_len);
-  } else {
-    if ((opcode == CACHE_OPEN_READ_LONG) || (opcode == CACHE_OPEN_READ_BUFFER_LONG)) {
-      return caches[frag_type]->open_read(cont, &url_md5, request, params, frag_type,
hostname, host_len);
-    } else {
-      return caches[frag_type]->open_read(cont, key, frag_type, hostname, host_len);
-    }
-  }
-}
-#endif
-
-#ifdef CLUSTER_CACHE
-TS_INLINE Action *
-CacheProcessor::link(Continuation *cont, CacheKey *from, CacheKey *to, bool cluster_cache_local,
CacheFragType type, char *hostname,
-                     int host_len)
-{
-  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) {
-      return Cluster_link(m, cont, from, to, type, hostname, host_len);
-    }
-  }
-  return caches[type]->link(cont, from, to, type, hostname, host_len);
-}
-
-TS_INLINE Action *
-CacheProcessor::deref(Continuation *cont, CacheKey *key, bool cluster_cache_local, CacheFragType
type, char *hostname, int host_len)
-{
-  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);
-    }
-  }
-  return caches[type]->deref(cont, key, type, hostname, host_len);
-}
-#endif
-
-TS_INLINE Action *
-CacheProcessor::scan(Continuation *cont, char *hostname, int host_len, int KB_per_second)
-{
-  return caches[CACHE_FRAG_TYPE_HTTP]->scan(cont, hostname, host_len, KB_per_second);
-}
-
-TS_INLINE int
-CacheProcessor::IsCacheEnabled()
-{
-  return CacheProcessor::initialized;
-}
-
-TS_INLINE bool
-CacheProcessor::IsCacheReady(CacheFragType type)
-{
-  if (IsCacheEnabled() != CACHE_INITIALIZED)
-    return 0;
-  return (bool)(cache_ready & (1 << type));
-}
-
 LINK_DEFINITION(CacheVC, opendir_link)
 
 #endif /* _P_CACHE_INTERNAL_H__ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cd8fbec5/proxy/Makefile.am
----------------------------------------------------------------------
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index ce5041f..b385c6c 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -318,12 +318,12 @@ traffic_sac_LDADD = \
   shared/liberror.a \
   shared/libxml.a \
   $(top_builddir)/mgmt/libmgmt_p.la \
+  $(top_builddir)/iocore/utils/libinkutils.a \
   $(top_builddir)/iocore/cluster/libinkcluster.a \
   $(top_builddir)/iocore/dns/libinkdns.a \
   $(top_builddir)/iocore/hostdb/libinkhostdb.a \
   $(top_builddir)/iocore/cluster/libinkcluster.a \
   $(top_builddir)/iocore/cache/libinkcache.a \
-  $(top_builddir)/iocore/utils/libinkutils.a \
   $(top_builddir)/iocore/aio/libinkaio.a \
   $(top_builddir)/iocore/net/libinknet.a \
   $(top_builddir)/iocore/eventsystem/libinkevent.a \


Mime
View raw message