Summary: This page explains how to filter specific data from being replicated through a gateway to another site.
This page assume prior knowledge of multi-site replication, please refer to Multi-Site Replication (WAN) before reading this page.

Overview

In some cases, there can be data that should not be replicated between the sites but should still be replicated locally between the primary and the backup/mirror service. In this case using the replicate class level or object level decoration is irrelevant as there is a need to control the replication behavior only to the remote site. Since a replication channel to a gateway is like any other replication channel, therefore a custom Replication Filter at the source space can be used to filter the relevant data from being sent to the target gateway.

This filtering should be based on the replication target name in order to identify the correct replication filter is called for the outgoing replication to the gateway.

The output-filter can be used also to modify the replicated data before it is arriving the target site. When using a SpaceDocument the modified field must be a predefined field described with the document schema (fixed field).

Using the Filter

With the example below a replication filter is used with the source space (output-filter). The New-York space is configured not to replicate the Stock object type to London site. This Stock object type still being replicated to all other location replication targets (backup/mirror) and also to the remote Hong Kong gateway. The filtering can be determined also based on the content of the replicated object or any other custom business logic.

New York Space
<?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"
	xmlns:os-events="http://www.openspaces.org/schema/events"
	xmlns:os-remoting="http://www.openspaces.org/schema/remoting"
	xmlns:os-sla="http://www.openspaces.org/schema/sla"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.openspaces.org/schema/core 
       http://www.openspaces.org/schema/8.0/core/openspaces-core.xsd
       http://www.openspaces.org/schema/events 
       http://www.openspaces.org/schema/8.0/events/openspaces-events.xsd
       http://www.openspaces.org/schema/remoting 
       http://www.openspaces.org/schema/8.0/remoting/openspaces-remoting.xsd
       http://www.openspaces.org/schema/sla 
       http://www.openspaces.org/schema/8.0/sla/openspaces-sla.xsd
       http://www.openspaces.org/schema/core/gateway 
       http://www.openspaces.org/schema/8.0/core/gateway/openspaces-gateway.xsd">


        <bean id="londonFilter" class="com.gigaspaces.examples.gateway.LondonReplicationFilter"/>

        <os-core:space id="space" url="/./myNYSpace" gateway-targets="gatewayTargets">
          <os-core:space-replication-filter>
            <os-core:output-filter ref="londonFilter"/>
          </os-core:space-replication-filter>
        </os-core:space>

        <os-gateway:targets id="gatewayTargets" local-gateway-name="NEWYORK">
          <os-gateway:target name="LONDON"/>    	    	        	        
          <os-gateway:target name="HONGKONG"/>    	    	        	        
        </os-gateway:targets>	

</beans>

Replication Filter Implementation
public class LondonReplicationFilter implements IReplicationFilter {
    
  public void init(IJSpace space, String paramUrl, ReplicationPolicy replicationPolicy) {  
  }

  public void process(int direction, IReplicationFilterEntry replicationFilterEntry, String replicationTargetName) {
      if (replicationTargetName.equals("gateway:LONDON")) {
          if (replicationFilterEntry.getClassName().equals(Stock.class.getName())) {
              replicationFilterEntry.discard();
          }
      }
  }

  public void close() {
  }
}
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence