DMAAP-83 Initial code import
[dmaap/dbcapi.git] / src / main / java / org / onap / dmaap / dbcapi / model / MR_Cluster.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.onap.dmaap
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.dmaap.dbcapi.model;
22
23 import java.util.Date;
24
25 import javax.xml.bind.annotation.XmlRootElement;
26
27
28
29 @XmlRootElement
30 public class MR_Cluster extends DmaapObject {
31
32         private String dcaeLocationName;
33         private String fqdn;
34         private String[] hosts;
35         //private       DmaapTimestamp lastMod;
36         private String  topicProtocol;
37         private String  topicPort;
38
39         
40         // TODO: make this a system property
41         private static String defaultTopicProtocol = "https";
42         private static String defaultTopicPort = "3905";
43         
44
45
46
47         public MR_Cluster() {
48                 this.topicProtocol = defaultTopicProtocol;
49                 this.topicPort = defaultTopicPort;
50                 this.lastMod = new Date();
51
52                 debugLogger.debug( "MR_Cluster constructor " + this.lastMod );
53                 
54         }
55         
56         public MR_Cluster( String dLN,
57                                                 String f,
58                                                 String a,
59                                                 String[] h ) {
60                 this.dcaeLocationName = dLN;
61                 this.fqdn = f;
62                 this.hosts[0] = h[0];
63                 this.hosts[1] = h[1];
64                 this.hosts[2] = h[2];
65                 this.topicProtocol = defaultTopicProtocol;
66                 this.topicPort = defaultTopicPort;
67
68                 debugLogger.debug( "MR_Cluster constructor w initialization complete" + this.lastMod );
69         }
70
71         public String getDcaeLocationName() {
72                 return dcaeLocationName;
73         }
74
75         public void setDcaeLocationName(String dcaeLocationName) {
76                 this.dcaeLocationName = dcaeLocationName;
77         }
78
79         public String getFqdn() {
80                 return fqdn;
81         }
82
83         public void setFqdn(String fqdn) {
84                 this.fqdn = fqdn;
85         }
86
87         public String[] getHosts() {
88                 return hosts;
89         }
90
91         public void setHosts(String[] hosts) {
92                 this.hosts = hosts;
93         }
94
95         public String getTopicProtocol() {
96                 return topicProtocol;
97         }
98
99         public void setTopicProtocol(String topicProtocol) {
100                 this.topicProtocol = topicProtocol;
101         }
102
103         public String getTopicPort() {
104                 return topicPort;
105         }
106
107         public void setTopicPort(String topicPort) {
108                 this.topicPort = topicPort;
109         }
110
111
112
113         public String genTopicURL(String overideFqdn, String topic) {
114
115                 StringBuilder str = new StringBuilder( topicProtocol );
116                 str.append("://")
117                         .append( overideFqdn != null ? overideFqdn : fqdn)
118                         .append(":")
119                         .append(topicPort)
120                         .append("/events/")
121                         .append(topic);
122                 
123                 return str.toString();
124
125
126         }
127
128
129 }