Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
log error messages in log.error(object,throwable) format and change t…
Browse files Browse the repository at this point in the history
…he position of some log messages
  • Loading branch information
asankasan committed Aug 11, 2015
1 parent 8a42670 commit 1250412
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ public boolean configure(Topology topology) throws LoadBalancerExtensionExceptio
}
}
activeClusterIdList.clear();

log.info("Load balancer was configured as given topology");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ private void buildComputeEngineObject() throws IOException, GeneralSecurityExcep
}
} catch (GeneralSecurityException e) {
//Security exception occurred. Cant proceed further
log.fatal("Could not authenticate and build compute object");
log.error("Could not authenticate and build compute object");
throw new GeneralSecurityException(e);
} catch (IOException e) {
//IO exception occurred. Cant proceed further
log.fatal("Could not authenticate and build compute object");
log.error("Could not authenticate and build compute object");
throw new IOException(e);
}
}
Expand All @@ -132,7 +132,7 @@ public static InstanceList getInstanceList(String zoneName, String filter) {
return instanceList;
}
} catch (IOException e) {
log.warn("Could not get instance list from GCE ", e);
log.error("Could not get instance list from GCE ", e);
return null;
}
}
Expand Down Expand Up @@ -215,7 +215,7 @@ private static HttpHealthCheckList getHealthCheckList() {
return healthCheckList;
}
} catch (IOException e) {
log.warn("Could not get health check list from GCE", e);
log.error("Could not get health check list from GCE", e);
return null;
}
}
Expand Down Expand Up @@ -248,11 +248,10 @@ public void createTargetPool(String targetPoolName, String healthCheckName) {
Operation operation =
compute.targetPools().insert(PROJECT_ID, REGION_NAME, targetPool).execute();
waitForRegionOperationCompletion(operation.getName());

log.info("Target pool " + targetPoolName + " was created");
} catch (Exception e) {
log.warn("Could not create target pool: " + targetPoolName + " " + e);
log.error("Could not create target pool: " + targetPoolName, e);
}
log.info("Target pool " + targetPoolName + " was created");
}

