Browse Source
Merge pull request #7595 from volodymyr-babak/rest-client-updates
[3.4.2] RestClient updates. Remove default connection from RPC from device to push to cloud
pull/7634/head
Andrew Shvayka
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
26 additions and
7 deletions
-
application/src/main/data/json/tenant/edge_management/rule_chains/edge_root_rule_chain.json
-
application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcSession.java
-
common/data/src/main/java/org/thingsboard/server/common/data/EdgeUtils.java
-
rest-client/src/main/java/org/thingsboard/rest/client/RestClient.java
|
|
|
@ -174,11 +174,6 @@ |
|
|
|
"fromIndex": 3, |
|
|
|
"toIndex": 7, |
|
|
|
"type": "Timeseries Updated" |
|
|
|
}, |
|
|
|
{ |
|
|
|
"fromIndex": 4, |
|
|
|
"toIndex": 7, |
|
|
|
"type": "Success" |
|
|
|
} |
|
|
|
], |
|
|
|
"ruleChainConnections": null |
|
|
|
|
|
|
|
@ -244,7 +244,7 @@ public final class EdgeGrpcSession implements Closeable { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onFailure(Throwable t) { |
|
|
|
String errorMsg = t.getMessage() != null ? t.getMessage() : ""; |
|
|
|
String errorMsg = EdgeUtils.createErrorMsgFromRootCauseAndStackTrace(t); |
|
|
|
UplinkResponseMsg uplinkResponseMsg = UplinkResponseMsg.newBuilder() |
|
|
|
.setUplinkMsgId(uplinkMsg.getUplinkMsgId()) |
|
|
|
.setSuccess(false).setErrorMsg(errorMsg).build(); |
|
|
|
|
|
|
|
@ -16,6 +16,7 @@ |
|
|
|
package org.thingsboard.server.common.data; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
import com.google.common.base.Throwables; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.thingsboard.server.common.data.edge.EdgeEvent; |
|
|
|
import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
|
|
|
@ -29,6 +30,8 @@ import java.util.concurrent.ThreadLocalRandom; |
|
|
|
@Slf4j |
|
|
|
public final class EdgeUtils { |
|
|
|
|
|
|
|
private static final int STACK_TRACE_LIMIT = 10; |
|
|
|
|
|
|
|
private EdgeUtils() { |
|
|
|
} |
|
|
|
|
|
|
|
@ -93,4 +96,20 @@ public final class EdgeUtils { |
|
|
|
edgeEvent.setBody(body); |
|
|
|
return edgeEvent; |
|
|
|
} |
|
|
|
|
|
|
|
public static String createErrorMsgFromRootCauseAndStackTrace(Throwable t) { |
|
|
|
Throwable rootCause = Throwables.getRootCause(t); |
|
|
|
StringBuilder errorMsg = new StringBuilder(rootCause.getMessage() != null ? rootCause.getMessage() : ""); |
|
|
|
if (rootCause.getStackTrace().length > 0) { |
|
|
|
int idx = 0; |
|
|
|
for (StackTraceElement stackTraceElement : rootCause.getStackTrace()) { |
|
|
|
errorMsg.append("\n").append(stackTraceElement.toString()); |
|
|
|
idx++; |
|
|
|
if (idx > STACK_TRACE_LIMIT) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return errorMsg.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -2032,10 +2032,15 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { |
|
|
|
} |
|
|
|
|
|
|
|
public PageData<RuleChain> getRuleChains(PageLink pageLink) { |
|
|
|
return getRuleChains(RuleChainType.CORE, pageLink); |
|
|
|
} |
|
|
|
|
|
|
|
public PageData<RuleChain> getRuleChains(RuleChainType ruleChainType, PageLink pageLink) { |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
params.put("type", ruleChainType.name()); |
|
|
|
addPageLinkToParam(params, pageLink); |
|
|
|
return restTemplate.exchange( |
|
|
|
baseURL + "/api/ruleChains?" + getUrlParams(pageLink), |
|
|
|
baseURL + "/api/ruleChains?type={type}&" + getUrlParams(pageLink), |
|
|
|
HttpMethod.GET, |
|
|
|
HttpEntity.EMPTY, |
|
|
|
new ParameterizedTypeReference<PageData<RuleChain>>() { |
|
|
|
|