GigaSpaces Starter Examples

  GigaSpaces 5.X

Documentation Home
Quick Start Guide
Release Notes

Previous release

  Search Here
Searching GigaSpaces Platform 5.X Documentation

                                               

Summary: GigaSpaces JavaSpaces, Data Grid, Map, JMS, JDBC, persistency, and Spring examples.

JavaSpaces Examples

Name Description Source Code Example Folder
helloWorld In this example, you start a local space/cache instance. You then execute an application (HelloWorld.java) that connects to the space, writes an object to it, and reads it back from the space, using the JavaSpaces API. The object is defined in Message.java. For more details, see the example description HelloWorld.java [main] Message.java <GigaSpaces Root>/examples/Basic/helloSpace
HelloWorldIterator In this example, a sample application (HelloWorldIterator.java) writes several objects to the space, defines a collection of templates (Message.java), and then uses the GigaSpaces GSIterator to iterate over the result. For more details, see the example description HelloWorldIterator.java [main]
Message.java
<GigaSpaces Root>\examples\Basic\helloSpace
HelloWorldNotify This example demonstrates usage of basic notifications in JavaSpaces. This allows a client to receive notification events when Entries are written into the space. HelloWorldNotify.java [main]
JiniSpaceAccessor.java
Listener.java
Message.java
<GigaSpaces Root>\examples\Basic\helloSpace
HelloWorldNotifyDelegator In this example, a sample application (HelloWorldNotifyDelegator.java) instantiates the GigaSpaces NotifyDelegator, writes objects to the space, and is automatically notified of each space operation. The space Entries class is defined in MyMetaDataEntry.java. For more details, see the example description HelloWorldNotifyDelegator.java [main]
Message.java
<GigaSpaces Root>\examples\Basic\helloSpace
HelloWorldTake In this example, a sample application (HelloWorldTake.java) writes three objects to the space, then reads and deletes one using the JavaSpaces-standard take() method. The objects are defined in Message.java. For more details, see the example description HelloWorldTake.java [main]
Message.java
<GigaSpaces Root>\examples\Basic\helloSpace
HelloWorldTransactions In this example, a sample application (HelloWorldTransaction.java) instantiates the GigaSpaces LocalTransactionManager, writes (Message.java) objects to the space under a transaction, and then rolls back the operation by aborting the transaction. For more details, see the example description HelloWorldTransaction.java [main]
Message.java
<GigaSpaces Root>\examples\Basic\helloSpace
HelloWorldUpdate In this example, a sample application (HelloWorldUpdate.java) writes an object to the space, defines new content for it, and then updates it with the new content using the update() method. The object is defined in MyMetaDataEntry.java. For more details, see the example description. HelloWorldUpdate.java [main]
Message.java
<GigaSpaces Root>\examples\Basic\helloSpace
batch-operations This example shows the usage of readMultiple, writeMultiple, takeMultiple and updateMultiple: these operations allow you to work with multiple Entries but make only one call on the space. The example shows the performance diffference between each batch operation and its single-operation counterpart. For more details, see readme.txt. JSBatchOperations.java [main]
Message.java
<GigaSpaces Root>\examples\Advanced\Advanced_JavaSpaces\batch-operations
query This example uses ReadMultiple, a GigaSpaces extension to the JavaSpaces standard, to read a group of entries that match a specific template. The SQLQuery class (see JavaDoc) is then used to query the space using the SQL syntax. For more details, see readme.txt. SimpleQuery.java [main]
MyEntry.java
<GigaSpaces Root>\examples\Advanced\Advanced_JavaSpaces\query
externalentry-query In this example, a sample application writes 50,000 Entries to the space and runs a query for the Entry with min/max values, using ExternalEntry (see JavaDoc) and the TemplateMatchCodes. For more details, see readme.txt. EEQuery.java <GigaSpaces Root>\examples\Advanced\Advanced_JavaSpaces\externalentry-query
fifo This example shows how to write FIFO (first-in-first-out) classes to the space and perform a take operation in FIFO mode. For more details, see readme.txt. Fifo.java [main]
FifoEntry.java
NonFifoEntry.java
<GigaSpaces Root>\examples\Advanced\Advanced_JavaSpaces\fifo
tokenized-notify In this example, a client application uses tokenized notifications to receive notifications for requested templates. The only difference from a simple notify is that the notification uses a TokenTemplate wrapping for the Entry. When such an Entry enters the space, its field is tokenized, and each tokened value is used to search a matching notify template. For more details, see readme.txt. TokenizedNotify.java [main]
MailMessage.java
<GigaSpaces Root>\examples\Advanced\Advanced_JavaSpaces\tokenized-notify

