Permalink
Browse files

added logging(debug) to correctness check code for balancer

  • Loading branch information...
1 parent a374c3e commit 3b5002ab95defd60613a728f1e2b1885f51b907a @janmejay janmejay committed Apr 16, 2012
Showing with 32 additions and 4 deletions.
  1. +32 −4 balancer/src/tlb/service/TlbServer.java
@@ -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;
@@ -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
@@ -92,7 +95,14 @@ public int totalPartitions() {
}
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.");
@@ -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);
@@ -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) {
@@ -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);
}

0 comments on commit 3b5002a

Please sign in to comment.