net.sf.sparql.benchmarking.parallel.impl
Class StressTestParallelClientManager

java.lang.Object
  extended by net.sf.sparql.benchmarking.parallel.impl.StressTestParallelClientManager
All Implemented Interfaces:
Callable<Object>, ParallelClientManager<StressOptions>

public class StressTestParallelClientManager
extends Object
implements ParallelClientManager<StressOptions>

A Callable uses to manage the running of parallel clients for stress testing

Author:
rvesse

Constructor Summary
StressTestParallelClientManager(Runner<StressOptions> runner, StressOptions options)
          Creates a new Parallel Client Manager
 
Method Summary
 Object call()
           
 int completeRun()
          Method that will be called by parallel clients to indicate they have completed a run and to obtain what run completion number it is
 ParallelClient<StressOptions> createClient(int id)
          Creates a new parallel client
protected  boolean exceededMaxRuntime()
          Gets whether the maximum run time has been exceeded
 long getCurrentClientCount()
          Gets the current number of parallel clients in-use
 StressOptions getOptions()
          Gets the options
 Runner<StressOptions> getRunner()
          Gets the runner
 void halt()
          Method called by parallel clients to tell the manager that they encountered a halting condition and thus all clients should halt
 boolean hasFinished()
          Returns whether the parallel clients have finished all necessary runs
 boolean isReady()
          Gets whether the manager is ready for clients to begin executing
 boolean shouldRun()
          Method that will be called by parallel clients to determine if they should continue to run, calls to this are thread safe
 boolean startRun()
          Method that will be called by parallel clients to indicate they have started a new run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StressTestParallelClientManager

public StressTestParallelClientManager(Runner<StressOptions> runner,
                                       StressOptions options)
Creates a new Parallel Client Manager

Parameters:
runner - Benchmark runner
options - Options
Method Detail

getCurrentClientCount

public long getCurrentClientCount()
Gets the current number of parallel clients in-use

Returns:
Current number of parallel clients

call

public Object call()
            throws Exception
Specified by:
call in interface Callable<Object>
Throws:
Exception

exceededMaxRuntime

protected boolean exceededMaxRuntime()
Gets whether the maximum run time has been exceeded

Returns:
True if maximum runtime has been exceeded

shouldRun

public boolean shouldRun()
Description copied from interface: ParallelClientManager
Method that will be called by parallel clients to determine if they should continue to run, calls to this are thread safe

Specified by:
shouldRun in interface ParallelClientManager<StressOptions>
Returns:
True if a client should continue to run, false if they should terminate

startRun

public boolean startRun()
Description copied from interface: ParallelClientManager
Method that will be called by parallel clients to indicate they have started a new run

A boolean is returned indicating whether the client should actually go ahead with the run, this is to help avoid race conditions where multiple threads check ParallelClientManager.shouldRun() to see if they should proceed and then attempt to start more runs than actually necessary.

Specified by:
startRun in interface ParallelClientManager<StressOptions>
Returns:
True if the run should actually run, false otherwise

completeRun

public int completeRun()
Description copied from interface: ParallelClientManager
Method that will be called by parallel clients to indicate they have completed a run and to obtain what run completion number it is

Specified by:
completeRun in interface ParallelClientManager<StressOptions>
Returns:
Run completion number

hasFinished

public boolean hasFinished()
Description copied from interface: ParallelClientManager
Returns whether the parallel clients have finished all necessary runs

Specified by:
hasFinished in interface ParallelClientManager<StressOptions>
Returns:
True if all runs have finished, false otherwise

halt

public void halt()
Description copied from interface: ParallelClientManager
Method called by parallel clients to tell the manager that they encountered a halting condition and thus all clients should halt

Specified by:
halt in interface ParallelClientManager<StressOptions>

isReady

public boolean isReady()
Description copied from interface: ParallelClientManager
Gets whether the manager is ready for clients to begin executing

Specified by:
isReady in interface ParallelClientManager<StressOptions>
Returns:
True if the manager is ready, false otherwise

getRunner

public Runner<StressOptions> getRunner()
Description copied from interface: ParallelClientManager
Gets the runner

Specified by:
getRunner in interface ParallelClientManager<StressOptions>
Returns:
Runner

getOptions

public StressOptions getOptions()
Description copied from interface: ParallelClientManager
Gets the options

Specified by:
getOptions in interface ParallelClientManager<StressOptions>
Returns:
Options

createClient

public ParallelClient<StressOptions> createClient(int id)
Description copied from interface: ParallelClientManager
Creates a new parallel client

Specified by:
createClient in interface ParallelClientManager<StressOptions>
Parameters:
id - Client ID
Returns:
Parallel client


Copyright © 2014. All Rights Reserved.