<article>
<title>Squid Programmers Guide</title>
<author>Duane Wessels, Squid Developers
-<date>$Id: prog-guide.sgml,v 1.44 2001/06/18 16:34:15 wessels Exp $</date>
+<date>$Id: prog-guide.sgml,v 1.45 2001/07/04 00:12:05 hno Exp $</date>
<abstract>
Squid is a WWW Cache application developed by the National Laboratory
Finishes a walk of the maintained objects, destroys
walker and restores the policy to it's normal state.
-<sect2>Future removal policy implementation
+<sect3>policy.Stats()
-<sect3>Source layout
+<P>
+<verb>
+ purgewalker->Stats(RemovalPurgeWalker *purgewalker, StoreEntry *entry)
+</verb>
+
+ <P>
+ Appends statistics about the policy to the given entry.
+
+<sect2>Source layout
<P>
Policy implementations resides in src/repl/<name>/, and a make in
such a directory must result in a object archive src/repl/<name>.a
containing all the objects implementing the policy.
-<sect3>Internal structures
+<sect2>Internal structures
-<sect4>RemovalPolicy
+<sect3>RemovalPolicy
<P>
<verb>
<P>
The _data member is for storing policy specific information.
-<sect4>RemovalPolicyWalker
+<sect3>RemovalPolicyWalker
<P>
<verb>
};
</verb>
-<sect4>RemovalPolicyNode
+<sect3>RemovalPolicyNode
<P>
<verb>
maybe later provide more space here to allow simple policies
to store all their data "inline" to preserve some memory.
-<sect3>Policy registration
+<sect2>Policy registration
<P>
Policies are automatically registered in the Squid binary from the
might get extended to support loadable modules. All registered
policies are available to object stores which wishes to use them.
-<sect3>Policy instance creation
+<sect2>Policy instance creation
<P>
Each policy must implement a "create/new" function "<tt/RemovalPolicy *
It should also populate the _data member with a pointer to policy
specific data.
-<sect3>Walker
+<sect2>Walker
<P>
When a walker is created the policy populates it with at least the API
/*
- * $Id: store_repl_lru.cc,v 1.8 2001/03/03 10:39:39 hno Exp $
+ * $Id: store_repl_lru.cc,v 1.9 2001/07/04 00:12:06 hno Exp $
*
* DEBUG: section ? LRU Removal policy
* AUTHOR: Henrik Nordstrom
return walker;
}
+static void
+lru_stats(RemovalPolicy * policy, StoreEntry * sentry)
+{
+ LruPolicyData *lru = policy->_data;
+ LruNode *lru_node = (LruNode *)lru->list.head;
+
+again:
+ if (lru_node) {
+ StoreEntry * entry = (StoreEntry *) lru_node->node.data;
+ if (storeEntryLocked(entry)) {
+ lru_node = (LruNode *)lru_node->node.next;
+ goto again;
+ }
+ storeAppendPrintf(sentry, "LRU reference age: %.2f days\n", (double) (squid_curtime - entry->lastref) / (double) (24 * 60 * 60));
+ }
+}
+
static void
lru_free(RemovalPolicy * policy)
{
policy->Dereferenced = lru_referenced;
policy->WalkInit = lru_walkInit;
policy->PurgeInit = lru_purgeInit;
+ policy->Stats = lru_stats;
/* Increase policy usage count */
nr_lru_policies += 0;
return policy;
/*
- * $Id: store_dir.cc,v 1.130 2001/03/28 16:33:56 wessels Exp $
+ * $Id: store_dir.cc,v 1.131 2001/07/04 00:12:05 hno Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
storeAppendPrintf(sentry, "Current Capacity : %d%% used, %d%% free\n",
percent((int) store_swap_size, (int) Config.Swap.maxSize),
percent((int) (Config.Swap.maxSize - store_swap_size), (int) Config.Swap.maxSize));
+ /* FIXME Here we should output memory statistics */
/* Now go through each swapdir, calling its statfs routine */
for (i = 0; i < Config.cacheSwap.n_configured; i++) {
storeAppendPrintf(sentry, "FS Block Size %d Bytes\n",
SD->fs.blksize);
SD->statfs(SD, sentry);
+ if (SD->repl) {
+ storeAppendPrintf(sentry, "Removal policy: %s\n", SD->repl->_type);
+ if (SD->repl->Stats)
+ SD->repl->Stats(SD->repl, sentry);
+ }
}
}
/*
- * $Id: structs.h,v 1.392 2001/06/29 14:48:06 hno Exp $
+ * $Id: structs.h,v 1.393 2001/07/04 00:12:05 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
void (*Dereferenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
RemovalPolicyWalker *(*WalkInit) (RemovalPolicy * policy);
RemovalPurgeWalker *(*PurgeInit) (RemovalPolicy * policy, int max_scan);
+ void (*Stats) (RemovalPolicy * policy, StoreEntry * entry);
};
struct _RemovalPolicyWalker {