use of com.zimbra.common.lmtp.SmtpToLmtp in project zm-mailbox by Zimbra.
the class Zimbra method startup.
/**
* Initialize the various subsystems at server/CLI startup time.
* @param forMailboxd true if this is the mailboxd process; false for CLI processes
* @throws ServiceException
*/
private static synchronized void startup(boolean forMailboxd) throws ServiceException {
if (sInited)
return;
sIsMailboxd = forMailboxd;
if (sIsMailboxd) {
FirstServlet.waitForInitialization();
}
Provisioning prov = Provisioning.getInstance();
Server server = prov.getLocalServer();
alwaysOnClusterId = server.getAlwaysOnClusterId();
setSystemProperties();
validateJavaOptions();
logVersionAndSysInfo();
SoapTransport.setDefaultUserAgent("ZCS", BuildInfo.VERSION);
checkForClasses();
ZimbraApplication app = ZimbraApplication.getInstance();
DbPool.startup();
app.initializeZimbraDb(forMailboxd);
if (!Versions.checkVersions()) {
Zimbra.halt("Data version mismatch. Reinitialize or upgrade the backend data store.");
}
DbPool.loadSettings();
String tzFilePath = LC.timezone_file.value();
try {
File tzFile = new File(tzFilePath);
WellKnownTimeZones.loadFromFile(tzFile);
} catch (Throwable t) {
Zimbra.halt("Unable to load timezones from " + tzFilePath, t);
}
if (prov instanceof LdapProv) {
((LdapProv) prov).waitForLdapServer();
if (forMailboxd) {
AttributeManager.loadLdapSchemaExtensionAttrs((LdapProv) prov);
}
}
if (server.isMailSSLClientCertOCSPEnabled()) {
// Activate OCSP
Security.setProperty("ocsp.enable", "true");
// Activate CRLDP
System.setProperty("com.sun.security.enableCRLDP", "true");
} else {
// Disable OCSP
Security.setProperty("ocsp.enable", "false");
// Disable CRLDP
System.setProperty("com.sun.security.enableCRLDP", "false");
}
try {
RightManager.getInstance();
} catch (ServiceException e) {
Util.halt("cannot initialize RightManager", e);
}
ZimbraHttpConnectionManager.startReaperThread();
EphemeralStore.registerFactory("ldap", LdapEphemeralStore.Factory.class.getName());
ExtensionUtil.initAll();
try {
StoreManager.getInstance().startup();
} catch (IOException e) {
throw ServiceException.FAILURE("Unable to initialize StoreManager.", e);
}
MailboxManager.getInstance();
app.startup();
if (app.supports(MemcachedConnector.class.getName())) {
MemcachedConnector.startup();
}
if (app.supports(EhcacheManager.class.getName())) {
EhcacheManager.getInstance().startup();
}
// ZimletUtil.loadZimlets();
MailboxIndex.startup();
RedoLogProvider redoLog = RedoLogProvider.getInstance();
if (sIsMailboxd) {
redoLog.startup();
} else {
redoLog.initRedoLogManager();
}
System.setProperty("ical4j.unfolding.relaxed", "true");
MailboxManager.getInstance().startup();
app.initialize(sIsMailboxd);
if (sIsMailboxd) {
SessionCache.startup();
AuthTokenRegistry.startup(prov.getConfig(Provisioning.A_zimbraAuthTokenNotificationInterval).getIntAttr(Provisioning.A_zimbraAuthTokenNotificationInterval, 60000));
dbSessionCleanup();
if (!redoLog.isSlave()) {
boolean useDirectBuffers = server.isMailUseDirectBuffers();
IoBuffer.setUseDirectBuffer(useDirectBuffers);
ZimbraLog.misc.info("MINA setUseDirectBuffers(" + useDirectBuffers + ")");
ServerManager.getInstance().startServers();
}
if (app.supports(WaitSetMgr.class.getName())) {
WaitSetMgr.startup();
}
if (app.supports(MemoryStats.class.getName())) {
MemoryStats.startup();
}
if (app.supports(ScheduledTaskManager.class.getName())) {
ScheduledTaskManager.startup();
}
if (app.supports(PurgeThread.class.getName())) {
PurgeThread.startup();
}
if (app.supports(AutoProvisionThread.class.getName())) {
AutoProvisionThread.switchAutoProvThreadIfNecessary();
}
if (LC.smtp_to_lmtp_enabled.booleanValue()) {
int smtpPort = LC.smtp_to_lmtp_port.intValue();
int lmtpPort = Provisioning.getInstance().getLocalServer().getLmtpBindPort();
SmtpToLmtp smtpServer = SmtpToLmtp.startup(smtpPort, "localhost", lmtpPort);
smtpServer.setRecipientValidator(new SmtpRecipientValidator());
}
if (app.supports(AclPushTask.class)) {
long pushInterval = server.getSharingUpdatePublishInterval();
sTimer.schedule(new AclPushTask(), pushInterval, pushInterval);
}
if (app.supports(ExternalAccountManagerTask.class)) {
long interval = server.getExternalAccountStatusCheckInterval();
sTimer.schedule(new ExternalAccountManagerTask(), interval, interval);
}
if (prov.getLocalServer().isMessageChannelEnabled()) {
try {
MessageChannel.getInstance().startup();
} catch (IOException e) {
ZimbraLog.misc.warn("can't start notification channels", e);
}
}
Server localServer = Provisioning.getInstance().getLocalServer();
String provPort = localServer.getAttr(Provisioning.A_zimbraMailPort);
String lcPort = LC.zimbra_mail_service_port.value();
if (!lcPort.equals(provPort)) {
LocalConfig lc;
try {
lc = new LocalConfig(null);
lc.set(LC.zimbra_mail_service_port.key(), provPort);
lc.save();
LC.reload();
} catch (DocumentException | ConfigException | IOException e) {
ZimbraLog.misc.warn("Cannot set LC zimbra_mail_service_port", e);
}
}
// should be last, so that other subsystems can add dynamic stats counters
if (app.supports(ZimbraPerf.class.getName())) {
ZimbraPerf.initialize();
}
}
ExtensionUtil.postInitAll();
// Register the service with ZooKeeper
if (sIsMailboxd && isAlwaysOn()) {
try {
CuratorManager curatorManager = CuratorManager.getInstance();
if (curatorManager == null) {
throw ServiceException.FAILURE("ZooKeeper addresses not configured.", null);
}
curatorManager.start();
} catch (Exception e) {
throw ServiceException.FAILURE("Unable to start Distributed Lock service.", e);
}
}
sInited = true;
}
Aggregations