1 /*
2  * Copyright (C) 2019 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.tradefed.cluster;
17 
18 /** Interface for ClusterEventUploader */
19 public interface IClusterEventUploader<T extends IClusterEvent> {
20     /**
21      * Get the maximum number of events to upload at once.
22      *
23      * @param batchSize the maximum number of events to upload at once.
24      */
setMaxBatchSize(int batchSize)25     public void setMaxBatchSize(int batchSize);
26 
27     /**
28      * Get the maximum batch size used when uploading events.
29      *
30      * @return the maximum batch size.
31      */
getMaxBatchSize()32     public int getMaxBatchSize();
33 
34     /**
35      * Set how often we upload events to TFC.
36      *
37      * @param interval in ms for events to be uploaded to TFC.
38      */
setEventUploadInterval(long interval)39     public void setEventUploadInterval(long interval);
40 
41     /**
42      * Get the upload interval.
43      *
44      * @return the upload interval in ms.
45      */
getEventUploadInterval()46     public long getEventUploadInterval();
47 
48     /**
49      * Posts an event to TFC. This queues the event to be uploaded. Events will be batched and
50      * uploaded.
51      *
52      * @param event the event to upload
53      */
postEvent(final T event)54     void postEvent(final T event);
55 
56     /** Force an upload of all events queued. */
flush()57     void flush();
58 }
59