Class SynchEngineImpl
- java.lang.Object
-
- org.bedework.synch.SynchEngineImpl
-
- All Implemented Interfaces:
SynchEngine,org.bedework.util.calendar.XcalUtil.TzGetter,org.bedework.util.logging.Logged
public class SynchEngineImpl extends Object implements org.bedework.util.logging.Logged, SynchEngine, org.bedework.util.calendar.XcalUtil.TzGetter
Synch processor.The synch processor manages subscriptions made by a subscriber to a target. Such a subscription might be one way or two way.
There are two ends to a subscription handled by connectors. The connectors implement a standard interface which provides sufficient information for the synch process.
Synchronization is triggered either when a change takes place - through some sort of push-notification or periodically.
For example, we might have a one way subscription from bedework to exchange. Exchange will post notifications to the synch engine which will then resynch the modified entity.
Alternatively we might have a subscription to a file which we refresh each day at 4am.
A subscription may be in the following states:
- dormant - that is there is no current activity, for example a file subscription with a periodic update,
- active - there is some active connection associated with it, for example, an Exchange push subscription waiting for a notification
- processing - for example, an Exchange push subscription which is processing a notification
- unsubscribing - the user has asked to unsubscribe but there is some activity we are waiting for
Interactions with the calendars is carried out through an interface which assumes the CalWs-SOAP protocol. Messages and responses are of that form though the actual implementation may not use the protocol if the target does not support it. For example we convert CalWs-SOAP interactions into ExchangeWS. --------------------- ignore below ----------------------------------------
This process manages the setting up of push-subscriptions with the exchange service and provides support for the resulting call-back from Exchange. There will be one instance of this object to handle the tables we create and manipulate.
There will be multiple threads calling the various methods. Push subscriptions work more or less as follows:
- Subscribe to exchange giving a url to call back to. Set a refresh period
- Exchange calls back even if there is no change - effectively polling us
- If we don't respond Exchange doubles the wait period and tries again
- Repeats that a few times then gives up
- If we do respond will call again at the specified rate
- No unsubscribe - wait for a ping then respond with unsubscribe
At startup we ask for the back end system to tell us what the subscription are and we spend some time setting those up.
We also provide a way for the system to tell us about new (un)subscribe requests. While starting up we need to queue these as they may be unsubscribes for a subscribe in the startup list.
Shutdown ought to wait for the remote systems to ping us for every outstanding subscription. That ought to be fairly quick.
- Author:
- Mike Douglass
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSubscription(Subscription sub)Stringdecrypt(String val)voiddeleteSubscription(Subscription sub)Subscriptionfind(Subscription sub)static SynchConfiggetConfig()ConnectorgetConnector(String id)Set<String>getConnectorIds()ConnectorInstancegetConnectorInstance(Subscription sub, org.bedework.synch.wsmessages.SynchEndType end)org.bedework.util.security.PwEncryptionIntfgetEncrypter()org.bedework.util.logging.BwLoggergetLogger()booleangetRunning()List<Stat>getStats()SubscriptiongetSubscription(String id)static SynchEnginegetSyncher()org.bedework.util.timezones.TimezonesgetTimezones()net.fortuna.ical4j.model.TimeZonegetTz(String id)Get a timezone object given the id.org.bedework.util.calendar.XcalUtil.TzGettergetTzGetter()voidhandleNotification(Notification<?> note)voidhandleNotifications(Connector.NotificationBatch<Notification> notes)voidreschedule(Subscription sub, boolean newSub)voidrescheduleNow(String id)static voidsetConfigHolder(org.bedework.util.jmx.ConfigHolder<SynchConfig> val)voidsetConnectors(Subscription sub)voidstart()voidstop()booleansubscriptionsOnly()voidupdateConfig()voidupdateSubscription(Subscription sub)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bedework.util.logging.Logged
audit, debug, debug, enableAuditLogger, enableErrorLogger, enableMetricsLogger, error, error, error, getLogLevel, info, isAuditLoggerEnabled, isErrorLoggerEnabled, isMetricsDebugEnabled, isMetricsLoggerEnabled, metrics, setLoggerClass, setLoggerClass, trace, trace, warn
-
-
-
-
Method Detail
-
getSyncher
public static SynchEngine getSyncher()
- Returns:
- the syncher
-
getTimezones
public org.bedework.util.timezones.Timezones getTimezones()
- Specified by:
getTimezonesin interfaceSynchEngine
-
subscriptionsOnly
public boolean subscriptionsOnly()
- Specified by:
subscriptionsOnlyin interfaceSynchEngine
-
handleNotification
public void handleNotification(Notification<?> note)
- Specified by:
handleNotificationin interfaceSynchEngine
-
setConnectors
public void setConnectors(Subscription sub) throws SynchException
- Specified by:
setConnectorsin interfaceSynchEngine- Throws:
SynchException
-
rescheduleNow
public void rescheduleNow(String id) throws SynchException
- Specified by:
rescheduleNowin interfaceSynchEngine- Throws:
SynchException
-
reschedule
public void reschedule(Subscription sub, boolean newSub)
- Specified by:
reschedulein interfaceSynchEngine
-
getConnectorInstance
public ConnectorInstance getConnectorInstance(Subscription sub, org.bedework.synch.wsmessages.SynchEndType end) throws SynchException
- Specified by:
getConnectorInstancein interfaceSynchEngine- Throws:
SynchException
-
addSubscription
public void addSubscription(Subscription sub) throws SynchException
- Specified by:
addSubscriptionin interfaceSynchEngine- Throws:
SynchException
-
deleteSubscription
public void deleteSubscription(Subscription sub) throws SynchException
- Specified by:
deleteSubscriptionin interfaceSynchEngine- Throws:
SynchException
-
updateSubscription
public void updateSubscription(Subscription sub) throws SynchException
- Specified by:
updateSubscriptionin interfaceSynchEngine- Throws:
SynchException
-
getSubscription
public Subscription getSubscription(String id) throws SynchException
- Specified by:
getSubscriptionin interfaceSynchEngine- Throws:
SynchException
-
find
public Subscription find(Subscription sub) throws SynchException
- Specified by:
findin interfaceSynchEngine- Throws:
SynchException
-
getConnector
public Connector getConnector(String id)
- Specified by:
getConnectorin interfaceSynchEngine
-
getConnectorIds
public Set<String> getConnectorIds()
- Specified by:
getConnectorIdsin interfaceSynchEngine
-
handleNotifications
public void handleNotifications(Connector.NotificationBatch<Notification> notes) throws SynchException
- Specified by:
handleNotificationsin interfaceSynchEngine- Throws:
SynchException
-
getTzGetter
public org.bedework.util.calendar.XcalUtil.TzGetter getTzGetter()
- Specified by:
getTzGetterin interfaceSynchEngine
-
start
public void start() throws SynchException- Specified by:
startin interfaceSynchEngine- Throws:
SynchException
-
getStats
public List<Stat> getStats()
- Specified by:
getStatsin interfaceSynchEngine
-
stop
public void stop()
- Specified by:
stopin interfaceSynchEngine
-
getRunning
public boolean getRunning()
- Returns:
- true if we're running
-
setConfigHolder
public static void setConfigHolder(org.bedework.util.jmx.ConfigHolder<SynchConfig> val)
- Parameters:
val-
-
getConfig
public static SynchConfig getConfig()
- Returns:
- current state of the configuration
-
updateConfig
public void updateConfig()
-
getTz
public net.fortuna.ical4j.model.TimeZone getTz(String id) throws Throwable
Get a timezone object given the id. This will return transient objects registered in the timezone directory- Specified by:
getTzin interfaceorg.bedework.util.calendar.XcalUtil.TzGetter- Parameters:
id-- Returns:
- TimeZone with id or null
- Throws:
Throwable
-
decrypt
public String decrypt(String val) throws SynchException
- Specified by:
decryptin interfaceSynchEngine- Parameters:
val- possibly null password- Returns:
- decrypted string
- Throws:
SynchException- on decryption failure
-
getEncrypter
public org.bedework.util.security.PwEncryptionIntf getEncrypter() throws SynchException- Returns:
- en/decryptor
- Throws:
SynchException
-
getLogger
public org.bedework.util.logging.BwLogger getLogger()
- Specified by:
getLoggerin interfaceorg.bedework.util.logging.Logged
-
-