Skip to content

Commit 76ed22e

Browse files
authored
Merge pull request #42 from uber/fix-header
Fix java samples file header
2 parents d748dd1 + 545cffa commit 76ed22e

File tree

2 files changed

+47
-25
lines changed

2 files changed

+47
-25
lines changed

src/main/java/com/uber/cadence/samples/hello/HelloSideEffect.java

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Modifications copyright (C) 2017 Uber Technologies, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
7+
* use this file except in compliance with the License. A copy of the License is
8+
* located at
9+
*
10+
* http://aws.amazon.com/apache2.0
11+
*
12+
* or in the "license" file accompanying this file. This file is distributed on
13+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
* express or implied. See the License for the specific language governing
15+
* permissions and limitations under the License.
16+
*/
17+
118
package com.uber.cadence.samples.hello;
219

320
import static com.uber.cadence.samples.common.SampleConstants.DOMAIN;

src/main/java/com/uber/cadence/samples/hello/HelloWorkerSetup.java

+30-25
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717

1818
package com.uber.cadence.samples.hello;
1919

20+
import static com.uber.cadence.samples.common.SampleConstants.DOMAIN;
21+
2022
import com.uber.cadence.activity.ActivityMethod;
2123
import com.uber.cadence.client.WorkflowClient;
2224
import com.uber.cadence.worker.Worker;
2325
import com.uber.cadence.worker.WorkerOptions;
2426
import com.uber.cadence.workflow.Workflow;
2527
import com.uber.cadence.workflow.WorkflowMethod;
2628

27-
import static com.uber.cadence.samples.common.SampleConstants.DOMAIN;
28-
2929
/**
30-
* Hello World Cadence workflow that executes a single activity with full example of how to customize
31-
* a worker
30+
* Hello World Cadence workflow that executes a single activity with full example of how to
31+
* customize a worker
3232
*/
3333
public class HelloWorkerSetup {
3434

@@ -76,33 +76,38 @@ public static void main(String[] args) {
7676
// Start a worker that hosts both workflow and activity implementations.
7777

7878
/**
79-
* If you see error "Not enough threads to execute workflows" exception it indicates that there are
80-
* not enough threads to execute currently running workflow tasks.
81-
*
82-
* For example, if each workflow uses two threads(using Asycn function) and maxConcurrentWorklfowExecutionSize is 100,
83-
* and assuming the factory only creates one worker. Then maxWorkflowThreads should be at least 200.
84-
* With such setup 0 workflows will be cached as all the threads would be consumed by the currently executing workflow tasks.
85-
* So in general it is better to keep maxWorkflowThreads much higher than maxConcurrentWorklfowExecutionSize to support caching.
86-
*
87-
* maxWorkflowThreads defines how many threads all currently executing and cached workflows can use.
88-
* It's a Factory level option, meaning that the thread pool is shared across all workers created by the factory.
79+
* If you see error "Not enough threads to execute workflows" exception it indicates that there
80+
* are not enough threads to execute currently running workflow tasks.
8981
*
90-
* maxConcurrentWorklfowExecutionSize defines how many workflow tasks can execute in parallel.
91-
* It's a worker level option.
82+
* <p>For example, if each workflow uses two threads(using Asycn function) and
83+
* maxConcurrentWorklfowExecutionSize is 100, and assuming the factory only creates one worker.
84+
* Then maxWorkflowThreads should be at least 200. With such setup 0 workflows will be cached as
85+
* all the threads would be consumed by the currently executing workflow tasks. So in general it
86+
* is better to keep maxWorkflowThreads much higher than maxConcurrentWorklfowExecutionSize to
87+
* support caching.
9288
*
89+
* <p>maxWorkflowThreads defines how many threads all currently executing and cached workflows
90+
* can use. It's a Factory level option, meaning that the thread pool is shared across all
91+
* workers created by the factory.
9392
*
93+
* <p>maxConcurrentWorklfowExecutionSize defines how many workflow tasks can execute in
94+
* parallel. It's a worker level option.
9495
*/
95-
Worker.Factory factory = new Worker.Factory(DOMAIN,
96+
Worker.Factory factory =
97+
new Worker.Factory(
98+
DOMAIN,
9699
new Worker.FactoryOptions.Builder()
97-
.setMaxWorkflowThreadCount(1000)
98-
.setCacheMaximumSize(100)
99-
.setDisableStickyExecution(false)
100-
.build());
101-
Worker worker = factory.newWorker(TASK_LIST,
100+
.setMaxWorkflowThreadCount(1000)
101+
.setCacheMaximumSize(100)
102+
.setDisableStickyExecution(false)
103+
.build());
104+
Worker worker =
105+
factory.newWorker(
106+
TASK_LIST,
102107
new WorkerOptions.Builder()
103-
.setMaxConcurrentActivityExecutionSize(100)
104-
.setMaxConcurrentWorkflowExecutionSize(100)
105-
.build());
108+
.setMaxConcurrentActivityExecutionSize(100)
109+
.setMaxConcurrentWorkflowExecutionSize(100)
110+
.build());
106111
// Workflows are stateful. So you need a type to create instances.
107112
worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class);
108113
// Activities are stateless and thread safe. So a shared instance is used.

0 commit comments

Comments
 (0)