including missing files
[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 import org.onap.dmaap.dbcapi.util.DmaapTimestamp;
28
29
30
31 @XmlRootElement
32 public class MR_Cluster extends DmaapObject {
33
34         private String dcaeLocationName;
35         private String fqdn;
36         private String[] hosts;
37         private DmaapTimestamp lastMod;
38         private String  topicProtocol;
39         private String  topicPort;
40
41         
42         // TODO: make this a system property
43         private static String defaultTopicProtocol = "https";
44         private static String defaultTopicPort = "3905";
45         
46
47
48
49         public MR_Cluster() {
50                 this.topicProtocol = defaultTopicProtocol;
51                 this.topicPort = defaultTopicPort;
52                 this.hosts = new String[3];
53                 this.lastMod = new DmaapTimestamp();
54                 this.lastMod.mark();
55
56                 debugLogger.debug( "MR_Cluster constructor " + this.lastMod );
57                 
58         }
59         
60         public MR_Cluster( String dLN,
61                                                 String f,
62                                                 String a,
63                                                 String[] h ) {
64                 this.dcaeLocationName = dLN;
65                 this.fqdn = f;
66 logger.info( "templog:MR_Cluster at 10" );
67                 this.hosts = new String[3];
68                 this.hosts[0] = h[0];
69 logger.info( "templog:MR_Cluster at 20" );
70                 this.hosts[1] = h[1];
71 logger.info( "templog:MR_Cluster at 30" );
72                 this.hosts[2] = h[2];
73 logger.info( "templog:MR_Cluster at 40" );
74                 this.topicProtocol = defaultTopicProtocol;
75 logger.info( "templog:MR_Cluster at 50" );
76                 this.topicPort = defaultTopicPort;
77                 this.lastMod = new DmaapTimestamp();
78                 this.lastMod.mark();
79
80                 debugLogger.debug( "MR_Cluster constructor w initialization complete" + this.lastMod.getVal() );
81 logger.info( "templog:MR_Cluster at 60" );
82         }
83
84         public String getDcaeLocationName() {
85                 return dcaeLocationName;
86         }
87
88         public void setDcaeLocationName(String dcaeLocationName) {
89                 this.dcaeLocationName = dcaeLocationName;
90         }
91
92         public String getFqdn() {
93                 return fqdn;
94         }
95
96         public void setFqdn(String fqdn) {
97                 this.fqdn = fqdn;
98         }
99
100         public String[] getHosts() {
101                 return hosts;
102         }
103
104         public void setHosts(String[] hosts) {
105                 this.hosts = hosts;
106         }
107
108         public String getTopicProtocol() {
109                 return topicProtocol;
110         }
111
112         public void setTopicProtocol(String topicProtocol) {
113                 this.topicProtocol = topicProtocol;
114         }
115
116         public String getTopicPort() {
117                 return topicPort;
118         }
119
120         public void setTopicPort(String topicPort) {
121                 this.topicPort = topicPort;
122         }
123
124
125
126         public String genTopicURL(String overideFqdn, String topic) {
127
128                 StringBuilder str = new StringBuilder( topicProtocol );
129                 str.append("://")
130                         .append( overideFqdn != null ? overideFqdn : fqdn)
131                         .append(":")
132                         .append(topicPort)
133                         .append("/events/")
134                         .append(topic);
135                 
136                 return str.toString();
137
138
139         }
140
141
142 }