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 java.nio.ByteBuffer; | |
import java.util.Random; | |
public class BufferPerformanceComparison { | |
public final static int MEGA_BYTE = 1024 * 1024; | |
public final static long GIGA_BYTE = MEGA_BYTE * 1024; | |
private final ByteBuffer heapByteBuffer; | |
private final ByteBuffer offHeapByteBuffer; | |
private final long dataToLoad; | |
private final int bufferSize; |
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
//Quartz 1.8.4 Example 2 | |
// First we must get a reference to a scheduler | |
SchedulerFactory sf = new StdSchedulerFactory(); | |
Scheduler sched = sf.getScheduler(); | |
log.info("------- Initialization Complete -----------"); | |
log.info("------- Scheduling Jobs -------------------"); | |
// computer a time that is on the next round minute |
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
//Quartz scheduler Example 2 from 1.8.3 | |
// job3 will run 11 times (run once and repeat 10 more times) | |
// job3 will repeat every 10 seconds (10000 ms) | |
job = new JobDetail("job3", "group1", SimpleJob.class); | |
trigger = new SimpleTrigger("trigger3", "group1", "job3", "group1", | |
new Date(ts), null, 10, 10000L); | |
ft = sched.scheduleJob(job, trigger); | |
// the same job (job3) will be scheduled by a another trigger |
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
//Quartz 1.8.4 Example 3 snippet | |
// job 7 will run every 30 seconds but only on Weekends (Saturday and | |
// Sunday) | |
job = new JobDetail("job7", "group1", SimpleJob.class); | |
trigger = new CronTrigger("trigger7", "group1", "job7", "group1", | |
"0,30 * * ? * SAT,SUN"); | |
sched.addJob(job, true); | |
ft = sched.scheduleJob(trigger); |
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
<repositories> | |
<repository> | |
<id>terracotta-snapshots</id> | |
<name>Terracotta Repo</name> | |
<url>http://www.terracotta.org/download/reflector/releases</url> | |
</repository> | |
</repositories> | |
<pluginRepositories> | |
<pluginRepository> |
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
Query query = cache.createQuery(); | |
query.includeKeys(); | |
query.includeValues(); | |
query.addCriteria(name.ilike(“Greg*”).and(gender.eq(Gender.MALE))).addOrderBy(age, Direction.ASCENDING).maxResults(10); | |
Results results = query.execute(); | |
System.out.println(” Size: ” + results.size()); | |
for (Result result : results.all()) { | |
System.out.println(“Got: Key[" + result.getKey() + "] Value class [" + result.getValue().getClass() + "] Value [" + result.getValue() + "]“); | |
} |
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
Configuration config; | |
FactoryConfiguration factoryConfig = new FactoryConfiguration(); | |
factoryConfig.setClass("org.terracotta.ehcachedx.monitor.probe.ProbePeerListenerFactory"); | |
factoryConfig.setProperties("monitorAddress=localhost, monitorPort=9889"); | |
config.addCacheManagerPeerListenerFactory(factoryConfig); | |
... and in pom.xml: | |
<dependency> | |
<groupId>org.terracotta</groupId> |
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
albums = getAllAlbumsBy(artist); | |
songs = getAllSongs(artist); | |
printSongCountHeader(songs.size()); | |
pringAlbumCountHeader(albums.size()); |
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
public Collection getAllAlbumsBy(Artist artist){ | |
List results = new ArrayList(); | |
for(Iterator i = getAllAlbums();i.hasNext();){ | |
Album album = (Album)i.next(); | |
if(album.isBy(artist)){ | |
results.add(album); | |
} | |
} | |
return results; |
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
//Go from this | |
<ehcache> | |
// to this | |
<ehcache maxBytesLocalHeap="100M" > | |
// or | |
<ehcache maxBytesLocalHeap="50%" > |
OlderNewer