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.grtoolkit.data;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
30 * A data container with information about an actor in the Akka cluster.
32 * @author Anthony Haddox
34 public class ClusterActor {
36 private String member;
38 private String akkaPort;
39 private boolean voting;
41 private boolean unreachable;
42 private ArrayList<String> shardLeader;
43 private ArrayList<String> replicaShards;
44 private ArrayList<String> nonReplicaShards;
45 private HashMap<String, Integer> commits;
47 public static final String SITE_1 = "Site 1";
48 public static final String SITE_2 = "Site 2";
50 public ClusterActor() {
57 shardLeader = new ArrayList<>();
58 replicaShards = new ArrayList<>();
59 nonReplicaShards = new ArrayList<>();
60 commits = new HashMap<>();
63 public String getNode() {
67 public void setNode(String node) {
71 public String getMember() {
75 public void setMember(String member) {
79 public String getSite() {
83 public void setSite(String site) {
87 public String getAkkaPort() {
91 public void setAkkaPort(String akkaPort) {
92 this.akkaPort = akkaPort;
95 public boolean isVoting() {
99 public void setVoting(boolean voting) {
100 this.voting = voting;
103 public boolean isUp() {
107 public void setUp(boolean up) {
111 public boolean isUnreachable() {
115 public void setUnreachable(boolean unreachable) {
116 this.unreachable = unreachable;
119 public List<String> getShardLeader() {
123 public void setShardLeader(List<String> shardLeader) {
124 this.shardLeader = (ArrayList<String>) shardLeader;
127 public List<String> getReplicaShards() {
128 return replicaShards;
131 public void setReplicaShards(List<String> replicaShards) {
132 this.replicaShards = (ArrayList<String>) replicaShards;
135 public List<String> getNonReplicaShards() {
136 return nonReplicaShards;
139 public void setNonReplicaShards(List<String> nonReplicaShards) {
140 this.nonReplicaShards = (ArrayList<String>) nonReplicaShards;
143 public Map<String, Integer> getCommits() {
147 public void setCommits(Map<String, Integer> commits) {
148 this.commits = (HashMap<String, Integer>) commits;
151 public void flush() {
153 replicaShards.clear();
154 nonReplicaShards.clear();
159 public String toString() {
160 StringBuilder builder = new StringBuilder();
161 builder.append("[ ");
162 builder.append(this.member);
163 builder.append(" ] ");
165 builder.append(this.node);
167 builder.append(this.akkaPort);
168 builder.append(" is");
170 builder.append(" Up");
172 builder.append(" Down");
174 builder.append(" [ UNREACHABLE ]");
175 return builder.toString();
179 builder.append(" (Voting)");
181 builder.append("\n");
183 for(String l : this.shardLeader) {
184 builder.append("\tLeader: ");
186 builder.append("\n");
189 for(String r : this.replicaShards) {
190 builder.append("\tReplicating: ");
192 builder.append("\n");
195 for(String n : this.nonReplicaShards) {
196 builder.append("\tNot replicating: ");
198 builder.append("\n");
201 for(Map.Entry<String, Integer> entry : commits.entrySet()) {
202 String key = entry.getKey();
203 int value = entry.getValue();
205 builder.append("\t");
206 builder.append(value);
207 builder.append(" commits ahead of ");
209 builder.append("\n");
212 builder.append("\t");
213 builder.append(value);
214 builder.append(" commits behind ");
216 builder.append("\n");
220 return builder.toString();