]> source.dussan.org Git - sonarqube.git/commitdiff
Cleanup and deprecate Decorator related stuff 511/head
authorJulien HENRY <julien.henry@sonarsource.com>
Wed, 16 Sep 2015 14:43:25 +0000 (16:43 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 17 Sep 2015 07:48:22 +0000 (09:48 +0200)
sonar-batch/src/main/java/org/sonar/batch/phases/PhasesTimeProfiler.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/PostJob.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/events/DecoratorExecutionHandler.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/events/DecoratorsPhaseHandler.java

index 32c2538ab10b4ecaa45e54ba6c6f7572cff4593d..87f2f9e2eea938ff846ad945498156bf1e2ea0c4 100644 (file)
  */
 package org.sonar.batch.phases;
 
-import com.google.common.collect.Lists;
 import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.SystemUtils;
-import org.sonar.api.batch.Decorator;
-import org.sonar.api.batch.events.DecoratorExecutionHandler;
-import org.sonar.api.batch.events.DecoratorsPhaseHandler;
 import org.sonar.api.batch.events.SensorExecutionHandler;
 import org.sonar.api.batch.events.SensorsPhaseHandler;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.api.utils.log.Profiler;
 
-import java.util.IdentityHashMap;
-import java.util.List;
-import java.util.Map;
-
-public class PhasesTimeProfiler implements SensorExecutionHandler, DecoratorExecutionHandler, DecoratorsPhaseHandler, SensorsPhaseHandler {
+public class PhasesTimeProfiler implements SensorExecutionHandler, SensorsPhaseHandler {
 
   private static final Logger LOG = Loggers.get(PhasesTimeProfiler.class);
 
   private Profiler profiler = Profiler.create(LOG);
-  private DecoratorsProfiler decoratorsProfiler = new DecoratorsProfiler();
 
   @Override
   public void onSensorsPhase(SensorsPhaseEvent event) {
@@ -58,64 +48,4 @@ public class PhasesTimeProfiler implements SensorExecutionHandler, DecoratorExec
     }
   }
 
-  @Override
-  public void onDecoratorExecution(DecoratorExecutionEvent event) {
-    if (event.isStart()) {
-      decoratorsProfiler.start(event.getDecorator());
-    } else {
-      decoratorsProfiler.stop();
-    }
-  }
-
-  @Override
-  public void onDecoratorsPhase(DecoratorsPhaseEvent event) {
-    if (event.isStart()) {
-      LOG.info("Execute decorators...");
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Decorators: {}", StringUtils.join(event.getDecorators(), " -> "));
-      }
-    } else {
-      decoratorsProfiler.log();
-    }
-  }
-
-  static class DecoratorsProfiler {
-    List<Decorator> decorators = Lists.newArrayList();
-    Map<Decorator, Long> durations = new IdentityHashMap<>();
-    long startTime;
-    Decorator currentDecorator;
-
-    DecoratorsProfiler() {
-    }
-
-    void start(Decorator decorator) {
-      this.startTime = System.currentTimeMillis();
-      this.currentDecorator = decorator;
-    }
-
-    void stop() {
-      final Long cumulatedDuration;
-      if (durations.containsKey(currentDecorator)) {
-        cumulatedDuration = durations.get(currentDecorator);
-      } else {
-        decorators.add(currentDecorator);
-        cumulatedDuration = 0L;
-      }
-      durations.put(currentDecorator, cumulatedDuration + (System.currentTimeMillis() - startTime));
-    }
-
-    void log() {
-      LOG.debug(getMessage());
-    }
-
-    String getMessage() {
-      StringBuilder sb = new StringBuilder("Decorator time:").append(SystemUtils.LINE_SEPARATOR);
-      for (Decorator decorator : decorators) {
-        sb.append("\t").append(decorator.toString()).append(": ").append(durations.get(decorator)).append("ms")
-            .append(SystemUtils.LINE_SEPARATOR);
-      }
-      return sb.toString();
-    }
-  }
-
 }
index 6c468813437df45b3bc915c43e170b8a10d97985..2b8a2f6242af456868b64caf6438daf10aba6a6e 100644 (file)
@@ -25,8 +25,8 @@ import org.sonar.api.resources.Project;
 /**
  * PostJobs are executed at the very end of batch analysis. A PostJob can't do any modification
  * since everything is already computed (issues, measures,...). <br/>
- * WANRING: Do not rely on the fact that analysis results are available on server side. Even if it is true
- * for now (synchronous storage) it will become an asynchronous processing on server side in 5.x series.
+ * WANRING: Do not rely on the fact that analysis results are available on server side. Starting from 5.x
+ * it is an asynchronous processing on server side.
  *
  * @since 1.10
  */
index e9bd02b85f45920673db50fefb15f3dfccb4d96e..b9799689ac1f0f8b05291b8b683d861eeb41bc8b 100644 (file)
@@ -23,7 +23,9 @@ import org.sonar.api.batch.Decorator;
 
 /**
  * @since 2.8
+ * @deprecated since 5.2 no more decorator
  */
+@Deprecated
 public interface DecoratorExecutionHandler extends EventHandler {
 
   /**
index 12ff4172dc0daa2c17fbc28ce2fad76980e9e70a..85f946691e473490c522c23e990f9af1c98ccbb5 100644 (file)
  */
 package org.sonar.api.batch.events;
 
-import org.sonar.api.batch.Decorator;
-
 import java.util.List;
+import org.sonar.api.batch.Decorator;
 
 /**
  * @since 2.8
+ * @deprecated since 5.2 no more decorator
  */
+@Deprecated
 public interface DecoratorsPhaseHandler extends EventHandler {
 
   /**