From 5ba249ae467ba8c6da81319d37b4bb51cd07aa12 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 23 Jan 2011 23:18:39 -0800 Subject: [PATCH] tuning logs --- .../RunScriptOnNodeAsInitScriptUsingSsh.java | 6 ++-- .../compute/internal/BaseComputeService.java | 6 ++-- .../AdaptingComputeServiceStrategies.java | 36 ++++--------------- ...agIntoNameRunNodesAndAddToSetStrategy.java | 4 ++- .../java/org/jclouds/ssh/ExecResponse.java | 2 +- 5 files changed, 17 insertions(+), 37 deletions(-) diff --git a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java index 0d84880954..0ff672cdee 100644 --- a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java +++ b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java @@ -115,8 +115,10 @@ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode { ExecResponse returnVal; String command = (runAsRoot) ? execScriptAsRoot(action) : execScriptAsDefaultUser(action); returnVal = runCommand(command); - logger.debug("<< %s(%d)", action, returnVal.getExitCode()); - logger.trace("<< %s[%s]", action, returnVal); + if (logger.isTraceEnabled()) + logger.trace("<< %s[%s]", action, returnVal); + else + logger.debug("<< %s(%d)", action, returnVal.getExitCode()); return returnVal; } diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java index 6b9d72ed69..5c9456a838 100755 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java @@ -425,10 +425,10 @@ public class BaseComputeService implements ComputeService { @Override public void suspendNode(String id) { checkNotNull(id, "id"); - logger.debug(">> suspendping node(%s)", id); + logger.debug(">> suspending node(%s)", id); NodeMetadata node = suspendNodeStrategy.suspendNode(id); boolean successful = nodeSuspended.apply(node); - logger.debug("<< suspendped node(%s) success(%s)", id, successful); + logger.debug("<< suspended node(%s) success(%s)", id, successful); } /** @@ -528,7 +528,7 @@ public class BaseComputeService implements ComputeService { Iterable nodes, Statement script, RunScriptOptions options, Map badNodes) { return filter(transformParallel(nodes, new TransformNodesIntoInitializedScriptRunners(script, options, badNodes), - executor, null, logger, "transformNodesIntoInitializedScriptRunners(" + nodes + ")"), notNull()); + executor, null, logger, "initialize script runners"), notNull()); } private Set detailsOnAllNodes() { diff --git a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java index 28cd081ce5..fcb601adce 100644 --- a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java @@ -85,63 +85,43 @@ public class AdaptingComputeServiceStrategies implements AddNodeWith @Override public NodeMetadata getNode(String id) { - N node = client.getNode(id); + N node = client.getNode(checkNotNull(id, "id")); return node == null ? null : nodeMetadataAdapter.apply(node); } @Override public NodeMetadata rebootNode(String id) { - - NodeMetadata node = getNode(id); + NodeMetadata node = getNode(checkNotNull(id, "id")); if (node == null || node.getState() == NodeState.TERMINATED) return node; - - logger.debug(">> rebooting node(%s)", id); client.rebootNode(id); - logger.debug("<< rebooted node(%s)", id); - return node; } @Override public NodeMetadata resumeNode(String id) { - - NodeMetadata node = getNode(id); + NodeMetadata node = getNode(checkNotNull(id, "id")); if (node == null || node.getState() == NodeState.TERMINATED || node.getState() == NodeState.RUNNING) return node; - - logger.debug(">> resuming node(%s)", id); client.resumeNode(id); - logger.debug("<< resumed node(%s)", id); - return node; } @Override public NodeMetadata suspendNode(String id) { - - NodeMetadata node = getNode(id); + NodeMetadata node = getNode(checkNotNull(id, "id")); if (node == null || node.getState() == NodeState.TERMINATED || node.getState() == NodeState.SUSPENDED) return node; - - logger.debug(">> suspending node(%s)", id); client.suspendNode(id); - logger.debug("<< suspended node(%s)", id); - return node; } @Override public NodeMetadata destroyNode(String id) { - - NodeMetadata node = getNode(id); + NodeMetadata node = getNode(checkNotNull(id, "id")); if (node == null) return node; - - logger.debug(">> destroying node(%s)", id); client.destroyNode(id); - logger.debug("<< destroyed node(%s)", id); - return node; } @@ -152,14 +132,10 @@ public class AdaptingComputeServiceStrategies implements AddNodeWith public NodeMetadata addNodeWithTag(String tag, String name, Template template) { checkState(tag != null, "tag (that which groups identical nodes together) must be specified"); checkState(name != null && name.indexOf(tag) != -1, "name should have %s encoded into it", tag); - - logger.debug(">> instantiating node location(%s) name(%s) image(%s) hardware(%s)", - template.getLocation().getId(), name, template.getImage().getProviderId(), template.getHardware() - .getProviderId()); + checkState(template != null, "template must be specified"); N from = client.runNodeWithTagAndNameAndStoreCredentials(tag, name, template, credentialStore); NodeMetadata node = nodeMetadataAdapter.apply(from); - logger.debug("<< instantiated node(%s)", node.getId()); return node; } diff --git a/compute/src/main/java/org/jclouds/compute/strategy/impl/EncodeTagIntoNameRunNodesAndAddToSetStrategy.java b/compute/src/main/java/org/jclouds/compute/strategy/impl/EncodeTagIntoNameRunNodesAndAddToSetStrategy.java index 835af67704..aaadaab3a3 100755 --- a/compute/src/main/java/org/jclouds/compute/strategy/impl/EncodeTagIntoNameRunNodesAndAddToSetStrategy.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/impl/EncodeTagIntoNameRunNodesAndAddToSetStrategy.java @@ -75,7 +75,9 @@ public class EncodeTagIntoNameRunNodesAndAddToSetStrategy implements RunNodesAnd @Override public NodeMetadata call() throws Exception { NodeMetadata node = null; - logger.debug(">> starting node(%s) tag(%s)", name, tag); + logger.debug(">> adding node location(%s) name(%s) image(%s) hardware(%s)", + template.getLocation().getId(), name, template.getImage().getProviderId(), template.getHardware() + .getProviderId()); node = addNodeWithTagStrategy.addNodeWithTag(tag, name, template); logger.debug("<< %s node(%s)", node.getState(), node.getId()); return node; diff --git a/compute/src/main/java/org/jclouds/ssh/ExecResponse.java b/compute/src/main/java/org/jclouds/ssh/ExecResponse.java index 7bf6bf18d7..c5f83c8ae6 100644 --- a/compute/src/main/java/org/jclouds/ssh/ExecResponse.java +++ b/compute/src/main/java/org/jclouds/ssh/ExecResponse.java @@ -46,7 +46,7 @@ public class ExecResponse implements CustomizationResponse { @Override public String toString() { - return "ExecResponse [output=" + output + ", error=" + error + ", exitCode=" + exitCode + "]"; + return "[output=" + output + ", error=" + error + ", exitCode=" + exitCode + "]"; } @Override