Skip to content

Instantly share code, notes, and snippets.

View InputNeuron's full-sized avatar

Kevin Burton InputNeuron

View GitHub Profile
curl -XGET 'http://acme.elasticsearch.spinn3r.com/content*/_search?pretty=true' --header "X-vendor: acme" --header "X-vendor-auth: vKkYntP73c1IVZddxXnvRorPQiHo" -d '{
"size": 1,
"query" : {
"term" : { "main" : "firefox" }
}
}
'
POST /content_*/_search HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 131
Content-Type: application/json
Host: localhost:9200
User-Agent: HTTPie/0.9.2
{
{
"query": {
"query_string": {
"query": "source_publisher_type:MAINSTREAM_NEWS"
}
},
"filter": {
"range": {
"date_found": {
"gte": "2015-07-21T10:25:15Z",
{
"query": {
"query_string": {
"query": "source_publisher_type:MAINSTREAM_NEWS"
}
},
"filter": {
"range": {
"date_found": {
"gte": "2015-07-21T10:25:15Z",
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;
{
"took" : 2021,
"timed_out" : false,
"_shards" : {
"total" : 200,
"successful" : 200,
"failed" : 0
},
"hits" : {
{
"took" : 4421,
"timed_out" : false,
"_shards" : {
"total" : 20,
"successful" : 20,
"failed" : 0
},
"hits" : {
"total" : 18558,
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() {
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 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;
}