edu.usc.bg.workloads
Class ResourceWorkload

java.lang.Object
  extended by edu.usc.bg.base.Workload
      extended by edu.usc.bg.workloads.ResourceWorkload

public class ResourceWorkload
extends Workload

Used for loading resources for the members

Author:
barahman

Field Summary
static int avgResourceCount
           
static long BASE_INTERVAL
           
static int fieldCount
           
static int fieldLength
           
static java.lang.String[] fieldName
           
static long MAX_INTERVAL
           
static java.lang.String table
           
 
Constructor Summary
ResourceWorkload()
           
 
Method Summary
 java.lang.String buildKeyName(long keyNum)
           
 boolean doInsert(DB db, java.lang.Object threadState)
          Do one insert operation.
 int doTransaction(DB db, java.lang.Object threadstate, int threadid, java.lang.StringBuilder updateLog, java.lang.StringBuilder readLog, int seqID, java.util.HashMap<java.lang.String,java.lang.Integer> resUpdateOperations, java.util.HashMap<java.lang.String,java.lang.Integer> frienshipInfo, java.util.HashMap<java.lang.String,java.lang.Integer> pendingInfo, int thinkTime, boolean insertImage, boolean warmup)
          Do one transaction operation.
 java.lang.String getDate()
           
 java.util.HashMap<java.lang.String,java.lang.String> getDBInitialStats(DB db)
          Gets the initial statistics from the data stores: member count, friend count per user, pending friend count per user and the resource count per user assuming all users initially have the same number of confirmed and pending friendships.
 void init(java.util.Properties p, java.util.Vector<java.lang.Integer> members)
          Initialize the scenario.
 
Methods inherited from class edu.usc.bg.base.Workload
cleanup, initThread, isStopRequested, requestStop, resetDBInternalStructures, setStopRequested
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

public static java.lang.String table

fieldCount

public static int fieldCount

fieldLength

public static int fieldLength

fieldName

public static java.lang.String[] fieldName

MAX_INTERVAL

public static final long MAX_INTERVAL
See Also:
Constant Field Values

BASE_INTERVAL

public static final long BASE_INTERVAL
See Also:
Constant Field Values

avgResourceCount

public static int avgResourceCount
Constructor Detail

ResourceWorkload

public ResourceWorkload()
Method Detail

init

public void init(java.util.Properties p,
                 java.util.Vector<java.lang.Integer> members)
          throws WorkloadException
Description copied from class: Workload
Initialize the scenario. Create any generators and other shared objects here. Called once, in the main client thread, before any operations are started. Also called when client threads load the database.

Overrides:
init in class Workload
Parameters:
p - The properties.
members - Needed for the load phase, keeps a track of the set of memberids that the BG client is responsible for.
Throws:
WorkloadException

getDate

public java.lang.String getDate()

buildKeyName

public java.lang.String buildKeyName(long keyNum)

doInsert

public boolean doInsert(DB db,
                        java.lang.Object threadState)
Description copied from class: Workload
Do one insert operation. Because it will be called concurrently from multiple client threads, this function must be thread safe. However, avoid synchronized, or the threads will block waiting for each other, and it will be difficult to reach the target throughput. Ideally, this function would have no side effects other than DB operations and mutations on threadstate. Mutations to threadstate do not need to be synchronized, since each thread has its own threadstate instance.

Specified by:
doInsert in class Workload

getDBInitialStats

public java.util.HashMap<java.lang.String,java.lang.String> getDBInitialStats(DB db)
Description copied from class: Workload
Gets the initial statistics from the data stores: member count, friend count per user, pending friend count per user and the resource count per user assuming all users initially have the same number of confirmed and pending friendships.

Specified by:
getDBInitialStats in class Workload

doTransaction

public int doTransaction(DB db,
                         java.lang.Object threadstate,
                         int threadid,
                         java.lang.StringBuilder updateLog,
                         java.lang.StringBuilder readLog,
                         int seqID,
                         java.util.HashMap<java.lang.String,java.lang.Integer> resUpdateOperations,
                         java.util.HashMap<java.lang.String,java.lang.Integer> frienshipInfo,
                         java.util.HashMap<java.lang.String,java.lang.Integer> pendingInfo,
                         int thinkTime,
                         boolean insertImage,
                         boolean warmup)
Description copied from class: Workload
Do one transaction operation. Because it will be called concurrently from multiple client threads, this function must be thread safe. However, avoid synchronized, or the threads will block waiting for each other, and it will be difficult to reach the target throughput. Ideally, this function would have no side effects other than DB operations and mutations on threadstate. Mutations to threadstate do not need to be synchronized, since each thread has its own threadstate instance.

Specified by:
doTransaction in class Workload
updateLog - The update log record created by that transaction which needs to be written to the update file.
readLog - The read log record created by that transaction which needs to be written to the update file.
seqID - For workloads issuing sessions keeps a track of the current sessionid.
resUpdateOperations - Keeps a track of all the postcomment updates issued - needed for validation based on exact values.
frienshipInfo - Keeps a track of all the confirmed friendships created throughout the benchmark execution - needed for validation based on exact values.
pendingInfo - Keeps a track of all the pending invites created during the benchmark execution - needed for validation based on exact values.
thinkTime - Think time between the actions in a session.
insertImage - If set to true means images will be retrieved for relevant actions i.e. getUserProfile.
warmup - If set to true the workload would not issue any update actions.
Returns:
greater than 0 if everything is fine.