• 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.common;
18 
19 /** FederatedCompute feature flags interface. This Flags interface hold the default values */
20 public interface Flags {
21 
22     /** Flags for {@link FederatedComputeJobManager}. */
23     long DEFAULT_SCHEDULING_PERIOD_SECS = 60 * 5; // 5 minutes
24 
getDefaultSchedulingPeriodSecs()25     default long getDefaultSchedulingPeriodSecs() {
26         return DEFAULT_SCHEDULING_PERIOD_SECS;
27     }
28 
29     long MIN_SCHEDULING_INTERVAL_SECS_FOR_FEDERATED_COMPUTATION = 1 * 60; // 1 min
30 
getMinSchedulingIntervalSecsForFederatedComputation()31     default long getMinSchedulingIntervalSecsForFederatedComputation() {
32         return MIN_SCHEDULING_INTERVAL_SECS_FOR_FEDERATED_COMPUTATION;
33     }
34 
35     long MAX_SCHEDULING_INTERVAL_SECS_FOR_FEDERATED_COMPUTATION =
36             6 * 24 * 60 * 60; // 6 days (< default ttl 7d)
37 
getMaxSchedulingIntervalSecsForFederatedComputation()38     default long getMaxSchedulingIntervalSecsForFederatedComputation() {
39         return MAX_SCHEDULING_INTERVAL_SECS_FOR_FEDERATED_COMPUTATION;
40     }
41 
42     long MAX_SCHEDULING_PERIOD_SECS = 60 * 60 * 24 * 2; // 2 days
43 
getMaxSchedulingPeriodSecs()44     default long getMaxSchedulingPeriodSecs() {
45         return MAX_SCHEDULING_PERIOD_SECS;
46     }
47 
48     long TRAINING_TIME_FOR_LIVE_SECONDS = 7 * 24 * 60 * 60; // one week
49 
getTrainingTimeForLiveSeconds()50     default long getTrainingTimeForLiveSeconds() {
51         return TRAINING_TIME_FOR_LIVE_SECONDS;
52     }
53 
54     long TRAINING_SERVICE_RESULT_CALLBACK_TIMEOUT_SEC =
55             60 * 9 + 45; // 9 minutes 45 seconds, leaving ~15 seconds to clean up.
56 
getTrainingServiceResultCallbackTimeoutSecs()57     default long getTrainingServiceResultCallbackTimeoutSecs() {
58         return TRAINING_SERVICE_RESULT_CALLBACK_TIMEOUT_SEC;
59     }
60 
61     float TRANSIENT_ERROR_RETRY_DELAY_JITTER_PERCENT = 0.2f;
62 
getTransientErrorRetryDelayJitterPercent()63     default float getTransientErrorRetryDelayJitterPercent() {
64         return TRANSIENT_ERROR_RETRY_DELAY_JITTER_PERCENT;
65     }
66 
67     long TRANSIENT_ERROR_RETRY_DELAY_SECS = 15 * 60; // 15 minutes
68 
getTransientErrorRetryDelaySecs()69     default long getTransientErrorRetryDelaySecs() {
70         return TRANSIENT_ERROR_RETRY_DELAY_SECS;
71     }
72 
73     /** Flags for {@link FederatedExampleIterator}. */
74     long APP_HOSTED_EXAMPLE_STORE_TIMEOUT_SECS = 30;
75 
getAppHostedExampleStoreTimeoutSecs()76     default long getAppHostedExampleStoreTimeoutSecs() {
77         return APP_HOSTED_EXAMPLE_STORE_TIMEOUT_SECS;
78     }
79 
80     /** Flags for ResultHandlingService. */
81     long RESULT_HANDLING_BIND_SERVICE_TIMEOUT_SECS = 10;
82 
getResultHandlingBindServiceTimeoutSecs()83     default long getResultHandlingBindServiceTimeoutSecs() {
84         return RESULT_HANDLING_BIND_SERVICE_TIMEOUT_SECS;
85     }
86 
87     // 9 minutes 45 seconds, leaving ~15 seconds to clean up.
88     long RESULT_HANDLING_SERVICE_CALLBACK_TIMEOUT_SECS = 60 * 9 + 45;
89 
getResultHandlingServiceCallbackTimeoutSecs()90     default long getResultHandlingServiceCallbackTimeoutSecs() {
91         return RESULT_HANDLING_SERVICE_CALLBACK_TIMEOUT_SECS;
92     }
93 }
94