Summary: Allows applications to start and stop a space; get status, statistics, and cluster mode; and shutdown a container.
OverviewGigaSpaces provides various administration APIs that allow you to control the space, get space status, statistics, cluster mode, start and stop space, and shutdown container.
Getting Space Statistics via StatisticsAdmin APIThe example below demonstrates how to get space statistics: IJSpaceContainer containerProxy = (IJSpaceContainer)SpaceFinder.find(containerURL); IJSpace space = containerProxy.getSpace(spaceName , false); StatisticsAdmin stats = (StatisticsAdmin )space.getAdmin(); if (!stats.isStatisticsAvailable()) { return; } StatisticsContext readStat = (StatisticsContext)stats.getStatistics(new Integer(FilterOperationCodes.BEFORE_READ)); StatisticsContext readMStat = (StatisticsContext)stats.getStatistics(new Integer(FilterOperationCodes.AFTER_READ_MULTIPLE)); StatisticsContext writeStat = stats.getStatistics(new Integer(FilterOperationCodes.BEFORE_WRITE)); StatisticsContext updateStat = stats.getStatistics(new Integer(FilterOperationCodes.BEFORE_UPDATE)); StatisticsContext notifyStat = stats.getStatistics(new Integer(FilterOperationCodes.BEFORE_NOTIFY)); StatisticsContext takeStat = stats.getStatistics(new Integer(FilterOperationCodes.BEFORE_TAKE)); StatisticsContext takeMStat = stats.getStatistics(new Integer(FilterOperationCodes.AFTER_TAKE_MULTIPLE)); int readValue = ((readStat == null) ? 0:(int)readStat.getCurrentCount()); int readMValue = ((readMStat == null) ? 0:(int)readMStat.getCurrentCount()); int writeValue = ((writeStat == null) ? 0:(int)writeStat.getCurrentCount()); int updateValue = ((updateStat == null) ? 0:(int)updateStat.getCurrentCount()); int notifyValue = ((notifyStat == null) ? 0:(int)notifyStat.getCurrentCount()); int takeValue = ((takeStat == null) ? 0:(int)takeStat.getCurrentCount()); int takeMValue = ((takeMStat == null) ? 0:(int)takeMStat.getCurrentCount()); takeValue = takeValue + takeMValue; readValue = readValue + readMValue; Creating Container and SpaceThe following code example creates a container, creates a space, get its attributes, iterates over the spaces within the container and shuts down the container. package com.j_spaces.examples.container; import com.j_spaces.core.IJSpaceContainer; import com.j_spaces.core.JSpaceAttributes; import com.j_spaces.core.client.FinderException; import com.j_spaces.core.client.SpaceFinder; public class ContainerDemo { public static void main(String[] args) { try { // get proxy of container - we can provide also remote container URL IJSpaceContainer containerProxy = (IJSpaceContainer)SpaceFinder.find("java://localhost/myContainer"); // export arguments String containerName = containerProxy.getName(); String spaceName = "mySpace"; // get container name System.out.println("\nThe container name is <" + containerProxy.getName() + ">" ); // create space in container System.out.println("\nCreating <" + spaceName + "> space in <" + containerName + "> container..."); // passing the schema name containerProxy.createSpace( spaceName, new JSpaceAttributes( "cache") ); System.out.println("The " + spaceName + " space created successfully."); // get space attributes of <spaceDemo> System.out.println("\nGet " + spaceName + " attributes:"); JSpaceAttributes spaceAttr = containerProxy.getSpaceAttributes( spaceName ); System.out.println(spaceAttr); // get all space names from container System.out.println("\nGet space names from container"); String[] names = containerProxy.getSpaceNames(); for ( int i = 0; i < names.length; i++ ) System.out.println( names[i] ); // destroy space in container System.out.println( "\nDestroying <" + spaceName + "> space."); containerProxy.destroySpace( spaceName ); // shutdown container System.out.println("\nShutdown <" + containerName + "> container."); containerProxy.shutdown(); System.out.println("<" + containerName + "> container shutdown successfully."); } catch( Exception ex ) { ex.printStackTrace(); } } } The expected output: System Environment: System: OS Version: 5.1 Architecture: x86 OS Name: Windows XP Number Of Processors: 1 J2SE Support: VM Vendor: Sun Microsystems Inc. Using Java Home: D:\JDK\jdk1.5.0_04\jre Java(TM) 2 Runtime Environment, Standard Edition Java HotSpot(TM) Client VM (build 1.5.0_04-b05 ) JVM Memory: Max Heap Size (KB): 65088 Current Allocated Heap Size (KB): 181 Network Interfaces Information: Host Name: [MY-MACHINE] Network Interface Name: lo / MS TCP Loopback interface IP Address: 127.0.0.1 GigaSpaces Platform: Version: 6.0XAP Build: 1410 INFO: Aug 9, 2006 8:12:41 PM Created RMIRegistry on: < localhost:10098 > INFO: Aug 9, 2006 8:12:41 PM Webster HTTP server started successfully serving the following roots: D:\GigaSpacesXAP6.0\/lib;D:\GigaSpacesXAP6.0\/lib/jini Webster serving on: MY-MACHINE:3727 INFO: Aug 9, 2006 8:12:41 PM Space is Using -Djava.rmi.server.codebase=http: //155.256.777.53:3727/JSpaces-dl.jar http://155.256.777.53:3727/reggie-dl.jar http://155.256.777.53:3727/jsk-dl.jar INFO: Aug 9, 2006 8:12:41 PM Starting Embedded Jini Lookup Service using the following Codebase: http ://155.256.777.53:3727/reggie-dl.jar http://155.256.777.53:3727/jsk-dl.jar INFO: Aug 9, 2006 8:12:42 PM started Reggie: 561e8efe-dfe4-45c4-b54c-1689e266949b, [gigaspaces-6.0XAP], ConstrainableLookupLocator[[jini://155.256.777.53/], [null]] INFO: Aug 9, 2006 8:12:42 PM Started an embedded Jini Lookup Service INFO: Aug 9, 2006 8:12:42 PM Enabled the Jini Unicast Discovery on: < localhost:4160 > INFO: Aug 9, 2006 8:12:42 PM Directory Service (RMI Registry): [ <myContainer> container bound successfully to RMIRegistry. ] [ provider URL: rmi://localhost:10098 ] CONFIG: Aug 9, 2006 8:12:42 PM Loaded the container xml file < file:/D:/GigaSpacesXAP6.0/config/myContainer.xml >. CONFIG: Aug 9, 2006 8:12:42 PM Loaded the space schema < jar:file:/D:/GigaSpacesXAP6.0/lib/JSpaces.jar! /config/schemas/cache-space-schema.xml > for the space configuration. CONFIG: Aug 9, 2006 8:12:42 PM Loaded the requested space schema < cache > to be used for the < mySpace > space configuration. INFO: Aug 9, 2006 8:12:43 PM Directory Service (Jini Lookup Service): [ Container <myContainer> member of [gigaspaces-6.0XAP] jini lookup groups ] [ Was advertised successfully with serviceID <ea9a0c1f-58a1-40a1-91aa-993cd63983df>. ] INFO: Aug 9, 2006 8:12:43 PM *** Welcome to the GigaSpaces world ! - GigaSpaces Platform(TM) 6.0XAP Build: 1600-253 Server started successfully ! *** CONFIG: Aug 9, 2006 8:12:44 PM Loaded the space schema < jar:file:/D:/GigaSpacesXAP6.0/lib/JSpaces.jar! /config/schemas/cache-space-schema.xml > for the space configuration. The container name is <myContainer> Creating <mySpace> space in <myContainer> container... CONFIG: Aug 9, 2006 8:12:45 PM Loaded the requested space schema < cache > to be used for the < mySpace > space configuration. INFO: Aug 9, 2006 8:12:47 PM Space <mySpace> started successfully INFO: Aug 9, 2006 8:12:48 PM Directory Service (Jini Lookup Service): [ Space <mySpace> member of [gigaspaces-6.0XAP] jini lookup groups ] [ Was advertised successfully with serviceID <2e3751d5-541f-438f-a0ea-3fdec662ebf3>. ] INFO: Aug 9, 2006 8:12:48 PM Directory Service (RMI Registry): [ <mySpace> space bound successfully to RMIRegistry. ] [ provider URL: rmi://localhost:10098 ] INFO: Aug 9, 2006 8:12:48 PM Beginning <mySpace> shutdown ... The mySpace space created successfully. Get mySpace attributes: --- JSpaceAttributes --- DCache Properties=null Cluster Policy=null Filters Info=null Custom Properties=null -- listing properties -- space-config.persistent.DataBaseName= space-config.schema=cache Get space names from container mySpace Destroying <mySpace> space. Shutdown <myContainer> container. INFO: Aug 9, 2006 8:12:49 PM < mySpace > space unbound successfully from RMIRegistry lookup service. INFO: Aug 9, 2006 8:12:49 PM Space <mySpace> shutdown complete INFO: Aug 9, 2006 8:12:49 PM The <mySpace> space of <myContainer> container was destroyed successfully. INFO: Aug 9, 2006 8:12:49 PM <myContainer> container unbound successfully from RMIRegistry lookup service. INFO: Aug 9, 2006 8:12:49 PM All spaces unregistered successfully. INFO: Aug 9, 2006 8:12:49 PM Reggie shutdown completed <myContainer> container shutdown successfully. |
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |