• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Cluster类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中backtype.storm.scheduler.Cluster的典型用法代码示例。如果您正苦于以下问题:Java Cluster类的具体用法?Java Cluster怎么用?Java Cluster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Cluster类属于backtype.storm.scheduler包,在下文中一共展示了Cluster类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getSpyCluster

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
private Cluster getSpyCluster(int numWorkers, int numExecutors) {
  Cluster spyCluster = getSpyCluster();

  List<MesosWorkerSlot> mesosWorkerSlots = this.generateMesosWorkerSlots(numWorkers);
  initializeMesosWorkerSlotMap(mesosWorkerSlots);

  Set<ExecutorDetails> executorsToAssign = this.generateExecutorDetailsSet(numExecutors);
  List<WorkerSlot> workerSlotList = getWorkerSlotFromMesosWorkerSlot(mesosWorkerSlots);
  topologyMap.put(sampleTopologyId, TestUtils.constructTopologyDetails(sampleTopologyId, numWorkers, 0.1, 100));
  this.topologies = new Topologies(topologyMap);

  doReturn(workerSlotList).when(spyCluster).getAvailableSlots();
  doReturn(executorsToAssign).when(spyCluster).getUnassignedExecutors(any(TopologyDetails.class));

  return spyCluster;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:17,代码来源:DefaultSchedulerTest.java


示例2: testScheduleWithOneWorkerSlot

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
@Test
public void testScheduleWithOneWorkerSlot() {
  Cluster spyCluster = getSpyCluster();

  List<MesosWorkerSlot> mesosWorkerSlots = this.generateMesosWorkerSlots(1);
  initializeMesosWorkerSlotMap(mesosWorkerSlots);

  Set<ExecutorDetails> executorsToAssign = this.generateExecutorDetailsSet(4);
  List<WorkerSlot> workerSlotList = getWorkerSlotFromMesosWorkerSlot(mesosWorkerSlots);

  doReturn(workerSlotList).when(spyCluster).getAvailableSlots();
  doReturn(executorsToAssign).when(spyCluster).getUnassignedExecutors(any(TopologyDetails.class));

  defaultScheduler.schedule(topologies, spyCluster);

  Set<ExecutorDetails> assignedExecutors = spyCluster.getAssignmentById(sampleTopologyId).getExecutors();
  assertEquals(executorsToAssign, assignedExecutors);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:19,代码来源:DefaultSchedulerTest.java


示例3: schedule

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
@Override
public void schedule(Topologies topologies, Cluster cluster) {
	
	logger.info("Online Scheduler");
	logger.info("+++++++++++++++++++++++++++");
	if (!topologies.getTopologies().isEmpty()) {
		int rescheduleTimeout = DEFAULT_RESCHEDULE_TIMEOUT;
		for (TopologyDetails topology : topologies.getTopologies()) {
			rescheduleTimeout = Integer.parseInt(topology.getConf().get(Utils.RESCHEDULE_TIMEOUT).toString());
		}
		long now = System.currentTimeMillis();
		long elapsedTime = (now - lastRescheduling) / 1000; // s
		if (lastRescheduling == 0 || elapsedTime >= rescheduleTimeout)
			doSchedule(topologies, cluster);
		else
			logger.info("It's not time to reschedule yet, " + elapsedTime + " seconds have passed, other " + (rescheduleTimeout - elapsedTime) + " seconds have to pass");
	}

	logger.info("---------------------------");
	
	logger.info("Calling EvenScheduler to schedule remaining executors...");
	new EvenScheduler().schedule(topologies, cluster);
	logger.info("Ok, EvenScheduler succesfully called");
	
	assignmentTracker.checkAssignment(topologies, cluster);
}
 
开发者ID:leonardoaniello,项目名称:storm-adaptive-schedulers,代码行数:27,代码来源:OnlineScheduler.java


示例4: free

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
/**
 * Frees a single slot in this node
 * 
 * @param ws the slot to free
 * @param cluster the cluster to update
 */
public void free(WorkerSlot ws, Cluster cluster, boolean forceFree) {
    if (_freeSlots.contains(ws))
        return;
    boolean wasFound = false;
    for (Entry<String, Set<WorkerSlot>> entry : _topIdToUsedSlots.entrySet()) {
        Set<WorkerSlot> slots = entry.getValue();
        if (slots.remove(ws)) {
            cluster.freeSlot(ws);
            if (_isAlive) {
                _freeSlots.add(ws);
            }
            wasFound = true;
        }
    }
    if (!wasFound) {
        if (forceFree) {
            LOG.info("Forcefully freeing the " + ws);
            cluster.freeSlot(ws);
            _freeSlots.add(ws);
        } else {
            throw new IllegalArgumentException("Tried to free a slot that was not" + " part of this node " + _nodeId);
        }
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:31,代码来源:Node.java


示例5: assign

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
/**
 * Assign a free slot on the node to the following topology and executors. This will update the cluster too.
 * 
 * @param topId the topology to assign a free slot to.
 * @param executors the executors to run in that slot.
 * @param cluster the cluster to be updated
 */
public void assign(String topId, Collection<ExecutorDetails> executors, Cluster cluster) {
    if (!_isAlive) {
        throw new IllegalStateException("Trying to adding to a dead node " + _nodeId);
    }
    if (_freeSlots.isEmpty()) {
        throw new IllegalStateException("Trying to assign to a full node " + _nodeId);
    }
    if (executors.size() == 0) {
        LOG.warn("Trying to assign nothing from " + topId + " to " + _nodeId + " (Ignored)");
    } else {
        WorkerSlot slot = _freeSlots.iterator().next();
        cluster.assign(slot, topId, executors);
        assignInternal(slot, topId, false);
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:23,代码来源:Node.java


示例6: free

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
/**
 * Frees a single slot in this node
 *
 * @param ws      the slot to free
 * @param cluster the cluster to update
 */
public void free(WorkerSlot ws, Cluster cluster, boolean forceFree) {
    if (_freeSlots.contains(ws))
        return;
    boolean wasFound = false;
    for (Entry<String, Set<WorkerSlot>> entry : _topIdToUsedSlots.entrySet()) {
        Set<WorkerSlot> slots = entry.getValue();
        if (slots.remove(ws)) {
            cluster.freeSlot(ws);
            if (_isAlive) {
                _freeSlots.add(ws);
            }
            wasFound = true;
        }
    }
    if (!wasFound) {
        if (forceFree) {
            LOG.info("Forcefully freeing the " + ws);
            cluster.freeSlot(ws);
            _freeSlots.add(ws);
        } else {
            throw new IllegalArgumentException("Tried to free a slot that was not" + " part of this node " + _nodeId);
        }
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:31,代码来源:Node.java


示例7: assign

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
/**
 * Assign a free slot on the node to the following topology and executors. This will update the cluster too.
 *
 * @param topId     the topology to assign a free slot to.
 * @param executors the executors to run in that slot.
 * @param cluster   the cluster to be updated
 */
public void assign(String topId, Collection<ExecutorDetails> executors, Cluster cluster) {
    if (!_isAlive) {
        throw new IllegalStateException("Trying to adding to a dead node " + _nodeId);
    }
    if (_freeSlots.isEmpty()) {
        throw new IllegalStateException("Trying to assign to a full node " + _nodeId);
    }
    if (executors.size() == 0) {
        LOG.warn("Trying to assign nothing from " + topId + " to " + _nodeId + " (Ignored)");
    } else {
        WorkerSlot slot = _freeSlots.iterator().next();
        cluster.assign(slot, topId, executors);
        assignInternal(slot, topId, false);
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:23,代码来源:Node.java


示例8: schedule

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
/**
 * Schedule function looks in the "mesosWorkerSlotMap" to determine which topology owns the particular
 * WorkerSlot and assigns the executors accordingly.
 */
@Override
public void schedule(Topologies topologies, Cluster cluster) {
  List<WorkerSlot> workerSlots = cluster.getAvailableSlots();
  Map<String, List<MesosWorkerSlot>> perTopologySlotList = getMesosWorkerSlotPerTopology(workerSlots);

  // So far we know how many MesosSlots each of the topologies have got. Lets assign executors for each of them
  for (String topologyId : perTopologySlotList.keySet()) {
    TopologyDetails topologyDetails = topologies.getById(topologyId);
    List<MesosWorkerSlot> mesosWorkerSlots = perTopologySlotList.get(topologyId);

    int countSlotsRequested = topologyDetails.getNumWorkers();
    int countSlotsAssigned = cluster.getAssignedNumWorkers(topologyDetails);

    if (mesosWorkerSlots.size() == 0) {
      log.warn("No slots found for topology {} while scheduling", topologyId);
      continue;
    }

    int countSlotsAvailable = Math.min(mesosWorkerSlots.size(), (countSlotsRequested - countSlotsAssigned));

    List<List<ExecutorDetails>> executorsPerWorkerList = executorsPerWorkerList(cluster, topologyDetails, countSlotsAvailable);

    for (int i = 0; i < countSlotsAvailable; i++) {
      cluster.assign(mesosWorkerSlots.remove(0), topologyId, executorsPerWorkerList.remove(0));
    }
  }
  mesosWorkerSlotMap.clear();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:33,代码来源:DefaultScheduler.java


示例9: testScheduleWithMultipleSlotsOnSameHost

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
@Test
public void testScheduleWithMultipleSlotsOnSameHost() {
  Cluster spyCluster = this.getSpyCluster(3, 3);
  defaultScheduler.schedule(topologies, spyCluster);
  SchedulerAssignment schedulerAssignment = spyCluster.getAssignments()
                                                       .get(sampleTopologyId);
  Map<ExecutorDetails, WorkerSlot> executorDetailsWorkerSlotMap = schedulerAssignment.getExecutorToSlot();
  /* We expect the three unassigned executors to be spread
     across the three available worker slots */
  assertEquals(executorDetailsWorkerSlotMap.keySet().size(), 3);
  assertEquals(executorDetailsWorkerSlotMap.values().size(), 3);

  spyCluster = this.getSpyCluster(3, 6);
  defaultScheduler.schedule(topologies, spyCluster);
  executorDetailsWorkerSlotMap = spyCluster.getAssignments()
                                            .get(sampleTopologyId)
                                            .getExecutorToSlot();
  /* We expect all executors to be scheduled across the three
     available slots */
  assertEquals(executorDetailsWorkerSlotMap.keySet().size(), 6);
  int workerSlotsUsed = new HashSet<>(executorDetailsWorkerSlotMap.values()).size() ;
  assertEquals(workerSlotsUsed, 3);

  /* Lets make sure that the executors are evenly spread
     across the worker slots in a round robin fashion */
  schedulerAssignment = spyCluster.getAssignments()
                                                       .get(sampleTopologyId);
  executorDetailsWorkerSlotMap = schedulerAssignment.getExecutorToSlot();

  Map<WorkerSlot, List<ExecutorDetails>> workerSlotExecutorDetailsMap = this.getworkerSlotExecutorDetailsMap(executorDetailsWorkerSlotMap);

  for (WorkerSlot workerSlot : workerSlotExecutorDetailsMap.keySet()) {
    List<ExecutorDetails> executorDetails = workerSlotExecutorDetailsMap.get(workerSlot);
    assertEquals(3, Math.abs(executorDetails.get(0).getStartTask() - executorDetails.get(1).getEndTask()));
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:37,代码来源:DefaultSchedulerTest.java


示例10: init

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
@Override
public void init(Cluster cluster, Map<String, Node> nodeIdToNode) {
    super.init(cluster, nodeIdToNode);
    for (Node n : nodeIdToNode.values()) {
        if (n.isTotallyFree() && n.isAlive()) {
            _nodes.add(n);
            _totalSlots += n.totalSlotsFree();
        }
    }
    LOG.debug("Found {} nodes with {} slots", _nodes.size(), _totalSlots);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:12,代码来源:FreePool.java


示例11: freeAllSlots

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
/**
 * Free all slots on this node. This will update the Cluster too.
 * 
 * @param cluster the cluster to be updated
 */
public void freeAllSlots(Cluster cluster) {
    if (!_isAlive) {
        LOG.warn("Freeing all slots on a dead node {} ", _nodeId);
    }
    for (Entry<String, Set<WorkerSlot>> entry : _topIdToUsedSlots.entrySet()) {
        cluster.freeSlots(entry.getValue());
        if (_isAlive) {
            _freeSlots.addAll(entry.getValue());
        }
    }
    _topIdToUsedSlots = new HashMap<String, Set<WorkerSlot>>();
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:18,代码来源:Node.java


示例12: freeTopology

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
/**
 * Frees all the slots for a topology.
 * 
 * @param topId the topology to free slots for
 * @param cluster the cluster to update
 */
public void freeTopology(String topId, Cluster cluster) {
    Set<WorkerSlot> slots = _topIdToUsedSlots.get(topId);
    if (slots == null || slots.isEmpty())
        return;
    for (WorkerSlot ws : slots) {
        cluster.freeSlot(ws);
        if (_isAlive) {
            _freeSlots.add(ws);
        }
    }
    _topIdToUsedSlots.remove(topId);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:19,代码来源:Node.java


示例13: freeAllSlots

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
/**
 * Free all slots on this node. This will update the Cluster too.
 *
 * @param cluster the cluster to be updated
 */
public void freeAllSlots(Cluster cluster) {
    if (!_isAlive) {
        LOG.warn("Freeing all slots on a dead node {} ", _nodeId);
    }
    for (Entry<String, Set<WorkerSlot>> entry : _topIdToUsedSlots.entrySet()) {
        cluster.freeSlots(entry.getValue());
        if (_isAlive) {
            _freeSlots.addAll(entry.getValue());
        }
    }
    _topIdToUsedSlots = new HashMap<>();
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:18,代码来源:Node.java


示例14: freeTopology

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
/**
 * Frees all the slots for a topology.
 *
 * @param topId   the topology to free slots for
 * @param cluster the cluster to update
 */
public void freeTopology(String topId, Cluster cluster) {
    Set<WorkerSlot> slots = _topIdToUsedSlots.get(topId);
    if (slots == null || slots.isEmpty())
        return;
    for (WorkerSlot ws : slots) {
        cluster.freeSlot(ws);
        if (_isAlive) {
            _freeSlots.add(ws);
        }
    }
    _topIdToUsedSlots.remove(topId);
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:19,代码来源:Node.java


示例15: schedule

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
@Override
public void schedule(Topologies topologies, Cluster cluster) {
	evenScheduler.schedule(topologies, cluster);
	assignmentTracker.checkAssignment(topologies, cluster);
}
 
开发者ID:leonardoaniello,项目名称:storm-adaptive-schedulers,代码行数:6,代码来源:DefaultScheduler.java


示例16: schedule

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
@Override
public void schedule(Topologies topologies, Cluster cluster) {
    LOG.trace("scheduling topologies...");



    this.evenScheduler.schedule(topologies, cluster);
}
 
开发者ID:uzh,项目名称:storm-scheduler,代码行数:9,代码来源:DummyScheduler.java


示例17: init

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
/**
 * Initialize the pool.
 * 
 * @param cluster the cluster
 * @param nodeIdToNode the mapping of node id to nodes
 */
public void init(Cluster cluster, Map<String, Node> nodeIdToNode) {
    _cluster = cluster;
    _nodeIdToNode = nodeIdToNode;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:11,代码来源:NodePool.java


示例18: init

import backtype.storm.scheduler.Cluster; //导入依赖的package包/类
/**
 * Initialize the pool.
 *
 * @param cluster      the cluster
 * @param nodeIdToNode the mapping of node id to nodes
 */
public void init(Cluster cluster, Map<String, Node> nodeIdToNode) {
    _cluster = cluster;
    _nodeIdToNode = nodeIdToNode;
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:11,代码来源:NodePool.java



注:本文中的backtype.storm.scheduler.Cluster类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AppBean类代码示例发布时间:2022-05-22
下一篇:
Java TransformationContext类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap