1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.google.gce.gceservice; 17 18 import android.util.Log; 19 import java.util.ArrayList; 20 21 public abstract class JobBase { 22 private final String mTag; 23 JobBase(String tag)24 JobBase(String tag) { 25 mTag = tag; 26 } 27 28 29 /** Invoked, when job could not be started due to dependency failure. 30 * 31 * Supplied exception describes reason of failure. 32 */ onDependencyFailed(Exception exception)33 public abstract void onDependencyFailed(Exception exception); 34 35 36 /** Invoked, when one or more tasks have taken substantial time to complete. 37 * 38 * This is not a direct indication of an error, but merely an information 39 * about what stops current job from being executed. 40 * 41 * @param stragglingDependencies list of dependencies that have not completed 42 * in last 10 seconds. 43 */ onDependencyStraggling(ArrayList<GceFuture<?>> stragglingDependencies)44 public void onDependencyStraggling(ArrayList<GceFuture<?>> stragglingDependencies) { 45 Log.i(mTag, "Waiting for: " + GceFuture.toString(stragglingDependencies)); 46 } 47 48 49 /** Invoked, when all dependencies are ready and job is clear to commence. 50 * 51 * Returns number of second before re-execution, or 0, if job is done. 52 */ execute()53 public abstract int execute(); 54 } 55