Merge branch 'stable-2.11'
* stable-2.11: Set version to 2.11.2 in dev-plugins.txt Release notes for Gerrit 2.11.2 Bind OnlineReindexer.Factory in LuceneIndexModule Add ssh command to activate the latest index Add ssh command to restart online indexer PluginAPI: Don't convert to String in RestApi.get() method Change-Id: I907e665b20568fce8563bf9e22a7a0ffc96fc847
This commit is contained in:
@@ -36,6 +36,7 @@ public class DefaultCommandModule extends CommandModule {
|
||||
protected void configure() {
|
||||
final CommandName git = Commands.named("git");
|
||||
final CommandName gerrit = Commands.named("gerrit");
|
||||
CommandName index = Commands.named(gerrit, "index");
|
||||
final CommandName logging = Commands.named(gerrit, "logging");
|
||||
final CommandName plugin = Commands.named(gerrit, "plugin");
|
||||
final CommandName testSubmit = Commands.named(gerrit, "test-submit");
|
||||
@@ -56,8 +57,12 @@ public class DefaultCommandModule extends CommandModule {
|
||||
command(gerrit, StreamEvents.class);
|
||||
command(gerrit, VersionCommand.class);
|
||||
command(gerrit, GarbageCollectionCommand.class);
|
||||
command(gerrit, "plugin").toProvider(new DispatchCommandProvider(plugin));
|
||||
|
||||
command(index).toProvider(new DispatchCommandProvider(index));
|
||||
command(index, IndexActivateCommand.class);
|
||||
command(index, IndexStartCommand.class);
|
||||
|
||||
command(gerrit, "plugin").toProvider(new DispatchCommandProvider(plugin));
|
||||
command(plugin, PluginLsCommand.class);
|
||||
command(plugin, PluginEnableCommand.class);
|
||||
command(plugin, PluginInstallCommand.class);
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// 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.sshd.commands;
|
||||
|
||||
import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER;
|
||||
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.extensions.annotations.RequiresCapability;
|
||||
import com.google.gerrit.lucene.LuceneVersionManager;
|
||||
import com.google.gerrit.lucene.ReindexerAlreadyRunningException;
|
||||
import com.google.gerrit.sshd.CommandMetaData;
|
||||
import com.google.gerrit.sshd.SshCommand;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@CommandMetaData(name = "activate",
|
||||
description = "Activate the latest index version available",
|
||||
runsAt = MASTER)
|
||||
public class IndexActivateCommand extends SshCommand {
|
||||
|
||||
@Inject
|
||||
private LuceneVersionManager luceneVersionManager;
|
||||
|
||||
@Override
|
||||
protected void run() throws UnloggedFailure {
|
||||
try {
|
||||
if (luceneVersionManager.activateLatestIndex()) {
|
||||
stdout.println("Activated latest index version");
|
||||
} else {
|
||||
stdout.println("Not activating index, already using latest version");
|
||||
}
|
||||
} catch (ReindexerAlreadyRunningException e) {
|
||||
throw new UnloggedFailure("Failed to activate latest index: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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.sshd.commands;
|
||||
|
||||
import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER;
|
||||
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.extensions.annotations.RequiresCapability;
|
||||
import com.google.gerrit.lucene.LuceneVersionManager;
|
||||
import com.google.gerrit.lucene.ReindexerAlreadyRunningException;
|
||||
import com.google.gerrit.sshd.CommandMetaData;
|
||||
import com.google.gerrit.sshd.SshCommand;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@CommandMetaData(name = "start", description = "Start the online reindexer",
|
||||
runsAt = MASTER)
|
||||
public class IndexStartCommand extends SshCommand {
|
||||
|
||||
@Inject
|
||||
private LuceneVersionManager luceneVersionManager;
|
||||
|
||||
@Override
|
||||
protected void run() throws UnloggedFailure {
|
||||
try {
|
||||
if (luceneVersionManager.startReindexer()) {
|
||||
stdout.println("Reindexer started");
|
||||
} else {
|
||||
stdout.println("Nothing to reindex, index is already the latest version");
|
||||
}
|
||||
} catch (ReindexerAlreadyRunningException e) {
|
||||
throw new UnloggedFailure("Failed to start reindexer: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user