GemFire 6.6.1

com.gemstone.gemfire.cache.util
Class BridgeWriter

java.lang.Object
  extended by com.gemstone.gemfire.cache.util.BridgeWriter
All Implemented Interfaces:
CacheCallback, CacheWriter, Declarable
Direct Known Subclasses:
BridgeClient

Deprecated. as of 5.7 use pools instead.

@Deprecated
public class BridgeWriter
extends Object
implements CacheWriter, Declarable

A CacheWriter that writes data to one or more remote CacheServer processes. This allows for a hierarchical caching scheme in which one cache ('client' cache) delegates a request to another cache ('server' cache). When using the BridgeWriter, at least two GemFire Caches must exist in a client/server mode (they should not be part of the same distributed system). The 'server' cache must be running a gemfire CacheServer process, while the 'client' cache must have a BridgeWriter installed in one or more of its Regions. If a BridgeWriter is defined in a client Region, there must also be a Region defined in the 'server' cache with the same exact name.

The BridgeWriter performs put() operations on the remote server cache, and does not provide the distribution behavior that can be enabled by using a DISTRIBUTED or DISTRIBUTED_NO_ACK Region. This mechanism is designed as a more targeted alternative to netSearch, in which the 'client' cache completely delegates the loading of the data to the 'server' cache if it is not yet cached in the client. This directed behavior enables a remote network put() operation to be performed much more efficiently in a scenario where there is a hierarchical cache topology. Updates and invalidation remain local, in fact the Regions that are used for this loosely coupled cache may even be LOCAL in scope. The BridgeWriter may be used to configure caches with multi-layer hierarchies.

Load Balancing:

The BridgeWriter supports these load balancing mechanisms (specified by the LBPolicy config attribute):

Failover:

If a remote server cache throws an exception or times out, the client will retry based on the configured retryCount parameter. If the retryCount is exceeded, the server in question will be added to a failed server list, and the client will select another server to connect to. The servers in the failed server list will be periodically pinged with an intelligent ping that ensures cache health. If a server is determined to be healthy again, it will be promoted back to the healthy server list. The time period between failed server pings is configurable via the retryInterval parameter.

Configuration:

The BridgeWriter is configurable declaratively or programmatically. Declarative configuration is achieved through defining the configuration parameters in a cache.xml file. Programmatic configuration may be achieved by first instantiating a BridgeWriter object and subsequently calling init(Properties)with a Properties object containing each desired parameter and value.

The supported parameters are:

If you are using a cache.xml file to create a Region declaratively, you can include the following to associate a BridgeWriter with a Region (default values shown for optional parameters):

 
 <cache-writer>
   <classname>com.gemstone.gemfire.cache.util.BridgeWriter</classname>
   <parameter name="endpoints">
     <string>MyHost=ninja.gemstone.com:40404</string>
   </parameter>
   <parameter name="readTimeout">
     <string>10000</string>
   </parameter>
   <parameter name="retryAttempts">
     <string>5</string>
   </parameter>
   <parameter name="retryInterval">
     <string>10000</string>
   </parameter>
   <parameter name="LBPolicy">
     <string>Sticky</string>
   </parameter>
   <parameter name="establishCallbackConnection">
     <string>false</string>
   </parameter>
   <parameter name="socketBufferSize">
     <string>32768</string>
   </parameter>
   </parameter>
   <parameter name="messageTrackingTimeout">
     <string>300000</string>
   </parameter>
   </parameter>
   </parameter>
   <parameter name="clientAckInterval">
      <string>5000</string>
    </parameter>
 </cache-writer>
 

Since:
3.5

Constructor Summary
BridgeWriter()
          Deprecated.  
 
