Skip to content

Commit

Permalink
Implement Redis Hash functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
obabec committed Jul 29, 2024
1 parent e628c81 commit 5c6ce79
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 14 deletions.
6 changes: 3 additions & 3 deletions database-manipulation-tool-schema/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>

<dependencies>
Expand Down
9 changes: 7 additions & 2 deletions database-manipulation-tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ You can reset all databases on DMT start with property `onstart.reset.database`.
<summary><code>POST</code> <code><b>/Main/GenerateBatchLoad?count={count}&maxRows={maxRows}</b></code> <code>(Same as GenerateLoad but uses batch statements for better performance)</code></summary>
<br />
<summary>
<code>GET</code>
<code>POST</code>
<code><b>/Redis/pollMessages?max=5</b></code>
<code>
[
Expand All @@ -107,7 +107,7 @@ You can reset all databases on DMT start with property `onstart.reset.database`.
<code>Reads at most 'max' messages from specified channels</code>
</summary>
<summary>
<code>GET</code>
<code>POST</code>
<code><b>/Redis/sendMessage?channel=channel1</b></code>
<code>
{
Expand All @@ -123,6 +123,11 @@ You can reset all databases on DMT start with property `onstart.reset.database`.
<code><b>/Redis/reset</b></code>
<code>Flush whole Redis instance</code>
</summary>
<summary>
<code>GET</code>
<code><b>/Redis/readHash?hashKey=hash1</b></code>
<code>Returns all messages stored under 'hashKey'</code>
</summary>

## Running the application in dev mode

Expand Down
4 changes: 2 additions & 2 deletions database-manipulation-tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@

<properties>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
Expand Down
2 changes: 1 addition & 1 deletion database-manipulation-tool/src/main/docker/Dockerfile.jvm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
# accessed directly. (example: "foo.example.com,bar.example.com")
#
###
FROM registry.access.redhat.com/ubi8/openjdk-17:1.14
FROM registry.access.redhat.com/ubi8/openjdk-21:1.20-3

ENV LANGUAGE='en_US:en'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
# accessed directly. (example: "foo.example.com,bar.example.com")
#
###
FROM registry.access.redhat.com/ubi8/openjdk-17:1.14
FROM registry.access.redhat.com/ubi8/openjdk-21:1.20-3

ENV LANGUAGE='en_US:en'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import java.util.List;
import java.util.Map;
import java.util.Objects;

import io.quarkus.runtime.annotations.RegisterForReflection;
import io.skodjob.dmt.service.RedisService;
Expand Down Expand Up @@ -66,12 +67,22 @@ public Response sendMessage(@QueryParam("channel") String channel, Map<String, S
}

@Path("pollMessages")
@GET
@POST
public Response pollMessages(@QueryParam("max") Integer max, List<String> channels) {
List<Map.Entry<String, List<StreamEntry>>> res = redisService.get(max, channels);
return Response.ok(res).build();
}

@Path("readHash")
@GET
public Response readHash(@QueryParam("hashKey") String hashKey) {
Map<String, String> map = redisService.readHash(hashKey);
if (Objects.isNull(map)) {
return Response.serverError().build();
}
return Response.ok(map).build();
}

@Path("reset")
@GET
public Response resetRedis() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public List<Map.Entry<String, List<StreamEntry>>> get(int amount, List<String> c
return redisDataSource.pollMessages(amount, channels);
}

public Map<String, String> readHash(String hashKey) {
return redisDataSource.readHash(hashKey);
}

public void resetRedis() {
redisDataSource.flushRedis();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public List<Map.Entry<String, List<StreamEntry>>> pollMessages(int maxAmount, Li
return jedis.xread(XReadParams.xReadParams().count(maxAmount), streams);
}

public Map<String, String> readHash(String hashKey) {
Jedis jedis = pool.getResource();
return jedis.hgetAll(hashKey);
}

public void flushRedis() {
Jedis jedis = pool.getResource();
jedis.flushAll();
Expand Down
2 changes: 1 addition & 1 deletion load-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</licenses>

<properties>
<java.version>17</java.version>
<java.version>21</java.version>
<slf4j.version>2.0.3</slf4j.version>
<jackson.version>2.13.4.2</jackson.version>
<datafaker.version>1.9.0</datafaker.version>
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
</developers>

<properties>
<maven.compiler.release>17</maven.compiler.release>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.release>21</maven.compiler.release>
<compiler-plugin.version>3.13.0</compiler-plugin.version>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
Expand Down

0 comments on commit 5c6ce79

Please sign in to comment.