Skip to content

Commit

Permalink
Merge branch 'master' into emb-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
uglide authored Jun 12, 2024
2 parents f217596 + 811dca0 commit 79d7ec7
Show file tree
Hide file tree
Showing 309 changed files with 54,128 additions and 2,654 deletions.
20 changes: 1 addition & 19 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,10 @@ jobs:
mvn javadoc:jar
- name: Run tests
run: |
TEST="" make test
make test
env:
JVM_OPTS: -Xmx3200m
TERM: dumb
- name: sleep 10s
run: sleep 10s
- name: Make - start
run: |
make start
sleep 2s
- name: Docker - mod or stack
run: docker run -p 52567:6379 -d redis/redis-stack-server:edge
- name: Test commands - default protocol
run: mvn -Dtest="redis.clients.jedis.commands.**" test
- name: Test commands - RESP3 protocol
run: mvn -DjedisProtocol=3 -Dtest="redis.clients.jedis.commands.**" test
- name: Test module commands - default protocol
run: mvn -DmodulesDocker="localhost:52567" -Dtest="redis.clients.jedis.modules.**" test
- name: Test module commands - RESP3 protocol
run: mvn -DjedisProtocol=3 -DmodulesDocker="localhost:52567" -Dtest="redis.clients.jedis.modules.**" test
- name: Make - stop
run: make stop
- name: Codecov
run: |
bash <(curl -s https://codecov.io/bash)
84 changes: 73 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,50 @@ cluster-enabled yes
cluster-config-file /tmp/redis_cluster_node5.conf
endef

# STABLE CLUSTER REDIS NODES
# The structure of this cluster is not changed by the tests!
define REDIS_STABLE_CLUSTER_NODE1_CONF
daemonize yes
protected-mode no
requirepass cluster
port 7479
cluster-node-timeout 15000
pidfile /tmp/redis_stable_cluster_node1.pid
logfile /tmp/redis_stable_cluster_node1.log
save ""
appendonly no
cluster-enabled yes
cluster-config-file /tmp/redis_stable_cluster_node1.conf
endef

define REDIS_STABLE_CLUSTER_NODE2_CONF
daemonize yes
protected-mode no
requirepass cluster
port 7480
cluster-node-timeout 15000
pidfile /tmp/redis_stable_cluster_node2.pid
logfile /tmp/redis_stable_cluster_node2.log
save ""
appendonly no
cluster-enabled yes
cluster-config-file /tmp/redis_stable_cluster_node2.conf
endef

define REDIS_STABLE_CLUSTER_NODE3_CONF
daemonize yes
protected-mode no
requirepass cluster
port 7481
cluster-node-timeout 15000
pidfile /tmp/redis_stable_cluster_node3.pid
logfile /tmp/redis_stable_cluster_node3.log
save ""
appendonly no
cluster-enabled yes
cluster-config-file /tmp/redis_stable_cluster_node3.conf
endef

# UDS REDIS NODES
define REDIS_UDS
daemonize yes
Expand Down Expand Up @@ -355,6 +399,9 @@ export REDIS_CLUSTER_NODE2_CONF
export REDIS_CLUSTER_NODE3_CONF
export REDIS_CLUSTER_NODE4_CONF
export REDIS_CLUSTER_NODE5_CONF
export REDIS_STABLE_CLUSTER_NODE1_CONF
export REDIS_STABLE_CLUSTER_NODE2_CONF
export REDIS_STABLE_CLUSTER_NODE3_CONF
export REDIS_UDS
export REDIS_UNAVAILABLE_CONF
export STUNNEL_CONF
Expand All @@ -366,7 +413,7 @@ ifndef STUNNEL_BIN
endif
export SKIP_SSL

start: stunnel cleanup
start: stunnel cleanup compile-module
echo "$$REDIS1_CONF" | redis-server -
echo "$$REDIS2_CONF" | redis-server -
echo "$$REDIS3_CONF" | redis-server -
Expand All @@ -393,8 +440,13 @@ start: stunnel cleanup
echo "$$REDIS_CLUSTER_NODE3_CONF" | redis-server -
echo "$$REDIS_CLUSTER_NODE4_CONF" | redis-server -
echo "$$REDIS_CLUSTER_NODE5_CONF" | redis-server -
echo "$$REDIS_STABLE_CLUSTER_NODE1_CONF" | redis-server -
echo "$$REDIS_STABLE_CLUSTER_NODE2_CONF" | redis-server -
echo "$$REDIS_STABLE_CLUSTER_NODE3_CONF" | redis-server -
echo "$$REDIS_UDS" | redis-server -
echo "$$REDIS_UNAVAILABLE_CONF" | redis-server -
redis-cli -a cluster --cluster create 127.0.0.1:7479 127.0.0.1:7480 127.0.0.1:7481 --cluster-yes
docker run -p 6479:6379 --name jedis-stack -d redis/redis-stack-server:edge

cleanup:
- rm -vf /tmp/redis_cluster_node*.conf 2>/dev/null
Expand All @@ -404,6 +456,7 @@ stunnel:
@if [ -e "$$STUNNEL_BIN" ]; then\
echo "$$STUNNEL_CONF" | stunnel -fd 0;\
fi

stop:
kill `cat /tmp/redis1.pid`
kill `cat /tmp/redis2.pid`
Expand All @@ -426,6 +479,9 @@ stop:
kill `cat /tmp/redis_cluster_node3.pid` || true
kill `cat /tmp/redis_cluster_node4.pid` || true
kill `cat /tmp/redis_cluster_node5.pid` || true
kill `cat /tmp/redis_stable_cluster_node1.pid`
kill `cat /tmp/redis_stable_cluster_node2.pid`
kill `cat /tmp/redis_stable_cluster_node3.pid`
kill `cat /tmp/redis_uds.pid` || true
kill `cat /tmp/stunnel.pid` || true
[ -f /tmp/redis_unavailable.pid ] && kill `cat /tmp/redis_unavailable.pid` || true
Expand All @@ -439,29 +495,35 @@ stop:
rm -f /tmp/redis_cluster_node3.conf
rm -f /tmp/redis_cluster_node4.conf
rm -f /tmp/redis_cluster_node5.conf
rm -f /tmp/redis_stable_cluster_node1.conf
rm -f /tmp/redis_stable_cluster_node2.conf
rm -f /tmp/redis_stable_cluster_node3.conf
docker rm -f jedis-stack

test: compile-module start
sleep 2
test: | start mvn-test stop

mvn-test:
mvn -Dtest=${SKIP_SSL}${TEST} clean compile test
make stop

package: start
package: | start mvn-package stop

mvn-package:
mvn clean package
make stop

deploy: start
deploy: | start mvn-deploy stop

mvn-deploy:
mvn clean deploy
make stop

format:
mvn java-formatter:format

release:
make start
release: | start mvn-release stop

mvn-release:
mvn release:clean
mvn release:prepare
mvn release:perform -DskipTests
make stop

system-setup:
sudo apt install -y gcc g++
Expand Down
22 changes: 14 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<jedis.module.name>redis.clients.jedis</jedis.module.name>
<slf4j.version>1.7.36</slf4j.version>
<resilience4j.version>1.7.1</resilience4j.version>
<jackson.version>2.16.1</jackson.version>
<jackson.version>2.17.1</jackson.version>
<maven.surefire.version>3.2.5</maven.surefire.version>
</properties>

Expand All @@ -67,7 +67,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20240205</version>
<version>20240303</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand All @@ -79,7 +79,7 @@
<dependency>
<groupId>com.kohlschutter.junixsocket</groupId>
<artifactId>junixsocket-core</artifactId>
<version>2.9.0</version>
<version>2.9.1</version>
<type>pom</type>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -127,6 +127,12 @@
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.javacrumbs.json-unit</groupId>
<artifactId>json-unit</artifactId>
<version>2.38.0</version> <!-- 3.x requires Java 17 -->
<scope>test</scope>
</dependency>

<!-- circuit breaker / failover -->
<dependency>
Expand Down Expand Up @@ -171,7 +177,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<version>0.8.12</version>
<executions>
<execution>
<goals>
Expand All @@ -189,7 +195,7 @@
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -210,7 +216,7 @@
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
<configuration>
<attach>true</attach>
</configuration>
Expand Down Expand Up @@ -266,7 +272,7 @@
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.1</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
Expand Down Expand Up @@ -300,7 +306,7 @@
<!--Sign the components - this is required by maven central for releases -->
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.4</version>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/redis/clients/jedis/AbstractTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ protected AbstractTransaction() {
super(new CommandObjects());
}

protected AbstractTransaction(CommandObjects commandObjects) {
super(commandObjects);
}

public abstract void multi();

/**
Expand All @@ -32,4 +36,12 @@ protected AbstractTransaction() {
public Response<Long> waitReplicas(int replicas, long timeout) {
return appendCommand(commandObjects.waitReplicas(replicas, timeout));
}

public Response<Long> publish(String channel, String message) {
return appendCommand(commandObjects.publish(channel, message));
}

public Response<Long> publish(byte[] channel, byte[] message) {
return appendCommand(commandObjects.publish(channel, message));
}
}
56 changes: 43 additions & 13 deletions src/main/java/redis/clients/jedis/BuilderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ public String toString() {
}
};

@Deprecated
public static final Builder<Set<Tuple>> TUPLE_ZSET = new Builder<Set<Tuple>>() {
@Override
@SuppressWarnings("unchecked")
Expand All @@ -683,6 +684,7 @@ public String toString() {
}
};

@Deprecated
public static final Builder<Set<Tuple>> TUPLE_ZSET_RESP3 = new Builder<Set<Tuple>>() {
@Override
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -1420,10 +1422,10 @@ public List<Map.Entry<String, List<StreamEntry>>> build(Object data) {
.collect(Collectors.toList());
} else {
List<Map.Entry<String, List<StreamEntry>>> result = new ArrayList<>(list.size());
for (Object streamObj : list) {
List<Object> stream = (List<Object>) streamObj;
String streamKey = STRING.build(stream.get(0));
List<StreamEntry> streamEntries = STREAM_ENTRY_LIST.build(stream.get(1));
for (Object anObj : list) {
List<Object> streamObj = (List<Object>) anObj;
String streamKey = STRING.build(streamObj.get(0));
List<StreamEntry> streamEntries = STREAM_ENTRY_LIST.build(streamObj.get(1));
result.add(KeyValue.of(streamKey, streamEntries));
}
return result;
Expand All @@ -1436,6 +1438,35 @@ public String toString() {
}
};

public static final Builder<Map<String, List<StreamEntry>>> STREAM_READ_MAP_RESPONSE
= new Builder<Map<String, List<StreamEntry>>>() {
@Override
public Map<String, List<StreamEntry>> build(Object data) {
if (data == null) return null;
List list = (List) data;
if (list.isEmpty()) return Collections.emptyMap();

if (list.get(0) instanceof KeyValue) {
return ((List<KeyValue>) list).stream()
.collect(Collectors.toMap(kv -> STRING.build(kv.getKey()), kv -> STREAM_ENTRY_LIST.build(kv.getValue())));
} else {
Map<String, List<StreamEntry>> result = new HashMap<>(list.size());
for (Object anObj : list) {
List<Object> streamObj = (List<Object>) anObj;
String streamKey = STRING.build(streamObj.get(0));
List<StreamEntry> streamEntries = STREAM_ENTRY_LIST.build(streamObj.get(1));
result.put(streamKey, streamEntries);
}
return result;
}
}

@Override
public String toString() {
return "Map<String, List<StreamEntry>>";
}
};

public static final Builder<List<StreamPendingEntry>> STREAM_PENDING_ENTRY_LIST = new Builder<List<StreamPendingEntry>>() {
@Override
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -1783,15 +1814,14 @@ public StreamPendingSummary build(Object data) {
}

List<Object> objectList = (List<Object>) data;
long total = BuilderFactory.LONG.build(objectList.get(0));
String minId = SafeEncoder.encode((byte[]) objectList.get(1));
String maxId = SafeEncoder.encode((byte[]) objectList.get(2));
List<List<Object>> consumerObjList = (List<List<Object>>) objectList.get(3);
Map<String, Long> map = new HashMap<>(consumerObjList.size());
for (List<Object> consumerObj : consumerObjList) {
map.put(SafeEncoder.encode((byte[]) consumerObj.get(0)), Long.parseLong(SafeEncoder.encode((byte[]) consumerObj.get(1))));
}
return new StreamPendingSummary(total, new StreamEntryID(minId), new StreamEntryID(maxId), map);
long total = LONG.build(objectList.get(0));
StreamEntryID minId = STREAM_ENTRY_ID.build(objectList.get(1));
StreamEntryID maxId = STREAM_ENTRY_ID.build(objectList.get(2));
Map<String, Long> map = objectList.get(3) == null ? null
: ((List<List<Object>>) objectList.get(3)).stream().collect(
Collectors.toMap(pair -> STRING.build(pair.get(0)),
pair -> Long.parseLong(STRING.build(pair.get(1)))));
return new StreamPendingSummary(total, minId, maxId, map);
}

@Override
Expand Down
Loading

0 comments on commit 79d7ec7

Please sign in to comment.