Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to logging #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,51 +130,47 @@ public boolean canHandleNewSession() {
return !sessionInProgress();
}

public boolean unreliable() {
public boolean unreliable() {
final Response response;

try {
LOGGER.debug("Polling Remote Control at " + host + ":" + port);
response = httpClient.get(remoteControlPingURL());
} catch (Exception e) {
LOGGER.warn("Remote Control at " + host + ":" + port + " is unresponsive");

if (this.sessionInProgress() && (failedHeartbeatCount < MAX_FAILED_HEARTBEATS)) {
LOGGER.warn(String.format("... attempt %d of %d -- trying again.", failedHeartbeatCount + 1, MAX_FAILED_HEARTBEATS));

failedHeartbeatCount++;
return unreliable();
}
else {
failedHeartbeatCount = 0;
return true;
}
} catch (final IOException ioe) {
LOGGER.warn("Remote Control at " + host + ":" + port + " is unresponsive", ioe);
return failedHeartBeat();
} catch (final RuntimeException re) {
LOGGER.warn("Remote Control at " + host + ":" + port + " is unresponsive", re);
return failedHeartBeat();
}

if (response.statusCode() != 200) {
LOGGER.warn("Remote Control at " + host + ":" + port + " did not respond correctly");

if (this.sessionInProgress() && (failedHeartbeatCount < MAX_FAILED_HEARTBEATS)) {
LOGGER.warn(String.format("... attempt %d of %d -- trying again.", failedHeartbeatCount + 1, MAX_FAILED_HEARTBEATS));

failedHeartbeatCount++;
return unreliable();
}
else {
failedHeartbeatCount = 0;
return true;
}
return failedHeartBeat();
}

failedHeartbeatCount = 0;
return false;
}

public String sessionId() {
return sessionId;
}
public boolean failedHeartBeat() {
if (sessionInProgress() && (failedHeartbeatCount < MAX_FAILED_HEARTBEATS)) {
LOGGER.warn(String.format("... attempt %d of %d -- trying again.", failedHeartbeatCount + 1, MAX_FAILED_HEARTBEATS));

failedHeartbeatCount++;
return unreliable();
}
else {
failedHeartbeatCount = 0;
return true;
}
}

public String sessionId() {
return sessionId;
}

public void setSessionId(String sessionId){
this.sessionId = sessionId;
}
public void setSessionId(String sessionId){
this.sessionId = sessionId;
}
}