Skip to content

Commit 6ab64f9

Browse files
committed
Renamed admin artifact to redis-enterprise-admin
1 parent 76caac8 commit 6ab64f9

File tree

16 files changed

+93
-52
lines changed

16 files changed

+93
-52
lines changed

jreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ checksum:
9292
files: false
9393

9494
distributions:
95-
admin:
95+
redis-enterprise-admin:
9696
artifacts:
9797
- path: subprojects/{{distributionName}}/build/distributions/{{distributionName}}-{{projectVersion}}.zip
9898
transform: '{{distributionName}}/{{distributionName}}-{{projectEffectiveVersion}}.zip'
File renamed without changes.

subprojects/admin/admin.gradle renamed to subprojects/redis-enterprise-admin/redis-enterprise-admin.gradle

File renamed without changes.

subprojects/admin/src/main/java/com/redis/enterprise/Admin.java renamed to subprojects/redis-enterprise-admin/src/main/java/com/redis/enterprise/Admin.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@
5050
import com.fasterxml.jackson.databind.DeserializationFeature;
5151
import com.fasterxml.jackson.databind.JavaType;
5252
import com.fasterxml.jackson.databind.ObjectMapper;
53-
import com.fasterxml.jackson.databind.type.CollectionType;
5453
import com.fasterxml.jackson.databind.type.SimpleType;
54+
import com.redis.enterprise.Database.ModuleConfig;
5555
import com.redis.enterprise.rest.Action;
5656
import com.redis.enterprise.rest.Bootstrap;
57-
import com.redis.enterprise.rest.Command;
5857
import com.redis.enterprise.rest.CommandResponse;
59-
import com.redis.enterprise.rest.Database;
60-
import com.redis.enterprise.rest.Database.ModuleConfig;
61-
import com.redis.enterprise.rest.Module;
58+
import com.redis.enterprise.rest.InstalledModule;
6259
import com.redis.enterprise.rest.ModuleInstallResponse;
6360

6461
public class Admin implements AutoCloseable {
@@ -163,6 +160,7 @@ private <T> T post(String path, Object request, Class<T> responseType) throws Pa
163160
private <T> T post(String path, Object request, JavaType responseType) throws ParseException, IOException {
164161
HttpPost post = new HttpPost(uri(path));
165162
String json = objectMapper.writeValueAsString(request);
163+
log.debug("POST {}", json);
166164
post.setEntity(new StringEntity(json));
167165
return read(header(post), responseType, HttpStatus.SC_OK);
168166
}
@@ -183,14 +181,14 @@ private <T> T read(ClassicHttpRequest request, JavaType type, int successCode) t
183181
throw new HttpResponseException(response.getCode(), response.getReasonPhrase() + " " + json);
184182
}
185183

