Strom:pluggable scheduler :如何检测component是否已经分配到了指定的主机上
来源:互联网 发布:高效程序员的修炼 编辑:程序博客网 时间:2024/05/16 15:03
转自:http://blog.csdn.net/daliaojie/article/details/18617305
在做storm项目的时候,发现之前的那种判断是否执行自定义分配策略的条件太粗陋。以下是较严格的解决方案:
处理步骤应该为:
不懂得可以给我留言
//从实体的名字获取实体的线程集
private ArrayList<ExecutorDetails> getExecutorByName(TopologyDetails topology, String ExecutorNames) {ArrayList<ExecutorDetails> re = new ArrayList<ExecutorDetails>();TopologyDetails TempTP = topology;Map<ExecutorDetails, String> temMap = TempTP.getExecutorToComponent();Set<ExecutorDetails> keyS = temMap.keySet();String ComName = null;for (ExecutorDetails temp : keyS) {ComName = temMap.get(temp);if (ComName.equals(ExecutorNames)) {re.add(temp);}}return re;}
//从线程集获取对应的WorkerSlot集合private ArrayList<WorkerSlot> getslotByEx(SchedulerAssignment currentAssignment,ArrayList<ExecutorDetails> Edlist) {ArrayList<WorkerSlot> re = new ArrayList<WorkerSlot>();Map<ExecutorDetails, WorkerSlot> tempEw = currentAssignment.getExecutorToSlot();WorkerSlot tempWorkSlot = null;for (ExecutorDetails temp : Edlist) {tempWorkSlot = tempEw.get(temp);re.add(tempWorkSlot);}return re;}
//根据WorkerSlot获取对应的主机名集合private ArrayList<String> getHostName(ArrayList<WorkerSlot> wSlotAlist,Cluster cluster) {ArrayList<String> AlHostName = new ArrayList<String>();for (WorkerSlot wSlot : wSlotAlist) {String tmp = wSlot.getNodeId();String HostName = cluster.getHost(tmp);if (AlHostName.contains(HostName) == false) {AlHostName.add(HostName);}}return AlHostName;}
//需要执行自定义策略,则返回1private int needdocustomSchedule(String topologyName, String ComName,String HostName, Cluster cluster, Topologies topologies) {int flag = -1;Map<String, List<ExecutorDetails>> componentToExecutors = cluster.getNeedsSchedulingComponentToExecutors(topologies.getByName(topologyName));if (componentToExecutors == null) {System.out.println("currentAssignment is null!!!");return flag;}if (componentToExecutors.containsKey(ComName))// component don't allocate{flag = 1;} else {TopologyDetails topologyss = topologies.getByName(topologyName);ArrayList<ExecutorDetails> tempEname = getExecutorByName(topologyss, ComName);SchedulerAssignment currentAssignment = cluster.getAssignmentById(topologies.getByName(topologyName).getId());if (currentAssignment != null) {ArrayList<WorkerSlot> alistWs = getslotByEx(currentAssignment,tempEname);ArrayList<String> AlistHostName = getHostName(alistWs, cluster);for (String tempStr : AlistHostName) {if (tempStr.equals(HostName)) {flag = 0;}else{flag = 1;}}}}return flag;}
//释放当前已分配的任务private void freeAssignment(SchedulerAssignment currentAssignment,Cluster cluster) {Set<WorkerSlot> tempws=currentAssignment.getSlots();for(WorkerSlot temp:tempws){cluster.freeSlot(new WorkerSlot(temp.getNodeId(),temp.getPort()));}}
0 0
- Strom:pluggable scheduler :如何检测component是否已经分配到了指定的主机上
- Strom:pluggable scheduler 自己写的自定义分配任务
- 如何检测远程主机上的某个端口是否开启?
- 如何检测远程主机上的某个端口是否开启
- 如何检测远程主机上的某个端口是否开启?
- Strom 可定制任务调度策略(Pluggable Scheduler)
- 是否已经到了迷茫的阶段?
- Telnet命令检测远程主机上的端口是否开启
- 如何检测系统是否已经运行了相同的程序。
- 如何检测系统是否已经运行了相同的程序
- 在系统中检测指定的窗口是否已经打开,检查某进程是否存在
- 在系统中检测指定的窗口是否已经打开,检查某进程是否存在
- 如何检测电脑是否已经中毒?
- 如何检测指定的Windows服务是否启动
- DELPHI如何检测指定的端口是否开放
- Twitter Storm的新利器Pluggable Scheduler 【转】
- PtInRegion 检测鼠标的坐标是否移动到了某个区域
- cocos2dx 检测是否点击到了图片的透明区域
- 睡眠十律:程序员必看
- sql学习
- 悟透JavaScript (强烈推荐)
- ise 在线逻辑分析仪
- Linux内核学习笔记之高速缓冲管理(五)
- Strom:pluggable scheduler :如何检测component是否已经分配到了指定的主机上
- E: Sub-process /usr/bin/dpkg returned an error code (1)错误解决
- no space left on device 导致服务器启动失败
- Restore IP Addresses
- 白杨树的枝、叶大都向上,很少有向下生长的;
- test
- Nginx + Tomcat + MSM + Memcached 非粘性Session共享测试
- Java 多态的简单介绍.
- 使用php curl出现的一点问题