/[projects]/dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/LookupMain.java
ViewVC logotype

Diff of /dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/LookupMain.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2244 by torben, Wed Dec 10 10:06:32 2014 UTC revision 2260 by torben, Mon Feb 9 14:00:53 2015 UTC
# Line 6  import java.util.List; Line 6  import java.util.List;
6  import java.util.logging.FileHandler;  import java.util.logging.FileHandler;
7  import java.util.logging.Logger;  import java.util.logging.Logger;
8  import java.util.logging.SimpleFormatter;  import java.util.logging.SimpleFormatter;
9    import java.util.concurrent.*;
10    
11  public class LookupMain {  public class LookupMain {
12    
# Line 29  public class LookupMain { Line 30  public class LookupMain {
30          static Statistik stoersteDataset = new Statistik();          static Statistik stoersteDataset = new Statistik();
31                    
32          static Adresse[] alleDaekkedeAdresser;          static Adresse[] alleDaekkedeAdresser;
33    
34            static ThreadPoolExecutor threadPool;
35    
36            private static void setupThreadPool() {
37                    threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(max_workers, new WorkerThreadFactory() );
38            }
39                    
40                    
41          public static void main(String[] args) throws Exception {          public static void main(String[] args) throws Exception {
# Line 61  public class LookupMain { Line 68  public class LookupMain {
68                                                    
69                  }                  }
70                  logger.info("Starting with MAX_WORKERS:" + max_workers);                  logger.info("Starting with MAX_WORKERS:" + max_workers);
71                    setupThreadPool();
72                                    
73                                    
74                  verbose = Boolean.parseBoolean( conf.getSafeProperty("VERBOSE") );                  verbose = Boolean.parseBoolean( conf.getSafeProperty("VERBOSE") );
# Line 109  public class LookupMain { Line 117  public class LookupMain {
117                          db.resetResultTable();                          db.resetResultTable();
118                                                    
119                          for(String postnr : postnumre) {                          for(String postnr : postnumre) {
120                                  Lookup lookup = new Lookup(postnr, db);                                  Lookup lookup = new Lookup(postnr, db, threadPool);
121                                  lookup.doLookup();                                                        lookup.doLookup();                      
122                          }                          }
123                                                    
# Line 130  public class LookupMain { Line 138  public class LookupMain {
138                                  logger.info( "AlleDaekkedeAdresser.length=" + alleDaekkedeAdresser.length);                                  logger.info( "AlleDaekkedeAdresser.length=" + alleDaekkedeAdresser.length);
139                          }                          }
140                                                    
141                          Lookup lookup = new Lookup("458x", db);                          Lookup lookup = new Lookup("458x", db, threadPool);
142                          lookup.doLookup();                                                                                        lookup.doLookup();                                                              
143                  }                  }
144    
145                    threadPool.shutdown();
146                                    
147                  long now = System.currentTimeMillis();                  long now = System.currentTimeMillis();
148                  long elapsed = now - start ;                  long elapsed = now - start ;
# Line 169  public class LookupMain { Line 179  public class LookupMain {
179                  int hours   = (int) ((milliseconds / (1000*60*60)) % 24);                  int hours   = (int) ((milliseconds / (1000*60*60)) % 24);
180                                    
181                  return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, mseconds);                  return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, mseconds);
182          }                }
183            
184            static class WorkerThreadFactory implements ThreadFactory {
185                    int count = 0;
186    
187                    @Override
188                    public Thread newThread(Runnable r) {
189                            return new Thread(r, "lookupWorker/" + count++);
190                    }      
191            }
192  }  }

Legend:
Removed from v.2244  
changed lines
  Added in v.2260

  ViewVC Help
Powered by ViewVC 1.1.20