celeborn/openapi/openapi-client/pom.xml
Wang, Fei 1596cffb39 [CELEBORN-1607] Enable useEnumCaseInsensitive for openapi-generator
### What changes were proposed in this pull request?
Enable `useEnumCaseInsensitive` for openapi-generator.
And then in celeborn server end, the enum will be mapped to celeborn internal WorkerEventType.

### Why are the changes needed?

I met exception when sending worker event with openapi sdk.
```
Exception in thread "main" ApiException{code=400, responseHeaders={Server=[Jetty(9.4.52.v20230823)], Content-Length=[491], Date=[Fri, 20 Sep 2024 23:50:27 GMT], Content-Type=[text/plain]}, responseBody='Cannot deserialize value of type `org.apache.celeborn.rest.v1.model.SendWorkerEventRequest$EventTypeEnum` from String "DecommissionThenIdle": not one of the values accepted for Enum class: [DECOMMISSION_THEN_IDLE, GRACEFUL, NONE, DECOMMISSION, IMMEDIATELY, RECOMMISSION]
 at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 14] (through reference chain: org.apache.celeborn.rest.v1.model.SendWorkerEventRequest["eventType"])'}
    at org.apache.celeborn.rest.v1.master.invoker.ApiClient.processResponse(ApiClient.java:913)
    at org.apache.celeborn.rest.v1.master.invoker.ApiClient.invokeAPI(ApiClient.java:1000)
    at org.apache.celeborn.rest.v1.master.WorkerApi.sendWorkerEvent(WorkerApi.java:378)
    at org.apache.celeborn.rest.v1.master.WorkerApi.sendWorkerEvent(WorkerApi.java:334)
    at org.example.Main.main(Main.java:22)

```

The testing code to re-produce:
```
package org.example;

import org.apache.celeborn.rest.v1.master.WorkerApi;
import org.apache.celeborn.rest.v1.master.invoker.ApiClient;
import org.apache.celeborn.rest.v1.model.ExcludeWorkerRequest;
import org.apache.celeborn.rest.v1.model.SendWorkerEventRequest;
import org.apache.celeborn.rest.v1.model.WorkerId;

public class Main {
    public static void main(String[] args) throws Exception {

        String cmUrl = "http://localhost:9098";
        WorkerApi workerApi = new WorkerApi(new ApiClient().setBasePath(cmUrl));
        workerApi.excludeWorker(new ExcludeWorkerRequest()
                .addAddItem(new WorkerId()
                        .host("localhost")
                        .rpcPort(1)
                        .pushPort(2)
                        .fetchPort(3)
                        .replicatePort(4)));
        workerApi.sendWorkerEvent(new SendWorkerEventRequest()
                        .addWorkersItem(new WorkerId()
                                .host("127.0.0.1")
                                .rpcPort(56116)
                                .pushPort(56117)
                                .fetchPort(56119)
                                .replicatePort(56118))
                .eventType(SendWorkerEventRequest.EventTypeEnum.DECOMMISSION_THEN_IDLE));
    }
}
```

Seems because for the EventTypeEnum, the name and value not the same and then cause this issue.

Not sure why the UT passed, but the integration testing failed.

For EventTypeEnum, because its value is case sensitive, so we meet this issue.

8734d16638/openapi/openapi-client/src/main/java/org/apache/celeborn/rest/v1/model/SendWorkerEventRequest.java (L47-L83)

Related issue in jersey end I think, https://github.com/eclipse-ee4j/jersey/issues/5288

In this PR, `useEnumCaseInsensitive` is enabled for openapi-generator.

### Does this PR introduce _any_ user-facing change?
No, there is not user facing change and this SDK has not been released yet.

### How was this patch tested?
Existing UT and Integration testing.
<img width="1265" alt="image" src="https://github.com/user-attachments/assets/6a34a0dd-c474-4e8d-b372-19b0fda94972">

Closes #2754 from turboFei/eventTypeEnumMapping.

Authored-by: Wang, Fei <fwang12@ebay.com>
Signed-off-by: mingji <fengmingxiao.fmx@alibaba-inc.com>
2024-09-23 20:43:04 +08:00

