Browse Source

Merge remote-tracking branch 'origin/develop/2.6-edge' into develop/3.3-edge

pull/3811/head
Volodymyr Babak 6 years ago
parent
commit
005b802c17
  1. 4
      application/src/main/java/org/thingsboard/server/actors/ActorSystemContext.java
  2. 4
      application/src/main/java/org/thingsboard/server/actors/device/DeviceActorMessageProcessor.java
  3. 12
      application/src/main/java/org/thingsboard/server/controller/BaseController.java
  4. 9
      application/src/main/java/org/thingsboard/server/controller/EdgeController.java
  5. 6
      application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeEventStorageSettings.java
  6. 2
      application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java
  7. 10
      application/src/main/resources/thingsboard.yml
  8. 6
      dao/src/main/java/org/thingsboard/server/dao/edge/EdgeServiceImpl.java
  9. 8
      ui-ngx/src/assets/locale/locale.constant-en_US.json

4
application/src/main/java/org/thingsboard/server/actors/ActorSystemContext.java

@ -335,9 +335,9 @@ public class ActorSystemContext {
@Getter @Getter
private long statisticsPersistFrequency; private long statisticsPersistFrequency;
@Value("${edges.rpc.enabled}") @Value("${edges.enabled}")
@Getter @Getter
private boolean edgesRpcEnabled; private boolean edgesEnabled;
@Scheduled(fixedDelayString = "${actors.statistics.js_print_interval_ms}") @Scheduled(fixedDelayString = "${actors.statistics.js_print_interval_ms}")
public void printStats() { public void printStats() {

4
application/src/main/java/org/thingsboard/server/actors/device/DeviceActorMessageProcessor.java

@ -130,7 +130,7 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
this.defaultMetaData = new TbMsgMetaData(); this.defaultMetaData = new TbMsgMetaData();
this.defaultMetaData.putValue("deviceName", deviceName); this.defaultMetaData.putValue("deviceName", deviceName);
this.defaultMetaData.putValue("deviceType", deviceType); this.defaultMetaData.putValue("deviceType", deviceType);
if (systemContext.isEdgesRpcEnabled()) { if (systemContext.isEdgesEnabled()) {
this.edgeId = findRelatedEdgeId(); this.edgeId = findRelatedEdgeId();
} }
return true; return true;
@ -169,7 +169,7 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
} }
boolean sent; boolean sent;
if (systemContext.isEdgesRpcEnabled() && edgeId != null) { if (systemContext.isEdgesEnabled() && edgeId != null) {
log.debug("[{}][{}] device is related to edge [{}]. Saving RPC request to edge queue", tenantId, deviceId, edgeId.getId()); log.debug("[{}][{}] device is related to edge [{}]. Saving RPC request to edge queue", tenantId, deviceId, edgeId.getId());
saveRpcRequestToEdgeQueue(request, rpcRequest.getRequestId()); saveRpcRequestToEdgeQueue(request, rpcRequest.getRequestId());
sent = true; sent = true;

12
application/src/main/java/org/thingsboard/server/controller/BaseController.java

@ -254,9 +254,9 @@ public abstract class BaseController {
@Getter @Getter
private boolean logControllerErrorStackTrace; private boolean logControllerErrorStackTrace;
@Value("${edges.rpc.enabled}") @Value("${edges.enabled}")
@Getter @Getter
private boolean edgesRpcEnabled; protected boolean edgesEnabled;
@ExceptionHandler(ThingsboardException.class) @ExceptionHandler(ThingsboardException.class)
public void handleThingsboardException(ThingsboardException ex, HttpServletResponse response) { public void handleThingsboardException(ThingsboardException ex, HttpServletResponse response) {
@ -884,7 +884,7 @@ public abstract class BaseController {
} }
protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, CustomerId customerId, EdgeEventActionType action) { protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, CustomerId customerId, EdgeEventActionType action) {
if (!edgesRpcEnabled) { if (!edgesEnabled) {
return; return;
} }
try { try {
@ -895,7 +895,7 @@ public abstract class BaseController {
} }
protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, CustomerId customerId, EdgeEventActionType action) { protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, CustomerId customerId, EdgeEventActionType action) {
if (!edgesRpcEnabled) { if (!edgesEnabled) {
return; return;
} }
EdgeEventType type = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType()); EdgeEventType type = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType());
@ -909,7 +909,7 @@ public abstract class BaseController {
} }
protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityRelation relation, EdgeEventActionType action) { protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityRelation relation, EdgeEventActionType action) {
if (!edgesRpcEnabled) { if (!edgesEnabled) {
return; return;
} }
try { try {
@ -927,7 +927,7 @@ public abstract class BaseController {
} }
protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, EntityType entityType, EdgeEventActionType action) { protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, EntityType entityType, EdgeEventActionType action) {
if (!edgesRpcEnabled) { if (!edgesEnabled) {
return; return;
} }
EdgeEventType type = EdgeUtils.getEdgeEventTypeByEntityType(entityType); EdgeEventType type = EdgeUtils.getEdgeEventTypeByEntityType(entityType);

9
application/src/main/java/org/thingsboard/server/controller/EdgeController.java

@ -64,6 +64,13 @@ public class EdgeController extends BaseController {
public static final String EDGE_ID = "edgeId"; public static final String EDGE_ID = "edgeId";
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/edges/enabled", method = RequestMethod.GET)
@ResponseBody
public boolean isEdgesSupportEnabled() {
return edgesEnabled;
}
@PreAuthorize("hasAuthority('TENANT_ADMIN')") @PreAuthorize("hasAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.GET) @RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ -470,7 +477,7 @@ public class EdgeController extends BaseController {
public void syncEdge(@RequestBody EdgeId edgeId) throws ThingsboardException { public void syncEdge(@RequestBody EdgeId edgeId) throws ThingsboardException {
try { try {
edgeId = checkNotNull(edgeId); edgeId = checkNotNull(edgeId);
if (isEdgesRpcEnabled()) { if (isEdgesEnabled()) {
EdgeGrpcSession session = edgeGrpcService.getEdgeGrpcSessionById(edgeId); EdgeGrpcSession session = edgeGrpcService.getEdgeGrpcSessionById(edgeId);
Edge edge = session.getEdge(); Edge edge = session.getEdge();
syncEdgeService.sync(edge); syncEdgeService.sync(edge);

6
application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeEventStorageSettings.java

@ -23,10 +23,10 @@ import org.springframework.stereotype.Component;
@Component @Component
@Data @Data
public class EdgeEventStorageSettings { public class EdgeEventStorageSettings {
@Value("${edges.rpc.storage.max_read_records_count}") @Value("${edges.storage.max_read_records_count}")
private int maxReadRecordsCount; private int maxReadRecordsCount;
@Value("${edges.rpc.storage.no_read_records_sleep}") @Value("${edges.storage.no_read_records_sleep}")
private long noRecordsSleepInterval; private long noRecordsSleepInterval;
@Value("${edges.rpc.storage.sleep_between_batches}") @Value("${edges.storage.sleep_between_batches}")
private long sleepIntervalBetweenBatches; private long sleepIntervalBetweenBatches;
} }

2
application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java

@ -59,7 +59,7 @@ import java.util.concurrent.TimeUnit;
@Service @Service
@Slf4j @Slf4j
@ConditionalOnProperty(prefix = "edges.rpc", value = "enabled", havingValue = "true") @ConditionalOnProperty(prefix = "edges", value = "enabled", havingValue = "true")
@TbCoreComponent @TbCoreComponent
public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase implements EdgeRpcService { public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase implements EdgeRpcService {

10
application/src/main/resources/thingsboard.yml

@ -576,8 +576,8 @@ transport:
# Edges parameters # Edges parameters
edges: edges:
enabled: "${EDGES_ENABLED:false}"
rpc: rpc:
enabled: "${EDGES_RPC_ENABLED:false}"
port: "${EDGES_RPC_PORT:7070}" port: "${EDGES_RPC_PORT:7070}"
client_max_keep_alive_time_sec: "${EDGES_RPC_CLIENT_MAX_KEEP_ALIVE_TIME_SEC:300}" client_max_keep_alive_time_sec: "${EDGES_RPC_CLIENT_MAX_KEEP_ALIVE_TIME_SEC:300}"
ssl: ssl:
@ -585,10 +585,10 @@ edges:
enabled: "${EDGES_RPC_SSL_ENABLED:false}" enabled: "${EDGES_RPC_SSL_ENABLED:false}"
cert: "${EDGES_RPC_SSL_CERT:certChainFile.pem}" cert: "${EDGES_RPC_SSL_CERT:certChainFile.pem}"
private_key: "${EDGES_RPC_SSL_PRIVATE_KEY:privateKeyFile.pem}" private_key: "${EDGES_RPC_SSL_PRIVATE_KEY:privateKeyFile.pem}"
storage: storage:
max_read_records_count: "${EDGES_RPC_STORAGE_MAX_READ_RECORDS_COUNT:50}" max_read_records_count: "${EDGES_STORAGE_MAX_READ_RECORDS_COUNT:50}"
no_read_records_sleep: "${EDGES_RPC_NO_READ_RECORDS_SLEEP:1000}" no_read_records_sleep: "${EDGES_NO_READ_RECORDS_SLEEP:1000}"
sleep_between_batches: "${EDGES_RPC_SLEEP_BETWEEN_BATCHES:1000}" sleep_between_batches: "${EDGES_SLEEP_BETWEEN_BATCHES:1000}"
scheduler_pool_size: "${EDGES_SCHEDULER_POOL_SIZE:4}" scheduler_pool_size: "${EDGES_SCHEDULER_POOL_SIZE:4}"
edge_events_ttl: "${EDGES_EDGE_EVENTS_TTL:0}" edge_events_ttl: "${EDGES_EDGE_EVENTS_TTL:0}"
state: state:

6
dao/src/main/java/org/thingsboard/server/dao/edge/EdgeServiceImpl.java

@ -126,12 +126,12 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic
@Autowired @Autowired
private RelationService relationService; private RelationService relationService;
@Value("${edges.rpc.enabled:false}") @Value("${edges.enabled:false}")
private boolean edgesRpcEnabled; private boolean edgesEnabled;
@PostConstruct @PostConstruct
public void init() { public void init() {
if (edgesRpcEnabled) { if (edgesEnabled) {
initRestTemplate(); initRestTemplate();
} }
} }

8
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -1204,7 +1204,7 @@
"selected-edges": "{ count, plural, 1 {1 edge} other {# edges} } selected", "selected-edges": "{ count, plural, 1 {1 edge} other {# edges} } selected",
"any-edge": "Any edge", "any-edge": "Any edge",
"no-edge-types-matching": "No edge types matching '{{entitySubtype}}' were found.", "no-edge-types-matching": "No edge types matching '{{entitySubtype}}' were found.",
"edge-type-list-empty": "No device types selected.", "edge-type-list-empty": "No edge types selected.",
"edge-types": "Edge types", "edge-types": "Edge types",
"dashboard": "Edge dashboard", "dashboard": "Edge dashboard",
"unassign-edges-action-title": "Unassign { count, plural, 1 {1 edge} other {# edges} } from customer", "unassign-edges-action-title": "Unassign { count, plural, 1 {1 edge} other {# edges} } from customer",
@ -1863,7 +1863,11 @@
"entity-field": "Entity field", "entity-field": "Entity field",
"access-token": "Access token", "access-token": "Access token",
"isgateway": "Is Gateway", "isgateway": "Is Gateway",
"description": "Description" "description": "Description",
"edgeLicenseKey": "License Key",
"cloudEndpoint": "Cloud Endpoint",
"routingKey": "Edge key",
"secret": "Edge secret"
}, },
"stepper-text":{ "stepper-text":{
"select-file": "Select a file", "select-file": "Select a file",

Loading…
Cancel
Save