####################
### MQTT Broker Configuration
####################
# whether to enable the mqtt service.
enable_mqtt_service=false # 修改成 true , 代表开启 mqtt服务
# the mqtt service binding host.
mqtt_host=0.0.0.0 # ip
# the mqtt service binding port.
mqtt_port=1883 # 端口
# the handler pool size for handing the mqtt messages.
mqtt_handler_pool_size=1
# the mqtt message payload formatter.
mqtt_payload_formatter=json # 数据格式
# max length of mqtt message in byte
mqtt_max_message_size=1048576
设置一个存储组到IOTDB,名为root : IoTDB> SET STORAGE GROUP TO root
查看当前IOTDB的存储组 : IoTDB> SHOW STORAGE GROUP
IoTDB> SHOW STORAGE GROUP
+-------------+
|storage group|
+-------------+
| root.test|
+-------------+
Total line number = 1
It costs 0.127s
查看系统中存在的所有时间序列 : IoTDB> SHOW TIMESERIES
IoTDB> show timeseries
+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+
| timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+
|root.test.wf01.wt01.temperature| null| root.test| FLOAT| GORILLA| SNAPPY|null| null|
| root.test.wf01.wt01.status| null| root.test| BOOLEAN| RLE| SNAPPY|null| null|
| root.test.wf01.wt01.hardware| null| root.test| TEXT| PLAIN| SNAPPY|null| null|
+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+
Total line number = 3
It costs 0.009s
查看系统中存在的特定时间序列: SHOW TIMESERIES root.test.wf01.wt01.status
IoTDB> SHOW TIMESERIES root.test.wf01.wt01.status
+--------------------------+-----+-------------+--------+--------+-----------+----+----------+
| timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
+--------------------------+-----+-------------+--------+--------+-----------+----+----------+
|root.test.wf01.wt01.status| null| root.test| BOOLEAN| RLE| SNAPPY|null| null|
+--------------------------+-----+-------------+--------+--------+-----------+----+----------+
Total line number = 1
It costs 0.003s
插入数据 INSERT INTO root.test.wf01.wt01(timestamp,status,temperature) values(200,false,20.71)
IoTDB> INSERT INTO root.test.wf01.wt01(timestamp,status,temperature) values(200,false,20.71)
Msg: The statement is executed successfully.
查看数据: select * from root.test;
IoTDB> select * from root.test;
+------------------------+-------------------------------+--------------------------+----------------------------+
| Time|root.test.wf01.wt01.temperature|root.test.wf01.wt01.status|root.test.wf01.wt01.hardware|
+------------------------+-------------------------------+--------------------------+----------------------------+
|2021-01-20T02:00:00.000Z| 21.2| true| hello|
+------------------------+-------------------------------+--------------------------+----------------------------+
Total line number = 1
It costs 0.077s
查看设备:show devices
IoTDB> show devices
+-------------------+
| devices|
+-------------------+
|root.test.wf01.wt01|
+-------------------+
Total line number = 1
It costs 0.002s
mqtt to iotdb
代码
构建一个实体对象,用于存储
package wang.datahub.iotdb;
import com.google.gson.Gson;
import java.util.List;
public class IotdbVO {
private String device;
private long timestamp = System.currentTimeMillis();
private List measurements;
private List
模拟数据发射到iotdb
package wang.datahub.iotdb;
import org.fusesource.mqtt.client.BlockingConnection;
import org.fusesource.mqtt.client.MQTT;
import org.fusesource.mqtt.client.QoS;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class EmmitToIotdb {
public static void main(String[] args) {
String[] hardwares = new String[]{
"a1",
"b1",
"b2",
"c3",
"d1",
"f5"
};
int count = 1000;
for(int i = 0; i < count ;i++){
IotdbVO iotdbVO = new IotdbVO();
iotdbVO.setDevice("root.test.wf01.wt01");
List measurements = new ArrayList<>();
List values = new ArrayList<>();
measurements.add("temperature");
measurements.add("status");
measurements.add("hardware");
Random r = new Random();
values.add(r.nextInt(40));
values.add(r.nextBoolean());
values.add(hardwares[r.nextInt(hardwares.length)]);
iotdbVO.setMeasurements(measurements);
iotdbVO.setValues(values);
emmitToIotdb(iotdbVO);
}
}
public static void emmitToIotdb(IotdbVO content){
try {
MQTT mqtt = new MQTT();
mqtt.setHost("127.0.0.1", 1883);
mqtt.setUserName("root");
mqtt.setPassword("root");
BlockingConnection connection = mqtt.blockingConnection();
connection.connect();
String payload = content.toJson();
connection.publish(content.getDevice(),payload.getBytes(), QoS.AT_LEAST_ONCE,false);
connection.disconnect();
} catch (Exception e){
e.printStackTrace();
}
}
}
public class Power {
/**
*Q71-数值的整数次方
*实现函数double Power(double base, int exponent),求base的exponent次方。不需要考虑溢出。
*/
private static boolean InvalidInput=false;
public static void main(
实现两个WEB之间通过session 共享数据
查看tomcat 关于 HTTP Connector 中有个emptySessionPath 其解释如下:
If set to true, all paths for session cookies will be set to /. This can be useful for portlet specification impleme
Parses a raw HTTP request using yii\helpers\Json::decode()
To enable parsing for JSON requests you can configure yii\web\Request::$parsers using this class:
'request' =&g
Sort a linked list in O(n log n) time using constant space complexity.
====analysis=======
mergeSort for singly-linked list
====code======= /**
* Definition for sin
我使用的是ubuntu13.04系统,在安装nginx的时候遇到如下几个问题,然后找思路解决的,nginx 的下载与安装
wget http://nginx.org/download/nginx-1.0.11.tar.gz
tar zxvf nginx-1.0.11.tar.gz
./configure
make
make install
安装的时候出现
在系统开发过程中,总少不免要自己处理一些异常信息,然后将异常信息变成友好的提示返回到客户端的这样一个过程,之前都是new一个自定义的异常,当然这个所谓的自定义异常也是继承RuntimeException的,但这样往往会造成异常信息说明不一致的情况,所以就想到了用枚举来解决的办法。
1,先创建一个接口,里面有两个方法,一个是getCode, 一个是getMessage
public