Browse Source

revert changes that are not related to this PR

pull/11498/head
YevhenBondarenko 2 years ago
parent
commit
399c072595
  1. 2
      application/src/main/java/org/thingsboard/server/service/subscription/DefaultTbLocalSubscriptionService.java
  2. 8
      application/src/main/java/org/thingsboard/server/service/subscription/TbAlarmsSubscription.java
  3. 8
      application/src/main/java/org/thingsboard/server/service/subscription/TbAttributeSubscription.java
  4. 28
      application/src/main/java/org/thingsboard/server/service/subscription/TbEntityLocalSubsInfo.java
  5. 23
      application/src/main/java/org/thingsboard/server/service/subscription/TbSubscription.java
  6. 5
      application/src/main/java/org/thingsboard/server/service/subscription/TbSubscriptionUtils.java
  7. 7
      application/src/main/java/org/thingsboard/server/service/subscription/TbSubscriptionsInfo.java
  8. 8
      application/src/main/java/org/thingsboard/server/service/subscription/TbTimeSeriesSubscription.java
  9. 5
      application/src/main/java/org/thingsboard/server/service/ws/notification/sub/AbstractNotificationSubscription.java
  10. 5
      application/src/main/java/org/thingsboard/server/service/ws/notification/sub/NotificationsCountSubscription.java
  11. 5
      application/src/main/java/org/thingsboard/server/service/ws/notification/sub/NotificationsSubscription.java

2
application/src/main/java/org/thingsboard/server/service/subscription/DefaultTbLocalSubscriptionService.java

@ -227,7 +227,7 @@ public class DefaultTbLocalSubscriptionService implements TbLocalSubscriptionSer
onSubEventCallback(tenantId, entityId.getId(), seqNumber, entityUpdatesInfo, callback);
}
public void onSubEventCallback(TenantId tenantId, UUID entityId, int seqNumber, TbEntityUpdatesInfo entityUpdatesInfo, TbCallback callback) {
private void onSubEventCallback(TenantId tenantId, UUID entityId, int seqNumber, TbEntityUpdatesInfo entityUpdatesInfo, TbCallback callback) {
log.debug("[{}][{}][{}] Processing sub event callback: {}.", tenantId, entityId, seqNumber, entityUpdatesInfo);
entityUpdates.put(entityId, entityUpdatesInfo);
Set<TbSubscription<?>> pendingSubs = null;

8
application/src/main/java/org/thingsboard/server/service/subscription/TbAlarmsSubscription.java

@ -36,8 +36,12 @@ public class TbAlarmsSubscription extends TbSubscription<AlarmSubscriptionUpdate
}
@Override
public boolean canEqual(final Object other) {
return other instanceof TbAlarmsSubscription;
public boolean equals(Object o) {
return super.equals(o);
}
@Override
public int hashCode() {
return super.hashCode();
}
}

8
application/src/main/java/org/thingsboard/server/service/subscription/TbAttributeSubscription.java

@ -43,8 +43,12 @@ public class TbAttributeSubscription extends TbSubscription<TelemetrySubscriptio
}
@Override
protected boolean canEqual(final Object other) {
return other instanceof TbAttributeSubscription;
public boolean equals(Object o) {
return super.equals(o);
}
@Override
public int hashCode() {
return super.hashCode();
}
}

28
application/src/main/java/org/thingsboard/server/service/subscription/TbEntityLocalSubsInfo.java