315 lines
14 KiB
XML

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.celeborn</groupId>
<artifactId>celeborn-parent_${scala.binary.version}</artifactId>
<version>${project.version}</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>celeborn-openapi-client_${scala.binary.version}</artifactId>
<packaging>jar</packaging>
<name>Celeborn OpenAPI Client</name>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.core5</groupId>
<artifactId>httpcore5</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.core5</groupId>
<artifactId>httpcore5-h2</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<relocations>
<relocation>
<pattern>org.openapitools</pattern>
<shadedPattern>${shading.prefix}.org.openapitools</shadedPattern>
</relocation>
<relocation>
<pattern>javax.annotation</pattern>
<shadedPattern>${shading.prefix}.javax.annotation</shadedPattern>
</relocation>
<relocation>
<pattern>com.fasterxml.jackson</pattern>
<shadedPattern>${shading.prefix}.com.fasterxml.jackson</shadedPattern>
</relocation>
<relocation>
<pattern>jakarta.validation</pattern>
<shadedPattern>${shading.prefix}.jakarta.validation</shadedPattern>
</relocation>
<relocation>
<pattern>javax.validation</pattern>
<shadedPattern>${shading.prefix}.javax.validation</shadedPattern>
</relocation>
<relocation>
<pattern>javax.ws.rs.ext</pattern>
<shadedPattern>${shading.prefix}.javax.ws.rs.ext</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.hc</pattern>
<shadedPattern>${shading.prefix}.org.apache.hc</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>${shading.prefix}.org.slf4j</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF/versions/11/com/fasterxml/jackson</pattern>
<shadedPattern>META-INF/versions/11/org/apache/celeborn/shaded/com/fasterxml/jackson</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF/versions/17/com/fasterxml/jackson</pattern>
<shadedPattern>META-INF/versions/17/org/apache/celeborn/shaded/com/fasterxml/jackson</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF/versions/19/com/fasterxml/jackson</pattern>
<shadedPattern>META-INF/versions/19/org/apache/celeborn/shaded/com/fasterxml/jackson</shadedPattern>
</relocation>
</relocations>
<artifactSet>
<includes>
<include>com.fasterxml.jackson.core:jackson-annotations</include>
<include>com.fasterxml.jackson.core:jackson-databind</include>
<include>com.fasterxml.jackson.datatype:jackson-datatype-jsr310</include>
<include>org.apache.httpcomponents.client5:httpclient5</include>
<include>org.apache.httpcomponents.core5:httpcore5</include>
<include>org.apache.httpcomponents.core5:httpcore5-h2</include>
<include>com.fasterxml.jackson.core:jackson-core</include>
<include>com.google.code.findbugs:jsr305</include>
<include>jakarta.annotation:jakarta.annotation-api</include>
<include>org.openapitools:jackson-databind-nullable</include>
<include>org.slf4j:slf4j-api</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>**/log4j.properties</exclude>
<exclude>META-INF/DEPENDENCIES</exclude>
<exclude>META-INF/*LICENSE*</exclude>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/*NOTICE*</exclude>
<exclude>META-INF/**/module-info.class</exclude>
<exclude>LICENSE.txt</exclude>
<exclude>NOTICE.txt</exclude>
<exclude>mozilla/*.txt</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"></transformer>
</transformers>
</configuration>
</plugin>
<!--
This is to ensure references to shaded classes can be resolved in IDEs such as Intellij.
For reference: https://youtrack.jetbrains.com/issue/IDEA-126596
-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>attach-artifact</goal>
</goals>
<phase>package</phase>
<configuration>
<artifacts>
<artifact>
<file>${basedir}/target/${project.artifactId}-${project.version}.jar</file>
<type>jar</type>
<classifier>optional</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>generate</id>
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!--
please keep the schema definitions consistent between master_rest_v1.yaml and worker_rest_v1.yaml
-->
<executions>
<execution>
<id>generate-java-master-rest-v1</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<inputSpec>${project.basedir}/src/main/openapi3/master_rest_v1.yaml</inputSpec>
<output>${project.build.directory}/generated-sources/java</output>
<apiPackage>org.apache.celeborn.rest.v1.master</apiPackage>
<modelPackage>org.apache.celeborn.rest.v1.model</modelPackage>
<invokerPackage>org.apache.celeborn.rest.v1.master.invoker</invokerPackage>
<generatorName>java</generatorName>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<artifactVersion>${project.version}</artifactVersion>
<addCompileSourceRoot>false</addCompileSourceRoot>
<templateDirectory>${project.basedir}/src/main/openapi3/templates</templateDirectory>
<cleanupOutput>true</cleanupOutput>
<configOptions>
<licenseName>Apache License 2.0</licenseName>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<artifactVersion>${project.version}</artifactVersion>
<dateLibrary>java8</dateLibrary>
<useGzipFeature>true</useGzipFeature>
<library>apache-httpclient</library>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<supportUrlQuery>false</supportUrlQuery>
<annotationLibrary>none</annotationLibrary>
<useEnumCaseInsensitive>true</useEnumCaseInsensitive>
</configOptions>
</configuration>
</execution>
<execution>
<id>generate-java-worker-rest-v1</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<inputSpec>${project.basedir}/src/main/openapi3/worker_rest_v1.yaml</inputSpec>
<output>${project.build.directory}/generated-sources/java</output>
<apiPackage>org.apache.celeborn.rest.v1.worker</apiPackage>
<modelPackage>org.apache.celeborn.rest.v1.model</modelPackage>
<invokerPackage>org.apache.celeborn.rest.v1.worker.invoker</invokerPackage>
<generatorName>java</generatorName>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<artifactVersion>${project.version}</artifactVersion>
<addCompileSourceRoot>false</addCompileSourceRoot>
<templateDirectory>${project.basedir}/src/main/openapi3/templates</templateDirectory>
<configOptions>
<licenseName>Apache License 2.0</licenseName>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<artifactVersion>${project.version}</artifactVersion>
<dateLibrary>java8</dateLibrary>
<useGzipFeature>true</useGzipFeature>
<library>apache-httpclient</library>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<supportUrlQuery>false</supportUrlQuery>
<annotationLibrary>none</annotationLibrary>
<useEnumCaseInsensitive>true</useEnumCaseInsensitive>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<goals>
<goal>copy-resources</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${project.basedir}/target/generated-sources/java/src/main/java</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>