package org.radargun.service;

import java.util.concurrent.ExecutionException;

import org.radargun.traits.Clustered;

public class Infinispan110ServerLifecycle extends Infinispan100ServerLifecycle {

   public Infinispan110ServerLifecycle(InfinispanServerService service) {
      super(service);
   }

   @Override
   protected void stopInternal() {
      Clustered clustered = this.service.getClustered();
      if (clustered == null) {
         throw new NullPointerException("clustered cannot be null");
      }
      if (clustered instanceof Infinispan100ServerClustered) {
         Infinispan100ServerClustered innerClustered = (Infinispan100ServerClustered) clustered;
         innerClustered.getRestAPI().stopCluster(service.stopTimeout);
         // the stop request return as fast as possible
         long now = System.currentTimeMillis();
         while (System.currentTimeMillis() - now < service.stopTimeout) {
            try {
               Thread.sleep(1000);
               try {
                  innerClustered.getRestAPI().info();
               } catch (ExecutionException e) {
                  // we should kill the inherited process
                  super.stopInternal();
                  break;
               }
            } catch (InterruptedException e) {
               throw new IllegalStateException("InterruptedException", e);
            }
         }
         // if the server still alive, fail
         if (this.service.getLifecycle().isRunning()) {
            throw new IllegalStateException("Error while stopping the server. The server is still running");
         }
      } else {
         throw new IllegalStateException("service.clustered should extends Infinispan100ServerClustered");
      }
   }
}

@@ -28,96 +28,8 @@
 e;%0A%0A
-import java.util.concurrent.ExecutionException;%0A%0Aimport org.radargun.traits.Clustered;%0A%0A
 publ
@@ -212,1446 +212,6 @@
  %7D%0A%0A
-   @Override%0A   protected void stopInternal() %7B%0A      Clustered clustered = this.service.getClustered();%0A      if (clustered == null) %7B%0A         throw new NullPointerException(%22clustered cannot be null%22);%0A      %7D%0A      if (clustered instanceof Infinispan100ServerClustered) %7B%0A         Infinispan100ServerClustered innerClustered = (Infinispan100ServerClustered) clustered;%0A         innerClustered.getRestAPI().stopCluster(service.stopTimeout);%0A         // the stop request return as fast as possible%0A         long now = System.currentTimeMillis();%0A         while (System.currentTimeMillis() - now %3C service.stopTimeout) %7B%0A            try %7B%0A               Thread.sleep(1000);%0A               try %7B%0A                  innerClustered.getRestAPI().info();%0A               %7D catch (ExecutionException e) %7B%0A                  // we should kill the inherited process%0A                  super.stopInternal();%0A                  break;%0A               %7D%0A            %7D catch (InterruptedException e) %7B%0A               throw new IllegalStateException(%22InterruptedException%22, e);%0A            %7D%0A         %7D%0A         // if the server still alive, fail%0A         if (this.service.getLifecycle().isRunning()) %7B%0A            throw new IllegalStateException(%22Error while stopping the server. The server is still running%22);%0A         %7D%0A      %7D else %7B%0A         throw new IllegalStateException(%22service.clustered should extends Infinispan100ServerClustered%22);%0A      %7D%0A   %7D%0A
 %7D%0A

Remove stopping Infinispan by Rest API