Method Summary
 void addEndpoint(String name, String host, int port)
          Deprecated. Add an Endpoint to the known Endpoints.
 void attach(Region r)
          Deprecated. Notify the BridgeWriter that the given Region will begin delivering events to this BridgeWriter.
 void beforeCreate(EntryEvent event)
          Deprecated. Called before an entry is created.
 void beforeDestroy(EntryEvent event)
          Deprecated. Called before an entry is destroyed.
 void beforeRegionClear(RegionEvent event)
          Deprecated. Called before a region is cleared.
 void beforeRegionDestroy(RegionEvent event)
          Deprecated. Called before a region is destroyed.
 void beforeUpdate(EntryEvent event)
          Deprecated. Called before an entry is updated.
 void close()
          Deprecated. Called when a region using this BridgeWriter is destroyed, when the cache is closed, or when a callback is removed from a region using an AttributesMutator.
 void detach(Region r)
          Deprecated. Notify the BridgeWriter that the given region is no longer relevant.
 int getAttachCount()
          Deprecated. Returns the number of attaches that have not yet called detach.
 Object getConnectionProxy()
          Deprecated. Returns the ConnectionProxy associated with this BridgeWriter.
 String getLBPolicy()
          Deprecated. Returns the load balancing policy being used by the bridge writer Internal use only
 Properties getProperties()
          Deprecated. Returns the properties that defined this BridgeWriter.
 int getReadTimeout()
          Deprecated. Returns the read timeout being used to time out requests to the server Internal use only.
 int getRetryAttempts()
          Deprecated. Returns the number of times the bridge writer tries to write data on encountering certain types of exceptions.
 int getRetryInterval()
          Deprecated. Returns the retry interval in use.
 boolean hasEstablishCallbackConnection()
          Deprecated. Return true if this writer has not been closed and it was configured to establish a callback connection.
 void init(BridgeWriter bridgeWriter)
          Deprecated. Initializes this writer from an existing BridgeWriter.
 void init(Properties p)
          Deprecated. Initializes the writer with supplied config parameters.
 boolean isClosed()
          Deprecated. Returns true if this BridgeWriter has been closed.
static void loadEmergencyClasses()
          Deprecated. Ensure that the BridgeClient and BridgePoolImpl classes get loaded.
 void release()
          Deprecated. For speed optimizations, a connection to a server may be assigned to the calling thread when the BridgeWriter is used to do an operation.
 void removeEndpoint(String name, String host, int port)
          Deprecated. Remove an Endpoint from the dead Endpoints.
 void terminate()
          Deprecated. This method should be invoked when the BridgeWriter mechanism is to be shut down explicitly , outside of closing the cache.
 String toString()
          Deprecated. Returns a brief description of this BridgeWriter
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BridgeWriter

public BridgeWriter()
Deprecated. 
Method Detail

init

public void init(Properties p)
Deprecated. 
Initializes the writer with supplied config parameters. If instantiating the writer programmatically, this method must be called with a Properties object that at a minimum contains the 'endpoints' parameter before the writer can be used. If init fails with a LicenseException, the resulting BridgeWriter will throw IllegalStateException until it is properly initialized.

Specified by:
init in interface Declarable
Parameters:
p - configuration data such as 'endpoint' definitions
Throws:
LicenseException
IllegalStateException - if the writer is already initialized

init

public void init(BridgeWriter bridgeWriter)
Deprecated. 
Initializes this writer from an existing BridgeWriter. This method reuses the existing BridgeWriter's proxy.

Parameters:
bridgeWriter - The existing BridgeWriter
Throws:
IllegalStateException - if the writer is already initialized
Since:
4.2

loadEmergencyClasses

public static void loadEmergencyClasses()
Deprecated. 
Ensure that the BridgeClient and BridgePoolImpl classes get loaded.

See Also:
SystemFailure.loadEmergencyClasses()

close

public void close()
Deprecated. 
Called when a region using this BridgeWriter is destroyed, when the cache is closed, or when a callback is removed from a region using an AttributesMutator. Closes connections to BridgeServerswhen all Regionsare finished using this BridgeWriter,