/**
Expand All @@ -265,11 +264,10 @@ public void deleteTargetPool(String targetPoolName) {
try {
Operation operation = compute.targetPools().delete(PROJECT_ID, REGION_NAME, targetPoolName).execute();
waitForRegionOperationCompletion(operation.getName());

log.info("Target pool: " + targetPoolName + " was deleted");
} catch (Exception e) {
log.warn("Could not delete target pool " + targetPoolName + " " + e);
log.error("Could not delete target pool " + targetPoolName, e);
}
log.info("Target pool: " + targetPoolName + " was deleted");
}

/**
Expand All @@ -295,10 +293,10 @@ public void createForwardingRule(String forwardingRuleName, String targetPoolNam
try {
Operation operation = compute.forwardingRules().insert(PROJECT_ID, REGION_NAME, forwardingRule).execute();
waitForRegionOperationCompletion(operation.getName());
log.info("Forwarding rule: " + forwardingRuleName + " was created");
} catch (Exception e) {
log.warn("Could not create a forwarding rule " + forwardingRuleName + " " + e);
log.error("Could not create a forwarding rule " + forwardingRuleName, e);
}
log.info("Forwarding rule: " + forwardingRuleName + " was created");
}

/**
Expand All @@ -312,10 +310,10 @@ public void deleteForwardingRule(String forwardingRuleName) {
Operation operation = compute.forwardingRules().
delete(PROJECT_ID, REGION_NAME, forwardingRuleName).execute();
waitForRegionOperationCompletion(operation.getName());
log.info("Forwarding rule " + forwardingRuleName + " was deleted");
} catch (Exception e) {
log.warn("Could not delete forwarding rule " + forwardingRuleName + " " + e);
log.error("Could not delete forwarding rule " + forwardingRuleName, e);
}
log.info("Forwarding rule " + forwardingRuleName + " was deleted");
}

/**
Expand All @@ -339,7 +337,7 @@ public boolean isTargetPoolExists(String targetPoolName) {
}
}
} catch (IOException e) {
log.warn("Could not check whether the target pool " + targetPoolName + " exists or not " + e);
log.error("Could not check whether the target pool " + targetPoolName + " exists or not ", e);
}
if (log.isDebugEnabled()) {
log.debug("Target pool " + targetPoolName + " does not exist");
Expand All @@ -365,7 +363,7 @@ public TargetPool getTargetPool(String targetPoolName) {
}
return null;
} catch (IOException e) {
log.warn("Could not get target pool " + targetPoolName + " " + e);
log.error("Could not get target pool " + targetPoolName, e);
}
return null;
}
Expand Down Expand Up @@ -407,11 +405,10 @@ public void removeInstancesFromTargetPool(List<String> instancesIdsList, String
Operation operation = compute.targetPools().removeInstance(PROJECT_ID, REGION_NAME,
targetPoolName, targetPoolsRemoveInstanceRequest).execute();
waitForRegionOperationCompletion(operation.getName());

log.info("Instances are removed from target pool: " + targetPoolName);
} catch (Exception e) {
log.warn("Could not remove instances from target pool " + targetPoolName + " " + e);
log.error("Could not remove instances from target pool " + targetPoolName, e);
}
log.info("Instances are removed from target pool: " + targetPoolName);
}

/**
Expand Down Expand Up @@ -457,11 +454,10 @@ public void addInstancesToTargetPool(List<String> instancesIdsList, String targe
Operation operation = compute.targetPools().addInstance(PROJECT_ID, REGION_NAME,
targetPoolName, targetPoolsAddInstanceRequest).execute();
waitForRegionOperationCompletion(operation.getName());

log.info("Added instances to target pool: " + targetPoolName);
} catch (Exception e) {
log.warn("Could not add instance to target pool" + targetPoolName + " " + e);
log.error("Could not add instance to target pool" + targetPoolName, e);
}
log.info("Added instances to target pool: " + targetPoolName);
}

/**
Expand All @@ -484,23 +480,21 @@ public void createHealthCheck(String healthCheckName) {
try {
Operation operation = compute.httpHealthChecks().insert(PROJECT_ID, httpHealthCheck).execute();
waitForGlobalOperationCompletion(operation.getName());

log.info("Health check " + healthCheckName + " was created");
} catch (Exception e) {
log.error("Could not create health check " + healthCheckName + " " + e);
log.error("Could not create health check " + healthCheckName, e);
}
log.info("Health check " + healthCheckName + " was created");
}

public void deleteHealthCheck(String healthCheckName) {
log.info("Deleting Health Check: " + healthCheckName);
try {
Operation operation = compute.httpHealthChecks().delete(PROJECT_ID, healthCheckName).execute();
waitForGlobalOperationCompletion(operation.getName());

log.info("Health check: " + healthCheckName + " was deleted");
} catch (Exception e) {
log.warn("Could not get delete health check " + healthCheckName + " " + e);
log.error("Could not get delete health check " + healthCheckName, e);
}
log.info("Health check: " + healthCheckName + " was deleted");
}

/**
Expand Down Expand Up @@ -535,7 +529,7 @@ private void waitForGlobalOperationCompletion(String operationName) throws LoadB
timeout += 1000;
}
} catch (Exception e) {
log.error("Could not wait for global operation completion " + operationName);
log.error("Could not wait for global operation completion " + operationName , e);
throw new LoadBalancerExtensionException(e);
}
}
Expand Down Expand Up @@ -570,7 +564,7 @@ private void waitForRegionOperationCompletion(String operationName) throws LoadB
timeout += 1000;
}
} catch (Exception e) {
log.error("Could not wait for region operation completion " + operationName);
log.error("Could not wait for region operation completion " + operationName , e);
throw new LoadBalancerExtensionException(e);
}
}
Expand Down

0 comments on commit 1250412

Please sign in to comment.