Return-Path: X-Original-To: apmail-brooklyn-commits-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A4F241774A for ; Fri, 29 May 2015 17:22:11 +0000 (UTC) Received: (qmail 42495 invoked by uid 500); 29 May 2015 17:22:11 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 42474 invoked by uid 500); 29 May 2015 17:22:11 -0000 Mailing-List: contact commits-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list commits@brooklyn.incubator.apache.org Received: (qmail 42465 invoked by uid 99); 29 May 2015 17:22:11 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 May 2015 17:22:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 206E2182399 for ; Fri, 29 May 2015 17:22:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.771 X-Spam-Level: * X-Spam-Status: No, score=1.771 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id eRpH7nP5F6CK for ; Fri, 29 May 2015 17:22:03 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id B18C747BEB for ; Fri, 29 May 2015 17:21:55 +0000 (UTC) Received: (qmail 41493 invoked by uid 99); 29 May 2015 17:21:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 May 2015 17:21:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EA3E4E1110; Fri, 29 May 2015 17:21:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aledsage@apache.org To: commits@brooklyn.incubator.apache.org Date: Fri, 29 May 2015 17:22:02 -0000 Message-Id: <16a25e2edbcd4b13a03b272e0cde9a3f@git.apache.org> In-Reply-To: <2e32313e76084e1691aed3843ca1784a@git.apache.org> References: <2e32313e76084e1691aed3843ca1784a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/27] incubator-brooklyn git commit: Avoids unnecessary Arrays.copyOf in WinRmMachineLocation.copyTo Avoids unnecessary Arrays.copyOf in WinRmMachineLocation.copyTo Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/f5664860 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/f5664860 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/f5664860 Branch: refs/heads/master Commit: f5664860d7249a0caea95dad071c6935946a54c2 Parents: 2b07bed Author: Martin Harris Authored: Mon Apr 13 13:14:47 2015 +0100 Committer: Richard Downer Committed: Thu May 28 17:27:34 2015 +0100 ---------------------------------------------------------------------- .../location/basic/WinRmMachineLocation.java | 18 +++++++++++------- .../basic/AbstractSoftwareProcessDriver.java | 6 +----- 2 files changed, 12 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f5664860/core/src/main/java/brooklyn/location/basic/WinRmMachineLocation.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/location/basic/WinRmMachineLocation.java b/core/src/main/java/brooklyn/location/basic/WinRmMachineLocation.java index 186fc4f..6f8ef04 100644 --- a/core/src/main/java/brooklyn/location/basic/WinRmMachineLocation.java +++ b/core/src/main/java/brooklyn/location/basic/WinRmMachineLocation.java @@ -122,14 +122,18 @@ public class WinRmMachineLocation extends AbstractLocation implements MachineLoc public int copyTo(InputStream source, File destination) { executePsScript(ImmutableList.of("rm -ErrorAction SilentlyContinue " + destination.getPath())); try { - byte[] inputData = new byte[getConfig(COPY_FILE_CHUNK_SIZE_BYTES)]; - int bytesRead = source.read(inputData); - while (bytesRead > 0) { - byte[] chunk = Arrays.copyOf(inputData, bytesRead); - String encoded = new String(Base64.encodeBase64(chunk)); + int chunkSize = getConfig(COPY_FILE_CHUNK_SIZE_BYTES); + byte[] inputData = new byte[chunkSize]; + int bytesRead; + while ((bytesRead = source.read(inputData)) > 0) { + byte[] chunk; + if (bytesRead == chunkSize) { + chunk = inputData; + } else { + chunk = Arrays.copyOf(inputData, bytesRead); + } executePsScript(ImmutableList.of("Add-Content -Encoding Byte -path " + destination.getPath() + - " -value ([System.Convert]::FromBase64String(\"" + encoded + "\"))")); - bytesRead = source.read(inputData); + " -value ([System.Convert]::FromBase64String(\"" + new String(Base64.encodeBase64(chunk)) + "\"))")); } return 0; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f5664860/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java index 9762c4f..061cd12 100644 --- a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java +++ b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java @@ -314,11 +314,7 @@ public abstract class AbstractSoftwareProcessDriver implements SoftwareProcessDr */ public void copyRuntimeResources() { try { - // Ensure environment variables are not looked up here, otherwise sub-classes might - // lookup port numbers and fail with ugly error if port is not set. It could also - // cause us to block for attribute ready earlier than we need. - DynamicTasks.queue(SshEffectorTasks.ssh("mkdir -p " + getRunDir()).summary("create run directory") - .requiringExitCodeZero()).get(); + createDirectory(getRunDir(), "create run directory"); Map runtimeFiles = entity.getConfig(SoftwareProcess.RUNTIME_FILES); if (runtimeFiles != null && runtimeFiles.size() > 0) {