|
OverviewSince GigaSpaces 6.0, Mirror Service examples are part of the eternal data source examples. Primary-Backup topology with a Custom Mirror Service Deployed as a Processing UnitThis example introduce simple OpenSpaces Mirror benchmark application.
All application components deployed as Processing Units. <os-sla:sla cluster-schema="partitioned-sync2backup" number-of-instances="1" number-of-backups="1" max-instances-per-vm="1"> </os-sla:sla> Simply increase the number-of-instances to have larger value. Installing the ApplicationExtract the example into \GigaSpacesXAP\examples\openspaces folder. Deploying the ApplicationTo deploy the feeder , clustered space and a Mirror: The above build commands will create processing unit deployment folders at: Once you deploy the Feeder , cluster and the Mirror processing units, the UI should display the following:
The GSC running the Mirror Service will display its throughput: As you can see, because the Mirror is based on a reliable asynchronous replication channel, it is receiving its operations periodically. The Mirror Processing Unit configurationThe Mirror Processing Unit configuration declaration includes: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:os-core="http://www.openspaces.org/schema/core" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.openspaces.org/schema/core http://www.openspaces.org/schema/core/openspaces-core.xsd"> <bean id="propertiesConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> <bean id="myMirror" class="org.openspaces.example.mirror.MyMirror"> </bean> <os-core:space id="space" url="/./mirror-service" schema="mirror" external-data-source="myMirror" /> </beans> The org.openspaces.example.mirror.MyMirror is the actual custom Mirror implementation. The Mirror ImplementationThe org.openspaces.example.mirror.MyMirror class implements the BulkDataPersister and the ManagedDataSource interfaces. package org.openspaces.example.mirror; import java.util.List; import java.util.Properties; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.atomic.AtomicInteger; import com.gigaspaces.datasource.BulkDataPersister; import com.gigaspaces.datasource.BulkItem; import com.gigaspaces.datasource.DataIterator; import com.gigaspaces.datasource.DataSourceException; import com.gigaspaces.datasource.ManagedDataSource; public class MyMirror implements BulkDataPersister, ManagedDataSource<Person> { public class Reminder { Timer timer; public Reminder() { timer = new Timer(); timer.schedule(new RemindTask(), 1000 ,1000); } class RemindTask extends TimerTask { public void run() { int val = count.intValue(); int done = val -lastVal ; lastVal = val; long dur = System.currentTimeMillis() - lastTime; lastTime = System.currentTimeMillis(); double tp =0; if (done >0) { tp = (done) / (double) (dur) * 1000; } System.out.println("got:" + val + " operations" + " TP[oper/sec]:" + tp); } } } public AtomicInteger count = new AtomicInteger(); long lastTime = System.currentTimeMillis(); int lastVal = 0; Reminder reminder ; public void executeBulk(List<BulkItem> bulk) throws DataSourceException { count.getAndAdd(bulk.size()); } public void init(Properties arg) throws DataSourceException { System.out.println("init" + arg); reminder = new Reminder(); } public DataIterator<Person> initialLoad() throws DataSourceException { return null; } public void shutdown() throws DataSourceException { reminder.timer.cancel(); } } Primary-Backup topology with a Mirror ServiceThis figure shows how two spaces, a primary and its backup, are joined by a Mirror Service space.
Mirror Service over WANThis figure shows how two clusters, each of a primary and its backup, are joined together by a Mirror Service space.
|
(works on Firefox 2 and Internet Explorer 7)





