Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3f786f0
New data type
gkanade Feb 12, 2016
e16a23b
Merge branch 'master' of https://github.com/gkanade/phoenix
gkanade Feb 16, 2016
26ead8d
New sequence type
gkanade Feb 16, 2016
1a4277b
testing new data type
gkanade Feb 16, 2016
fefad56
New sequence type
gkanade Feb 16, 2016
a61f324
New sequence type
gkanade Feb 16, 2016
a2959dc
New sequence type
gkanade Feb 16, 2016
3d3a22c
New sequence type
gkanade Feb 17, 2016
231fd93
New sequence type
gkanade Feb 17, 2016
4c2c056
New sequence type sync up
gkanade Feb 17, 2016
cdcff31
Intercepting query sets
gkanade Feb 18, 2016
476ee0b
Intercepting query sets
gkanade Feb 18, 2016
522e306
Intercepting query sets
gkanade Feb 18, 2016
ad5e36c
Intercepting query sets
gkanade Feb 18, 2016
7d55a53
Intercepting query sets
gkanade Feb 18, 2016
b9b2f08
Intercepting query sets
gkanade Feb 18, 2016
731351e
Intercepting query sets
gkanade Feb 18, 2016
0728f92
Intercepting query sets
gkanade Feb 18, 2016
9d0f422
Batch writes
gkanade Feb 25, 2016
413aa95
Batch writes
gkanade Feb 25, 2016
4c2631a
Batch writes
gkanade Feb 25, 2016
2babed5
Batch writes
gkanade Feb 25, 2016
36aae6e
Batch writes
gkanade Feb 25, 2016
cf0fced
Batch writes
gkanade Feb 25, 2016
01c5e13
Batch writes
gkanade Feb 25, 2016
d2b08fb
Batch writes
gkanade Feb 25, 2016
49ba0fb
Batch writes
gkanade Feb 25, 2016
95369c2
Stupid
gkanade Feb 26, 2016
d0d8ed9
Logging
gkanade Mar 9, 2016
40cf0c0
Merge remote-tracking branch 'upstream/master'
gkanade Mar 29, 2016
a5fcecc
remove logging
gkanade Mar 31, 2016
3b92cf2
remove logging
gkanade Mar 31, 2016
ed5f257
remove clearbatch
gkanade Mar 31, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/pherf-cluster.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,7 +75,7 @@
stderr=subprocess.PIPE).communicate()

