Skip to content
Open
5 changes: 4 additions & 1 deletion core/src/main/java/com/yahoo/ycsb/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,10 @@ public void run()
}

try
{
{
if ( workload.getStartTime() != null){
st = workload.getStartTime();
}
exportMeasurements(props, opsDone, en - st);
} catch (IOException e)
{
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/com/yahoo/ycsb/ClientMulti.java
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,9 @@ public void run()

try
{
if ( workload.getStartTime() != null){
st = workload.getStartTime();
}
exportMeasurements(props, opsDone, en - st);
} catch (IOException e)
{
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/com/yahoo/ycsb/Workload.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,9 @@ public boolean isSchedulerTerminated() {
}
public void setStartTime() {
}
/* method to obtain the beginning start barrier */
public Long getStartTime(){
return null;
}

}
63 changes: 62 additions & 1 deletion core/src/main/java/com/yahoo/ycsb/workloads/ReplayWorkload.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@

import java.io.BufferedReader;
import java.io.FileReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
import java.io.FileInputStream;
import java.io.InputStream;
Expand Down Expand Up @@ -203,7 +206,25 @@ public class ReplayWorkload extends Workload
public static final String WITH_SLEEP_PROPERTY_DEFAULT="true";

boolean withsleep;


/**
* The name of the property with the start datetime
*/
public static final String STARTDATETIME_PROPERTY="startdatetime";

/**
* The default value for the STARTDATETIME property.
*/
public static final String STARTDATETIME_PROPERTY_DEFAULT="2016-01-01 00:00:00:000";

String startdatetime="2016-01-01 00:00:00:000"; /*Declared later when property is read*/


private long startTime = -1;
private long currentTime = -1;
//private boolean booleanStartBarrier = true;
//private long sleeptime = 0;
/**
* The name of the property for deciding whether to check all returned
* data against the formation template to ensure data integrity.
Expand Down Expand Up @@ -455,6 +476,8 @@ public void init(Properties p) throws WorkloadException
ascache=Boolean.parseBoolean(p.getProperty(AS_CACHE_PROPERTY,AS_CACHE_PROPERTY_DEFAULT));
withtimestamp=Boolean.parseBoolean(p.getProperty(WITH_TIMESTAMP_PROPERTY,WITH_TIMESTAMP_PROPERTY_DEFAULT));
withsleep=Boolean.parseBoolean(p.getProperty(WITH_SLEEP_PROPERTY,WITH_SLEEP_PROPERTY_DEFAULT));
startdatetime=p.getProperty(STARTDATETIME_PROPERTY,STARTDATETIME_PROPERTY_DEFAULT);


dataintegrity = Boolean.parseBoolean(p.getProperty(DATA_INTEGRITY_PROPERTY, DATA_INTEGRITY_PROPERTY_DEFAULT));
//Confirm that fieldlengthgenerator returns a constant if data
Expand Down Expand Up @@ -730,7 +753,17 @@ public boolean doTransaction(DB db, Object threadstate)
}
//System.out.println("Delay: " + sleeptime);
try{
Thread.sleep(sleeptime);
Thread.sleep(sleeptime);
}catch(InterruptedException e){
e.printStackTrace();
}
}

long currentTimeBarrier= System.currentTimeMillis();
if (( currentTimeBarrier < startTime) && !(withtimestamp)){
sleeptime=Math.abs(currentTimeBarrier - startTime);
try{
Thread.sleep(sleeptime);
}catch(InterruptedException e){
e.printStackTrace();
}
Expand Down Expand Up @@ -789,6 +822,34 @@ protected void verifyRow(String key, HashMap<String,ByteIterator> cells, int fie
}
Measurements.getMeasurements().measure("VERIFY", matchType);
}

/* Method to check if the scheduler is terminated */
public void setStartTime() {
//Read the start time from the properties. If it's in the past, use currentTime.
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
Date date = new Date();
Date currentDate = new Date();
try {
date = format.parse(startdatetime);
} catch (ParseException e) {
e.printStackTrace();
}
//long dateTimestamp = date.getTime();
if (date.before(currentDate)){
startTime = System.currentTimeMillis();
} else{
startTime = date.getTime();
}
System.out.println("Start time in format: " + startdatetime);
System.out.println("Start Time in Milliseconds: "+ startTime);
}

/* Method to obtain the start time in milliseconds */
@Override
public Long getStartTime() {
return startTime;
}


int nextKeynum() {
int keynum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,19 @@ public class ReplayWorkloadScheduled extends Workload
*/
public static final String TEMPORAL_SCALING_PROPERTY_DEFAULT = "1.0";


/**
* The name of the property with the start datetime
*/
public static final String STARTDATETIME_PROPERTY="startdatetime";

/**
* The default value for the STARTDATETIME property.
*/
public static final String STARTDATETIME_PROPERTY_DEFAULT="2016-01-01 00:00:00:000";

String startdatetime="2016-01-01 00:00:00:000"; /*Declared later when property is read*/

/**
* ScheduledExecutorService object to schedule the rquests.
* We are using a single thread, because in some cases (like Redis), the client
Expand All @@ -226,6 +239,7 @@ public class ReplayWorkloadScheduled extends Workload
private long startTime = -1;
private long currentTime = -1;
private long sleeptime = 0;
//private boolean booleanStartBarrier = true;


/**
Expand Down Expand Up @@ -480,6 +494,8 @@ public void init(Properties p) throws WorkloadException
ascache=Boolean.parseBoolean(p.getProperty(AS_CACHE_PROPERTY,AS_CACHE_PROPERTY_DEFAULT));
withtimestamp=Boolean.parseBoolean(p.getProperty(WITH_TIMESTAMP_PROPERTY,WITH_TIMESTAMP_PROPERTY_DEFAULT));
timestampfactor=Integer.parseInt(p.getProperty(TIMESTAMP_FACTOR_PROPERTY,TIMESTAMP_FACTOR_PROPERTY_DEFAULT));

startdatetime=p.getProperty(STARTDATETIME_PROPERTY,STARTDATETIME_PROPERTY_DEFAULT);

dataintegrity = Boolean.parseBoolean(p.getProperty(DATA_INTEGRITY_PROPERTY, DATA_INTEGRITY_PROPERTY_DEFAULT));
//Confirm that fieldlengthgenerator returns a constant if data
Expand Down Expand Up @@ -757,8 +773,12 @@ public boolean doTransaction(DB db, Object threadstate)
delay = sleeptime - (currentTime-startTime);
//System.out.println("Real delay: " + delay);
}

// Schedule the event

long currentTimeBarrier= System.currentTimeMillis();
if (( currentTimeBarrier < startTime) && !(withtimestamp)){
delay=Math.abs(currentTimeBarrier - startTime);
}

scheduler.schedule(new ScheduledEvent(db, op, dbkey , fieldSize), delay, TimeUnit.MILLISECONDS);

return true;
Expand Down Expand Up @@ -818,13 +838,40 @@ public boolean isSchedulerTerminated() {
return scheduler.isTerminated();
}

/* Method to check if the scheduler is terminated */
/* Method to check if the scheduler is terminated */
public void setStartTime() {
startTime = System.currentTimeMillis();
//Read the start time from the properties. If it's in the past, use currentTime.
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
Date date = new Date();
Date currentDate = new Date();
try {
date = format.parse(startdatetime);
} catch (ParseException e) {
e.printStackTrace();
}
//long dateTimestamp = date.getTime();
if (date.before(currentDate)){
startTime = System.currentTimeMillis();
} else{
System.out.println("entra aqui");
startTime = date.getTime();
}
System.out.println("\n");
System.out.println("date is : " + date);
System.out.println("Current date is: " + currentDate);
System.out.println("Start time date : " + startdatetime);
System.out.println("Start Time in Milliseconds: "+ startTime);
}

/* Method to obtain the start time in milliseconds */
@Override
public Long getStartTime() {
return startTime;
}




/**
* modificado jose viteri 30/11/2016
* Results are reported in the first three buckets of the histogram under
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public class ReplayWorkloadScheduledMulti extends Workload
private long startTime = -1;
private long currentTime = -1;
private long sleeptime = 0;
//private boolean booleanStartBarrier = true;


/**
Expand Down Expand Up @@ -824,9 +825,13 @@ public boolean doTransaction(DB db, Object threadstate)
delay = sleeptime - (currentTime-startTime) + 20;
//System.out.println("Real delay: " + delay);
}
long currentTimeBarrier= System.currentTimeMillis();
if (( currentTimeBarrier < startTime) && !(withtimestamp)){
delay=Math.abs(currentTimeBarrier - startTime);
}

// Schedule the event
System.out.println(dbkey + "," + trace[2] + "," + sleeptime + "," + delay);
//System.out.println(dbkey + "," + trace[2] + "," + sleeptime + "," + delay);
scheduler.schedule(new ScheduledEvent(db, op, dbkey, fieldSize), delay, TimeUnit.MILLISECONDS);

return true;
Expand Down Expand Up @@ -905,6 +910,12 @@ public void setStartTime() {
}
System.out.println("Start Time in Milliseconds: "+ startTime);
}

/* Method to obtain the start time in milliseconds */
@Override
public Long getStartTime() {
return startTime;
}


/**
Expand Down
24 changes: 20 additions & 4 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,38 @@ Would generate **4* traces using the **sha** hash method. And it will print the

### Explanation

Intensifying is a way to scale up a trace. The objective of these method is to generate a trace with the same amount of records and keys as the original but **temporally and spatially scaled**. To accomplish that the original trace is divided in subtraces that are aligned at time 0 and merged to create an illusion of concurrency , in which a record of the subtrace N is replayed after a record of the subtrace N-1. The numbers of subtraces created and originated is also called **TIF** acronym of **trace intensifying factor**. The timestamps between records is also compressed in a factor proportional to the number of subtraces present. Is important to say that the subtraces obtained with these method are not the same that the ones obtained with the subtracing script.
Intensifying is a way to scale up a trace. The objective of these method is to generate a trace with the same amount of records and keys as the original but **temporally and spatially scaled**. To accomplish that the original trace is divided in subtraces that are aligned at time 0 and merged to create an illusion of concurrency . The numbers of subtraces created and originated is also called **TIF** acronym of **trace intensifying factor**. Is important to say that the subtraces obtained with these method are not the same that the ones obtained with the subtracing script.

### Description of how to use the script

The script has 3 **parameters** to enter. The first is the **original trace file** that we want to scale, the second is the **TIF** we want to made, where TIF means trace intensifying factor , these is the number of subtraces generated and merged. The third is the **name of the output file** that will be generated.
The script has 4 **parameters** to enter. The first is the **original trace file** that we want to scale, the second is the **TIF** we want to made, where TIF means trace intensifying factor , these is the number of subtraces generated and merged. The third is the **name of the output file** that will be generated. The fourth parameter is an **optional boolean parameter** that defines the way in which the subtraces are made. If is **true** the division of subtraces will be **by time**. If it is **false** the division of the subtraces will be by **the number of registers**. Each method is better explained in the paragraph below. **Default** value is **true**.


The output trace will have the **same number of records** as the original, but the records will be in order. That means that after a subtrace n record will follow a record part of the subtrace n+1 . That until it reachs a record part of the last subtrace, in that case the record that will follow it is some record part of the subtrace 1. The timestamps also will be compressed.
The division of subtraces by time divides the original trace that has a duration of **t time** in subtraces with **t/TIF
approximately duration each one**. In the same way ,division by number of subtraces will divide the original trace in **n** subtraces with **n/TIF records each one** . Is important to notice that in these particular method, the output trace **won't have the exactly same number of records** because the division in subtraces normally have a **residue** and that records are not count in the output trace. That means that if the original trace have **n** records and in the output trace there will be **st** merged subtraces, the output will have **st\*floor( st / 3)** records . For example if n=1000 and st=3 the output trace will have 999 records.

Both methods **merge the records** and put them in order **aligned at time zero**. The records in the output trace could be identified by subtrace because each record now has a **subtrace ID at the beggining**.


### Example of use

**1**
```
./intensifyingScript.sh traceExample.dat 4 traceOutput.dat
```
That would generate an intenseTrace with a TIF=4 named traceOutput.dat originated from the trace named traceExample.dat.
That would generate an intenseTrace with a TIF=4 named traceOutput.dat originated from the trace named traceExample.dat. The division in subtraces will be by time.

**2**
```
./intensifyingScript.sh traceExample.dat 4 traceOutput.dat false
```
That would generate an intenseTrace with a TIF=4 named traceOutput.dat originated from the trace named traceExample.dat. The division in subtraces will be by number or records.

**3**
```
./intensifyingScript.sh traceExample.dat 4 traceOutput.dat true
```
That would generate an intenseTrace with a TIF=4 named traceOutput.dat originated from the trace named traceExample.dat. The division in subtraces will be by time.



Expand Down
Loading