本文整理汇总了Java中backtype.storm.scheduler.WorkerSlot类的典型用法代码示例。如果您正苦于以下问题:Java WorkerSlot类的具体用法?Java WorkerSlot怎么用?Java WorkerSlot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkerSlot类属于backtype.storm.scheduler包,在下文中一共展示了WorkerSlot类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getMesosWorkerSlotPerTopology
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
Map<String, List<MesosWorkerSlot>> getMesosWorkerSlotPerTopology(List<WorkerSlot> workerSlots) {
HashMap<String, List<MesosWorkerSlot>> perTopologySlotList = new HashMap<>();
for (WorkerSlot workerSlot : workerSlots) {
if (workerSlot.getNodeId() == null) {
log.warn("Unexpected: Node id is null for worker slot while scheduling");
continue;
}
MesosWorkerSlot mesosWorkerSlot = mesosWorkerSlotMap.get(workerSlot.getNodeId() +
":" + String.valueOf(workerSlot.getPort()));
String topologyId = mesosWorkerSlot.getTopologyId();
if (perTopologySlotList.get(topologyId) == null) {
perTopologySlotList.put(topologyId, new ArrayList<MesosWorkerSlot>());
}
perTopologySlotList.get(topologyId).add(mesosWorkerSlot);
}
return perTopologySlotList;
}
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:21,代码来源:DefaultScheduler.java
示例2: assignSlots
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
@Override
public void assignSlots(Topologies topologies, Map<String, Collection<WorkerSlot>> slots) {
if (slots.size() == 0) {
LOG.debug("assignSlots: no slots passed in, nothing to do");
return;
}
for (Map.Entry<String, Collection<WorkerSlot>> topologyToSlots : slots.entrySet()) {
String topologyId = topologyToSlots.getKey();
for (WorkerSlot slot : topologyToSlots.getValue()) {
TopologyDetails details = topologies.getById(topologyId);
LOG.debug("assignSlots: topologyId: {} worker being assigned to slot: {} with workerCpu: {} workerMem: {}",
topologyId, slot, MesosCommon.topologyWorkerCpu(_conf, details), MesosCommon.topologyWorkerMem(_conf, details));
}
}
synchronized (_offersLock) {
computeLaunchList(topologies, slots);
}
}
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:19,代码来源:MesosNimbus.java
示例3: getSpyCluster
import backtype.storm.scheduler.WorkerSlot; //导入依赖的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
示例4: testScheduleWithOneWorkerSlot
import backtype.storm.scheduler.WorkerSlot; //导入依赖的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
示例5: mapToString
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
private String mapToString(Map<String, List<WorkerSlot>> map) {
if (map == null)
return "null";
if (map.keySet().isEmpty())
return "<empty map>";
StringBuffer sb = new StringBuffer();
int i = 0;
for (Object key : map.keySet()) {
sb.append(key.toString() + " -> (");
sb.append(collectionToString(map.get(key)) + ")");
if (i < map.keySet().size() - 1)
sb.append(", ");
i++;
}
return sb.toString();
}
开发者ID:leonardoaniello,项目名称:storm-adaptive-schedulers,代码行数:17,代码来源:NodeHelper.java
示例6: isOutTaskConnected
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
private boolean isOutTaskConnected(int taskId) {
boolean ret = false;
if (workerData.getInnerTaskTransfer().get(taskId) != null) {
// Connections to inner tasks should be done after initialization.
// So return true here for all inner tasks.
ret = true;
} else {
WorkerSlot slot = taskNodeport.get(taskId);
if (slot != null) {
IConnection connection = nodeportSocket.get(slot);
if (connection != null) {
ret = connection.available();
}
}
}
return ret;
}
开发者ID:kkllwww007,项目名称:jstrom,代码行数:20,代码来源:RefreshConnections.java
示例7: assignInternal
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
boolean assignInternal(WorkerSlot ws, String topId, boolean dontThrow) {
validateSlot(ws);
if (!_freeSlots.remove(ws)) {
for (Entry<String, Set<WorkerSlot>> topologySetEntry : _topIdToUsedSlots.entrySet()) {
if (topologySetEntry.getValue().contains(ws)) {
if (dontThrow) {
LOG.warn("Worker slot [" + ws + "] can't be assigned to " + topId + ". Its already assigned to " + topologySetEntry.getKey() + ".");
return true;
}
throw new IllegalStateException("Worker slot [" + ws + "] can't be assigned to " + topId + ". Its already assigned to "
+ topologySetEntry.getKey() + ".");
}
}
LOG.warn("Adding Worker slot [" + ws + "] that was not reported in the supervisor heartbeats," + " but the worker is already running for topology "
+ topId + ".");
}
Set<WorkerSlot> usedSlots = _topIdToUsedSlots.get(topId);
if (usedSlots == null) {
usedSlots = new HashSet<WorkerSlot>();
_topIdToUsedSlots.put(topId, usedSlots);
}
usedSlots.add(ws);
return false;
}
开发者ID:kkllwww007,项目名称:jstrom,代码行数:25,代码来源:Node.java
示例8: free
import backtype.storm.scheduler.WorkerSlot; //导入依赖的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
示例9: assign
import backtype.storm.scheduler.WorkerSlot; //导入依赖的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
示例10: addTopology
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
@Override
public void addTopology(TopologyDetails td) {
String topId = td.getId();
LOG.debug("Adding in Topology {}", topId);
SchedulerAssignment assignment = _cluster.getAssignmentById(topId);
Set<Node> assignedNodes = new HashSet<Node>();
if (assignment != null) {
for (WorkerSlot ws : assignment.getSlots()) {
Node n = _nodeIdToNode.get(ws.getNodeId());
assignedNodes.add(n);
}
}
_usedNodes += assignedNodes.size();
_topologyIdToNodes.put(topId, assignedNodes);
_tds.put(topId, td);
if (td.getConf().get(Config.TOPOLOGY_ISOLATED_MACHINES) != null) {
_isolated.add(topId);
}
}
开发者ID:kkllwww007,项目名称:jstrom,代码行数:20,代码来源:IsolatedPool.java
示例11: findOffer
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
private OfferID findOffer(WorkerSlot worker) {
int port = worker.getPort();
ArrayList<Offer> offers = new ArrayList(_offers.values());
Collections.shuffle(offers);
for (Offer offer : offers) {
if (offer.getHostname().equals(worker.getNodeId())) {
for (Resource r : offer.getResourcesList()) {
if (r.getName().equals("ports")) {
for (Range range : r.getRanges().getRangeList()) {
if (port >= range.getBegin() && port <= range.getEnd()) {
return offer.getId();
}
}
}
}
}
}
return null;
}
开发者ID:deric,项目名称:storm-mesos,代码行数:20,代码来源:MesosNimbus.java
示例12: isOutTaskConnected
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
private boolean isOutTaskConnected(int taskId) {
boolean ret = false;
if (workerData.getInnerTaskTransfer().get(taskId) != null) {
// Connections to inner tasks should be done after initialization.
// So return true here for all inner tasks.
ret = true;
} else {
WorkerSlot slot = taskToNodePort.get(taskId);
if (slot != null) {
IConnection connection = nodePortToSocket.get(slot);
if (connection != null) {
ret = connection.available(taskId);
}
}
}
return ret;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:20,代码来源:RefreshConnections.java
示例13: isOutboundTaskAvailable
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
private boolean isOutboundTaskAvailable(int taskId) {
boolean ret = false;
DisruptorQueue targetQueue = workerData.getInnerTaskTransfer().get(taskId);
if (targetQueue != null) {
float queueLoadRatio = targetQueue.pctFull();
if (queueLoadRatio < loadMark) {
ret = true;
}
} else {
WorkerSlot slot = taskNodePort.get(taskId);
if (slot != null) {
IConnection connection = nodePortToSocket.get(slot);
if (connection != null) {
ret = connection.available(taskId);
}
}
}
if (!ret) {
LOG.debug("taskId:{} is unavailable", taskId);
}
return ret;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:26,代码来源:MkShuffer.java
示例14: assignInternal
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
boolean assignInternal(WorkerSlot ws, String topId, boolean dontThrow) {
validateSlot(ws);
if (!_freeSlots.remove(ws)) {
for (Entry<String, Set<WorkerSlot>> topologySetEntry : _topIdToUsedSlots.entrySet()) {
if (topologySetEntry.getValue().contains(ws)) {
if (dontThrow) {
LOG.warn("Worker slot [" + ws + "] can't be assigned to " + topId + ". Its already assigned to " + topologySetEntry.getKey() + ".");
return true;
}
throw new IllegalStateException("Worker slot [" + ws + "] can't be assigned to " + topId + ". Its already assigned to "
+ topologySetEntry.getKey() + ".");
}
}
LOG.warn("Adding Worker slot [" + ws + "] that was not reported in the supervisor heartbeats," + " but the worker is already running for topology "
+ topId + ".");
}
Set<WorkerSlot> usedSlots = _topIdToUsedSlots.get(topId);
if (usedSlots == null) {
usedSlots = new HashSet<>();
_topIdToUsedSlots.put(topId, usedSlots);
}
usedSlots.add(ws);
return false;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:25,代码来源:Node.java
示例15: free
import backtype.storm.scheduler.WorkerSlot; //导入依赖的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
示例16: assign
import backtype.storm.scheduler.WorkerSlot; //导入依赖的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
示例17: addTopology
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
@Override
public void addTopology(TopologyDetails td) {
String topId = td.getId();
LOG.debug("Adding in topology {}", topId);
SchedulerAssignment assignment = _cluster.getAssignmentById(topId);
Set<Node> assignedNodes = new HashSet<>();
if (assignment != null) {
for (WorkerSlot ws : assignment.getSlots()) {
Node n = _nodeIdToNode.get(ws.getNodeId());
assignedNodes.add(n);
}
}
_usedNodes += assignedNodes.size();
_topologyIdToNodes.put(topId, assignedNodes);
_tds.put(topId, td);
if (td.getConf().get(Config.TOPOLOGY_ISOLATED_MACHINES) != null) {
_isolated.add(topId);
}
}
开发者ID:alibaba,项目名称:jstorm,代码行数:20,代码来源:IsolatedPool.java
示例18: schedule
import backtype.storm.scheduler.WorkerSlot; //导入依赖的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
示例19: allSlotsAvailableForScheduling
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
@Override
public Collection<WorkerSlot> allSlotsAvailableForScheduling(
Collection<SupervisorDetails> existingSupervisors, Topologies topologies, Set<String> topologiesMissingAssignments) {
synchronized (_offersLock) {
return _mesosStormScheduler.allSlotsAvailableForScheduling(
_offers,
existingSupervisors,
topologies,
topologiesMissingAssignments);
}
}
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:12,代码来源:MesosNimbus.java
示例20: findOffer
import backtype.storm.scheduler.WorkerSlot; //导入依赖的package包/类
private OfferID findOffer(WorkerSlot worker) {
int port = worker.getPort();
for (Offer offer : _offers.values()) {
if (offer.getHostname().equals(worker.getNodeId())) {
List<Resource> r = getResourcesRange(offer.getResourcesList(), port, "ports");
if (r != null) return offer.getId();
}
}
// Still haven't found the slot? Maybe it's an offer we already used.
return null;
}
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:12,代码来源:MesosNimbus.java
注:本文中的backtype.storm.scheduler.WorkerSlot类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论