Package org.syncany.operations.watch
Class WatchOperation
- java.lang.Object
-
- org.syncany.operations.Operation
-
- org.syncany.operations.watch.WatchOperation
-
- All Implemented Interfaces:
NotificationListener.NotificationListenerListener
,RecursiveWatcher.WatchListener
public class WatchOperation extends Operation implements NotificationListener.NotificationListenerListener, RecursiveWatcher.WatchListener
The watch operation implements the constant synchronization known from other sync tools.In order to sync instantly, it offers the following strategies:
- It monitors the local file system using the
DefaultRecursiveWatcher
. Whenever a file or folder changes, the sync is started (after a short settlement wait period). - It subscribes to a repo-specific channel on the Syncany pub/sub server,
using the
NotificationListener
, and publishes updates to this channel. - It periodically runs the sync, i.e. the
DownOperation
and subsequently theUpOperation
. If the other two mechanisms are disabled or fail to register changes, this method will make sure that changes are synced eventually.
-
-
Constructor Summary
Constructors Constructor Description WatchOperation(Config config, WatchOperationOptions options)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WatchOperationResult
execute()
Executes the operation synchronously and returns a result when the operation exits.boolean
isSyncRequested()
boolean
isSyncRunning()
void
pause()
void
pushNotificationReceived(java.lang.String channel, java.lang.String message)
void
resume()
void
stop()
void
watchEventsOccurred()
-
-
-
Constructor Detail
-
WatchOperation
public WatchOperation(Config config, WatchOperationOptions options)
-
-
Method Detail
-
execute
public WatchOperationResult execute()
Description copied from class:Operation
Executes the operation synchronously and returns a result when the operation exits. Using covariance is recommend, that is OperationFoo should override execute so as to return a OperationFooResult rather than OperationResult.
-
pushNotificationReceived
public void pushNotificationReceived(java.lang.String channel, java.lang.String message)
- Specified by:
pushNotificationReceived
in interfaceNotificationListener.NotificationListenerListener
-
watchEventsOccurred
public void watchEventsOccurred()
- Specified by:
watchEventsOccurred
in interfaceRecursiveWatcher.WatchListener
-
pause
public void pause()
-
resume
public void resume()
-
stop
public void stop()
-
isSyncRunning
public boolean isSyncRunning()
-
isSyncRequested
public boolean isSyncRequested()
-
-