merlimat closed pull request #1774: Removed multifunction.jar from sources
URL: https://github.com/apache/incubator-pulsar/pull/1774
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/pulsar-functions/pom.xml b/pulsar-functions/pom.xml
index 49e6021cdb..99c6947b6d 100644
--- a/pulsar-functions/pom.xml
+++ b/pulsar-functions/pom.xml
@@ -35,6 +35,7 @@
<module>proto</module>
<module>proto-shaded</module>
<module>api-java</module>
+ <module>java-examples</module>
<module>utils</module>
<module>metrics</module>
<module>instance</module>
@@ -43,7 +44,6 @@
<module>runtime-all</module>
<module>worker</module>
<module>worker-shaded</module>
- <module>java-examples</module>
</modules>
<dependencyManagement>
diff --git a/pulsar-functions/utils/pom.xml b/pulsar-functions/utils/pom.xml
index 6c8032cb48..b19366d545 100644
--- a/pulsar-functions/utils/pom.xml
+++ b/pulsar-functions/utils/pom.xml
@@ -129,7 +129,6 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
- <version>4.1.12.Final</version>
</dependency>
<dependency>
diff --git
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheEntryTest.java
b/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheEntryTest.java
deleted file mode 100644
index b42be1497f..0000000000
---
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheEntryTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * 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.pulsar.functions.utils.functioncache;
-
-import static org.testng.Assert.fail;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.testng.annotations.Test;
-
-/**
- * Unit test of {@link FunctionCacheEntry}.
- */
-public class FunctionCacheEntryTest {
-
- private final URL jarUrl;
- private final Set<String> jarFiles;
- private final Set<URL> classpaths;
- private final URL[] libraryUrls;
-
- public FunctionCacheEntryTest() {
- this.jarUrl =
getClass().getClassLoader().getResource("multifunction.jar");
- this.jarFiles = new HashSet<>();
- this.jarFiles.add(jarUrl.getPath());
- this.libraryUrls = new URL[] { jarUrl };
- this.classpaths = Collections.emptySet();
- }
-
- @Test
- public void testConstructor() {
- String iid = java.util.UUID.randomUUID().toString();
- FunctionCacheEntry entry = new FunctionCacheEntry(
- jarFiles,
- classpaths,
- libraryUrls,
- iid);
- assertTrue(entry.isInstanceRegistered(iid));
- entry.close();
- }
-
- @Test
- public void testUnregister() {
- String iid1 = java.util.UUID.randomUUID().toString();
- String iid2 = java.util.UUID.randomUUID().toString();
- FunctionCacheEntry entry = new FunctionCacheEntry(
- jarFiles,
- classpaths,
- libraryUrls,
- iid1);
- assertTrue(entry.isInstanceRegistered(iid1));
- assertFalse(entry.isInstanceRegistered(iid2));
-
- assertFalse(entry.unregister(iid2));
- assertTrue(entry.unregister(iid1));
- assertFalse(entry.isInstanceRegistered(iid1));
- entry.close();
- }
-
- @Test
- public void testRegisterJarFilesDontMatch() {
- String iid = java.util.UUID.randomUUID().toString();
- FunctionCacheEntry entry = new FunctionCacheEntry(
- jarFiles,
- classpaths,
- libraryUrls,
- iid);
- String iid2 = java.util.UUID.randomUUID().toString();
- try {
- entry.register(
- iid2,
- Collections.emptySet(),
- Collections.emptySet());
- fail("Should fail to register an instance if jar files don't
match");
- } catch (IllegalStateException e) {
- assertTrue(e.getMessage().contains("jar files"));
- } finally {
- entry.close();
- }
- }
-
- @Test
- public void testRegisterClasspathsDontMatch() throws IOException {
- String iid = java.util.UUID.randomUUID().toString();
- FunctionCacheEntry entry = new FunctionCacheEntry(
- jarFiles,
- classpaths,
- libraryUrls,
- iid);
- String iid2 = java.util.UUID.randomUUID().toString();
- try {
- entry.register(
- iid2,
- jarFiles,
-
Collections.singletonList(URI.create("http://localhost").toURL()));
- fail("Should fail to register an instance if jar files don't
match");
- } catch (IllegalStateException e) {
- assertTrue(e.getMessage().contains("classpaths"));
- } finally {
- entry.close();
- }
- }
-
- @Test
- public void testRegister() {
- String iid1 = java.util.UUID.randomUUID().toString();
- String iid2 = java.util.UUID.randomUUID().toString();
- FunctionCacheEntry entry = new FunctionCacheEntry(
- jarFiles,
- classpaths,
- libraryUrls,
- iid1);
- assertTrue(entry.isInstanceRegistered(iid1));
- assertFalse(entry.isInstanceRegistered(iid2));
-
- entry.register(
- iid2,
- jarFiles,
- classpaths);
- assertTrue(entry.isInstanceRegistered(iid2));
- entry.close();
- }
-}
diff --git
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheManagerImplTest.java
b/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheManagerImplTest.java
deleted file mode 100644
index 00049d339c..0000000000
---
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheManagerImplTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * 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.pulsar.functions.utils.functioncache;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertSame;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.function.Function;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- * Unit test of {@link FunctionCacheManagerImpl}.
- */
-public class FunctionCacheManagerImplTest {
-
- private URL jarUrl;
- private List<String> jarFiles;
- private List<URL> classpaths;
- private FunctionCacheManagerImpl cacheManager;
-
- @BeforeMethod
- public void setUp() {
- this.jarUrl =
getClass().getClassLoader().getResource("multifunction.jar");
- this.jarFiles = new
ArrayList<>(Collections.singletonList(jarUrl.getPath()));
- this.classpaths = Collections.emptyList();
- this.cacheManager = new FunctionCacheManagerImpl();
- }
-
- @AfterMethod
- public void tearDown() {
- this.cacheManager.close();
- }
-
- void verifyClassLoader(ClassLoader clsLoader) throws Exception {
- assertNotNull(clsLoader);
- Class<? extends Function<Integer, Integer>> cls =
- (Class<? extends Function<Integer, Integer>>)
-
clsLoader.loadClass("org.apache.pulsar.functions.runtime.functioncache.AddFunction");
- Function<Integer, Integer> func = cls.newInstance();
- assertEquals(4, func.apply(2).intValue());
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testGetClassLoaderNullFunctionID() {
- this.cacheManager.getClassLoader(null);
- }
-
- @Test(expectedExceptions = IllegalStateException.class)
- public void testGetClassLoaderNotFound() {
-
this.cacheManager.getClassLoader(java.util.UUID.randomUUID().toString());
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testRegisterNullFunctionID() throws Exception {
- this.cacheManager.registerFunctionInstance(
- null,
- java.util.UUID.randomUUID().toString(),
- Collections.emptyList(),
- Collections.emptyList());
- }
-
- @Test
- public void testRegister() throws Exception {
- String fid = java.util.UUID.randomUUID().toString();
- String eid = java.util.UUID.randomUUID().toString();
- this.cacheManager.registerFunctionInstance(fid, eid,
- jarFiles,
- classpaths);
-
- assertEquals(1, cacheManager.getCacheFunctions().size());
- FunctionCacheEntry entry = cacheManager.getCacheFunctions().get(fid);
- assertNotNull(entry);
- assertTrue(entry.isInstanceRegistered(eid));
- verifyClassLoader(cacheManager.getClassLoader(fid));
- }
-
- @Test
- public void testRegisterTwoInstances() throws Exception {
- String fid = java.util.UUID.randomUUID().toString();
- String iid1 = java.util.UUID.randomUUID().toString();
- String iid2 = java.util.UUID.randomUUID().toString();
-
- this.cacheManager.registerFunctionInstance(
- fid,
- iid1,
- jarFiles,
- classpaths);
-
- assertEquals(1, cacheManager.getCacheFunctions().size());
- FunctionCacheEntry entry1 = cacheManager.getCacheFunctions().get(fid);
- assertNotNull(entry1);
- assertTrue(entry1.isInstanceRegistered(iid1));
- verifyClassLoader(cacheManager.getClassLoader(fid));
-
- this.cacheManager.registerFunctionInstance(
- fid,
- iid2,
- jarFiles,
- classpaths);
-
- assertEquals(1, cacheManager.getCacheFunctions().size());
- FunctionCacheEntry entry2 = cacheManager.getCacheFunctions().get(fid);
- assertNotNull(entry2);
- assertSame(entry1, entry2);
- assertTrue(entry1.isInstanceRegistered(iid2));
- }
-
- @Test
- public void testUnregister() throws Exception {
- String fid = java.util.UUID.randomUUID().toString();
- String iid = java.util.UUID.randomUUID().toString();
-
- this.cacheManager.registerFunctionInstance(
- fid,
- iid,
- jarFiles,
- classpaths);
-
- assertEquals(1, cacheManager.getCacheFunctions().size());
- FunctionCacheEntry entry = cacheManager.getCacheFunctions().get(fid);
- assertNotNull(entry);
- assertTrue(entry.isInstanceRegistered(iid));
- verifyClassLoader(cacheManager.getClassLoader(fid));
-
- this.cacheManager.unregisterFunctionInstance(
- fid,
- iid);
-
- assertEquals(0, cacheManager.getCacheFunctions().size());
- assertNull(cacheManager.getCacheFunctions().get(fid));
- assertFalse(entry.isInstanceRegistered(iid));
- }
-
-}
diff --git
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionClassLoadersTest.java
b/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionClassLoadersTest.java
deleted file mode 100644
index cfd5203284..0000000000
---
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionClassLoadersTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * 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.pulsar.functions.utils.functioncache;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertSame;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.function.Function;
-import org.testng.annotations.Test;
-
-/**
- * Unit test of {@link FunctionClassLoaders}.
- */
-public class FunctionClassLoadersTest {
-
- @Test
- public void testCreateClassLoader() throws Exception {
- URL jarUrl =
getClass().getClassLoader().getResource("multifunction.jar");
- ClassLoader parent = getClass().getClassLoader();
- URLClassLoader clsLoader = FunctionClassLoaders.create(
- new URL[] { jarUrl },
- parent);
- assertSame(parent, clsLoader.getParent());
- Class<? extends Function<Integer, Integer>> cls =
- (Class<? extends Function<Integer, Integer>>)
-
clsLoader.loadClass("org.apache.pulsar.functions.runtime.functioncache.AddFunction");
- Function<Integer, Integer> func = cls.newInstance();
- assertEquals(4, func.apply(2).intValue());
- }
-
- @Test(expectedExceptions = ClassNotFoundException.class)
- public void testClassNotFound() throws Exception {
- ClassLoader clsLoader = getClass().getClassLoader();
-
clsLoader.loadClass("org.apache.pulsar.functions.runtime.functioncache.AddFunction");
- }
-
-}
diff --git a/pulsar-functions/utils/src/test/resources/multifunction.jar
b/pulsar-functions/utils/src/test/resources/multifunction.jar
deleted file mode 100644
index 9f8e1815ce..0000000000
Binary files a/pulsar-functions/utils/src/test/resources/multifunction.jar and
/dev/null differ
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services