001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2013-2015 ForgeRock AS 025 */ 026 027package org.opends.server.tools.upgrade; 028 029import com.forgerock.opendj.cli.ClientException; 030 031/** 032 * An upgrade task. 033 */ 034public interface UpgradeTask 035{ 036 037 /** 038 * Defines the different types of upgrade tasks. 039 */ 040 public enum TaskType { 041 /** 042 * Defines a standard task. 043 */ 044 NORMAL, 045 /** 046 * Defines a task which require a standard user interaction. 047 */ 048 NEED_USER_INTERACTION, 049 /** 050 * Defines a critical task which require an imperative user interaction. 051 */ 052 MANDATORY_USER_INTERACTION, 053 /** 054 * Defines a task which take a long time to complete. 055 */ 056 TAKE_LONG_TIME_TO_COMPLETE, 057 /** 058 * Defines a task which cannot be reverted once started. 059 */ 060 CANNOT_BE_REVERTED 061 } 062 063 /** 064 * Performs any preparation work required before performing the upgrade task, including 065 * interacting with the user where needed (e.g. in order to ask for confirmation), and throw a 066 * {@code ClientException} if the upgrade cannot proceed. 067 * 068 * @param context 069 * Context through which tasks can interact with the server installation. 070 * @throws ClientException 071 * If the upgrade cannot proceed. 072 */ 073 void prepare(UpgradeContext context) throws ClientException; 074 075 /** 076 * Performs this upgrade task. 077 * 078 * @param context 079 * Context through which tasks can interact with the server installation. 080 * @throws ClientException 081 * If an error occurred while performing the task. 082 */ 083 void perform(UpgradeContext context) throws ClientException; 084 085 /** 086 * This method will be invoked after all upgrade tasks have completed 087 * successfully The post upgrade tasks are processes which should be launched 088 * after a successful upgrade. 089 * 090 * @param context 091 * Context through which tasks can interact with the server 092 * installation. 093 * @throws ClientException 094 * If the task cannot proceed. 095 */ 096 void postUpgrade(UpgradeContext context) throws ClientException; 097 098 /** 099 * This method will be invoked only if one of the previous post upgrade task 100 * has failed. 101 * 102 * @param context 103 * Context through which tasks can interact with the server 104 * installation. 105 * @throws ClientException 106 * If the task cannot proceed. 107 */ 108 void postponePostUpgrade(UpgradeContext context) throws ClientException; 109}