@ -84,7 +84,6 @@ public class TbEntityLocalSubsInfo {
if (!newState.attrAllKeys) {
if (attrSub.isAllKeys()) {
newState.attrAllKeys = true;
newState.attrKeys = null;
stateChanged = true;
} else {
if (newState.attrKeys == null) {
@ -101,7 +100,6 @@ public class TbEntityLocalSubsInfo {
if (!newState.tsAllKeys) {
if (tsSub.isAllKeys()) {
newState.tsAllKeys = true;
newState.tsKeys = null;
stateChanged = true;
} else {
if (newState.tsKeys == null) {
@ -135,30 +133,8 @@ public class TbEntityLocalSubsInfo {
return toEvent(ComponentLifecycleEvent.DELETED);
}
TbSubscriptionsInfo oldState = state.copy();
//copy unchanged state only
TbSubscriptionsInfo newState = state.copy();
switch (sub.getType()) {
case NOTIFICATIONS:
case NOTIFICATIONS_COUNT:
newState.notifications = false;
break;
case ALARMS:
newState.alarms = false;
break;
case ATTRIBUTES:
newState.attrAllKeys = false;
newState.attrKeys = null;
break;
case TIMESERIES:
newState.tsAllKeys = false;
newState.tsKeys = null;
}
TbSubscriptionsInfo newState = new TbSubscriptionsInfo();
for (TbSubscription<?> subscription : subs) {
if (subscription.getType() != sub.getType()) {
continue; // skip unchanged types
}
switch (subscription.getType()) {
case NOTIFICATIONS:
case NOTIFICATIONS_COUNT:
@ -175,7 +151,6 @@ public class TbEntityLocalSubsInfo {
var attrSub = (TbAttributeSubscription) subscription;
if (!newState.attrAllKeys && attrSub.isAllKeys()) {
newState.attrAllKeys = true;
newState.attrKeys = null;
continue;
}
if (newState.attrKeys == null) {
@ -188,7 +163,6 @@ public class TbEntityLocalSubsInfo {
var tsSub = (TbTimeSeriesSubscription) subscription;
if (!newState.tsAllKeys && tsSub.isAllKeys()) {
newState.tsAllKeys = true;
newState.tsKeys = null;
continue;
}
if (newState.tsKeys == null) {

23
application/src/main/java/org/thingsboard/server/service/subscription/TbSubscription.java

@ -15,25 +15,40 @@
*/
package org.thingsboard.server.service.subscription;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.thingsboard.server.common.data.id.EntityId;
import org.thingsboard.server.common.data.id.TenantId;
import java.util.Objects;
import java.util.function.BiConsumer;
@Data
@EqualsAndHashCode(cacheStrategy = EqualsAndHashCode.CacheStrategy.LAZY, doNotUseGetters = true)
@AllArgsConstructor
public abstract class TbSubscription<T> {
@EqualsAndHashCode.Exclude
private final String serviceId;
private final String sessionId;
private final int subscriptionId;
private final TenantId tenantId;
private final EntityId entityId;
private final TbSubscriptionType type;
@EqualsAndHashCode.Exclude
private final BiConsumer<TbSubscription<T>, T> updateProcessor;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TbSubscription that = (TbSubscription) o;
return subscriptionId == that.subscriptionId &&
sessionId.equals(that.sessionId) &&
tenantId.equals(that.tenantId) &&
entityId.equals(that.entityId) &&
type == that.type;
}
@Override
public int hashCode() {
return Objects.hash(sessionId, subscriptionId, tenantId, entityId, type);
}
}

5
application/src/main/java/org/thingsboard/server/service/subscription/TbSubscriptionUtils.java

@ -109,9 +109,8 @@ public class TbSubscriptionUtils {
.type(event);
if (!ComponentLifecycleEvent.DELETED.equals(event)) {
builder.info(new TbSubscriptionsInfo(proto.getNotifications(), proto.getAlarms(),
proto.getTsAllKeys(), proto.getAttrAllKeys(),
proto.getTsKeysCount() > 0 ? new HashSet<>(proto.getTsKeysList()) : null,
proto.getAttrKeysCount() > 0 ? new HashSet<>(proto.getAttrKeysList()) : null,
proto.getTsAllKeys(), proto.getTsKeysCount() > 0 ? new HashSet<>(proto.getTsKeysList()) : null,
proto.getAttrAllKeys(), proto.getAttrKeysCount() > 0 ? new HashSet<>(proto.getAttrKeysList()) : null,
proto.getSeqNumber()));
}
return builder.build();

7
application/src/main/java/org/thingsboard/server/service/subscription/TbSubscriptionsInfo.java

@ -27,17 +27,16 @@ import java.util.Set;
*/
@RequiredArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@EqualsAndHashCode(exclude = {"seqNumber"})
@ToString
public class TbSubscriptionsInfo {
protected boolean notifications;
protected boolean alarms;
protected boolean tsAllKeys;
protected boolean attrAllKeys; // primitives first for equals performance
protected Set<String> tsKeys;
protected boolean attrAllKeys;
protected Set<String> attrKeys;
@EqualsAndHashCode.Exclude
protected int seqNumber;
public boolean isEmpty() {
@ -49,7 +48,7 @@ public class TbSubscriptionsInfo {
}
protected TbSubscriptionsInfo copy(int seqNumber) {
return new TbSubscriptionsInfo(notifications, alarms, tsAllKeys, attrAllKeys, tsKeys, attrKeys, seqNumber);
return new TbSubscriptionsInfo(notifications, alarms, tsAllKeys, tsKeys, attrAllKeys, attrKeys, seqNumber);
}
}

8
application/src/main/java/org/thingsboard/server/service/subscription/TbTimeSeriesSubscription.java

@ -53,8 +53,12 @@ public class TbTimeSeriesSubscription extends TbSubscription<TelemetrySubscripti
}
@Override
protected boolean canEqual(final Object other) {
return other instanceof TbTimeSeriesSubscription;
public boolean equals(Object o) {
return super.equals(o);
}
@Override
public int hashCode() {
return super.hashCode();
}
}

5
application/src/main/java/org/thingsboard/server/service/ws/notification/sub/AbstractNotificationSubscription.java

@ -35,9 +35,4 @@ public abstract class AbstractNotificationSubscription<T> extends TbSubscription
super(serviceId, sessionId, subscriptionId, tenantId, entityId, type, updateProcessor);
}
@Override
protected boolean canEqual(final Object other) {
return other instanceof AbstractNotificationSubscription;
}
}

5
application/src/main/java/org/thingsboard/server/service/ws/notification/sub/NotificationsCountSubscription.java

@ -34,11 +34,6 @@ public class NotificationsCountSubscription extends AbstractNotificationSubscrip
super(serviceId, sessionId, subscriptionId, tenantId, entityId, TbSubscriptionType.NOTIFICATIONS_COUNT, updateProcessor);
}
@Override
protected boolean canEqual(final Object other) {
return other instanceof NotificationsCountSubscription;
}
public UnreadNotificationsCountUpdate createUpdate() {
return UnreadNotificationsCountUpdate.builder()
.cmdId(getSubscriptionId())

5
application/src/main/java/org/thingsboard/server/service/ws/notification/sub/NotificationsSubscription.java

@ -47,11 +47,6 @@ public class NotificationsSubscription extends AbstractNotificationSubscription<
this.limit = limit;
}
@Override
protected boolean canEqual(final Object other) {
return other instanceof NotificationsSubscription;
}
public UnreadNotificationsUpdate createFullUpdate() {
return UnreadNotificationsUpdate.builder()
.cmdId(getSubscriptionId())

Loading…
Cancel
Save