java_cmd = java +' -cp "' + hbasecp + os.pathsep + phoenix_utils.pherf_conf_path + os.pathsep + phoenix_utils.hbase_conf_dir + os.pathsep + phoenix_utils.phoenix_pherf_jar + \
'" -Dlog4j.configuration=file:' + \
os.pathsep + phoenix_utils.phoenix_thin_client_jar + '" -Dlog4j.configuration=file:' + \
os.path.join(phoenix_utils.current_dir, "log4j.properties") + \
" org.apache.phoenix.pherf.Pherf " + args

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -254,6 +254,7 @@ public void run() throws Exception {
// Schema and Data Load
if (preLoadData) {
logger.info("\nStarting Data Load...");
System.out.print("Starting Data Load ...");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to use the logger config for stdout instead.

Workload workload = new WriteWorkload(parser, generateStatistics);
try {
workloadExecutor.add(workload);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,7 @@ public static enum CompareType {
private static PherfConstants instance = null;
private static Properties instanceProperties = null;

public static final String DEFAULT_PRIMARY_KEY = "TENANT_ID";
public static final int DEFAULT_THREAD_POOL_SIZE = 10;
public static final int DEFAULT_BATCH_SIZE = 1000;
public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS";
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,5 +19,5 @@
package org.apache.phoenix.pherf.configuration;

public enum DataSequence {
RANDOM, SEQUENTIAL,LIST;
RANDOM, SEQUENTIAL,LIST,SUPERSEQUENTIAL;
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,8 @@ public enum DataTypeMapping {
CHAR("CHAR", Types.CHAR),
DECIMAL("DECIMAL", Types.DECIMAL),
INTEGER("INTEGER", Types.INTEGER),
DATE("DATE", Types.DATE);
DATE("DATE", Types.DATE),
YCSBKEY("YCSBKEY", Types.VARCHAR);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: formatting


private final String sType;

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,24 @@ public class QuerySet {
private long numberOfExecutions = PherfConstants.DEFAULT_NUMBER_OF_EXECUTIONS;
private long executionDurationInMs = PherfConstants.DEFAULT_THREAD_DURATION_IN_MS;
private ExecutionType executionType = ExecutionType.SERIAL;

private boolean randomPointRead = false;
private String primaryKey = PherfConstants.DEFAULT_PRIMARY_KEY;

@XmlAttribute
public String getPrimaryKey() {
return primaryKey;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: more formatting. Make sure you import the code stye preferences into your project.

}
public void setPrimaryKey(String pk){
primaryKey=pk;
}
@XmlAttribute
public boolean isRandomPointRead() {
return randomPointRead;
}
public void setRandomPointRead(boolean value) {
randomPointRead = value;
}

/**
* List of queries in each query set
* @return
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,6 +27,7 @@
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang3.RandomUtils;
import org.apache.phoenix.pherf.util.PhoenixUtil;

@XmlRootElement(namespace = "org.apache.phoenix.pherf.configuration.DataModel")
Expand DownExpand Up@@ -126,6 +127,21 @@ public void setDataOverride(DataOverride dataOverride) {
* @return
*/
public List<QuerySet> getQuerySet() {
for(QuerySet qs : querySet){
if(qs.isRandomPointRead()){
List<Query> queryList = new ArrayList<Query>();
String tableName = this.getTableName();
String primaryKey = qs.getPrimaryKey();
for(int i = 0; i < 10; i++) {
Query query = new Query();
long keyInt = RandomUtils.nextLong(100, 10000100);
query.setStatement("select * from " + this.getTableName() + " where " + primaryKey + " = 'user" + keyInt+"'");
queryList.add(query);
}

qs.setQuery(queryList);
}
}
return querySet;
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -168,6 +168,16 @@ private void init(String pattern) throws Exception {
}
for (Path path : this.paths) {
System.out.println("Adding model for path:" + path.toString());
DataModel dm = XMLConfigParser.readDataModel(path);
List<Scenario> sl = dm.getScenarios();
for(Scenario s : sl) {
List<QuerySet> lqs = s.getQuerySet();
for(QuerySet qs : lqs) {
System.out.println("Concurrency is " + qs.getConcurrency());
System.out.println("Exec duration is " + qs.getExecutionDurationInMs());
System.out.println("RandomPointRead is " + qs.isRandomPointRead());
}
}
this.dataModels.add(XMLConfigParser.readDataModel(path));
}
}
Expand All@@ -176,3 +186,4 @@ private Collection<Path> getResources(String pattern) throws Exception {
return resourceList.getResourceList(pattern);
}
}
;
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,6 +32,7 @@ public QuerySetResult(QuerySet querySet) {
this.setNumberOfExecutions(querySet.getNumberOfExecutions());
this.setExecutionDurationInMs(querySet.getExecutionDurationInMs());
this.setExecutionType(querySet.getExecutionType());
this.setRandomPointRead(querySet.isRandomPointRead());
}

public QuerySetResult() {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,17 +18,20 @@

package org.apache.phoenix.pherf.result;

import org.apache.commons.collections.IteratorUtils;
import org.apache.phoenix.pherf.PherfConstants;
import org.apache.phoenix.pherf.result.file.ResultFileDetails;
import org.apache.phoenix.pherf.result.impl.CSVFileResultHandler;
import org.apache.phoenix.pherf.result.impl.ImageResultHandler;
import org.apache.phoenix.pherf.result.impl.XMLResultHandler;
import org.apache.phoenix.util.InstanceResolver;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ServiceLoader;

public class ResultManager {
private static final Logger logger = LoggerFactory.getLogger(ResultManager.class);
Expand DownExpand Up@@ -71,10 +74,25 @@ public ResultManager(String fileNameSeed) {
@SuppressWarnings("unchecked")
public ResultManager(String fileNameSeed, boolean writeRuntimeResults) {
this(fileNameSeed, writeRuntimeResults ?
InstanceResolver.get(ResultHandler.class, defaultHandlers) :
InstanceResolver.get(ResultHandler.class, minimalHandlers));
instanceResolverGet(ResultHandler.class, defaultHandlers) :
instanceResolverGet(ResultHandler.class, minimalHandlers));

}

// Workaround running against phoenix-4.4 not having this method in InstanceResolver.
@SuppressWarnings("unchecked")
public static <T> List<T> instanceResolverGet(Class<T> clazz, List<T> defaultInstances) {
Iterator<T> iterator = ServiceLoader.load(clazz).iterator();
if (defaultInstances != null) {
defaultInstances.addAll(IteratorUtils.toList(iterator));
} else {
defaultInstances = IteratorUtils.toList(iterator);
}

return defaultInstances;
}


public ResultManager(String fileNameSeed, List<ResultHandler> resultHandlers) {
this.resultHandlers = resultHandlers;
util = new ResultUtil();
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -139,6 +139,7 @@ public DataValue getDataValue(Column column) throws Exception{
}

switch (column.getType()) {

case VARCHAR:
// Use the specified data values from configs if they exist
if ((column.getDataValues() != null) && (column.getDataValues().size() > 0)) {
Expand All@@ -157,7 +158,11 @@ public DataValue getDataValue(Column column) throws Exception{
data = pickDataValueFromList(dataValues);
} else {
Preconditions.checkArgument(length > 0, "length needs to be > 0");
if (column.getDataSequence() == DataSequence.SEQUENTIAL) {

if(column.getDataSequence() == DataSequence.SUPERSEQUENTIAL) {
data = getSuperSequentialDataValue(column);
}
else if (column.getDataSequence() == DataSequence.SEQUENTIAL) {
data = getSequentialDataValue(column);
} else {
data = getRandomDataValue(column);
Expand DownExpand Up@@ -432,4 +437,14 @@ private DataValue getRandomDataValue(Column column) {
varchar = StringUtils.left(varchar, column.getLength());
return new DataValue(column.getType(), varchar);
}

private DataValue getSuperSequentialDataValue(Column column) {
DataValue data = null;
long inc = COUNTER.getAndIncrement();
String strInc = String.valueOf(inc);
String varchar = "user";
varchar = varchar + strInc;
data = new DataValue(column.getType(), varchar);
return data;
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,7 @@
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
Expand DownExpand Up@@ -242,6 +243,7 @@ public Future<Info> upsertData(final Scenario scenario, final List<Column> colum
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Connection connection = null;
PreparedStatement stmt = null;

try {
connection = pUtil.getConnection(scenario.getTenantId());
long logStartTime = System.currentTimeMillis();
Expand All@@ -253,13 +255,22 @@ public Future<Info> upsertData(final Scenario scenario, final List<Column> colum

last = start = System.currentTimeMillis();
String sql = buildSql(columns, tableName);
//System.out.print("going to create statement");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out code.


//System.out.print("statement created");
stmt = connection.prepareStatement(sql);
for (long i = rowCount; (i > 0) && ((System.currentTimeMillis() - logStartTime)
< maxDuration); i--) {
stmt = buildStatement(scenario, columns, stmt, simpleDateFormat);
rowsCreated += stmt.executeUpdate();

stmt = buildStatement(scenario, columns, stmt, simpleDateFormat);
//System.out.print(stmt);
stmt.addBatch();
//rowsCreated += stmt.executeUpdate();
if ((i % getBatchSize()) == 0) {
//System.out.print("Executing batch");
stmt.executeBatch();
connection.commit();
//stmt.clearBatch();
duration = System.currentTimeMillis() - last;
logger.info("Writer (" + Thread.currentThread().getName()
+ ") committed Batch. Total " + getBatchSize()
Expand All@@ -281,6 +292,8 @@ public Future<Info> upsertData(final Scenario scenario, final List<Column> colum
}
} finally {
if (stmt != null) {
System.out.print("Executing batch");
stmt.executeBatch();
stmt.close();
}
if (connection != null) {
Expand All@@ -307,7 +320,7 @@ private PreparedStatement buildStatement(Scenario scenario, List<Column> columns
PreparedStatement statement, SimpleDateFormat simpleDateFormat) throws Exception {
int count = 1;
for (Column column : columns) {

//System.out.print("Column is " + column.getName());
DataValue dataValue = getRulesApplier().getDataForRule(scenario, column);
switch (column.getType()) {
case VARCHAR:
Expand All@@ -318,6 +331,7 @@ private PreparedStatement buildStatement(Scenario scenario, List<Column> columns
}
break;
case CHAR:
//System.out.print("Data value "+ dataValue.getValue());
if (dataValue.getValue().equals("")) {
statement.setNull(count, Types.CHAR);
} else {
Expand DownExpand Up@@ -354,6 +368,7 @@ private PreparedStatement buildStatement(Scenario scenario, List<Column> columns
}
count++;
}
//System.out.print("Returning statement " + statement.toString());
return statement;
}

Expand Down