|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.genesyslab.platform.standby.WarmStandby
public class WarmStandby
WarmStandby is used for opening/restoring a channel connection to any endpoint from the pool.
Constructor Summary | |
---|---|
WarmStandby(ClientChannel channel,
Endpoint... endpoints)
Creates the new warm stanby instance and defines endpoint pool. |
|
WarmStandby(ClientChannel channel,
java.util.List<Endpoint> endpoints)
Creates the new warm stanby instance and defines endpoints pool. |
|
WarmStandby(java.lang.String name,
ClientChannel channel,
Endpoint... endpoints)
Creates the new warm stanby instance and defines endpoint pool. |
|
WarmStandby(java.lang.String name,
ClientChannel channel,
java.util.List<Endpoint> endpoints)
Creates the new warm stanby instance and defines endpoints pool. |
Method Summary | ||
---|---|---|
void |
autoRestore()
Enables auto restore and opens asynchronously the channel if it's closed. |
|
void |
autoRestore(boolean open)
Enables auto restore and opens asynchronously the channel if it's needed. |
|
void |
close()
Synchronously closes the channel and stops all WarmStandby's activity. |
|
java.util.concurrent.Future<java.lang.Void> |
closeAsync()
Asynchronously closes the channel and stops all WarmStandby's activity. |
|
|
closeAsync(CompletionHandler<java.lang.Void,A> handler,
A attachment)
Asynchronously closes the channel and stops all WarmStandby's activity. |
|
ClientChannel |
getChannel()
Gets attached channel. |
|
WSConfig |
getConfig()
Gets warmstandby's configuration. |
|
java.lang.String |
getName()
Gets warmStandby name. |
|
boolean |
isOpened()
Checks if the channel state is opened. |
|
void |
open()
Opens synchronously the channel to any available server specified in the configuration. |
|
java.util.concurrent.Future<ChannelOpenedEvent> |
openAsync()
Opens asynchronously the channel to any available server specified in the configuration. |
|
|
openAsync(CompletionHandler<ChannelOpenedEvent,A> handler,
A attachment)
Opens asynchronously the channel to any available server specified in the configuration. |
|
void |
setConfig(WSConfig config)
Applies a new configuration. |
|
void |
setHandler(IWSHandler handler)
Sets a handler. |
|
void |
setHandler(WSHandler handler)
Sets a handler. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WarmStandby(ClientChannel channel, Endpoint... endpoints)
Note: if endpoints with same app,host and port will be passed multiple times then only first one will be used while opening.
The iteration through endpoints always starts from the begin of the
endpoint pool.
Endpoint from which channel has been disconnected and endpoints which
have been already checked unsuccessfully after disconnection, are skipped
from the iteration.
If some other order of iteration is desired than in the appropriate event
handler (onChannelDisconnected, onEndpointCheckUnsuccessfully, ..) the
endpoints order in the pool can be changed appropriately.
channel
- that must be attached to the new WarmStandby instance.endpoints
- array of endpoints.
java.lang.IllegalArgumentException
- if argument channel is null.
java.lang.IllegalArgumentException
- if null endpoint occurs.
DisabledMethodException
- if the channel has already been attached to another warm
standby.public WarmStandby(ClientChannel channel, java.util.List<Endpoint> endpoints)
Note: if endpoints with same app,host and port will be passed multiple times then only first one will be used while opening.
The iteration through endpoints always starts from the begin of the
endpoint pool.
Endpoint from which channel has been disconnected and endpoints which
have been already checked unsuccessfully after disconnection, are skipped
from the iteration.
If some other order of iteration is desired than in the appropriate event
handler (onChannelDisconnected, onEndpointCheckUnsuccessfully, ..) the
endpoints order in the pool can be changed appropriately.
channel
- that must be attached to the new WarmStandby instance.endpoints
- list of endpoints.
java.lang.IllegalArgumentException
- if argument channel is null.
java.lang.IllegalArgumentException
- if null endpoint occurs.
DisabledMethodException
- if the channel has already been attached to another warm
standby.public WarmStandby(java.lang.String name, ClientChannel channel, Endpoint... endpoints)
Note: if endpoints with same app,host and port will be passed multiple times then only first one will be used while opening.
The iteration through endpoints always starts from the begin of the
endpoint pool.
Endpoint from which channel has been disconnected and endpoints which
have been already checked unsuccessfully after disconnection, are skipped
from the iteration.
If some other order of iteration is desired than in the appropriate event
handler (onChannelDisconnected, onEndpointCheckUnsuccessfully, ..) the
endpoints order in the pool can be changed appropriately.
name
- of the warmStandby instance.channel
- that must be attached to the new WarmStandby instance.endpoints
- array of endpoints.
java.lang.IllegalArgumentException
- if argument channel is null.
java.lang.IllegalArgumentException
- if null endpoint occurs.
DisabledMethodException
- if the channel has already been attached to another warm
standby.public WarmStandby(java.lang.String name, ClientChannel channel, java.util.List<Endpoint> endpoints)
Note: if endpoints with same app,host and port will be passed multiple times then only first one will be used while opening.
The iteration through endpoints always starts from the begin of the
endpoint pool.
Endpoint from which channel has been disconnected and endpoints which
have been already checked unsuccessfully after disconnection, are skipped
from the iteration.
If some other order of iteration is desired than in the appropriate event
handler (onChannelDisconnected, onEndpointCheckUnsuccessfully, ..) the
endpoints order in the pool can be changed appropriately.
name
- of the warmStandby instance.channel
- that must be attached to the new WarmStandby instance.endpoints
- list of endpoints.
java.lang.IllegalArgumentException
- if argument channel is null.
java.lang.IllegalArgumentException
- if null endpoint occurs.
DisabledMethodException
- if the channel has already been attached to another warm
standby.Method Detail |
---|
public java.lang.String getName()
public ClientChannel getChannel()
public WSConfig getConfig()
public void setConfig(WSConfig config)
java.lang.IllegalArgumentException
- if the argument value is null.public boolean isOpened()
public void open() throws java.lang.InterruptedException, WSException
This method blocks until the channel is opened, also in the case that channel opening is already in progress.
Do not use directly channel's open/close operations. Use the warmstandby's ones.
java.lang.InterruptedException
- it can be thrown if the caller thread has been interrupted.
It interrupts the waiting for the completion.
WSException
- throws as descendant WSCanceledException,
WSNoAvailableServersException or WSEmptyEndpointPoolException.
WSNoAvailableServersException
- when all endpoints have been checked unsuccessfully.
WSEmptyEndpointPoolException
- (descendant of WSNoAvailableServersException)
when no any endpoint in the pool.
WSCanceledException
- if open operation has been canceled.
java.lang.RuntimeException
- when it's called inside warmStandBy handler or completion handler.
It prevents from infinite lock.public java.util.concurrent.Future<ChannelOpenedEvent> openAsync()
The future of this method blocks until the channel is opened, also in the case that channel opening is already in progress.
It may be used to continue the connection restoring to the same endpoint
inside the event OnEndpointCheckedUnsuccessfully handler when event cause
is RegistrationException. To restart the warm standby use
close()
before.
Do not use directly channel's open/close operations. Use the warmstandby's ones.
public <A> void openAsync(CompletionHandler<ChannelOpenedEvent,A> handler, A attachment)
The completion handler is notified about success when the channel is opened, also in the case that channel opening is already in progress.
It may be used to continue the connection restoring to the same endpoint
inside the event OnEndpointCheckedUnsuccessfully handler when event cause
is RegistrationException.
To restart warmStandby use {use openAsync()
.
Do not use directly channel's open/close operations. Use the warmstandby's ones.
handler
- is completion handler.attachment
- that passed to completion handler.public void close() throws java.lang.InterruptedException
It disables auto restore, cancels channel opening and closes the channel synchronously.
Do not use directly channel's open/close operations. Use the warmstandby's ones.
java.lang.InterruptedException
public java.util.concurrent.Future<java.lang.Void> closeAsync()
It disables auto restore, cancels channel opening and closes the channel asynchronously.
Do not use directly channel's open/close operations. Use the warmstandby's ones.
public <A> void closeAsync(CompletionHandler<java.lang.Void,A> handler, A attachment)
It disables auto restore, cancels channel opening and closes the channel asynchronously.
Do not use directly channel's open/close operations. Use the warmstandby's ones.
handler
- is completion handler.attachment
- that must be passed to the completion handler.public void autoRestore()
public void autoRestore(boolean open)
open
- flag specify if asynchronous channel opening must be initiated
if the channel is closed.public void setHandler(WSHandler handler)
handler
- that will handle the WarmStandby's events.
java.lang.IllegalArgumentException
- if the argument is null.public void setHandler(IWSHandler handler)
handler
- that will handle the WarmStandby's events.
java.lang.IllegalArgumentException
- if the argument is null.
|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |