Skip to content

Commit 83d5a08

Browse files
Init shading suppport
1 parent e0bfc6e commit 83d5a08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+137
-11
lines changed

README.md

+2-2

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ build_script:
3030
Write-Host “Found git tag."
3131
}
3232
else {
33-
$buildNumber = "1.6.2-$env:APPVEYOR_BUILD_NUMBER"
33+
$buildNumber = "1.7.1-$env:APPVEYOR_BUILD_NUMBER"
3434
Write-Host “git tag not found. Setting package suffix to '$buildNumber'"
3535
}
3636
.\package.ps1 -buildNumber $buildNumber

azure-pipelines.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ steps:
1919
Write-Host “Found git tag."
2020
}
2121
else {
22-
$buildNumber = "1.6.2-$(Build.BuildId)"
22+
$buildNumber = "1.7.1-$(Build.BuildId)"
2323
Write-Host “git tag not found. Setting package suffix to '$buildNumber'"
2424
}
25-
.\package.ps1 -buildNumber $buildNumber
25+
.\package-pipeline.ps1 -buildNumber $buildNumber
2626
displayName: 'Executing build script'
2727
- task: CopyFiles@2
2828
inputs:

e2e-nightly-cli-azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ steps:
1919
Write-Host “Found git tag."
2020
}
2121
else {
22-
$buildNumber = "1.6.2-$(Build.BuildId)"
22+
$buildNumber = "1.7.1-$(Build.BuildId)"
2323
Write-Host “git tag not found. Setting package suffix to '$buildNumber'"
2424
}
2525
.\package.ps1 -buildNumber $buildNumber
Binary file not shown.
3.05 KB
Binary file not shown.
189 KB
Binary file not shown.

lib_worker_1.6.2/commons-cli-1.4.jar

52.6 KB
Binary file not shown.
492 KB
Binary file not shown.
Binary file not shown.
28.3 KB
Binary file not shown.

lib_worker_1.6.2/grpc-core-1.20.0.jar

763 KB
Binary file not shown.
218 KB
Binary file not shown.
4.88 KB
Binary file not shown.
7.44 KB
Binary file not shown.

lib_worker_1.6.2/grpc-stub-1.20.0.jar

38.6 KB
Binary file not shown.

lib_worker_1.6.2/gson-2.8.5.jar

236 KB
Binary file not shown.

lib_worker_1.6.2/guava-26.0-jre.jar

2.61 MB
Binary file not shown.
8.58 KB
Binary file not shown.
Binary file not shown.

lib_worker_1.6.2/jna-5.3.0.jar

1.44 MB
Binary file not shown.
2.5 MB
Binary file not shown.

lib_worker_1.6.2/jsr305-3.0.2.jar

19.5 KB
Binary file not shown.
272 KB
Binary file not shown.
309 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
575 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
320 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
1.36 MB
Binary file not shown.

package-pipeline.ps1

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
param (
2+
[string]$buildNumber = $env:APPVEYOR_BUILD_NUMBER
3+
)
4+
5+
# A function that checks exit codes and fails script if an error is found
6+
function StopOnFailedExecution {
7+
if ($LastExitCode)
8+
{
9+
exit $LastExitCode
10+
}
11+
}
12+
Write-Host "Building azure-functions-java-worker"
13+
cmd.exe /c '.\mvnBuild.bat'
14+
StopOnFailedExecution
15+
16+
Write-Host "Creating nuget package Microsoft.Azure.Functions.JavaWorker"
17+
Write-Host "buildNumber: " $buildNumber
18+
Get-Command nuget
19+
StopOnFailedExecution
20+
remove-item pkg -Recurse -ErrorAction Ignore
21+
mkdir pkg
22+
Get-ChildItem -Path .\target\* -Include 'azure*' -Exclude '*shaded.jar','*tests.jar' | %{ Copy-Item $_.FullName .\pkg\azure-functions-java-worker.jar }
23+
StopOnFailedExecution
24+
copy-item ./worker.config.json pkg
25+
copy-item ./tools/AzureFunctionsJavaWorker.nuspec pkg/
26+
Copy-Item ".\lib_worker_1.6.2" pkg\lib -Recurse
27+
set-location pkg
28+
nuget pack -Properties version=$buildNumber
29+
set-location ..

package.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Get-ChildItem -Path .\target\* -Include 'azure*' -Exclude '*shaded.jar' | %{ Cop
2323
StopOnFailedExecution
2424
copy-item ./worker.config.json pkg
2525
copy-item ./tools/AzureFunctionsJavaWorker.nuspec pkg/
26+
Copy-Item ".\lib_worker_1.6.2" pkg\lib -Recurse
2627
set-location pkg
2728
nuget pack -Properties version=$buildNumber
2829
set-location ..

pom.xml

+54-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.microsoft.azure.functions</groupId>
66
<artifactId>azure-functions-java-worker</artifactId>
7-
<version>1.6.2</version>
7+
<version>1.7.1</version>
88
<packaging>jar</packaging>
99
<parent>
1010
<groupId>com.microsoft.maven</groupId>
@@ -174,7 +174,7 @@
174174
</plugin>
175175
<plugin>
176176
<artifactId>maven-shade-plugin</artifactId>
177-
<version>3.2.0</version>
177+
<version>3.2.4</version>
178178
<executions>
179179
<execution>
180180
<phase>package</phase>
@@ -184,14 +184,15 @@
184184
<configuration>
185185
<transformers>
186186
<transformer
187-
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
187+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
188188
<mainClass>com.microsoft.azure.functions.worker.Application</mainClass>
189189
<manifestEntries>
190190
<Implementation-Title>${project.name}</Implementation-Title>
191191
<Implementation-Version>${project.version}</Implementation-Version>
192192
<Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
193193
</manifestEntries>
194194
</transformer>
195+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
195196
</transformers>
196197
<filters>
197198
<filter>
@@ -203,6 +204,56 @@
203204
</excludes>
204205
</filter>
205206
</filters>
207+
<relocations>
208+
<relocation combine.children="append">
209+
<pattern>com.google</pattern>
210+
<shadedPattern>com.microsoft.azure.functions.shaded.com.google</shadedPattern>
211+
</relocation>
212+
<relocation combine.children="append">
213+
<pattern>com.sun</pattern>
214+
<shadedPattern>com.microsoft.azure.functions.shaded.com.sun</shadedPattern>
215+
</relocation>
216+
<relocation combine.children="append">
217+
<pattern>android</pattern>
218+
<shadedPattern>com.microsoft.azure.functions.shaded.android</shadedPattern>
219+
</relocation>
220+
<relocation combine.children="append">
221+
<pattern>google</pattern>
222+
<shadedPattern>com.microsoft.azure.functions.shaded.google</shadedPattern>
223+
</relocation>
224+
<relocation combine.children="append">
225+
<pattern>identity</pattern>
226+
<shadedPattern>com.microsoft.azure.functions.shaded.identity</shadedPattern>
227+
</relocation>
228+
<relocation combine.children="append">
229+
<pattern>shared</pattern>
230+
<shadedPattern>com.microsoft.azure.functions.shaded.shared</shadedPattern>
231+
</relocation>
232+
<relocation combine.children="append">
233+
<pattern>org</pattern>
234+
<shadedPattern>com.microsoft.azure.functions.shaded.org</shadedPattern>
235+
</relocation>
236+
<relocation combine.children="append">
237+
<pattern>io.netty</pattern>
238+
<shadedPattern>com.microsoft.azure.functions.shaded.io.netty</shadedPattern>
239+
</relocation>
240+
<relocation combine.children="append">
241+
<pattern>io.perfmark</pattern>
242+
<shadedPattern>com.microsoft.azure.functions.shaded.io.perfmark</shadedPattern>
243+
</relocation>
244+
<relocation combine.children="append">
245+
<pattern>io.grpc</pattern>
246+
<shadedPattern>com.microsoft.azure.functions.shaded.io.grpc</shadedPattern>
247+
</relocation>
248+
<relocation combine.children="append">
249+
<pattern>javax.annotation</pattern>
250+
<shadedPattern>com.microsoft.azure.functions.shaded.javax.annotation</shadedPattern>
251+
</relocation>
252+
<relocation combine.children="append">
253+
<pattern>io.opencensus</pattern>
254+
<shadedPattern>com.microsoft.azure.functions.shaded.io.opencensus</shadedPattern>
255+
</relocation>
256+
</relocations>
206257
</configuration>
207258
</execution>
208259
</executions>

setup-tests-pipeline.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ if(!$skipCliDownload)
3636
Write-Host "Copying azure-functions-java-worker to Functions Host workers directory...."
3737
Get-ChildItem -Path .\target\* -Include 'azure*' -Exclude '*shaded.jar','*tests.jar' | %{ Copy-Item $_.FullName ".\Azure.Functions.Cli\workers\java\azure-functions-java-worker.jar" }
3838
Copy-Item ".\worker.config.json" ".\Azure.Functions.Cli\workers\java"
39-
39+
Copy-Item ".\lib_worker_1.6.2" ".\Azure.Functions.Cli\workers\java\lib" -Recurse

setup-tests.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ if(!$skipCliDownload)
4444
Write-Host "Copying azure-functions-java-worker to Functions Host workers directory...."
4545
Get-ChildItem -Path .\target\* -Include 'azure*' -Exclude '*shaded.jar','*tests.jar' | %{ Copy-Item $_.FullName ".\Azure.Functions.Cli\workers\java\azure-functions-java-worker.jar" }
4646
Copy-Item ".\worker.config.json" ".\Azure.Functions.Cli\workers\java"
47+
Copy-Item ".\lib_worker_1.6.2" ".\Azure.Functions.Cli\workers\java\lib" -Recurse
4748

4849
Write-Host "Building endtoendtests...."
4950
$Env:Path = $Env:Path+";$currDir\Azure.Functions.Cli"

src/main/java/com/microsoft/azure/functions/worker/Constants.java

+2
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
public final class Constants {
77
private Constants(){}
88
public final static String TRIGGER_METADATA_DOLLAR_REQUEST_KEY = "$request";
9+
public final static String FUNCTIONS_WORKER_DIRECTORY = "FUNCTIONS_WORKER_DIRECTORY";
10+
public final static String JAVA_REVERSE_JARS_LOADING = "JAVA_REVERSE_JARS_LOADING";
911
}

src/main/java/com/microsoft/azure/functions/worker/broker/JavaFunctionBroker.java

+43-1
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
package com.microsoft.azure.functions.worker.broker;
22

33
import java.io.File;
4+
import java.io.FileFilter;
45
import java.io.IOException;
56
import java.net.URL;
67
import java.util.*;
78
import java.util.concurrent.ConcurrentHashMap;
9+
import java.util.logging.Level;
810

911
import com.microsoft.azure.functions.rpc.messages.*;
1012
import com.microsoft.azure.functions.worker.Constants;
13+
import com.microsoft.azure.functions.worker.WorkerLogManager;
1114
import com.microsoft.azure.functions.worker.binding.BindingDataStore;
1215
import com.microsoft.azure.functions.worker.description.FunctionMethodDescriptor;
1316
import com.microsoft.azure.functions.worker.reflect.ClassLoaderProvider;
1417

18+
import org.apache.commons.lang3.SystemUtils;
1519
import org.apache.commons.lang3.exception.ExceptionUtils;
1620
import org.apache.commons.lang3.tuple.ImmutablePair;
1721

@@ -89,7 +93,45 @@ private void addSearchPathsToClassLoader(FunctionMethodDescriptor function) thro
8993

9094
private void registerWithClassLoaderProvider(File libDirectory) {
9195
try {
92-
classLoaderProvider.addDirectory(libDirectory);
96+
if(SystemUtils.IS_JAVA_1_8) {
97+
String workerPath = System.getenv(Constants.FUNCTIONS_WORKER_DIRECTORY) + "/lib";
98+
String reverseJarsLoading = System.getenv(Constants.JAVA_REVERSE_JARS_LOADING);
99+
if(reverseJarsLoading != null && reverseJarsLoading.toLowerCase().equals("true")) {
100+
if(!new File(workerPath).exists()) {
101+
throw new Exception("Customer: " + workerPath);
102+
} else {
103+
File[] jarFiles = new File(workerPath).listFiles(new FileFilter() {
104+
@Override
105+
public boolean accept(File file) {
106+
return file.isFile() && file.getName().endsWith(".jar");
107+
}
108+
});
109+
if(jarFiles.length == 0) {
110+
throw new Exception("Customer length: " + jarFiles.length);
111+
}
112+
}
113+
classLoaderProvider.addDirectory(libDirectory);
114+
classLoaderProvider.addDirectory(new File(workerPath));
115+
} else {
116+
if(!new File(workerPath).exists()) {
117+
throw new Exception("Default: " + workerPath);
118+
} else {
119+
File[] jarFiles = new File(workerPath).listFiles(new FileFilter() {
120+
@Override
121+
public boolean accept(File file) {
122+
return file.isFile() && file.getName().endsWith(".jar");
123+
}
124+
});
125+
if(jarFiles.length == 0) {
126+
throw new Exception("Default length: " + jarFiles.length);
127+
}
128+
}
129+
classLoaderProvider.addDirectory(new File(workerPath));
130+
classLoaderProvider.addDirectory(libDirectory);
131+
}
132+
} else {
133+
classLoaderProvider.addDirectory(libDirectory);
134+
}
93135
} catch (Exception ex) {
94136
ExceptionUtils.rethrow(ex);
95137
}

0 commit comments

Comments
 (0)