< prev index next >

src/com/sun/javatest/services/ServiceManager.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg


 273             }
 274         } catch (NotConnectedException ex) {
 275             String msg = "Service " + sID + " was not stopped because of" +
 276                     " connection failure\n";
 277             msg += ex.getMessage();
 278             commonLog.log(Level.WARNING, msg);
 279         } catch (ServiceError ex) {
 280             String msg = "Service " + sID + " was not stopped because of" +
 281                     " service error\n";
 282             msg += ex.getMessage();
 283             commonLog.log(Level.WARNING, msg);
 284         }
 285 
 286         return false;
 287     }
 288 
 289     public void startingTestRun(Parameters params) {
 290         if (mode == StartMode.UP_FRONT) {
 291             Set<String> active = new TreeSet<>();
 292             try {
 293                 Iterator iter = harness.getTestsIterator(null);
 294                 active = selectActiveServices(iter);
 295             } catch (Harness.Fault f) {
 296                 commonLog.log(Level.SEVERE, f.getMessage());
 297                 return;
 298             }
 299 
 300             for (String sID : active) {
 301                 startService(sID);
 302             }
 303         }
 304 
 305     }
 306 
 307     public synchronized void startingTest(TestResult tr) {
 308         if (mode == StartMode.LAZY) {
 309             try {
 310                 TestDescription td = tr.getDescription();
 311 
 312                 for (TestPath p : testServiceMap) {
 313                     if (p.matches(td)) {


 350         stopServices();
 351     }
 352 
 353     public void finishedTestRun(boolean allOK) {
 354         // Or is it better to stop services after all post-processing done?
 355     }
 356 
 357     public void error(String msg) {
 358         // Ignore test errors
 359     }
 360 
 361     /**
 362      * Set service's start mode.
 363      * @param mode one of supported
 364      * {@link com.sun.javatest.service.ServiceManager#StartMode} values.
 365      */
 366     public void setStartMode(StartMode mode) {
 367         this.mode = mode;
 368     }
 369 
 370     private Set<String> selectActiveServices(Iterator iter) {
 371         Set<String> active = new TreeSet<>();
 372         Set<TestPath> copy = new HashSet<>(testServiceMap);
 373         TestResult tr;
 374         TestDescription td;
 375         while (!copy.isEmpty() && active.size() < services.size() &&
 376                 (tr = (TestResult)iter.next()) != null ) {
 377             try {
 378                 td = tr.getDescription();
 379                 HashSet<TestPath> toRemove = new HashSet<>();
 380                 for (TestPath p : copy) {
 381                     if (p.matches(td)) {
 382                         for (String sId : p.getServices()) {
 383                             active.add(sId);
 384                         }
 385                         toRemove.add(p);
 386                     }
 387                 }
 388                 copy.removeAll(toRemove);
 389             } catch (Fault ex) {}
 390         }
 391         return active;
 392     }
 393 
 394     private synchronized void stopServices() {
 395         Set<String> toRemove = new TreeSet<>();
 396         for (String s : activeServices) {




 273             }
 274         } catch (NotConnectedException ex) {
 275             String msg = "Service " + sID + " was not stopped because of" +
 276                     " connection failure\n";
 277             msg += ex.getMessage();
 278             commonLog.log(Level.WARNING, msg);
 279         } catch (ServiceError ex) {
 280             String msg = "Service " + sID + " was not stopped because of" +
 281                     " service error\n";
 282             msg += ex.getMessage();
 283             commonLog.log(Level.WARNING, msg);
 284         }
 285 
 286         return false;
 287     }
 288 
 289     public void startingTestRun(Parameters params) {
 290         if (mode == StartMode.UP_FRONT) {
 291             Set<String> active = new TreeSet<>();
 292             try {
 293                 Iterator<TestResult> iter = harness.getTestsIterator(null);
 294                 active = selectActiveServices(iter);
 295             } catch (Harness.Fault f) {
 296                 commonLog.log(Level.SEVERE, f.getMessage());
 297                 return;
 298             }
 299 
 300             for (String sID : active) {
 301                 startService(sID);
 302             }
 303         }
 304 
 305     }
 306 
 307     public synchronized void startingTest(TestResult tr) {
 308         if (mode == StartMode.LAZY) {
 309             try {
 310                 TestDescription td = tr.getDescription();
 311 
 312                 for (TestPath p : testServiceMap) {
 313                     if (p.matches(td)) {


 350         stopServices();
 351     }
 352 
 353     public void finishedTestRun(boolean allOK) {
 354         // Or is it better to stop services after all post-processing done?
 355     }
 356 
 357     public void error(String msg) {
 358         // Ignore test errors
 359     }
 360 
 361     /**
 362      * Set service's start mode.
 363      * @param mode one of supported
 364      * {@link com.sun.javatest.service.ServiceManager#StartMode} values.
 365      */
 366     public void setStartMode(StartMode mode) {
 367         this.mode = mode;
 368     }
 369 
 370     private Set<String> selectActiveServices(Iterator<TestResult> iter) {
 371         Set<String> active = new TreeSet<>();
 372         Set<TestPath> copy = new HashSet<>(testServiceMap);
 373         TestResult tr;
 374         TestDescription td;
 375         while (!copy.isEmpty() && active.size() < services.size() &&
 376                 (tr = iter.next()) != null ) {
 377             try {
 378                 td = tr.getDescription();
 379                 HashSet<TestPath> toRemove = new HashSet<>();
 380                 for (TestPath p : copy) {
 381                     if (p.matches(td)) {
 382                         for (String sId : p.getServices()) {
 383                             active.add(sId);
 384                         }
 385                         toRemove.add(p);
 386                     }
 387                 }
 388                 copy.removeAll(toRemove);
 389             } catch (Fault ex) {}
 390         }
 391         return active;
 392     }
 393 
 394     private synchronized void stopServices() {
 395         Set<String> toRemove = new TreeSet<>();
 396         for (String s : activeServices) {


< prev index next >