Fix upgrade script and improved variable names
This commit is contained in:
parent
d92681cf71
commit
2900d3c1ed
@ -33,7 +33,7 @@ $$
|
||||
BEGIN
|
||||
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'rule_node' AND column_name = 'debug_settings')
|
||||
THEN
|
||||
UPDATE rule_node SET debug_settings = '{"failuresEnabled": true, "allEnabledUntil": ' || (extract(epoch from now()) + 900) * 1000 || '}' WHERE debug_mode = true; -- 15 minutes according to thingsboard.yml default settings.
|
||||
UPDATE rule_node SET debug_settings = '{"failuresEnabled": true, "allEnabledUntil": ' || cast((extract(epoch from now()) + 900) * 1000 as bigint) || '}' WHERE debug_mode = true; -- 15 minutes according to thingsboard.yml default settings.
|
||||
ALTER TABLE rule_node DROP COLUMN debug_mode;
|
||||
END IF;
|
||||
END
|
||||
|
||||
@ -26,7 +26,6 @@ import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.thingsboard.common.util.DebugModeUtil;
|
||||
import org.thingsboard.server.actors.ActorSystemContext;
|
||||
import org.thingsboard.server.actors.TbActorRef;
|
||||
import org.thingsboard.server.actors.ruleChain.DefaultTbContext;
|
||||
@ -837,7 +836,7 @@ class DefaultTbContextTest {
|
||||
|
||||
// GIVEN
|
||||
Mockito.clearInvocations(mainCtxMock);
|
||||
ruleNode.setDebugSettings(new DebugSettings(ruleNode.getDebugSettings().isDebugFailures(), 0));
|
||||
ruleNode.setDebugSettings(new DebugSettings(ruleNode.getDebugSettings().isFailuresEnabled(), 0));
|
||||
|
||||
// WHEN
|
||||
defaultTbContext.tellNext(msg, connection);
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
package org.thingsboard.server.common.data.debug;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@ -27,18 +26,18 @@ public class DebugSettings {
|
||||
private static DebugSettings DEBUG_OFF = new DebugSettings(false, 0);
|
||||
private static DebugSettings DEBUG_FAILURES = new DebugSettings(true, 0);
|
||||
|
||||
public DebugSettings(boolean debugFailures, long debugAllUntil) {
|
||||
this.debugFailures = debugFailures;
|
||||
this.debugAll = false;
|
||||
this.debugAllUntil = debugAllUntil;
|
||||
public DebugSettings(boolean failuresEnabled, long allEnabledUntil) {
|
||||
this.failuresEnabled = failuresEnabled;
|
||||
this.allEnabled = false;
|
||||
this.allEnabledUntil = allEnabledUntil;
|
||||
}
|
||||
|
||||
@Schema(description = "Debug failures. ", example = "false")
|
||||
private boolean debugFailures;
|
||||
private boolean failuresEnabled;
|
||||
@Schema(description = "Debug All. Used as a trigger for updating debugAllUntil.", example = "false")
|
||||
private boolean debugAll;
|
||||
private boolean allEnabled;
|
||||
@Schema(description = "Timestamp of the end time for the processing debug events.")
|
||||
private long debugAllUntil;
|
||||
private long allEnabledUntil;
|
||||
|
||||
public static DebugSettings off() {return DebugSettings.DEBUG_OFF;}
|
||||
|
||||
@ -50,11 +49,11 @@ public class DebugSettings {
|
||||
|
||||
public static DebugSettings all() {
|
||||
var ds = new DebugSettings();
|
||||
ds.setDebugAll(true);
|
||||
ds.setAllEnabled(true);
|
||||
return ds;
|
||||
}
|
||||
|
||||
public DebugSettings copy(long maxDebugAllUntil) {
|
||||
return new DebugSettings(debugFailures, debugAll ? maxDebugAllUntil : Math.min(debugAllUntil, maxDebugAllUntil));
|
||||
return new DebugSettings(failuresEnabled, allEnabled ? maxDebugAllUntil : Math.min(allEnabledUntil, maxDebugAllUntil));
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
package org.thingsboard.common.util;
|
||||
|
||||
import org.thingsboard.server.common.data.HasDebugSettings;
|
||||
import org.thingsboard.server.common.data.debug.DebugSettings;
|
||||
import org.thingsboard.server.common.data.msg.TbNodeConnectionType;
|
||||
|
||||
import java.util.Set;
|
||||
@ -38,7 +37,7 @@ public final class DebugModeUtil {
|
||||
|
||||
public static boolean isDebugAllAvailable(HasDebugSettings debugSettingsAware) {
|
||||
var debugSettings = debugSettingsAware.getDebugSettings();
|
||||
return debugSettings != null && debugSettings.getDebugAllUntil() > System.currentTimeMillis();
|
||||
return debugSettings != null && debugSettings.getAllEnabledUntil() > System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static boolean isDebugAvailable(HasDebugSettings debugSettingsAware, String nodeConnection) {
|
||||
@ -46,7 +45,7 @@ public final class DebugModeUtil {
|
||||
return true;
|
||||
} else {
|
||||
var debugSettings = debugSettingsAware.getDebugSettings();
|
||||
return debugSettings != null && debugSettings.isDebugFailures() && TbNodeConnectionType.FAILURE.equals(nodeConnection);
|
||||
return debugSettings != null && debugSettings.isFailuresEnabled() && TbNodeConnectionType.FAILURE.equals(nodeConnection);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +54,7 @@ public final class DebugModeUtil {
|
||||
return true;
|
||||
} else {
|
||||
var debugSettings = debugSettingsAware.getDebugSettings();
|
||||
return debugSettings != null && nodeConnections != null && debugSettings.isDebugFailures() && nodeConnections.contains(TbNodeConnectionType.FAILURE);
|
||||
return debugSettings != null && nodeConnections != null && debugSettings.isFailuresEnabled() && nodeConnections.contains(TbNodeConnectionType.FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user