Space Local View

  GigaSpaces 5.X

Documentation Home
Quick Start Guide
Release Notes

Previous release

  Search Here
Searching GigaSpaces Platform 5.X Documentation

                                               

Summary: The space local view proxy maintains a subset of the master space's data, allowing the client to read distributed data without any remote operations.

Overview

The space local view proxy maintains a subset of the master space's data, allowing the client to read distributed data without any remote operations.

Data is streamed into the client view in an implicit manner – as opposed to local cache data, that is loaded into the client on-demand, and later updated or evicted.

The local view is defined via a filter – regular template or SQLQuery – as opposed to the local cache that caches data at the client side only after the data has been read.

The space local view can be constructed using:

IJSpace localViewSpace = (IJSpace)SpaceFinder.find("jini://*/*/myMasterSpace?useLocalCache&
views={com.gs.MyClass1:A=3 AND b=3,com.gs.MyClass2:g=3 AND b=3}");
IJSpace localViewSpace = (IJSpace)SpaceFinder.find("jini://*/*/myMasterSpace?useLocalCache" , properties);

Read-Only Feature
The following operations are not supported when using local view, and should be performed directly in the master space:
  • write
  • writeMultiple
  • update
  • updateMultiple
  • replace
  • clear
  • Any operation under a transaction
  • take
New in GigaSpaces 5.2
The Space Local View is a new feature in GigaSpaces version 5.2 and onwards.
For details on how to run a two-level cache: a local cache in the physical address space of the application and a master cache in a different process, refer to the Master-Local Space section.

Streaming Space Subset Data into Client

Once the local view is constructed, data is pre-loaded into the client based on the view filter criteria (as opposed to the local cache that does not have a pre-load phase).

The local view is continuously updated by the master space in an asynchronous mode (using notifications). Both write and update operations are delivered into the client based on the view filter criteria (as opposed to the local cache that delivers only update operations to the client).

All read operations (including readMultiple) use the local view proxy only (as opposed to the local cache that might read data from a remote master space).

Data is not evicted from the local view.

Write, update, or take operations using the local view proxy affect also the remote master space.

Code Example

Stock ibmStock = new Stock("ibm");
Stock microsoftStock = new Stock("microsoft");
View[] views = new View [2];
views[0] = new View (ibmStock , "name='ibm' and price<1000");
views[1] = new View (microsoftStock , "name='microsoft' and price>1000");
Properties props = new Properties();
props.put("views" ,views );
IJSpace spaceView = (IJSpace) SpaceFinder.find("jini://*/*/myCache?timeout=10000&useLocalCache" , props);
NotifyDelegator ntf = new NotifyDelegator(spaceView,new Stock() , null ,this , Lease.FOREVER , null , true ,
NotifyModifiers.NOTIFY_ALL); // will get notifications from local view
Entry[] stocks = spaceView.readMultiple(new Stock() , null, 1000 ); // will read data only from local view

IRemoteJSpaceAdmin admin = (IRemoteJSpaceAdmin)spaceView.getAdmin();
admin.stop(); // stop the local view from being updated
admin.restart();

Example

To download a running example that demonstrates local view usage, click here.

The example includes:

  • A feeder program (Feeder.java) that writes four different Stock Entries into the space: Microsoft, IBM, HP, and Oracle, and updates their price constantly.
  • An application program (Application.java) – used by the trader to track only IBM stock that its price<1000, and Microsoft stock that its price>1000, using the relevant local view. The application program performs read operations from the local view and also gets notifications from the local view. The output presents both the data in the local view and the notifications sent from the local view when modified by the master space.
  • A monitor program (Monitor.java) – this program acts as a control program and alerts the user when the feeder writes Entries into the master space that are different from the filter defined by the application program.

Wiki Content Tree


Your Feedback Needed!

We need your help to improve this wiki site. If you have any suggestions or corrections, write to us at techw@gigaspaces.com. Please provide a link to the wiki page you are referring to.

Labels