当前位置: 首页>>代码示例>>Java>>正文


Java InstanceDiedException类代码示例

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


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

示例1: getFreeSlotForTask

import org.apache.flink.runtime.instance.InstanceDiedException; //导入依赖的package包/类
/**
 * Gets a suitable instance to schedule the vertex execution to.
 * <p>
 * NOTE: This method does is not thread-safe, it needs to be synchronized by the caller.
 * 
 * @param vertex The task to run. 
 * @return The instance to run the vertex on, it {@code null}, if no instance is available.
 */
protected SimpleSlot getFreeSlotForTask(ExecutionVertex vertex,
										Iterable<TaskManagerLocation> requestedLocations,
										boolean localOnly) {
	// we need potentially to loop multiple times, because there may be false positives
	// in the set-with-available-instances
	while (true) {
		Pair<Instance, Locality> instanceLocalityPair = findInstance(requestedLocations, localOnly);

		if (instanceLocalityPair == null){
			return null;
		}

		Instance instanceToUse = instanceLocalityPair.getLeft();
		Locality locality = instanceLocalityPair.getRight();

		try {
			SimpleSlot slot = instanceToUse.allocateSimpleSlot();
			
			// if the instance has further available slots, re-add it to the set of available resources.
			if (instanceToUse.hasResourcesAvailable()) {
				this.instancesWithAvailableResources.put(instanceToUse.getTaskManagerID(), instanceToUse);
			}
			
			if (slot != null) {
				slot.setLocality(locality);
				return slot;
			}
		}
		catch (InstanceDiedException e) {
			// the instance died it has not yet been propagated to this scheduler
			// remove the instance from the set of available instances
			removeInstance(instanceToUse);
		}
		
		// if we failed to get a slot, fall through the loop
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:46,代码来源:Scheduler.java

示例2: getNewSlotForSharingGroup

import org.apache.flink.runtime.instance.InstanceDiedException; //导入依赖的package包/类
/**
 * Tries to allocate a new slot for a vertex that is part of a slot sharing group. If one
 * of the instances has a slot available, the method will allocate it as a shared slot, add that
 * shared slot to the sharing group, and allocate a simple slot from that shared slot.
 * 
 * <p>This method will try to allocate a slot from one of the local instances, and fall back to
 * non-local instances, if permitted.</p>
 * 
 * @param vertex The vertex to allocate the slot for.
 * @param requestedLocations The locations that are considered local. May be null or empty, if the
 *                           vertex has no location preferences.
 * @param groupAssignment The slot sharing group of the vertex. Mandatory parameter.
 * @param constraint The co-location constraint of the vertex. May be null.
 * @param localOnly Flag to indicate if non-local choices are acceptable.
 * 
 * @return A sub-slot for the given vertex, or {@code null}, if no slot is available.
 */
protected SimpleSlot getNewSlotForSharingGroup(ExecutionVertex vertex,
												Iterable<TaskManagerLocation> requestedLocations,
												SlotSharingGroupAssignment groupAssignment,
												CoLocationConstraint constraint,
												boolean localOnly)
{
	// we need potentially to loop multiple times, because there may be false positives
	// in the set-with-available-instances
	while (true) {
		Pair<Instance, Locality> instanceLocalityPair = findInstance(requestedLocations, localOnly);
		
		if (instanceLocalityPair == null) {
			// nothing is available
			return null;
		}

		final Instance instanceToUse = instanceLocalityPair.getLeft();
		final Locality locality = instanceLocalityPair.getRight();

		try {
			JobVertexID groupID = vertex.getJobvertexId();
			
			// allocate a shared slot from the instance
			SharedSlot sharedSlot = instanceToUse.allocateSharedSlot(groupAssignment);

			// if the instance has further available slots, re-add it to the set of available resources.
			if (instanceToUse.hasResourcesAvailable()) {
				this.instancesWithAvailableResources.put(instanceToUse.getTaskManagerID(), instanceToUse);
			}

			if (sharedSlot != null) {
				// add the shared slot to the assignment group and allocate a sub-slot
				SimpleSlot slot = constraint == null ?
						groupAssignment.addSharedSlotAndAllocateSubSlot(sharedSlot, locality, groupID) :
						groupAssignment.addSharedSlotAndAllocateSubSlot(sharedSlot, locality, constraint);

				if (slot != null) {
					return slot;
				}
				else {
					// could not add and allocate the sub-slot, so release shared slot
					sharedSlot.releaseSlot(new FlinkException("Could not allocate sub-slot."));
				}
			}
		}
		catch (InstanceDiedException e) {
			// the instance died it has not yet been propagated to this scheduler
			// remove the instance from the set of available instances
			removeInstance(instanceToUse);
		}

		// if we failed to get a slot, fall through the loop
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:72,代码来源:Scheduler.java

示例3: handleNewSlot

import org.apache.flink.runtime.instance.InstanceDiedException; //导入依赖的package包/类
private void handleNewSlot() {
	
	synchronized (globalLock) {
		Instance instance = this.newlyAvailableInstances.poll();
		if (instance == null || !instance.hasResourcesAvailable()) {
			// someone else took it
			return;
		}
		
		QueuedTask queued = taskQueue.peek();
		
		// the slot was properly released, we can allocate a new one from that instance
		
		if (queued != null) {
			ScheduledUnit task = queued.getTask();
			ExecutionVertex vertex = task.getTaskToExecute().getVertex();
			
			try {
				SimpleSlot newSlot = instance.allocateSimpleSlot();
				if (newSlot != null) {
					
					// success, remove from the task queue and notify the future
					taskQueue.poll();
					if (queued.getFuture() != null) {
						try {
							queued.getFuture().complete(newSlot);
						}
						catch (Throwable t) {
							LOG.error("Error calling allocation future for task " + vertex.getTaskNameWithSubtaskIndex(), t);
							task.getTaskToExecute().fail(t);
						}
					}
				}
			}
			catch (InstanceDiedException e) {
				if (LOG.isDebugEnabled()) {
					LOG.debug("Instance " + instance + " was marked dead asynchronously.");
				}
				
				removeInstance(instance);
			}
		}
		else {
			this.instancesWithAvailableResources.put(instance.getTaskManagerID(), instance);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:48,代码来源:Scheduler.java


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