Skip to content

Instantly share code, notes, and snippets.

View burtonator's full-sized avatar

Kevin Burton burtonator

View GitHub Profile
{
"bucket" : 1428951900070,
"sequence" : 1428951959000012001,
"hashcode" : "pkD2mJAo3516JOLgLmXSJ4wtJj4",
"resource" : "http://theglobeandmail.com/news/world/man-sought-after-nc-community-college-employee-killed/article23900584/comments",
"date_found" : "2015-04-13T19:05:59Z",
"index_method" : "PERMALINK_TASK",
"detection_method" : "SOURCE",
"lang" : "en",
"source_hashcode" : "FpCN4NfCkLoMqKWRpCLcQ9zwiRs",
{
"bucket" : 1428951900070,
"sequence" : 1428951959000012001,
"hashcode" : "pkD2mJAo3516JOLgLmXSJ4wtJj4",
"resource" : "http://theglobeandmail.com/news/world/man-sought-after-nc-community-college-employee-killed/article23900584/comments",
"date_found" : "2015-04-13T19:05:59Z",
"index_method" : "PERMALINK_TASK",
"detection_method" : "SOURCE",
"lang" : "en",
"source_hashcode" : "FpCN4NfCkLoMqKWRpCLcQ9zwiRs",
{
"bucket" : 1429224600002,
"sequence" : 1429224655000012527,
"hashcode" : "ltLxymayA_rsi-hpRCk3hDjwuRI",
"resource" : "http://independent.co.uk/news/uk/politics/generalelection/donald-macintyres-sketch-are-you-watching-david-this-is-for-you-10183377.html",
"date_found" : "2015-04-16T22:50:55Z",
"index_method" : "PERMALINK_TASK",
"detection_method" : "SOURCE",
"lang" : "en",
"source_hashcode" : "LRHRdQh0Bom-tWE3oRgKMr4bdU8",
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
public final class Scheduler extends ServiceSupport {
private final String name;
private Timer timer;
private final HashMap<Runnable, TimerTask> timerTasks = new HashMap<Runnable, TimerTask>();
public Scheduler(String name) {
this.name = name;
}
public synchronized void cancel(Runnable task) {
SchedulerTimerTask ticket = timerTasks.remove(task);
if (ticket != null) {
ticket.cancel();
// now clear the ticket so we can remove the reference to the
// underlying task. This is necessary to allow GC to take effect.
// Otherwise the Runnable will still have a reference and hog
// memory.
ticket.clear();
}
public class SchedulerTimerTask extends TimerTask {
private final AtomicReference<Runnable> task = new AtomicReference<Runnable>( null );
public SchedulerTimerTask(Runnable task) {
this.task.set( task );
}
public void run() {
{
"took" : 4421,
"timed_out" : false,
"_shards" : {
"total" : 20,
"successful" : 20,
"failed" : 0
},
"hits" : {
"total" : 18558,
{
"took" : 2021,
"timed_out" : false,
"_shards" : {
"total" : 200,
"successful" : 200,
"failed" : 0
},
"hits" : {
package com.spinn3r.artemis.scheduler.activemq;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.RedeliveryPolicy;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.util.IdGenerator;
import org.junit.Before;
import org.junit.Test;