Skip to content

Commit

Permalink
Sync with v2.60+
Browse files Browse the repository at this point in the history
- jeromq update
- gradle update to 4.2.1
- fixed responses handling (single instead of list handling)
- fixed request empty params
  • Loading branch information
EgorBlagov committed Sep 11, 2019
1 parent b80ac59 commit 2e81293
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test {
task uiTest(type: Test) {
description 'Runs UI testing(E2E)'
outputs.upToDateWhen { false }
testClassesDir = sourceSets.uiTest.output.classesDir
testClassesDirs = sourceSets.uiTest.output.classesDirs
classpath = sourceSets.uiTest.runtimeClasspath

testLogging {
Expand Down Expand Up @@ -73,7 +73,7 @@ dependencies {
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.6.0'
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version:'2.5.4'
compile group: 'org.json', name: 'json', version:'20150729'
compile group: 'org.zeromq', name: 'jeromq', version:'0.4.0'
compile group: 'org.zeromq', name: 'jeromq', version:'0.5.1'
compile group: 'commons-io', name: 'commons-io', version:'2.4'
compile group: 'commons-lang', name: 'commons-lang', version:'2.4'
compile group: 'com.google.code.gson', name: 'gson', version:'2.7'
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Feb 01 15:27:25 NOVT 2019
#Tue Sep 10 13:45:42 NOVT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-bin.zip
2 changes: 2 additions & 0 deletions src/main/java/com/exalttech/trex/core/ConnectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ public String sendRequest(String cmd, String parameters) {
param = "{" + apiHParam + " , " + parameters + "}";
}

} else {
param = "{}";
}
String request = "{ \"id\" : \"aggogxls\", \"jsonrpc\" : \"2.0\", \"method\" : \"" + cmd + "\", \"params\" :" + param + " }";
LOG.trace("Sending request \n" + Util.toPrettyFormat(request));
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/exalttech/trex/core/RPCCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ private static String sendRequest(final String command, final Map<String, Object
stringParameters = jsonParameters.substring(1, jsonParameters.length() - 1);
}
final String jsonRPCResult = ConnectionManager.getInstance().sendRequest(command, stringParameters);
final RPCResponse[] rpcResult = new ObjectMapper().readValue(jsonRPCResult, RPCResponse[].class);
final String specError = extractSpecError(rpcResult[0]);
final RPCResponse rpcResult = new ObjectMapper().readValue(jsonRPCResult, RPCResponse.class);
final String specError = extractSpecError(rpcResult);
final String invalidHandlerErrorPart = "API handler provided mismatch";

if (specError.contains(invalidHandlerErrorPart)) {
ConnectionManager.getInstance().notifyServerWasRestarted();
}

return rpcResult[0].getResult();
return rpcResult.getResult();
}

private static String extractSpecError(final RPCResponse resp) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/exalttech/trex/core/RPCMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public String getSupportedCmds() {
public Boolean pingRPCServer() {
LOG.trace("Pinging RPC Server");
try {
serverConnectionManager.sendRPCRequest(Constants.PING_METHOD, null);
serverConnectionManager.sendRPCRequest(Constants.PING_METHOD, new PingParams());
LOG.trace("Ping OK");
return true;
} catch (JsonProcessingException | UnsupportedEncodingException | InvalidRPCResponseException | IncorrectRPCMethodException | NullPointerException | SizeLimitExceededException ex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.exalttech.trex.remote.models.params;

public class PingParams extends Params {
}
10 changes: 9 additions & 1 deletion src/main/java/com/exalttech/trex/ui/PortsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.exalttech.trex.ui.models.PortStatus;
import com.exalttech.trex.util.Util;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import org.apache.log4j.Logger;

import java.util.*;
Expand Down Expand Up @@ -159,7 +160,14 @@ public void updatedPorts(List<Integer> portIndexes) {
if (response == null) {
return;
}
List<PortStatus> portStatusList = mapper.readValue(response, mapper.getTypeFactory().constructCollectionType(List.class, PortStatus.class));
List<PortStatus> portStatusList = new ArrayList<>();

try {
portStatusList = mapper.readValue(response, mapper.getTypeFactory().constructCollectionType(List.class, PortStatus.class));
} catch (MismatchedInputException ex) {
portStatusList.add(mapper.readValue(response, mapper.getTypeFactory().constructType(PortStatus.class)));
}

for (Port port : list) {
PortStatus.PortStatusResult portStatus = portStatusList.get(list.indexOf(port)).getResult();
port.setOwner(portStatus.getOwner());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ private void loadSystemInfo() {

String versionResponse = ConnectionManager.getInstance().sendRequest("get_version", "");
Gson gson = new Gson();
JsonObject version = gson.fromJson(versionResponse, JsonArray.class).get(0).getAsJsonObject();
JsonObject version = gson.fromJson(versionResponse, JsonObject.class);
systemInfoReq.getResult().setApiVersion(version.getAsJsonObject("result").getAsJsonPrimitive("version").getAsString());
LogsController.getInstance().appendText(LogType.INFO, "Loading port information complete");
}
Expand Down

0 comments on commit 2e81293

Please sign in to comment.