Repository: oozie Updated Branches: refs/heads/master 553d5d4db -> 7804e7447
OOZIE-3232 Reduce heap waste by reducing duplicate string count (Misha Dmitriev via andras.piros) Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/7804e744 Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/7804e744 Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/7804e744 Branch: refs/heads/master Commit: 7804e74474130c2905c3404740ab467055fe16cb Parents: 553d5d4 Author: Andras Piros <andras.pi...@cloudera.com> Authored: Tue May 8 17:15:17 2018 +0200 Committer: Andras Piros <andras.pi...@cloudera.com> Committed: Tue May 8 17:15:17 2018 +0200 ---------------------------------------------------------------------- .../main/java/org/apache/oozie/StringBlob.java | 10 +++--- .../org/apache/oozie/WorkflowActionBean.java | 21 ++++++------ .../java/org/apache/oozie/WorkflowJobBean.java | 35 ++++++-------------- .../oozie/command/wf/ActionEndXCommand.java | 3 +- .../oozie/service/CallableQueueService.java | 3 +- .../java/org/apache/oozie/util/StringUtils.java | 13 ++++++++ release-log.txt | 1 + 7 files changed, 45 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oozie/blob/7804e744/core/src/main/java/org/apache/oozie/StringBlob.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/StringBlob.java b/core/src/main/java/org/apache/oozie/StringBlob.java index cb5aff4..b453f09 100644 --- a/core/src/main/java/org/apache/oozie/StringBlob.java +++ b/core/src/main/java/org/apache/oozie/StringBlob.java @@ -21,10 +21,10 @@ package org.apache.oozie; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; -import java.io.UnsupportedEncodingException; import org.apache.oozie.compression.CodecFactory; import org.apache.oozie.compression.CompressionCodec; +import org.apache.oozie.util.StringUtils; /** * StringBlob to maintain compress and uncompressed data @@ -49,7 +49,7 @@ public class StringBlob { * @param inputString the string */ public StringBlob(String inputString) { - this.string = inputString; + this.string = StringUtils.intern(inputString); this.rawBlob = null; } @@ -59,7 +59,7 @@ public class StringBlob { * @param str the string */ public void setString(String str) { - this.string = str; + this.string = StringUtils.intern(str); this.rawBlob = null; } @@ -79,10 +79,10 @@ public class StringBlob { DataInputStream dais = new DataInputStream(new ByteArrayInputStream(rawBlob)); CompressionCodec codec = CodecFactory.getDeCompressionCodec(dais); if (codec != null) { - string = codec.decompressToString(dais); + string = StringUtils.intern(codec.decompressToString(dais)); } else { - string = new String(rawBlob, CodecFactory.UTF_8_ENCODING); + string = StringUtils.intern((new String(rawBlob, CodecFactory.UTF_8_ENCODING))); } dais.close(); http://git-wip-us.apache.org/repos/asf/oozie/blob/7804e744/core/src/main/java/org/apache/oozie/WorkflowActionBean.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/WorkflowActionBean.java b/core/src/main/java/org/apache/oozie/WorkflowActionBean.java index 32bebae..2d75e16 100644 --- a/core/src/main/java/org/apache/oozie/WorkflowActionBean.java +++ b/core/src/main/java/org/apache/oozie/WorkflowActionBean.java @@ -44,6 +44,7 @@ import org.apache.oozie.client.rest.JsonUtils; import org.apache.oozie.util.DateUtils; import org.apache.oozie.util.ParamChecker; import org.apache.oozie.util.PropertiesUtils; +import org.apache.oozie.util.StringUtils; import org.apache.oozie.util.WritableUtils; import org.apache.openjpa.persistence.jdbc.Index; import org.apache.openjpa.persistence.jdbc.Strategy; @@ -372,7 +373,7 @@ public class WorkflowActionBean implements Writable, WorkflowAction, JsonBean { setTrackerUri(WritableUtils.readStr(dataInput)); setConsoleUrl(WritableUtils.readStr(dataInput)); setErrorInfo(WritableUtils.readStr(dataInput), WritableUtils.readStr(dataInput)); - wfId = WritableUtils.readStr(dataInput); + setJobId(WritableUtils.readStr(dataInput)); executionPath = WritableUtils.readStr(dataInput); pending = dataInput.readInt(); d = dataInput.readLong(); @@ -677,7 +678,7 @@ public class WorkflowActionBean implements Writable, WorkflowAction, JsonBean { * @param id jobId; */ public void setJobId(String id) { - this.wfId = id; + this.wfId = StringUtils.intern(id); } public void setSlaXml(String slaXmlStr) { @@ -707,7 +708,7 @@ public class WorkflowActionBean implements Writable, WorkflowAction, JsonBean { * @param val the status */ public void setStatus(Status val) { - this.statusStr = val.toString(); + this.statusStr = StringUtils.intern(val.toString()); } @Override @@ -721,7 +722,7 @@ public class WorkflowActionBean implements Writable, WorkflowAction, JsonBean { * @param statusStr the status */ public void setStatusStr(String statusStr) { - this.statusStr = statusStr; + this.statusStr = StringUtils.intern(statusStr); } /** @@ -920,7 +921,7 @@ public class WorkflowActionBean implements Writable, WorkflowAction, JsonBean { } public void setId(String id) { - this.id = id; + this.id = StringUtils.intern(id); } public Timestamp getCreatedTimestamp() { @@ -941,7 +942,7 @@ public class WorkflowActionBean implements Writable, WorkflowAction, JsonBean { } public void setName(String name) { - this.name = name; + this.name = StringUtils.intern(name); } @Override @@ -959,7 +960,7 @@ public class WorkflowActionBean implements Writable, WorkflowAction, JsonBean { } public void setType(String type) { - this.type = type; + this.type = StringUtils.intern(type); } @Override @@ -1108,7 +1109,7 @@ public class WorkflowActionBean implements Writable, WorkflowAction, JsonBean { * @param externalId the id */ public void setExternalId(String externalId) { - this.externalId = externalId; + this.externalId = StringUtils.intern(externalId); } @Override @@ -1122,7 +1123,7 @@ public class WorkflowActionBean implements Writable, WorkflowAction, JsonBean { * @param externalStatus the external status */ public void setExternalStatus(String externalStatus) { - this.externalStatus = externalStatus; + this.externalStatus = StringUtils.intern(externalStatus); } @Override @@ -1136,7 +1137,7 @@ public class WorkflowActionBean implements Writable, WorkflowAction, JsonBean { * @param trackerUri the URI */ public void setTrackerUri(String trackerUri) { - this.trackerUri = trackerUri; + this.trackerUri = StringUtils.intern(trackerUri); } @Override http://git-wip-us.apache.org/repos/asf/oozie/blob/7804e744/core/src/main/java/org/apache/oozie/WorkflowJobBean.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/WorkflowJobBean.java b/core/src/main/java/org/apache/oozie/WorkflowJobBean.java index 22a01d3..1e55884 100644 --- a/core/src/main/java/org/apache/oozie/WorkflowJobBean.java +++ b/core/src/main/java/org/apache/oozie/WorkflowJobBean.java @@ -25,6 +25,7 @@ import org.apache.oozie.client.rest.JsonBean; import org.apache.oozie.client.rest.JsonTags; import org.apache.oozie.client.rest.JsonUtils; import org.apache.oozie.util.DateUtils; +import org.apache.oozie.util.StringUtils; import org.apache.oozie.util.WritableUtils; import org.apache.oozie.workflow.WorkflowInstance; import org.apache.oozie.workflow.lite.LiteWorkflowInstance; @@ -437,13 +438,9 @@ public class WorkflowJobBean implements Writable, WorkflowJob, JsonBean { return endTimestamp; } - public void setStatusStr (String statusStr) { - this.statusStr = statusStr; - } + public void setStatusStr (String statusStr) { this.statusStr = StringUtils.intern(statusStr); } - public void setStatus(Status val) { - this.statusStr = val.toString(); - } + public void setStatus(Status val) { this.statusStr = StringUtils.intern(val.toString()); } @Override public Status getStatus() { @@ -455,7 +452,7 @@ public class WorkflowJobBean implements Writable, WorkflowJob, JsonBean { } public void setExternalId(String externalId) { - this.externalId = externalId; + this.externalId = StringUtils.intern(externalId); } @Override @@ -533,25 +530,19 @@ public class WorkflowJobBean implements Writable, WorkflowJob, JsonBean { return appPath; } - public void setAppPath(String appPath) { - this.appPath = appPath; - } + public void setAppPath(String appPath) { this.appPath = StringUtils.intern(appPath); } public String getAppName() { return appName; } - public void setAppName(String appName) { - this.appName = appName; - } + public void setAppName(String appName) { this.appName = StringUtils.intern(appName); } public String getId() { return id; } - public void setId(String id) { - this.id = id; - } + public void setId(String id) { this.id = StringUtils.intern(id); } public String getConf() { return conf == null ? null : conf.getString(); @@ -578,9 +569,7 @@ public class WorkflowJobBean implements Writable, WorkflowJob, JsonBean { return user; } - public void setUser(String user) { - this.user = user; - } + public void setUser(String user) { this.user = StringUtils.intern(user); } public String getGroup() { return group; @@ -592,7 +581,7 @@ public class WorkflowJobBean implements Writable, WorkflowJob, JsonBean { } public void setGroup(String group) { - this.group = group; + this.group = StringUtils.intern(group); } public int getRun() { @@ -628,9 +617,7 @@ public class WorkflowJobBean implements Writable, WorkflowJob, JsonBean { * * @param parentId the Parent Action id */ - public void setParentId(String parentId) { - this.parentId = parentId; - } + public void setParentId(String parentId) { this.parentId = StringUtils.intern(parentId); } /** * Set the workflow job console URL. @@ -638,7 +625,7 @@ public class WorkflowJobBean implements Writable, WorkflowJob, JsonBean { * @param consoleUrl the workflow job console URL. */ public void setConsoleUrl(String consoleUrl) { - this.consoleUrl = consoleUrl; + this.consoleUrl = StringUtils.intern(consoleUrl); } @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/oozie/blob/7804e744/core/src/main/java/org/apache/oozie/command/wf/ActionEndXCommand.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/command/wf/ActionEndXCommand.java b/core/src/main/java/org/apache/oozie/command/wf/ActionEndXCommand.java index ef0ed66..8bf4fc7 100644 --- a/core/src/main/java/org/apache/oozie/command/wf/ActionEndXCommand.java +++ b/core/src/main/java/org/apache/oozie/command/wf/ActionEndXCommand.java @@ -54,6 +54,7 @@ import org.apache.oozie.service.Services; import org.apache.oozie.service.UUIDService; import org.apache.oozie.util.Instrumentation; import org.apache.oozie.util.LogUtils; +import org.apache.oozie.util.StringUtils; import org.apache.oozie.util.XLog; import org.apache.oozie.util.db.SLADbXOperations; import org.apache.oozie.workflow.WorkflowInstance; @@ -74,7 +75,7 @@ public class ActionEndXCommand extends ActionXCommand<Void> { public ActionEndXCommand(String actionId, String type) { super("action.end", type, 0); - this.actionId = actionId; + this.actionId = StringUtils.intern(actionId); this.jobId = Services.get().get(UUIDService.class).getId(actionId); } http://git-wip-us.apache.org/repos/asf/oozie/blob/7804e744/core/src/main/java/org/apache/oozie/service/CallableQueueService.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/service/CallableQueueService.java b/core/src/main/java/org/apache/oozie/service/CallableQueueService.java index cfd208a..7b89964 100644 --- a/core/src/main/java/org/apache/oozie/service/CallableQueueService.java +++ b/core/src/main/java/org/apache/oozie/service/CallableQueueService.java @@ -45,6 +45,7 @@ import org.apache.oozie.util.NamedThreadFactory; import org.apache.oozie.util.PollablePriorityDelayQueue; import org.apache.oozie.util.PriorityDelayQueue; import org.apache.oozie.util.PriorityDelayQueue.QueueElement; +import org.apache.oozie.util.StringUtils; import org.apache.oozie.util.XCallable; import org.apache.oozie.util.XLog; @@ -279,7 +280,7 @@ public class CallableQueueService implements Service, Instrumentable { separator = ","; } sb.append("]"); - name = sb.toString(); + name = StringUtils.intern(sb.toString()); } @Override http://git-wip-us.apache.org/repos/asf/oozie/blob/7804e744/core/src/main/java/org/apache/oozie/util/StringUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/util/StringUtils.java b/core/src/main/java/org/apache/oozie/util/StringUtils.java index 280c83a..26079be 100644 --- a/core/src/main/java/org/apache/oozie/util/StringUtils.java +++ b/core/src/main/java/org/apache/oozie/util/StringUtils.java @@ -37,4 +37,17 @@ public class StringUtils { } return str; } + + /** + * Return the internalized string, or null if the given string is null. + * @param str The string to intern + * @return The identical string cached in the JVM string pool. + */ + public static String intern(String str) { + if (str == null) { + return null; + } + return str.intern(); + } } + http://git-wip-us.apache.org/repos/asf/oozie/blob/7804e744/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index 9f148b8..9c066a7 100644 --- a/release-log.txt +++ b/release-log.txt @@ -1,5 +1,6 @@ -- Oozie 5.1.0 release (trunk - unreleased) +OOZIE-3232 Reduce heap waste by reducing duplicate string count (Misha Dmitriev via andras.piros) OOZIE-2914 Consolidate trim calls (Jan Hentschel via andras.piros) OOZIE-2934 [sharelib/spark] Fix Findbugs error (Jan Hentschel via andras.piros) OOZIE-3225 [Kerberos] Webconsole disabled message shown instead of 401 error (kmarton via andras.piros)