public <T extends JobRunResult> int send(List<T> jobResults) {
        if (CollectionUtils.isEmpty(jobResults)) {
            return 0;
        }

        // 单个 就不用 分组了
        if (jobResults.size() == 1) {

            JobRunResult result = jobResults.get(0);
            if (!send0(result.getJobMeta().getJob().getSubmitNodeGroup(), Collections.singletonList(result))) {
                // 如果没有完成就返回
                clientNotifyHandler.handleFailed(jobResults);
                return 0;
            }
        } else if (jobResults.size() > 1) {

            List<JobRunResult> failedJobRunResult = new ArrayList<JobRunResult>();

            // 有多个要进行分组 (出现在 失败重发的时候)
            Map<String/*nodeGroup*/, List<JobRunResult>> groupMap = new HashMap<String, List<JobRunResult>>();

            for (T jobResult : jobResults) {
                List<JobRunResult> results = groupMap.get(jobResult.getJobMeta().getJob().getSubmitNodeGroup());
                if (results == null) {
                    results = new ArrayList<JobRunResult>();
                    groupMap.put(jobResult.getJobMeta().getJob().getSubmitNodeGroup(), results);
                }
                results.add(jobResult);
            }
            for (Map.Entry<String, List<JobRunResult>> entry : groupMap.entrySet()) {

                if (!send0(entry.getKey(), entry.getValue())) {
                    failedJobRunResult.addAll(entry.getValue());
                }
            }
            clientNotifyHandler.handleFailed(failedJobRunResult);
            return jobResults.size() - failedJobRunResult.size();
        }
        return jobResults.size();
    }
public < T extends JobRunResult > int send ( List < T > jobResults ) { if ( CollectionUtils . isEmpty ( jobResults ) ) { return 0 ; } if ( jobResults . size ( ) == 1 ) { JobRunResult result = jobResults . get ( 0 ) ; if ( ! send0 ( result . getJobMeta ( ) . getJob ( ) . getSubmitNodeGroup ( ) , Collections . singletonList ( result ) ) ) { clientNotifyHandler . handleFailed ( jobResults ) ; return 0 ; } } else if ( jobResults . size ( ) > 1 ) { List < JobRunResult > failedJobRunResult = new ArrayList < JobRunResult > ( ) ; Map < String , List < JobRunResult > > groupMap = new HashMap < String , List < JobRunResult > > ( ) ; for ( T jobResult : jobResults ) { List < JobRunResult > results = groupMap . get ( jobResult . getJobMeta ( ) . getJob ( ) . getSubmitNodeGroup ( ) ) ; if ( results == null ) { results = new ArrayList < JobRunResult > ( ) ; groupMap . put ( jobResult . getJobMeta ( ) . getJob ( ) . getSubmitNodeGroup ( ) , results ) ; } results . add ( jobResult ) ; } for ( Map . Entry < String , List < JobRunResult > > entry : groupMap . entrySet ( ) ) { if ( ! send0 ( entry . getKey ( ) , entry . getValue ( ) ) ) { failedJobRunResult . addAll ( entry . getValue ( ) ) ; } } clientNotifyHandler . handleFailed ( failedJobRunResult ) ; return jobResults . size ( ) - failedJobRunResult . size ( ) ; } return jobResults . size ( ) ; }
发送给客户端
@return 返回成功的个数