Line data Source code
1 : // Copyright (C) 2017 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.server.index; 16 : 17 : import com.google.gerrit.extensions.events.LifecycleListener; 18 : import com.google.gerrit.lifecycle.LifecycleModule; 19 : import com.google.inject.Inject; 20 : 21 : /** Listener to handle upgrading index schema versions at startup. */ 22 : public class OnlineUpgrader implements LifecycleListener { 23 15 : public static class OnlineUpgraderModule extends LifecycleModule { 24 : @Override 25 : protected void configure() { 26 15 : listener().to(OnlineUpgrader.class); 27 15 : } 28 : } 29 : 30 : private final VersionManager versionManager; 31 : 32 : @Inject 33 15 : OnlineUpgrader(VersionManager versionManager) { 34 15 : this.versionManager = versionManager; 35 15 : } 36 : 37 : @Override 38 : public void start() { 39 15 : versionManager.startOnlineUpgrade(); 40 15 : } 41 : 42 : @Override 43 : public void stop() { 44 : // Do nothing; reindexing threadpools are shut down in another listener, and indexes are closed 45 : // on demand by IndexCollection. 46 15 : } 47 : }