In case you want to use models only, you can use the InfluxDBMapper to save and load measurements. You can create models that specify the database the measurement and the retention policy.
@Measurement(name = "cpu",database="servers", retentionPolicy="autogen",timeUnit = TimeUnit.MILLISECONDS)
public class Cpu {
@Column(name = "time")
private Instant time;
@Column(name = "host", tag = true)
private String hostname;
@Column(name = "region", tag = true)
private String region;
@Column(name = "idle")
private Double idle;
@Column(name = "happydevop")
private Boolean happydevop;
@Column(name = "uptimesecs")
private Long uptimeSecs;
// getters (and setters if you need)
}
Save operation using a model.
Cpu cpu = .., create the cpu measure
influxDBMapper.save(cpu);
Load data using a model.
Cpu persistedCpu = influxDBMapper.query(Cpu.class).get(0);
Load data using a query and specify the model for mapping.
Query query = ... create your query
List<Cpu> persistedMeasure = influxDBMapper.query(query,Cpu.class);
Tags are automatically converted to strings, since tags are strings to influxdb Supported values for fields are boolean, int, long, double, Boolean, Integer, Long, Double. The time field should be of type instant. If you do not specify the time or set a value then the current system time shall be used with the timeunit specified.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。