Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Client.d

Go to the documentation of this file.
00001 /*******************************************************************************
00002 
00003         @file Client.d
00004         
00005         Copyright (c) 2004 Kris Bell
00006         
00007         This software is provided 'as-is', without any express or implied
00008         warranty. In no event will the authors be held liable for damages
00009         of any kind arising from the use of this software.
00010         
00011         Permission is hereby granted to anyone to use this software for any 
00012         purpose, including commercial applications, and to alter it and/or 
00013         redistribute it freely, subject to the following restrictions:
00014         
00015         1. The origin of this software must not be misrepresented; you must 
00016            not claim that you wrote the original software. If you use this 
00017            software in a product, an acknowledgment within documentation of 
00018            said product would be appreciated but is not required.
00019 
00020         2. Altered source versions must be plainly marked as such, and must 
00021            not be misrepresented as being the original software.
00022 
00023         3. This notice may not be removed or altered from any distribution
00024            of the source.
00025 
00026         4. Derivative works are permitted, but they must carry this notice
00027            in full and credit the original source.
00028 
00029 
00030                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00031 
00032 
00033         @version        Initial version, July 2004      
00034         @author         Kris
00035 
00036 
00037 *******************************************************************************/
00038 
00039 module mango.cluster.Client;
00040 
00041 private import  mango.sys.System;  
00042 
00043 private import  mango.io.Exception;        
00044 
00045 public  import  mango.cluster.Message;        
00046 
00047 public  import  mango.cluster.model.ICluster;        
00048 
00049 /*******************************************************************************
00050 
00051         The base class for all cluster clients (such as CacheInvalidator)
00052         which acts simply as a container for the operating IChannel and
00053         the configured ICluster. The former specifies something akin to
00054         a 'topic' in the pub/sub world, while the latter provides access
00055         to the underlying functional substrate (the QOS implementation).
00056 
00057 *******************************************************************************/
00058 
00059 class Client
00060 {
00061         private IChannel channel;
00062         private ICluster cluster;
00063 
00064         public static NullMessage EmptyMessage;
00065 
00066         static this ()
00067         {
00068                 EmptyMessage = new NullMessage;
00069         }
00070 
00071         /***********************************************************************
00072 
00073                 Construct this client with the specified channel and cluster. 
00074                 The former specifies something akin to a 'topic', whilst the 
00075                 latter provides access to the underlying functional substrate 
00076                 (the QOS implementation). A good way to think about channels
00077                 is to map them directly to a class name. That is, since you
00078                 send and recieve classes on a channel, you might utilize the 
00079                 class name as the channel name (this.classinfo.name).
00080  
00081         ***********************************************************************/
00082         
00083         this (ICluster cluster, char[] channel)
00084         in {
00085            assert (cluster);
00086            assert (channel.length);
00087            }
00088         body
00089         {
00090                 this.cluster = cluster;
00091                 this.channel = cluster.createChannel (channel);
00092         }
00093 
00094         /***********************************************************************
00095 
00096                 Return the channel we're tuned to
00097 
00098         ***********************************************************************/
00099         
00100         IChannel getChannel ()
00101         {
00102                 return channel;
00103         }
00104 
00105         /***********************************************************************
00106 
00107                 Return the cluster specified during construction
00108 
00109         ***********************************************************************/
00110         
00111         ICluster getCluster ()
00112         {
00113                 return cluster;
00114         }
00115 
00116         /***********************************************************************
00117 
00118                 Return the number of milliseconds since Jan 1st 1970
00119 
00120         ***********************************************************************/
00121         
00122         long getTime ()
00123         {
00124                 return System.getMillisecs;
00125         }
00126 
00127         /***********************************************************************
00128         
00129                 Create a channel with the specified name. A channel 
00130                 represents something akin to a publush/subscribe topic, 
00131                 or a radio station. These are used to segregate cluster 
00132                 operations into a set of groups, where each group is 
00133                 represented by a channel. Channel names are whatever you 
00134                 want then to be; use of dot notation has proved useful 
00135                 in the past. In fact, a good way to think about channels
00136                 is to map them directly to a class name. That is, since you
00137                 typically send and recieve classes on a channel, you might 
00138                 utilize the class name as the channel (this.classinfo.name).
00139 
00140         ***********************************************************************/
00141         
00142         IChannel createChannel (char[] name)
00143         {
00144                 return cluster.createChannel (name);
00145         }
00146 }
00147 
00148 /*******************************************************************************
00149 
00150         This exception is thrown by the cluster subsystem when it runs
00151         into something unexpected.
00152 
00153 *******************************************************************************/
00154 
00155 class ClusterException : IOException
00156 {
00157         /***********************************************************************
00158         
00159                 Construct exception with the provided text string
00160 
00161         ***********************************************************************/
00162 
00163         this (char[] msg)
00164         {
00165                 super (msg);
00166         }
00167 }
00168 
00169 /*******************************************************************************
00170 
00171         This exception is thrown by the cluster subsystem when an attempt
00172         is made to place additional content into a full queue
00173 
00174 *******************************************************************************/
00175 
00176 class ClusterFullException : ClusterException
00177 {
00178         /***********************************************************************
00179         
00180                 Construct exception with the provided text string
00181 
00182         ***********************************************************************/
00183 
00184         this (char[] msg)
00185         {
00186                 super (msg);
00187         }
00188 }
00189 
00190 /*******************************************************************************
00191 
00192         This exception is thrown by the cluster subsystem when an attempt
00193         is made to converse with a non-existant cluster, or one where all
00194         cluster-servers have died.
00195 
00196 *******************************************************************************/
00197 
00198 class ClusterEmptyException : ClusterException
00199 {
00200         /***********************************************************************
00201         
00202                 Construct exception with the provided text string
00203 
00204         ***********************************************************************/
00205 
00206         this (char[] msg)
00207         {
00208                 super (msg);
00209         }
00210 }
00211 

Generated on Fri Nov 11 18:44:18 2005 for Mango by  doxygen 1.4.0