Summary: Space Administration using .NET API.
Space administration using .NET is a new feature in GigaSpaces version 6.5 and onwards.

Overview

In some scenarios, you might need to perform administrative tasks on the space (e.g. testing your space-related code). The .NET API provides an interface called IServerAdmin with a set of operations to perform such tasks. IServerAdmin can be easily accessed from the space proxy

using GigaSpaces.Core.Admin;

ISpaceProxy proxy;
IServerAdmin admin = proxy.GetServerAdmin();

Getting Cluster Member Names and Connecting Directly to Specific Member

When working with a clustered space, the proxy is actually connected to a single node in the cluster which is elected to serve as a gateway to the cluster. In general, this implementation detail is irrelevant, since most of the cluster activity is done seamlessly behind the scenes. However, in some scenarios, knowing which node is the active proxy and switching between them can be very helpful.

Getting Cluster Member Names

You can use the GetClusterMemberNames method to retrieve an array of strings representing the names of the cluster members, according to the cluster configuration schema which is used. For example:

string[] membersNames = admin.GetClusterMemberNames();

Connecting Directly to Specific Member

You can use the GetDirectProxy method with a member name to get an ISpaceProxy connected directly to that member. For example, to get direct proxies to all the cluster members, write something like this:

ISpaceProxy[] directProxies = new ISpaceProxy[membersNames.Length];
for (int i = 0; i < membersNames.Length; i++)
directProxies[i] = admin.GetDirectProxy(membersNames[i]);

Connecting Directly to Embedded Member

In SBA solutions, the worker usually gets a URL to a clustered space, where the target node is embedded. The worker needs to get a direct proxy to the embedded member to work efficiently. The easiest way to do this is to use the GetDirectProxy method overload without the member name argument.

This is intended strictly for embedded cluster scenarios – if the cluster is remote, there is no way to know which member of the cluster is selected.

ISpaceProxy localProxy = admin.GetDirectProxy();

Check out the <GigaSpaces Root>\dotnet\StocksSba example for a reference implementation of a worker.

Space State

Use the State property to get the current state of the server. For example:

SpaceState state = admin.State;

Retrieving Space Type Information

Runtime Information Regarding Type Usage

Use the GetRuntimeInfo method to retrieve runtime information about current types in use by the space. The method returns a structure (ISpaceRuntimeInfo) containing the information (for each type: name, number of instances in the space, and number of templates).

There are 3 overloads:

  • GetRuntimeInfo() – returns information about all the types in the space.
  • GetRuntimeInfo(String spaceTypeName) – returns information about the specified type name and all its subtypes.
  • GetRuntimeInfo(Type type) returns information about the specified type and all its subtypes.

Using the GetRuntimeInfo(String spaceTypeName) overload might be tricky, since the spaceTypeName might not be identical to the .NET type name (for example, inner classes, generics).

GetRuntimeInfo is not supported when working with a clustered proxy.

ISpaceRuntimeInfo runtimeInfo = admin.GetRuntimeInfo(typeof(Person));

Type Descriptors Information

Use the GetTypeDescriptor method to retrieve metadata about a specific type in the space. The method returns a structure (ITypeDescriptor) containing the information (name, basic types, FIFO, replication; and information for each field: name, type, and index).

There are 2 overloads:

  • GetTypeDescriptor(String spaceTypeName) – returns a type description for the specified type name.
  • GetTypeDescriptor(Type type) – returns a type description for the specified type.

Using the GetTypeDescriptor(String spaceTypeName) overload might be tricky, since the spaceTypeName might not be identical to the .NET type name (for example, inner classes, generics).

GetTypeDescriptor is not supported when working with a clustered proxy.

For example, to get type descriptors for all the types in the space, write something like this:

ISpaceRuntimeInfo runtimeInfo = admin.GetRuntimeInfo();
ITypeDescriptor[] typesInfo = new ITypeDescriptor[runtimeInfo.Types.Length];
for (int i = 0; i < typesInfo.Length; i++)
typesInfo[i] = admin.GetTypeDescriptor(runtimeInfo.Types[i].SpaceTypeName);

Importing Data from Another Space

Use the SpaceCopy method to copy Entries from another space to the current space.

You can control which objects are copied using the template argument, and optimize the copy speed using the batchSize argument.

The method returns an instance of ISpaceCopyResult, which provides detailed information about the copy operation results (for example, how many objects were copied, what are their types, which objects were not copied because they already exist in the target space, etc.).

ISpaceCopyResult copyResult = admin.SpaceCopy("/./SomeOtherSpace", new MyPono(), 1000);
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence