45 |
|
|
46 |
ExecutorService threadPool; |
ExecutorService threadPool; |
47 |
|
|
48 |
boolean isIncremental; |
final boolean isIncremental; |
49 |
|
final int max_workers; |
50 |
|
|
51 |
|
|
52 |
public AfstandAndenRuteTask(String distributor, String type) { |
public AfstandAndenRuteTask(String distributor, String type) { |
63 |
default: |
default: |
64 |
throw new RuntimeException("Unknown type" + type); |
throw new RuntimeException("Unknown type" + type); |
65 |
} |
} |
66 |
|
|
67 |
|
int tmp_max_workers = ServiceConfig.getInstance().maxWorkers; |
68 |
|
if (tmp_max_workers <= 0) { |
69 |
|
logger.info("!!! AUTO-DETECT MAX_WORKERS !!!"); |
70 |
|
int cores = Runtime.getRuntime().availableProcessors(); |
71 |
|
cores -= 1;//Efterlad 1 core/cpu i reserve til systemet |
72 |
|
|
73 |
|
tmp_max_workers = Math.max(1, cores); //Dog skal der som minimum være 1 core til beregning |
74 |
|
|
75 |
|
} |
76 |
|
if (test_mode) { |
77 |
|
tmp_max_workers = 1; |
78 |
|
} |
79 |
|
|
80 |
|
max_workers = tmp_max_workers; |
81 |
} |
} |
82 |
|
|
83 |
|
|
88 |
Constants.init(distributor); |
Constants.init(distributor); |
89 |
Constants consts = Constants.getInstance(); |
Constants consts = Constants.getInstance(); |
90 |
|
|
91 |
int max_workers = ServiceConfig.getInstance().maxWorkers; |
|
|
if (max_workers <= 0) { |
|
|
logger.info("!!! AUTO-DETECT MAX_WORKERS !!!"); |
|
|
int cores = Runtime.getRuntime().availableProcessors(); |
|
|
cores -= 1;//Efterlad 1 core/cpu i reserve til systemet |
|
|
|
|
|
max_workers = Math.max(1, cores); //Dog skal der som minimum være 1 core til beregning |
|
|
|
|
|
} |
|
|
if (test_mode) { |
|
|
max_workers = 1; |
|
|
} |
|
92 |
logger.info("Starting with MAX_WORKERS:" + max_workers); |
logger.info("Starting with MAX_WORKERS:" + max_workers); |
93 |
|
|
94 |
threadPool = Executors.newFixedThreadPool(max_workers, new WorkerThreadFactory() ); |
threadPool = Executors.newFixedThreadPool(max_workers, new WorkerThreadFactory() ); |
111 |
|
|
112 |
logger.info("======================================================================"); |
logger.info("======================================================================"); |
113 |
|
|
114 |
mainRun(consts, isIncremental, "ruteMa", max_workers, antalFundne, antalDaekkedeAdresser); |
mainRun(consts, isIncremental, "ruteMa", antalFundne, antalDaekkedeAdresser); |
115 |
|
|
116 |
logger.info("======================================================================"); |
logger.info("======================================================================"); |
117 |
|
|
118 |
mainRun(consts, true, "ruteLo", max_workers, antalFundne, antalDaekkedeAdresser); |
mainRun(consts, true, "ruteLo", antalFundne, antalDaekkedeAdresser); |
119 |
|
|
120 |
logger.info("======================================================================"); |
logger.info("======================================================================"); |
121 |
|
|
122 |
mainRun(consts, true, "ruteSo", max_workers, antalFundne, antalDaekkedeAdresser); |
mainRun(consts, true, "ruteSo", antalFundne, antalDaekkedeAdresser); |
123 |
|
|
124 |
logger.info("======================================================================"); |
logger.info("======================================================================"); |
125 |
|
|
146 |
} |
} |
147 |
|
|
148 |
|
|
149 |
private void mainRun(Constants consts, boolean localIsIncremental, String ugedag, int max_workers, AtomicInteger antalFundne, AtomicInteger antalDaekkedeAdresser) throws Exception { |
private void mainRun(Constants consts, boolean localIsIncremental, String ugedag, AtomicInteger antalFundne, AtomicInteger antalDaekkedeAdresser) throws Exception { |
150 |
|
|
151 |
logger.info("MainRun() isIncremental=" + localIsIncremental + " ugedag=" + ugedag); |
logger.info("MainRun() isIncremental=" + localIsIncremental + " ugedag=" + ugedag); |
152 |
|
|