When a client connects to a space, a proxy is created that holds a connection to the space. All client interaction is performed through this proxy. The proxy provides a simpler space API using the ISpaceProxy interface. It is created with a Space URL and optional parameters.
The Space URL
In order to locate a space you need to specify its URL. The SpaceURL is used as part of the space proxy.
The general format of the space URL is:
<protocol>://<lookup service hostname>:<port>/<space container name>/<space name>?<properties>
The following parameters can be defined:
|The machine host name/IP running the lookup service. May be * when Jini is used as a protocol. In this case the space is located using multicast or unicast with search path.
|The Jini lookup port. If no port is specified the default port (10098) will be used
|Space Container Name
|The name of the space container that holds the space. May be * when Jini is used as a protocol. In this case the container name will be ignored when performing lookup and the space will be searched regardless of the container that holds it.
|The space name to search. The same name defined when space has been created via the Space browser or the
|(Optional) named value list of special properties.
Make sure your network and machines running GigaSpaces are configured to have multicast enabled. See the How to Configure Multicast section for details on how to enable multicast.
Accessing Remote Space Using Jini Lookup Service - Unicast Discovery
Accessing Remote Space Using the Jini Lookup Service - Multicast Discovery
/./mySpace (which translates to java://localhost:10098/containerName/mySpace?schema=default)
/./mySpace?schema=cache (which translates to java://localhost:10098/containerName/mySpace?schema=cache)
Distributed Unicast-Based Lookup Service Support
In environments that do not support multicast, you can use the
locators space URL property to instruct the started space or a client to locate the Jini Lookup Service on specific host names and ports.The locators can have a comma-delimited lookup hosts list.
The following URL formats are supported:
jini://LookupServiceHostName1:port1,....LookupServiceHostName n:port n/*/space_name
jini://LookupServiceHostName1:port1,....LookupServiceHostName n:port n/*/space_name?locators=LookupServiceHostName1:port,LookupServiceHostName2:port,LookupServiceHostName3:port
Space Container Notation
The Space URL uses the following notation to start a space:
/./<Space Name>. For example:
When using that space URL the system will instantiate (create) a space instance named
mySpace using the default schema configuration. The default schema is set to transient space configuration and it is equivalent to using the following URL:
You can use “.” as the container name in the space URL. A value of “.” as the container name will be translated to
<space name>_container name. In the above example the container name is explicitly defined as
When a URL is provided without the protocol (java) and host name (localhost), the following URL is created /./mySpace as:
The following are optional property string values:
|Creates a new space using the container’s default parameters. New spaces use the default space configuration file. Example:
|Indicates that all take/write operations be conducted in FIFO mode. Default is false. Example:
|The Jini Lookup Service group to find container or space using multicast. Example:
The default value of the
XAP_LOOKUP_GROUPS variable is the GigaSpaces version number, preceded by
XAP. For example, in GigaSpaces XAP 6.0 the default lookup group is
XAP6.0. This is the lookup group which the space and Jini Transaction Manager register with, and which clients use by default to connect to the space.
Jini groups are irrelevant when using unicast lookup discovery – they are relevant only when using multicast lookup discovery. If you have multiple spaces with the same name and you are using unicast lookup discovery, you might end up getting the wrong proxy. In such a case, make sure you have a different lookup for each space, where each space is configured to use a specific lookup. A good practice is to have different space names.
|Instructs the started space or a client to locate the Jini Lookup Service on specific host name and port. For more details please refer to How to Configure Unicast Discovery page.
|Push or pull update mode. Example:
SpaceFinder will not initialize RMISecurityManager. Default is
|Turn Master-Local Space mode.By default Master-Local mode is turned off. To enable master local have the
useLocalCache as part of the URL
|When false, optimistic lock is disabled. In a local cache and views the default is
true, otherwise the default value is
|The cluster name to lookup using multicast. The returned object is a clustered proxy.
|The cluster group to lookup using multicast. The returned object is a clustered proxy.
|The cluster schema XSL file name to be used to setup a cluster config on the fly in memory. If the
?cluster_schema option is passed e.g.
?cluster_schema=sync_replication, the system will use the
sync_replication-cluster-schema.xsl together with a cluster Dom which will be built using user’s inputs on regards # of members, # of backup members etc.
|Using the schema flag, the requested space schema name will be loaded/parsed while creating an embedded space. If the space already has configuration file then the requested schema will not be applied and the that file exist, it will overwrite the default configuration defined by the schema. Note that when using the option ?create with java:// protocol, the system will create a container, space and use the default space configuration schema file (default-space-schema.xml)
total_members attribute in the space URL stands for the total number of cache members within the cache cluster.
The number is used to create the list of members participating in the cluster on the fly based on the cache name convention. This pattern is used to avoid the need for creating a cluster topology file.
The number of actual running cache instances can vary dynamically between
The format of the
total_members = number of primary instances, number of backup instances per primary. In this example the value is 4,2 which means that this cluster contains up to 4 primary instances each containing 2 backup instances. The backup_id is used to define whether the instance is a backup instance or not.
If this attribute is not defined the instance will be considered a primary instance. The container name will be translated in this case to [cache name]_container[id][backup_id].
In this case it will be expanded to mySpace_container1_1
|Used in case of Partitioned Cache (when adding backup to each partition). The backup_id is used to define whether the instance is a backup instance or not. If this attribute is not defined the instance will be considered a primary cache instance.
The container name will be translated in this case to [cache name]container[id][backup_id].
In this case it will be expanded to mySpace_container1_1.
|The id attribute is used to distinguish between cache instances in this cluster.
|if properties property is used as part of the URL space, space and container schema will be loaded and the properties listed as part of the properties file (
[prop-file-name].properties) which contains the values to override the schema space/container/cluster configuration values that are defined in the schema files.
Another benefit of using the ?properties option is when we want to load system properties while VM starts or set SpaceURL attributes. See /config/gs.properties file as a reference.
|When setting this URL property it will allow the space to connect to the Mirror service to push its data and operations for asynchronous persistency.
Default: no mirror connection
|Initial lookup discovery timeout duration. The default is 5000ms
Example for space URL using options:
The EmbeddedSpaceFactory class allows you to set different properties using a
Here is an example of a space working in FIFO mode, using specific lookup groups:
Dictionary<String,String> properties = new Dictionary<String,String> ();
properties.Add ("fifo", "true");
// Cluster info settings
ClusterInfo clusterInfo = new ClusterInfo ();
clusterInfo.NumberOfBackups = 1;
clusterInfo.Schema = "sync_replication";
// Create the factory
EmbeddedSpaceFactory factory = new EmbeddedSpaceFactory ("mySpace");
factory.ClusterInfo = clusterInfo;
factory.CustomProperties = properties;
//create the ISpaceProxy
ISpaceProxy proxy = factory.Create();