Skip to content

Commit

Permalink
added logging(debug) to correctness check code for balancer
Browse files Browse the repository at this point in the history
  • Loading branch information
janmejay committed Apr 16, 2012
1 parent a374c3e commit 3b5002a
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions balancer/src/tlb/service/TlbServer.java
Expand Up @@ -3,6 +3,7 @@
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import tlb.TlbConstants;
import tlb.TlbSuiteFile;
import tlb.domain.SuiteResultEntry;
Expand All @@ -25,6 +26,8 @@
* @understands exchanging balancing/ordering related data with the TLB server
*/
public class TlbServer extends SmoothingServer {
private static final Logger logger = Logger.getLogger(TlbServer.class.getName());

private final HttpAction httpAction;

//reflectively invoked by factory
Expand Down Expand Up @@ -92,7 +95,14 @@ private static class RemoteValidationResponse {
}

public ValidationResult validateUniversalSet(List<TlbSuiteFile> universalSet, String moduleName) {
RemoteValidationResponse resp = correctnessPost(universalSet, getUrl(namespace(), CORRECTNESS_CHECK, jobVersion(), TlbConstants.Server.EntryRepoFactory.UNIVERSAL_SET, moduleName));
String namespace = namespace();
String jobVersion = jobVersion();

if (logger.isDebugEnabled()) {
logger.debug(String.format("Posting to validate universal set for %s[v:%s](m:%s)", namespace, jobVersion, moduleName));
}

RemoteValidationResponse resp = correctnessPost(universalSet, getUrl(namespace, CORRECTNESS_CHECK, jobVersion, TlbConstants.Server.EntryRepoFactory.UNIVERSAL_SET, moduleName));

if (resp.status == HttpStatus.SC_CREATED) {
return new ValidationResult(ValidationResult.Status.FIRST, "First validation snapshot.");
Expand All @@ -106,7 +116,16 @@ public ValidationResult validateUniversalSet(List<TlbSuiteFile> universalSet, St
}

public ValidationResult validateSubSet(List<TlbSuiteFile> subSet, String moduleName) {
RemoteValidationResponse resp = correctnessPost(subSet, getUrl(namespace(), CORRECTNESS_CHECK, jobVersion(), String.valueOf(totalPartitions()), String.valueOf(partitionNumber()), TlbConstants.Server.EntryRepoFactory.SUB_SET, moduleName));
String namespace = namespace();
String jobVersion = jobVersion();
String totalPartition = String.valueOf(totalPartitions());
String partitionNumber = String.valueOf(partitionNumber());

if (logger.isDebugEnabled()) {
logger.debug(String.format("Posting to validate subset %s/%s for %s[v:%s](m:%s)", partitionNumber, totalPartition, namespace, jobVersion, moduleName));
}

RemoteValidationResponse resp = correctnessPost(subSet, getUrl(namespace, CORRECTNESS_CHECK, jobVersion, totalPartition, partitionNumber, TlbConstants.Server.EntryRepoFactory.SUB_SET, moduleName));

if (resp.status == HttpStatus.SC_NOT_ACCEPTABLE) {
return new ValidationResult(ValidationResult.Status.FAILED, resp.body);
Expand All @@ -120,7 +139,12 @@ public ValidationResult validateSubSet(List<TlbSuiteFile> subSet, String moduleN
}

public ValidationResult verifyAllPartitionsExecutedFor(String moduleName) {
HttpResponse httpResponse = httpAction.doGet(getUrl(namespace(), CORRECTNESS_CHECK, jobVersion(), TlbConstants.Server.VERIFY_PARTITION_COMPLETENESS, moduleName));
String namespace = namespace();
String jobVersion = jobVersion();
if (logger.isDebugEnabled()) {
logger.debug(String.format("Verifying partitions executed for %s[v:%s](m:%s)", namespace, jobVersion, moduleName));
}
HttpResponse httpResponse = httpAction.doGet(getUrl(namespace, CORRECTNESS_CHECK, jobVersion, TlbConstants.Server.VERIFY_PARTITION_COMPLETENESS, moduleName));
RemoteValidationResponse resp = validationResponse(httpResponse);

if (resp.status == HttpStatus.SC_EXPECTATION_FAILED) {
Expand All @@ -137,7 +161,11 @@ private RemoteValidationResponse correctnessPost(List<TlbSuiteFile> set, final S
for (TlbSuiteFile suiteFile : set) {
builder.append(suiteFile.dump());
}
HttpResponse httpResponse = httpAction.doPost(url, builder.toString());
String body = builder.toString();
if (logger.isDebugEnabled()) {
logger.debug("Posting for correctness check: << " + body + " >>");
}
HttpResponse httpResponse = httpAction.doPost(url, body);
return validationResponse(httpResponse);
}

Expand Down

0 comments on commit 3b5002a

Please sign in to comment.