Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
GraphFunctions |
|
| 1.0416666666666667;1.042 | ||||
GraphFunctions$1 |
|
| 1.0416666666666667;1.042 | ||||
GraphFunctions$2 |
|
| 1.0416666666666667;1.042 | ||||
GraphFunctions$3 |
|
| 1.0416666666666667;1.042 | ||||
GraphFunctions$4 |
|
| 1.0416666666666667;1.042 | ||||
GraphFunctions$5 |
|
| 1.0416666666666667;1.042 | ||||
GraphFunctions$6 |
|
| 1.0416666666666667;1.042 |
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.graph; | |
20 | ||
21 | /** | |
22 | * Each compute node running on the underlying cluster | |
23 | * is marked with this enum to indicate the worker or | |
24 | * master task(s) it must perform during job runs. | |
25 | */ | |
26 | 0 | public enum GraphFunctions { |
27 | /** Undecided yet */ | |
28 | 0 | UNKNOWN { |
29 | 0 | @Override public boolean isMaster() { return false; } |
30 | 0 | @Override public boolean isWorker() { return false; } |
31 | 0 | @Override public boolean isZooKeeper() { return false; } |
32 | }, | |
33 | /** Only be the master */ | |
34 | 0 | MASTER_ONLY { |
35 | 0 | @Override public boolean isMaster() { return true; } |
36 | 0 | @Override public boolean isWorker() { return false; } |
37 | 0 | @Override public boolean isZooKeeper() { return false; } |
38 | }, | |
39 | /** Only be the master and ZooKeeper */ | |
40 | 0 | MASTER_ZOOKEEPER_ONLY { |
41 | 0 | @Override public boolean isMaster() { return true; } |
42 | 0 | @Override public boolean isWorker() { return false; } |
43 | 0 | @Override public boolean isZooKeeper() { return true; } |
44 | }, | |
45 | /** Only be the worker */ | |
46 | 0 | WORKER_ONLY { |
47 | 0 | @Override public boolean isMaster() { return false; } |
48 | 0 | @Override public boolean isWorker() { return true; } |
49 | 0 | @Override public boolean isZooKeeper() { return false; } |
50 | }, | |
51 | /** Do master, worker, and ZooKeeper */ | |
52 | 0 | ALL { |
53 | 0 | @Override public boolean isMaster() { return true; } |
54 | 0 | @Override public boolean isWorker() { return true; } |
55 | 0 | @Override public boolean isZooKeeper() { return true; } |
56 | }, | |
57 | /** Do master and worker */ | |
58 | 0 | ALL_EXCEPT_ZOOKEEPER { |
59 | 0 | @Override public boolean isMaster() { return true; } |
60 | 0 | @Override public boolean isWorker() { return true; } |
61 | 0 | @Override public boolean isZooKeeper() { return false; } |
62 | }; | |
63 | ||
64 | /** | |
65 | * Tell whether this function acts as a master. | |
66 | * | |
67 | * @return true iff this map function is a master | |
68 | */ | |
69 | public abstract boolean isMaster(); | |
70 | ||
71 | /** | |
72 | * Tell whether this function acts as a worker. | |
73 | * | |
74 | * @return true iff this map function is a worker | |
75 | */ | |
76 | public abstract boolean isWorker(); | |
77 | ||
78 | /** | |
79 | * Tell whether this function acts as a ZooKeeper server. | |
80 | * | |
81 | * @return true iff this map function is a zookeeper server | |
82 | */ | |
83 | public abstract boolean isZooKeeper(); | |
84 | ||
85 | public boolean isKnown() { | |
86 | 0 | return this != UNKNOWN; |
87 | } | |
88 | ||
89 | public boolean isUnknown() { | |
90 | 0 | return !isKnown(); |
91 | } | |
92 | ||
93 | public boolean isNotAWorker() { | |
94 | 0 | return isKnown() && !isWorker(); |
95 | } | |
96 | } |