private void updateAgent() {

    // We need to write the agent to the db,
    // We'll potentially need to retry due to possible database locking
    // so we use the JPAAgentUpdater that already knows
    // how to do this
    try {
      // initial agent parameters
      final TestJobAgentWorker lAgent = mAgentProvider.get();

      LOGGER.info("Successfully retrieved agent " + lAgent);

      if (lAgent.getProcessID() != null) {
        LOGGER.info(
            "Process succsesfully retrieved "
                + lAgent.getProcessID()
                + ". Stopping agent update thread");

        mAgentUpdateThread.interrupt();
        return;
      }

      LOGGER.info("PID not yet set, retrieving and updating");
      configureAgentInitialParameters(lAgent);
      LOGGER.info("Updating agent");

      mAgentUpdater.write(lAgent);
    } catch (Exception e) {
      LOGGER.error("Couldn't write the agent", e);
    }
  }
  static {
    if (NONPROXY_HOSTS.length() > 0) {
      StringTokenizer s = new StringTokenizer(NONPROXY_HOSTS, "|"); // $NON-NLS-1$
      while (s.hasMoreTokens()) {
        String t = s.nextToken();
        if (t.indexOf('*') == 0) { // e.g. *.apache.org // $NON-NLS-1$
          nonProxyHostSuffix.add(t.substring(1));
        } else {
          nonProxyHostFull.add(t); // e.g. www.apache.org
        }
      }
    }
    nonProxyHostSuffixSize = nonProxyHostSuffix.size();

    InetAddress inet = null;
    String localHostOrIP = JMeterUtils.getPropDefault("httpclient.localaddress", ""); // $NON-NLS-1$
    if (localHostOrIP.length() > 0) {
      try {
        inet = InetAddress.getByName(localHostOrIP);
        log.info("Using localAddress " + inet.getHostAddress());
      } catch (UnknownHostException e) {
        log.warn(e.getLocalizedMessage());
      }
    } else {
      // Get hostname
      localHostOrIP = JMeterUtils.getLocalHostName();
    }
    localAddress = inet;
    localHost = localHostOrIP;
    log.info("Local host = " + localHost);
  }
 @Override
 public void rstopTest(boolean now) throws RemoteException {
   if (now) {
     log.info("Stopping test ...");
   } else {
     log.info("Shutting test ...");
   }
   backingEngine.stopTest(now);
   log.info("... stopped");
 }
 public SampleResult runTest(JavaSamplerContext arg0) {
   log.info("<<<发送地址:" + conf.getBaseUri() + conf.getApiUri());
   log.info("<<<发送数据:" + sb.toString());
   try {
     HttpSend.doPost(conf, headMsg, sb.toString(), log);
   } catch (Exception e) {
     log.info("ERROR...", e);
   }
   results.setSuccessful(true);
   return results;
 }
 private void init() throws RemoteException {
   log.info("Starting backing engine on " + this.rmiPort);
   InetAddress localHost = null;
   // Bug 47980 - allow override of local hostname
   String host = System.getProperties().getProperty("java.rmi.server.hostname"); // $NON-NLS-1$
   try {
     if (host == null) {
       localHost = InetAddress.getLocalHost();
     } else {
       localHost = InetAddress.getByName(host);
     }
   } catch (UnknownHostException e1) {
     throw new RemoteException("Cannot start. Unable to get local host IP address.", e1);
   }
   log.info("IP address=" + localHost.getHostAddress());
   String hostName = localHost.getHostName();
   // BUG 52469 : Allow loopback address for SSH Tunneling of RMI traffic
   if (localHost.isLoopbackAddress() && host == null) {
     throw new RemoteException("Cannot start. " + hostName + " is a loopback address.");
   }
   if (localHost.isSiteLocalAddress()) {
     // should perhaps be log.warn, but this causes the client-server test to fail
     log.info(
         "IP address is a site-local address; this may cause problems with remote access.\n"
             + "\tCan be overridden by defining the system property 'java.rmi.server.hostname' - see jmeter-server script file");
   }
   log.debug("This = " + this);
   if (createServer) {
     log.info("Creating RMI registry (server.rmi.create=true)");
     try {
       LocateRegistry.createRegistry(this.rmiPort);
     } catch (RemoteException e) {
       String msg = "Problem creating registry: " + e;
       log.warn(msg);
       System.err.println(msg);
       System.err.println("Continuing...");
     }
   }
   try {
     Registry reg = LocateRegistry.getRegistry(this.rmiPort);
     reg.rebind(JMETER_ENGINE_RMI_NAME, this);
     log.info("Bound to registry on port " + this.rmiPort);
   } catch (Exception ex) {
     log.error(
         "rmiregistry needs to be running to start JMeter in server "
             + "mode\n\t"
             + ex.toString());
     // Throw an Exception to ensure caller knows ...
     throw new RemoteException("Cannot start. See server log file.", ex);
   }
 }
 /*
  * Called by:
  * - ClientJMeterEngine.exe() which is called on remoteStop
  */
 @Override
 public void rexit() throws RemoteException {
   log.info("Exitting");
   backingEngine.exit();
   // Tidy up any objects we created
   Registry reg = LocateRegistry.getRegistry(this.rmiPort);
   try {
     reg.unbind(JMETER_ENGINE_RMI_NAME);
   } catch (NotBoundException e) {
     log.warn(JMETER_ENGINE_RMI_NAME + " is not bound", e);
   }
   log.info("Unbound from registry");
   // Help with garbage control
   JMeterUtils.helpGC();
 }
 public BinaryTCPClientImpl() {
   super();
   setEolByte(eomInt);
   if (useEolByte) {
     log.info("Using eomByte=" + eolByte);
   }
 }
  @Override
  public synchronized void process() {
    if (file == null) {
      log.info("Creating file object: " + getFileName());
      try {
        file = new FileInputStream(getFileName()).getChannel();
      } catch (FileNotFoundException ex) {
        log.error(getFileName(), ex);
        return;
      }
    }
    String rawData;

    try {
      rawData = readNextChunk(getNextChunkSize());
    } catch (EndOfFileException ex) {
      if (getRewindOnEOF()) {
        if (log.isDebugEnabled()) {
          log.debug("Rewind file");
        }
        try {
          file.position(0);
        } catch (IOException ex1) {
          log.error("Cannot rewind", ex1);
        }
        process();
        return;
      } else {
        log.info("End of file reached: " + getFileName());
        if (JMeterContextService.getContext().getThread() != null) {
          JMeterContextService.getContext().getThread().stop();
        }
        throw new RuntimeEOFException("End of file reached", ex);
      }
    } catch (IOException ex) {
      log.error("Error reading next chunk", ex);
      throw new RuntimeException("Error reading next chunk", ex);
    }

    final JMeterVariables vars = JMeterContextService.getContext().getVariables();
    if (vars != null) {
      vars.put(getVarName(), rawData);
    }
  }
 /**
  * Constructor
  *
  * @param listener that the List of sample events will be sent to.
  */
 StatisticalSampleSender(RemoteSampleListener listener) {
   this.listener = listener;
   init();
   log.info(
       "Using batching for this run."
           + " Thresholds: num="
           + numSamplesThreshold
           + ", time="
           + timeThreshold);
 }
 /** {@inheritDoc} */
 @Override
 public void testEnded() {
   if (purgeQueue()) {
     log.info("Purging queue " + getQueue());
     try {
       channel.queuePurge(getQueue());
     } catch (IOException e) {
       log.error("Failed to purge queue " + getQueue(), e);
     }
   }
 }
 static {
   BSFManager.registerScriptingEngine(
       "jexl", //$NON-NLS-1$
       "org.apache.commons.jexl.bsf.JexlEngine", //$NON-NLS-1$
       new String[] {"jexl"}); // $NON-NLS-1$
   log.info("Registering JMeter version of JavaScript engine as work-round for BSF-22");
   BSFManager.registerScriptingEngine(
       "javascript", //$NON-NLS-1$
       "org.apache.jmeter.util.BSFJavaScriptEngine", //$NON-NLS-1$
       new String[] {"js"}); // $NON-NLS-1$
 }
  /** disconnect from the server */
  public static void disconnect(DirContext dirContext) {
    if (dirContext == null) {
      log.info("Cannot disconnect null context");
      return;
    }

    try {
      dirContext.close();
    } catch (NamingException e) {
      log.warn("Ldap client disconnect - ", e);
    }
  }
