1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.linecorp.centraldogma.server.management;
18
19 import com.fasterxml.jackson.annotation.JsonProperty;
20
21
22
23
24 public enum ServerStatus {
25
26 READ_ONLY(false, false),
27 REPLICATION_ONLY(false, true),
28 WRITABLE(true, true);
29
30 private final boolean writable;
31 private final boolean replicating;
32
33
34
35 ServerStatus(boolean writable, boolean replicating) {
36 this.writable = writable;
37 this.replicating = replicating;
38 }
39
40
41
42
43 public static ServerStatus of(boolean writable, boolean replicating) {
44 if (writable) {
45 if (replicating) {
46 return WRITABLE;
47 } else {
48 throw new IllegalArgumentException("replicating must be true if writable is true");
49 }
50 } else {
51 if (replicating) {
52 return REPLICATION_ONLY;
53 } else {
54 return READ_ONLY;
55 }
56 }
57 }
58
59
60
61
62 @JsonProperty("writable")
63 public boolean writable() {
64 return writable;
65 }
66
67
68
69
70 @JsonProperty("replicating")
71 public boolean replicating() {
72 return replicating;
73 }
74 }