-
Notifications
You must be signed in to change notification settings - Fork 131
feat: Apache Karaf support #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a8a30fe
feat: Apache Karaf support
borcsokj 8cdf035
feat: Apache Karaf support (update changelog)
borcsokj 8fceab8
feat: Apache Karaf support (update documentation)
borcsokj 02c9bef
feat: Apache Karaf support (minor changes based on PR review)
borcsokj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
# Apache Karaf Integration for InfluxDB 2.0 | ||
|
||
## Features | ||
|
||
- [Submodules](#submodules) | ||
- [Installation](#installation) | ||
- [Configuration](#configuration) | ||
- [Examples](#examples) | ||
|
||
## Submodules | ||
|
||
The Apache Karaf feature definition modules supporting InfluxDB 2.0: | ||
|
||
| Module | Description | | ||
| --- | --- | | ||
| **karaf-features** | Apache Karaf feature definition (XML) artifact for InfluxDB 2.0. | | ||
| **karaf-kar** | KAraf aRchive (KAR) artifact containing client for InfluxDB 2.0. | | ||
| **karaf-assembly** | Apache Karaf (sample) distribution having InfluxDB 2.0 client. | | ||
|
||
## Installation | ||
|
||
Apache Karaf Integration can be enabled by installing Karaf feature or KAR file. | ||
|
||
### Preparing | ||
|
||
Download [Apache Karaf](http://karaf.apache.org/download.html) 4.2+, extract to directory referenced by `KARAF_HOME` below and start container: | ||
|
||
``` | ||
$KARAF_HOME/bin/karaf | ||
``` | ||
|
||
### Karaf feature installation | ||
|
||
Add feature repository (`mvn:com.influxdb/influxdb-karaf-features/VERSION/xml/features`) and install feature named `influxdb-client` (replace `VERSION` with current version). | ||
|
||
``` | ||
karaf@root()> feature:repo-add mvn:com.influxdb/influxdb-karaf-features/VERSION/xml/features | ||
karaf@root()> feature:install influxdb-client | ||
``` | ||
|
||
Feature repository can be referenced by custom Karaf distributions too. | ||
|
||
### KAR deployment | ||
|
||
Install KAR Maven artifact `mvn:com.influxdb/influxdb-karaf-kar/VERSION/kar` (replace `VERSION` with current version: | ||
|
||
``` | ||
karaf@root()> kar:install mvn:com.influxdb/influxdb-karaf-kar/VERSION/kar | ||
``` | ||
|
||
### Sample Apache Karaf distribution | ||
|
||
A sample Apache Karaf distribution is created automatically by compiling karaf-assembly Maven module. ZIP and TGZ packages can be found in `karaf-assembly/target/` directory. OSGi component developers using InfluxDB do not need to download Apache Karaf and complete installation process (above) but unpack archive only and start the server. | ||
|
||
An alternate way to start the server is running `karaf-assembly/target/assembly/bin/karaf`. Installed features and bundles can be checked by the following commands: | ||
|
||
``` | ||
karaf@root()> feature:list | grep influx | ||
influxdb-client │ 2.2.0.SNAPSHOT │ │ Started │ influxdb-features-2.2.0-SNAPSHOT │ InfluxDB client | ||
kotlin │ 1.3.72 │ │ Started │ influxdb-features-2.2.0-SNAPSHOT │ Kotlin | ||
influxdb-karaf-features │ 2.2.0.SNAPSHOT │ │ Uninstalled │ influxdb-features-2.2.0-SNAPSHOT │ Apache Karaf Features for InfluxDB 2.0 | ||
karaf@root()> bundle:list | grep -i influx | ||
16 │ Active │ 80 │ 2.2.0.SNAPSHOT │ The OSGi InfluxDB 2.0 Client | ||
``` | ||
|
||
Declarative services (i.e. that are writing data to InfluxDB by OSGi events) become available if you copy configuration files (see below) to `karaf-assembly/target/assembly/deploy` directory. | ||
|
||
``` | ||
karaf@root()> scr:list | ||
com.influxdb.client.osgi.LineProtocolWriter in bundle 16 (com.influxdb.client-osgi:2.2.0.SNAPSHOT) enabled, 1 instance. | ||
Id: 3, State:ACTIVE, PID(s): [com.influxdb.client.osgi.LineProtocolWriter.7617b1fb-5b49-402b-b794-1bab69bf6136] | ||
com.influxdb.client.osgi.InfluxDBConnector in bundle 16 (com.influxdb.client-osgi:2.2.0.SNAPSHOT) enabled, 1 instance. | ||
Id: 1, State:ACTIVE, PID(s): [com.influxdb.client.osgi.InfluxDBConnector.1e27ec4c-4dcb-4545-a2ec-40405877a409] | ||
com.influxdb.client.osgi.PointWriter in bundle 16 (com.influxdb.client-osgi:2.2.0.SNAPSHOT) enabled, 1 instance. | ||
``` | ||
|
||
## Configuration | ||
|
||
Configuration options are described by [client-osgi](../client-osgi/README.md). Create configurations by hand (`*.cfg` files, copy them to `KARAF_HOME/deploy` directory) or via web console (need to install `webconsole` Karaf feature). | ||
|
||
## Examples | ||
|
||
### Preparing | ||
|
||
Install Apache Karaf Integration as described above. Create the following configuration files (replace connection properties): | ||
|
||
- `KARAF_HOME/deploy/com.influxdb.client.osgi.InfluxDBConnector-test.cfg` | ||
``` | ||
alias=test | ||
url=http://localhost:8086 | ||
token=TOKEN | ||
organization=example | ||
bucket=test | ||
``` | ||
|
||
- `KARAF_HOME/deploy/com.influxdb.client.osgi.LineProtocolWriter-tester.cfg` | ||
``` | ||
client.target=(alias=test) | ||
timestamp.append=true | ||
``` | ||
|
||
- `KARAF_HOME/deploy/com.influxdb.client.osgi.PointWriter-tester.cfg` | ||
``` | ||
event.topics=influxdb/point/* | ||
client.target=(alias=test) | ||
host.name.add=true | ||
host.address.add=true | ||
timestamp.add=true | ||
timestamp.precision=ns | ||
``` | ||
|
||
### Write RAW (line protocol) record | ||
|
||
Publish OSGi event containing line protocol record (i.e. via Karaf console). | ||
|
||
``` | ||
karaf@root()> event:send influxdb/lineprotocol "record=weather,location=HU temperature=5.89,humidity=48" | ||
``` | ||
|
||
### Write structured data | ||
|
||
Publish OSGi event containing structured data (i.e. by custom component). Both InfluxDB Point and Java Map types are supported (see [client-osgi](../client-osgi/README.md) and [javadoc](https://influxdata.github.io/influxdb-client-java/influxdb-client-osgi/apidocs/index.html) for details). | ||
|
||
```java | ||
@Component | ||
public class Tester { | ||
|
||
@Reference | ||
EventAdmin eventAdmin; | ||
|
||
public void tester() { | ||
final Map<String, String> tags = new TreeMap<>(); | ||
tags.put("location", "HU"); | ||
|
||
final Map<String, Object> fields = new TreeMap<>(); | ||
fields.put("temperature", 5.89); | ||
fields.put("humidity", 48); | ||
fields.put("raining", false); | ||
fields.put("sky", "CLOUDY"); | ||
|
||
final Map<String, Object> point = new TreeMap<>(); | ||
point.put("tags", tags); | ||
point.put("fields", fields); | ||
|
||
eventAdmin.postEvent(new Event("influxdb/point/weather", Collections.singletonMap("point", point))); | ||
} | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
|
||
The MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
|
||
--> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>influxdb-karaf</artifactId> | ||
<groupId>com.influxdb</groupId> | ||
<version>2.2.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>influxdb-karaf-assembly</artifactId> | ||
<packaging>karaf-assembly</packaging> | ||
|
||
<name>Apache Karaf Assembly for InfluxDB 2.0</name> | ||
<description> | ||
Apache Karaf distribution including InfluxDB 2.0 client. | ||
</description> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.karaf.tooling</groupId> | ||
<artifactId>karaf-maven-plugin</artifactId> | ||
<extensions>true</extensions> | ||
|
||
<executions> | ||
<execution> | ||
<id>default-assembly</id> | ||
<configuration> | ||
<javase>1.8</javase> | ||
<framework>framework</framework> | ||
<bootFeatures> | ||
<feature>instance</feature> | ||
<feature>package</feature> | ||
<feature>log</feature> | ||
<feature>ssh</feature> | ||
<feature>system</feature> | ||
<feature>eventadmin</feature> | ||
<feature>feature</feature> | ||
<feature>shell</feature> | ||
<feature>management</feature> | ||
<feature>service</feature> | ||
<feature>jaas</feature> | ||
<feature>deployer</feature> | ||
<feature>diagnostic</feature> | ||
<feature>wrap</feature> | ||
<feature>bundle</feature> | ||
<feature>config</feature> | ||
<feature>kar</feature> | ||
</bootFeatures> | ||
<startupFeatures> | ||
<feature>influxdb-client</feature> | ||
</startupFeatures> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>generate-docker</id> | ||
<activation> | ||
<activeByDefault>false</activeByDefault> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.karaf.tooling</groupId> | ||
<artifactId>karaf-maven-plugin</artifactId> | ||
<extensions>true</extensions> | ||
|
||
<executions> | ||
<execution> | ||
<id>dockerfile</id> | ||
<goals> | ||
<goal>dockerfile</goal> | ||
</goals> | ||
</execution> | ||
|
||
<execution> | ||
<id>docker</id> | ||
<goals> | ||
<goal>docker</goal> | ||
</goals> | ||
<configuration> | ||
<imageName>${project.artifactId}</imageName> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>influxdb-karaf-features</artifactId> | ||
<version>${project.version}</version> | ||
<scope>runtime</scope> | ||
<classifier>features</classifier> | ||
<type>xml</type> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
|
||
The MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
|
||
--> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>influxdb-karaf</artifactId> | ||
<groupId>com.influxdb</groupId> | ||
<version>2.2.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>influxdb-karaf-features</artifactId> | ||
<packaging>feature</packaging> | ||
|
||
<name>Apache Karaf Features for InfluxDB 2.0</name> | ||
<description> | ||
Apache Karaf Features for InfluxDB 2.0: feature definition of client bundles and dependencies. | ||
</description> | ||
|
||
<properties> | ||
<dependency.gson-fire.version>1.8.3</dependency.gson-fire.version> | ||
<dependency.reactivestreams.version>1.0.3</dependency.reactivestreams.version> | ||
</properties> | ||
borcsokj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/feature</directory> | ||
<filtering>true</filtering> | ||
<targetPath>target/feature</targetPath> | ||
</resource> | ||
</resources> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.karaf.tooling</groupId> | ||
<artifactId>karaf-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>default-verify</id> | ||
<configuration> | ||
<javase>1.8</javase> | ||
<distribution>org.apache.karaf.features:framework</distribution> | ||
<descriptors> | ||
<descriptor>mvn:org.apache.karaf.features/framework/${karaf.version}/xml/features</descriptor> | ||
<descriptor>mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features</descriptor> | ||
<!--descriptor>mvn:org.apache.karaf.features/enterprise/${karaf.version}/xml/features</descriptor--> | ||
<!--descriptor>mvn:org.apache.karaf.features/spring/${karaf.version}/xml/features</descriptor--> | ||
<descriptor>file:${project.build.directory}/feature/feature.xml</descriptor> | ||
</descriptors> | ||
<framework> | ||
<feature>framework</feature> | ||
<feature>scr</feature> | ||
</framework> | ||
<features> | ||
<feature>influxdb-client</feature> | ||
</features> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.