/** Shuts down the auto provision thread. Does nothing if it is not running. */ public static synchronized void shutdown() { synchronized (THREAD_CONTROL_LOCK) { if (autoProvThread != null) { ZimbraLog.autoprov.info("Shutting down auto provision thread"); autoProvThread.requestShutdown(); autoProvThread.interrupt(); autoProvThread = null; } else { ZimbraLog.autoprov.debug("shutdown() called, but auto provision thread is not running."); } } }
public static synchronized void switchAutoProvThreadIfNecessary() throws ServiceException { Server localServer = Provisioning.getInstance().getLocalServer(); long interval = localServer.getTimeInterval(Provisioning.A_zimbraAutoProvPollingInterval, 0); Set<String> scheduledDomains = localServer.getMultiAttrSet(Provisioning.A_zimbraAutoProvScheduledDomains); boolean needRunning = interval > 0 && !scheduledDomains.isEmpty(); if (needRunning && !AutoProvisionThread.isRunning()) { AutoProvisionThread.startup(); } else if (!needRunning && AutoProvisionThread.isRunning()) { AutoProvisionThread.shutdown(); } }
/** Starts up the auto provision thread. */ public static synchronized void startup() { synchronized (THREAD_CONTROL_LOCK) { if (isRunning()) { ZimbraLog.autoprov.warn( "Cannot start a second auto provision thread while another one is running."); return; } if (getSleepInterval() == 0) { ZimbraLog.autoprov.info( "Not starting auto provision thread because %s is 0.", Provisioning.A_zimbraAutoProvPollingInterval); return; } // Log status try { String displayInterval = Provisioning.getInstance() .getLocalServer() .getAttr(Provisioning.A_zimbraAutoProvPollingInterval, null); ZimbraLog.autoprov.info( "Starting auto provision thread with sleep interval %s.", displayInterval); } catch (ServiceException e) { ZimbraLog.autoprov.warn( "Unable to get %s. Aborting thread startup.", Provisioning.A_zimbraAutoProvPollingInterval, e); return; } // Start thread autoProvThread = new AutoProvisionThread(); autoProvThread.start(); } }