58 changed files with 1786 additions and 304 deletions
@ -0,0 +1,62 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.service.notification.rule.trigger; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import org.apache.commons.collections.CollectionUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.thingsboard.server.common.data.notification.info.EdgeCommunicationFailureNotificationInfo; |
|||
import org.thingsboard.server.common.data.notification.info.RuleOriginatedNotificationInfo; |
|||
import org.thingsboard.server.common.data.notification.rule.trigger.EdgeCommunicationFailureTrigger; |
|||
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeCommunicationFailureNotificationRuleTriggerConfig; |
|||
import org.thingsboard.server.common.data.notification.rule.trigger.config.NotificationRuleTriggerType; |
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class EdgeCommunicationFailureTriggerProcessor implements NotificationRuleTriggerProcessor<EdgeCommunicationFailureTrigger, EdgeCommunicationFailureNotificationRuleTriggerConfig> { |
|||
|
|||
@Override |
|||
public boolean matchesFilter(EdgeCommunicationFailureTrigger trigger, EdgeCommunicationFailureNotificationRuleTriggerConfig triggerConfig) { |
|||
if (CollectionUtils.isNotEmpty(triggerConfig.getEdges())) { |
|||
return !triggerConfig.getEdges().contains(trigger.getEdgeId().getId()); |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
@Override |
|||
public RuleOriginatedNotificationInfo constructNotificationInfo(EdgeCommunicationFailureTrigger trigger) { |
|||
return EdgeCommunicationFailureNotificationInfo.builder() |
|||
.tenantId(trigger.getTenantId()) |
|||
.edgeId(trigger.getEdgeId()) |
|||
.customerId(trigger.getCustomerId()) |
|||
.edgeName(trigger.getEdgeName()) |
|||
.failureMsg(truncateFailureMsg(trigger.getFailureMsg())) |
|||
.build(); |
|||
} |
|||
|
|||
@Override |
|||
public NotificationRuleTriggerType getTriggerType() { |
|||
return NotificationRuleTriggerType.EDGE_COMMUNICATION_FAILURE; |
|||
} |
|||
|
|||
private String truncateFailureMsg(String input) { |
|||
int maxLength = 500; |
|||
if (input != null && input.length() > maxLength) { |
|||
return input.substring(0, maxLength); |
|||
} |
|||
return input; |
|||
} |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.service.notification.rule.trigger; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import org.apache.commons.collections.CollectionUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.thingsboard.server.common.data.notification.info.EdgeConnectionNotificationInfo; |
|||
import org.thingsboard.server.common.data.notification.info.RuleOriginatedNotificationInfo; |
|||
import org.thingsboard.server.common.data.notification.rule.trigger.EdgeConnectionTrigger; |
|||
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectionNotificationRuleTriggerConfig; |
|||
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectionNotificationRuleTriggerConfig.EdgeConnectivityEvent; |
|||
import org.thingsboard.server.common.data.notification.rule.trigger.config.NotificationRuleTriggerType; |
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class EdgeConnectionTriggerProcessor implements NotificationRuleTriggerProcessor<EdgeConnectionTrigger, EdgeConnectionNotificationRuleTriggerConfig> { |
|||
|
|||
@Override |
|||
public boolean matchesFilter(EdgeConnectionTrigger trigger, EdgeConnectionNotificationRuleTriggerConfig triggerConfig) { |
|||
EdgeConnectivityEvent event = trigger.isConnected() ? EdgeConnectivityEvent.CONNECTED : EdgeConnectivityEvent.DISCONNECTED; |
|||
if (CollectionUtils.isEmpty(triggerConfig.getNotifyOn()) || !triggerConfig.getNotifyOn().contains(event)) { |
|||
return false; |
|||
} |
|||
if (CollectionUtils.isNotEmpty(triggerConfig.getEdges())) { |
|||
return triggerConfig.getEdges().contains(trigger.getEdgeId().getId()); |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
@Override |
|||
public RuleOriginatedNotificationInfo constructNotificationInfo(EdgeConnectionTrigger trigger) { |
|||
return EdgeConnectionNotificationInfo.builder() |
|||
.eventType(trigger.isConnected() ? "connected" : "disconnected") |
|||
.tenantId(trigger.getTenantId()) |
|||
.customerId(trigger.getCustomerId()) |
|||
.edgeId(trigger.getEdgeId()) |
|||
.edgeName(trigger.getEdgeName()) |
|||
.build(); |
|||
} |
|||
|
|||
@Override |
|||
public NotificationRuleTriggerType getTriggerType() { |
|||
return NotificationRuleTriggerType.EDGE_CONNECTION; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.notification.info; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
import org.thingsboard.server.common.data.id.CustomerId; |
|||
import org.thingsboard.server.common.data.id.EdgeId; |
|||
import org.thingsboard.server.common.data.id.EntityId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import static org.thingsboard.server.common.data.util.CollectionsUtil.mapOf; |
|||
|
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
@Builder |
|||
public class EdgeCommunicationFailureNotificationInfo implements RuleOriginatedNotificationInfo { |
|||
|
|||
private TenantId tenantId; |
|||
private CustomerId customerId; |
|||
private EdgeId edgeId; |
|||
private String edgeName; |
|||
private String failureMsg; |
|||
|
|||
@Override |
|||
public Map<String, String> getTemplateData() { |
|||
return mapOf( |
|||
"edgeId", edgeId.toString(), |
|||
"edgeName", edgeName, |
|||
"failureMsg", failureMsg |
|||
); |
|||
} |
|||
|
|||
@Override |
|||
public TenantId getAffectedTenantId() { |
|||
return tenantId; |
|||
} |
|||
|
|||
@Override |
|||
public CustomerId getAffectedCustomerId() { |
|||
return customerId; |
|||
} |
|||
|
|||
@Override |
|||
public EntityId getStateEntityId() { |
|||
return edgeId; |
|||
} |
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.notification.info; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
import org.thingsboard.server.common.data.id.CustomerId; |
|||
import org.thingsboard.server.common.data.id.EdgeId; |
|||
import org.thingsboard.server.common.data.id.EntityId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import static org.thingsboard.server.common.data.util.CollectionsUtil.mapOf; |
|||
|
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
@Builder |
|||
public class EdgeConnectionNotificationInfo implements RuleOriginatedNotificationInfo { |
|||
|
|||
private String eventType; |
|||
private TenantId tenantId; |
|||
private CustomerId customerId; |
|||
private EdgeId edgeId; |
|||
private String edgeName; |
|||
|
|||
@Override |
|||
public Map<String, String> getTemplateData() { |
|||
return mapOf( |
|||
"eventType", eventType, |
|||
"edgeId", edgeId.toString(), |
|||
"edgeName", edgeName |
|||
); |
|||
} |
|||
|
|||
@Override |
|||
public TenantId getAffectedTenantId() { |
|||
return tenantId; |
|||
} |
|||
|
|||
@Override |
|||
public CustomerId getAffectedCustomerId() { |
|||
return customerId; |
|||
} |
|||
|
|||
@Override |
|||
public EntityId getStateEntityId() { |
|||
return edgeId; |
|||
} |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.notification.rule.trigger; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import org.thingsboard.server.common.data.id.CustomerId; |
|||
import org.thingsboard.server.common.data.id.EdgeId; |
|||
import org.thingsboard.server.common.data.id.EntityId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.data.notification.rule.trigger.config.NotificationRuleTriggerType; |
|||
|
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
@Data |
|||
@Builder |
|||
public class EdgeCommunicationFailureTrigger implements NotificationRuleTrigger { |
|||
|
|||
private final TenantId tenantId; |
|||
private final CustomerId customerId; |
|||
private final EdgeId edgeId; |
|||
private final String edgeName; |
|||
private final String failureMsg; |
|||
private final String error; |
|||
|
|||
@Override |
|||
public boolean deduplicate() { |
|||
return true; |
|||
} |
|||
|
|||
@Override |
|||
public String getDeduplicationKey() { |
|||
return String.join(":", NotificationRuleTrigger.super.getDeduplicationKey(), error); |
|||
} |
|||
|
|||
@Override |
|||
public long getDefaultDeduplicationDuration() { |
|||
return TimeUnit.MINUTES.toMillis(30); |
|||
} |
|||
|
|||
@Override |
|||
public NotificationRuleTriggerType getType() { |
|||
return NotificationRuleTriggerType.EDGE_COMMUNICATION_FAILURE; |
|||
} |
|||
|
|||
@Override |
|||
public EntityId getOriginatorEntityId() { |
|||
return edgeId; |
|||
} |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.notification.rule.trigger; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import org.thingsboard.server.common.data.id.CustomerId; |
|||
import org.thingsboard.server.common.data.id.EdgeId; |
|||
import org.thingsboard.server.common.data.id.EntityId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.data.notification.rule.trigger.config.NotificationRuleTriggerType; |
|||
|
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
@Data |
|||
@Builder |
|||
public class EdgeConnectionTrigger implements NotificationRuleTrigger { |
|||
|
|||
private final TenantId tenantId; |
|||
private final CustomerId customerId; |
|||
private final EdgeId edgeId; |
|||
private final boolean connected; |
|||
private final String edgeName; |
|||
|
|||
@Override |
|||
public boolean deduplicate() { |
|||
return true; |
|||
} |
|||
|
|||
@Override |
|||
public String getDeduplicationKey() { |
|||
return String.join(":", NotificationRuleTrigger.super.getDeduplicationKey(), String.valueOf(connected)); |
|||
} |
|||
|
|||
@Override |
|||
public long getDefaultDeduplicationDuration() { |
|||
return TimeUnit.MINUTES.toMillis(1); |
|||
} |
|||
|
|||
@Override |
|||
public NotificationRuleTriggerType getType() { |
|||
return NotificationRuleTriggerType.EDGE_CONNECTION; |
|||
} |
|||
|
|||
@Override |
|||
public EntityId getOriginatorEntityId() { |
|||
return edgeId; |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.notification.rule.trigger.config; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.util.Set; |
|||
import java.util.UUID; |
|||
|
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
@Builder |
|||
public class EdgeCommunicationFailureNotificationRuleTriggerConfig implements NotificationRuleTriggerConfig { |
|||
|
|||
private Set<UUID> edges; // if empty - all edges
|
|||
|
|||
@Override |
|||
public NotificationRuleTriggerType getTriggerType() { |
|||
return NotificationRuleTriggerType.EDGE_COMMUNICATION_FAILURE; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.notification.rule.trigger.config; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.util.Set; |
|||
import java.util.UUID; |
|||
|
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
@Builder |
|||
public class EdgeConnectionNotificationRuleTriggerConfig implements NotificationRuleTriggerConfig { |
|||
|
|||
private Set<UUID> edges; // if empty - all edges
|
|||
private Set<EdgeConnectivityEvent> notifyOn; |
|||
|
|||
@Override |
|||
public NotificationRuleTriggerType getTriggerType() { |
|||
return NotificationRuleTriggerType.EDGE_CONNECTION; |
|||
} |
|||
|
|||
public enum EdgeConnectivityEvent { |
|||
CONNECTED, DISCONNECTED |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.snmp.session; |
|||
|
|||
import com.google.common.util.concurrent.AsyncCallable; |
|||
import com.google.common.util.concurrent.Futures; |
|||
import com.google.common.util.concurrent.ListenableFuture; |
|||
import com.google.common.util.concurrent.MoreExecutors; |
|||
import lombok.Data; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
|
|||
import java.util.concurrent.ScheduledExecutorService; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
@Data |
|||
@Slf4j |
|||
public class ScheduledTask { |
|||
private ListenableFuture<?> scheduledFuture; |
|||
private boolean stopped = false; |
|||
|
|||
public void init(AsyncCallable<Void> task, long delayMs, ScheduledExecutorService scheduler) { |
|||
schedule(task, delayMs, scheduler); |
|||
} |
|||
|
|||
private void schedule(AsyncCallable<Void> task, long delayMs, ScheduledExecutorService scheduler) { |
|||
scheduledFuture = Futures.scheduleAsync(() -> { |
|||
if (stopped) { |
|||
return Futures.immediateCancelledFuture(); |
|||
} |
|||
try { |
|||
return task.call(); |
|||
} catch (Throwable t) { |
|||
log.error("Unhandled error in scheduled task", t); |
|||
return Futures.immediateFailedFuture(t); |
|||
} |
|||
}, delayMs, TimeUnit.MILLISECONDS, scheduler); |
|||
if (!stopped) { |
|||
scheduledFuture.addListener(() -> schedule(task, delayMs, scheduler), MoreExecutors.directExecutor()); |
|||
} |
|||
} |
|||
|
|||
public void cancel() { |
|||
stopped = true; |
|||
if (scheduledFuture != null) { |
|||
scheduledFuture.cancel(true); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -1,43 +0,0 @@ |
|||
{ |
|||
"timeoutMs": 500, |
|||
"retries": 0, |
|||
"communicationConfigs": [ |
|||
{ |
|||
"spec": "TELEMETRY_QUERYING", |
|||
"queryingFrequencyMs": 3000, |
|||
"mappings": [ |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.1.1.50", |
|||
"key": "temperature", |
|||
"dataType": "LONG" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.2.1.52", |
|||
"key": "humidity", |
|||
"dataType": "DOUBLE" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"spec": "CLIENT_ATTRIBUTES_QUERYING", |
|||
"queryingFrequencyMs": 5000, |
|||
"mappings": [ |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.3.1.54", |
|||
"key": "isCool", |
|||
"dataType": "STRING" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"spec": "SHARED_ATTRIBUTES_SETTING", |
|||
"mappings": [ |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.7.1.58", |
|||
"key": "shared", |
|||
"dataType": "STRING" |
|||
} |
|||
] |
|||
} |
|||
] |
|||
} |
|||
@ -1,13 +0,0 @@ |
|||
{ |
|||
"address": "192.168.3.23", |
|||
"port": 1610, |
|||
"protocolVersion": "V3", |
|||
|
|||
"username": "tb-user", |
|||
"engineId": "qwertyuioa", |
|||
"securityName": "tb-user", |
|||
"authenticationProtocol": "SHA_512", |
|||
"authenticationPassphrase": "sdfghjkloifgh", |
|||
"privacyProtocol": "DES", |
|||
"privacyPassphrase": "rtytguijokod" |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
{ |
|||
"address": "127.0.0.1", |
|||
"port": 1610, |
|||
"community": "public", |
|||
"protocolVersion": "V2C" |
|||
} |
|||
@ -0,0 +1,289 @@ |
|||
{ |
|||
"name": "SNMP Device Profile", |
|||
"description": "", |
|||
"image": null, |
|||
"type": "DEFAULT", |
|||
"transportType": "SNMP", |
|||
"provisionType": "DISABLED", |
|||
"defaultRuleChainId": null, |
|||
"defaultDashboardId": null, |
|||
"defaultQueueName": null, |
|||
"profileData": { |
|||
"configuration": { |
|||
"type": "DEFAULT" |
|||
}, |
|||
"transportConfiguration": { |
|||
"type": "SNMP", |
|||
"timeoutMs": 500, |
|||
"retries": 0, |
|||
"communicationConfigs": [ |
|||
{ |
|||
"spec": "TELEMETRY_QUERYING", |
|||
"mappings": [ |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.1.1.52", |
|||
"key": "key_1", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.2.1.52", |
|||
"key": "key_2", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.3.1.52", |
|||
"key": "key_3", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.4.1.52", |
|||
"key": "key_4", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.5.1.52", |
|||
"key": "key_5", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.6.1.52", |
|||
"key": "key_6", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.7.1.52", |
|||
"key": "key_7", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.8.1.52", |
|||
"key": "key_8", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.9.1.52", |
|||
"key": "key_9", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.10.1.52", |
|||
"key": "key_10", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.11.1.52", |
|||
"key": "key_11", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.12.1.52", |
|||
"key": "key_12", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.13.1.52", |
|||
"key": "key_13", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.14.1.52", |
|||
"key": "key_14", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.15.1.52", |
|||
"key": "key_15", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.16.1.52", |
|||
"key": "key_16", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.17.1.52", |
|||
"key": "key_17", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.18.1.52", |
|||
"key": "key_18", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.19.1.52", |
|||
"key": "key_19", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.20.1.52", |
|||
"key": "key_20", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.21.1.52", |
|||
"key": "key_21", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.22.1.52", |
|||
"key": "key_22", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.23.1.52", |
|||
"key": "key_23", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.24.1.52", |
|||
"key": "key_24", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.25.1.52", |
|||
"key": "key_25", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.26.1.52", |
|||
"key": "key_26", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.27.1.52", |
|||
"key": "key_27", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.28.1.52", |
|||
"key": "key_28", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.29.1.52", |
|||
"key": "key_29", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.30.1.52", |
|||
"key": "key_30", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.31.1.52", |
|||
"key": "key_31", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.32.1.52", |
|||
"key": "key_32", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.33.1.52", |
|||
"key": "key_33", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.34.1.52", |
|||
"key": "key_34", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.35.1.52", |
|||
"key": "key_35", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.36.1.52", |
|||
"key": "key_36", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.37.1.52", |
|||
"key": "key_37", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.38.1.52", |
|||
"key": "key_38", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.39.1.52", |
|||
"key": "key_39", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.40.1.52", |
|||
"key": "key_40", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.41.1.52", |
|||
"key": "key_41", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.42.1.52", |
|||
"key": "key_42", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.43.1.52", |
|||
"key": "key_43", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.44.1.52", |
|||
"key": "key_44", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.45.1.52", |
|||
"key": "key_45", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.46.1.52", |
|||
"key": "key_46", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.47.1.52", |
|||
"key": "key_47", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.48.1.52", |
|||
"key": "key_48", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.49.1.52", |
|||
"key": "key_49", |
|||
"dataType": "STRING" |
|||
}, |
|||
{ |
|||
"oid": ".1.3.6.1.2.1.50.1.52", |
|||
"key": "key_50", |
|||
"dataType": "STRING" |
|||
} |
|||
], |
|||
"queryingFrequencyMs": 5000 |
|||
} |
|||
] |
|||
}, |
|||
"provisionConfiguration": { |
|||
"type": "DISABLED", |
|||
"provisionDeviceSecret": null |
|||
}, |
|||
"alarms": null |
|||
}, |
|||
"provisionDeviceKey": null, |
|||
"firmwareId": null, |
|||
"softwareId": null, |
|||
"defaultEdgeRuleChainId": null, |
|||
"default": false |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.dao.service.timeseries.nosql; |
|||
|
|||
import com.datastax.oss.driver.api.core.uuid.Uuids; |
|||
import org.junit.Test; |
|||
import org.springframework.test.context.TestPropertySource; |
|||
import org.thingsboard.server.common.data.id.DeviceId; |
|||
import org.thingsboard.server.common.data.kv.Aggregation; |
|||
import org.thingsboard.server.common.data.kv.BaseReadTsKvQuery; |
|||
import org.thingsboard.server.common.data.kv.BasicTsKvEntry; |
|||
import org.thingsboard.server.common.data.kv.DoubleDataEntry; |
|||
import org.thingsboard.server.common.data.kv.LongDataEntry; |
|||
import org.thingsboard.server.common.data.kv.TsKvEntry; |
|||
import org.thingsboard.server.dao.service.DaoNoSqlTest; |
|||
|
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.concurrent.ExecutionException; |
|||
import java.util.concurrent.TimeUnit; |
|||
import java.util.concurrent.TimeoutException; |
|||
|
|||
import static org.assertj.core.api.Assertions.assertThat; |
|||
import static org.junit.Assert.assertEquals; |
|||
import static org.junit.Assert.assertFalse; |
|||
import static org.junit.Assert.assertTrue; |
|||
|
|||
@DaoNoSqlTest |
|||
@TestPropertySource(properties = { |
|||
"cassandra.query.set_null_values_enabled=true", |
|||
}) |
|||
public class TimeseriesServiceNoSqlSetNullEnabledTest extends TimeseriesServiceNoSqlTest { |
|||
|
|||
@Override |
|||
@Test |
|||
public void testNullValuesOfNoneTargetColumn() throws ExecutionException, InterruptedException, TimeoutException { |
|||
long ts = TimeUnit.MINUTES.toMillis(1); |
|||
TsKvEntry longEntry = new BasicTsKvEntry(ts, new LongDataEntry("temp", 0L)); |
|||
double doubleValue = 20.6; |
|||
TsKvEntry doubleEntry = new BasicTsKvEntry(ts, new DoubleDataEntry("temp", doubleValue)); |
|||
DeviceId deviceId = new DeviceId(Uuids.timeBased()); |
|||
tsService.save(tenantId, deviceId, longEntry).get(MAX_TIMEOUT, TimeUnit.SECONDS); |
|||
tsService.save(tenantId, deviceId, doubleEntry).get(MAX_TIMEOUT, TimeUnit.SECONDS); |
|||
|
|||
List<TsKvEntry> listWithoutAgg = tsService.findAll(tenantId, deviceId, Collections.singletonList(new BaseReadTsKvQuery("temp", 0L, |
|||
ts + 1 , 1000, 3, Aggregation.NONE))).get(MAX_TIMEOUT, TimeUnit.SECONDS); |
|||
assertEquals(1, listWithoutAgg.size()); |
|||
assertFalse(listWithoutAgg.get(0).getLongValue().isPresent()); |
|||
assertTrue(listWithoutAgg.get(0).getDoubleValue().isPresent()); |
|||
assertThat(listWithoutAgg.get(0).getDoubleValue().get()).isEqualTo(doubleValue); |
|||
|
|||
// long value should be set to null after second insert, so avg = doubleValue
|
|||
List<TsKvEntry> listWithAgg = tsService.findAll(tenantId, deviceId, Collections.singletonList(new BaseReadTsKvQuery("temp", 0L, |
|||
ts + 1 , 1000, 3, Aggregation.AVG))).get(MAX_TIMEOUT, TimeUnit.SECONDS); |
|||
assertEquals(1, listWithAgg.size()); |
|||
assertTrue(listWithAgg.get(0).getDoubleValue().isPresent()); |
|||
assertThat(listWithAgg.get(0).getDoubleValue().get()).isEqualTo(doubleValue); |
|||
} |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
#### Edge communication failure notification templatization |
|||
|
|||
<div class="divider"></div> |
|||
<br/> |
|||
|
|||
Notification subject and message fields support templatization. |
|||
The list of available templatization parameters depends on the template type. |
|||
See the available types and parameters below: |
|||
|
|||
Available template parameters: |
|||
|
|||
* `edgeId` - the edge id as uuid string; |
|||
* `edgeName` - the name of the edge; |
|||
* `failureMsg` - the string representation of the failure, occurred on the Edge; |
|||
|
|||
Parameter names must be wrapped using `${...}`. For example: `${edgeName}`. |
|||
You may also modify the value of the parameter with one of the suffixes: |
|||
|
|||
* `upperCase`, for example - `${edgeName:upperCase}` |
|||
* `lowerCase`, for example - `${edgeName:lowerCase}` |
|||
* `capitalize`, for example - `${edgeName:capitalize}` |
|||
|
|||
<div class="divider"></div> |
|||
|
|||
##### Examples |
|||
|
|||
Let's assume the notification about the failing of processing connection to Edge. |
|||
The following template: |
|||
|
|||
```text |
|||
Edge '${edgeName}' communication failure occurred |
|||
{:copy-code} |
|||
``` |
|||
|
|||
will be transformed to: |
|||
|
|||
```text |
|||
Edge 'DatacenterEdge' communication failure occurred |
|||
``` |
|||
|
|||
<br/> |
|||
|
|||
The following template: |
|||
|
|||
```text |
|||
Failure message: '${failureMsg}' |
|||
{:copy-code} |
|||
``` |
|||
|
|||
will be transformed to: |
|||
|
|||
```text |
|||
Failure message: 'Failed to process edge connection!' |
|||
``` |
|||
|
|||
<br> |
|||
<br> |
|||
@ -0,0 +1,44 @@ |
|||
#### Edge connection notification templatization |
|||
|
|||
<div class="divider"></div> |
|||
<br/> |
|||
|
|||
Notification subject and message fields support templatization. |
|||
The list of available templatization parameters depends on the template type. |
|||
See the available types and parameters below: |
|||
|
|||
Available template parameters: |
|||
|
|||
* `edgeId` - the edge id as uuid string; |
|||
* `edgeName` - the name of the edge; |
|||
* `eventType` - the string representation of the connectivity status: connected or disconnected; |
|||
|
|||
Parameter names must be wrapped using `${...}`. For example: `${edgeName}`. |
|||
You may also modify the value of the parameter with one of the suffixes: |
|||
|
|||
* `upperCase`, for example - `${edgeName:upperCase}` |
|||
* `lowerCase`, for example - `${edgeName:lowerCase}` |
|||
* `capitalize`, for example - `${edgeName:capitalize}` |
|||
|
|||
<div class="divider"></div> |
|||
|
|||
##### Examples |
|||
|
|||
Let's assume the notification about the connecting Edge into the ThingsBoard. |
|||
The following template: |
|||
|
|||
```text |
|||
Edge '${edgeName}' is now ${eventType} |
|||
{:copy-code} |
|||
``` |
|||
|
|||
will be transformed to: |
|||
|
|||
```text |
|||
Edge 'DatacenterEdge' is now connected |
|||
``` |
|||
|
|||
<br/> |
|||
|
|||
<br> |
|||
<br> |
|||
Loading…
Reference in new issue