Data Grid Examples

Name Description Source Code Example Folder
replicated In this example, you start two local cache instances, which automatically form a replicated cache. You then execute an application (PopulateCache.java) that writes objects to the cache; wait for the data to be replicated to both cache nodes; and execute an application that reads the data back from the cache. The objects are defined in MyEntry.java; Utility.java ensures that a connection to cache has been established. For more details, see the example description. PopulateCache.java [main]
Utility.java
MyEntry.java
<GigaSpaces Root>\examples\Advanced\Data_Grid\replicated
partitioned In this example, you start two local cache instances, which together form a partitioned cache. You then execute an application (PopulateCache.java) that writes objects to the partitioned cache, and see that half of the data was written to each partition. The objects are defined in MyEntry.java; Utility.java ensures that a connection to cache has been established. For more details, see the example description. PopulateCache.java [main]
Utility.java
MyEntry.java
<GigaSpaces Root>\examples\Advanced\Data_Grid\partitioned
master-local In this example, you start a cache instance which acts as a master cache. You then execute an application (PopulateCache.java) that writes objects to the master cache, and then execute an application that requests the data from a local in-memory cache. On the first request, the data is copied from the master cache; on subsequent requests, it is read directly from the local in-memory cache. The objects are defined in MyEntry.java. For more details, see the example description. PopulateCache.java [main]
MyEntry.java
<GigaSpaces Root>\examples\Advanced\Data_Grid\master-local
HibernateCachePlugin This example shows how GigaSpaces allows client applications to use the Hibernate interface transparently. Hibernate's pluggable cache interfaces (CacheProvider and Cache) are implemented using the GigaSpaces map interface. For more details, see readme.txt. Main.java [main]
Record.java
GigaHibernateCache.java
GigaSpacesCacheProvider.java
Utility.java
<GigaSpaces Root>\examples\Advanced\Data_Grid\Database-Integration\HibernateCachePlugin
fail-over In this example, replication and failover are defined between two cache instances, cache1 and cache2. Operations are automatically routed to cache2 if cache1 is shut down. A sequence list of numbers is used in reading and writing iterations, allowing you to check consistency after shutting down one of the cache instances. For more details, see readme.txt. ReplicationFailOver.java [main]
CounterEntry.java
<GigaSpaces Root>\examples\Advanced\Data_Grid\fail-over
simple-ol In this example, one Entry is updated by many concurrent workers (10 by default). Every worker increments the salary field by 10. The internal versionID provided by the space is used to keep consistency. For more details, see readme.txt. OptimisticLock.java [main]
myEntry.java
<GigaSpaces Root>\examples\Advanced\Data_Grid\Optimistic-Locking\simple-ol
advanced-ol In this example, each of several concurrent workers (10 by default) uses the updateMultiple operation to update several Entries under a transaction. In each Entry, the salary field is incremented by 10. The internal versionID provided by the space is used to keep consistency. For more details, see readme.txt. OptimisticLockMultipleTx.java [main]
myEntry.java
<GigaSpaces Root>\examples\Advanced\Data_Grid\Optimistic-Locking\advanced-ol
multi-space-query This example queries a partitioned cache, without using index fields (this is otherwise mandatory). Every group member is contacted separately; a readMultiple operation is executed (multi-threaded); and the result is returned in an ArrayList. For more details, see readme.txt. MultispaceQuery.java [main]
MyEntry.java
<GigaSpaces Root\examples\Advanced\Data_Grid\multi-space-query
HibernateCacheStore This example loads or stores data into or from the space, using Hibernate to map space objects to external database tables. The example uses the Space API with the write, writeMultiple, read, take, readMultiple, and takeMultiple operations using null templates, non-null templates, and SQLQuery templates. For more details, see readme.txt. SpaceLauncher.java [main]
CacheStoreSpaceApi.java [main]
Person.java
<GigaSpaces Root>\examples\Advanced\Data_Grid\Database-Integration\HibernateCacheStore
JDBCCacheStore This example loads or stores data into or from the space, using the JDBC API to map space objects to external database tables. The example demonstrates the Space API, by using its basic methods with null templates, non-null templates, and SQLQuery templates, with or without transactions; and the Map API, by using its basic methods, with or without transactions. For more details, see readme.txt. CacheStoreSpaceApi.java [main]
CacheStoreMapApi.java [main]
CacheStoreImpl.java
JDCConnection.java
JDCConnectionDriver.java
JDCConnectionPool.java
Person.java
<GigaSpaces Root>\examples\Advanced\Data_Grid\Database-Integration\JDBCCacheStore

