Fix slave cloning issue by binding Scanning rather than Searching /index
Move ChangeCache implementation binding from GerritGlobalModule to new ChangeCacheImplModule. This is so that GerritGlobalModule no longer assumes a SearchingChangeCacheImpl. This was preventing slave gerrit servers from binding a ScanningChangeCacheImpl instead, as they do not rely on searching (an index); scanning, rather, relies on the git repo. Add new ChangeCacheImplModule usage to Daemon, so the latter can tell the former about gerrit server running as a slave or not. ChangeCacheImplModule can then install either the ScanningChangeCacheImpl or SearchingChangeCacheImpl module, which binds the corresponding ChangeCache implementation. Adapt InMemoryModule and WebAppInitializer accordingly. Fix ScanningChangeCacheImpl logger initialization. The Daemon non-slave case is already covered by existing IT testing. The slave case (involving a new branch in ChangeCacheImplModule) has to be tested manually; below bug/issue has a scenario. Now, ScanningChangeCacheImpl is already covered by IT. And, that slave case is exercised each time a slave gerrit server runs. InMemoryModule is exercised by existing unit testing; WebAppInitializer is used by web.xml. In both cases, the existing behavior was kept in the code. Bug: Issue 3323 Change-Id: Idfa255a5ef754979ca8289ae178e022c1e94be97
This commit is contained in:
parent
146afb82f0
commit
25d42dd5f4
@ -53,6 +53,7 @@ import com.google.gerrit.server.config.MasterNodeStartup;
|
||||
import com.google.gerrit.server.config.RestCacheAdminModule;
|
||||
import com.google.gerrit.server.contact.ContactStoreModule;
|
||||
import com.google.gerrit.server.contact.HttpContactStoreConnection;
|
||||
import com.google.gerrit.server.git.ChangeCacheImplModule;
|
||||
import com.google.gerrit.server.git.GarbageCollectionModule;
|
||||
import com.google.gerrit.server.git.ReceiveCommitsExecutorModule;
|
||||
import com.google.gerrit.server.git.WorkQueue;
|
||||
@ -321,6 +322,7 @@ public class Daemon extends SiteProgram {
|
||||
modules.add(new DiffExecutorModule());
|
||||
modules.add(new MimeUtil2Module());
|
||||
modules.add(cfgInjector.getInstance(GerritGlobalModule.class));
|
||||
modules.add(new ChangeCacheImplModule(slave));
|
||||
modules.add(new InternalAccountDirectory.Module());
|
||||
modules.add(new DefaultCacheFactory.Module());
|
||||
modules.add(new SmtpEmailSender.Module());
|
||||
|
@ -79,7 +79,6 @@ import com.google.gerrit.server.git.MergeQueue;
|
||||
import com.google.gerrit.server.git.MergeUtil;
|
||||
import com.google.gerrit.server.git.NotesBranchUtil;
|
||||
import com.google.gerrit.server.git.ReceivePackInitializer;
|
||||
import com.google.gerrit.server.git.SearchingChangeCacheImpl;
|
||||
import com.google.gerrit.server.git.TagCache;
|
||||
import com.google.gerrit.server.git.TransferConfig;
|
||||
import com.google.gerrit.server.git.validators.CommitValidationListener;
|
||||
@ -162,7 +161,6 @@ public class GerritGlobalModule extends FactoryModule {
|
||||
install(authModule);
|
||||
install(AccountByEmailCacheImpl.module());
|
||||
install(AccountCacheImpl.module());
|
||||
install(SearchingChangeCacheImpl.module());
|
||||
install(ChangeKindCacheImpl.module());
|
||||
install(ConflictsCacheImpl.module());
|
||||
install(GroupCacheImpl.module());
|
||||
@ -265,7 +263,6 @@ public class GerritGlobalModule extends FactoryModule {
|
||||
DynamicSet.setOf(binder(), ProjectDeletedListener.class);
|
||||
DynamicSet.setOf(binder(), HeadUpdatedListener.class);
|
||||
DynamicSet.setOf(binder(), UsageDataPublishedListener.class);
|
||||
DynamicSet.bind(binder(), GitReferenceUpdatedListener.class).to(SearchingChangeCacheImpl.class);
|
||||
DynamicSet.bind(binder(), GitReferenceUpdatedListener.class).to(ReindexAfterUpdate.class);
|
||||
DynamicSet.bind(binder(), GitReferenceUpdatedListener.class)
|
||||
.to(ProjectConfigEntry.UpdateChecker.class);
|
||||
|
@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.git;
|
||||
|
||||
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.inject.AbstractModule;
|
||||
|
||||
public class ChangeCacheImplModule extends AbstractModule {
|
||||
private final boolean slave;
|
||||
|
||||
public ChangeCacheImplModule(boolean slave) {
|
||||
this.slave = slave;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
if (slave) {
|
||||
install(ScanningChangeCacheImpl.module());
|
||||
} else {
|
||||
install(SearchingChangeCacheImpl.module());
|
||||
DynamicSet.bind(binder(), GitReferenceUpdatedListener.class)
|
||||
.to(SearchingChangeCacheImpl.class);
|
||||
}
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ import java.util.concurrent.ExecutionException;
|
||||
@Singleton
|
||||
public class ScanningChangeCacheImpl implements ChangeCache {
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(SearchingChangeCacheImpl.class);
|
||||
LoggerFactory.getLogger(ScanningChangeCacheImpl.class);
|
||||
|
||||
public static Module module() {
|
||||
return new CacheModule() {
|
||||
|
@ -41,6 +41,7 @@ import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.config.SitePath;
|
||||
import com.google.gerrit.server.config.TrackingFooters;
|
||||
import com.google.gerrit.server.config.TrackingFootersProvider;
|
||||
import com.google.gerrit.server.git.ChangeCacheImplModule;
|
||||
import com.google.gerrit.server.git.EmailReviewCommentsExecutor;
|
||||
import com.google.gerrit.server.git.GarbageCollection;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
@ -126,6 +127,7 @@ public class InMemoryModule extends FactoryModule {
|
||||
}
|
||||
});
|
||||
install(cfgInjector.getInstance(GerritGlobalModule.class));
|
||||
install(new ChangeCacheImplModule(false));
|
||||
factory(GarbageCollection.Factory.class);
|
||||
|
||||
bindScope(RequestScoped.class, PerThreadRequestScope.REQUEST);
|
||||
|
@ -39,6 +39,7 @@ import com.google.gerrit.server.config.RestCacheAdminModule;
|
||||
import com.google.gerrit.server.config.SitePath;
|
||||
import com.google.gerrit.server.contact.ContactStoreModule;
|
||||
import com.google.gerrit.server.contact.HttpContactStoreConnection;
|
||||
import com.google.gerrit.server.git.ChangeCacheImplModule;
|
||||
import com.google.gerrit.server.git.GarbageCollectionModule;
|
||||
import com.google.gerrit.server.git.LocalDiskRepositoryManager;
|
||||
import com.google.gerrit.server.git.ReceiveCommitsExecutorModule;
|
||||
@ -287,6 +288,7 @@ public class WebAppInitializer extends GuiceServletContextListener
|
||||
modules.add(new DiffExecutorModule());
|
||||
modules.add(new MimeUtil2Module());
|
||||
modules.add(cfgInjector.getInstance(GerritGlobalModule.class));
|
||||
modules.add(new ChangeCacheImplModule(false));
|
||||
modules.add(new InternalAccountDirectory.Module());
|
||||
modules.add(new DefaultCacheFactory.Module());
|
||||
modules.add(new SmtpEmailSender.Module());
|
||||
|
Loading…
Reference in New Issue
Block a user