• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 
17 package com.android.federatedcompute.services.http;
18 
19 import android.annotation.Nullable;
20 
21 import com.android.internal.util.Preconditions;
22 
23 import com.google.internal.federated.plan.ClientOnlyPlan;
24 import com.google.internal.federatedcompute.v1.RejectionInfo;
25 import com.google.ondevicepersonalization.federatedcompute.proto.TaskAssignment;
26 
27 /**
28  * The result after client calls TaskAssignment API. It includes init checkpoint data and plan data.
29  */
30 public class CheckinResult {
31     private final String mInputCheckpoint;
32     private final ClientOnlyPlan mPlanData;
33     private final TaskAssignment mTaskAssignment;
34     private final RejectionInfo mRejectionInfo;
35 
CheckinResult( String inputCheckpoint, ClientOnlyPlan planData, TaskAssignment taskAssignment)36     public CheckinResult(
37             String inputCheckpoint, ClientOnlyPlan planData, TaskAssignment taskAssignment) {
38         this.mInputCheckpoint = inputCheckpoint;
39         this.mPlanData = planData;
40         this.mTaskAssignment = taskAssignment;
41         this.mRejectionInfo = null;
42     }
43 
CheckinResult(RejectionInfo mRejectionInfo)44     public CheckinResult(RejectionInfo mRejectionInfo) {
45         this.mRejectionInfo = mRejectionInfo;
46         this.mInputCheckpoint = null;
47         this.mPlanData = null;
48         this.mTaskAssignment = null;
49     }
50 
51     @Nullable
getInputCheckpointFile()52     public String getInputCheckpointFile() {
53         Preconditions.checkArgument(
54                 mInputCheckpoint != null && !mInputCheckpoint.isEmpty(),
55                 "Input checkpoint file should not be none or empty");
56         return mInputCheckpoint;
57     }
58 
59     @Nullable
getPlanData()60     public ClientOnlyPlan getPlanData() {
61         return mPlanData;
62     }
63 
64     @Nullable
getTaskAssignment()65     public TaskAssignment getTaskAssignment() {
66         return mTaskAssignment;
67     }
68 
69     @Nullable
getRejectionInfo()70     public RejectionInfo getRejectionInfo() {
71         return mRejectionInfo;
72     }
73 }
74