Merge changes from topic 'daemon-slave-mode-fixes' into stable-2.12

* changes:
  ChangeCleanupConfig: Allow canonical web URL to be null
  Daemon: Don't add change cleanup module when running as slave
  Daemon: Don't add index commands when running as slave
This commit is contained in:
Edwin Kempin
2015-12-03 08:19:41 +00:00
committed by Gerrit Code Review
2 changed files with 12 additions and 5 deletions

View File

@@ -278,7 +278,9 @@ public class Daemon extends SiteProgram {
cfgInjector = createCfgInjector();
config = cfgInjector.getInstance(
Key.get(Config.class, GerritServerConfig.class));
initIndexType();
if (!slave) {
initIndexType();
}
sysInjector = createSysInjector();
sysInjector.getInstance(PluginGuiceEnvironment.class)
.setDbCfgInjector(dbInjector, cfgInjector);
@@ -374,7 +376,9 @@ public class Daemon extends SiteProgram {
}
});
modules.add(new GarbageCollectionModule());
modules.add(new ChangeCleanupRunner.Module());
if (!slave) {
modules.add(new ChangeCleanupRunner.Module());
}
return cfgInjector.createChildInjector(modules);
}
@@ -415,7 +419,7 @@ public class Daemon extends SiteProgram {
}
modules.add(new DefaultCommandModule(slave,
sysInjector.getInstance(DownloadConfig.class)));
if (indexType == IndexType.LUCENE) {
if (!slave && indexType == IndexType.LUCENE) {
modules.add(new IndexCommandsModule());
}
return sysInjector.createChildInjector(modules);

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.config;
import com.google.common.base.Strings;
import com.google.gerrit.common.Nullable;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -41,7 +42,7 @@ public class ChangeCleanupConfig {
@Inject
ChangeCleanupConfig(@GerritServerConfig Config cfg,
@CanonicalWebUrl String canonicalWebUrl) {
@CanonicalWebUrl @Nullable String canonicalWebUrl) {
scheduleConfig = new ScheduleConfig(cfg, SECTION);
abandonAfter = readAbandonAfter(cfg);
abandonIfMergeable =
@@ -61,7 +62,9 @@ public class ChangeCleanupConfig {
if (Strings.isNullOrEmpty(abandonMessage)) {
abandonMessage = DEFAULT_ABANDON_MESSAGE;
}
abandonMessage = abandonMessage.replaceAll("\\$\\{URL\\}", webUrl);
if (!Strings.isNullOrEmpty(webUrl)) {
abandonMessage = abandonMessage.replaceAll("\\$\\{URL\\}", webUrl);
}
return abandonMessage;
}