Skip to content

Commit 0de01b9

Browse files
authored
Swtich to newCachedThreadPool (#235)
* Update to E2E tests to latest snapshot
1 parent 8a0fbf7 commit 0de01b9

File tree

7 files changed

+25
-13
lines changed

7 files changed

+25
-13
lines changed

build.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ function StopOnFailedExecution {
77
}
88
}
99

10+
$skipCliDownload = $args[0]
11+
1012
$currDir = Get-Location
1113

1214
Write-Host "Building azure-function-java-worker"
1315
cmd.exe /c '.\mvnBuild.bat'
1416
StopOnFailedExecution
1517

1618
Write-Host "Starting azure-functions-java-endtoendtests execution"
17-
.\setup-tests.ps1
19+
Write-Host s$cliDownload
20+
.\setup-tests.ps1 $skipCliDownload
1821
$proc = start-process -filepath $currDir\Azure.Functions.Cli\func.exe -WorkingDirectory "$currDir\endtoendtests\target\azure-functions\azure-functions-java-endtoendtests" -ArgumentList "host start" -PassThru
1922

2023
# wait for host to start

endtoendtests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Microsoft Azure Functions in Java
1+
# Azure Functions in Java
22

33
This repo contains several Java Azure Functions samples for different events.
44

endtoendtests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<maven.compiler.source>1.8</maven.compiler.source>
1616
<maven.compiler.target>1.8</maven.compiler.target>
17-
<azure.functions.maven.plugin.version>1.0.0-beta-8-SNAPSHOT</azure.functions.maven.plugin.version>
17+
<azure.functions.maven.plugin.version>1.2.0-SNAPSHOT</azure.functions.maven.plugin.version>
1818
<azure.functions.java.library.version>1.0.0-beta-7-SNAPSHOT</azure.functions.java.library.version>
1919
<functionAppName>azure-functions-java-endtoendtests</functionAppName>
2020
<functionAppRegion>westus</functionAppRegion>

setup-tests.ps1

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@ function StopOnFailedExecution {
66
exit $LastExitCode
77
}
88
}
9+
Write-Host "$args[0]"
10+
Write-Host $args[0]
911

10-
$currDir = Get-Location
12+
$skipCliDownload = $false
13+
if($args[0])
14+
{
15+
$skipCliDownload = $args[0]
16+
}
17+
Write-Host $skipCliDownload
1118

19+
$currDir = Get-Location
20+
if(!$skipCliDownload)
21+
{
1222
Write-Host "Deleting Functions Core Tools if exists...."
1323
Remove-Item -Force ./Azure.Functions.Cli.zip -ErrorAction Ignore
1424
Remove-Item -Recurse -Force ./Azure.Functions.Cli -ErrorAction Ignore
@@ -25,7 +35,7 @@ $wc.DownloadFile($url, $output)
2535

2636
Write-Host "Extracting Functions Core Tools...."
2737
Expand-Archive ".\Azure.Functions.Cli.zip" -DestinationPath ".\Azure.Functions.Cli"
28-
38+
}
2939
Write-Host "Copying azure-functions-java-worker to Functions Host workers directory...."
3040
Get-ChildItem -Path .\target\* -Include 'azure*' -Exclude '*shaded.jar' | %{ Copy-Item $_.FullName ".\Azure.Functions.Cli\workers\java\azure-functions-java-worker.jar" }
3141
Copy-Item ".\worker.config.json" ".\Azure.Functions.Cli\workers\java"

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void close() throws Exception {
6868
private class StreamingMessagePeer implements StreamObserver<StreamingMessage>, AutoCloseable {
6969
StreamingMessagePeer() {
7070
this.task = new CompletableFuture<>();
71-
this.threadpool = Executors.newWorkStealingPool();
71+
this.threadpool = Executors.newCachedThreadPool();
7272
this.observer = FunctionRpcGrpc.newStub(JavaWorkerClient.this.channel).eventStream(this);
7373
}
7474

@@ -87,10 +87,10 @@ public synchronized void close() throws Exception {
8787
public void onNext(StreamingMessage message) {
8888
MessageHandler<?, ?> handler = JavaWorkerClient.this.handlerSuppliers.get(message.getContentCase()).get();
8989
handler.setRequest(message);
90-
handler.registerTask(this.threadpool.submit(() -> {
90+
this.threadpool.submit(() -> {
9191
handler.handle();
9292
this.send(message.getRequestId(), handler);
93-
}));
93+
});
9494
}
9595

9696
@Override

src/main/java/com/microsoft/azure/functions/worker/handler/InvocationRequestHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ String execute(InvocationRequest request, InvocationResponse.Builder response) t
2828

2929
this.invocationLogger = WorkerLogManager.getInvocationLogger(invocationId);
3030
response.setInvocationId(invocationId);
31-
31+
3232
List<ParameterBinding> outputBindings = new ArrayList<>();
3333
this.broker.invokeMethod(functionId, request, outputBindings).ifPresent(response::setReturnValue);
3434
response.addAllOutputData(outputBindings);
3535

36-
return String.format("Function \"%s\" (ID: %s) invoked by Java Worker",
37-
this.broker.getMethodName(functionId).orElse("UNKNOWN"), functionId);
36+
return String.format("Function \"%s\" (Id: %s) invoked by Java Worker",
37+
this.broker.getMethodName(functionId).orElse("UNKNOWN"), invocationId);
3838
}
3939

4040
private JavaFunctionBroker broker;

src/main/java/com/microsoft/azure/functions/worker/handler/MessageHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public void handle() {
5959
this.responseStatusMarshaller.accept(this.response, result.build());
6060
}
6161
}
62-
63-
public void registerTask(Future<?> task) { }
62+
6463
Logger getLogger() { return WorkerLogManager.getHostLogger(); }
6564
abstract String execute(TRequest request, TResponse response) throws Exception;
6665

0 commit comments

Comments
 (0)