1 /*******************************************************************************
2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
17 ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlAkka;
20 import java.util.regex.Matcher;
21 import java.util.regex.Pattern;
23 public class ClusterNodeInfo {
24 private final String protocol;
25 private final String clusterName;
26 private final String remoteAdr;
27 private final int port;
28 private final String seedNodeName;
30 public static ClusterNodeInfo defaultSingleNodeInfo() {
31 return new ClusterNodeInfo("akka.tcp","opendaylight-cluster-data","127.0.0.1",2550);
34 public ClusterNodeInfo(String s) throws Exception {
35 final String regex = "([a-z.]*):\\/\\/([a-zA-Z0-9-]*)@([a-zA-Z0-9.-]*):([0-9]*)";
36 final Pattern pattern = Pattern.compile(regex);
37 final Matcher matcher = pattern.matcher(s);
38 if (!matcher.find()) {
39 throw new Exception("invalid seedNode format");
41 this.seedNodeName = matcher.group();
42 this.protocol = matcher.group(1);
43 this.clusterName = matcher.group(2);
44 this.remoteAdr = matcher.group(3);
45 this.port = Integer.parseInt(matcher.group(4));
48 public ClusterNodeInfo(String protocol, String clustername, String remoteadr, int port) {
49 this.protocol=protocol;
50 this.clusterName=clustername;
51 this.remoteAdr=remoteadr;
53 this.seedNodeName=this.protocol+"://"+this.clusterName+"@"+this.remoteAdr+":"+this.port;
56 public String getProtocol() {
60 public String getClusterName() {
64 public String getRemoteAddress() {
67 public String getSeedNodeName() {
71 public int getPort() {
76 public String toString() {
77 return "ClusterNodeInfo [protocol=" + protocol + ", clusterName=" + clusterName + ", remoteAdr=" + remoteAdr
78 + ", port=" + port + ", seedNodeName=" + seedNodeName + "]";