Specified by:
close in interface CacheCallback
See Also:
attach(Region), detach(Region)

isClosed

public boolean isClosed()
Deprecated. 
Returns true if this BridgeWriter has been closed.


detach

public void detach(Region r)
Deprecated. 
Notify the BridgeWriter that the given region is no longer relevant. This method is used internally during Region destructionand closure. This method effects the behavor of close().

Parameters:
r - the Region which will no longer use this BridgeWriter
Since:
4.3
See Also:
attach(Region), close()

getAttachCount

public int getAttachCount()
Deprecated. 
Returns the number of attaches that have not yet called detach.

Since:
5.7

release

public void release()
Deprecated. 
For speed optimizations, a connection to a server may be assigned to the calling thread when the BridgeWriter is used to do an operation. When the application thread is done doing its work it can invoke the BridgeWriter release method to make the connection available to other application threads.


terminate

public void terminate()
Deprecated. 
This method should be invoked when the BridgeWriter mechanism is to be shut down explicitly , outside of closing the cache.


beforeUpdate

public void beforeUpdate(EntryEvent event)
                  throws CacheWriterException
Deprecated. 
Called before an entry is updated. The entry update is initiated by a put or a get that causes the writer to update an existing entry. The entry previously existed in the cache where the operation was initiated, although the old value may have been null. The entry being updated may or may not exist in the local cache where the CacheWriter is installed.

Specified by:
beforeUpdate in interface CacheWriter
Parameters:
event - an EntryEvent that provides information about the operation in progress
Throws:
CacheWriterException - if thrown will abort the operation in progress, and the exception will be propagated back to caller that initiated the operation
See Also:
Region.put(Object, Object), Region.get(Object)

beforeCreate

public void beforeCreate(EntryEvent event)
                  throws CacheWriterException
Deprecated. 
Called before an entry is created. Entry creation is initiated by a create, a put, or a get. The CacheWriter can determine whether this value comes from a get or not from EntryEvent.isLoad(). The entry being created may already exist in the local cache where this CacheWriter is installed, but it does not yet exist in the cache where the operation was initiated.

Specified by:
beforeCreate in interface CacheWriter
Parameters:
event - an EntryEvent that provides information about the operation in progress
Throws:
CacheWriterException - if thrown will abort the operation in progress, and the exception will be propagated back to caller that initiated the operation
See Also:
Region.create(Object, Object), Region.put(Object, Object), Region.get(Object)

beforeDestroy

public void beforeDestroy(EntryEvent event)
                   throws CacheWriterException
Deprecated. 
Called before an entry is destroyed. The entry being destroyed may or may not exist in the local cache where the CacheWriter is installed. This method is not called as a result of expiration or Region.localDestroy(Object).

Specified by:
beforeDestroy in interface CacheWriter
Parameters:
event - an EntryEvent that provides information about the operation in progress
Throws:
CacheWriterException - if thrown will abort the operation in progress, and the exception will be propagated back to caller that initiated the operation
See Also:
Region.destroy(Object)

beforeRegionDestroy

public void beforeRegionDestroy(RegionEvent event)
                         throws CacheWriterException
Deprecated. 
Called before a region is destroyed. The CacheWriter will not additionally be called for each entry that is destroyed in the region as a result of a region destroy. If the region's subregions have CacheWriter s installed, then they will be called for the cascading subregion destroys. This method is not called as a result of expiration or Region.localDestroyRegion(). However, the close()method is invoked regardless of whether a region is destroyed locally. A non-local region destroy results in an invocation of beforeRegionDestroy(com.gemstone.gemfire.cache.RegionEvent)followed by an invocation of close().

WARNING: This method should not destroy or create any regions itself or a deadlock will occur.

Specified by:
beforeRegionDestroy in interface CacheWriter
Parameters:
event - a RegionEvent that provides information about the
Throws:
CacheWriterException - if thrown, will abort the operation in progress, and the exception will be propagated back to the caller that initiated the operation
See Also:
Region.destroyRegion()

