Package org.apache.openjpa.event
Class TCPRemoteCommitProvider
- java.lang.Object
-
- org.apache.openjpa.event.AbstractRemoteCommitProvider
-
- org.apache.openjpa.event.TCPRemoteCommitProvider
-
- All Implemented Interfaces:
RemoteCommitProvider,Configurable,Closeable
- Direct Known Subclasses:
DynamicTCPRemoteCommitProvider
public class TCPRemoteCommitProvider extends AbstractRemoteCommitProvider implements Configurable
TCP-based implementation ofRemoteCommitProviderthat listens for object modifications and propagates those changes to other RemoteCommitProviders over TCP sockets.- Since:
- 0.2.5.0
- Author:
- Brian Leair, Patrick Linskey
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classTCPRemoteCommitProvider.HostAddressUtility class to store an InetAddress and an int.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<TCPRemoteCommitProvider.HostAddress>_addressesprotected java.util.concurrent.locks.ReentrantLock_addressesLockprotected int_portprotected static Localizers_loc-
Fields inherited from class org.apache.openjpa.event.AbstractRemoteCommitProvider
eventManager, log
-
-
Constructor Summary
Constructors Constructor Description TCPRemoteCommitProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidbroadcast(RemoteCommitEvent event)Notifies other remote event managers in this JVM and on other machines of changes to the cache.voidclose()Free the resources used by this provider.voidendConfiguration()Subclasses that need to perform actions inConfigurable.endConfiguration()must invoke this method.intgetMaxIdle()intgetMaxTotal()intgetNumBroadcastThreads()intgetPort()intgetRecoveryTimeMillis()voidsetAddresses(java.lang.String names)Sets the list of addresses of peers to which this provider will send events to.voidsetMaxActive(int maxActive)Deprecated.voidsetMaxIdle(int maxIdle)Set the number of idle sockets that this provider can keep open to each peer in the cluster.voidsetMaxTotal(int maxTotal)Set the maximum total number of sockets that this provider can simultaneously open to each peer in the cluster.voidsetNumBroadcastThreads(int numBroadcastThreads)Set the number of worker threads that are used for transmitting packets to peers in the cluster.voidsetPort(int port)Set the port that this provider should listen on.voidsetRecoveryTimeMillis(int recoverytime)Set the number of milliseconds to wait before retrying to reconnect to a peer after it becomes unreachable.-
Methods inherited from class org.apache.openjpa.event.AbstractRemoteCommitProvider
fireEvent, setConfiguration, setRemoteCommitEventManager, startConfiguration
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.openjpa.lib.conf.Configurable
setConfiguration, startConfiguration
-
-
-
-
Field Detail
-
s_loc
protected static final Localizer s_loc
-
_port
protected int _port
-
_addresses
protected java.util.List<TCPRemoteCommitProvider.HostAddress> _addresses
-
_addressesLock
protected final java.util.concurrent.locks.ReentrantLock _addressesLock
-
-
Method Detail
-
getPort
public int getPort()
- Returns:
- the port that this provider should listen on.
-
setPort
public void setPort(int port)
Set the port that this provider should listen on. Set once only.- Parameters:
port- the port that this provider should listen on
-
setRecoveryTimeMillis
public void setRecoveryTimeMillis(int recoverytime)
Set the number of milliseconds to wait before retrying to reconnect to a peer after it becomes unreachable.- Parameters:
recoverytime- the number of milliseconds to wait before retrying to reconnect to a peer after it becomes unreachable
-
getRecoveryTimeMillis
public int getRecoveryTimeMillis()
- Returns:
- the number of milliseconds to wait before retrying to reconnect to a peer after it becomes unreachable.
-
setMaxActive
@Deprecated public void setMaxActive(int maxActive)
Deprecated.Set the maximum number of sockets that this provider can simultaneously open to each peer in the cluster.- Parameters:
maxActive- the maximum total number of sockets that this provider can simultaneously open to each peer in the cluster. * @deprecated please usesetMaxTotal(int)instead
-
setMaxTotal
public void setMaxTotal(int maxTotal)
Set the maximum total number of sockets that this provider can simultaneously open to each peer in the cluster.- Parameters:
maxTotal- the maximum total number of sockets that this provider can simultaneously open to each peer in the cluster.
-
getMaxTotal
public int getMaxTotal()
- Returns:
- the maximum number of sockets that this provider can simultaneously open to each peer in the cluster.
-
setMaxIdle
public void setMaxIdle(int maxIdle)
Set the number of idle sockets that this provider can keep open to each peer in the cluster.- Parameters:
maxIdle- the number of idle sockets that this provider can keep open to each peer in the cluster
-
getMaxIdle
public int getMaxIdle()
- Returns:
- the number of idle sockets that this provider can keep open to each peer in the cluster.
-
setNumBroadcastThreads
public void setNumBroadcastThreads(int numBroadcastThreads)
Set the number of worker threads that are used for transmitting packets to peers in the cluster.- Parameters:
numBroadcastThreads- the number of worker threads that are used for transmitting packets to peers in the cluster
-
getNumBroadcastThreads
public int getNumBroadcastThreads()
- Returns:
- the number of worker threads that are used for transmitting packets to peers in the cluster.
-
setAddresses
public void setAddresses(java.lang.String names) throws java.net.UnknownHostExceptionSets the list of addresses of peers to which this provider will send events to. The peers are semicolon-separatednameslist in the form of "myhost1:portA;myhost2:portB".- Parameters:
names- the list of addresses of peers to which this provider will send events to- Throws:
java.net.UnknownHostException- in case peer name cannot be resolved
-
endConfiguration
public void endConfiguration()
Subclasses that need to perform actions inConfigurable.endConfiguration()must invoke this method.- Specified by:
endConfigurationin interfaceConfigurable- Overrides:
endConfigurationin classAbstractRemoteCommitProvider
-
broadcast
public void broadcast(RemoteCommitEvent event)
Description copied from interface:RemoteCommitProviderNotifies other remote event managers in this JVM and on other machines of changes to the cache. This method must not notify the event manager associated with the broker that originated this commit.- Specified by:
broadcastin interfaceRemoteCommitProvider
-
close
public void close()
Description copied from interface:RemoteCommitProviderFree the resources used by this provider.- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceRemoteCommitProvider
-
-