Mercurial > projects > ldc
comparison tango/tango/net/cluster/tina/CacheServer.d @ 132:1700239cab2e trunk
[svn r136] MAJOR UNSTABLE UPDATE!!!
Initial commit after moving to Tango instead of Phobos.
Lots of bugfixes...
This build is not suitable for most things.
author | lindquist |
---|---|
date | Fri, 11 Jan 2008 17:57:40 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:5825d48b27d1 | 132:1700239cab2e |
---|---|
1 /******************************************************************************* | |
2 | |
3 copyright: Copyright (c) 2004 Kris Bell. All rights reserved | |
4 | |
5 license: BSD style: $(LICENSE) | |
6 | |
7 version: July 2004: Initial release | |
8 | |
9 author: Kris | |
10 | |
11 *******************************************************************************/ | |
12 | |
13 module tango.net.cluster.tina.CacheServer; | |
14 | |
15 private import tango.net.cluster.tina.RollCall, | |
16 tango.net.cluster.tina.CacheThread, | |
17 tango.net.cluster.tina.ClusterCache, | |
18 tango.net.cluster.tina.ClusterServer; | |
19 | |
20 /****************************************************************************** | |
21 | |
22 Extends the ClusterServer to glue cluster-cache support together | |
23 | |
24 ******************************************************************************/ | |
25 | |
26 class CacheServer : ClusterServer | |
27 { | |
28 private ClusterCache cache; | |
29 | |
30 /********************************************************************** | |
31 | |
32 Construct this server with the requisite attributes. The | |
33 'bind' address is the local address we'll be listening on | |
34 | |
35 **********************************************************************/ | |
36 | |
37 this (InternetAddress bind, Logger logger, uint size) | |
38 { | |
39 super ("cache", bind, logger); | |
40 | |
41 // create a cache instance | |
42 cache = new ClusterCache (cluster, size); | |
43 } | |
44 | |
45 /********************************************************************** | |
46 | |
47 Start the server | |
48 | |
49 **********************************************************************/ | |
50 | |
51 void start (bool reuse=false) | |
52 { | |
53 super.start (new RollCall(RollCall.Cache), reuse); | |
54 } | |
55 | |
56 /********************************************************************** | |
57 | |
58 Factory method for servicing a request. We just create | |
59 a new CacheThread to handle requests from the client. | |
60 The thread does not exit until the socket connection is | |
61 broken by the client, or some other exception occurs. | |
62 | |
63 **********************************************************************/ | |
64 | |
65 override void service (IConduit conduit) | |
66 { | |
67 (new CacheThread (this, conduit, cluster, cache)).execute; | |
68 } | |
69 } | |
70 | |
71 | |
72 | |
73 version (CacheServer) | |
74 { | |
75 import tango.io.Console; | |
76 | |
77 import tango.net.cluster.tina.CmdParser; | |
78 | |
79 void main (char[][] args) | |
80 { | |
81 auto arg = new CmdParser ("cache.server"); | |
82 | |
83 // default number of cache entries (per channel) | |
84 arg.size = 1024; | |
85 | |
86 if (args.length > 1) | |
87 arg.parse (args[1..$]); | |
88 | |
89 if (arg.help) | |
90 Cout ("usage: cacheserver -port=number -size=cachesize -log[=trace, info, warn, error, fatal, none]").newline; | |
91 else | |
92 (new CacheServer(new InternetAddress(arg.port), arg.log, arg.size)).start; | |
93 } | |
94 } |