Basic Map Examples

Name Description Source Code Example Folder
HelloWorld In this example, you start a local cache instance. You then execute an application (HelloWorld.java) that connects to the space, puts an object to it, and gets it back, using the Map API. The object is defined in Message.java. For more details, see the example description. HelloWorld.java [main]
Message.java
<GigaSpaces Root>/examples/Basic/helloMap
HelloWorldTransaction In this example, a sample application (HelloWorldTransaction.java) instantiates the GigaSpaces LocalTransactionManager, puts an object to the cache under a transaction, and then rolls back the operation by aborting the transaction. For more details, see the example description HelloWorldTransaction.java [main]
Message.java
<GigaSpaces Root>/examples/Basic/helloMap
HelloWorldNotifyDelegator This example demonstrates usage of notifications by the Map API. This allows a client to receive notification events when objects are placed into the Map and written into the space. HelloWorldNotifyDelegator.java [main]
main
<GigaSpaces Root>/examples/Basic/helloMap

Basic JDBC Example

Name Description Source Code Example Folder
HelloWorld In this example, you start a space instance. You then execute an application (JDBCSpaces.java) that establishes a JDBC connection to the space, creates a table, and performs several SQL operations on the table data. For more details, see the example description. JDBCSpaces.java [main]
Utility.java
<GigaSpaces Root>/examples/Basic/helloJDBC

Basic JMS Example

Name Description Source Code Example Folder
helloJMS This example demonstrates the GigaSpaces JMS API usage. For more details, see readme.txt SenderToQueue.java [main]
SynchQueueReceiver.java [main]
SampleUtilities.java
TextListener.java
<GigaSpaces Root>/examples/Basic/helloJMS

Persistency Example

Name Description Source Code Example Folder
persistence In this example, you start a cache instance which is persisted to a database. You then execute an application (WriteSequence.java) that writes objects with an incremented counter (CounterEntry.java); these objects are automatically saved to the database. When you restart the space and re-run the application, the write continues from the last counter position. For more details, see the example description WriteSequence.java [main]
CounterEntry.java
<GigaSpaces Root>/examples/Basic/persistence

Spring Examples

Name Description Source Code Example Folder
GigaSpacesTemplate The GigaSpacesTemplate example shows how to use the GigaSpaces Spring Template that hides the JavaSpaces semantics and API from the user. It demonstrates the basic GigaSpaces APIs such as write, read, take, update and notify. For more details, see readme.txt. Notify.java [main]
Take.java [main]
Update.java [main] WriteRead.java [main]
Employee.java
Person.java
<GigaSpaces Root>
/spring
/examples
/gigaspaces
template
helloJDBCTemplate The GigaSpaces Spring JDBC example (based on the basic helloJDBC example) demonstrates the usage of the GigaSpaces JDBC API using the Spring JDBCTemplate API: CREATE TABLE, INSERT, DELETE, and SELECT on the space. For more details, see readme.txt. HelloJdbc.java [main] <GigaSpaces Root>
/spring
/examples
/helloJDBC
Template
HelloJMSTemplate The helloJMSTemplate example (based on the basic helloJMS example) demonstrates the usage of the Gigaspaces JMS implementation transparently. For more details, see readme.txt. SenderToQueue [main]
SynchQueueReceiver [main]
<GigaSpaces Root>
/spring
/examples
/HelloJMS
Template
remote The remote example shows the master-worker pattern using the GigaSpaces Spring Remote. For more details, see readme.txt. Master.java [main]
Result.java
Stopwatch.java
Task.java
TaskImpl
Worker.java
<GigaSpaces Root>
/spring
/examples
/remote
Transaction The Transaction example demonstrates programmatic and declarative usage of the GigaSpaces Spring Transaction support. GigaSpaces Spring Transaction is responsible for creating, starting, suspending, resuming, committing and rolling back the transactions which encompass space resource(s). The example can be executed in two different transaction types: declarative or programmatic. For more details, see readme.txt. TransactionWrite.java[main]
Employee.java ITransactedDao.java Person.java TransactedDao.java
<GigaSpaces Root>
/spring
/examples
/transaction
Declarative Caching This example demonstrates the GigaSpaces Spring Declarative Caching Integration. The space operations are injected into the POJO business domain classes, allowing the user to load, store, and delete data from the space implicitly. It can be dowloaded from the GigaSpaces website: http://www.gigaspaces.com/JForum/posts/list/139.page    

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