Skip to content

Commit

Permalink
adding new articles benchmark. first cut. wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Atreyee committed Mar 2, 2014
1 parent 763f6c7 commit 5b2abf1
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 0 deletions.
6 changes: 6 additions & 0 deletions properties/benchmarks/articles.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## ------------------------------------------------------------
## H-Store Benchmark Configuration Parameters
## ------------------------------------------------------------

builder = edu.brown.benchmark.articles.ArticlesProjectBuilder
datadir = src/benchmarks/edu/brown/benchmark/articles/data
79 changes: 79 additions & 0 deletions src/benchmarks/edu/brown/benchmark/articles/ArticlesClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package edu.brown.benchmark.articles;
import java.io.IOException;
import java.util.Random;
import org.voltdb.client.*;
import edu.brown.api.BenchmarkComponent;

public class ArticlesClient extends BenchmarkComponent {

public static void main(String args[]) {
BenchmarkComponent.main(ArticlesClient.class, args, false);
}

public ArticlesClient(String[] args) {
super(args);
for (String key : m_extraParams.keySet()) {
// TODO: Retrieve extra configuration parameters
} // FOR
}

@Override
public void runLoop() {
try {
Client client = this.getClientHandle();
Random rand = new Random();
while (true) {
// Select a random transaction to execute and generate its input parameters
// The procedure index (procIdx) needs to the same as the array of procedure
// names returned by getTransactionDisplayNames()
int procIdx = rand.nextInt(ArticlesProjectBuilder.PROCEDURES.length);
String procName = ArticlesProjectBuilder.PROCEDURES[procIdx].getSimpleName();
Object procParams[] = null; // TODO

// Create a new Callback handle that will be executed when the transaction completes
Callback callback = new Callback(procIdx);

// Invoke the stored procedure through the client handle. This is non-blocking
client.callProcedure(callback, procName, procIdx);

// Check whether all the nodes are backed-up and this client should block
// before sending new requests.
client.backpressureBarrier();
} // WHILE
} catch (NoConnectionsException e) {
// Client has no clean mechanism for terminating with the DB.
return;
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
// At shutdown an IOException is thrown for every connection to
// the DB that is lost Ignore the exception here in order to not
// get spammed, but will miss lost connections at runtime
}
}

private class Callback implements ProcedureCallback {
private final int idx;

public Callback(int idx) {
this.idx = idx;
}
@Override
public void clientCallback(ClientResponse clientResponse) {
// Increment the BenchmarkComponent's internal counter on the
// number of transactions that have been completed
incrementTransactionCounter(clientResponse, this.idx);
}
} // END CLASS

@Override
public String[] getTransactionDisplayNames() {
// Return an array of transaction names
String procNames[] = new String[ArticlesProjectBuilder.PROCEDURES.length];
for (int i = 0; i < procNames.length; i++) {
procNames[i] = ArticlesProjectBuilder.PROCEDURES[i].getSimpleName();
}
return (procNames);
}
}

45 changes: 45 additions & 0 deletions src/benchmarks/edu/brown/benchmark/articles/ArticlesLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package edu.brown.benchmark.articles;
import org.voltdb.CatalogContext;
import org.voltdb.VoltTable;
import org.voltdb.catalog.*;
import org.voltdb.client.Client;

import edu.brown.api.Loader;
import edu.brown.catalog.CatalogUtil;
import edu.brown.api.BenchmarkComponent;

