com.yahoo.ycsb.db
Class ShardClient

java.lang.Object
  extended by com.yahoo.ycsb.DB
      extended by com.yahoo.ycsb.db.ShardClient

public class ShardClient
extends DB

A client for the simple sharded MySQL called shardserver.


Field Summary
 boolean _debug
           
 boolean _donothing
           
static int HttpError
           
static int NoMatchingRecord
           
static java.lang.String NoMatchingRecordString
           
static int Ok
           
static int ServerError
           
 long TotalGetOps
           
 long TotalGetTime
           
 long TotalPostOps
           
 long TotalPostTime
           
static java.lang.String UrlPrefix
           
 
Constructor Summary
ShardClient()
           
 
Method Summary
 void cleanup()
          Cleanup any state for this DB.
 int delete(java.lang.String table, java.lang.String key)
          Delete a record from the database.
 java.util.Vector<char[]> doGet(java.lang.String url)
          Do a GET HTTP call.
 java.lang.String doPost(java.lang.String url, java.lang.String postbody)
          Do a POST HTTP call.
 void init()
          Initialize any state for this DB.
 int insert(java.lang.String table, java.lang.String key, java.util.HashMap<java.lang.String,java.lang.String> values)
          Insert a record in the database.
static void main(java.lang.String[] args)
          Simple test.
 int read(java.lang.String table, java.lang.String key, java.util.Set<java.lang.String> fields, java.util.HashMap<java.lang.String,java.lang.String> result)
          Read a record from the database.
 int scan(java.lang.String table, java.lang.String startkey, int recordcount, java.util.Set<java.lang.String> fields, java.util.Vector<java.util.HashMap<java.lang.String,java.lang.String>> result)
          Perform a range scan for a set of records in the database.
 int update(java.lang.String table, java.lang.String key, java.util.HashMap<java.lang.String,java.lang.String> values)
          Update a record in the database.
 
Methods inherited from class com.yahoo.ycsb.DB
getProperties, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UrlPrefix

public static final java.lang.String UrlPrefix
See Also:
Constant Field Values

NoMatchingRecordString

public static final java.lang.String NoMatchingRecordString
See Also:
Constant Field Values

Ok

public static final int Ok
See Also:
Constant Field Values

ServerError

public static final int ServerError
See Also:
Constant Field Values

HttpError

public static final int HttpError
See Also:
Constant Field Values

NoMatchingRecord

public static final int NoMatchingRecord
See Also:
Constant Field Values

_debug

public boolean _debug

_donothing

public boolean _donothing

TotalGetTime

public long TotalGetTime

TotalGetOps

public long TotalGetOps

TotalPostTime

public long TotalPostTime

TotalPostOps

public long TotalPostOps
Constructor Detail

ShardClient

public ShardClient()
Method Detail

init

public void init()
          throws DBException
Initialize any state for this DB. Called once per DB instance; there is one DB instance per client thread.

Overrides:
init in class DB
Throws:
DBException

cleanup

public void cleanup()
             throws DBException
Cleanup any state for this DB. Called once per DB instance; there is one DB instance per client thread.

Overrides:
cleanup in class DB
Throws:
DBException

doGet

public java.util.Vector<char[]> doGet(java.lang.String url)
                               throws DBException
Do a GET HTTP call. Returns the results in a Vector of char[] blocks.

Throws:
DBException

doPost

public java.lang.String doPost(java.lang.String url,
                               java.lang.String postbody)
                        throws DBException
Do a POST HTTP call. Returns the result as a String.

Throws:
DBException

read

public int read(java.lang.String table,
                java.lang.String key,
                java.util.Set<java.lang.String> fields,
                java.util.HashMap<java.lang.String,java.lang.String> result)
Read a record from the database. Each field/value pair from the result will be stored in a HashMap.

Specified by:
read in class DB
Parameters:
table - The name of the table
key - The record key of the record to read.
fields - The list of fields to read, or null for all of them
result - A HashMap of field/value pairs for the result
Returns:
Zero on success, a non-zero error code on error

scan

public int scan(java.lang.String table,
                java.lang.String startkey,
                int recordcount,
                java.util.Set<java.lang.String> fields,
                java.util.Vector<java.util.HashMap<java.lang.String,java.lang.String>> result)
Perform a range scan for a set of records in the database. Each field/value pair from the result will be stored in a HashMap.

Specified by:
scan in class DB
Parameters:
table - The name of the table
startkey - The record key of the first record to read.
recordcount - The number of records to read
fields - The list of fields to read, or null for all of them
result - A Vector of HashMaps, where each HashMap is a set field/value pairs for one record
Returns:
Zero on success, a non-zero error code on error

update

public int update(java.lang.String table,
                  java.lang.String key,
                  java.util.HashMap<java.lang.String,java.lang.String> values)
Update a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified record key, overwriting any existing values with the same field name.

Specified by:
update in class DB
Parameters:
table - The name of the table
key - The record key of the record to write.
values - A HashMap of field/value pairs to update in the record
Returns:
Zero on success, a non-zero error code on error

insert

public int insert(java.lang.String table,
                  java.lang.String key,
                  java.util.HashMap<java.lang.String,java.lang.String> values)
Insert a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified record key.

Specified by:
insert in class DB
Parameters:
table - The name of the table
key - The record key of the record to insert.
values - A HashMap of field/value pairs to insert in the record
Returns:
Zero on success, a non-zero error code on error

delete

public int delete(java.lang.String table,
                  java.lang.String key)
Delete a record from the database.

Specified by:
delete in class DB
Parameters:
table - The name of the table
key - The record key of the record to delete.
Returns:
Zero on success, a non-zero error code on error

main

public static void main(java.lang.String[] args)
Simple test.