XAP

Getting Started

This section contains guidance for getting started with GigaSpaces Service GridClosed A built-in orchestration tool which contains a set of Grid Service Containers (GSCs) managed by a Grid Service Manager. The containers host various deployments of Processing Units and data grids. Each container can be run on a separate physical machine. This orchestration is available for XAP only. (for XAPClosed GigaSpaces eXtreme Application Platform. Provides a powerful solution for data processing, launching, and running digital services) and KubernetesClosed An open-source container orchestration system for automating software deployment, scaling, and management of containerized applications. (XAP SkylineClosed A highly customizable developer platform that allows building scalable HA with high throughput and ultra-low latency Java applications running on Kubernetes clusters) environments.

 

Order Action Code Example Reference/Explanation
1 Create and connect to a SpaceClosed Where GigaSpaces data is stored. It is the logical cache that holds data objects in memory and might also hold them in layered in tiering. Data is hosted from multiple SoRs, consolidated as a unified data model.

// an example of instantiating a remote proxy

SpaceProxyConfigurer configurer = new SpaceProxyConfigurer("demo"); GigaSpace gigaSpace = new GigaSpaceConfigurer(configurer).gigaSpace();
The Space Bean
2 GigaSpaces Basic API - Write & Read Client Blueprint The Space Operations
3 Build your Data Model @SpaceClass public class Person { private Integer id; private String name; private String lastName; private int age; ... public Person() {} @SpaceId(autoGenerate=false) @SpaceRouting public Integer getId() { return id;} public void setId(Integer id) { this.id = id; } @SpaceIndex(type=SpaceIndexType.EQUAL) public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } @SpaceProperty(nullValue="-1") public int getAge(){ return age; } ....... } Modeling Your Data
4 Understanding RoutingClosed The mechanism that is in charge of routing the objects into and out of the corresponding partitions. The routing is based on a designated attribute inside the objects that are written to the Space, called the Routing Index.

Routing is the property inside a space class that says how objects will be distributed across partitions, there is also a strategy that instead of distributing you can replicate the table data across all partitions for small tables.

@SpaceClass public class Account { Integer accountID; String accountName; @SpaceRouting public Integer getAccountID() { return accountID; } public String getAccountName() { return accountName; } // setter methods ... }

 

Data Partitioning Practical

Broadcast Objects

5 Add Colocated Logic to your Space

Colocated logic can contain event processing, code for services, and any application bean that should run together within the Space partition, in the example provided, you can see colocated event containers and remote service exposure

 

In your installation folder you will find examples of event processing:

<GS_HOME>\examples\data-app\event-processing

Polling Container Overview

6 Query your data results = gigaSpace.readMultiple(new SQLQuery<MyClass>(MyClass.class, "num > 1 ORDER BY name")); Query Language
7 Change your Data Efficiently

// change api gigaSpace.change(sqlQuery, new ChangeSet().increment("price", new BigDecimal(5)));

Change API Overview
8 Send Code to be Executed on Data JVMs

public class MyDistTask implements DistributedTask<Integer, Long> { public Integer execute() throws Exception { return 1; } public Long reduce(List<AsyncResult<Integer>> results) throws Exception { long sum = 0; for (AsyncResult<Integer> result : results) { if (result.getException() != null) { throw result.getException(); } sum += result.getResult(); } return sum; } }

 

AsyncFuture<Long> future = gigaSpace.execute(new MyDistTask());long result = future.get(); // result will be number of partitions

 

Task Execution Overview
9 Build Workflows

With event processing you can build workflows, moving related object from one state to the other and define listeners per state

 

SimplePollingEventListenerContainer pollingEventListenerContainer = new SimplePollingContainerConfigurer(gigaSpace).template(new Data(false)).eventListenerAnnotation(new Object() {@SpaceDataEventpublic void eventHappened() {eventCalled.set(true);}}).pollingContainer();// start the notificationpollingEventListenerContainer.start()

Event Processing

10 Interact with the Database

You can perform an initial load into the Space from a data source and can replicate changes in memory to a target (database, KafkaClosed Apache Kafka is a distributed event store and stream-processing platform. Apache Kafka is a distributed publish-subscribe messaging system. A message is any kind of information that is sent from a producer (application that sends the messages) to a consumer (application that receives the messages). Producers write their messages or data to Kafka topics. These topics are divided into partitions that function like logs. Each message is written to a partition and has a unique offset, or identifier. Consumers can specify a particular offset point where they can begin to read messages.). Refer to the blueprintClosed Java project templating framework provided by DIH for developers, a bueprint, or class, contains a set of attributes and behaviors that define an object. example (see #2 above) of how to load data from a relational database using hibernate integration and how to replicate data to that database, similar can be done with other kinds of sources such as MongoDB, Cassandara and Kafka.

 

stateful-with-db BluePrint

Persistency for a Database
11 Creating a PUClosed This is the unit of packaging and deployment in the GigaSpaces Data Grid, and is essentially the main GigaSpaces service. The Processing Unit (PU) itself is typically deployed onto the Service Grid. When a Processing Unit is deployed, a Processing Unit instance is the actual runtime entity. (Service)

Creating a PU

 
12a

Deploy your Services in Service Grid

XAP only

Deploying onto the Service Grid

Deploy with RESTClosed REpresentational State Transfer. Application Programming Interface An API, or application programming interface, is a set of rules that define how applications or devices can connect to and communicate with each other. A REST API is an API that conforms to the design principles of the REST, or representational state transfer architectural style., CLI, OPS-UI, Admin code

12b

Deploy your Services in Kubernetes

XAP Skyline only

Deploying a Customer Processing Unit

helm install custom-pu gigaspaces/xap-pu --version 16.5.0 --set instances=0,partitions=1,resourceUrl=pu.jar,image.repository=my-space,image.tag=latest
  • Out of the box XAP Skyline is stateless so there is no need to create new stateless custom PUs as they have no added value.  However, when migrating from XAP to XAP Skyline there will already be stateless PUs defined and theses can be deployed and do not need to be recreated.

  • Creating Client Services in Kubernetes (refer to the README)

Training Materials

The following training materials can be accessed in order to assist in getting started:

Examples

Integration examples such as Spring data, how to use GrafanaClosed Grafana is a multi-platform open source analytics and interactive visualization web application. It provides charts, graphs, and alerts for the web when connected to supported data sources., monitoring with Kubernetes, installing on OpenShift, deep learning, and more can be found in our Git Solution Hub. You can also find a best practice section with examples for WAN gateway replication, Data modeling patterns, Custom aggregation examples, and much more.

 

Need assistance or further information? Don't hesitate to contact us — we're here to help!