diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/watcher/execution/Wid.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/watcher/execution/Wid.java index e0767daa9d0..a9378584eef 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/watcher/execution/Wid.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/watcher/execution/Wid.java @@ -5,24 +5,35 @@ */ package org.elasticsearch.xpack.watcher.execution; -import org.elasticsearch.common.UUIDs; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.ISODateTimeFormat; +import java.util.UUID; + import static org.elasticsearch.xpack.watcher.support.Exceptions.illegalArgument; +/** + * A representation class of a watch id, its execution time and a random UUID + * This class exists to be able to store several events from the same possible execution time and the same watch + * in the triggered store index or the history store + * + * One 'specialty' of this class is the handling of the underscore in the value. Nothing except the watchId should contain an + * underscore, otherwise this class will not be able to extract the proper watch id, when a a single string is handed over in its ctor + * + * This is also the reason why UUID.randomUUID() is used instead of UUIDs.base64UUID(), as the latter one contains underscores. Also this + * is not dependant on having time based uuids here, as the time is already included in the value + */ public class Wid { private static final DateTimeFormatter formatter = ISODateTimeFormat.dateTime(); private final String watchId; - private final String value; public Wid(String watchId, DateTime executionTime) { this.watchId = watchId; - this.value = watchId + "_" + UUIDs.base64UUID().replaceAll("_", "-") + "-" + formatter.print(executionTime); + this.value = watchId + "_" + UUID.randomUUID().toString() + "-" + formatter.print(executionTime); } public Wid(String value) {