Archive for the 'OpenSpaces' Category
TSSJS Prague: my take-aways
June 27th, 2008Once again TSSJS was a well-organized event with lots of interesting content. Hot topics that I took notice of were RIA, new languages, and obviously distributed computing and scalability. I arrived on Tuesday morning, which gave me a chance to…
Meet us @ TSSJS Prague
June 16th, 2008TheServerSide has a good record of picking nice spots for their conferences, and this year’s Java Symposium in Prague is no exception. It’s looking to be a fun event, as I’m going to meet not just lots of old friends,…
SyncRemoting cookbook
June 4th, 2008I wrote up a cheat sheet for myself when building scatter-gather or map reduce apps with GigaSpacesXAP.
It goes like this:
Create business interface (as part of shared classes)
Space-side stuff:
Create the Space-side implementation (logic) [ This may use a GigaSpace reference ]
Configure the implementation on the Space-Side:
Declare the business implementation as a [bean]
Declare a filter as part of the space
The filter references a ServiceExporter
Declare the os-remoting:service-exporter
The exporter references the business implementation [the bean]
If impl uses space: Declare the giga-space-context
Configure the implementation on the Space-Side:
Declare the business implementation as a [bean]
Declare a filter as part of the space
The filter references a ServiceExporter
Declare the os-remoting:service-exporter
The exporter references the business implementation [the bean]
If impl uses space: Declare the giga-space-context
Client-side stuff
Declare os-remoting:sync-proxy with its attributes:
The business interface it implements
The giga-space it uses as a transport layer
Whether broadcast is true or false
If necessary –declare the reducer for the proxy
Inject the client with the service proxy (ie: public void setMyService(MyService ref){} )
Let’s say we want to do a Map reduce exercise where each node in the cluster will process its share in parallel and return a total result for my digestion…
Let’s say I want to know the average price for all my widgets in all my inventory, but my inventory is scattered across a dozen servers because I do so much business…
I have my widgets:
package com.test.common;
import com.gigaspaces.annotation.pojo.SpaceRouting;
public class Widget {
private Double price;
private String description;
private Integer routingValue;
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@SpaceRouting
public Integer getRoutingValue() {
return routingValue;
}
public void setRoutingValue(Integer routingValue) {
this.routingValue = routingValue;
}
}
My Service needs an interface such as:
package com.test.common;
public interface PricingService{
public Double getAveragePriceOfAllWidgets();
}
Next, I need to implement the service:
package com.test;
import org.openspaces.core.GigaSpace;
import org.openspaces.core.context.GigaSpaceContext;
import com.j_spaces.core.client.SQLQuery;
import com.test.common.PricingService;
import com.test.common.Widget;
public class PricingServiceImpl implements PricingService{
@GigaSpaceContext
GigaSpace space;
public Double getAveragePriceOfAllWidgets() {
Object[] allWidgets = space.readMultiple(new Widget(), Integer.MAX_VALUE);
double priceTotal = 0.0d;
for(int x=0;x<allWidgets.length;x++){
priceTotal=priceTotal+((Widget)allWidgets[x]).getPrice().doubleValue();
}
double averagePrice = priceTotal/allWidgets.length;
return new Double(averagePrice);
}
}
Now I need a client that uses this service:
package com.test;
import java.util.TimerTask;
import com.test.common.PricingService;
public class WidgetSurfingClient extends TimerTask{
private PricingService service;
public void setPricingService(PricingService ref){
this.service=ref;
}
public void run(){
System.out.println(
”The average price of all widgets is now: $”+
service.getAveragePriceOfAllWidgets());
}
}
Now I need something to do the “reduce” side of the map-reduce: (it also performs the final average calculation because I am looking for the average price…
package com.test;
import org.openspaces.remoting.RemoteResultReducer;
import org.openspaces.remoting.SpaceRemotingInvocation;
import org.openspaces.remoting.SpaceRemotingResult;
public class AveragingDoubleResultReducer implements RemoteResultReducer<Double,Double>{
public Double reduce(SpaceRemotingResult<Double>[] results,
SpaceRemotingInvocation remotingInvocation) throws Exception {
double totalDouble = 0.0d;
int size = results.length;
for (int x=0;x<size;x++){
if(results[x]!=null){
if(results[x].getResult()!=null){
totalDouble += (Double) results[x].getResult();
}
}
}
double averageDouble=totalDouble/size;
return new Double(averageDouble);
}
}
That takes care of the Java code, now we have to configure this system:
First: the Space-side configuration:
<beans … XML namespace declaration stuff not shown…>
<!– bootstrap the construction of the serviceCluster: –>
<os-core:space id=”widgetTransport” url=”/./widgetsystem”>
<!– setup the PricingServiceExporter to handle calls –>
<os-core:filter-provider ref=”PricingServiceExporter”/>
</os-core:space>
<!– wrap the serviceCluster in Spring-ready OpenSpaces API –>
<os-core:giga-space id=”gigaspace” space=”widgetTransport”
tx-manager=”transactionManager” />
<!– declare the transaction manager –>
<os-core:local-tx-manager id=”transactionManager”
space=”widgetTransport”/>
<bean id=”PricingService” class=”com.test.PricingServiceImpl”/>
<!– provide a gigaspace context to the pricing service –>
<os-core:giga-space-context/>
<!–
Provide the binding to the Space-side
transport for the PricingService :
–>
<os-remoting:service-exporter id=”PricingServiceExporter”>
<os-remoting:service ref=”PricingService”/>
</os-remoting:service-exporter>
<!– configure a big or small cluster
(here we have 20 partitions with 1 backup for each) –>
<os-sla:sla cluster-schema=”partitioned-sync2backup”
number-of-instances=”20″ number-of-backups=”1″
max-instances-per-vm=”1″>
</os-sla:sla>
</beans>
Next: the client-side configuration:
<beans … XML namespace declaration stuff not shown…>
<!– bootstrap the basic proxy for the serviceCluster: –>
<os-core:space id=”widgetTransport” url=”jini://*/*/widgetsystem” />
<!– wrap the proxy in Spring-ready OpenSpaces API –>
<os-core:giga-space id=”gigaspace” space=”widgetTransport” />
<!– WidgetSurfer Service –>
<bean id=”WidgetSurfer” class=”com.test.WidgetSurfingClient”>
<property name=”pricingService” ref=”PricingService”/>
</bean>
<bean id=”AveragingDoubleResultReducer” class=”com.test.AveragingDoubleResultReducer”/>
<os-remoting:sync-proxy id=”PricingService”
giga-space=”gigaspace”
broadcast=”true”
interface=”com.test.common.PricingService”>
<os-remoting:result-reducer ref=”AveragingDoubleResultReducer”/>
</os-remoting:sync-proxy>
<!– this is regular Spring TimerTask configuration stuff: –>
<bean id=”widgetClientTask” class=”org.springframework.scheduling.timer.ScheduledTimerTask” >
<!– wait 1 seconds before starting repeated execution –>
<property name=”delay” value=”1000″ />
<!– run every 5 seconds –>
<property name=”period” value=”5000″ />
<property name=”timerTask” ref=”WidgetSurfer” />
</bean>
<bean id=”widgetClientTimer” class=”org.springframework.scheduling.timer.TimerFactoryBean”>
<property name=”scheduledTimerTasks”>
<list>
<!– This wires the factory to the scheduledTask bean above –>
<ref bean=”widgetClientTask” />
</list>
</property>
</bean>
</beans>
Cheers,
Owen.
OpenSpaces Developer Challenge WINNERS
May 28th, 2008Hurray and congrats to the 3 winners of our developer contest OpenSpaces Developer Challenge!
And the winners are (sorted alphabetically)…
Jason Carreira with DomainProxy
Kirill Ishanov with Gigapult
Leonardo Goncalves with GoDo - Goods Donation System
Who won the grand prize?
How was the review/judging process?
What is so special about the winning projects?
How do I join the next contest?
And the Winners [...]
Cool Projects on OpenSpaces.org
April 30th, 2008The OpenSpaces.org community site launched in January. I was surprise by the rapid adoption of OpenSpaces since then, with lots of interesting innovations on things I didn’t even think of. I’m sure that some of the projects will be very…
GigaSpaces Dashboard Using Hyperic plugin
April 21st, 2008Alexey Kharlamov created a project that implements a Hyperic plugin for GigaSpaces. It is available as an open source project on OpenSpaces.org. Hyperic is open source software for web infrastructure monitoring and management. Among its customers are Hi5 and Contegix….
Sharing Results of Expensive Computations
March 25th, 2008A customer recently contacted us to discuss how to use GigaSpaces XAP to minimize the number of times an expensive computation must run. The particular domain is option price stress testing, but the problem is more general and the solution demonstrates a couple of interesting GigaSpaces XAP features.
Consider a service that executes an expensive [...]
.Net Customer Announcement: Susquehanna (SIG)
March 11th, 2008In the past few months we've made several exciting announcements, such as our partnership with SpringSource , the expansion of our executive team, the launch of our community site OpenSpaces.org , the OpenSpaces Developer Challenge and the Start-Up Program . But there is nothing like a customer announcement, as in today's press release [...]
Underneath the Skin – What is the CPP Processing Unit and how can I build one?
March 1st, 2008I went to visit this extraordinary and shocking exhibition a few weeks ago - Bodies. It is located near pier 17 in Manhattan (not far from South Street Seaport, which I mentioned in my previous blog post).
See the links below for the exhibition site and a few videos: http://www.bodiestheexhibition.com/intro.html http://www.bodiestheexhibition.com/video/bodies-video-broadband-1.wmv http://www.bodiestheexhibition.com/video/bodies-video-broadband-2.wmv
You can find the same [...]
When virtualization meets SOA
February 26th, 2008There have been many separate discussions about SOA and virtualization. Only a few addressed how they relate to each other. Interestingly, while I was working on this post, Geva Perry brought to my attention Judith Hurwitz’s blog - Is Virtualization…
18 Submissions to OpenSpaces Developer Challenge, so far…
February 19th, 2008Well, this is an exciting moment…last Wednesday was the Early Birds submissions deadline of our Developer Challenge and so far we got 18 submissions! The reason I'm saying "so far" is that even though we passed the first milestone, people can still submit their concepts and final entries until April 02, 2008; click here to [...]
New OpenSpaces Demos and Examples Project
February 11th, 2008One of the goals of OpenSpaces.org is to promote best practices and recommended usage patterns among the GigaSpaces developer community. To that end, we have decided to dedicate some of our own resources to create a number of sample applications and blueprints that will help realize this goal. We have created a dedicated project under [...]







