WIP : Add data type, Add Migration to add data type to existing data adapter
This commit is contained in:
parent
2abda2fd7d
commit
1908a40a1c
@ -26,6 +26,7 @@ import org.graylog2.plugin.PluginModule;
|
||||
|
||||
import in.nosd.redis.dataadapters.RedisLookupDataAdapter;
|
||||
import in.nosd.redis.functions.RedisLookupPluginFunction;
|
||||
import in.nosd.redis.migrations.V104_MigrateRedisType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
@ -65,6 +66,8 @@ public class RedisLookupPluginModule extends PluginModule {
|
||||
* addConfigBeans();
|
||||
*/
|
||||
|
||||
addMigration(V104_MigrateRedisType.class);
|
||||
|
||||
addMessageProcessorFunction(RedisLookupPluginFunction.NAME, RedisLookupPluginFunction.class);
|
||||
|
||||
installLookupDataAdapter2(RedisLookupDataAdapter.NAME, RedisLookupDataAdapter.class,
|
||||
|
@ -69,7 +69,6 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
|
||||
private final RedisClient client;
|
||||
private RedisCommands<String, String> commands;
|
||||
private StatefulRedisConnection<String, String> connection;
|
||||
|
||||
private final Timer redisGetRequestTimer;
|
||||
private final Meter redisGetRequestErrors;
|
||||
private final Timer redisSetRequestTimer;
|
||||
@ -124,9 +123,6 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
|
||||
this.redisRemoveStringListRequestErrors = metricRegistry.meter(MetricRegistry.name(getClass(), "redisRemoveStringListRequestErrors"));
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* LookupDataAdapter functions
|
||||
**************************************************************************/
|
||||
@Override
|
||||
protected void doStart() throws Exception {
|
||||
connection = this.client.connect();
|
||||
@ -151,6 +147,11 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
|
||||
cachePurge.purgeAll();
|
||||
}
|
||||
|
||||
private String getSingleValue(String key) {
|
||||
final String value = this.commands.get(key);
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LookupResult doGet(Object key) {
|
||||
final Timer.Context time = redisGetRequestTimer.time();
|
||||
@ -239,11 +240,6 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
private String getSingleValue(String key) {
|
||||
final String value = this.commands.get(key);
|
||||
return value;
|
||||
}
|
||||
|
||||
private LookupResult setExpire(String key, Long ttl) {
|
||||
try {
|
||||
if (!this.commands.expire(key, ttl)) {
|
||||
@ -312,10 +308,6 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
|
||||
if (!keepDuplicates) {
|
||||
removeStringList(trimmedKey, listValue);
|
||||
}
|
||||
|
||||
LOG.info("Redis addStringList: List is <{}> items", listValue.size());
|
||||
LOG.info("Redis addStringList: List is <{}>", listValue);
|
||||
|
||||
final Long len = this.commands.rpush(trimmedKey, listValue.toArray(new String[0]));
|
||||
if (len > 0) {
|
||||
return LookupResult.withoutTTL().stringListValue(this.commands.lrange(trimmedKey, 0, -1)).build();
|
||||
@ -452,7 +444,10 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
|
||||
public abstract int redisDB();
|
||||
|
||||
@JsonProperty("redis_type")
|
||||
@NotEmpty
|
||||
/* FIXME: This should be notEmpty, but migration crash when dbDataAdapterService.findAll() with error
|
||||
* "Missing required properties: redisType"
|
||||
* so dont flag NoteEmpty and put Nullable. */
|
||||
@Nullable
|
||||
public abstract String redisType();
|
||||
|
||||
@JsonProperty("redis_ttl")
|
||||
|
Loading…
Reference in New Issue
Block a user