java list pair_Java Pair.getSecond方法代码示例

import azkaban.utils.Pair; //导入方法依赖的package包/类

private void processQueuedFlows(long activeExecutorsRefreshWindow,

int maxContinuousFlowProcessed) throws InterruptedException,

ExecutorManagerException {

long lastExecutorRefreshTime = 0;

Pair runningCandidate;

int currentContinuousFlowProcessed = 0;

while (isActive() && (runningCandidate = queuedFlows.fetchHead()) != null) {

ExecutionReference reference = runningCandidate.getFirst();

ExecutableFlow exflow = runningCandidate.getSecond();

long currentTime = System.currentTimeMillis();

// if we have dispatched more than maxContinuousFlowProcessed or

// It has been more then activeExecutorsRefreshWindow millisec since we

// refreshed

if (currentTime - lastExecutorRefreshTime > activeExecutorsRefreshWindow

|| currentContinuousFlowProcessed >= maxContinuousFlowProcessed) {

// Refresh executorInfo for all activeExecutors

refreshExecutors();

lastExecutorRefreshTime = currentTime;

currentContinuousFlowProcessed = 0;

}

/**

*

 
 

* TODO: Work around till we improve Filters to have a notion of GlobalSystemState.

* Currently we try each queued flow once to infer a global busy state

* Possible improvements:-

* 1. Move system level filters in refreshExecutors and sleep if we have all executors busy after refresh

* 2. Implement GlobalSystemState in selector or in a third place to manage system filters. Basically

* taking out all the filters which do not depend on the flow but are still being part of Selector.

* Assumptions:-

* 1. no one else except QueueProcessor is updating ExecutableFlow update time

* 2. re-attempting a flow (which has been tried before) is considered as all executors are busy

*

*/

if (exflow.getUpdateTime() > lastExecutorRefreshTime) {

// put back in the queue

queuedFlows.enqueue(exflow, reference);

long sleepInterval =

activeExecutorsRefreshWindow

- (currentTime - lastExecutorRefreshTime);

// wait till next executor refresh

sleep(sleepInterval);

} else if (getRunningFlowConcurrentWithUser(userManager.getUser(exflow.getSubmitUser()), exflow) ) {

//判断当前flow的并发量,若超过设定的并发量,进排队队列

exflow.setUpdateTime(currentTime);

queuedFlows.enqueue(exflow, reference);

} else {

exflow.setUpdateTime(currentTime);

// process flow with current snapshot of activeExecutors

selectExecutorAndDispatchFlow(reference, exflow, new HashSet(activeExecutors));

}

// do not count failed flow processsing (flows still in queue)

if (queuedFlows.getFlow(exflow.getExecutionId()) == null) {

currentContinuousFlowProcessed++;

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值