You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2018/12/10 03:07:50 UTC
[kylin] branch master updated: KYLIN-3617 Add javadoc for magic
number in isTaskExecutableOutput
This is an automated email from the ASF dual-hosted git repository.
shaofengshi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git
The following commit(s) were added to refs/heads/master by this push:
new 2de2b9f KYLIN-3617 Add javadoc for magic number in isTaskExecutableOutput
2de2b9f is described below
commit 2de2b9fced1ba27b1688b803e119160aa45950fc
Author: hit-lacus <hi...@126.com>
AuthorDate: Sun Dec 9 21:23:17 2018 +0800
KYLIN-3617 Add javadoc for magic number in isTaskExecutableOutput
---
.../org/apache/kylin/job/dao/ExecutableDao.java | 25 +++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/core-job/src/main/java/org/apache/kylin/job/dao/ExecutableDao.java b/core-job/src/main/java/org/apache/kylin/job/dao/ExecutableDao.java
index 4e7188a..a4dc4c1 100644
--- a/core-job/src/main/java/org/apache/kylin/job/dao/ExecutableDao.java
+++ b/core-job/src/main/java/org/apache/kylin/job/dao/ExecutableDao.java
@@ -31,6 +31,8 @@ import org.apache.kylin.common.persistence.ResourceStore;
import org.apache.kylin.common.persistence.Serializer;
import org.apache.kylin.common.util.AutoReadWriteLock;
import org.apache.kylin.job.exception.PersistentException;
+import org.apache.kylin.job.execution.AbstractExecutable;
+import org.apache.kylin.job.execution.DefaultChainedExecutable;
import org.apache.kylin.metadata.cachesync.Broadcaster;
import org.apache.kylin.metadata.cachesync.CachedCrudAssist;
import org.apache.kylin.metadata.cachesync.CaseInsensitiveStringCache;
@@ -164,8 +166,29 @@ public class ExecutableDao {
Broadcaster.getInstance(config).registerListener(new JobOutputSyncListener(), "execute_output");
}
+ /**
+ * Length of java.util.UUID's string representation is always 36.
+ */
+ private static final int UUID_STRING_REPRESENTATION_LENGTH = 36;
+
+ /**
+ * <pre>
+ * Backgroud :
+ * 1. Each Executable has id, and id should be unique, we use java.util.UUID to create id of Executable.
+ * 2. 36(UUID_STRING_REPRESENTATION_LENGTH) is a magic number, and it is the length of string of java.util.UUID.toString(). It can verified this simply by `System.out.println(UUID.randomUUID().toString().length());`
+ * 3. All subtask of a ChainedExecutable is also a Executable, its id is a string which length is 39 (36 + 3). See DefaultChainedExecutable#addTask.
+ * 4. Any other Executable's id is a String created by UUID.toString(), so its length is 36.
+ * 5. This method may be a bit fragile/confusing because it depend on specific implementation of subclass of Executable.
+ * </pre>
+ *
+ * @see DefaultChainedExecutable#addTask(AbstractExecutable)
+ * @see AbstractExecutable#AbstractExecutable()
+ *
+ * @param id id of a Executable (mostly it is a UUID)
+ * @return true if the job is a subtask of a ChainedExecutable; else return false
+ */
private boolean isTaskExecutableOutput(String id) {
- return id.length() > 36;
+ return id.length() > UUID_STRING_REPRESENTATION_LENGTH;
}
private class JobSyncListener extends Broadcaster.Listener {