Skip to content

Instantly share code, notes, and snippets.

View mikeycmccarthy's full-sized avatar

Michael McCarthy mikeycmccarthy

View GitHub Profile
@mikeycmccarthy
mikeycmccarthy / winrestrictioncheck
Created April 20, 2012 07:20
Testing win restriction dates
import org.joda.time.DateTime;
import org.joda.time.DateTimeUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
// NodeManager
public <T extends PropertyContainer> T indexPutIfAbsent( Index<T> index, T entity, String key, Object value )
{
T existing = index.get( key, value ).getSingle();
if ( existing != null ) return existing;
// Grab lock
IndexLock lock = new IndexLock( index.getName(), key );
@Test
public void testUniquenessInMultiThreadedScenario() throws Exception {
final Long firstMember = 100L;
final List<Exception> exceptionList = new ArrayList<Exception>();
ExecutorService exec = Executors.newFixedThreadPool(16);
for (int i = 101; i < 1000; i++) {
final Long buddyId = new Long(i);
@mikeycmccarthy
mikeycmccarthy / gist:1663559
Created January 23, 2012 15:05
Single Relationship Persistance
...domain model
@NodeEntity
public class Member {
@GraphId
private Long graphId;
@Indexed