Merge pull request #11139 from AndriiLandiak/feature/edge-proxy-rpc
[Edge] Proxy for grpc client
This commit is contained in:
commit
f5a85cafe8
@ -270,9 +270,10 @@ public class TenantActor extends RuleChainManagerActor {
|
|||||||
initRuleChains();
|
initRuleChains();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg.getEntityId().getEntityType() == EntityType.EDGE) {
|
if (msg.getEntityId().getEntityType() == EntityType.EDGE && isCore) {
|
||||||
EdgeId edgeId = new EdgeId(msg.getEntityId().getId());
|
EdgeId edgeId = new EdgeId(msg.getEntityId().getId());
|
||||||
EdgeRpcService edgeRpcService = systemContext.getEdgeRpcService();
|
EdgeRpcService edgeRpcService = systemContext.getEdgeRpcService();
|
||||||
|
if (edgeRpcService != null) {
|
||||||
if (msg.getEvent() == ComponentLifecycleEvent.DELETED) {
|
if (msg.getEvent() == ComponentLifecycleEvent.DELETED) {
|
||||||
edgeRpcService.deleteEdge(tenantId, edgeId);
|
edgeRpcService.deleteEdge(tenantId, edgeId);
|
||||||
} else if (msg.getEvent() == ComponentLifecycleEvent.UPDATED) {
|
} else if (msg.getEvent() == ComponentLifecycleEvent.UPDATED) {
|
||||||
@ -280,6 +281,7 @@ public class TenantActor extends RuleChainManagerActor {
|
|||||||
edgeRpcService.updateEdge(tenantId, edge);
|
edgeRpcService.updateEdge(tenantId, edge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (msg.getEntityId().getEntityType() == EntityType.DEVICE && ComponentLifecycleEvent.DELETED == msg.getEvent() && isMyPartition(msg.getEntityId())) {
|
if (msg.getEntityId().getEntityType() == EntityType.DEVICE && ComponentLifecycleEvent.DELETED == msg.getEvent() && isMyPartition(msg.getEntityId())) {
|
||||||
DeviceId deviceId = (DeviceId) msg.getEntityId();
|
DeviceId deviceId = (DeviceId) msg.getEntityId();
|
||||||
onToDeviceActorMsg(new DeviceDeleteMsg(tenantId, deviceId), true);
|
onToDeviceActorMsg(new DeviceDeleteMsg(tenantId, deviceId), true);
|
||||||
|
|||||||
@ -18,24 +18,20 @@ package org.thingsboard.server.controller;
|
|||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||||
import io.swagger.v3.oas.annotations.media.Content;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.context.request.async.DeferredResult;
|
import org.springframework.web.context.request.async.DeferredResult;
|
||||||
import org.thingsboard.rule.engine.flow.TbRuleChainInputNode;
|
import org.thingsboard.rule.engine.flow.TbRuleChainInputNode;
|
||||||
@ -114,8 +110,7 @@ public class EdgeController extends BaseController {
|
|||||||
@ApiOperation(value = "Is edges support enabled (isEdgesSupportEnabled)",
|
@ApiOperation(value = "Is edges support enabled (isEdgesSupportEnabled)",
|
||||||
notes = "Returns 'true' if edges support enabled on server, 'false' - otherwise.")
|
notes = "Returns 'true' if edges support enabled on server, 'false' - otherwise.")
|
||||||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/edges/enabled", method = RequestMethod.GET)
|
@GetMapping(value = "/edges/enabled")
|
||||||
@ResponseBody
|
|
||||||
public boolean isEdgesSupportEnabled() {
|
public boolean isEdgesSupportEnabled() {
|
||||||
return edgesEnabled;
|
return edgesEnabled;
|
||||||
}
|
}
|
||||||
@ -123,8 +118,7 @@ public class EdgeController extends BaseController {
|
|||||||
@ApiOperation(value = "Get Edge (getEdgeById)",
|
@ApiOperation(value = "Get Edge (getEdgeById)",
|
||||||
notes = "Get the Edge object based on the provided Edge Id. " + EDGE_SECURITY_CHECK + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
notes = "Get the Edge object based on the provided Edge Id. " + EDGE_SECURITY_CHECK + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.GET)
|
@GetMapping(value = "/edge/{edgeId}")
|
||||||
@ResponseBody
|
|
||||||
public Edge getEdgeById(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
public Edge getEdgeById(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||||
checkParameter(EDGE_ID, strEdgeId);
|
checkParameter(EDGE_ID, strEdgeId);
|
||||||
@ -135,8 +129,7 @@ public class EdgeController extends BaseController {
|
|||||||
@ApiOperation(value = "Get Edge Info (getEdgeInfoById)",
|
@ApiOperation(value = "Get Edge Info (getEdgeInfoById)",
|
||||||
notes = "Get the Edge Info object based on the provided Edge Id. " + EDGE_SECURITY_CHECK + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
notes = "Get the Edge Info object based on the provided Edge Id. " + EDGE_SECURITY_CHECK + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/edge/info/{edgeId}", method = RequestMethod.GET)
|
@GetMapping(value = "/edge/info/{edgeId}")
|
||||||
@ResponseBody
|
|
||||||
public EdgeInfo getEdgeInfoById(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
public EdgeInfo getEdgeInfoById(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||||
checkParameter(EDGE_ID, strEdgeId);
|
checkParameter(EDGE_ID, strEdgeId);
|
||||||
@ -153,8 +146,7 @@ public class EdgeController extends BaseController {
|
|||||||
"Remove 'id', 'tenantId' and optionally 'customerId' from the request body example (below) to create new Edge entity. " +
|
"Remove 'id', 'tenantId' and optionally 'customerId' from the request body example (below) to create new Edge entity. " +
|
||||||
TENANT_AUTHORITY_PARAGRAPH)
|
TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/edge", method = RequestMethod.POST)
|
@PostMapping(value = "/edge")
|
||||||
@ResponseBody
|
|
||||||
public Edge saveEdge(@Parameter(description = "A JSON value representing the edge.", required = true)
|
public Edge saveEdge(@Parameter(description = "A JSON value representing the edge.", required = true)
|
||||||
@RequestBody Edge edge) throws Exception {
|
@RequestBody Edge edge) throws Exception {
|
||||||
TenantId tenantId = getTenantId();
|
TenantId tenantId = getTenantId();
|
||||||
@ -179,8 +171,7 @@ public class EdgeController extends BaseController {
|
|||||||
@ApiOperation(value = "Delete edge (deleteEdge)",
|
@ApiOperation(value = "Delete edge (deleteEdge)",
|
||||||
notes = "Deletes the edge. Referencing non-existing edge Id will cause an error." + TENANT_AUTHORITY_PARAGRAPH)
|
notes = "Deletes the edge. Referencing non-existing edge Id will cause an error." + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.DELETE)
|
@DeleteMapping(value = "/edge/{edgeId}")
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
|
||||||
public void deleteEdge(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
public void deleteEdge(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||||
checkParameter(EDGE_ID, strEdgeId);
|
checkParameter(EDGE_ID, strEdgeId);
|
||||||
@ -193,8 +184,7 @@ public class EdgeController extends BaseController {
|
|||||||
notes = "Returns a page of edges owned by tenant. " +
|
notes = "Returns a page of edges owned by tenant. " +
|
||||||
PAGE_DATA_PARAMETERS + TENANT_AUTHORITY_PARAGRAPH)
|
PAGE_DATA_PARAMETERS + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
@GetMapping(value = "/edges", params = {"pageSize", "page"})
|
||||||
@ResponseBody
|
|
||||||
public PageData<Edge> getEdges(@Parameter(description = PAGE_SIZE_DESCRIPTION, required = true)
|
public PageData<Edge> getEdges(@Parameter(description = PAGE_SIZE_DESCRIPTION, required = true)
|
||||||
@RequestParam int pageSize,
|
@RequestParam int pageSize,
|
||||||
@Parameter(description = PAGE_NUMBER_DESCRIPTION, required = true)
|
@Parameter(description = PAGE_NUMBER_DESCRIPTION, required = true)
|
||||||
@ -213,8 +203,7 @@ public class EdgeController extends BaseController {
|
|||||||
@ApiOperation(value = "Assign edge to customer (assignEdgeToCustomer)",
|
@ApiOperation(value = "Assign edge to customer (assignEdgeToCustomer)",
|
||||||
notes = "Creates assignment of the edge to customer. Customer will be able to query edge afterwards." + TENANT_AUTHORITY_PARAGRAPH)
|
notes = "Creates assignment of the edge to customer. Customer will be able to query edge afterwards." + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/customer/{customerId}/edge/{edgeId}", method = RequestMethod.POST)
|
@PostMapping(value = "/customer/{customerId}/edge/{edgeId}")
|
||||||
@ResponseBody
|
|
||||||
public Edge assignEdgeToCustomer(@Parameter(description = CUSTOMER_ID_PARAM_DESCRIPTION, required = true)
|
public Edge assignEdgeToCustomer(@Parameter(description = CUSTOMER_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@PathVariable("customerId") String strCustomerId,
|
@PathVariable("customerId") String strCustomerId,
|
||||||
@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@ -231,8 +220,7 @@ public class EdgeController extends BaseController {
|
|||||||
@ApiOperation(value = "Unassign edge from customer (unassignEdgeFromCustomer)",
|
@ApiOperation(value = "Unassign edge from customer (unassignEdgeFromCustomer)",
|
||||||
notes = "Clears assignment of the edge to customer. Customer will not be able to query edge afterwards." + TENANT_AUTHORITY_PARAGRAPH)
|
notes = "Clears assignment of the edge to customer. Customer will not be able to query edge afterwards." + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/customer/edge/{edgeId}", method = RequestMethod.DELETE)
|
@DeleteMapping(value = "/customer/edge/{edgeId}")
|
||||||
@ResponseBody
|
|
||||||
public Edge unassignEdgeFromCustomer(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
public Edge unassignEdgeFromCustomer(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||||
checkParameter(EDGE_ID, strEdgeId);
|
checkParameter(EDGE_ID, strEdgeId);
|
||||||
@ -251,8 +239,7 @@ public class EdgeController extends BaseController {
|
|||||||
"This is useful to create dashboards that you plan to share/embed on a publicly available website. " +
|
"This is useful to create dashboards that you plan to share/embed on a publicly available website. " +
|
||||||
"However, users that are logged-in and belong to different tenant will not be able to access the edge." + TENANT_AUTHORITY_PARAGRAPH)
|
"However, users that are logged-in and belong to different tenant will not be able to access the edge." + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/customer/public/edge/{edgeId}", method = RequestMethod.POST)
|
@PostMapping(value = "/customer/public/edge/{edgeId}")
|
||||||
@ResponseBody
|
|
||||||
public Edge assignEdgeToPublicCustomer(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
public Edge assignEdgeToPublicCustomer(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||||
checkParameter(EDGE_ID, strEdgeId);
|
checkParameter(EDGE_ID, strEdgeId);
|
||||||
@ -265,8 +252,7 @@ public class EdgeController extends BaseController {
|
|||||||
notes = "Returns a page of edges owned by tenant. " +
|
notes = "Returns a page of edges owned by tenant. " +
|
||||||
PAGE_DATA_PARAMETERS + TENANT_AUTHORITY_PARAGRAPH)
|
PAGE_DATA_PARAMETERS + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/tenant/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
@GetMapping(value = "/tenant/edges", params = {"pageSize", "page"})
|
||||||
@ResponseBody
|
|
||||||
public PageData<Edge> getTenantEdges(
|
public PageData<Edge> getTenantEdges(
|
||||||
@Parameter(description = PAGE_SIZE_DESCRIPTION, required = true)
|
@Parameter(description = PAGE_SIZE_DESCRIPTION, required = true)
|
||||||
@RequestParam int pageSize,
|
@RequestParam int pageSize,
|
||||||
@ -293,8 +279,7 @@ public class EdgeController extends BaseController {
|
|||||||
notes = "Returns a page of edges info objects owned by tenant. " +
|
notes = "Returns a page of edges info objects owned by tenant. " +
|
||||||
PAGE_DATA_PARAMETERS + EDGE_INFO_DESCRIPTION + TENANT_AUTHORITY_PARAGRAPH)
|
PAGE_DATA_PARAMETERS + EDGE_INFO_DESCRIPTION + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/tenant/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
@GetMapping(value = "/tenant/edgeInfos", params = {"pageSize", "page"})
|
||||||
@ResponseBody
|
|
||||||
public PageData<EdgeInfo> getTenantEdgeInfos(
|
public PageData<EdgeInfo> getTenantEdgeInfos(
|
||||||
@Parameter(description = PAGE_SIZE_DESCRIPTION, required = true)
|
@Parameter(description = PAGE_SIZE_DESCRIPTION, required = true)
|
||||||
@RequestParam int pageSize,
|
@RequestParam int pageSize,
|
||||||
@ -321,8 +306,7 @@ public class EdgeController extends BaseController {
|
|||||||
notes = "Requested edge must be owned by tenant or customer that the user belongs to. " +
|
notes = "Requested edge must be owned by tenant or customer that the user belongs to. " +
|
||||||
"Edge name is an unique property of edge. So it can be used to identify the edge." + TENANT_AUTHORITY_PARAGRAPH)
|
"Edge name is an unique property of edge. So it can be used to identify the edge." + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/tenant/edges", params = {"edgeName"}, method = RequestMethod.GET)
|
@GetMapping(value = "/tenant/edges", params = {"edgeName"})
|
||||||
@ResponseBody
|
|
||||||
public Edge getTenantEdge(@Parameter(description = "Unique name of the edge", required = true)
|
public Edge getTenantEdge(@Parameter(description = "Unique name of the edge", required = true)
|
||||||
@RequestParam String edgeName) throws ThingsboardException {
|
@RequestParam String edgeName) throws ThingsboardException {
|
||||||
TenantId tenantId = getCurrentUser().getTenantId();
|
TenantId tenantId = getCurrentUser().getTenantId();
|
||||||
@ -333,8 +317,7 @@ public class EdgeController extends BaseController {
|
|||||||
notes = "Change root rule chain of the edge to the new provided rule chain. \n" +
|
notes = "Change root rule chain of the edge to the new provided rule chain. \n" +
|
||||||
"This operation will send a notification to update root rule chain on remote edge service." + TENANT_AUTHORITY_PARAGRAPH)
|
"This operation will send a notification to update root rule chain on remote edge service." + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST)
|
@PostMapping(value = "/edge/{edgeId}/{ruleChainId}/root")
|
||||||
@ResponseBody
|
|
||||||
public Edge setEdgeRootRuleChain(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
public Edge setEdgeRootRuleChain(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@PathVariable(EDGE_ID) String strEdgeId,
|
@PathVariable(EDGE_ID) String strEdgeId,
|
||||||
@Parameter(description = RULE_CHAIN_ID_PARAM_DESCRIPTION, required = true)
|
@Parameter(description = RULE_CHAIN_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@ -353,8 +336,7 @@ public class EdgeController extends BaseController {
|
|||||||
notes = "Returns a page of edges objects assigned to customer. " +
|
notes = "Returns a page of edges objects assigned to customer. " +
|
||||||
PAGE_DATA_PARAMETERS + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
PAGE_DATA_PARAMETERS + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/customer/{customerId}/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
@GetMapping(value = "/customer/{customerId}/edges", params = {"pageSize", "page"})
|
||||||
@ResponseBody
|
|
||||||
public PageData<Edge> getCustomerEdges(
|
public PageData<Edge> getCustomerEdges(
|
||||||
@Parameter(description = CUSTOMER_ID_PARAM_DESCRIPTION)
|
@Parameter(description = CUSTOMER_ID_PARAM_DESCRIPTION)
|
||||||
@PathVariable("customerId") String strCustomerId,
|
@PathVariable("customerId") String strCustomerId,
|
||||||
@ -389,8 +371,7 @@ public class EdgeController extends BaseController {
|
|||||||
notes = "Returns a page of edges info objects assigned to customer. " +
|
notes = "Returns a page of edges info objects assigned to customer. " +
|
||||||
PAGE_DATA_PARAMETERS + EDGE_INFO_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
PAGE_DATA_PARAMETERS + EDGE_INFO_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/customer/{customerId}/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
@GetMapping(value = "/customer/{customerId}/edgeInfos", params = {"pageSize", "page"})
|
||||||
@ResponseBody
|
|
||||||
public PageData<EdgeInfo> getCustomerEdgeInfos(
|
public PageData<EdgeInfo> getCustomerEdgeInfos(
|
||||||
@Parameter(description = CUSTOMER_ID_PARAM_DESCRIPTION)
|
@Parameter(description = CUSTOMER_ID_PARAM_DESCRIPTION)
|
||||||
@PathVariable("customerId") String strCustomerId,
|
@PathVariable("customerId") String strCustomerId,
|
||||||
@ -424,8 +405,7 @@ public class EdgeController extends BaseController {
|
|||||||
@ApiOperation(value = "Get Edges By Ids (getEdgesByIds)",
|
@ApiOperation(value = "Get Edges By Ids (getEdgesByIds)",
|
||||||
notes = "Requested edges must be owned by tenant or assigned to customer which user is performing the request." + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
notes = "Requested edges must be owned by tenant or assigned to customer which user is performing the request." + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/edges", params = {"edgeIds"}, method = RequestMethod.GET)
|
@GetMapping(value = "/edges", params = {"edgeIds"})
|
||||||
@ResponseBody
|
|
||||||
public List<Edge> getEdgesByIds(
|
public List<Edge> getEdgesByIds(
|
||||||
@Parameter(description = "A list of edges ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true)
|
@Parameter(description = "A list of edges ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true)
|
||||||
@RequestParam("edgeIds") String[] strEdgeIds) throws ThingsboardException, ExecutionException, InterruptedException {
|
@RequestParam("edgeIds") String[] strEdgeIds) throws ThingsboardException, ExecutionException, InterruptedException {
|
||||||
@ -452,8 +432,7 @@ public class EdgeController extends BaseController {
|
|||||||
"The entity id, relation type, edge types, depth of the search, and other query parameters defined using complex 'EdgeSearchQuery' object. " +
|
"The entity id, relation type, edge types, depth of the search, and other query parameters defined using complex 'EdgeSearchQuery' object. " +
|
||||||
"See 'Model' tab of the Parameters for more info." + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
"See 'Model' tab of the Parameters for more info." + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/edges", method = RequestMethod.POST)
|
@PostMapping(value = "/edges")
|
||||||
@ResponseBody
|
|
||||||
public List<Edge> findByQuery(@RequestBody EdgeSearchQuery query) throws ThingsboardException, ExecutionException, InterruptedException {
|
public List<Edge> findByQuery(@RequestBody EdgeSearchQuery query) throws ThingsboardException, ExecutionException, InterruptedException {
|
||||||
checkNotNull(query);
|
checkNotNull(query);
|
||||||
checkNotNull(query.getParameters());
|
checkNotNull(query.getParameters());
|
||||||
@ -477,8 +456,7 @@ public class EdgeController extends BaseController {
|
|||||||
notes = "Returns a set of unique edge types based on edges that are either owned by the tenant or assigned to the customer which user is performing the request."
|
notes = "Returns a set of unique edge types based on edges that are either owned by the tenant or assigned to the customer which user is performing the request."
|
||||||
+ TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
+ TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/edge/types", method = RequestMethod.GET)
|
@GetMapping(value = "/edge/types")
|
||||||
@ResponseBody
|
|
||||||
public List<EntitySubtype> getEdgeTypes() throws ThingsboardException, ExecutionException, InterruptedException {
|
public List<EntitySubtype> getEdgeTypes() throws ThingsboardException, ExecutionException, InterruptedException {
|
||||||
SecurityUser user = getCurrentUser();
|
SecurityUser user = getCurrentUser();
|
||||||
TenantId tenantId = user.getTenantId();
|
TenantId tenantId = user.getTenantId();
|
||||||
@ -490,7 +468,7 @@ public class EdgeController extends BaseController {
|
|||||||
notes = "Starts synchronization process between edge and cloud. \n" +
|
notes = "Starts synchronization process between edge and cloud. \n" +
|
||||||
"All entities that are assigned to particular edge are going to be send to remote edge service." + TENANT_AUTHORITY_PARAGRAPH)
|
"All entities that are assigned to particular edge are going to be send to remote edge service." + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/edge/sync/{edgeId}", method = RequestMethod.POST)
|
@PostMapping(value = "/edge/sync/{edgeId}")
|
||||||
public DeferredResult<ResponseEntity> syncEdge(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
public DeferredResult<ResponseEntity> syncEdge(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
|
@PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
|
||||||
checkParameter("edgeId", strEdgeId);
|
checkParameter("edgeId", strEdgeId);
|
||||||
@ -519,8 +497,7 @@ public class EdgeController extends BaseController {
|
|||||||
@ApiOperation(value = "Find missing rule chains (findMissingToRelatedRuleChains)",
|
@ApiOperation(value = "Find missing rule chains (findMissingToRelatedRuleChains)",
|
||||||
notes = "Returns list of rule chains ids that are not assigned to particular edge, but these rule chains are present in the already assigned rule chains to edge." + TENANT_AUTHORITY_PARAGRAPH)
|
notes = "Returns list of rule chains ids that are not assigned to particular edge, but these rule chains are present in the already assigned rule chains to edge." + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET)
|
@GetMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}")
|
||||||
@ResponseBody
|
|
||||||
public String findMissingToRelatedRuleChains(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
public String findMissingToRelatedRuleChains(@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
|
@PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
|
||||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||||
@ -547,8 +524,7 @@ public class EdgeController extends BaseController {
|
|||||||
@ApiOperation(value = "Get Edge Install Instructions (getEdgeInstallInstructions)",
|
@ApiOperation(value = "Get Edge Install Instructions (getEdgeInstallInstructions)",
|
||||||
notes = "Get an install instructions for provided edge id." + TENANT_AUTHORITY_PARAGRAPH)
|
notes = "Get an install instructions for provided edge id." + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/edge/instructions/install/{edgeId}/{method}", method = RequestMethod.GET)
|
@GetMapping(value = "/edge/instructions/install/{edgeId}/{method}")
|
||||||
@ResponseBody
|
|
||||||
public EdgeInstructions getEdgeInstallInstructions(
|
public EdgeInstructions getEdgeInstallInstructions(
|
||||||
@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@PathVariable("edgeId") String strEdgeId,
|
@PathVariable("edgeId") String strEdgeId,
|
||||||
@ -568,8 +544,7 @@ public class EdgeController extends BaseController {
|
|||||||
@ApiOperation(value = "Get Edge Upgrade Instructions (getEdgeUpgradeInstructions)",
|
@ApiOperation(value = "Get Edge Upgrade Instructions (getEdgeUpgradeInstructions)",
|
||||||
notes = "Get an upgrade instructions for provided edge version." + TENANT_AUTHORITY_PARAGRAPH)
|
notes = "Get an upgrade instructions for provided edge version." + TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/edge/instructions/upgrade/{edgeVersion}/{method}", method = RequestMethod.GET)
|
@GetMapping(value = "/edge/instructions/upgrade/{edgeVersion}/{method}")
|
||||||
@ResponseBody
|
|
||||||
public EdgeInstructions getEdgeUpgradeInstructions(
|
public EdgeInstructions getEdgeUpgradeInstructions(
|
||||||
@Parameter(description = "Edge version", required = true)
|
@Parameter(description = "Edge version", required = true)
|
||||||
@PathVariable("edgeVersion") String edgeVersion,
|
@PathVariable("edgeVersion") String edgeVersion,
|
||||||
@ -585,8 +560,7 @@ public class EdgeController extends BaseController {
|
|||||||
@ApiOperation(value = "Is edge upgrade enabled (isEdgeUpgradeAvailable)",
|
@ApiOperation(value = "Is edge upgrade enabled (isEdgeUpgradeAvailable)",
|
||||||
notes = "Returns 'true' if upgrade available for connected edge, 'false' - otherwise.")
|
notes = "Returns 'true' if upgrade available for connected edge, 'false' - otherwise.")
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/edge/{edgeId}/upgrade/available", method = RequestMethod.GET)
|
@GetMapping(value = "/edge/{edgeId}/upgrade/available")
|
||||||
@ResponseBody
|
|
||||||
public boolean isEdgeUpgradeAvailable(
|
public boolean isEdgeUpgradeAvailable(
|
||||||
@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@PathVariable("edgeId") String strEdgeId) throws Exception {
|
@PathVariable("edgeId") String strEdgeId) throws Exception {
|
||||||
@ -599,4 +573,5 @@ public class EdgeController extends BaseController {
|
|||||||
throw new ThingsboardException("Edges support disabled", ThingsboardErrorCode.GENERAL);
|
throw new ThingsboardException("Edges support disabled", ThingsboardErrorCode.GENERAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,18 +16,14 @@
|
|||||||
package org.thingsboard.server.controller;
|
package org.thingsboard.server.controller;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.media.Content;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.thingsboard.server.common.data.edge.EdgeEvent;
|
import org.thingsboard.server.common.data.edge.EdgeEvent;
|
||||||
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
||||||
@ -62,8 +58,7 @@ public class EdgeEventController extends BaseController {
|
|||||||
notes = "Returns a page of edge events for the requested edge. " +
|
notes = "Returns a page of edge events for the requested edge. " +
|
||||||
PAGE_DATA_PARAMETERS)
|
PAGE_DATA_PARAMETERS)
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/edge/{edgeId}/events", method = RequestMethod.GET)
|
@GetMapping(value = "/edge/{edgeId}/events")
|
||||||
@ResponseBody
|
|
||||||
public PageData<EdgeEvent> getEdgeEvents(
|
public PageData<EdgeEvent> getEdgeEvents(
|
||||||
@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
@Parameter(description = EDGE_ID_PARAM_DESCRIPTION, required = true)
|
||||||
@PathVariable(EDGE_ID) String strEdgeId,
|
@PathVariable(EDGE_ID) String strEdgeId,
|
||||||
@ -88,4 +83,5 @@ public class EdgeEventController extends BaseController {
|
|||||||
TimePageLink pageLink = createTimePageLink(pageSize, page, textSearch, sortProperty, sortOrder, startTime, endTime);
|
TimePageLink pageLink = createTimePageLink(pageSize, page, textSearch, sortProperty, sortOrder, startTime, endTime);
|
||||||
return checkNotNull(edgeEventService.findEdgeEvents(tenantId, edgeId, 0L, null, pageLink));
|
return checkNotNull(edgeEventService.findEdgeEvents(tenantId, edgeId, 0L, null, pageLink));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,9 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.service.edge.instructions;
|
package org.thingsboard.server.service.edge.instructions;
|
||||||
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.common.data.AttributeScope;
|
import org.thingsboard.server.common.data.AttributeScope;
|
||||||
@ -164,4 +162,5 @@ public class DefaultEdgeUpgradeInstructionsService extends BaseEdgeInstallUpgrad
|
|||||||
protected String getBaseDirName() {
|
protected String getBaseDirName() {
|
||||||
return UPGRADE_DIR;
|
return UPGRADE_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,14 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.service.edge.instructions;
|
package org.thingsboard.server.service.edge.instructions;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.thingsboard.server.common.data.edge.Edge;
|
import org.thingsboard.server.common.data.edge.Edge;
|
||||||
import org.thingsboard.server.common.data.edge.EdgeInstructions;
|
import org.thingsboard.server.common.data.edge.EdgeInstructions;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
public interface EdgeInstallInstructionsService {
|
public interface EdgeInstallInstructionsService {
|
||||||
|
|
||||||
EdgeInstructions getInstallInstructions(Edge edge, String installationMethod, HttpServletRequest request);
|
EdgeInstructions getInstallInstructions(Edge edge, String installationMethod, HttpServletRequest request);
|
||||||
|
|
||||||
void setAppVersion(String version);
|
void setAppVersion(String version);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,9 @@ import com.google.common.util.concurrent.Futures;
|
|||||||
import io.grpc.Server;
|
import io.grpc.Server;
|
||||||
import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder;
|
import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder;
|
||||||
import io.grpc.stub.StreamObserver;
|
import io.grpc.stub.StreamObserver;
|
||||||
|
import jakarta.annotation.Nullable;
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import jakarta.annotation.PreDestroy;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -55,9 +58,6 @@ import org.thingsboard.server.service.edge.EdgeContextComponent;
|
|||||||
import org.thingsboard.server.service.state.DefaultDeviceStateService;
|
import org.thingsboard.server.service.state.DefaultDeviceStateService;
|
||||||
import org.thingsboard.server.service.telemetry.TelemetrySubscriptionService;
|
import org.thingsboard.server.service.telemetry.TelemetrySubscriptionService;
|
||||||
|
|
||||||
import jakarta.annotation.Nullable;
|
|
||||||
import jakarta.annotation.PostConstruct;
|
|
||||||
import jakarta.annotation.PreDestroy;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|||||||
@ -23,12 +23,12 @@ import com.google.gson.JsonPrimitive;
|
|||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.thingsboard.server.common.adaptor.JsonConverter;
|
||||||
import org.thingsboard.server.common.data.DataConstants;
|
import org.thingsboard.server.common.data.DataConstants;
|
||||||
import org.thingsboard.server.common.data.StringUtils;
|
import org.thingsboard.server.common.data.StringUtils;
|
||||||
import org.thingsboard.server.common.data.edge.EdgeEventActionType;
|
import org.thingsboard.server.common.data.edge.EdgeEventActionType;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.adaptor.JsonConverter;
|
|
||||||
import org.thingsboard.server.gen.edge.v1.AttributeDeleteMsg;
|
import org.thingsboard.server.gen.edge.v1.AttributeDeleteMsg;
|
||||||
import org.thingsboard.server.gen.edge.v1.EntityDataProto;
|
import org.thingsboard.server.gen.edge.v1.EntityDataProto;
|
||||||
import org.thingsboard.server.gen.transport.TransportProtos;
|
import org.thingsboard.server.gen.transport.TransportProtos;
|
||||||
@ -106,4 +106,5 @@ public class EntityDataMsgConstructor {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import org.springframework.stereotype.Component;
|
|||||||
import org.thingsboard.common.util.JacksonUtil;
|
import org.thingsboard.common.util.JacksonUtil;
|
||||||
import org.thingsboard.server.common.data.Tenant;
|
import org.thingsboard.server.common.data.Tenant;
|
||||||
import org.thingsboard.server.common.data.TenantProfile;
|
import org.thingsboard.server.common.data.TenantProfile;
|
||||||
import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration;
|
|
||||||
import org.thingsboard.server.gen.edge.v1.EdgeVersion;
|
import org.thingsboard.server.gen.edge.v1.EdgeVersion;
|
||||||
import org.thingsboard.server.gen.edge.v1.TenantProfileUpdateMsg;
|
import org.thingsboard.server.gen.edge.v1.TenantProfileUpdateMsg;
|
||||||
import org.thingsboard.server.gen.edge.v1.TenantUpdateMsg;
|
import org.thingsboard.server.gen.edge.v1.TenantUpdateMsg;
|
||||||
@ -37,22 +36,6 @@ public class TenantMsgConstructorV2 implements TenantMsgConstructor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TenantProfileUpdateMsg constructTenantProfileUpdateMsg(UpdateMsgType msgType, TenantProfile tenantProfile, EdgeVersion edgeVersion) {
|
public TenantProfileUpdateMsg constructTenantProfileUpdateMsg(UpdateMsgType msgType, TenantProfile tenantProfile, EdgeVersion edgeVersion) {
|
||||||
tenantProfile = JacksonUtil.clone(tenantProfile);
|
|
||||||
// clear all config
|
|
||||||
var configuration = tenantProfile.getDefaultProfileConfiguration();
|
|
||||||
configuration.setRpcTtlDays(0);
|
|
||||||
configuration.setMaxJSExecutions(0);
|
|
||||||
configuration.setMaxREExecutions(0);
|
|
||||||
configuration.setMaxDPStorageDays(0);
|
|
||||||
configuration.setMaxTbelExecutions(0);
|
|
||||||
configuration.setQueueStatsTtlDays(0);
|
|
||||||
configuration.setMaxTransportMessages(0);
|
|
||||||
configuration.setDefaultStorageTtlDays(0);
|
|
||||||
configuration.setMaxTransportDataPoints(0);
|
|
||||||
configuration.setRuleEngineExceptionsTtlDays(0);
|
|
||||||
configuration.setMaxRuleNodeExecutionsPerMessage(0);
|
|
||||||
tenantProfile.getProfileData().setConfiguration(configuration);
|
|
||||||
|
|
||||||
return TenantProfileUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(tenantProfile)).build();
|
return TenantProfileUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(tenantProfile)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,6 @@ import org.thingsboard.server.common.data.edge.EdgeEvent;
|
|||||||
import org.thingsboard.server.common.data.id.EdgeId;
|
import org.thingsboard.server.common.data.id.EdgeId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.gen.edge.v1.DeviceCredentialsUpdateMsg;
|
import org.thingsboard.server.gen.edge.v1.DeviceCredentialsUpdateMsg;
|
||||||
import org.thingsboard.server.gen.edge.v1.DeviceProfileUpdateMsg;
|
|
||||||
import org.thingsboard.server.gen.edge.v1.DeviceRpcCallMsg;
|
import org.thingsboard.server.gen.edge.v1.DeviceRpcCallMsg;
|
||||||
import org.thingsboard.server.gen.edge.v1.DeviceUpdateMsg;
|
import org.thingsboard.server.gen.edge.v1.DeviceUpdateMsg;
|
||||||
import org.thingsboard.server.gen.edge.v1.DownlinkMsg;
|
import org.thingsboard.server.gen.edge.v1.DownlinkMsg;
|
||||||
@ -37,4 +36,5 @@ public interface DeviceProcessor extends EdgeProcessor {
|
|||||||
DownlinkMsg convertDeviceEventToDownlink(EdgeEvent edgeEvent, EdgeId edgeId, EdgeVersion edgeVersion);
|
DownlinkMsg convertDeviceEventToDownlink(EdgeEvent edgeEvent, EdgeId edgeId, EdgeVersion edgeVersion);
|
||||||
|
|
||||||
ListenableFuture<Void> processDeviceRpcCallFromEdge(TenantId tenantId, Edge edge, DeviceRpcCallMsg deviceRpcCallMsg);
|
ListenableFuture<Void> processDeviceRpcCallFromEdge(TenantId tenantId, Edge edge, DeviceRpcCallMsg deviceRpcCallMsg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.edge.rpc;
|
package org.thingsboard.edge.rpc;
|
||||||
|
|
||||||
|
import io.grpc.HttpConnectProxiedSocketAddress;
|
||||||
import io.grpc.ManagedChannel;
|
import io.grpc.ManagedChannel;
|
||||||
import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts;
|
import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts;
|
||||||
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;
|
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;
|
||||||
@ -43,6 +44,7 @@ import org.thingsboard.server.gen.edge.v1.UplinkMsg;
|
|||||||
import org.thingsboard.server.gen.edge.v1.UplinkResponseMsg;
|
import org.thingsboard.server.gen.edge.v1.UplinkResponseMsg;
|
||||||
|
|
||||||
import javax.net.ssl.SSLException;
|
import javax.net.ssl.SSLException;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -67,6 +69,16 @@ public class EdgeGrpcClient implements EdgeRpcClient {
|
|||||||
private String certResource;
|
private String certResource;
|
||||||
@Value("${cloud.rpc.max_inbound_message_size:4194304}")
|
@Value("${cloud.rpc.max_inbound_message_size:4194304}")
|
||||||
private int maxInboundMessageSize;
|
private int maxInboundMessageSize;
|
||||||
|
@Value("${cloud.rpc.proxy.enabled}")
|
||||||
|
private boolean proxyEnabled;
|
||||||
|
@Value("${cloud.rpc.proxy.host:}")
|
||||||
|
private String proxyHost;
|
||||||
|
@Value("${cloud.rpc.proxy.port:0}")
|
||||||
|
private int proxyPort;
|
||||||
|
@Value("${cloud.rpc.proxy.username:}")
|
||||||
|
private String proxyUsername;
|
||||||
|
@Value("${cloud.rpc.proxy.password:}")
|
||||||
|
private String proxyPassword;
|
||||||
@Getter
|
@Getter
|
||||||
private int serverMaxInboundMessageSize;
|
private int serverMaxInboundMessageSize;
|
||||||
|
|
||||||
@ -88,6 +100,7 @@ public class EdgeGrpcClient implements EdgeRpcClient {
|
|||||||
.keepAliveTime(keepAliveTimeSec, TimeUnit.SECONDS)
|
.keepAliveTime(keepAliveTimeSec, TimeUnit.SECONDS)
|
||||||
.keepAliveTimeout(keepAliveTimeoutSec, TimeUnit.SECONDS)
|
.keepAliveTimeout(keepAliveTimeoutSec, TimeUnit.SECONDS)
|
||||||
.keepAliveWithoutCalls(true);
|
.keepAliveWithoutCalls(true);
|
||||||
|
|
||||||
if (sslEnabled) {
|
if (sslEnabled) {
|
||||||
try {
|
try {
|
||||||
SslContextBuilder sslContextBuilder = GrpcSslContexts.forClient();
|
SslContextBuilder sslContextBuilder = GrpcSslContexts.forClient();
|
||||||
@ -102,6 +115,18 @@ public class EdgeGrpcClient implements EdgeRpcClient {
|
|||||||
} else {
|
} else {
|
||||||
builder.usePlaintext();
|
builder.usePlaintext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (proxyEnabled && StringUtils.isNotEmpty(proxyHost) && proxyPort > 0) {
|
||||||
|
InetSocketAddress proxyAddress = new InetSocketAddress(proxyHost, proxyPort);
|
||||||
|
InetSocketAddress targetAddress = new InetSocketAddress(rpcHost, rpcPort);
|
||||||
|
builder.proxyDetector(socketAddress -> HttpConnectProxiedSocketAddress.newBuilder()
|
||||||
|
.setTargetAddress(targetAddress)
|
||||||
|
.setProxyAddress(proxyAddress)
|
||||||
|
.setUsername(proxyUsername)
|
||||||
|
.setPassword(proxyPassword)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
channel = builder.build();
|
channel = builder.build();
|
||||||
EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel);
|
EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel);
|
||||||
log.info("[{}] Sending a connect request to the TB!", edgeKey);
|
log.info("[{}] Sending a connect request to the TB!", edgeKey);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user