Skip to content

Commit 5f480b0

Browse files
committed
Cleaning up
1 parent 09710d0 commit 5f480b0

File tree

3 files changed

+4
-84
lines changed

3 files changed

+4
-84
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>fi.hsl</groupId>
44
<artifactId>transitdata-common</artifactId>
5-
<version>2.0.3-RC7</version>
5+
<version>2.0.3-RC8</version>
66
<packaging>jar</packaging>
77
<name>Common utilities for Transitdata projects</name>
88
<properties>

src/main/java/fi/hsl/common/pulsar/PulsarApplication.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,9 @@ public PulsarApplicationContext initialize(@NotNull Config config) throws Except
9393
}
9494

9595
if (config.getBoolean("redis.enabled")) {
96-
int connTimeOutSecs = 2;
97-
if (config.hasPath("redis.connTimeOutSecs")) {
98-
connTimeOutSecs = config.getInt("redis.connTimeOutSecs");
99-
}
10096
jedis = createRedisClient(
10197
config.getString("redis.host"),
102-
config.getInt("redis.port"),
103-
connTimeOutSecs);
98+
config.getInt("redis.port"));
10499
}
105100

106101
if (config.getBoolean("health.enabled")) {
@@ -159,8 +154,8 @@ public PulsarApplicationContext initialize(@NotNull Config config) throws Except
159154
}
160155

161156
@NotNull
162-
protected Jedis createRedisClient(@NotNull String redisHost, int port, int connTimeOutSecs) {
163-
log.info("Connecting to Redis at " + redisHost + ":" + port + " with connection timeout of (s): "+ connTimeOutSecs);
157+
protected Jedis createRedisClient(@NotNull String redisHost, int port) {
158+
log.info("Connecting to Redis at " + redisHost + ":" + port);
164159

165160
//Construct a Token Credential from Identity library, e.g. DefaultAzureCredential / ClientSecretCredential / Client CertificateCredential / ManagedIdentityCredential etc.
166161
DefaultAzureCredential defaultAzureCredential = new DefaultAzureCredentialBuilder().build();

src/main/java/fi/hsl/common/redis/RedisUtils.java

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import com.google.gson.JsonObject;
88
import com.google.gson.JsonParser;
99
import fi.hsl.common.pulsar.PulsarApplicationContext;
10-
import fi.hsl.common.transitdata.TransitdataProperties;
1110
import org.jetbrains.annotations.NotNull;
12-
import org.jetbrains.annotations.Nullable;
1311
import org.slf4j.Logger;
1412
import org.slf4j.LoggerFactory;
1513
import redis.clients.jedis.*;
@@ -19,7 +17,6 @@
1917
import java.nio.charset.StandardCharsets;
2018
import java.time.Duration;
2119
import java.time.OffsetDateTime;
22-
import java.time.format.DateTimeFormatter;
2320
import java.util.*;
2421
import java.util.concurrent.ThreadLocalRandom;
2522

@@ -164,78 +161,6 @@ public List<String> getKeys(@NotNull final String prefix, @NotNull final String
164161
return new ArrayList<>(keys);
165162
}
166163
}
167-
168-
/**
169-
* Fetches hash values for keys
170-
* @param keys
171-
* @return HashMap of keys and their hash values if they exist
172-
*/
173-
@NotNull
174-
public Map<@NotNull String, Optional<Map<@NotNull String, @NotNull String>>> getValuesByKeys(@NotNull final List<@NotNull String> keys) {
175-
synchronized (jedis) {
176-
final Transaction transaction = jedis.multi();
177-
final Map<String, Response<Map<String, String>>> responses = new HashMap<>();
178-
keys.forEach(key -> responses.put(key, transaction.hgetAll(key)));
179-
transaction.exec();
180-
181-
final Map<String, Optional<Map<String, String>>> values = new HashMap<>(responses.size());
182-
responses.forEach((k, v) -> {
183-
final Map<String, String> value = v.get();
184-
if (value == null || value.isEmpty()) {
185-
values.put(k, Optional.empty());
186-
} else {
187-
values.put(k, Optional.of(value));
188-
}
189-
});
190-
191-
return values;
192-
}
193-
}
194-
195-
/**
196-
* Fetches string values for keys
197-
* @param keys
198-
* @return HashMap of keys and their values if they exist
199-
*/
200-
@NotNull
201-
public Map<@NotNull String, Optional<String>> getValueBykeys(@NotNull final List<@NotNull String> keys) {
202-
synchronized (jedis) {
203-
final Transaction transaction = jedis.multi();
204-
final Map<String, Response<String>> responses = new HashMap<>();
205-
keys.forEach(key -> responses.put(key, transaction.get(key)));
206-
transaction.exec();
207-
208-
final Map<String, Optional<String>> values = new HashMap<>(responses.size());
209-
responses.forEach((k, v) -> {
210-
final String value = v.get();
211-
if (value == null || value.isEmpty()) {
212-
values.put(k, Optional.empty());
213-
} else {
214-
values.put(k, Optional.of(value));
215-
}
216-
});
217-
218-
return values;
219-
}
220-
}
221-
222-
@NotNull
223-
public String updateTimestamp() {
224-
synchronized (jedis) {
225-
final OffsetDateTime now = OffsetDateTime.now();
226-
final String ts = DateTimeFormatter.ISO_INSTANT.format(now);
227-
log.info("Updating Redis timestamp to {}", ts);
228-
return jedis.set(TransitdataProperties.KEY_LAST_CACHE_UPDATE_TIMESTAMP, ts);
229-
}
230-
}
231-
232-
public boolean checkResponse(@Nullable final String response) {
233-
return response != null && response.trim().equalsIgnoreCase("OK");
234-
}
235-
236-
public boolean checkResponse(@Nullable final Long response) {
237-
return response != null && response == 1;
238-
}
239164

240165
// Azure Cache for Redis helper code
241166
public static Jedis createJedisClient(String cacheHostname, int port, String username, AccessToken accessToken, boolean useSsl) {

0 commit comments

Comments
 (0)