Exemple #13
0
  public static <T> T fromMap(Map<?, ?> map, Class<T> t) {
    if (map == null) return null;
    try {
      return mapper.readValue(toJson(map), t);
    } catch (Exception e) {
      logger.info(
          "Cannot parse map to Object. Map: <" + map + ">, Object class: <" + t.getName() + ">.",
          e);
    }

    return null;
  }
 @Override
 public void rreset() throws RemoteException, IllegalStateException {
   // Mail on userlist reported NPE here - looks like only happens if there are network errors, but
   // check anyway
   if (backingEngine != null) {
     log.info("Reset");
     checkOwner("reset");
     backingEngine.reset();
   } else {
     log.warn("Backing engine is null, ignoring reset");
   }
 }
  /**
   * Listen on the daemon port and handle incoming requests. This method will not exit until {@link
   * #stopServer()} is called or an error occurs.
   */
  @Override
  public void run() {
    except = null;
    running = true;
    ServerSocket mainSocket = null;

    try {
      log.info("Creating HttpMirror ... on port " + daemonPort);
      mainSocket = new ServerSocket(daemonPort);
      mainSocket.setSoTimeout(ACCEPT_TIMEOUT);
      log.info("HttpMirror up and running!");

      while (running) {
        try {
          // Listen on main socket
          Socket clientSocket = mainSocket.accept();
          if (running) {
            // Pass request to new thread
            HttpMirrorThread thd = new HttpMirrorThread(clientSocket);
            log.debug("Starting new Mirror thread");
            thd.start();
          } else {
            log.warn("Server not running");
            JOrphanUtils.closeQuietly(clientSocket);
          }
        } catch (InterruptedIOException e) {
          // Timeout occurred. Ignore, and keep looping until we're
          // told to stop running.
        }
      }
      log.info("HttpMirror Server stopped");
    } catch (Exception e) {
      except = e;
      log.warn("HttpMirror Server stopped", e);
    } finally {
      JOrphanUtils.closeQuietly(mainSocket);
    }
  }
 @Override
 public void rsetProperties(Properties p) throws RemoteException, IllegalStateException {
   checkOwner("setProperties");
   if (remotelySetProperties != null) {
     Properties jmeterProperties = JMeterUtils.getJMeterProperties();
     log.info("Cleaning previously set properties " + remotelySetProperties);
     for (Iterator<?> iterator = remotelySetProperties.keySet().iterator(); iterator.hasNext(); ) {
       String key = (String) iterator.next();
       jmeterProperties.remove(key);
     }
   }
   backingEngine.setProperties(p);
   this.remotelySetProperties = p;
 }
  @Override
  public void testIterationStart(LoopIterationEvent event) {

    final long lCurrentTime = new Date().getTime();

    if (checkEndInLock(lCurrentTime)) {
      final JMeterThread lThread = JMeterContextService.getContext().getThread();
      LOGGER.info(String.format("Cooldown stoping Thread: [%s]", lThread.getThreadName()));
      // change to jmeter 2.8
      if (!StandardJMeterEngine.stopThreadNow(lThread.getThreadName())) {
        LOGGER.warn(String.format("could not stop Thread: [%s]", lThread.getThreadName()));
      }
    }
  }
 @Override
 public void setupTest(JavaSamplerContext jsc) {
   log.info("<<<初始化测试数据...");
   conf = gson.fromJson(jsc.getParameter("conf"), Conf.class);
   headMsg = gson.fromJson(jsc.getParameter("handMsg"), HeadMsg.class);
   Iterator<String> it = jsc.getParameterNamesIterator();
   while (it.hasNext()) {
     String name = it.next();
     String value = jsc.getParameter(name);
     if (name.equals("conf") || name.equals("handMsg") || name.equals("TestElement.name"))
       continue;
     sb.append(name).append("=").append(value).append("&");
   }
 }
  @Override
  public void threadStarted() {
    LOGGER.info("AndroidDriverConfig.threadStarted()");

    if (hasThreadBrowser()) {
      LOGGER.warn(
          "Thread: "
              + currentThreadName()
              + " already has a WebDriver("
              + getThreadBrowser()
              + ") associated with it. ThreadGroup can only contain a single WebDriverConfig.");
      return;
    }
    setThreadBrowser(createBrowser());
  }
 /**
  * Adds a feature to the ThreadGroup attribute of the RemoteJMeterEngineImpl object.
  *
  * @param testTree the feature to be added to the ThreadGroup attribute
  */
 @Override
 public void rconfigure(HashTree testTree, String host, File jmxBase, String scriptName)
     throws RemoteException {
   log.info("Creating JMeter engine on host " + host + " base '" + jmxBase + "'");
   synchronized (LOCK) { // close window where another remote client might jump in
     if (backingEngine != null && backingEngine.isActive()) {
       log.warn("Engine is busy - cannot create JMeter engine");
       throw new IllegalStateException("Engine is busy - please try later");
     }
     ownerThread = Thread.currentThread();
     backingEngine = new StandardJMeterEngine(host);
     backingEngine.configure(testTree); // sets active = true
   }
   FileServer.getFileServer().setScriptName(scriptName);
   FileServer.getFileServer().setBase(jmxBase);
 }
