forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-7778] [build] Shade ZooKeeper dependency (part 2)
This closes apache#4927
- Loading branch information
1 parent
4d02823
commit d368a07
Showing
7 changed files
with
188 additions
and
26 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
66 changes: 66 additions & 0 deletions
66
flink-runtime/src/main/java/org/apache/flink/runtime/zookeeper/ZookeeperAccess.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,66 @@ | ||
/* | ||
* 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:https://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.flink.runtime.zookeeper; | ||
|
||
import org.apache.zookeeper.KeeperException; | ||
|
||
import java.util.ConcurrentModificationException; | ||
|
||
/** | ||
* Utility class providing access to relocated zookeeper classes. | ||
* | ||
* <p>This class is necessary as flink-runtime relocates its ZooKeeper dependency. | ||
* Other modules may still depend on this dependency but will encounter a ClassNotFoundException | ||
* on access as they don't apply the relocation pattern of flink-runtime. | ||
*/ | ||
public final class ZookeeperAccess { | ||
|
||
private ZookeeperAccess(){ | ||
} | ||
|
||
/** | ||
* Wraps and returns the given exception in a {@link ConcurrentModificationException} if it is a | ||
* {@link org.apache.zookeeper.KeeperException.NodeExistsException}. Otherwise the | ||
* given exception is returned. | ||
* | ||
* @param ex exception to wrap | ||
* @return wrapping ConcurrentModificationException if it is a NodeExistsException, otherwise the given exception | ||
*/ | ||
public static Exception wrapIfZooKeeperNodeExistsException(Exception ex) { | ||
if (ex instanceof KeeperException.NodeExistsException) { | ||
return new ConcurrentModificationException("ZooKeeper unexpectedly modified", ex); | ||
} | ||
return ex; | ||
} | ||
|
||
/** | ||
* Wraps and returns the given exception in a {@link ConcurrentModificationException} if it is a | ||
* {@link org.apache.zookeeper.KeeperException.NoNodeException}. Otherwise the | ||
* given exception is returned. | ||
* | ||
* @param ex exception to wrap | ||
* @return wrapping ConcurrentModificationException if it is a NoNodeException, otherwise the given exception | ||
*/ | ||
public static Exception wrapIfZooKeeperNoNodeException(Exception ex) { | ||
if (ex instanceof KeeperException.NoNodeException) { | ||
return new ConcurrentModificationException("ZooKeeper unexpectedly modified", ex); | ||
} | ||
return ex; | ||
} | ||
} |
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,88 @@ | ||
<?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:https://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:https://maven.apache.org/POM/4.0.0" xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-parent</artifactId> | ||
<version>1.4-SNAPSHOT</version> | ||
<relativePath>..</relativePath> | ||
</parent> | ||
|
||
<artifactId>flink-shaded-curator-recipes</artifactId> | ||
<name>flink-shaded-curator-recipes</name> | ||
|
||
<packaging>jar</packaging> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.curator</groupId> | ||
<artifactId>curator-recipes</artifactId> | ||
<version>${curator.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>shade-flink</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<artifactSet> | ||
<includes> | ||
<include>com.google.guava:guava</include> | ||
<include>org.apache.curator:*</include> | ||
</includes> | ||
</artifactSet> | ||
<filters> | ||
<filter> | ||
<artifact>com.google.guava:guava</artifact> | ||
<!-- Shade guava classes that are not included by curator --> | ||
<includes> | ||
<include>com/google/common/base/Function.class</include> | ||
<include>com/google/common/base/Predicate.class</include> | ||
<include>com/google/common/reflect/TypeToken.class</include> | ||
</includes> | ||
</filter> | ||
</filters> | ||
<relocations> | ||
<relocation> | ||
<pattern>com.google.common</pattern> | ||
<shadedPattern>org.apache.flink.curator.shaded.com.google.common</shadedPattern> | ||
</relocation> | ||
</relocations> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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