[ 
https://issues.apache.org/jira/browse/KYLIN-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16714233#comment-16714233
 ] 

ASF GitHub Bot commented on KYLIN-3617:
---------------------------------------

shaofengshi closed pull request #376: KYLIN-3617 Add javadoc for magic number 
in isTaskExecutableOutput
URL: https://github.com/apache/kylin/pull/376
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 4e7188a71c..a4dc4c1d87 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.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 @@ protected ExecutableOutputPO 
initEntityAfterReload(ExecutableOutputPO entity, St
         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 {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Reduce number of visiting metastore for job scheduler
> -----------------------------------------------------
>
>                 Key: KYLIN-3617
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3617
>             Project: Kylin
>          Issue Type: Improvement
>          Components: Job Engine
>    Affects Versions: v2.4.1
>            Reporter: nichunen
>            Assignee: nichunen
>            Priority: Major
>             Fix For: v2.6.0
>
>         Attachments: image-2018-12-09-20-22-51-336.png, 
> image-2018-12-09-20-24-30-590.png, image-2018-12-09-20-25-40-265.png, 
> image-2018-12-09-20-26-30-105.png, image-2018-12-09-20-26-40-478.png
>
>
> For KYLIN-3470 introduced cache for jobs' metadata, it's also can be used in 
> job scheduler to reduce the pressure on metastore



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to