00001 /******************************************************************************* 00002 00003 @file ICluster.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 00027 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00028 00029 00030 @version Initial version, July 2004 00031 @author Kris 00032 00033 00034 *******************************************************************************/ 00035 00036 module mango.cluster.model.ICluster; 00037 00038 private import mango.io.model.IPickle; 00039 00040 public import mango.log.model.ILogger; 00041 00042 public import mango.cache.model.IPayload; 00043 00044 public import mango.cluster.model.IEvent, 00045 mango.cluster.model.IChannel, 00046 mango.cluster.model.IMessage, 00047 mango.cluster.model.IConsumer; 00048 00049 /******************************************************************************* 00050 00051 The contract exposed by each QOS implementation. This is the heart 00052 of the cluster package, designed with multiple implementations in 00053 mind. It should be reasonably straightforward to construct specific 00054 implementations upon a database, pub/sub system, or other substrates. 00055 00056 *******************************************************************************/ 00057 00058 interface ICluster 00059 { 00060 /*********************************************************************** 00061 00062 Create a channel instance. Every cluster operation has 00063 a channel provided as an argument 00064 00065 ***********************************************************************/ 00066 00067 IChannel createChannel (char[] channel); 00068 00069 /*********************************************************************** 00070 00071 Scatter a payload to all registered listeners. This is 00072 akin to multicast. 00073 00074 ***********************************************************************/ 00075 00076 void broadcast (IChannel channel, IPayload payload = null); 00077 00078 /*********************************************************************** 00079 00080 Create a listener of the specified style on the given 00081 channel. The IEventListener should be called whenever 00082 a corresponding cluster event happens. Note that the 00083 notification is expected to be on a seperate thread. 00084 00085 ***********************************************************************/ 00086 00087 IConsumer createConsumer (IChannel channel, IEvent.Style style, 00088 IEventListener notify); 00089 00090 /*********************************************************************** 00091 00092 Return a cluster cache entry, and optionally remove it 00093 from the cluster. 00094 00095 ***********************************************************************/ 00096 00097 IPayload getCache (IChannel channel, char[] key, bool remove); 00098 00099 /*********************************************************************** 00100 00101 Place a cache entry into the cluster. If there is already 00102 a matching entry, it is replaced. 00103 00104 ***********************************************************************/ 00105 00106 IPayload putCache (IChannel channel, char[] key, IPayload payload); 00107 00108 /*********************************************************************** 00109 00110 Place a new entry into the cluster queue. This may throw 00111 a ClusterFullException when there is no space left within 00112 the cluster queues. 00113 00114 ***********************************************************************/ 00115 00116 IPayload putQueue (IChannel channel, IPayload payload); 00117 00118 /*********************************************************************** 00119 00120 Query the cluster for queued entries on our corresponding 00121 channel. Returns, and removes, the first matching entry 00122 from the cluster. 00123 00124 ***********************************************************************/ 00125 00126 IPayload getQueue (IChannel channel); 00127 00128 /*********************************************************************** 00129 00130 ***********************************************************************/ 00131 00132 void loadCache (IChannel channel, char[] key, IPayload payload); 00133 00134 /*********************************************************************** 00135 00136 Return the Logger associated with this cluster 00137 00138 ***********************************************************************/ 00139 00140 ILogger getLogger (); 00141 }