186-
public List<Module> getModules() throws ParseException, IOException {
187-
CollectionType type = objectMapper.getTypeFactory().constructCollectionType(List.class, Module.class);
188-
return get(v1(MODULES), type);
184+
public List<InstalledModule> getModules() throws ParseException, IOException {
185+
return get(v1(MODULES),
186+
objectMapper.getTypeFactory().constructCollectionType(List.class, InstalledModule.class));
189187
}
190188

191189
public Database createDatabase(Database database) throws ParseException, IOException {
192-
Map<String, Module> installedModules = new HashMap<>();
193-
for (Module module : getModules()) {
190+
Map<String, InstalledModule> installedModules = new HashMap<>();
191+
for (InstalledModule module : getModules()) {
194192
installedModules.put(module.getName(), module);
195193
}
196194
for (ModuleConfig moduleConfig : database.getModules()) {
@@ -201,7 +199,7 @@ public Database createDatabase(Database database) throws ParseException, IOExcep
201199
}
202200
Database response = post(v1(BDBS), database, Database.class);
203201
long uid = response.getUid();
204-
Awaitility.await().until(() -> {
202+
Awaitility.await().pollInterval(Duration.ofSeconds(1)).until(() -> {
205203
Command command = new Command();
206204
command.setCommand("PING");
207205
try {
@@ -215,12 +213,11 @@ public Database createDatabase(Database database) throws ParseException, IOExcep
215213
}
216214

217215
public List<Database> getDatabases() throws ParseException, IOException {
218-
CollectionType type = objectMapper.getTypeFactory().constructCollectionType(List.class, Database.class);
219-
return get(v1(BDBS), type);
216+
return get(v1(BDBS), objectMapper.getTypeFactory().constructCollectionType(List.class, Database.class));
220217
}
221218

222219
public void deleteDatabase(long uid) {
223-
Awaitility.await().timeout(Duration.ofSeconds(30)).pollInterval(Duration.ofSeconds(1)).until(() -> {
220+
Awaitility.await().pollInterval(Duration.ofSeconds(1)).until(() -> {
224221
try {
225222
delete(v1(BDBS, String.valueOf(uid)), Database.class);
226223
return true;
@@ -246,7 +243,7 @@ public ModuleInstallResponse installModule(String filename, InputStream inputStr
246243
ModuleInstallResponse response = read(post, SimpleType.constructUnsafe(ModuleInstallResponse.class),
247244
HttpStatus.SC_ACCEPTED);
248245
baos.close();
249-
Awaitility.await().timeout(Duration.ofSeconds(30)).pollInterval(Duration.ofSeconds(3)).until(() -> {
246+
Awaitility.await().timeout(Duration.ofMinutes(1)).pollInterval(Duration.ofSeconds(1)).until(() -> {
250247
log.info("Checking status of action {}", response.getActionUid());
251248
Action status = getAction(response.getActionUid());
252249
if ("completed".equals(status.getStatus())) {
@@ -259,7 +256,7 @@ public ModuleInstallResponse installModule(String filename, InputStream inputStr
259256
}
260257

261258
public void waitForBoostrap() {
262-
Awaitility.await().pollInterval(Duration.ofSeconds(3)).timeout(Duration.ofMinutes(1))
259+
Awaitility.await().pollInterval(Duration.ofSeconds(1)).timeout(Duration.ofMinutes(1))
263260
.until(() -> "idle".equals(getBootstrap().getStatus().getState()));
264261

265262
}
@@ -268,7 +265,7 @@ private Bootstrap getBootstrap() throws ParseException, IOException {
268265
return get(v1(BOOTSTRAP), Bootstrap.class);
269266
}
270267

271-
public Action getAction(String uid) throws ParseException, IOException {
268+
private Action getAction(String uid) throws ParseException, IOException {
272269
return get(v1(ACTIONS, uid), Action.class);
273270
}
274271

subprojects/admin/src/main/java/com/redis/enterprise/rest/Command.java renamed to subprojects/redis-enterprise-admin/src/main/java/com/redis/enterprise/Command.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.redis.enterprise.rest;
1+
package com.redis.enterprise;
22

33
import java.util.ArrayList;
44
import java.util.List;

subprojects/admin/src/main/java/com/redis/enterprise/rest/Database.java renamed to subprojects/redis-enterprise-admin/src/main/java/com/redis/enterprise/Database.java

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
package com.redis.enterprise.rest;
1+
package com.redis.enterprise;
22

33
import java.util.ArrayList;
44
import java.util.Arrays;
55
import java.util.List;
6+
import java.util.Objects;
67
import java.util.stream.Collectors;
78

89
import org.apache.hc.core5.util.Asserts;
@@ -67,15 +68,15 @@ public void setName(String name) {
6768
this.name = name;
6869
}
6970

70-
public boolean getReplication() {
71+
public boolean isReplication() {
7172
return replication;
7273
}
7374

7475
public void setReplication(boolean replication) {
7576
this.replication = replication;
7677
}
7778

78-
public boolean getSharding() {
79+
public boolean isSharding() {
7980
return sharding;
8081
}
8182

@@ -109,7 +110,7 @@ public void setType(String type) {
109110
}
110111

111112
@JsonProperty("oss_cluster")
112-
public boolean getOssCluster() {
113+
public boolean isOssCluster() {
113114
return ossCluster;
114115
}
115116

@@ -171,6 +172,29 @@ public void setModules(List<ModuleConfig> modules) {
171172
this.modules = modules;
172173
}
173174

175+
@Override
176+
public int hashCode() {
177+
return Objects.hash(memory, modules, name, ossCluster, ossClusterAPIPreferredIPType, port, proxyPolicy,
178+
replication, shardCount, shardKeyRegex, shardPlacement, sharding, type, uid);
179+
}
180+
181+
@Override
182+
public boolean equals(Object obj) {
183+
if (this == obj)
184+
return true;
185+
if (obj == null)
186+
return false;
187+
if (getClass() != obj.getClass())
188+
return false;
189+
Database other = (Database) obj;
190+
return memory == other.memory && Objects.equals(modules, other.modules) && Objects.equals(name, other.name)
191+
&& ossCluster == other.ossCluster && ossClusterAPIPreferredIPType == other.ossClusterAPIPreferredIPType
192+
&& Objects.equals(port, other.port) && proxyPolicy == other.proxyPolicy
193+
&& replication == other.replication && Objects.equals(shardCount, other.shardCount)
194+
&& Objects.equals(shardKeyRegex, other.shardKeyRegex) && shardPlacement == other.shardPlacement
195+
&& sharding == other.sharding && Objects.equals(type, other.type) && Objects.equals(uid, other.uid);
196+
}
197+
174198
public enum IPType {
175199
@JsonProperty("internal")
176200
INTERNAL, @JsonProperty("external")
@@ -368,13 +392,13 @@ public Builder shardPlacement(ShardPlacement shardPlacement) {
368392
return this;
369393
}
370394

371-
public Builder module(Module module) {
372-
this.moduleConfigs.add(new ModuleConfig(module.getName()));
395+
public Builder module(RedisModule module) {
396+
this.moduleConfigs.add(new ModuleConfig(module.getModuleName()));
373397
return this;
374398
}
375399

376-
public Builder modules(Module... modules) {
377-
for (Module module : modules) {
400+
public Builder modules(RedisModule... modules) {
401+
for (RedisModule module : modules) {
378402
module(module);
379403
}
380404
return this;
@@ -394,20 +418,5 @@ public Database build() {
394418
return new Database(this);
395419
}
396420

397-
public enum Module {
398-
399-
BLOOM("bf"), GEARS("rg"), GRAPH("graph"), JSON("ReJSON"), SEARCH("search"), TIMESERIES("timeseries");
400-
401-
private final String name;
402-
403-
Module(String name) {
404-
this.name = name;
405-
}
406-
407-
public String getName() {
408-
return name;
409-
}
410-
411-
}
412421
}
413422
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.redis.enterprise;
2+
3+
public enum RedisModule {
4+
5+
BLOOM("bf"), GEARS("rg"), GRAPH("graph"), JSON("ReJSON"), SEARCH("search"), TIMESERIES("timeseries");
6+
7+
private final String moduleName;
8+
9+
RedisModule(String moduleName) {
10+
this.moduleName = moduleName;
11+
}
12+
13+
public String getModuleName() {
14+
return moduleName;
15+
}
16+
17+
}

subprojects/admin/src/main/java/com/redis/enterprise/rest/Action.java renamed to subprojects/redis-enterprise-admin/src/main/java/com/redis/enterprise/rest/Action.java

File renamed without changes.

subprojects/admin/src/main/java/com/redis/enterprise/rest/Bootstrap.java renamed to subprojects/redis-enterprise-admin/src/main/java/com/redis/enterprise/rest/Bootstrap.java

File renamed without changes.

subprojects/admin/src/main/java/com/redis/enterprise/rest/CommandResponse.java renamed to subprojects/redis-enterprise-admin/src/main/java/com/redis/enterprise/rest/CommandResponse.java

File renamed without changes.

0 commit comments

Comments
 (0)