beforeRegionClear

public void beforeRegionClear(RegionEvent event)
                       throws CacheWriterException
Deprecated. 
Called before a region is cleared. The CacheWriter will not additionally be called for each entry that is cleared in the region as a result of a region clear. If the region's subregions have CacheWriter s installed, then they will be called for the cascading subregion clears. This method is not called as a result of expiration or Region.localDestroyRegion(). However, the close()method is invoked regardless of whether a region is cleared locally. A non-local region clear results in an invocation of beforeRegionClear(com.gemstone.gemfire.cache.RegionEvent)followed by an invocation of close().

WARNING: This method should not destroy or create or clear any regions itself or a deadlock will occur.

Specified by:
beforeRegionClear in interface CacheWriter
Parameters:
event - a RegionEvent that provides information about the
Throws:
CacheWriterException - if thrown, will abort the operation in progress, and the exception will be propagated back to the caller that initiated the operation
See Also:
Region.clear()

hasEstablishCallbackConnection

public boolean hasEstablishCallbackConnection()
Deprecated. 
Return true if this writer has not been closed and it was configured to establish a callback connection.

Since:
4.3

getRetryInterval

public int getRetryInterval()
Deprecated. 
Returns the retry interval in use. Retry interval refers to the interval at which dead servers are attempted to be reconnected. Internal use only.


getReadTimeout

public int getReadTimeout()
Deprecated. 
Returns the read timeout being used to time out requests to the server Internal use only.


getRetryAttempts

public int getRetryAttempts()
Deprecated. 
Returns the number of times the bridge writer tries to write data on encountering certain types of exceptions. Internal use only


getLBPolicy

public String getLBPolicy()
Deprecated. 
Returns the load balancing policy being used by the bridge writer Internal use only


getProperties

public Properties getProperties()
Deprecated. 
Returns the properties that defined this BridgeWriter.

Returns:
the properties that defined this BridgeWriter
Since:
4.2

addEndpoint

public void addEndpoint(String name,
                        String host,
                        int port)
                 throws EndpointExistsException
Deprecated. 
Add an Endpoint to the known Endpoints.

Parameters:
name - The name of the endpoint to add
host - The host name or ip address of the endpoint to add
port - The port of the endpoint to add
Throws:
EndpointExistsException - if the Endpoint to be added already exists.
Since:
5.0.2

removeEndpoint

public void removeEndpoint(String name,
                           String host,
                           int port)
                    throws EndpointDoesNotExistException,
                           EndpointInUseException
Deprecated. 
Remove an Endpoint from the dead Endpoints. The specified Endpoint must be dead.

Parameters:
name - The name of the endpoint to remove
host - The host name or ip address of the endpoint to remove
port - The port of the endpoint to remove
Throws:
EndpointDoesNotExistException - if the Endpoint to be removed doesn't exist.
EndpointInUseException - if the Endpoint to be removed contains Connections
Since:
5.0.2

toString

public String toString()
Deprecated. 
Returns a brief description of this BridgeWriter

Overrides:
toString in class Object
Since:
4.0

attach

public void attach(Region r)
Deprecated. 
Notify the BridgeWriter that the given Region will begin delivering events to this BridgeWriter. This method effects the behavior of close() This is called internally when the BridgeWriter is added to a Region via AttributesFactory.setCacheWriter(CacheWriter)}

Parameters:
r - the Region which will begin use this BridgeWriter.
Since:
4.3
See Also:
detach(Region), close()

getConnectionProxy

public Object getConnectionProxy()
Deprecated. 
Returns the ConnectionProxy associated with this BridgeWriter. For internal use only.

Returns:
the ConnectionProxy associated with this BridgeWriter

GemFire 6.6.1

Copyright © 1997-2011 VMware, Inc. All rights reserved.