2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.dmaap.dbcapi.model;
23 import javax.xml.bind.annotation.XmlRootElement;
25 import org.onap.dmaap.dbcapi.util.DmaapConfig;
26 import org.onap.dmaap.dbcapi.util.DmaapTimestamp;
31 public class MR_Cluster extends DmaapObject {
33 private String dcaeLocationName;
35 private DmaapTimestamp lastMod;
36 private String topicProtocol;
37 private String topicPort;
38 private String replicationGroup;
39 private String sourceReplicationPort;
40 private String targetReplicationPort;
43 // TODO: make this a system property
44 private static String defaultTopicProtocol;
45 private static String defaultTopicPort;
46 private static String defaultReplicationGroup;
47 private static String defaultSourceReplicationPort;
48 private static String defaultTargetReplicationPort;
50 private static void setDefaults() {
51 /* boolean been_here = false;
55 DmaapConfig dc = (DmaapConfig)DmaapConfig.getConfig();
56 defaultTopicProtocol = dc.getProperty("MR.TopicProtocol", "https");
57 defaultTopicPort = dc.getProperty( "MR.TopicPort", "3905");
58 defaultReplicationGroup = dc.getProperty( "MR.ReplicationGroup", "" );
59 defaultSourceReplicationPort = dc.getProperty( "MR.SourceReplicationPort", "2181");
60 defaultTargetReplicationPort = dc.getProperty( "MR.TargetReplicationPort", "9092");
67 this.topicProtocol = defaultTopicProtocol;
68 this.topicPort = defaultTopicPort;
69 this.replicationGroup = null;
70 this.sourceReplicationPort = defaultSourceReplicationPort;
71 this.targetReplicationPort = defaultTargetReplicationPort;
72 this.lastMod = new DmaapTimestamp();
75 debugLogger.debug( "MR_Cluster constructor " + this.lastMod );
79 // new style constructor
80 public MR_Cluster( String dLN,
85 this.dcaeLocationName = dLN;
88 if ( prot == null || prot.isEmpty() ) {
89 this.topicProtocol = defaultTopicProtocol;
91 this.topicProtocol = prot;
93 if ( port == null || port.isEmpty() ) {
94 this.topicPort = defaultTopicPort;
96 this.topicPort = port;
99 this.replicationGroup = defaultReplicationGroup;
100 this.sourceReplicationPort = defaultSourceReplicationPort;
101 this.targetReplicationPort = defaultTargetReplicationPort;
103 this.lastMod = new DmaapTimestamp();
106 debugLogger.debug( "MR_Cluster constructor w initialization complete" + this.lastMod.getVal() );
109 public MR_Cluster( String dLN,
114 String sourceRepPort,
115 String targetRepPort ) {
117 this.dcaeLocationName = dLN;
120 if ( prot == null || prot.isEmpty() ) {
121 this.topicProtocol = defaultTopicProtocol;
123 this.topicProtocol = prot;
125 if ( port == null || port.isEmpty() ) {
126 this.topicPort = defaultTopicPort;
128 this.topicPort = port;
130 if ( repGroup == null || repGroup.isEmpty() ) {
131 this.replicationGroup = defaultReplicationGroup;
133 this.replicationGroup = repGroup;
135 if ( sourceRepPort == null || sourceRepPort.isEmpty()) {
136 this.sourceReplicationPort = defaultSourceReplicationPort;
138 this.sourceReplicationPort = sourceRepPort;
140 if ( targetRepPort == null || targetRepPort.isEmpty()) {
141 this.targetReplicationPort = defaultTargetReplicationPort;
143 this.targetReplicationPort = targetRepPort;
146 this.lastMod = new DmaapTimestamp();
149 debugLogger.debug( "MR_Cluster constructor w initialization complete" + this.lastMod.getVal() );
151 public String getDcaeLocationName() {
152 return dcaeLocationName;
155 public void setDcaeLocationName(String dcaeLocationName) {
156 this.dcaeLocationName = dcaeLocationName;
159 public String getFqdn() {
163 public void setFqdn(String fqdn) {
168 public String getTopicProtocol() {
169 return topicProtocol;
172 public void setTopicProtocol(String topicProtocol) {
173 this.topicProtocol = topicProtocol;
176 public String getTopicPort() {
180 public void setTopicPort(String topicPort) {
181 this.topicPort = topicPort;
184 public String getReplicationGroup() {
185 return replicationGroup;
188 public void setReplicationGroup(String replicationGroup) {
189 this.replicationGroup = replicationGroup;
195 public String getSourceReplicationPort() {
196 return sourceReplicationPort;
201 public void setSourceReplicationPort(String sourceReplicationPort) {
202 this.sourceReplicationPort = sourceReplicationPort;
207 public String getTargetReplicationPort() {
208 return targetReplicationPort;
213 public void setTargetReplicationPort(String targetReplicationPort) {
214 this.targetReplicationPort = targetReplicationPort;
219 public String genTopicURL(String overideFqdn, String topic) {
221 StringBuilder str = new StringBuilder( topicProtocol );
223 .append( overideFqdn != null ? overideFqdn : fqdn)
229 return str.toString();