Exemple #21
0
  public static <T> T fromJson(String json, Class<T> t) {
    if (json == null) return null;
    try {
      return mapper.readValue(json, t);
    } catch (Exception e) {
      logger.info(
          "Cannot parse json string to Object. Json: <"
              + json
              + ">, Object class: <"
              + t.getName()
              + ">.",
          e);
    }

    return null;
  }
  /** {@inheritDoc} */
  @Override
  public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
      throws InvalidVariableException {
    // JMeterVariables vars = getVariables();
    Calendar cal = Calendar.getInstance();

    if (values.length == 1) { // If user has provided offset value then adjust the time.
      log.info("Got one paramenter");
      try {
        Integer offsetTime = new Integer(((CompoundVariable) values[0]).execute().trim());
        cal.add(Calendar.MILLISECOND, offsetTime);
      } catch (Exception e) { // In case user pass invalid parameter.
        throw new InvalidVariableException(e);
      }
    }

    return String.valueOf(cal.getTimeInMillis());
  }
 /**
  * connect to server
  *
  * @param host Description of Parameter
  * @param username Description of Parameter
  * @param password Description of Parameter
  * @exception NamingException Description of Exception
  */
 public static DirContext connect(
     String host,
     String port,
     String rootdn,
     String username,
     String password,
     String connTimeOut,
     boolean secure)
     throws NamingException {
   DirContext dirContext;
   Hashtable<String, String> env = new Hashtable<String, String>();
   env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); // $NON-NLS-1$
   StringBuilder sb = new StringBuilder(80);
   if (secure) {
     sb.append("ldaps://"); // $NON-NLS-1$
   } else {
     sb.append("ldap://"); // $NON-NLS-1$
   }
   sb.append(host);
   if (port.length() > 0) {
     sb.append(":"); // $NON-NLS-1$
     sb.append(port);
   }
   sb.append("/"); // $NON-NLS-1$
   sb.append(rootdn);
   env.put(Context.PROVIDER_URL, sb.toString());
   log.info("prov_url= " + env.get(Context.PROVIDER_URL)); // $NON-NLS-1$
   if (connTimeOut.length() > 0) {
     env.put("com.sun.jndi.ldap.connect.timeout", connTimeOut); // $NON-NLS-1$
   }
   env.put(Context.REFERRAL, "throw"); // $NON-NLS-1$
   env.put("java.naming.batchsize", "0"); // $NON-NLS-1$  // $NON-NLS-2$
   env.put(Context.SECURITY_CREDENTIALS, password);
   env.put(Context.SECURITY_PRINCIPAL, username);
   dirContext = new InitialDirContext(env);
   return dirContext;
 }
  @Override
  public void testStarted(String host) {
    // if we run in non gui mode, ensure the data will be saved
    if (GuiPackage.getInstance() == null) {
      if (getProperty(FILENAME) == null
          || getProperty(FILENAME).getStringValue().trim().length() == 0) {
        if (autoGenerateFiles) {
          setupSaving();
        } else {
          log.warn(
              "AWSMon metrics will not be recorded! Please run the test with -JforcePerfmonFile=true");
        }
      } else {
        log.info("AWSMon metrics will be stored in " + getProperty(FILENAME));
      }
    }

    initiateConnectors();

    workerThread = new Thread(this);
    workerThread.start();

    super.testStarted(host);
  }
 public void setupTest(JavaSamplerContext setupContext) {
   indexFileSystemPath = setupContext.getParameter("indexfilesystem.path");
   resultsDirectory = setupContext.getParameter("resultsDirectory");
   logger.info("Successfully retrieved indexFileSystemPath.");
 }
  /** {@inheritDoc} */
  @Override
  public SampleResult sample(Entry entry) {
    SampleResult result = new SampleResult();
    result.setSampleLabel(getName());
    result.setSuccessful(false);
    result.setResponseCode("500");

    QueueingConsumer consumer;
    String consumerTag;

    trace("AMQPConsumer.sample()");

    try {
      initChannel();

      consumer = new QueueingConsumer(channel);
      channel.basicQos(1); // TODO: make prefetchCount configurable?
      consumerTag = channel.basicConsume(getQueue(), autoAck(), consumer);
    } catch (IOException ex) {
      log.error("Failed to initialize channel", ex);
      return result;
    }

    result.setSampleLabel(getTitle());
    /*
     * Perform the sampling
     */
    result.sampleStart(); // Start timing
    try {
      QueueingConsumer.Delivery delivery = consumer.nextDelivery(getReceiveTimeoutAsInt());

      if (delivery == null) {
        log.warn("nextDelivery timed out");
        return result;
      }

      /*
       * Set up the sample result details
       */
      result.setSamplerData(new String(delivery.getBody()));

      result.setResponseData("OK", null);
      result.setDataType(SampleResult.TEXT);

      result.setResponseCodeOK();
      result.setResponseMessage("OK");
      result.setSuccessful(true);

      if (!autoAck()) channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);

    } catch (ShutdownSignalException e) {
      log.warn("AMQP consumer failed to consume", e);
      result.setResponseCode("400");
      result.setResponseMessage(e.toString());
      interrupt();
    } catch (ConsumerCancelledException e) {
      log.warn("AMQP consumer failed to consume", e);
      result.setResponseCode("300");
      result.setResponseMessage(e.toString());
      interrupt();
    } catch (InterruptedException e) {
      log.info("interuppted while attempting to consume");
      result.setResponseCode("200");
      result.setResponseMessage(e.toString());
    } catch (IOException e) {
      log.warn("AMQP consumer failed to consume", e);
      result.setResponseCode("100");
      result.setResponseMessage(e.toString());
    } finally {
      try {
        channel.basicCancel(consumerTag);
      } catch (IOException e) {
        log.error("Couldn't safely cancel the sample's consumer", e);
      }
    }

    result.sampleEnd(); // End timimg
    trace("AMQPConsumer.sample ended");

    return result;
  }
 @Override
 public void rrunTest() throws RemoteException, JMeterEngineException, IllegalStateException {
   log.info("Running test");
   checkOwner("runTest");
   backingEngine.runTest();
 }
  /**
   * @param writer
   * @param agentUpdater
   * @param translator
   * @param trendLineAggregator
   * @param agentProvider
   * @param timeBound
   * @param agentThreadCount
   * @param targetWebServer
   * @param trendLineTimer
   * @param trendLineTask
   * @param trendLinePeriod
   * @param nullAggregatorKey
   * @param collectRawData
   * @param errorSampleLimit
   */
  @Inject
  public BaseTestListenerImpl(
      AsynchSampleWriter<AgentDataPoint> writer,
      SampleWriter<TestJobAgentWorker> agentUpdater,
      Translator<SampleEvent, BaseSampleEntity[]> translator,
      Aggregator<Long, AggregationKey, Integer> trendLineAggregator,
      @Retrieve Provider<TestJobAgentWorker> agentProvider,
      @Named("timebound") Long timeBound,
      @Named("threadCount") Long agentThreadCount,
      @Named("webServer") String targetWebServer,
      @Named("trend.line") Timer trendLineTimer,
      @Named("trend.line") TimerTask trendLineTask,
      @Named("trend.line.period") long trendLinePeriod,
      @Named("null") AggregationKey nullAggregatorKey,
      @Named("collect.raw.data") boolean collectRawData,
      @Named("error.sample.limit") int errorSampleLimit) {

    // TODO [write error to file] pass in a new writer for error (wrap the MS Writer for database)

    mTranslator = translator;
    mTrendLineAggregator = trendLineAggregator;
    mSWriter = writer;
    mAgentUpdater = agentUpdater;
    mAgentProvider = agentProvider;
    mTimeBound = timeBound;
    mAgentThreadCount = agentThreadCount;
    mTargetWebServer = targetWebServer;

    //		609828[Error store limit] Limit the maximum error number to be stored.
    mErrorSampleLimitCountDown = new AtomicInteger(errorSampleLimit);
    mLimitErrorSamples = errorSampleLimit >= 0;
    //		615093: [Error limit -1] Error limit -1 doesn't work well.
    LOGGER.info(
        String.format(
            "Will limit error sample collection [%b] to [%d]",
            mLimitErrorSamples, mErrorSampleLimitCountDown.get()));

    mTrendLineTimer = trendLineTimer;
    mTrendLineTask = trendLineTask;
    mTrendLinePeriod = trendLinePeriod;
    mNullKey = nullAggregatorKey;
    mCollectRawData = collectRawData;

    mTrendLineTimer.schedule(mTrendLineTask, mTrendLinePeriod, mTrendLinePeriod);

    mStartTimeStamp = new Timestamp(System.currentTimeMillis());

    updateAgent();

    mAgentUpdateThread =
        new Thread(
            new Runnable() {
              @Override
              public void run() {
                LOGGER.info("Running agent update Thread");
                try {
                  while (!Thread.interrupted()) {
                    LOGGER.info("Waiting for agent update");

                    Thread.sleep((long) (2 * Math.random() * 1000));

                    LOGGER.info("Updating agent");
                    updateAgent();
                  }
                } catch (InterruptedException e) {
                  LOGGER.info("agent update thread interrupted");
                }
                LOGGER.info("agent update stop");
              }
            });
    mAgentUpdateThread.setDaemon(true);
    mAgentUpdateThread.setName("agent update thread");

    mAgentUpdateThread.start();
  }
