You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/12/01 12:07:12 UTC

[GitHub] [incubator-druid] doctording opened a new issue #8975: JavaScriptWorkerSelectStrategy is not equal sometimes

doctording opened a new issue #8975: JavaScriptWorkerSelectStrategy is not equal sometimes
URL: https://github.com/apache/incubator-druid/issues/8975
 
 
   ### Affected Version
   0.12.3
   
   ### Description
   
   I use JavaScriptWorkerSelectStrategy, the script :
   
   ```java
   {"type":"default","selectStrategy":{"type":"javascript","function":"function (config, zkWorkers, task) {\nvar batch_workers = new java.util.ArrayList(128);\nbatch_workers.add(\"host1:8091\");\nbatch_workers.add(\"host2:8091\");\nbatch_workers.add(\"host3:8091\");\nworkers = zkWorkers.keySet().toArray();\nvar sortedWorkers = new Array()\n;for(var i = 0; i < workers.length; i++){\n sortedWorkers[i] = workers[i];\n}\nArray.prototype.sort.call(sortedWorkers,function(a, b){return zkWorkers.get(a).getCurrCapacityUsed() - zkWorkers.get(b).getCurrCapacityUsed();});\nvar minWorkerVer = config.getMinWorkerVersion();\nfor (var i = 0; i < sortedWorkers.length; i++) {\n var worker = sortedWorkers[i];\n  var zkWorker = zkWorkers.get(worker);\n  if(zkWorker.canRunTask(task) && zkWorker.isValidVersion(minWorkerVer)){\n    if(task.getType() == 'index_hadoop' && batch_workers.contains(worker)){\n      return worker;\n    } else {\n      if(task.getType() != 'index_hadoop' && !batch_workers.contains(worker)){\n        return worker;\n      }\n    }\n  }\n}\nreturn null;\n}"},"autoScaler":null}
   ```
   
   when sometime 50 `index_hadoop` tasks comes, the worker's used capacity:
   
   ```
   host1: 30
   host2: 20
   host3: 0
   ```
   expect result should be
    ```
   host1: 17
   host2: 17
   host3: 16
   ```
   
   but it's equal in most times, the case like this
   
   more than 30 tasks assigned to a worker within 1-2s
   
   ![image](https://user-images.githubusercontent.com/11834821/69913677-c100b680-1475-11ea-9b45-8276be3b2aa5.png)
   
   
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org