Search in sources :

Example 1 with ShardingItemParameters

use of com.dangdang.ddframe.job.util.config.ShardingItemParameters in project elastic-job by dangdangdotcom.

the class ExecutionContextService method getJobShardingContext.

/**
     * 获取当前作业服务器分片上下文.
     * 
     * @param shardingItems 分片项
     * @return 分片上下文
     */
public ShardingContexts getJobShardingContext(final List<Integer> shardingItems) {
    LiteJobConfiguration liteJobConfig = configService.load(false);
    removeRunningIfMonitorExecution(liteJobConfig.isMonitorExecution(), shardingItems);
    if (shardingItems.isEmpty()) {
        return new ShardingContexts(buildTaskId(liteJobConfig, shardingItems), liteJobConfig.getJobName(), liteJobConfig.getTypeConfig().getCoreConfig().getShardingTotalCount(), liteJobConfig.getTypeConfig().getCoreConfig().getJobParameter(), Collections.<Integer, String>emptyMap());
    }
    Map<Integer, String> shardingItemParameterMap = new ShardingItemParameters(liteJobConfig.getTypeConfig().getCoreConfig().getShardingItemParameters()).getMap();
    return new ShardingContexts(buildTaskId(liteJobConfig, shardingItems), liteJobConfig.getJobName(), liteJobConfig.getTypeConfig().getCoreConfig().getShardingTotalCount(), liteJobConfig.getTypeConfig().getCoreConfig().getJobParameter(), getAssignedShardingItemParameterMap(shardingItems, shardingItemParameterMap));
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) ShardingItemParameters(com.dangdang.ddframe.job.util.config.ShardingItemParameters) ShardingContexts(com.dangdang.ddframe.job.executor.ShardingContexts)

Example 2 with ShardingItemParameters

use of com.dangdang.ddframe.job.util.config.ShardingItemParameters in project elastic-job by dangdangdotcom.

the class TaskLaunchScheduledService method getShardingContexts.

private ShardingContexts getShardingContexts(final TaskContext taskContext, final CloudAppConfiguration appConfig, final CloudJobConfiguration jobConfig) {
    Map<Integer, String> shardingItemParameters = new ShardingItemParameters(jobConfig.getTypeConfig().getCoreConfig().getShardingItemParameters()).getMap();
    Map<Integer, String> assignedShardingItemParameters = new HashMap<>(1, 1);
    int shardingItem = taskContext.getMetaInfo().getShardingItems().get(0);
    assignedShardingItemParameters.put(shardingItem, shardingItemParameters.containsKey(shardingItem) ? shardingItemParameters.get(shardingItem) : "");
    return new ShardingContexts(taskContext.getId(), jobConfig.getJobName(), jobConfig.getTypeConfig().getCoreConfig().getShardingTotalCount(), jobConfig.getTypeConfig().getCoreConfig().getJobParameter(), assignedShardingItemParameters, appConfig.getEventTraceSamplingCount());
}
Also used : HashMap(java.util.HashMap) ShardingItemParameters(com.dangdang.ddframe.job.util.config.ShardingItemParameters) ByteString(com.google.protobuf.ByteString) ShardingContexts(com.dangdang.ddframe.job.executor.ShardingContexts)

Aggregations

ShardingContexts (com.dangdang.ddframe.job.executor.ShardingContexts)2 ShardingItemParameters (com.dangdang.ddframe.job.util.config.ShardingItemParameters)2 LiteJobConfiguration (com.dangdang.ddframe.job.lite.config.LiteJobConfiguration)1 ByteString (com.google.protobuf.ByteString)1 HashMap (java.util.HashMap)1