Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Space.clean() in a cluster

Hello,

I have a pair of container/spaces configured to start in a partitioned cluster. When I call Space.clean(), I find that only one of the spaces in the cluster is being cleaned. The question is: should Space.clean() clean only one space in a cluster or all? I suspect it will only clean out a single space.

If the above suspicion is true, is there a recommended technique that would allow me to iterate through a cluster to obtain each of the spaces? I noticed the CLI can pull back the specific spaces within a contained cluster, so I suspect there's a clean approach for this. A clean() operation is probably only the first of many situations I'll encounter where multiple spaces in a cluster need similar operations.

Thanks for any assistance.

Steve h4. Attachments

[Utility.java|/upfiles/13759721554838199.txt]

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=1989]{quote}

asked 2008-01-31 13:26:23 -0500

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

In order to remove entries from all space cluster members you should use the clear operation with appropriate template.
Having null as the template would remove data from all space cluster members.
See:
http://www.gigaspaces.com/wiki/display/GS6/PartitionedSpaceConsiderations-6.0

Please note that the clear operation does come with some overhead when having lots of entries within the space. There is a way to boost the performance of this operation in special cases (spaces got read-only non transactional clients). If this is your case let me know.

Please note there is a way to get a direct proxy to each space using its Container proxy:
IJSpaceContainer containerProxy = (IJSpaceContainer)SpaceFinder.find("jini://*/myConatiner");
IJSpace mySpace = (IJSpace) containerProxy.getSpace("mySpace");

Shay

answered 2008-01-31 13:36:12 -0500

shay hassidim gravatar image
edit flag offensive delete link more
0

Thanks Shay, I appreciate your responses.

The clear() method looks to be what I need for cleaning all spaces in the cluster. Thanks for this.

However, your second response may not be quite what I was looking for. It appears to assume I know the names of my spaces. From a programatic point of view this appears to introduce code maintenance issues - esp. as I start to add more spaces to the cluster. For example, suppose I create a utility that needs to perform an operation on all objects of a specified class that exist in all partitions (spaces) of my cluster? If it's written today, it'll identify the two spaces in the cluster by name. As soon as I add a third space to the cluster, the utility will need to be altered/rebuilt to operate against the new space. A simple 'do this for all space members in my named cluster' approach would be more cost effective as the system grows.

I found a code sample in the GigaSpaces Partitioned DataGrid example project that appears to be a close match (I found this after submitting the question). Please refer to the IsClusteredActive() methodin the Utility.java file attached.

My only concern here is the code's reliance on policies set for the cluster. I'm not familiar with the ClusterPolicy object, but the code indicates we might not always have cluster policies set that we could rely upon to provide back a list of the space URLs for the cluster. Is there perhaps another Cluster-related object that the spaces are always registered with? h4. Attachments

[Utility.java|/upfiles/13759721568934047.txt]

answered 2008-01-31 14:29:26 -0500

edit flag offensive delete link more

Comments

The code example I sent is relevant only in special cases - mainly when you build your own admin tool. In most cases you do not need to know the cluster topology, exact amount of members , their container name or their physical locations. The clustered proxy takes care of this for you. Read/take operations would be done from all partitions in case the routing field is null (broadcast mode enabled by default). Write operations will be routed to all partitions based on routing field hash code value.

Shay

shay hassidim gravatar imageshay hassidim ( 2008-01-31 15:50:19 -0500 )edit
0

Thanks Shay.

If the container proxy gives me access to all cluster members, without needing to know the individual space names, then it should do the trick.

Thanks for your help - much appreciated.

Steve

answered 2008-01-31 17:11:48 -0500

edit flag offensive delete link more

Comments

The container proxy give you access to spaces running within specific container identified by its name. Its physical location is not needed. With a clustered proxy , in order to get all the container names comprising the cluster you will need to fetch this info from the cluster config object. Unless you have very special needs - you do not need to go this path. Shay

shay hassidim gravatar imageshay hassidim ( 2008-01-31 17:31:21 -0500 )edit

This is just an update post for the benefit of any readers of this thread.

m_AllClusterMemberList is a member of the ClusterPolicy class. If you want a list of cluster members (container and space names) belonging to a cluster, the following code snippet will help:

                IJspace space = (IJspace)SpaceFinder.find(url)
        IRemoteJSpaceAdmin admin = (IRemoteJSpaceAdmin) space.getAdmin();
        ClusterPolicy clusterPolicy = admin.getClusterPolicy();
        List clusterMembers = clusterPolicy.m_AllClusterMemberList;

        if (clusterMembers != null) 
        {
            for (int i = 0; i < clusterMembers.size(); i++) 
            {
                System.out.println("Member[" + i + "]" + clusterMembers.get(i));
            }
        }

The resulting output will look something like the following:

Member[0]Chaordix_container1:Chaordix Member[1]Chaordix_container2:Chaordix Member[2]Chaordix_container3:Chaordix

However, I agree that the ideal approach is as Shay indicated - using the container proxy for automatic (and consistent) operations against all spaces in the container. Call this code snippet trivia for the curious.

Once again, big thanks to Shay for providing the better solutions.

sjacquin gravatar imagesjacquin ( 2008-02-01 12:07:15 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2008-01-31 13:26:23 -0500

Seen: 24 times

Last updated: Jan 31 '08