Don't require secondary index when running daemon in slave mode
Add a dummy index implementation and install it when the daemon is started in slave mode. Make the reindex program exit with an error if run on a server that is configured to run in slave mode. Disable the query ssh command when in slave mode. Change-Id: Ia323d7dfc3b8f333857ba310072e41943878c11b
This commit is contained in:
parent
dcd2fd364e
commit
85f97710d3
@ -55,6 +55,7 @@ import com.google.gerrit.server.config.MasterNodeStartup;
|
|||||||
import com.google.gerrit.server.contact.HttpContactStoreConnection;
|
import com.google.gerrit.server.contact.HttpContactStoreConnection;
|
||||||
import com.google.gerrit.server.git.ReceiveCommitsExecutorModule;
|
import com.google.gerrit.server.git.ReceiveCommitsExecutorModule;
|
||||||
import com.google.gerrit.server.git.WorkQueue;
|
import com.google.gerrit.server.git.WorkQueue;
|
||||||
|
import com.google.gerrit.server.index.DummyIndexModule;
|
||||||
import com.google.gerrit.server.index.IndexModule;
|
import com.google.gerrit.server.index.IndexModule;
|
||||||
import com.google.gerrit.server.index.IndexModule.IndexType;
|
import com.google.gerrit.server.index.IndexModule.IndexType;
|
||||||
import com.google.gerrit.server.mail.SignedTokenEmailTokenVerifier;
|
import com.google.gerrit.server.mail.SignedTokenEmailTokenVerifier;
|
||||||
@ -357,6 +358,9 @@ public class Daemon extends SiteProgram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AbstractModule createIndexModule() {
|
private AbstractModule createIndexModule() {
|
||||||
|
if (slave) {
|
||||||
|
return new DummyIndexModule();
|
||||||
|
}
|
||||||
IndexType indexType = IndexModule.getIndexType(cfgInjector);
|
IndexType indexType = IndexModule.getIndexType(cfgInjector);
|
||||||
switch (indexType) {
|
switch (indexType) {
|
||||||
case LUCENE:
|
case LUCENE:
|
||||||
|
@ -27,6 +27,7 @@ import com.google.gerrit.extensions.registration.DynamicSet;
|
|||||||
import com.google.gerrit.lifecycle.LifecycleManager;
|
import com.google.gerrit.lifecycle.LifecycleManager;
|
||||||
import com.google.gerrit.lifecycle.LifecycleModule;
|
import com.google.gerrit.lifecycle.LifecycleModule;
|
||||||
import com.google.gerrit.lucene.LuceneIndexModule;
|
import com.google.gerrit.lucene.LuceneIndexModule;
|
||||||
|
import com.google.gerrit.pgm.util.Die;
|
||||||
import com.google.gerrit.pgm.util.SiteProgram;
|
import com.google.gerrit.pgm.util.SiteProgram;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
@ -124,6 +125,7 @@ public class Reindex extends SiteProgram {
|
|||||||
private boolean dryRun;
|
private boolean dryRun;
|
||||||
|
|
||||||
private Injector dbInjector;
|
private Injector dbInjector;
|
||||||
|
private Config cfg;
|
||||||
private Injector sysInjector;
|
private Injector sysInjector;
|
||||||
private ChangeIndex index;
|
private ChangeIndex index;
|
||||||
|
|
||||||
@ -131,6 +133,9 @@ public class Reindex extends SiteProgram {
|
|||||||
public int run() throws Exception {
|
public int run() throws Exception {
|
||||||
mustHaveValidSite();
|
mustHaveValidSite();
|
||||||
dbInjector = createDbInjector(MULTI_USER);
|
dbInjector = createDbInjector(MULTI_USER);
|
||||||
|
cfg = dbInjector.getInstance(
|
||||||
|
Key.get(Config.class, GerritServerConfig.class));
|
||||||
|
checkNotSlaveMode();
|
||||||
limitThreads();
|
limitThreads();
|
||||||
disableLuceneAutomaticCommit();
|
disableLuceneAutomaticCommit();
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
@ -160,9 +165,13 @@ public class Reindex extends SiteProgram {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkNotSlaveMode() throws Die {
|
||||||
|
if (cfg.getBoolean("container", "slave", false)) {
|
||||||
|
throw die("Cannot run reindex in slave mode");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void limitThreads() {
|
private void limitThreads() {
|
||||||
Config cfg =
|
|
||||||
dbInjector.getInstance(Key.get(Config.class, GerritServerConfig.class));
|
|
||||||
boolean usePool = cfg.getBoolean("database", "connectionpool",
|
boolean usePool = cfg.getBoolean("database", "connectionpool",
|
||||||
dbInjector.getInstance(DataSourceType.class).usePool());
|
dbInjector.getInstance(DataSourceType.class).usePool());
|
||||||
int poolLimit = cfg.getInt("database", "poollimit",
|
int poolLimit = cfg.getInt("database", "poollimit",
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
// Copyright (C) 2014 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.index;
|
||||||
|
|
||||||
|
import com.google.gerrit.server.query.Predicate;
|
||||||
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
|
import com.google.gerrit.server.query.change.ChangeDataSource;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class DummyIndex implements ChangeIndex {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Schema<ChangeData> getSchema() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insert(ChangeData cd) throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void replace(ChangeData cd) throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(ChangeData cd) throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteAll() throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChangeDataSource getSource(Predicate<ChangeData> p, int start,
|
||||||
|
int limit) throws QueryParseException {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void markReady(boolean ready) throws IOException {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2014 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.index;
|
||||||
|
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
|
||||||
|
public class DummyIndexModule extends AbstractModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
install(new IndexModule(1));
|
||||||
|
bind(ChangeIndex.class).toInstance(new DummyIndex());
|
||||||
|
}
|
||||||
|
}
|
@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.sshd.commands;
|
package com.google.gerrit.sshd.commands;
|
||||||
|
|
||||||
import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER_OR_SLAVE;
|
|
||||||
|
|
||||||
import com.google.gerrit.server.query.change.QueryProcessor;
|
import com.google.gerrit.server.query.change.QueryProcessor;
|
||||||
import com.google.gerrit.sshd.CommandMetaData;
|
import com.google.gerrit.sshd.CommandMetaData;
|
||||||
import com.google.gerrit.sshd.SshCommand;
|
import com.google.gerrit.sshd.SshCommand;
|
||||||
@ -26,8 +24,7 @@ import org.kohsuke.args4j.Option;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@CommandMetaData(name = "query", description = "Query the change database",
|
@CommandMetaData(name = "query", description = "Query the change database")
|
||||||
runsAt = MASTER_OR_SLAVE)
|
|
||||||
class Query extends SshCommand {
|
class Query extends SshCommand {
|
||||||
@Inject
|
@Inject
|
||||||
private QueryProcessor processor;
|
private QueryProcessor processor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user