Skip to content

Commit

Permalink
Changed request format
Browse files Browse the repository at this point in the history
  • Loading branch information
khayamgondal committed Dec 28, 2017
1 parent f10a1a7 commit 33a12c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion add-whitelist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ curl http://$CONTROLLER_IP:$CONTROLLER_REST_PORT/wm/sos/agent/add/json -X POST -
curl http://$CONTROLLER_IP:$CONTROLLER_REST_PORT/wm/sos/whitelist/add/json -X POST -d '{"server-ip-address":"10.0.0.211", "server-tcp-port":"5201", "client-ip-address":"10.0.0.111"}' | python -m json.tool
#curl http://$CONTROLLER_IP:$CONTROLLER_REST_PORT/wm/sos/whitelist/add/json -X POST -d '{"server-ip-address":"10.0.0.111", "server-tcp-port":"5201", "client-ip-address":"10.0.0.211"}' | python -m json.tool

curl http://$CONTROLLER_IP:$CONTROLLER_REST_PORT/wm/sos/config/json -X POST -d '{"parallel-connections":"4"}' | python -m json.tool
curl http://$CONTROLLER_IP:$CONTROLLER_REST_PORT/wm/sos/config/json -X POST -d '{"parallel-connections":"8"}' | python -m json.tool
curl http://$CONTROLLER_IP:$CONTROLLER_REST_PORT/wm/sos/config/json -X POST -d '{"queue-capacity":"4000"}' | python -m json.tool
curl http://$CONTROLLER_IP:$CONTROLLER_REST_PORT/wm/sos/config/json -X POST -d '{"buffer-size":"60000"}' | python -m json.tool
curl http://$CONTROLLER_IP:$CONTROLLER_REST_PORT/wm/sos/config/json -X POST -d '{"idle-timeout":"2000"}' | python -m json.tool
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/net/floodlightcontroller/sos/SOS.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public boolean isCallbackOrderingPostreq(OFType type, String name) {
*/
private boolean sendInfoToAgent(SOSConnection conn, boolean isClientSideAgent) {
HttpClient httpClient = new DefaultHttpClient();
JSONObject wrapper = new JSONObject();
JSONObject requestObject = new JSONObject();
try {
requestObject.put("is-client-agent", isClientSideAgent)
Expand All @@ -295,8 +296,9 @@ private boolean sendInfoToAgent(SOSConnection conn, boolean isClientSideAgent) {
.put("queue-capacity", conn.getQueueCapacity())
.put("server-ip", conn.getServer().getIPAddr().toString())
.put("server-port", conn.getServer().getTcpPort().toString()) ;
wrapper.put("request", requestObject);

StringBuilder uriBuilder = new StringBuilder(3);
StringBuilder uriBuilder = new StringBuilder(3);
uriBuilder.append(SOSAgentUtils.HTTP_PRESTRING);
if (isClientSideAgent) {
uriBuilder.append(SOSAgentUtils.addressBuilder(conn.getClientSideAgent().getRestIpAddr().toString(),
Expand All @@ -312,9 +314,9 @@ private boolean sendInfoToAgent(SOSConnection conn, boolean isClientSideAgent) {

HttpPost httpRequest = new HttpPost(uriBuilder.toString());
org.apache.http.entity.StringEntity stringEntry = null;
stringEntry = new org.apache.http.entity.StringEntity(requestObject.toString(), "UTF-8");
stringEntry = new org.apache.http.entity.StringEntity(wrapper.toString(), "UTF-8");
httpRequest.setEntity(stringEntry);
log.debug("JSON Object to sent {}", requestObject.toString());
log.debug("JSON Object to sent {}", wrapper.toString());
HttpResponse response = httpClient.execute(httpRequest);
log.info("Sending HTTP request to client-agent {} and server-agent {}",
conn.getClientSideAgent().getIPAddr().toString(),
Expand Down

0 comments on commit 33a12c9

Please sign in to comment.