зеркало из https://github.com/Azure/YCSB.git
[core, client] Fix record count property default value in CoreWorkload, also refactor
throttle method in client.
This commit is contained in:
Родитель
dfd79c800c
Коммит
0b02483454
|
@ -18,10 +18,6 @@
|
|||
package com.yahoo.ycsb;
|
||||
|
||||
|
||||
import com.yahoo.ycsb.measurements.Measurements;
|
||||
import com.yahoo.ycsb.measurements.exporter.MeasurementsExporter;
|
||||
import com.yahoo.ycsb.measurements.exporter.TextMeasurementsExporter;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -33,6 +29,10 @@ import java.util.Enumeration;
|
|||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.yahoo.ycsb.measurements.Measurements;
|
||||
import com.yahoo.ycsb.measurements.exporter.MeasurementsExporter;
|
||||
import com.yahoo.ycsb.measurements.exporter.TextMeasurementsExporter;
|
||||
|
||||
//import org.apache.log4j.BasicConfigurator;
|
||||
|
||||
/**
|
||||
|
@ -240,26 +240,7 @@ class ClientThread extends Thread
|
|||
|
||||
_opsdone++;
|
||||
|
||||
//throttle the operations
|
||||
if (_target>0)
|
||||
{
|
||||
//this is more accurate than other throttling approaches we have tried,
|
||||
//like sleeping for (1/target throughput)-operation latency,
|
||||
//because it smooths timing inaccuracies (from sleep() taking an int,
|
||||
//current time in millis) over many operations
|
||||
while (System.currentTimeMillis()-st<((double)_opsdone)/_target)
|
||||
{
|
||||
try
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
throttle(st);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -276,25 +257,7 @@ class ClientThread extends Thread
|
|||
|
||||
_opsdone++;
|
||||
|
||||
//throttle the operations
|
||||
if (_target>0)
|
||||
{
|
||||
//this is more accurate than other throttling approaches we have tried,
|
||||
//like sleeping for (1/target throughput)-operation latency,
|
||||
//because it smooths timing inaccuracies (from sleep() taking an int,
|
||||
//current time in millis) over many operations
|
||||
while (System.currentTimeMillis()-st<((double)_opsdone)/_target)
|
||||
{
|
||||
try
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
throttle(st);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -316,6 +279,29 @@ class ClientThread extends Thread
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void throttle(long currTimeMillis) {
|
||||
//throttle the operations
|
||||
if (_target>0)
|
||||
{
|
||||
//this is more accurate than other throttling approaches we have tried,
|
||||
//like sleeping for (1/target throughput)-operation latency,
|
||||
//because it smooths timing inaccuracies (from sleep() taking an int,
|
||||
//current time in millis) over many operations
|
||||
while (System.currentTimeMillis()-currTimeMillis<((double)_opsdone)/_target)
|
||||
{
|
||||
try
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -324,6 +310,8 @@ class ClientThread extends Thread
|
|||
public class Client
|
||||
{
|
||||
|
||||
public static final String DEFAULT_RECORD_COUNT = "0";
|
||||
|
||||
/**
|
||||
* The target number of operations to perform.
|
||||
*/
|
||||
|
@ -738,7 +726,7 @@ public class Client
|
|||
}
|
||||
else
|
||||
{
|
||||
opcount=Integer.parseInt(props.getProperty(RECORD_COUNT_PROPERTY,"0"));
|
||||
opcount=Integer.parseInt(props.getProperty(RECORD_COUNT_PROPERTY, DEFAULT_RECORD_COUNT));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ public class CoreWorkload extends Workload
|
|||
double insertproportion=Double.parseDouble(p.getProperty(INSERT_PROPORTION_PROPERTY,INSERT_PROPORTION_PROPERTY_DEFAULT));
|
||||
double scanproportion=Double.parseDouble(p.getProperty(SCAN_PROPORTION_PROPERTY,SCAN_PROPORTION_PROPERTY_DEFAULT));
|
||||
double readmodifywriteproportion=Double.parseDouble(p.getProperty(READMODIFYWRITE_PROPORTION_PROPERTY,READMODIFYWRITE_PROPORTION_PROPERTY_DEFAULT));
|
||||
recordcount=Integer.parseInt(p.getProperty(Client.RECORD_COUNT_PROPERTY));
|
||||
recordcount=Integer.parseInt(p.getProperty(Client.RECORD_COUNT_PROPERTY, Client.DEFAULT_RECORD_COUNT));
|
||||
String requestdistrib=p.getProperty(REQUEST_DISTRIBUTION_PROPERTY,REQUEST_DISTRIBUTION_PROPERTY_DEFAULT);
|
||||
int maxscanlength=Integer.parseInt(p.getProperty(MAX_SCAN_LENGTH_PROPERTY,MAX_SCAN_LENGTH_PROPERTY_DEFAULT));
|
||||
String scanlengthdistrib=p.getProperty(SCAN_LENGTH_DISTRIBUTION_PROPERTY,SCAN_LENGTH_DISTRIBUTION_PROPERTY_DEFAULT);
|
||||
|
|
Загрузка…
Ссылка в новой задаче