Ver código fonte

Add expire time in log flag status response

pull/37/head
Kristijan Mitrovic 4 anos atrás
pai
commit
15c0ba770e
4 arquivos alterados com 21 adições e 1 exclusões
  1. +5
    -1
      bubble-server/src/main/java/bubble/resources/cloud/LogsResource.java
  2. +7
    -0
      bubble-server/src/main/java/bubble/service/boot/SelfNodeService.java
  3. +6
    -0
      bubble-server/src/main/java/bubble/service/boot/StandardSelfNodeService.java
  4. +3
    -0
      bubble-server/src/main/java/bubble/service_dbfilter/DbFilterSelfNodeService.java

+ 5
- 1
bubble-server/src/main/java/bubble/resources/cloud/LogsResource.java Ver arquivo

@@ -14,6 +14,7 @@ import javax.annotation.Nullable;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

@@ -36,7 +37,10 @@ public class LogsResource {

@GET @Path(EP_STATUS)
@NonNull public Response getLoggingStatus(@NonNull @Context final ContainerRequest ctx) {
return ok(selfNodeService.getLogFlag());
final var flag = new HashMap<String, Object>(2);
flag.put("flag", selfNodeService.getLogFlag());
flag.put("expireAt", selfNodeService.getLogFlagExpirationTime().orElse(null));
return ok(flag);
}

@POST @Path(EP_START)


+ 7
- 0
bubble-server/src/main/java/bubble/service/boot/SelfNodeService.java Ver arquivo

@@ -28,5 +28,12 @@ public interface SelfNodeService {
BubblePlan getThisPlan();

boolean getLogFlag();

/**
* @return Empty if TTL for log flag is a special one (less than 0), else timestamp (milliseconds) when log flag
* will be expired (to be precise, a very close time after the real expiration time as some time is spent
* for processing here).
*/
@NonNull Optional<Long> getLogFlagExpirationTime();
void setLogFlag(final boolean logFlag, @NonNull final Optional<Integer> ttlInSeconds);
}

+ 6
- 0
bubble-server/src/main/java/bubble/service/boot/StandardSelfNodeService.java Ver arquivo

@@ -447,6 +447,12 @@ public class StandardSelfNodeService implements SelfNodeService {
return empty(flagStr) ? false : Boolean.valueOf(flagStr);
}

@Override
@NonNull public Optional<Long> getLogFlagExpirationTime() {
var ttl = getNodeConfig().get_ttl(REDIS_LOG_FLAG_KEY);
return ttl < 0 ? Optional.empty() : Optional.of(now() + ttl * 1000);
}

@Override
public void setLogFlag(final boolean logFlag, @NonNull final Optional<Integer> ttlInSeconds) {
if (logFlag) {


+ 3
- 0
bubble-server/src/main/java/bubble/service_dbfilter/DbFilterSelfNodeService.java Ver arquivo

@@ -33,6 +33,9 @@ public class DbFilterSelfNodeService implements SelfNodeService {
@Override public BubblePlan getThisPlan() { return notSupported("getThisPlan"); }

@Override public boolean getLogFlag() { return notSupported("getLogFlag"); }
@Override @NonNull public Optional<Long> getLogFlagExpirationTime() {
return notSupported("getLogFlagExpirationTime");
}
@Override public void setLogFlag(boolean logFlag, @NonNull final Optional<Integer> ttlInSeconds) {
notSupported("setLogFlag");
}


Carregando…
Cancelar
Salvar