LCOV - code coverage report
Current view: top level - sshd/commands - ReloadConfig.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 1 11 9.1 %
Date: 2022-11-19 15:00:39 Functions: 1 3 33.3 %

          Line data    Source code
       1             : // Copyright (C) 2018 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.sshd.commands;
      16             : 
      17             : import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER_OR_SLAVE;
      18             : 
      19             : import com.google.common.collect.Multimap;
      20             : import com.google.gerrit.common.data.GlobalCapability;
      21             : import com.google.gerrit.extensions.annotations.RequiresCapability;
      22             : import com.google.gerrit.server.config.ConfigUpdatedEvent.ConfigUpdateEntry;
      23             : import com.google.gerrit.server.config.ConfigUpdatedEvent.UpdateResult;
      24             : import com.google.gerrit.server.config.GerritServerConfigReloader;
      25             : import com.google.gerrit.sshd.CommandMetaData;
      26             : import com.google.gerrit.sshd.SshCommand;
      27             : import com.google.inject.Inject;
      28             : 
      29             : /** Issues a reload of gerrit.config. */
      30             : @RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
      31             : @CommandMetaData(
      32             :     name = "reload-config",
      33             :     description = "Reloads the Gerrit configuration",
      34             :     runsAt = MASTER_OR_SLAVE)
      35           1 : public class ReloadConfig extends SshCommand {
      36             : 
      37             :   @Inject private GerritServerConfigReloader gerritServerConfigReloader;
      38             : 
      39             :   @Override
      40             :   protected void run() throws Failure {
      41           0 :     enableGracefulStop();
      42           0 :     Multimap<UpdateResult, ConfigUpdateEntry> updates = gerritServerConfigReloader.reloadConfig();
      43           0 :     if (updates.isEmpty()) {
      44           0 :       stdout.println("No config entries updated!");
      45           0 :       return;
      46             :     }
      47             : 
      48             :     // Print out UpdateResult.{ACCEPTED|REJECTED} entries grouped by their type
      49           0 :     for (UpdateResult result : updates.keySet()) {
      50           0 :       stdout.println(result.toString() + " configuration changes:");
      51           0 :       updates.get(result).forEach(cfgEntry -> stdout.println(cfgEntry.toString()));
      52           0 :     }
      53           0 :   }
      54             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750