Add priority to AtomEvent
@@ -10,6 +10,7 @@ import org.apache.jena.riot.LangBuilder;
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.riot.RDFFormat;
+import won.matcher.service.common.mailbox.PriorityAtomEventMailbox;
import won.matcher.service.common.service.sparql.SparqlService;
/**
@@ -25,12 +26,38 @@ public class AtomEvent implements Serializable {
private String serializationLangContentType;
private long crawlDate;
private TYPE eventType;
+ private Priority priority;
+
+ /**
+ * Indicates the priority this event should be given by matchers. The priority
+ * should be given based on how the event was generated. Used in the
+ * {@link PriorityAtomEventMailbox}; lower priority values means more important.
+ */
+ public static enum Priority {
+ PUSHED(0), // we received a push about this Atom from a WoN node. React fast!
+ SCHEDULED_FOR_REMATCH(5), // we decided it's time to re-match for this Atom. Should be handled before
+ // events generated in crawling
+ CRAWLED(10), // we found this Atom during crawling. Handle when we have nothing else to do
+ ;
+ private int priority;
+
+ private Priority(int prio) {
+ this.priority = prio;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public static int LOWEST_PRIORTY = Integer.MAX_VALUE;
+ }
public static enum TYPE {
ACTIVE, INACTIVE
}
- public AtomEvent(String uri, String wonNodeUri, TYPE eventType, long crawlDate, String resource, Lang format) {
+ public AtomEvent(String uri, String wonNodeUri, TYPE eventType, long crawlDate, String resource, Lang format,
+ Priority priority) {
this.uri = uri;
this.wonNodeUri = wonNodeUri;
this.eventType = eventType;
@@ -40,7 +67,7 @@ public class AtomEvent implements Serializable {
serializationLangContentType = format.getContentType().getContentType();
}
- public AtomEvent(String uri, String wonNodeUri, TYPE eventType, long crawlDate, Dataset ds) {
+ public AtomEvent(String uri, String wonNodeUri, TYPE eventType, long crawlDate, Dataset ds, Priority priority) {
this.uri = uri;
this.wonNodeUri = wonNodeUri;
this.eventType = eventType;
@@ -64,6 +91,10 @@ public class AtomEvent implements Serializable {
return eventType;
}
+ public Priority getPriority() {
+ return priority;
+ }
+
public String getSerializedAtomResource() {
return serializedAtomResource;
}
@@ -84,7 +115,7 @@ public class AtomEvent implements Serializable {
@Override
public AtomEvent clone() {
AtomEvent e = new AtomEvent(uri, wonNodeUri, eventType, crawlDate, serializedAtomResource,
- getSerializationFormat());
+ getSerializationFormat(), priority);
return e;
}
