|
|
package com.yohoufo.common.alarm;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yohoufo.common.constant.InfluxdbFieldEnum;
|
|
|
import com.yohoufo.common.constant.InfluxdbMeasurementEnum;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by li.ma on 2019/2/26.
|
|
|
*/
|
|
|
public class UfoInfluxdbVo {
|
|
|
|
|
|
|
|
|
private String eventType;
|
|
|
|
|
|
private String measurement;
|
|
|
|
|
|
private Map<String, String> tags;
|
|
|
|
|
|
private Map<String, Object> fields;
|
|
|
|
|
|
public String getEventType() {
|
|
|
return eventType;
|
|
|
}
|
|
|
|
|
|
public void setEventType(String eventType) {
|
|
|
this.eventType = eventType;
|
|
|
}
|
|
|
|
|
|
public Map<String, String> getTags() {
|
|
|
return tags;
|
|
|
}
|
|
|
|
|
|
public void setTags(Map<String, String> tags) {
|
|
|
this.tags = tags;
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getFields() {
|
|
|
return fields;
|
|
|
}
|
|
|
|
|
|
public void setFields(Map<String, Object> fields) {
|
|
|
this.fields = fields;
|
|
|
}
|
|
|
|
|
|
public String getMeasurement() {
|
|
|
return measurement;
|
|
|
}
|
|
|
|
|
|
public void setMeasurement(String measurement) {
|
|
|
this.measurement = measurement;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String toString() {
|
|
|
return JSONObject.toJSONString(this);
|
|
|
}
|
|
|
|
|
|
public static class Builder {
|
|
|
private String eventType;
|
|
|
|
|
|
private String measurement;
|
|
|
|
|
|
private Map<String, String> tags;
|
|
|
|
|
|
private Map<String, Object> fields = new HashMap<>();
|
|
|
|
|
|
public Builder setEventType(String eventType) {
|
|
|
this.eventType = eventType;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
public Builder setTags(Map<String, String> tags) {
|
|
|
this.tags = tags;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
|
|
|
public Builder setFields(Map<String, Object> fields) {
|
|
|
this.fields = fields;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
public Builder addInitField(InfluxdbFieldEnum fieldEnum) {
|
|
|
this.fields.put(fieldEnum.getFiledName(), 1);
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
public Builder addField(String fieldName, Object fieldValue) {
|
|
|
this.fields.put(fieldName, fieldValue);
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
|
|
|
public Builder setMeasurement(InfluxdbMeasurementEnum measurementEnum) {
|
|
|
this.measurement = measurementEnum.getMeasurement();
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
|
|
|
public UfoInfluxdbVo build() {
|
|
|
UfoInfluxdbVo event = new UfoInfluxdbVo();
|
|
|
event.setFields(this.fields);
|
|
|
event.setMeasurement(this.measurement);
|
|
|
event.setTags(this.tags);
|
|
|
event.setEventType(this.eventType);
|
|
|
return event;
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|