-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bug] deploy flink job on yarn, get state bug fixed. (#3329)
* [Improve] resolve maven artifacts improvement * [Bug] extract programArgs bug fixed * [Improve] job maven dependency support exclusion * [Improve] maven dependency check improvement --------- Co-authored-by: benjobs <[email protected]>
- Loading branch information
Showing
22 changed files
with
492 additions
and
306 deletions.
There are no files selected for viewing
This file contains 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 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 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
101 changes: 101 additions & 0 deletions
101
...onsole-service/src/main/java/org/apache/streampark/console/core/bean/MavenDependency.java
This file contains 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,101 @@ | ||
/* | ||
* 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.streampark.console.core.bean; | ||
|
||
import org.apache.streampark.common.conf.Workspace; | ||
import org.apache.streampark.common.util.FileUtils; | ||
import org.apache.streampark.console.base.util.JacksonUtils; | ||
import org.apache.streampark.console.base.util.WebUtils; | ||
import org.apache.streampark.flink.packer.maven.Artifact; | ||
import org.apache.streampark.flink.packer.maven.MavenArtifact; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import lombok.Data; | ||
import lombok.SneakyThrows; | ||
|
||
import java.io.File; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
@Data | ||
public class MavenDependency { | ||
|
||
private Set<MavenPom> pom = Collections.emptySet(); | ||
|
||
private Set<String> jar = Collections.emptySet(); | ||
|
||
@SneakyThrows | ||
public static MavenDependency of(String dependency) { | ||
if (StringUtils.isNotBlank(dependency)) { | ||
return JacksonUtils.read(dependency, MavenDependency.class); | ||
} | ||
return new MavenDependency(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object that) { | ||
if (this == that) { | ||
return true; | ||
} | ||
|
||
if (that == null || getClass() != that.getClass()) { | ||
return false; | ||
} | ||
|
||
MavenDependency thatDep = (MavenDependency) that; | ||
|
||
if (this.pom.size() != thatDep.pom.size() | ||
|| this.jar.size() != thatDep.jar.size() | ||
|| !this.pom.containsAll(thatDep.pom)) { | ||
return false; | ||
} | ||
|
||
File localJar = WebUtils.getAppTempDir(); | ||
File localUploads = new File(Workspace.local().APP_UPLOADS()); | ||
for (String jarName : jar) { | ||
if (!thatDep.jar.contains(jarName) | ||
|| !FileUtils.equals(new File(localJar, jarName), new File(localUploads, jarName))) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public MavenArtifact toMavenArtifact() { | ||
List<Artifact> mvnArts = | ||
this.pom.stream() | ||
.map( | ||
pom -> | ||
new Artifact( | ||
pom.getGroupId(), | ||
pom.getArtifactId(), | ||
pom.getVersion(), | ||
pom.getClassifier(), | ||
pom.toExclusionString())) | ||
.collect(Collectors.toList()); | ||
List<String> extJars = | ||
this.jar.stream() | ||
.map(jar -> Workspace.local().APP_UPLOADS() + "/" + jar) | ||
.collect(Collectors.toList()); | ||
return new MavenArtifact(mvnArts, extJars); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...console-service/src/main/java/org/apache/streampark/console/core/bean/MavenExclusion.java
This file contains 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,55 @@ | ||
/* | ||
* 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.streampark.console.core.bean; | ||
|
||
import lombok.Data; | ||
|
||
import java.util.Objects; | ||
|
||
@Data | ||
public class MavenExclusion { | ||
|
||
private String groupId; | ||
|
||
private String artifactId; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
|
||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
|
||
MavenExclusion that = (MavenExclusion) o; | ||
if (this.groupId == null || that.groupId == null) { | ||
return false; | ||
} | ||
if (this.artifactId == null || that.artifactId == null) { | ||
return false; | ||
} | ||
return this.groupId.equals(that.groupId) && this.artifactId.equals(that.artifactId); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(groupId, artifactId); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
...mpark-console-service/src/main/java/org/apache/streampark/console/core/bean/MavenPom.java
This file contains 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,93 @@ | ||
/* | ||
* 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.streampark.console.core.bean; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import lombok.Data; | ||
|
||
import java.util.Collections; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
@Data | ||
public class MavenPom { | ||
private String groupId; | ||
private String artifactId; | ||
private String version; | ||
private String classifier; | ||
private Set<MavenExclusion> exclusions = Collections.emptySet(); | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
|
||
MavenPom that = (MavenPom) o; | ||
|
||
boolean basic = | ||
this.groupId.equals(that.groupId) | ||
&& this.artifactId.equals(that.artifactId) | ||
&& this.version.equals(that.version); | ||
|
||
boolean classify = | ||
StringUtils.isAllBlank(this.classifier, that.classifier) | ||
|| this.classifier.equals(that.classifier); | ||
|
||
if (basic && classify) { | ||
Set<MavenExclusion> thisEx = | ||
this.exclusions == null ? Collections.emptySet() : this.exclusions; | ||
Set<MavenExclusion> thatEx = | ||
that.exclusions == null ? Collections.emptySet() : that.exclusions; | ||
return thisEx.size() == thatEx.size() && thisEx.containsAll(thatEx); | ||
} | ||
return false; | ||
} | ||
|
||
public String artifactName() { | ||
if (StringUtils.isBlank(classifier)) { | ||
return String.format("%s-%s.jar", artifactId, version); | ||
} | ||
return String.format("%s-%s-%s.jar", artifactId, version, classifier); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(groupId, artifactId, version, classifier); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return groupId + ":" + artifactId + ":" + version + getClassifier(); | ||
} | ||
|
||
public Set<String> toExclusionString() { | ||
return this.exclusions.stream() | ||
.map(x -> String.format("%s:%s", x.getGroupId(), x.getArtifactId())) | ||
.collect(Collectors.toSet()); | ||
} | ||
|
||
public String getClassifier() { | ||
return StringUtils.isBlank(classifier) ? "" : ":" + classifier; | ||
} | ||
} |
Oops, something went wrong.