NOTE: 534 stars, 106 forks. I love you all. Please contribute tips and edits back to this cheat sheet -- email's [email protected] and you can treat gists like git repositories and send git diffs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
...domain model | |
@NodeEntity | |
public class Member { | |
@GraphId | |
private Long graphId; | |
@Indexed |