Skip to content
Snippets Groups Projects
Commit df4e4768 authored by Jesper Fyhr Knudsen's avatar Jesper Fyhr Knudsen
Browse files

Update Heartbeat so all data is synced

parent 5d2eb1d9
Branches
No related tags found
No related merge requests found
......@@ -32,7 +32,12 @@ public class RequestParser {
String query = requestString.substring(startOfQueryString +1, requestString.indexOf("HTTP"));
try {
query = URLDecoder.decode(query.trim(), "UTF-8");
} catch (UnsupportedEncodingException e) { }
} catch (UnsupportedEncodingException e) {
} catch (IllegalArgumentException e) {
System.err.println("RequestParser.parseQueryString()");
System.err.println(query.trim());
System.err.println();
}
if("".equals(query)) return parameters;
......
......@@ -64,10 +64,13 @@ public class SimpleServer implements Runnable {
this.socket = socket;
}
@Override
public void run() {
String requestString = null;
try {
Request request = RequestParser.parse(readRequestFromStream());
requestString = readRequestFromStream();
Request request = RequestParser.parse(requestString);
Response res = route(request);
SendResponse(res);
......@@ -76,7 +79,15 @@ public class SimpleServer implements Runnable {
// if the socket is closed it means the server is turned off, so we can ignore the exception
if (!socket.isClosed()) se.printStackTrace();
} catch (Exception e) {
System.err.println("RequestHandler.Run()");
if(requestString != null)
System.err.println(requestString);
e.printStackTrace();
System.err.println();
}
}
......
package com.chaos.octopus.server.synchronization;
import com.chaos.octopus.server.AgentProxy;
import com.chaos.octopus.server.AllocationHandler;
import com.chaos.sdk.HeartbeatGateway;
import com.chaos.sdk.v6.dto.ClusterState;
......@@ -17,15 +16,7 @@ public class Heartbeat implements SynchronizationTask {
public void action() {
ClusterState state = new ClusterState();
state.queueSize = allocationHandler.getQueued();
for (AgentProxy ap : allocationHandler.getAgents()){
ClusterState.AgentState as = ap.getState();
as.hasAvailableSlots = !ap.isQueueFull();
as.hostname = ap.getHostname();
as.port = ap.port;
state.agents.add(as);
}
state.agents = allocationHandler.getAgentStates();
gateway.set(state);
}
......
......@@ -42,6 +42,8 @@ public class Synchronization extends TimerTask {
task.action();
} catch (Exception e) {
System.err.println("Synchronization (" + task.getClass().getName()+ ") - " + e.getMessage());
e.printStackTrace();
System.err.println();
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment