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
TCP-based implementation of
RemoteCommitProvider that
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 ClassesModifier and TypeClassDescriptionprotected classUtility class to store an InetAddress and an int. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<TCPRemoteCommitProvider.HostAddress> protected final ReentrantLockprotected intprotected static final LocalizerFields inherited from class AbstractRemoteCommitProvider
eventManager, log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanacceptsConnectionFrom(InetAddress address) Whether this provider accepts an incoming connection from the given address.protected voidUpdates the addresses from which incoming connections are accepted.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.voidSubclasses that need to perform actions inConfigurable.endConfiguration()must invoke this method.intintintintintgetPort()intbooleanprotected voidrefreshAddresses(long acceptedNanos) Refreshes the addresses of the peers before a connection from an unknown host is rejected.protected booleanWhether this provider can refresh its addresses when a connection from an unknown host arrives, seerefreshAddresses(long).voidsetAddresses(String names) Sets the list of addresses of peers to which this provider will send events to.voidsetBindAddress(String address) Set address this provider should listen on.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.voidsetMaxReceiveConnections(int maxReceiveConnections) Set the maximum number of incoming connections that are received from peers simultaneously.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.voidsetRestrictToPeers(boolean restrictToPeers) Set whether incoming connections are only accepted from the configured peers (seesetAddresses(String)) and from this host.Methods inherited from class AbstractRemoteCommitProvider
fireEvent, setConfiguration, setRemoteCommitEventManager, startConfiguration
-
Field Details
-
s_loc
-
_port
protected int _port -
_addresses
-
_addressesLock
-
-
Constructor Details
-
TCPRemoteCommitProvider
- Throws:
UnknownHostException
-
-
Method Details
-
setBindAddress
Set address this provider should listen on. Set once only.- Parameters:
address- address this provider should listen on- Throws:
UnknownHostException
-
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.
-
setRestrictToPeers
public void setRestrictToPeers(boolean restrictToPeers) Set whether incoming connections are only accepted from the configured peers (seesetAddresses(String)) and from this host. Defaults totrue.- Parameters:
restrictToPeers- whether incoming connections are only accepted from the configured peers and this host
-
isRestrictToPeers
public boolean isRestrictToPeers()- Returns:
- whether incoming connections are only accepted from the configured peers and from this host.
-
setMaxReceiveConnections
public void setMaxReceiveConnections(int maxReceiveConnections) Set the maximum number of incoming connections that are received from peers simultaneously. Further connections are closed until a receiving connection ends. A value of 0 or less means no limit. Defaults to 100.- Parameters:
maxReceiveConnections- the maximum number of incoming connections that are received simultaneously
-
getMaxReceiveConnections
public int getMaxReceiveConnections()- Returns:
- the maximum number of incoming connections that are received from peers simultaneously.
-
setMaxActive
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
Sets 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:
UnknownHostException- in case peer name cannot be resolved
-
addressesChanged
protected void addressesChanged()Updates the addresses from which incoming connections are accepted. Must be invoked, while holding_addressesLock, whenever_addresseshas been changed. -
acceptsConnectionFrom
Whether this provider accepts an incoming connection from the given address. Connections from this host are always accepted; connections from other hosts only if they are one of the configured peers, unlessRestrictToPeersis turned off. The port of the peers is not considered, as the peers connect from arbitrary local ports.- Parameters:
address- the address of the remote end of the incoming connection- Returns:
trueif the connection is accepted
-
refreshesAddressesOnDemand
protected boolean refreshesAddressesOnDemand()Whether this provider can refresh its addresses when a connection from an unknown host arrives, seerefreshAddresses(long). Defaults tofalse.- Returns:
trueifrefreshAddresses(long)may find further peers
-
refreshAddresses
protected void refreshAddresses(long acceptedNanos) Refreshes the addresses of the peers before a connection from an unknown host is rejected. It is invoked on the thread receiving that connection, not on the thread accepting connections, and only ifrefreshesAddressesOnDemand()returnstrue.- Parameters:
acceptedNanos- theSystem.nanoTime()at which the connection was accepted; a refresh started later already covers this connection
-
endConfiguration
public void endConfiguration()Subclasses that need to perform actions inConfigurable.endConfiguration()must invoke this method.- Specified by:
endConfigurationin interfaceConfigurable- Overrides:
endConfigurationin classAbstractRemoteCommitProvider
-
broadcast
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. -
close
public void close()Description copied from interface:RemoteCommitProviderFree the resources used by this provider.
-