1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.apache.giraph.master;
20
21 import com.facebook.swift.codec.ThriftField;
22 import com.facebook.swift.codec.ThriftStruct;
23
24 /**
25 * Stores information about master progress
26 */
27 @ThriftStruct
28 public final class MasterProgress {
29 /** Singleton instance for everyone to use */
30 private static final MasterProgress INSTANCE = new MasterProgress();
31
32 /** How many vertex input splits were created */
33 private int vertexInputSplitCount = -1;
34 /** How many edge input splits were created */
35 private int edgeInputSplitCount = -1;
36
37 /**
38 * Public constructor for thrift to create us.
39 * Please use MasterProgress.get() to get the static instance.
40 */
41 public MasterProgress() {
42 }
43
44 /**
45 * Get singleton instance of MasterProgress.
46 *
47 * @return MasterProgress singleton instance
48 */
49 public static MasterProgress get() {
50 return INSTANCE;
51 }
52
53 @ThriftField(1)
54 public int getVertexInputSplitCount() {
55 return vertexInputSplitCount;
56 }
57
58 @ThriftField
59 public void setVertexInputSplitCount(int vertexInputSplitCount) {
60 this.vertexInputSplitCount = vertexInputSplitCount;
61 }
62
63 @ThriftField(2)
64 public int getEdgeInputSplitsCount() {
65 return edgeInputSplitCount;
66 }
67
68 @ThriftField
69 public void setEdgeInputSplitsCount(int edgeInputSplitCount) {
70 this.edgeInputSplitCount = edgeInputSplitCount;
71 }
72
73 /**
74 * Whether or not number of vertex input splits was set yet
75 *
76 * @return True iff it was set
77 */
78 public boolean vertexInputSplitsSet() {
79 return vertexInputSplitCount != -1;
80 }
81
82 /**
83 * Whether or not number of edge input splits was set yet
84 *
85 * @return True iff it was set
86 */
87 public boolean edgeInputSplitsSet() {
88 return edgeInputSplitCount != -1;
89 }
90 }