|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.crankuptheamps.client.Client
com.crankuptheamps.client.HAClient
public class HAClient
A highly-available AMPS Client object that automatically reconnects and re-subscribes to AMPS instances upon disconnect.
Nested Class Summary | |
---|---|
static class |
HAClient.HADisconnectHandler
|
Nested classes/interfaces inherited from class com.crankuptheamps.client.Client |
---|
Client.Bookmarks, Client.Version |
Field Summary |
---|
Fields inherited from class com.crankuptheamps.client.Client |
---|
exceptionListener, MIN_MULTI_BOOKMARK_VERSION, MIN_PERSISTED_BOOKMARK_VERSION |
Constructor Summary | |
---|---|
HAClient(String name)
Constructs a new HAClient. |
Method Summary | |
---|---|
void |
connect(String uri)
Connects to the AMPS instance through the provided URI. |
void |
connectAndLogon()
Connects to the next server chosen for us by our ServerChooser . |
static HAClient |
createFileBacked(String name,
String publishLog,
int initialPublishCapacity,
String subscribeLog)
Creates a new highly available client backed by disk. |
static HAClient |
createFileBacked(String name,
String publishLog,
String subscribeLog)
Creates a new highly available client backed by disk. |
static HAClient |
createMemoryBacked(String name)
Creates a new memory-backed highly-available client. |
void |
disconnect()
Disconnect from the AMPS server. |
ConnectionInfo |
getConnectionInfo()
Assembles a new ConnectionInfo with the state of this client and associated classes. |
int |
getReconnectDelay()
Returns the time delay between reconnect events. |
ServerChooser |
getServerChooser()
Returns the current ServerChooser . |
int |
getTimeout()
Returns the timeout used for logging on and resubscribing, once a connection is re-established. |
void |
setHeartbeat(int intervalSeconds_,
int timeoutSeconds_)
Requests a server heartbeat, and configures the client to close the connection if a heartbeat (or other activity) is not seen on the connection. |
void |
setReconnectDelay(int reconnectInterval)
Sets the time delay between reconnect events. |
void |
setServerChooser(ServerChooser serverChooser_)
Sets a ServerChooser for self. |
void |
setTimeout(int timeout_)
Sets the timeout used for logging on and resubscribing, once a connection is re-established. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HAClient(String name)
name
- The client name, passed to the server to uniquely identify
this client across sessions.Method Detail |
---|
public int getReconnectDelay()
public void setReconnectDelay(int reconnectInterval)
reconnectInterval
- The time waited between reconnect events, in milliseconds.public void setTimeout(int timeout_)
timeout_
- The timeout value, in milliseconds.public int getTimeout()
public void setHeartbeat(int intervalSeconds_, int timeoutSeconds_) throws DisconnectedException
Client
setHeartbeat
in class Client
intervalSeconds_
- The time (seconds) between beats from the server.timeoutSeconds_
- The time (seconds) to allow silence on the connection before assuming it is dead.
DisconnectedException
- The client became disconnected while attempting to send the heartbeat request.public ServerChooser getServerChooser()
ServerChooser
.
public void setServerChooser(ServerChooser serverChooser_)
ServerChooser
for self.
serverChooser_
- The ServerChooser that will be used by self to reconnect.public static HAClient createMemoryBacked(String name) throws StoreException
name
- The client name, passed to the server to uniquely identify
this client across sessions.
StoreException
public static HAClient createFileBacked(String name, String publishLog, int initialPublishCapacity, String subscribeLog) throws IOException, StoreException
name
- The client name, passed to the server to uniquely identify
this client across sessions.publishLog
- The path to a file used to store outgoing messages. This file
will be created if it does not exist.initialPublishCapacity
- The initial size (in 2k blocks) of the publish store. Choosing
an optimal value of initialPublishCapacity can prevent costly
resizes, when servers or networks slow down.subscribeLog
- The path to a file used to log incoming message bookmarks.
This file will be created if it does not exist.
IOException
StoreException
public static HAClient createFileBacked(String name, String publishLog, String subscribeLog) throws IOException, StoreException
name
- The client name, passed to the server to uniquely identify
this client across sessions.publishLog
- The path to a file used to store outgoing messages. This file
will be created if it does not exist.subscribeLog
- The path to a file used to log incoming message bookmarks.
This file will be created if it does not exist.
IOException
StoreException
public void connectAndLogon() throws ConnectionException
ServerChooser
.
Will continue attempting to connect and logon to each successive
server returned by the ServerChooser until the connection suceeds
or the ServerChooser returns an empty URI.
ConnectionException
- An exception indicating no AMPS instance could be connected
to.public void connect(String uri) throws ConnectionException
Client
String
with the format:
transport://host:port/protocol
Notice that the protocol can be independent of the message type. 60East
recommends using the amps
protocol, although some
installations use one of the legacy protocols such as fix
,
nvfix
or xml
. Contact your server
administrator for the correct URI for the instance.
connect
in class Client
uri
- The URI string to connect to
ConnectionRefusedException
- The connection could not be established
AlreadyConnectedException
- The connection is already connected
InvalidURIException
- The specified URI is invalid
ProtocolException
- The protocol is invalid
TransportTypeException
- The transport type is invalid
ConnectionException
public void disconnect()
Client
disconnect
in class Client
public ConnectionInfo getConnectionInfo()
getConnectionInfo
in class Client
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |