Skip to content

Instantly share code, notes, and snippets.

View seiyak's full-sized avatar

Seiya Kawashima seiyak

  • The University of Chicago
  • Chicago, IL
View GitHub Profile
@seiyak
seiyak / 1. SampleTest derived from TestCase
Created April 4, 2012 14:47
In 1), one method is treated as a test and run. In 2) no test is run since there are no methods annotated by @test and it's not derived from TestCase.
public class SampleTest extends TestCase{
private Sample sample;
public static void main(String args[]) {
System.out.println( "main is running ...." );
}
@Before
public void setUp() throws Exception {
@seiyak
seiyak / 1.Original setNextValue() method with exclusive lock.
Created February 24, 2012 21:16
The original implementation for VoldemortDatastoreProvider.setNextValue() totally blocks concurrency because of the exclusive lock. The second version allows concurrency but I'm not sure if it's the right way to calculate next values.
public void setNextValue(RowKey key, IntegralDataTypeHolder value, int increment, int initialValue) {
this.lock.lock();
try {
Versioned v = this.getValue(this.getVoldemortSequecenStoreName(),
this.toJSON(key.getRowKeyAsMap()), true);
if (v == null) {
Map<String, Integer> nextSequence = new HashMap<String, Integer>();
nextSequence.put("nextSequence", initialValue);
@seiyak
seiyak / my first fist
Created February 24, 2012 21:13
sample gist
hello world