pools
instead.@Deprecated public class BridgeLoader extends Object implements CacheLoader, Declarable
CacheLoader
that loads data from 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 it cannot find the data locally.
When using the BridgeLoader
, at least two GemFire Caches must
be running 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 BridgeLoader
installed in one or more of its Regions
. If a
BridgeLoader
is defined in a client Region
,
there must also be a Region
defined in the 'server' cache with
the same exact name.
The BridgeLoader
performs get()
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 get()
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 BridgeLoader
may be used to configure caches with
multi-layer hierarchies.
Load Balancing:
The BridgeLoader
supports these load balancing mechanisms
(specified by the LBPolicy
config attribute):
BridgeLoader
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 BridgeLoader
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
BridgeLoader
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="socketBufferSize">
<string>32768</string>
</parameter>
If you are using a cache.xml
file to create a
Region
declaratively, you can include the following
<cache-loader> definition to associate a BridgeLoader
with a Region
(default values shown for optional parameters):
<cache-loader> <class-name>com.gemstone.gemfire.cache.util.BridgeLoader</class-name> <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="socketBufferSize"> <string>32768</string> </parameter> </parameter> </cache-loader>
Constructor and Description |
---|
BridgeLoader()
Deprecated.
|
BridgeLoader(BridgeWriter bw)
Deprecated.
Creates a loader from an existing
BridgeWriter . |
Modifier and Type | Method and Description |
---|---|
void |
addEndpoint(String name,
String host,
int port)
Deprecated.
Add an
Endpoint to the known Endpoint s. |
void |
attach(Region r)
Deprecated.
Notify the BridgeLoader that the given Region will begin calling
load(LoaderHelper) . |
void |
close()
Deprecated.
Called when the region containing this
BridgeLoader is
destroyed, when the Cache is closed, or when a callback is removed
from a region using an AttributesMutator
Closes connections to BridgeServer s when all Region s are
finished using this BridgeLoader, |
void |
detach(Region r)
Deprecated.
Notify the BridgeLoader that the given region is no longer relevant.
|
Object |
getConnectionProxy()
Deprecated.
Returns the
ConnectionProxy associated with this
BridgeLoader . |
String |
getLBPolicy()
Deprecated.
Returns the load balancing policy being used by the bridge loader 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 loader tries to get data on
encountering certain types of exceptions.
|
int |
getRetryInterval()
Deprecated.
Returns the retry interval in use.
|
void |
init(BridgeLoader bridgeLoader)
Deprecated.
Initializes this loader from an existing
BridgeLoader . |
void |
init(BridgeWriter bridgeWriter)
Deprecated.
Initializes this loader from an existing
BridgeWriter . |
void |
init(Properties p)
Deprecated.
Initializes the loader with supplied config parameters.
|
boolean |
isClosed()
Deprecated.
Returns true if this
BridgeLoader has been closed. |
Object |
load(LoaderHelper helper)
Deprecated.
This method is invoked implicitly when an object requested on the client
cache cannot be found.
|
static void |
loadEmergencyClasses()
Deprecated.
Ensure that the ConnectionProxyImpl class gets loaded.
|
SelectResults |
query(String queryStr)
Deprecated.
use
Region.query(java.lang.String) instead |
void |
release()
Deprecated.
For speed optimizations, a connection to a server may be assigned to the
calling thread when load is called.
|
void |
removeEndpoint(String name,
String host,
int port)
Deprecated.
Remove an
Endpoint from the dead Endpoint s. |
void |
terminate()
Deprecated.
This method should be invoked when the BridgeLoader mechanism is to be shut
down explicitly , outside of closing the cache.
|
String |
toString()
Deprecated.
Returns a brief description of this
BridgeLoader |
public BridgeLoader()
public BridgeLoader(BridgeWriter bw)
BridgeWriter
. This
method reuses the existing BridgeWriter
's proxy.bw
- The existing BridgeWriter
public void init(Properties p)
Properties
object that at a minimum contains the 'endpoints'
parameter before the loader can be used. If a LicenseException is thrown
during initialization the BridgeLoader will trhow IllegalStateExceptions
until properly initialized.init
in interface Declarable
p
- configuration data such as 'endpoint' definitionsIllegalStateException
- if the loader is already initializedpublic void init(BridgeLoader bridgeLoader)
BridgeLoader
.
This method reuses the existing BridgeLoader
's connections
to the server.bridgeLoader
- The existing BridgeLoader
IllegalStateException
- if the loader is already initializedpublic void init(BridgeWriter bridgeWriter)
BridgeWriter
. This
method reuses the existing BridgeWriter
's proxy.bridgeWriter
- The existing BridgeWriter
IllegalStateException
- if the loader is already initializedpublic static void loadEmergencyClasses()
SystemFailure.loadEmergencyClasses()
public void close()
BridgeLoader
is
destroyed, when the Cache
is closed, or when a callback is removed
from a region using an AttributesMutator
Closes connections to BridgeServer
s when all Region
s are
finished using this BridgeLoader,close
in interface CacheCallback
detach(Region)
,
attach(Region)
public boolean isClosed()
BridgeLoader
has been closed.public void release()
public void terminate()
public Object load(LoaderHelper helper) throws CacheLoaderException
load
in interface CacheLoader
helper
- a LoaderHelper object that is passed in from cache service
and provides access to the key, region, argument, and netSearch
.null
causes
Region.get(Object, Object)
to return null
.CacheLoaderException
Region.get
@Deprecated public SelectResults query(String queryStr) throws CacheLoaderException
Region.query(java.lang.String)
insteadCacheLoaderException
public int getRetryInterval()
public int getReadTimeout()
public int getRetryAttempts()
public String getLBPolicy()
public Properties getProperties()
BridgeWriter
.BridgeWriter
public Object getConnectionProxy()
ConnectionProxy
associated with this
BridgeLoader
.
For internal use only.ConnectionProxy
associated with this
BridgeLoader
public void addEndpoint(String name, String host, int port) throws EndpointExistsException
Endpoint
to the known Endpoint
s.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 Endpoint
s.
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 Connection
spublic String toString()
BridgeLoader
public void detach(Region r)
destruction
and
closure
. This method effects the behavor of
close()
.r
- the Region which will no longer use this BridgeLoaderclose()
,
attach(Region)
public void attach(Region r)
load(LoaderHelper)
.
This method affects the behavior of close()
.
This is called internally when the BridgeLoader is added to a Region via
AttributesFactory.setCacheLoader(CacheLoader)
r
- the Region which will begin use this BridgeWriter.detach(Region)
,
close()
Copyright © 1997-2017 Pivotal Software, Inc. All rights reserved.