Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ target/
*.iml

# log
logs/
logs/

.DS_Store
~/
2 changes: 1 addition & 1 deletion connectors/grafana-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Grafana is an open source volume metrics monitoring and visualization tool, whic

We developed the Grafana-Plugin for IoTDB, using the IoTDB REST service to present time series data and providing many visualization methods for time series data.

Iotdb grafana plugin supports grafana version 9.3.0 and above
IoTDB grafana plugin supports grafana version 9.3.0 and above

### How to use Grafana-Plugin

Expand Down
2 changes: 2 additions & 0 deletions distributions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
<descriptors>
<descriptor>src/assembly/spark-connector.xml</descriptor>
<descriptor>src/assembly/flink-sql-connector.xml</descriptor>
<descriptor>src/assembly/mybatis-generator-plugin.xml</descriptor>
<descriptor>src/assembly/iotdb-spring-boot-starter.xml</descriptor>
</descriptors>
<finalName>apache-iotdb-${project.version}</finalName>
</configuration>
Expand Down
41 changes: 41 additions & 0 deletions distributions/src/assembly/iotdb-spring-boot-starter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
<assembly>
<id>spring-boot-starter-bin</id>
<formats>
<format>dir</format>
<format>zip</format>
</formats>
<baseDirectory>apache-iotdb-${project.version}-spring-boot-starter-bin</baseDirectory>
<fileSets>
<fileSet>
<directory>${maven.multiModuleProjectDirectory}/iotdb-spring-boot-starter/target/</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>iotdb-spring-boot-starter-*.jar</include>
</includes>
</fileSet>
</fileSets>
<componentDescriptors>
<componentDescriptor>common-files.xml</componentDescriptor>
</componentDescriptors>
</assembly>
41 changes: 41 additions & 0 deletions distributions/src/assembly/mybatis-generator-plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
<assembly>
<id>mybatis-generator-plugin-bin</id>
<formats>
<format>dir</format>
<format>zip</format>
</formats>
<baseDirectory>apache-iotdb-${project.version}-mybatis-generator-plugin-bin</baseDirectory>
<fileSets>
<fileSet>
<directory>${maven.multiModuleProjectDirectory}/mybatis-generator/target/</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>mybatis-generator-plugin-*.jar</include>
</includes>
</fileSet>
</fileSets>
<componentDescriptors>
<componentDescriptor>common-files.xml</componentDescriptor>
</componentDescriptors>
</assembly>
63 changes: 63 additions & 0 deletions examples/iotdb-spring-boot-start/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.3</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-spring-boot-start-example</artifactId>
<version>2.0.2-SNAPHOT</version>
<name>iotdb-spring-boot-start</name>
<description>iotdb-spring-boot-start</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-spring-boot-starter</artifactId>
<version>2.0.2-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
116 changes: 116 additions & 0 deletions examples/iotdb-spring-boot-start/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
# IoTDB-Spring-Boot-Starter Demo
## Introduction

This demo shows how to use iotdb-spring-boot-starter

### Version usage

IoTDB: 2.0.1-beta
iotdb-spring-boot-starter: 2.0.2-SNAPSHOT

### 1. Install IoTDB

please refer to [https://iotdb.apache.org/#/Download](https://iotdb.apache.org/#/Download)

### 2. Startup IoTDB

please refer to [Quick Start](http://iotdb.apache.org/UserGuide/Master/Get%20Started/QuickStart.html)

Then we need to create a database 'wind' by cli in table model
```
create database wind;
use wind;
```
Then we need to create a database 'table'
```
CREATE TABLE table1 (
time TIMESTAMP TIME,
region STRING TAG,
plant_id STRING TAG,
device_id STRING TAG,
model_id STRING ATTRIBUTE,
maintenance STRING ATTRIBUTE,
temperature FLOAT FIELD,
humidity FLOAT FIELD,
status Boolean FIELD,
arrival_time TIMESTAMP FIELD
) WITH (TTL=31536000000);
```

### 3. Build Dependencies with Maven in your Project

```
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-spring-boot-starter</artifactId>
<version>2.0.2-SNAPSHOT</version>
</dependency>
</dependencies>
```

### 4、Use The target Bean with @Autowired

You can use the target Bean in your Project,like:
```
@Autowired
private ITableSessionPool ioTDBSessionPool;
@Autowired
private SessionPool sessionPool;

public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException {
ITableSession tableSession = ioTDBSessionPool.getSession();
final SessionDataSet sessionDataSet = tableSession.executeQueryStatement("select * from power_data_set limit 10");
while (sessionDataSet.hasNext()) {
final RowRecord rowRecord = sessionDataSet.next();
final List<Field> fields = rowRecord.getFields();
for (Field field : fields) {
System.out.print(field.getStringValue());
}
System.out.println();
}
}

public void querySessionPool() throws IoTDBConnectionException, StatementExecutionException {
final SessionDataSetWrapper sessionDataSetWrapper = sessionPool.executeQueryStatement("show databases");
while (sessionDataSetWrapper.hasNext()) {
final RowRecord rowRecord = sessionDataSetWrapper.next();
final List<Field> fields = rowRecord.getFields();
for (Field field : fields) {
System.out.print(field.getStringValue());
}
System.out.println();
}
}

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.iotdb.iotdbspringbootstartexample;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class IoTDBSpringBootStartApplication {

public static void main(String[] args) {
SpringApplication.run(IoTDBSpringBootStartApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.iotdb.iotdbspringbootstartexample.service;

import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionDataSet;
import org.apache.iotdb.isession.pool.ISessionPool;
import org.apache.iotdb.isession.pool.ITableSessionPool;
import org.apache.iotdb.isession.pool.SessionDataSetWrapper;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.session.pool.SessionPool;
import org.apache.tsfile.read.common.Field;
import org.apache.tsfile.read.common.RowRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IoTDBService {

@Autowired
private ITableSessionPool ioTDBSessionPool;

@Autowired
private ISessionPool sessionPool;


public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException {
ITableSession tableSession = ioTDBSessionPool.getSession();
final SessionDataSet sessionDataSet = tableSession.executeQueryStatement("select * from power_data_set limit 10");
while (sessionDataSet.hasNext()) {
final RowRecord rowRecord = sessionDataSet.next();
final List<Field> fields = rowRecord.getFields();
for (Field field : fields) {
System.out.print(field.getStringValue());
}
System.out.println();
}
}

public void querySessionPool() throws IoTDBConnectionException, StatementExecutionException {
final SessionDataSetWrapper sessionDataSetWrapper = sessionPool.executeQueryStatement("show databases");
while (sessionDataSetWrapper.hasNext()) {
final RowRecord rowRecord = sessionDataSetWrapper.next();
final List<Field> fields = rowRecord.getFields();
for (Field field : fields) {
System.out.print(field.getStringValue());
}
System.out.println();
}
}
}
Loading
Loading