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

HotelsDotCom / waggle-dance / #445

24 Jul 2025 02:27PM UTC coverage: 69.257% (-7.1%) from 76.395%
#445

push

patduin
Merge branch 'hive-3.x' of github.com:ExpediaGroup/waggle-dance into hive-3.x

2620 of 3783 relevant lines covered (69.26%)

0.69 hits per line

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

61.32
/waggle-dance-api/src/main/java/com/hotels/bdp/waggledance/api/model/AbstractMetaStore.java
1
/**
2
 * Copyright (C) 2016-2025 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.HashMap;
24
import java.util.List;
25
import java.util.Map;
26

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

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

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

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

65
  public AbstractMetaStore() {}
1✔
66

67
  public AbstractMetaStore(String name, String remoteMetaStoreUris, AccessControlType accessControlType) {
×
68
    this.name = name;
×
69
    this.remoteMetaStoreUris = remoteMetaStoreUris;
×
70
    this.accessControlType = accessControlType;
×
71
  }
×
72

73
  public AbstractMetaStore(
74
      String name,
75
      String remoteMetaStoreUris,
76
      AccessControlType accessControlType,
77
      List<String> writableDatabaseWhitelist) {
1✔
78
    this.name = name;
1✔
79
    this.remoteMetaStoreUris = remoteMetaStoreUris;
1✔
80
    this.accessControlType = accessControlType;
1✔
81
    this.writableDatabaseWhitelist = writableDatabaseWhitelist;
1✔
82
  }
1✔
83

84
  public AbstractMetaStore(
85
          String name,
86
          String remoteMetaStoreUris,
87
          String databasePrefix,
88
          AccessControlType accessControlType,
89
          List<String> writableDatabaseWhitelist) {
1✔
90
    this.name = name;
1✔
91
    this.remoteMetaStoreUris = remoteMetaStoreUris;
1✔
92
    this.databasePrefix = databasePrefix;
1✔
93
    this.accessControlType = accessControlType;
1✔
94
    this.writableDatabaseWhitelist = writableDatabaseWhitelist;
1✔
95
  }
1✔
96

97

98
  public static FederatedMetaStore newFederatedInstance(String name, String remoteMetaStoreUris) {
99
    return new FederatedMetaStore(name, remoteMetaStoreUris);
1✔
100
  }
101

102
  public static PrimaryMetaStore newPrimaryInstance(
103
      String name,
104
      String remoteMetaStoreUris,
105
      AccessControlType accessControlType) {
106
    return new PrimaryMetaStore(name, remoteMetaStoreUris, accessControlType);
1✔
107
  }
108

109
  public static PrimaryMetaStore newPrimaryInstance(String name, String remoteMetaStoreUris) {
110
    return new PrimaryMetaStore(name, remoteMetaStoreUris, AccessControlType.READ_ONLY);
1✔
111
  }
112

113
  public static PrimaryMetaStore newPrimaryInstance(
114
          String name,
115
          String remoteMetaStoreUris,
116
          String databasePrefix,
117
          AccessControlType accessControlType) {
118
    return new PrimaryMetaStore(name, remoteMetaStoreUris, databasePrefix, accessControlType);
1✔
119
  }
120

121
  public String getDatabasePrefix() {
122
    return databasePrefix;
1✔
123
  }
124

125
  public void setDatabasePrefix(String databasePrefix) {
126
    this.databasePrefix = databasePrefix;
1✔
127
  }
1✔
128

129
  public String getHiveMetastoreFilterHook() {
130
    return hiveMetastoreFilterHook;
1✔
131
  }
132

133
  public void setHiveMetastoreFilterHook(String hiveMetastoreFilterHook) {
134
    this.hiveMetastoreFilterHook = hiveMetastoreFilterHook;
×
135
  }
×
136

137
  public String getName() {
138
    return name;
1✔
139
  }
140

141
  public void setName(String name) {
142
    this.name = name;
1✔
143
  }
1✔
144

145
  public String getRemoteMetaStoreUris() {
146
    return remoteMetaStoreUris;
1✔
147
  }
148

149
  public void setRemoteMetaStoreUris(String remoteMetaStoreUris) {
150
    this.remoteMetaStoreUris = remoteMetaStoreUris;
1✔
151
  }
1✔
152

153
  public String getReadOnlyRemoteMetaStoreUris() {
154
    return readOnlyRemoteMetaStoreUris;
1✔
155
  }
156
  
157
  public void setReadOnlyRemoteMetaStoreUris(String readOnlyRemoteMetaStoreUris) {
158
    this.readOnlyRemoteMetaStoreUris = readOnlyRemoteMetaStoreUris;
×
159
  }
×
160
  
161
  public MetastoreTunnel getMetastoreTunnel() {
162
    return metastoreTunnel;
1✔
163
  }
164

165
  public void setMetastoreTunnel(MetastoreTunnel metastoreTunnel) {
166
    this.metastoreTunnel = metastoreTunnel;
1✔
167
  }
1✔
168

169
  public ConnectionType getConnectionType() {
170
    if (getMetastoreTunnel() != null) {
1✔
171
      return TUNNELED;
×
172
    }
173
    return DIRECT;
1✔
174
  }
175

176
  abstract public FederationType getFederationType();
177

178
  public AccessControlType getAccessControlType() {
179
    return accessControlType;
1✔
180
  }
181

182
  public void setAccessControlType(AccessControlType accessControlType) {
183
    this.accessControlType = accessControlType;
1✔
184
  }
1✔
185

186
  public List<String> getWritableDatabaseWhiteList() {
187
    if (writableDatabaseWhitelist == null) {
1✔
188
      return Collections.emptyList();
1✔
189
    }
190
    return Collections.unmodifiableList(writableDatabaseWhitelist);
1✔
191
  }
192

193
  public void setWritableDatabaseWhiteList(List<String> writableDatabaseWhitelist) {
194
    this.writableDatabaseWhitelist = writableDatabaseWhitelist;
×
195
  }
×
196

197
  public long getLatency() {
198
    return latency;
1✔
199
  }
200

201
  public void setLatency(long latency) {
202
    this.latency = latency;
×
203
  }
×
204

205
  public List<String> getMappedDatabases() {
206
    return mappedDatabases;
1✔
207
  }
208

209
  public void setMappedDatabases(List<String> mappedDatabases) {
210
    this.mappedDatabases = mappedDatabases;
1✔
211
  }
1✔
212

213
  public List<MappedTables> getMappedTables() {
214
    return mappedTables;
1✔
215
  }
216

217
  public void setMappedTables(List<MappedTables> mappedTables) {
218
    this.mappedTables = mappedTables;
1✔
219
  }
1✔
220

221
  public Map<String, String> getDatabaseNameMapping() {
222
    return databaseNameMapping;
1✔
223
  }
224

225
  public void setDatabaseNameMapping(Map<String, String> databaseNameMapping) {
226
    if (databaseNameMapping == null) {
1✔
227
      databaseNameMapping = Collections.emptyMap();
1✔
228
    }
229
    this.databaseNameMapping = Collections.unmodifiableMap(databaseNameMapping);
1✔
230
    databaseNameBiMapping = HashBiMap.create(databaseNameMapping);
1✔
231
  }
1✔
232

233
  public GlueConfig getGlueConfig() {
234
    return glueConfig;
1✔
235
  }
236

237
  public void setGlueConfig(GlueConfig glueConfig) {
238
    this.glueConfig = glueConfig;
×
239
  }
×
240

241
  @Transient
242
  public HashBiMap<String, String> getDatabaseNameBiMapping() {
243
    return databaseNameBiMapping;
1✔
244
  }
245

246
  public Map<String, String> getConfigurationProperties() {
247
    return configurationProperties;
1✔
248
  }
249

250
  public void setConfigurationProperties(
251
          Map<String, String> configurationProperties) {
252
    this.configurationProperties = configurationProperties;
×
253
  }
×
254
  
255
  @Transient
256
  public MetaStoreStatus getStatus() {
257
    return status;
×
258
  }
259

260
  @Transient
261
  public void setStatus(MetaStoreStatus status) {
262
    this.status = status;
×
263
  }
×
264

265
  public boolean isImpersonationEnabled() {
266
    return impersonationEnabled;
1✔
267
  }
268

269
  public void setImpersonationEnabled(boolean impersonationEnabled) {
270
    this.impersonationEnabled = impersonationEnabled;
×
271
  }
×
272

273
  @Override
274
  public int hashCode() {
275
    return Objects.hashCode(name);
×
276
  }
277

278
  @Override
279
  public boolean equals(Object obj) {
280
    if (obj == null) {
1✔
281
      return false;
1✔
282
    }
283
    if (getClass() != obj.getClass()) {
×
284
      return false;
×
285
    }
286
    final AbstractMetaStore other = (AbstractMetaStore) obj;
×
287
    return Objects.equal(name, other.name);
×
288
  }
289

290
  @Override
291
  public String toString() {
292
    return MoreObjects
×
293
        .toStringHelper(this)
×
294
        .add("name", name)
×
295
        .add("databasePrefix", databasePrefix)
×
296
        .add("federationType", getFederationType())
×
297
        .add("remoteMetaStoreUris", remoteMetaStoreUris)
×
298
        .add("readOnlyRemoteMetaStoreUris", readOnlyRemoteMetaStoreUris)
×
299
        .add("metastoreTunnel", metastoreTunnel)
×
300
        .add("accessControlType", accessControlType)
×
301
        .add("writableDatabaseWhiteList", writableDatabaseWhitelist)
×
302
        .add("latency", latency)
×
303
        .add("status", status)
×
304
        .toString();
×
305
  }
306
}
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

© 2026 Coveralls, Inc