2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.sli.plugins.data;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
29 public class ClusterActor {
31 private String member;
33 private String akkaPort;
34 private boolean voting;
36 private boolean unreachable;
37 private ArrayList<String> shardLeader;
38 private ArrayList<String> replicaShards;
39 private ArrayList<String> nonReplicaShards;
40 private HashMap<String, Integer> commits;
42 public static final String SITE_1 = "Site 1";
43 public static final String SITE_2 = "Site 2";
45 public ClusterActor() {
52 shardLeader = new ArrayList<>();
53 replicaShards = new ArrayList<>();
54 nonReplicaShards = new ArrayList<>();
55 commits = new HashMap<>();
58 public String getNode() {
62 public void setNode(String node) {
66 public String getMember() {
70 public void setMember(String member) {
74 public String getSite() {
78 public void setSite(String site) {
82 public String getAkkaPort() {
86 public void setAkkaPort(String akkaPort) {
87 this.akkaPort = akkaPort;
90 public boolean isVoting() {
94 public void setVoting(boolean voting) {
98 public boolean isUp() {
102 public void setUp(boolean up) {
106 public boolean isUnreachable() {
110 public void setUnreachable(boolean unreachable) {
111 this.unreachable = unreachable;
114 public List<String> getShardLeader() {
118 public void setShardLeader(List<String> shardLeader) {
119 this.shardLeader = (ArrayList<String>) shardLeader;
122 public List<String> getReplicaShards() {
123 return replicaShards;
126 public void setReplicaShards(List<String> replicaShards) {
127 this.replicaShards = (ArrayList<String>) replicaShards;
130 public List<String> getNonReplicaShards() {
131 return nonReplicaShards;
134 public void setNonReplicaShards(List<String> nonReplicaShards) {
135 this.nonReplicaShards = (ArrayList<String>) nonReplicaShards;
138 public Map<String, Integer> getCommits() {
142 public void setCommits(Map<String, Integer> commits) {
143 this.commits = (HashMap<String, Integer>) commits;
146 public void flush() {
148 replicaShards.clear();
149 nonReplicaShards.clear();
154 public String toString() {
155 StringBuilder builder = new StringBuilder();
156 builder.append("[ ");
157 builder.append(this.member);
158 builder.append(" ] ");
160 builder.append(this.node);
162 builder.append(this.akkaPort);
163 builder.append(" is");
165 builder.append(" Up");
167 builder.append(" Down");
169 builder.append(" [ UNREACHABLE ]");
172 builder.append(" (Voting)");
174 builder.append("\n");
176 for(String l : this.shardLeader) {
177 builder.append("\tLeader: ");
179 builder.append("\n");
182 for(String r : this.replicaShards) {
183 builder.append("\tReplicating: ");
185 builder.append("\n");
188 for(String n : this.nonReplicaShards) {
189 builder.append("\tNot replicating: ");
191 builder.append("\n");
194 for(Map.Entry<String, Integer> entry : commits.entrySet()) {
195 String key = entry.getKey();
196 int value = entry.getValue();
198 builder.append("\t");
199 builder.append(value);
200 builder.append(" commits ahead of ");
202 builder.append("\n");
205 builder.append("\t");
206 builder.append(value);
207 builder.append(" commits behind ");
209 builder.append("\n");
213 return builder.toString();