Exemple #29
0
 /*
  * Helper method for use by scripts
  *
  */
 public void log_info(String s) {
   log.info(s);
 }
  public SampleResult runTest(JavaSamplerContext runTestContext) {
    String indexFileSystemPath = runTestContext.getParameter("indexfilesystem.path");

    String timeStamp =
        new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime());
    resultObj.put("Date and Execution Time", timeStamp);

    resultObj.put("Execution Plan", "Sequential Performance of Indexes FS");
    try {
      resultObj.put("Host", InetAddress.getLocalHost().getHostAddress());
    } catch (UnknownHostException e) {
      e.printStackTrace();
    }

    SampleResult result = new SampleResult();

    try {
      result.sampleStart();
      preallocateTestFile(FILE_NAME);

      for (final PerfTestCase testCase : testCases) {
        JSONArray readDuration = new JSONArray();
        JSONArray bytesRead = new JSONArray();
        JSONArray bytesWrite = new JSONArray();
        for (int i = 0; i < 5; i++) {
          System.gc();
          long writeDurationMs = testCase.test(PerfTestCase.Type.WRITE, FILE_NAME);
          System.gc();
          long readDurationMs = testCase.test(PerfTestCase.Type.READ, FILE_NAME);
          long bytesReadPerSec = (FILE_SIZE * 1000L) / readDurationMs;
          long bytesWrittenPerSec = (FILE_SIZE * 1000L) / writeDurationMs;
          readDuration.add(readDurationMs);
          bytesRead.add(bytesReadPerSec);
          bytesWrite.add(bytesWrittenPerSec);

          out.format(
              "%s\twrite=%,d\tread=%,d bytes/sec\n",
              testCase.getName(), bytesWrittenPerSec, bytesReadPerSec);

          String output =
              out.format(
                      "%s\twrite=%,d\tread=%,d bytes/sec\n",
                      testCase.getName(), bytesWrittenPerSec, bytesReadPerSec)
                  .toString();
          result.setSamplerData(testCase.getName() + "-- IO RESULTS --- " + output);
          // resultIo.setSamplerData(testCase.getName() + "-- Writen Bytes per second:" +
          // bytesWrittenPerSec + "-- Read Bytes per second:" + bytesReadPerSec);
          result.addSubResult(result);
        }

        resultObj.put(testCase.getName(), readDuration);
        resultObj.put(testCase.getName(), bytesRead);
        resultObj.put(testCase.getName(), bytesWrite);
      }

      deleteFile(indexFileSystemPath + "/" + FILE_NAME);

      try {

        FileWriter file = new FileWriter(resultsDirectory + "/" + OUTPUT_JSON_FILE_NAME);
        file.write(resultObj.toJSONString());
        file.flush();
        file.close();

      } catch (IOException e) {
        e.printStackTrace();
      }

      result.sampleEnd();
      result.setSuccessful(true);
      logger.info("Successfully Tested Index Disk IO  at path: " + indexFileSystemPath);
      result.setResponseMessage("Successfully Tested IO at  Indexes Disk");
      result.setResponseCodeOK();
    } catch (Exception e) {
      result.sampleEnd();
      result.setSuccessful(false);
      result.setResponseMessage("Failed to TestIO: " + e);
      StringWriter stringWriter = new StringWriter();
      e.printStackTrace(new PrintWriter(stringWriter));
      result.setResponseData(stringWriter.toString().getBytes());
      result.setDataType(SampleResult.TEXT);
      result.setResponseCode("500");
    }
    return result;
  }