comparison tango/tango/net/cluster/tina/QueueServer.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.QueueServer;
14
15 private import tango.net.cluster.tina.RollCall,
16 tango.net.cluster.tina.QueueThread,
17 tango.net.cluster.tina.ClusterQueue,
18 tango.net.cluster.tina.ClusterServer;
19
20 /******************************************************************************
21
22 Extends the ClusterServer to glue cluster-cache support together.
23
24 ******************************************************************************/
25
26 class QueueServer : ClusterServer
27 {
28 private ClusterQueue queue;
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)
38 {
39 super ("queue", bind, logger);
40
41 // create a queue instance
42 // queue = new MemoryQueue (cluster, 64 * 1024 * 1024, 1.0);
43 queue = new PersistQueue (cluster, 64 * 1024 * 1024, 3.0);
44
45 }
46
47 /**********************************************************************
48
49 Start the server
50
51 **********************************************************************/
52
53 void start (bool reuse=false)
54 {
55 super.start (new RollCall(RollCall.Queue), reuse);
56 }
57
58 /**********************************************************************
59
60 Factory method for servicing a request. We just create
61 a new QueueThread to handle requests from the client.
62 The thread does not exit until the socket connection is
63 broken by the client, or some other exception occurs.
64
65 **********************************************************************/
66
67 override void service (IConduit conduit)
68 {
69 (new QueueThread (this, conduit, cluster, queue)).execute;
70 }
71 }
72
73
74
75 version (QueueServer)
76 {
77 import tango.io.Console;
78
79 import tango.net.cluster.tina.CmdParser;
80
81 void main (char[][] args)
82 {
83 auto arg = new CmdParser ("queue.server");
84
85 if (args.length > 1)
86 arg.parse (args[1..$]);
87
88 if (arg.help)
89 Cout ("usage: queueserver -port=number -log[=trace, info, warn, error, fatal, none]").newline;
90 else
91 (new QueueServer(new InternetAddress(arg.port), arg.log)).start;
92 }
93 }