34 |
static ThreadPoolExecutor threadPool; |
static ThreadPoolExecutor threadPool; |
35 |
|
|
36 |
private static void setupThreadPool() { |
private static void setupThreadPool() { |
37 |
threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(max_workers, new ThreadFactory() { |
threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(max_workers, new WorkerThreadFactory() ); |
|
@Override |
|
|
public Thread newThread(Runnable r) { |
|
|
return new Thread(r, "lookupWorker"); |
|
|
} |
|
|
}); |
|
38 |
} |
} |
39 |
|
|
40 |
|
|
85 |
Constants consts = Constants.getInstance(); |
Constants consts = Constants.getInstance(); |
86 |
|
|
87 |
Database db = new Database(conf); |
Database db = new Database(conf); |
|
|
|
|
|
|
88 |
|
|
89 |
|
|
90 |
boolean testRun= false; |
boolean testRun= false; |
104 |
bbox.validateBbox(); |
bbox.validateBbox(); |
105 |
} |
} |
106 |
|
|
107 |
if (consts.doExtendedLookup()) { |
|
108 |
logger.info("Henter alle daekkede adresser"); |
logger.info("Henter alle daekkede adresser"); |
109 |
alleDaekkedeAdresser = db.hentAlleDaekkedeAdresser(); |
alleDaekkedeAdresser = db.hentAlleDaekkedeAdresser(); |
110 |
logger.info( "AlleDaekkedeAdresser.length=" + alleDaekkedeAdresser.length); |
logger.info( "AlleDaekkedeAdresser.length=" + alleDaekkedeAdresser.length); |
|
} |
|
|
|
|
111 |
|
|
112 |
//pre-check er ok - reset tmp tabel og start søgningen |
//pre-check er ok - reset tmp tabel og start søgningen |
113 |
db.resetResultTable(); |
db.resetResultTable(); |
137 |
Lookup lookup = new Lookup("458x", db, threadPool); |
Lookup lookup = new Lookup("458x", db, threadPool); |
138 |
lookup.doLookup(); |
lookup.doLookup(); |
139 |
} |
} |
140 |
|
|
141 |
|
threadPool.shutdown(); |
142 |
|
|
143 |
long now = System.currentTimeMillis(); |
long now = System.currentTimeMillis(); |
144 |
long elapsed = now - start ; |
long elapsed = now - start ; |
175 |
int hours = (int) ((milliseconds / (1000*60*60)) % 24); |
int hours = (int) ((milliseconds / (1000*60*60)) % 24); |
176 |
|
|
177 |
return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, mseconds); |
return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, mseconds); |
178 |
} |
} |
179 |
|
|
180 |
|
static class WorkerThreadFactory implements ThreadFactory { |
181 |
|
int count = 0; |
182 |
|
|
183 |
|
@Override |
184 |
|
public Thread newThread(Runnable r) { |
185 |
|
return new Thread(r, "lookupWorker/" + count++); |
186 |
|
} |
187 |
|
} |
188 |
} |
} |