-
Notifications
You must be signed in to change notification settings - Fork 2
RemoteSpace Class
sequenze edited this page Jun 19, 2017
·
6 revisions
Provides networked access to a remote space, using any supported protocol and mode.
Object
public sealed class RemoteSpace : ISpace| Name | Description |
|---|---|
| RemoteSpace(String,ITupleFactory) | Initializes a new instances of the RemoteSpace class providing networked access to a space repository. All tuples will be created using the provided tuple factory; if none is provided the default TupleFactory will be used. |
| Name | Description |
|---|---|
| Get(IPattern) | Retrieves and removes the first tuple from the space, matching the specified pattern. The operation will block if no elements match. |
| Get(Object[]) | Retrieves and removes the first tuple from the space, matching the specified pattern. The operation will block if no elements match. |
| GetP(IPattern) | Retrieves and removes the first tuple from the space, matching the specified pattern. The operation is non-blocking. The operation will return null if no elements match. |
| GetP(Object[]) | Retrieves and removes the first tuple from the space, matching the specified pattern. The operation is non-blocking. The operation will return null if no elements match. |
| GetAll(IPattern) | Retrieves and removes all tuples from the space matching the specified pattern. The operation is non-blocking. The operation will return an empty set if no elements match. |
| GetAll(Object[]) | Retrieves and removes all tuples from the space matching the specified pattern. The operation is non-blocking. The operation will return an empty set if no elements match. |
| Query(IPattern) | Retrieves the first tuple from the space, matching the specified pattern. The operation will block if no elements match. |
| Query(Object[]) | Retrieves the first tuple from the space, matching the specified pattern. The operation will block if no elements match. |
| QueryP(IPattern) | Retrieves the first tuple from the space, matching the specified pattern. The operation is non-blocking. The operation will return null if no elements match. |
| QueryP(Object[]) | Retrieves the first tuple from the space, matching the specified pattern.The operation is non-blocking.The operation will return null if no elements match. |
| QueryAll(IPattern) | Retrieves all tuples from the space matching the specified pattern. The operation is non-blocking. The operation will return an empty set if no elements match. |
| QueryAll(Object[]) | Retrieves all tuples from the space matching the specified pattern. The operation is non-blocking. The operation will return an empty set if no elements match. |
| Put(ITuple) | Inserts the tuple passed as argument into the space. |
| Put(Object[]) | Inserts the tuple passed as argument into the space. |
The RemoteSpace class is a space proxy in that it allows access to a networked space repository. It supports all the same features as a typical space, however the properties are defined by the actual space being access. This means that if the remote space is a FIFO space, then the RemoteSpace inherits the properties thereof. In order to obtain access to a networked space repository, a connection string must be specified.
The connection string is defined through multiple optional and mandatory properties:
<protocol>://<host>:<port><name of space>?<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.
- name of space is mandatory, and is specifying the textual identifier of the space being stored in the space repository.
-
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.
The following example shows how to use a RemoteSpace to connect to a networked space. 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!
*/