-
Notifications
You must be signed in to change notification settings - Fork 2
SpaceRepository Class
Concrete implementation of a space repository. Provides the basic functionality for supporting multiple distributed spaces. It allows direct access to the contained spaces through their respective identifies. Additionally, it facilitates distributed access to the underlying spaces through Gates.
Object > RepositoryBase
public sealed class SpaceRepository : RepositoryBase, IRepository
Name | Description |
---|---|
SpaceRepository() | Initializes a new instance of the SpaceRepository class. |
Name | Description |
---|---|
OnConnect(IConnectionMode) | Processes the incoming connection using the internal operation map. |
AddGate(String) | Adds a new Gate to the repository based on the provided connectionstring. |
AddSpace(String,ISpace) | Adds a new Space to the repository, identified by the specified parameter. |
GetSpace(String) | Returns the local instance of the space identified by the parameter. |
Get(String,IPattern) | Retrieves and removes the first tuple from the target Space, matching the specified pattern. The operation will block if no elements match. |
Get(String,Object[]) | Retrieves and removes the first tuple from the target Space, matching the specified pattern. The operation will block if no elements match. |
GetP(String,IPattern) | Retrieves and removes the first tuple from the target Space, matching the specified pattern. The operation is non-blocking. The operation will return null if no elements match. |
GetP(String,Object[]) | Retrieves and removes the first tuple from the target Space, matching the specified pattern. The operation is non-blocking. The operation will return null if no elements match. |
GetAll(String,IPattern) | Retrieves and removes all tuples from the target Space matching the specified pattern. The operation is non-blocking. The operation will return an empty set if no elements match. |
GetAll(String,Object[]) | Retrieves and removes all tuples from the target Space matching the specified pattern. The operation is non-blocking. The operation will return an empty set if no elements match. |
Query(String,IPattern) | Retrieves the first tuple from the target Space, matching the specified pattern. The operation will block if no elements match. |
Query(String,Object[]) | Retrieves the first tuple from the target Space, matching the specified pattern. The operation will block if no elements match. |
QueryP(String,IPattern) | Retrieves the first tuple from the target Space, matching the specified pattern. The operation is non-blocking. The operation will return null if no elements match. |
QueryP(String,Object[]) | Retrieves the first tuple from the target Space, matching the specified pattern.The operation is non-blocking.The operation will return null if no elements match. |
QueryAll(String,IPattern) | Retrieves all tuples from the target Space matching the specified pattern. The operation is non-blocking. The operation will return an empty set if no elements match. |
QueryAll(String,Object[]) | Retrieves all tuples from the target Space matching the specified pattern. The operation is non-blocking. The operation will return an empty set if no elements match. |
Put(String,ITuple) | Inserts the tuple passed as argument into the target Space. |
Put(String,Object[]) | Inserts the tuple passed as argument into the target Space. |
The SpaceRepository class is a container and host of multiple spaces in that it allows networked access to all space instances. Furthermore the SpaceRepository supports multiple access points, called Gate's, allowing different protocols and connection schemes to provide networked access. A gate is configured through a connectionstring. The connection string is defined through multiple optional and mandatory properties:
<protocol>://<host>:<port>?<connectionmode>
where
- protocol is optional, and is defaulted to TCP. Currently only TCP is supported.
- host is mandatory, and is defined through either a dns name or a IPv4 address.
- port is optional, and is defaulted to 31415.
-
connectionmode is optional, and defaulted to KEEP. Currently the following modes are supported:
- KEEP is a persistent connection is kept alive throughout the entire lifetime.
- CONN is a short lived connection. A new connection is created for every request/response.
Finally, the SpaceRepository supports the same operation as a typical space, with the exception that one has to specify the target space as the first parameter of any given ISpace operation.
The following example shows how to instantiate a SpaceRepository using TCP and CONN connectionscheme. The code contains two programs.
class ServerProgram
{
static void Main(string[] args)
{
SpaceRepository repository = new SpaceRepository();
repository.AddGate("tcp://127.0.0.1:123?CONN");
repository.AddSpace("dtu", new FifoSpace());
repository.Put("dtu", "Hello world!");
Console.Read();
}
}
// ...
class ClientProgram
{
static void Main(string[] args)
{
ISpace remotespace = new RemoteSpace("tcp://127.0.0.1:123/dtu?CONN");
ITuple tuple = repository.Get("dtu", typeof(string));
Console.WriteLine(string.Format("{0}", tuple[0]));
Console.Read();
}
}
/*
The following is printed to the console:
Hello world!
*/
RepositoryBase, IRepository, IConnectionMode, ISpace, IPattern, ITuple