Commit d8ac388395254edbdbbc9e7c1eb14261cc46507d

Authored by Andrew Shvayka
1 parent ba1dc4db

Fixed NPE in DataEntry objects and logging statistics of rule chains/nodes

@@ -57,6 +57,9 @@ public class RuleChainActor extends ComponentActor<RuleChainId, RuleChainActorMe @@ -57,6 +57,9 @@ public class RuleChainActor extends ComponentActor<RuleChainId, RuleChainActorMe
57 break; 57 break;
58 case CLUSTER_EVENT_MSG: 58 case CLUSTER_EVENT_MSG:
59 break; 59 break;
  60 + case STATS_PERSIST_TICK_MSG:
  61 + onStatsPersistTick(id);
  62 + break;
60 default: 63 default:
61 return false; 64 return false;
62 } 65 }
@@ -50,6 +50,9 @@ public class RuleNodeActor extends ComponentActor<RuleNodeId, RuleNodeActorMessa @@ -50,6 +50,9 @@ public class RuleNodeActor extends ComponentActor<RuleNodeId, RuleNodeActorMessa
50 case RULE_TO_SELF_MSG: 50 case RULE_TO_SELF_MSG:
51 onRuleNodeToSelfMsg((RuleNodeToSelfMsg) msg); 51 onRuleNodeToSelfMsg((RuleNodeToSelfMsg) msg);
52 break; 52 break;
  53 + case STATS_PERSIST_TICK_MSG:
  54 + onStatsPersistTick(id);
  55 + break;
53 default: 56 default:
54 return false; 57 return false;
55 } 58 }
@@ -159,11 +159,11 @@ public abstract class ComponentActor<T extends EntityId, P extends ComponentMsgP @@ -159,11 +159,11 @@ public abstract class ComponentActor<T extends EntityId, P extends ComponentMsgP
159 } 159 }
160 } 160 }
161 161
162 - protected void logLifecycleEvent(ComponentLifecycleEvent event) { 162 + private void logLifecycleEvent(ComponentLifecycleEvent event) {
163 logLifecycleEvent(event, null); 163 logLifecycleEvent(event, null);
164 } 164 }
165 165
166 - protected void logLifecycleEvent(ComponentLifecycleEvent event, Exception e) { 166 + private void logLifecycleEvent(ComponentLifecycleEvent event, Exception e) {
167 systemContext.persistLifecycleEvent(tenantId, id, event, e); 167 systemContext.persistLifecycleEvent(tenantId, id, event, e);
168 } 168 }
169 169
@@ -15,4 +15,12 @@ @@ -15,4 +15,12 @@
15 */ 15 */
16 package org.thingsboard.server.actors.stats; 16 package org.thingsboard.server.actors.stats;
17 17
18 -public final class StatsPersistTick {} 18 +import org.thingsboard.server.common.msg.MsgType;
  19 +import org.thingsboard.server.common.msg.TbActorMsg;
  20 +
  21 +public final class StatsPersistTick implements TbActorMsg{
  22 + @Override
  23 + public MsgType getMsgType() {
  24 + return MsgType.STATS_PERSIST_TICK_MSG;
  25 + }
  26 +}
@@ -33,7 +33,7 @@ public class BooleanDataEntry extends BasicKvEntry { @@ -33,7 +33,7 @@ public class BooleanDataEntry extends BasicKvEntry {
33 33
34 @Override 34 @Override
35 public Optional<Boolean> getBooleanValue() { 35 public Optional<Boolean> getBooleanValue() {
36 - return Optional.of(value); 36 + return Optional.ofNullable(value);
37 } 37 }
38 38
39 @Override 39 @Override
@@ -34,7 +34,7 @@ public class DoubleDataEntry extends BasicKvEntry { @@ -34,7 +34,7 @@ public class DoubleDataEntry extends BasicKvEntry {
34 34
35 @Override 35 @Override
36 public Optional<Double> getDoubleValue() { 36 public Optional<Double> getDoubleValue() {
37 - return Optional.of(value); 37 + return Optional.ofNullable(value);
38 } 38 }
39 39
40 @Override 40 @Override
@@ -34,7 +34,7 @@ public class LongDataEntry extends BasicKvEntry { @@ -34,7 +34,7 @@ public class LongDataEntry extends BasicKvEntry {
34 34
35 @Override 35 @Override
36 public Optional<Long> getLongValue() { 36 public Optional<Long> getLongValue() {
37 - return Optional.of(value); 37 + return Optional.ofNullable(value);
38 } 38 }
39 39
40 @Override 40 @Override
@@ -35,7 +35,7 @@ public class StringDataEntry extends BasicKvEntry { @@ -35,7 +35,7 @@ public class StringDataEntry extends BasicKvEntry {
35 35
36 @Override 36 @Override
37 public Optional<String> getStrValue() { 37 public Optional<String> getStrValue() {
38 - return Optional.of(value); 38 + return Optional.ofNullable(value);
39 } 39 }
40 40
41 @Override 41 @Override
@@ -110,6 +110,7 @@ public enum MsgType { @@ -110,6 +110,7 @@ public enum MsgType {
110 ACTOR_SYSTEM_TO_DEVICE_SESSION_ACTOR_MSG, 110 ACTOR_SYSTEM_TO_DEVICE_SESSION_ACTOR_MSG,
111 TRANSPORT_TO_DEVICE_SESSION_ACTOR_MSG, 111 TRANSPORT_TO_DEVICE_SESSION_ACTOR_MSG,
112 SESSION_TIMEOUT_MSG, 112 SESSION_TIMEOUT_MSG,
113 - SESSION_CTRL_MSG; 113 + SESSION_CTRL_MSG,
  114 + STATS_PERSIST_TICK_MSG;
114 115
115 } 116 }