-
Notifications
You must be signed in to change notification settings - Fork 44
Feature/ingest v2 #439
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
base: master
Are you sure you want to change the base?
Feature/ingest v2 #439
Changes from 26 commits
b7dcd56
420a906
ab0d587
8badc85
67c8b15
6f8a41c
d7f4662
3f34273
847e7dc
2215353
dff5d6c
503c93b
9036adc
8d554ad
73afddd
428b46a
75c6545
c28e9fa
1794659
723a166
635fb8d
9d9f336
8cc94f5
87f4fed
dca3002
31ff143
b484e73
5ac8080
dc308e1
533cd35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # ingest-v2 | ||
|
|
||
| This project was created using the [Ktor Project Generator](https://start.ktor.io). | ||
|
|
||
| Here are some useful links to get you started: | ||
|
|
||
| - [Ktor Documentation](https://ktor.io/docs/home.html) | ||
| - [Ktor GitHub page](https://github.com/ktorio/ktor) | ||
| - The [Ktor Slack chat](https://app.slack.com/client/T09229ZC6/C0A974TJ9). You'll need to [request an invite](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up) to join. | ||
|
|
||
| ## Features | ||
|
|
||
| Here's a list of features included in this project: | ||
|
|
||
| | Name | Description | | ||
| |------------------------------------------------------------------------|------------------------------------------------------------------------------------| | ||
| | [Content Negotiation](https://start.ktor.io/p/content-negotiation) | Provides automatic content conversion according to Content-Type and Accept headers | | ||
| | [Routing](https://start.ktor.io/p/routing) | Provides a structured routing DSL | | ||
| | [kotlinx.serialization](https://start.ktor.io/p/kotlinx-serialization) | Handles JSON serialization using kotlinx.serialization library | | ||
| | [AsyncAPI](https://start.ktor.io/p/asyncapi) | Generates and serves AsyncAPI documentation | | ||
|
|
||
| ## Building & Running | ||
|
|
||
| To build or run the project, use one of the following tasks: | ||
|
|
||
| | Task | Description | | ||
| |--------------------------------------------------------------|-------------------| | ||
| | `mvn test` | Run the tests | | ||
| | `mvn package` | Build the project | | ||
| | `java -jar target/ingest-v2-0.0.1-jar-with-dependencies.jar` | Run the server | | ||
|
|
||
| If the server starts successfully, you'll see the following output: | ||
|
|
||
| ``` | ||
| 2024-12-04 14:32:45.584 [main] INFO Application - Application started in 0.303 seconds. | ||
| 2024-12-04 14:32:45.682 [main] INFO Application - Responding at http://0.0.0.0:8080 | ||
| ``` | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,215 @@ | ||||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <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> | ||||||
| <artifactId>ingest-v2</artifactId> | ||||||
| <version>${revision}</version> | ||||||
| <name>ingest-v2</name> | ||||||
| <description>ingest-v2</description> | ||||||
| <properties> | ||||||
| <kotlin.code.style>official</kotlin.code.style> | ||||||
| <kotlin.version>2.2.20</kotlin.version> | ||||||
| <ktor.version>3.3.0</ktor.version> | ||||||
| <ktor.async.api.version>3.1.1</ktor.async.api.version> | ||||||
| <kotlinx.coroutines.debug.version>1.10.2</kotlinx.coroutines.debug.version> | ||||||
| <logback.version>1.4.14</logback.version> | ||||||
| <junit.version>5.10.0</junit.version> | ||||||
| <openapi.generator.version>7.15.0</openapi.generator.version> | ||||||
| <slf4j.version>2.0.9</slf4j.version> | ||||||
| <spotless.version>2.46.1</spotless.version> | ||||||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||||||
| <kotlin.compiler.incremental>true</kotlin.compiler.incremental> | ||||||
| </properties> | ||||||
| <parent> | ||||||
| <artifactId>kusto-client</artifactId> | ||||||
| <groupId>com.microsoft.azure.kusto</groupId> | ||||||
| <!--suppress MavenPropertyInParent --> | ||||||
| <version>${revision}</version> | ||||||
| </parent> | ||||||
| <dependencies> | ||||||
| <dependency> | ||||||
| <groupId>io.ktor</groupId> | ||||||
| <artifactId>ktor-client-auth-jvm</artifactId> | ||||||
| <version>${ktor.version}</version> | ||||||
| </dependency> | ||||||
| <dependency> | ||||||
| <groupId>io.ktor</groupId> | ||||||
| <artifactId>ktor-client-content-negotiation-jvm</artifactId> | ||||||
| <version>${ktor.version}</version> | ||||||
| </dependency> | ||||||
| <dependency> | ||||||
| <groupId>io.ktor</groupId> | ||||||
| <artifactId>ktor-serialization-kotlinx-json-jvm</artifactId> | ||||||
| <version>${ktor.version}</version> | ||||||
| </dependency> | ||||||
| <dependency> | ||||||
| <groupId>io.ktor</groupId> | ||||||
| <artifactId>ktor-client-java-jvm</artifactId> | ||||||
| <version>${ktor.version}</version> | ||||||
| </dependency> | ||||||
| <dependency> | ||||||
| <groupId>org.slf4j</groupId> | ||||||
| <artifactId>slf4j-simple</artifactId> | ||||||
| <version>${slf4j.version}</version> | ||||||
| </dependency> | ||||||
| <dependency> | ||||||
| <groupId>com.azure</groupId> | ||||||
| <artifactId>azure-identity</artifactId> | ||||||
| </dependency> | ||||||
| <dependency> | ||||||
| <groupId>org.jetbrains.kotlin</groupId> | ||||||
| <artifactId>kotlin-test-junit5</artifactId> | ||||||
| <version>${kotlin.version}</version> | ||||||
| <scope>test</scope> | ||||||
| </dependency> | ||||||
| <dependency> | ||||||
| <groupId>org.jetbrains.kotlinx</groupId> | ||||||
| <artifactId>kotlinx-coroutines-debug</artifactId> | ||||||
| <version>${kotlinx.coroutines.debug.version}</version> | ||||||
| <scope>test</scope> | ||||||
| </dependency> | ||||||
| <dependency> | ||||||
| <groupId>io.mockk</groupId> | ||||||
| <artifactId>mockk-jvm</artifactId> | ||||||
| <version>1.14.5</version> | ||||||
| <scope>test</scope> | ||||||
| </dependency> | ||||||
| <dependency> | ||||||
| <groupId>org.junit.jupiter</groupId> | ||||||
| <artifactId>junit-jupiter-params</artifactId> | ||||||
| <version>${junit.version}</version> | ||||||
| <scope>test</scope> | ||||||
| </dependency> | ||||||
| </dependencies> | ||||||
| <build> | ||||||
| <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory> | ||||||
| <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory> | ||||||
| <resources> | ||||||
| <resource> | ||||||
| <directory>${project.basedir}/src/main/resources</directory> | ||||||
| </resource> | ||||||
| </resources> | ||||||
| <plugins> | ||||||
| <plugin> | ||||||
| <groupId>org.jetbrains.kotlin</groupId> | ||||||
| <artifactId>kotlin-maven-plugin</artifactId> | ||||||
| <version>${kotlin.version}</version> | ||||||
| <executions> | ||||||
| <execution> | ||||||
| <id>compile</id> | ||||||
| <phase>compile</phase> | ||||||
| <goals> | ||||||
| <goal>compile</goal> | ||||||
| </goals> | ||||||
| <configuration> | ||||||
| <sourceDirs> | ||||||
| <sourceDir>${project.basedir}/src/main/kotlin</sourceDir> | ||||||
| <sourceDir>${project.build.directory}/generated-sources/openapi/src/main/kotlin</sourceDir> | ||||||
| </sourceDirs> | ||||||
| </configuration> | ||||||
| </execution> | ||||||
| <execution> | ||||||
| <id>test-compile</id> | ||||||
| <phase>test-compile</phase> | ||||||
| <goals> | ||||||
| <goal>test-compile</goal> | ||||||
| </goals> | ||||||
| </execution> | ||||||
| </executions> | ||||||
| <configuration> | ||||||
| <compilerPlugins> | ||||||
| <plugin>kotlinx-serialization</plugin> | ||||||
| </compilerPlugins> | ||||||
| <jvmTarget>1.8</jvmTarget> | ||||||
|
||||||
| <jvmTarget>1.8</jvmTarget> | |
| <jvmTarget>11</jvmTarget> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generating doesn't work for me at all - I'm getting this error:
Execution default-cli of goal org.openapitools:openapi-generator-maven-plugin:7.15.0:generate failed: Unable to load the mojo 'generate' in the plugin 'org.openapitools:openapi-generator-maven-plugin:7.15.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/openapitools/codegen/plugin/CodeGenMojo has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which indicates a problem with using java 8 - using a later version works. We need to support java 8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting the following warnings:
Unknown type found in the schema: long. To map it, please use the schema mapping option (e.g. --schema-mappings in CLI)
Unknown type found in the schema: long. To map it, please use the schema mapping option (e.g. --schema-mappings in CLI)
Unknown type found in the schema: long. To map it, please use the schema mapping option (e.g. --schema-mappings in CLI)
Empty operationId found for path: post /v1/rest/ingestion/queued/{database}/{table}. Renamed to auto-generated operationId: v1RestIngestionQueuedDatabaseTablePost
Empty operationId found for path: get /v1/rest/ingestion/configuration. Renamed to auto-generated operationId: v1RestIngestionConfigurationGet
Empty operationId found for path: get /v1/rest/ingestion/queued/{database}/{table}/{operationId}. Renamed to auto-generated operationId: v1RestIngestionQueuedDatabaseTableOperationIdGet
Empty operationId found for path: post /v1/rest/ingest/{database}/{table}. Renamed to auto-generated operationId: v1RestIngestDatabaseTablePost
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this is because we are using 11.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
| package com.microsoft.azure.kusto.ingest.v2 | ||
|
|
||
| import com.azure.core.credential.TokenCredential | ||
| import com.microsoft.azure.kusto.ingest.v2.apis.DefaultApi | ||
| import com.microsoft.azure.kusto.ingest.v2.common.exceptions.IngestException | ||
| import com.microsoft.azure.kusto.ingest.v2.infrastructure.HttpResponse | ||
| import com.microsoft.azure.kusto.ingest.v2.models.ConfigurationResponse | ||
| import org.slf4j.LoggerFactory | ||
|
|
||
| class ConfigurationApiWrapper( | ||
|
||
| override val dmUrl: String, | ||
| override val tokenCredential: TokenCredential, | ||
| override val skipSecurityChecks: Boolean = false, | ||
| ) : KustoBaseApiClient(dmUrl, tokenCredential, skipSecurityChecks) { | ||
|
||
| private val logger = | ||
| LoggerFactory.getLogger(ConfigurationApiWrapper::class.java) | ||
| private val baseUrl = "$dmUrl/v1/rest/ingestion/configuration" | ||
| private val api: DefaultApi = | ||
| DefaultApi(baseUrl = dmUrl, httpClientConfig = setupConfig) | ||
|
|
||
| suspend fun getConfigurationDetails(): ConfigurationResponse { | ||
| val configurationHttpResponse: HttpResponse<ConfigurationResponse> = | ||
| api.getIngestConfiguration() | ||
| if (configurationHttpResponse.success) { | ||
| logger.info( | ||
| "Successfully retrieved configuration details from $dmUrl with status: ${configurationHttpResponse.status}", | ||
| ) | ||
| logger.debug( | ||
| "Configuration details: {}", | ||
| configurationHttpResponse.body(), | ||
| ) | ||
| return configurationHttpResponse.body() | ||
| } else { | ||
| logger.error( | ||
| "Failed to retrieve configuration details from $baseUrl. Status: ${configurationHttpResponse.status}, " + | ||
| "Body: ${configurationHttpResponse.body()}", | ||
| ) | ||
| throw IngestException( | ||
| "Failed to retrieve configuration details from $baseUrl. Status: ${configurationHttpResponse.status}, " + | ||
| "Body: ${configurationHttpResponse.body()}", | ||
| ) | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove java 8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initial thought:
Some internal projects (spark specifically) were using Java8. However newer distributions start at 11 (and are moving to 17 as well).