M - the data type of the remotepublic interface Remote<M> extends Shutdownable, Activatable, Lockable, PingProvider, DataProvider<M>
| Modifier and Type | Interface and Description |
|---|---|
static class |
Remote.ConnectionState |
Shutdownable.ShutdownDeamon| Modifier and Type | Method and Description |
|---|---|
void |
activate(boolean waitForData)
Method activates the remote instance and blocks until the first data synchronization is done.
|
void |
activate(Object maintainer)
Atomic activate which makes sure that the maintainer stays the same.
|
void |
addConnectionStateObserver(Observer<Remote.ConnectionState> observer)
This method allows the registration of connection state observers to get informed about connection state changes.
|
Remote.ConnectionState |
getConnectionState()
Method returns the current connection state between this remote and its main controller.
|
M |
getData()
Method returns the data object of this remote which is synchronized with
the server data in background.
|
Class<M> |
getDataClass()
Method returns the class of the data object.
|
default CompletableFuture<M> |
getDataFuture()
Returns a future of the data object.
|
Long |
getPing()
Method returns the result of the latest connection ping between this
remote and its main controller.
|
boolean |
isConnected()
Checks if a server connection is established.
|
Future<Long> |
ping()
Method triggers a ping between this remote and its main controller and
returns the calculated connection delay.
|
void |
removeConnectionStateObserver(Observer<Remote.ConnectionState> observer)
This method removes already registered connection state observers.
|
CompletableFuture<M> |
requestData()
This method synchronizes this remote instance with the main controller
and returns the new data object.
|
void |
waitForConnectionState(Remote.ConnectionState connectionState,
long timeout)
Method blocks until the remote reaches the desired connection state.
|
void |
waitForData()
Method blocks until an initial data message was received from the remote controller.
|
void |
waitForData(long timeout,
TimeUnit timeUnit)
Method blocks until an initial data message was received from the main controller or the given timeout is reached.
|
registerShutdownHook, registerShutdownHook, shutdownactivate, deactivate, isActiveisLocked, lock, unlock, verifyMaintainabilityaddDataObserver, isDataAvailable, removeDataObservervoid activate(boolean waitForData)
throws CouldNotPerformException,
InterruptedException
waitForData - if this flag is true the method will block until the first data synchronization is done.CouldNotPerformException - if the activation could not be performedInterruptedException - if the activation is interruptedvoid activate(Object maintainer) throws InterruptedException, CouldNotPerformException
maintainer - the current maintainer of this remoteInterruptedException - if activation is interruptedCouldNotPerformException - if activation failsvoid addConnectionStateObserver(Observer<Remote.ConnectionState> observer)
observer - the observer addedvoid removeConnectionStateObserver(Observer<Remote.ConnectionState> observer)
observer - the observer removedClass<M> getDataClass()
getDataClass in interface DataProvider<M>M getData() throws NotAvailableException
getData in interface DataProvider<M>NotAvailableException - is thrown in case the data is not yet synchronized with the main controller instance.default CompletableFuture<M> getDataFuture()
getDataFuture in interface DataProvider<M>void waitForData()
throws CouldNotPerformException,
InterruptedException
waitForData in interface DataProvider<M>CouldNotPerformException - is thrown if any error occurs.InterruptedException - is thrown in case the thread is externally interrupted.void waitForData(long timeout,
TimeUnit timeUnit)
throws CouldNotPerformException,
InterruptedException
waitForData in interface DataProvider<M>timeout - maximal time to wait for the main controller data. After the timeout is reached a NotAvailableException is thrown which is caused by a TimeoutException.timeUnit - the time unit of the timeout.CouldNotPerformException - is thrown in case the any error occurs, or if the given timeout is reached. In this case a TimeoutException is thrown.InterruptedException - is thrown in case the thread is externally interrupted.boolean isConnected()
Remote.ConnectionState getConnectionState()
void waitForConnectionState(Remote.ConnectionState connectionState, long timeout) throws InterruptedException, TimeoutException, CouldNotPerformException
connectionState - the desired connection statetimeout - the timeout in milliseconds until the method throw a
TimeoutException in case the connection state was not reached.InterruptedException - is thrown in case the thread is externally
interrupted.TimeoutException - is thrown in case the
timeout is expired without reaching the connection state.CouldNotPerformException - is thrown in case the connection state does not match and the shutdown of this remote
has been initializedCompletableFuture<M> requestData() throws CouldNotPerformException
CouldNotPerformException - In case the sync could not be triggered
an CouldNotPerformException will be thrown.Future<Long> ping()
ping in interface PingProviderLong getPing()
getPing in interface PingProviderCopyright © 2015–2018 openbase.org. All rights reserved.