public class ArticlesLoader extends Loader{

public static void main(String args[]) throws Exception {
BenchmarkComponent.main(ArticlesLoader.class, args, true);
}

public ArticlesLoader(String[] args) {
super(args);
for (String key : m_extraParams.keySet()) {
// TODO: Retrieve extra configuration parameters
} // FOR
}

@Override
public void load() {
// The catalog contains all the information about the database (e.g., tables, columns, indexes)
// It is loaded from the benchmark's project JAR file
// Catalog
CatalogContext _catalog = this.getCatalogContext();
Catalog catalog = _catalog.catalog;

// Iterate over all of the Table handles in the catalog and generate
// tuples to upload into the database
for (Table catalog_tbl : CatalogUtil.getDatabase(catalog).getTables()) {
// TODO: Create an empty VoltTable handle and then populate it in batches to
// be sent to the DBMS
VoltTable table = CatalogUtil.getVoltTable(catalog_tbl);

// Invoke the BenchmarkComponent's data loading method
// This will upload the contents of the VoltTable into the DBMS cluster
this.loadVoltTable(catalog_tbl.getName(), table);
} // FOR
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package edu.brown.benchmark.articles;
import org.voltdb.VoltProcedure;

import edu.brown.benchmark.AbstractProjectBuilder;
import edu.brown.api.BenchmarkComponent;
import edu.brown.benchmark.articles.procedures.*;

public class ArticlesProjectBuilder extends AbstractProjectBuilder{

// REQUIRED: Retrieved via reflection by BenchmarkController
public static final Class<? extends BenchmarkComponent> m_clientClass = ArticlesClient.class;

// REQUIRED: Retrieved via reflection by BenchmarkController
public static final Class<? extends BenchmarkComponent> m_loaderClass = ArticlesLoader.class;

public static final Class<?> PROCEDURES[] = new Class<?>[] {
GetArticle.class,
};
public static final String PARTITIONING[][] = new String[][] {
// { "TABLE NAME", "PARTITIONING COLUMN NAME" }
{"TABLEA", "A_ID"},
{"TABLEB", "B_A_ID"},
};

@SuppressWarnings("unchecked")
public ArticlesProjectBuilder() {
super("Articles", ArticlesProjectBuilder.class, (Class<? extends VoltProcedure>[]) PROCEDURES, PARTITIONING);

}

}

47 changes: 47 additions & 0 deletions src/benchmarks/edu/brown/benchmark/articles/articles-ddl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-- ================================================================
-- USER
-- Represents users
-- u_id User ID
-- u_firstname User's first name
-- u_lastname User's last name
-- u_password User's password
-- u_email User's email
-- ================================================================
CREATE TABLE USER (
u_id BIGINT NOT NULL,
u_firstname VARCHAR(100),
u_lastname VARCHAR(100),
u_password VARCHAR(100),
u_email VARCHAR(100),
PRIMARY KEY (u_id)
);
-- ================================================================
-- ARTICLE
-- Represents articles
-- a_id ID
-- a_title Article's title
-- a_text Article's content
-- a_num_comments Number of comments on the article
-- ================================================================
CREATE TABLE ARTICLES (
a_id BIGINT NOT NULL,
a_title VARCHAR(100),
a_text VARCHAR(100),
a_num_comments BIGINT,
PRIMARY KEY (a_id)
);
-- ================================================================
-- COMMENTS
-- Represents comments provided by buyers
-- c_id Comment's ID
-- a_id Article's ID
-- u_id User's ID
-- c_text Actual comment text
-- ================================================================
CREATE TABLE COMMENT (
c_id BIGINT NOT NULL,
a_id BIGINT NOT NULL REFERENCES ARTICLES (a_id),
u_id BIGINT NOT NULL REFERENCES USERS (u_id),
c_text VARCHAR(100),
PRIMARY KEY (c_id)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package edu.brown.benchmark.articles.procedures;
import org.voltdb.*;

public class GetArticle extends VoltProcedure{

public final SQLStmt GetArticle = new SQLStmt("SELECT * FROM ARTICLES WHERE A_ID = ? ");

public VoltTable[] run(long a_id) {
voltQueueSQL(GetArticle, a_id);
return (voltExecuteSQL());
}

}
1 change: 1 addition & 0 deletions src/frontend/edu/brown/utils/ProjectType.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public enum ProjectType {
VOTER("Voter", "edu.brown.benchmark.voter"),
SMALLBANK("SmallBank", "edu.brown.benchmark.smallbank"),
EXAMPLE("Example", "edu.brown.benchmark.example"),
ARTICLES ("Articles", "edu.brown.benchmark.articles"),
TEST("Test", null),
;

Expand Down

0 comments on commit 5b2abf1

Please sign in to comment.