Skip to content

Commit f57922e

Browse files
authored
OCI Integration (helidon-io#2894)
* OCI integration for Helidon SE * OCI integration for CDI * Vault CDI integration + API. * Object Storage Integration + API * Add metrics integration + API Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
1 parent ef10764 commit f57922e

134 files changed

Lines changed: 11531 additions & 14 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bom/pom.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@
337337
<artifactId>helidon-security-providers-http-sign</artifactId>
338338
<version>${helidon.version}</version>
339339
</dependency>
340+
<dependency>
341+
<groupId>io.helidon.security.providers</groupId>
342+
<artifactId>helidon-security-providers-config-vault</artifactId>
343+
<version>${helidon.version}</version>
344+
</dependency>
340345
<dependency>
341346
<groupId>io.helidon.security.integration</groupId>
342347
<artifactId>helidon-security-integration-common</artifactId>
@@ -886,6 +891,31 @@
886891
<artifactId>helidon-integrations-micrometer-cdi</artifactId>
887892
<version>${helidon.version}</version>
888893
</dependency>
894+
<dependency>
895+
<groupId>io.helidon.integrations.oci</groupId>
896+
<artifactId>helidon-integrations-oci-connect</artifactId>
897+
<version>${helidon.version}</version>
898+
</dependency>
899+
<dependency>
900+
<groupId>io.helidon.integrations.oci</groupId>
901+
<artifactId>helidon-integrations-oci-telemetry</artifactId>
902+
<version>${helidon.version}</version>
903+
</dependency>
904+
<dependency>
905+
<groupId>io.helidon.integrations.oci</groupId>
906+
<artifactId>helidon-integrations-oci-objectstorage</artifactId>
907+
<version>${helidon.version}</version>
908+
</dependency>
909+
<dependency>
910+
<groupId>io.helidon.integrations.oci</groupId>
911+
<artifactId>helidon-integrations-oci-vault</artifactId>
912+
<version>${helidon.version}</version>
913+
</dependency>
914+
<dependency>
915+
<groupId>io.helidon.integrations.oci</groupId>
916+
<artifactId>helidon-integrations-oci-cdi</artifactId>
917+
<version>${helidon.version}</version>
918+
</dependency>
889919
<!-- OpenAPI support -->
890920
<dependency>
891921
<groupId>io.helidon.openapi</groupId>

common/common/src/main/java/io/helidon/common/FeatureCatalog.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,13 @@ final class FeatureCatalog {
177177
.experimental(true)
178178
.nativeSupported(true)
179179
.flavor(HelidonFlavor.SE));
180-
180+
add("io.helidon.integrations.oci.connect",
181+
FeatureDescriptor.builder()
182+
.name("OCI")
183+
.description("OCI Integration")
184+
.path("OCI")
185+
.flavor(HelidonFlavor.SE)
186+
.experimental(true));
181187
/*
182188
* MP Modules
183189
*/
@@ -360,6 +366,14 @@ final class FeatureCatalog {
360366
.nativeSupported(true)
361367
.flavor(HelidonFlavor.MP));
362368

369+
add("io.helidon.integrations.oci.cdi",
370+
FeatureDescriptor.builder()
371+
.name("OCI")
372+
.description("OCI Integration")
373+
.path("OCI")
374+
.flavor(HelidonFlavor.MP)
375+
.experimental(true));
376+
363377
/*
364378
* Common modules
365379
*/
@@ -578,6 +592,18 @@ final class FeatureCatalog {
578592
"Static Content",
579593
"Static content support for webserver",
580594
"WebServer", "Static Content");
595+
add("io.helidon.integrations.oci.objectstorage",
596+
"OCI Object Storage",
597+
"Integration with OCI Object Storage",
598+
"OCI", "Object Storage");
599+
add("io.helidon.integrations.oci.vault",
600+
"OCI Vault",
601+
"Integration with OCI Vault",
602+
"OCI", "Vault");
603+
add("io.helidon.integrations.oci.telemetry",
604+
"OCI Telemetry",
605+
"Integration with OCI Telemetry",
606+
"OCI", "Telemetry");
581607

582608
/*
583609
* Packages that are not a feature

config/yaml/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2017, 2021 Oracle and/or its affiliates.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -57,8 +57,9 @@
5757
<dependency>
5858
<groupId>org.eclipse.microprofile.config</groupId>
5959
<artifactId>microprofile-config-api</artifactId>
60-
<scope>provided</scope>
61-
<optional>true</optional>
60+
<!-- this does not work correctly with JPMS and usage of service loader -->
61+
<!-- <scope>provided</scope>-->
62+
<!-- <optional>true</optional>-->
6263
</dependency>
6364
<dependency>
6465
<groupId>io.helidon.config</groupId>

etc/copyright-exclude.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
4747
etc/THIRD_PARTY_LICENSES.xml
4848
etc/HELIDON_THIRD_PARTY_LICENSES.xml
4949
etc/dependency-check-suppression.xml
50+
META-INF/services/
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (c) 2021 Oracle and/or its affiliates.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
22+
https://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
<parent>
25+
<groupId>io.helidon.applications</groupId>
26+
<artifactId>helidon-se</artifactId>
27+
<version>2.3.0-SNAPSHOT</version>
28+
<relativePath>../../../../applications/se/pom.xml</relativePath>
29+
</parent>
30+
31+
<properties>
32+
<mainClass>io.helidon.examples.integrations.oci.telemetry.reactive.OciMetricsMain</mainClass>
33+
</properties>
34+
35+
<groupId>io.helidon.examples.integrations.oci</groupId>
36+
<artifactId>helidon-examples-integrations-oci-metrics-reactive</artifactId>
37+
<name>Helidon Examples Integration OCI Metrics Reactive</name>
38+
<description>Reactive integration with OCI Metrics.</description>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>io.helidon.webserver</groupId>
43+
<artifactId>helidon-webserver</artifactId>
44+
</dependency>
45+
<dependency>
46+
<groupId>io.helidon.integrations.oci</groupId>
47+
<artifactId>helidon-integrations-oci-telemetry</artifactId>
48+
</dependency>
49+
<dependency>
50+
<groupId>io.helidon.config</groupId>
51+
<artifactId>helidon-config-yaml</artifactId>
52+
</dependency>
53+
</dependencies>
54+
55+
<build>
56+
<plugins>
57+
<plugin>
58+
<groupId>org.apache.maven.plugins</groupId>
59+
<artifactId>maven-dependency-plugin</artifactId>
60+
<executions>
61+
<execution>
62+
<id>copy-libs</id>
63+
</execution>
64+
</executions>
65+
</plugin>
66+
</plugins>
67+
</build>
68+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Copyright (c) 2021 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.helidon.examples.integrations.oci.telemetry.reactive;
18+
19+
import java.time.Instant;
20+
import java.time.temporal.ChronoUnit;
21+
22+
import io.helidon.common.LogConfig;
23+
import io.helidon.config.Config;
24+
import io.helidon.integrations.common.rest.ApiEntityResponse;
25+
import io.helidon.integrations.oci.telemetry.OciMetricsRx;
26+
import io.helidon.integrations.oci.telemetry.PostMetricData;
27+
28+
import static io.helidon.config.ConfigSources.classpath;
29+
import static io.helidon.config.ConfigSources.file;
30+
31+
/**
32+
* OCI Metrics example.
33+
*/
34+
public final class OciMetricsMain {
35+
private OciMetricsMain() {
36+
}
37+
38+
/**
39+
* Main method.
40+
* @param args ignored
41+
*/
42+
public static void main(String[] args) {
43+
LogConfig.configureRuntime();
44+
// as I cannot share my configuration of OCI, let's combine the configuration
45+
// from my home directory with the one compiled into the jar
46+
// when running this example, you can either update the application.yaml in resources directory
47+
// or use the same approach
48+
Config config = buildConfig();
49+
50+
OciMetricsRx metrics = OciMetricsRx.create(config.get("oci"));
51+
52+
String compartmentId = config.get("oci.metrics.compartment-ocid").asString().get();
53+
54+
Instant now = Instant.now();
55+
PostMetricData.Request request = PostMetricData.Request.builder()
56+
.addMetricData(PostMetricData.MetricData.builder()
57+
.compartmentId(compartmentId)
58+
// Add a few data points to see something in the console
59+
.addDataPoint(now.minus(10, ChronoUnit.SECONDS), 101)
60+
.addDataPoint(now.minus(5, ChronoUnit.SECONDS), 123)
61+
.addDataPoint(now, 149)
62+
.addDimension("resourceId", "myresourceid")
63+
.addMetaData("unit", "cm")
64+
.name("my_app.jump")
65+
.namespace("helidon_examples"));
66+
67+
/*
68+
* Invoke the API call. I use .await() to block the call, as otherwise our
69+
* main method would finish without waiting for the response.
70+
* In a real reactive application, this should not be done (as you would write the response
71+
* to a server response or use other reactive/non-blocking APIs).
72+
*/
73+
metrics.postMetricData(request)
74+
.peek(it -> {
75+
System.out.println("PostMetrics: " + it.status());
76+
printHeaders(it);
77+
})
78+
.forSingle(it -> {
79+
int count = it.failedMetricsCount();
80+
System.out.println("Failed count: " + count);
81+
if (count > 0) {
82+
System.out.println("Failed metrics:");
83+
for (PostMetricData.FailedMetric failedMetric : it.failedMetrics()) {
84+
System.out.println("\t" + failedMetric.message() + ": " + failedMetric.failedDataJson());
85+
}
86+
}
87+
})
88+
.await();
89+
}
90+
91+
private static void printHeaders(ApiEntityResponse response) {
92+
System.out.println("\tHeaders:");
93+
response.headers().toMap().forEach((key, values) -> System.out.println("\t\t" + key + ": " + values));
94+
}
95+
96+
private static Config buildConfig() {
97+
return Config.builder()
98+
.sources(
99+
// you can use this file to override the defaults that are built-in
100+
file(System.getProperty("user.home") + "/helidon/conf/examples.yaml").optional(),
101+
// in jar file (see src/main/resources/application.yaml)
102+
classpath("application.yaml"))
103+
.build();
104+
}
105+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2021 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Example using OCI metrics reactive API.
19+
*/
20+
package io.helidon.examples.integrations.oci.telemetry.reactive;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2021 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Example using OCI metrics reactive API.
19+
*/
20+
module io.helidon.examples.integrations.oci.metrics.reactive {
21+
requires java.logging;
22+
23+
requires io.helidon.config;
24+
requires io.helidon.integrations.oci.telemetry;
25+
26+
exports io.helidon.examples.integrations.oci.telemetry.reactive;
27+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# Copyright (c) 2021 Oracle and/or its affiliates.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
# The values are read from
18+
# ~/helidon/conf/examples.yaml
19+
# or you can just update them here
20+
oci:
21+
metrics:
22+
compartment-ocid: "${oci.properties.compartment-ocid}"
23+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Copyright (c) 2021 Oracle and/or its affiliates.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
# Send messages to the console
18+
handlers=io.helidon.common.HelidonConsoleHandler
19+
20+
# HelidonConsoleHandler uses a SimpleFormatter subclass that replaces "!thread!" with the current thread
21+
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
22+
23+
# Global logging level. Can be overridden by specific loggers
24+
.level=INFO
25+
26+
io.helidon.level=INFO
27+
io.helidon.integrations.level=INFO

0 commit comments

Comments
 (0)