• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HotelsDotCom / waggle-dance / #367

24 Oct 2023 01:42PM UTC coverage: 73.44% (+0.01%) from 73.43%
#367

push

web-flow
Merge 9791dc13f into 63142df34

9 of 9 new or added lines in 3 files covered. (100.0%)

2389 of 3253 relevant lines covered (73.44%)

0.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.92
/waggle-dance-api/src/main/java/com/hotels/bdp/waggledance/api/model/AbstractMetaStore.java
1
/**
2
 * Copyright (C) 2016-2023 Expedia, Inc.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package com.hotels.bdp.waggledance.api.model;
17

18
import static com.hotels.bdp.waggledance.api.model.ConnectionType.DIRECT;
19
import static com.hotels.bdp.waggledance.api.model.ConnectionType.TUNNELED;
20

21
import java.beans.Transient;
22
import java.util.Collections;
23
import java.util.List;
24
import java.util.Map;
25

26
import javax.validation.Valid;
27
import javax.validation.constraints.NotBlank;
28
import javax.validation.constraints.NotNull;
29

30
import com.fasterxml.jackson.annotation.JsonIgnore;
31
import com.fasterxml.jackson.annotation.JsonProperty;
32
import com.fasterxml.jackson.annotation.JsonSubTypes;
33
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
34
import com.fasterxml.jackson.annotation.JsonTypeInfo;
35
import com.google.common.base.MoreObjects;
36
import com.google.common.base.Objects;
37
import com.google.common.collect.HashBiMap;
38

39
import com.hotels.hcommon.hive.metastore.client.tunnelling.MetastoreTunnel;
40

41
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "federationType")
42
@JsonSubTypes({
43
    @Type(value = PrimaryMetaStore.class, name = "PRIMARY"),
44
    @Type(value = FederatedMetaStore.class, name = "FEDERATED") })
45
public abstract class AbstractMetaStore {
46
  private String databasePrefix;
47
  private String hiveMetastoreFilterHook;
48
  private List<String> writableDatabaseWhitelist;
49
  private List<String> mappedDatabases;
50
  private @Valid List<MappedTables> mappedTables;
51
  private Map<String, String> databaseNameMapping = Collections.emptyMap();
1✔
52
  private @NotBlank String name;
53
  private String remoteMetaStoreUris;
54
  private @Valid MetastoreTunnel metastoreTunnel;
55
  private @NotNull AccessControlType accessControlType = AccessControlType.READ_ONLY;
1✔
56
  private transient @JsonProperty @NotNull MetaStoreStatus status = MetaStoreStatus.UNKNOWN;
1✔
57
  private long latency = 0;
1✔
58
  private transient @JsonIgnore HashBiMap<String, String> databaseNameBiMapping = HashBiMap.create();
1✔
59
  private GlueConfig glueConfig;
60

61
  public AbstractMetaStore() {}
1✔
62

63
  public AbstractMetaStore(String name, String remoteMetaStoreUris, AccessControlType accessControlType) {
×
64
    this.name = name;
×
65
    this.remoteMetaStoreUris = remoteMetaStoreUris;
×
66
    this.accessControlType = accessControlType;
×
67
  }
×
68

69
  public AbstractMetaStore(
70
      String name,
71
      String remoteMetaStoreUris,
72
      AccessControlType accessControlType,
73
      List<String> writableDatabaseWhitelist) {
1✔
74
    this.name = name;
1✔
75
    this.remoteMetaStoreUris = remoteMetaStoreUris;
1✔
76
    this.accessControlType = accessControlType;
1✔
77
    this.writableDatabaseWhitelist = writableDatabaseWhitelist;
1✔
78
  }
1✔
79

80
  public static FederatedMetaStore newFederatedInstance(String name, String remoteMetaStoreUris) {
81
    return new FederatedMetaStore(name, remoteMetaStoreUris);
1✔
82
  }
83

84
  public static PrimaryMetaStore newPrimaryInstance(
85
      String name,
86
      String remoteMetaStoreUris,
87
      AccessControlType accessControlType) {
88
    return new PrimaryMetaStore(name, remoteMetaStoreUris, accessControlType);
1✔
89
  }
90

91
  public static PrimaryMetaStore newPrimaryInstance(String name, String remoteMetaStoreUris) {
92
    return new PrimaryMetaStore(name, remoteMetaStoreUris, AccessControlType.READ_ONLY);
1✔
93
  }
94

95
  public String getDatabasePrefix() {
96
    return databasePrefix;
1✔
97
  }
98

99
  public void setDatabasePrefix(String databasePrefix) {
100
    this.databasePrefix = databasePrefix;
1✔
101
  }
1✔
102

103
  public String getHiveMetastoreFilterHook() {
104
    return hiveMetastoreFilterHook;
1✔
105
  }
106

107
  public void setHiveMetastoreFilterHook(String hiveMetastoreFilterHook) {
108
    this.hiveMetastoreFilterHook = hiveMetastoreFilterHook;
×
109
  }
×
110

111
  public String getName() {
112
    return name;
1✔
113
  }
114

115
  public void setName(String name) {
116
    this.name = name;
1✔
117
  }
1✔
118

119
  public String getRemoteMetaStoreUris() {
120
    return remoteMetaStoreUris;
1✔
121
  }
122

123
  public void setRemoteMetaStoreUris(String remoteMetaStoreUris) {
124
    this.remoteMetaStoreUris = remoteMetaStoreUris;
1✔
125
  }
1✔
126

127
  public MetastoreTunnel getMetastoreTunnel() {
128
    return metastoreTunnel;
1✔
129
  }
130

131
  public void setMetastoreTunnel(MetastoreTunnel metastoreTunnel) {
132
    this.metastoreTunnel = metastoreTunnel;
1✔
133
  }
1✔
134

135
  public ConnectionType getConnectionType() {
136
    if (getMetastoreTunnel() != null) {
1✔
137
      return TUNNELED;
×
138
    }
139
    return DIRECT;
1✔
140
  }
141

142
  abstract public FederationType getFederationType();
143

144
  public AccessControlType getAccessControlType() {
145
    return accessControlType;
1✔
146
  }
147

148
  public void setAccessControlType(AccessControlType accessControlType) {
149
    this.accessControlType = accessControlType;
1✔
150
  }
1✔
151

152
  public List<String> getWritableDatabaseWhiteList() {
153
    if (writableDatabaseWhitelist == null) {
1✔
154
      return Collections.emptyList();
1✔
155
    }
156
    return Collections.unmodifiableList(writableDatabaseWhitelist);
1✔
157
  }
158

159
  public void setWritableDatabaseWhiteList(List<String> writableDatabaseWhitelist) {
160
    this.writableDatabaseWhitelist = writableDatabaseWhitelist;
×
161
  }
×
162

163
  public long getLatency() {
164
    return latency;
1✔
165
  }
166

167
  public void setLatency(long latency) {
168
    this.latency = latency;
×
169
  }
×
170

171
  public List<String> getMappedDatabases() {
172
    return mappedDatabases;
1✔
173
  }
174

175
  public void setMappedDatabases(List<String> mappedDatabases) {
176
    this.mappedDatabases = mappedDatabases;
1✔
177
  }
1✔
178

179
  public List<MappedTables> getMappedTables() {
180
    return mappedTables;
1✔
181
  }
182

183
  public void setMappedTables(List<MappedTables> mappedTables) {
184
    this.mappedTables = mappedTables;
1✔
185
  }
1✔
186

187
  public Map<String, String> getDatabaseNameMapping() {
188
    return databaseNameMapping;
1✔
189
  }
190

191
  public void setDatabaseNameMapping(Map<String, String> databaseNameMapping) {
192
    if (databaseNameMapping == null) {
1✔
193
      databaseNameMapping = Collections.emptyMap();
1✔
194
    }
195
    this.databaseNameMapping = Collections.unmodifiableMap(databaseNameMapping);
1✔
196
    databaseNameBiMapping = HashBiMap.create(databaseNameMapping);
1✔
197
  }
1✔
198

199
  public GlueConfig getGlueConfig() {
200
    return glueConfig;
1✔
201
  }
202

203
  public void setGlueConfig(GlueConfig glueConfig) {
204
    this.glueConfig = glueConfig;
×
205
  }
×
206

207
  @Transient
208
  public HashBiMap<String, String> getDatabaseNameBiMapping() {
209
    return databaseNameBiMapping;
1✔
210
  }
211

212
  @Transient
213
  public MetaStoreStatus getStatus() {
214
    return status;
×
215
  }
216

217
  @Transient
218
  public void setStatus(MetaStoreStatus status) {
219
    this.status = status;
×
220
  }
×
221

222
  @Override
223
  public int hashCode() {
224
    return Objects.hashCode(name);
×
225
  }
226

227
  @Override
228
  public boolean equals(Object obj) {
229
    if (obj == null) {
1✔
230
      return false;
1✔
231
    }
232
    if (getClass() != obj.getClass()) {
×
233
      return false;
×
234
    }
235
    final AbstractMetaStore other = (AbstractMetaStore) obj;
×
236
    return Objects.equal(name, other.name);
×
237
  }
238

239
  @Override
240
  public String toString() {
241
    return MoreObjects
×
242
        .toStringHelper(this)
×
243
        .add("name", name)
×
244
        .add("databasePrefix", databasePrefix)
×
245
        .add("federationType", getFederationType())
×
246
        .add("remoteMetaStoreUris", remoteMetaStoreUris)
×
247
        .add("metastoreTunnel", metastoreTunnel)
×
248
        .add("accessControlType", accessControlType)
×
249
        .add("writableDatabaseWhiteList", writableDatabaseWhitelist)
×
250
        .add("latency", latency)
×
251
        .add("status", status)
×
252
        .toString();
×
253
  }
254

255
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc