26 |
|
|
27 |
private TaskLogger logger = TaskLogger.getInstance(); |
private TaskLogger logger = TaskLogger.getInstance(); |
28 |
|
|
29 |
final boolean verbose = false;// |
final static boolean VERBOSE = false;// |
30 |
|
|
31 |
|
|
32 |
static boolean test_mode; |
static boolean test_mode; |
41 |
|
|
42 |
ThreadPoolExecutor threadPool; |
ThreadPoolExecutor threadPool; |
43 |
|
|
44 |
|
boolean isIncremental; |
45 |
|
|
46 |
|
|
47 |
public AfstandAndenRuteTask(String distributor) { |
public AfstandAndenRuteTask(String distributor, String type) { |
48 |
this.distributor = distributor; |
this.distributor = distributor; |
49 |
|
|
50 |
|
type = type.toUpperCase(); |
51 |
|
switch(type) { |
52 |
|
case "FULL": |
53 |
|
isIncremental = false; |
54 |
|
break; |
55 |
|
case "INCREMENTAL": |
56 |
|
isIncremental = true; |
57 |
|
break; |
58 |
|
default: |
59 |
|
throw new RuntimeException("Unknown type" + type); |
60 |
|
} |
61 |
} |
} |
62 |
|
|
63 |
|
|
64 |
@Override |
@Override |
65 |
protected void taskRun() throws Exception { |
protected void taskRun() throws Exception { |
66 |
|
|
|
|
|
|
|
|
|
|
|
|
//Setup j.u.l Logger |
|
|
//Logger root = Logger.getLogger(""); |
|
|
//FileHandler fhandler = new FileHandler("fulddaekning.log"); // Ingen max størrelse, ingen rotation og ingen append |
|
|
//fhandler.setFormatter( new SimpleFormatter() ); |
|
|
//root.addHandler( fhandler ); |
|
|
|
|
|
|
|
67 |
|
|
68 |
Constants.init(distributor); |
Constants.init(distributor); |
69 |
Constants consts = Constants.getInstance(); |
Constants consts = Constants.getInstance(); |
82 |
} |
} |
83 |
logger.info("Starting with MAX_WORKERS:" + max_workers); |
logger.info("Starting with MAX_WORKERS:" + max_workers); |
84 |
setupThreadPool(max_workers); |
setupThreadPool(max_workers); |
85 |
|
|
86 |
|
logger.info("Starting with INCREMENTAL:" + isIncremental); |
87 |
|
|
88 |
|
|
89 |
|
|
90 |
try (Connection conn = DBConnection.getConnection() ) { |
try (Connection conn = DBConnection.getConnection() ) { |
91 |
Database db = new Database(conn); |
DatabaseRouteDistance db = new DatabaseRouteDistance(conn, isIncremental); |
92 |
|
|
93 |
|
db.prepareIncrementalSearch(); |
94 |
|
|
95 |
Queue<Address> ikkeDaekkede = db.hentAlleIkkedaekkedeAdresser(consts.getMinPostnr(), consts.getMaxPostnr() ); |
Queue<Address> ikkeDaekkede = db.hentAlleIkkedaekkedeAdresser(consts.getMinPostnr(), consts.getMaxPostnr() ); |
96 |
antalIkkeDaekkede = ikkeDaekkede.size(); |
antalIkkeDaekkede = ikkeDaekkede.size(); |
152 |
CyclicBarrier barrier = new CyclicBarrier(max_workers + 1); |
CyclicBarrier barrier = new CyclicBarrier(max_workers + 1); |
153 |
|
|
154 |
for (int i=0; i<max_workers; i++) { |
for (int i=0; i<max_workers; i++) { |
155 |
LookupWorker worker = new LookupWorker(i, this, barrier, ikkeDaekkede, hoTrees,antalFundne,antalBeregnet,db,verbose,consts); |
LookupWorker worker = new LookupWorker(i, this, barrier, ikkeDaekkede, hoTrees,antalFundne,antalBeregnet,db,VERBOSE,consts); |
156 |
threadPool.submit( worker ); |
threadPool.submit( worker ); |
157 |
} |
} |
158 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
} else { |
} /*else { |
181 |
/// Test |
/// Test |
182 |
/* |
|
183 |
db.resetResultTable(); |
db.resetResultTable(); |
184 |
|
|
185 |
|
|
188 |
|
|
189 |
short post = (short) 2700; |
short post = (short) 2700; |
190 |
Lookup lookup = new Lookup(post, db, threadPool); |
Lookup lookup = new Lookup(post, db, threadPool); |
191 |
lookup.doLookup();*/ |
lookup.doLookup(); |
192 |
} |
} */ |
193 |
|
|
194 |
|
|
195 |
long now = System.currentTimeMillis(); |
long now = System.currentTimeMillis(); |
204 |
logger.info("Heraf, antal fundne : " + antalFundne ); |
logger.info("Heraf, antal fundne : " + antalFundne ); |
205 |
|
|
206 |
logger.info( String.format("Fandt adresser til : %.2f %%", (antalFundne.get() *100.0)/antalIkkeDaekkede ) ); |
logger.info( String.format("Fandt adresser til : %.2f %%", (antalFundne.get() *100.0)/antalIkkeDaekkede ) ); |
|
//logger.info("Fandt adresser til : " + (antalFundne*100.0)/ikkeDaekkede.length + "%" ); |
|
|
|
|
207 |
} |
} |
208 |
} |
} |
209 |
|
|
245 |
|
|
246 |
@Override |
@Override |
247 |
public String getDetail() { |
public String getDetail() { |
248 |
// TODO Auto-generated method stub |
if (isIncremental) { |
249 |
return ""; |
return "Type: incremental"; |
250 |
|
} else { |
251 |
|
return "Type: full"; |
252 |
|
} |
253 |
} |
} |
254 |
|
|
255 |
|
|