pools instead.@Deprecated public class BridgeWriter extends Object implements CacheWriter, Declarable
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):
BridgeWriter picks another server and then sends further
requests to that server. This achieves a level of load balancing by
redirecting requests away from servers that produce timeouts.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:
<parameter name="endpoints">
<string>MyPrimaryServer=hostsrv:40404,MySecondary=hostsrv2:40404</string>
</parameter>
<parameter name="readTimeout">
<string>5000</string>
</parameter>
<parameter name="retryAttempts">
<string>5</string>
</parameter>
ServerMonitor to ping living servers to verify that
they are still alive and dead servers to verify that they are still dead.
<parameter name="retryInterval">
<string>10000</string>
</parameter>
<parameter name="LBPolicy">
<string>Sticky</string>
</parameter>
0 causes no initial connections to be
created (they are only created on demand).
<parameter name="connectionsPerServer">
<string>10</string>
</parameter>
<parameter name="establishCallbackConnection">
<string>true</string>
</parameter>
<parameter name="redundancyLevel">
<string>1</string>
</parameter>
<parameter name="socketBufferSize">
<string>32768</string>
</parameter>
<parameter name="messageTrackingTimeout">
<string>300000</string>
</parameter>
<parameter name="clientAckInterval">
<string>5000</string>
</parameter>
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>
| Constructor and Description |
|---|
BridgeWriter()
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
public void init(Properties p)
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.init in interface Declarablep - configuration data such as 'endpoint' definitionsLicenseExceptionIllegalStateException - if the writer is already initializedpublic void init(BridgeWriter bridgeWriter)
BridgeWriter. This
method reuses the existing BridgeWriter's proxy.bridgeWriter - The existing BridgeWriterIllegalStateException - if the writer is already initializedpublic static void loadEmergencyClasses()
SystemFailure.loadEmergencyClasses()public void close()
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,close in interface CacheCallbackattach(Region),
detach(Region)public boolean isClosed()
BridgeWriter has been closed.public void detach(Region r)
destructionand
closure. This method effects the behavor of
close().r - the Region which will no longer use this BridgeWriterattach(Region),
close()public int getAttachCount()
public void release()
public void terminate()
public void beforeUpdate(EntryEvent event) throws CacheWriterException
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.beforeUpdate in interface CacheWriterevent - an EntryEvent that provides information about the operation in
progressCacheWriterException - if thrown will abort the operation in progress, and the exception
will be propagated back to caller that initiated the operationRegion.put(Object, Object),
Region.get(Object)public void beforeCreate(EntryEvent event) throws CacheWriterException
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.beforeCreate in interface CacheWriterevent - an EntryEvent that provides information about the operation in
progressCacheWriterException - if thrown will abort the operation in progress, and the exception
will be propagated back to caller that initiated the operationRegion.create(Object, Object),
Region.put(Object, Object),
Region.get(Object)public void beforeDestroy(EntryEvent event) throws CacheWriterException
Region.localDestroy(Object).beforeDestroy in interface CacheWriterevent - an EntryEvent that provides information about the operation in
progressCacheWriterException - if thrown will abort the operation in progress, and the exception
will be propagated back to caller that initiated the operationRegion.destroy(Object)public void beforeRegionDestroy(RegionEvent event) throws CacheWriterException
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.
beforeRegionDestroy in interface CacheWriterevent - a RegionEvent that provides information about theCacheWriterException - if thrown, will abort the operation in progress, and the
exception will be propagated back to the caller that initiated
the operationRegion.destroyRegion()public void beforeRegionClear(RegionEvent event) throws CacheWriterException
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.
beforeRegionClear in interface CacheWriterevent - a RegionEvent that provides information about theCacheWriterException - if thrown, will abort the operation in progress, and the
exception will be propagated back to the caller that initiated
the operationRegion.clear()public boolean hasEstablishCallbackConnection()
public int getRetryInterval()
public int getReadTimeout()
public int getRetryAttempts()
public String getLBPolicy()
public Properties getProperties()
BridgeWriter.BridgeWriterpublic void addEndpoint(String name, String host, int port) throws EndpointExistsException
Endpoint to the known Endpoints.name - The name of the endpoint to addhost - The host name or ip address of the endpoint to addport - The port of the endpoint to addEndpointExistsException - if the Endpoint to be
added already exists.public void removeEndpoint(String name, String host, int port) throws EndpointDoesNotExistException, EndpointInUseException
Endpoint from the dead Endpoints.
The specified Endpoint must be dead.name - The name of the endpoint to removehost - The host name or ip address of the endpoint to removeport - The port of the endpoint to removeEndpointDoesNotExistException - if the Endpoint to be
removed doesn't exist.EndpointInUseException - if the Endpoint to be removed
contains Connectionspublic String toString()
BridgeWriterpublic void attach(Region r)
close()
This is called internally when the BridgeWriter is added to a Region via
AttributesFactory.setCacheWriter(CacheWriter)}r - the Region which will begin use this BridgeWriter.detach(Region),
close()public Object getConnectionProxy()
ConnectionProxy associated with this
BridgeWriter.
For internal use only.ConnectionProxy associated with this
BridgeWriterCopyright © 1997-2017 Pivotal Software, Inc. All rights reserved.