You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/11/15 13:27:10 UTC

[GitHub] [shardingsphere-elasticjob] johnny2002 commented on issue #1720: Customize the JobInstance

johnny2002 commented on issue #1720:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1720#issuecomment-727569644


   > @johnny2002 Hi, thank you for the suggestion.
   > I want discuss further.
   > Job instance id is internal impl in elastic job which user should not focus on them.
   > It is not a good idea to expose lots of internal impl to special reason.
   > 
   > Can you consider about reuse the job sharding strategy to rebalance your sub-job?
   
   Hi Terry,
   My problem is cannot identify JobInstnaces.
   If you don't like to change the jobinstance id, I have another graceful way like:
   Pass all System Properties that name starts with "elasticjob." into JobInstance.
   Sample code:
   ```java
       public JobInstance() {
           jobInstanceId = IpUtils.getIp() + DELIMITER + ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
           
           //extract all system properties that name start with "elasticjob."
           for (Map.Entry propEntry : System.getProperties().entrySet()) {
               if (propEntry.getKey().toString().startsWith("elasticjob.")) {
                   properties.put((String)propEntry.getKey(), (String)propEntry.getValue());
               }
           }
       }
   ```
   Then we can identify JobInstance through JobInstance.properties


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org