Skip to content

Commit

Permalink
Merge pull request #112 from cisco-system-traffic-generator/acquirePort2
Browse files Browse the repository at this point in the history
acquire port only when it is not already acquired
  • Loading branch information
Emil-Gustafsson authored Dec 10, 2019
2 parents 4f1c355 + bb95bbc commit 0e0f79e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/com/cisco/trex/stateless/TRexClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,17 @@ protected void serverAPISync() throws TRexConnectionException {
}

public PortStatus acquirePort(int portIndex, Boolean force) {
Map<String, Object> payload = createPayload(portIndex);
payload.put("session_id", SESSON_ID);
payload.put("user", userName);
payload.put("force", force);
String json = callMethod("acquire", payload);
String handler = getResultFromResponse(json).getAsString();
portHandlers.put(portIndex, handler);
if (!portHandlers.containsKey(portIndex)) {
Map<String, Object> payload = createPayload(portIndex);
payload.put("session_id", SESSON_ID);
payload.put("user", userName);
payload.put("force", force);
String json = callMethod("acquire", payload);
String handler = getResultFromResponse(json).getAsString();
portHandlers.put(portIndex, handler);
} else {
LOGGER.debug("Port already acquired, continueing");
}
return getPortStatus(portIndex).get();
}

Expand Down

0 comments on commit 0e0f79e

Please sign in to comment.