From 99cfec04aabdf62a54376e854cc4a5d6dd40893c Mon Sep 17 00:00:00 2001 From: GSmithApps Date: Thu, 2 Jan 2025 14:05:58 -0600 Subject: [PATCH 1/7] Grant notes while onboarding to DSE and taking 102 courses. --- .vscode/settings.json | 7 ------- exercises/debug-activity/README.md | 7 ++++++- exercises/durable-execution/README.md | 16 +++++++++++----- .../TranslationActivitiesImpl.java | 4 ---- .../TranslationWorkflowImpl.java | 2 +- exercises/testing-code/README.md | 12 +++++++----- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 658a150..2643478 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,4 @@ { - "editor.minimap.enabled": false, "java.format.settings.url": "https://raw.githubusercontent.com/temporalio/edu-versioning-java-code/main/.vscode/custom-eclipse-java-google-style.xml", "java.checkstyle.configuration": "/google_checks.xml", "[java]": { @@ -8,9 +7,6 @@ "go.alternateTools": { "go": "/home/linuxbrew/.linuxbrew/bin/go", }, - "markdown.styles": [ - "style.css" - ], "terminal.integrated.defaultProfile.linux": "bash", "terminal.integrated.profiles.linux": { "bash": { @@ -21,7 +17,4 @@ } }, "workbench.startupEditor": "none", - "workbench.editorAssociations": { - "README.md": "vscode.markdown.preview.editor" - } } \ No newline at end of file diff --git a/exercises/debug-activity/README.md b/exercises/debug-activity/README.md index 7033325..ec6d715 100644 --- a/exercises/debug-activity/README.md +++ b/exercises/debug-activity/README.md @@ -26,6 +26,11 @@ the code. | `ex3w` | Execute the Exercise 3 Worker. Must be within the appropriate directory for this to succeed. (either `practice` or `solution`) | | `ex3st` | Execute the Exercise 3 Starter. Must be within the appropriate directory for this to succeed. (either `practice` or `solution`) | +## Prerequisite: Ensure the Temporal Service is running + +1. Start the Temporal Service from the command line with + `temporal server start-dev` + ## Part A: Run the Workflow In this part of the exercise, you will start two Workers and run the @@ -182,7 +187,7 @@ in the Workflow code, rather than in an Activity, since that is typically not prone to failure and unlikely to affect whether the Workflow executes in a deterministic manner. This exercise implemented it in the Activity, since you can deploy a fix to Activity code without a risk of causing a -non-deterministic error. Later in this course, you'll learn how to safely +non-deterministic error. As you learned earlier in this course, there are also ways to safely deploy changes to Workflow Definitions. ### This is the end of the exercise. diff --git a/exercises/durable-execution/README.md b/exercises/durable-execution/README.md index 283b93d..e182c96 100644 --- a/exercises/durable-execution/README.md +++ b/exercises/durable-execution/README.md @@ -20,13 +20,18 @@ skip this step. An instance of the Microservice is already running in your environment** 1. Navigate to the `utilities` directory at the root level of the course -2. Change directoryies into the `microservice directory` +2. Change directories into the `microservice directory` 1. `cd utilities/microservice` 3. Compile the microservice 1. `mvn clean compile` 4. Start the microservice 1. `mvn exec:java -Dexec.mainClass="translationapi.Microservice"` +## Prerequisite: Ensure the Temporal Service is running + +1. Start the Temporal Service from the command line with + `temporal server start-dev` + ### GitPod Environment Shortcuts If you are executing the exercises in the provided GitPod environment, you @@ -74,7 +79,7 @@ You will now add a Timer between the two Activity calls in the Workflow Definiti 1. After the statement where `helloMessage` is defined, but before the statement where `goodbyeInput` is defined, add a new statement that logs the message `Sleeping between translation calls` at the info level. -2. Just after the new log statement, use `workflow.Sleep(Duration.ofSeconds(30))` to set a Timer for 30 seconds +2. Just after the new log statement, use `workflow.Sleep(Duration.ofSeconds(10))` to set a Timer for 30 seconds ## Part D: Observe Durable Execution @@ -89,9 +94,10 @@ Before proceeding, make sure that there are no Workers running for this or any p 1. If your using the GitPod environment, you can run `ex1w` 4. In another terminal, execute the Workflow by running `mvn exec:java -Dexec.mainClass="translationworkflow.Starter" -Dexec.args="Stanislav sk"` (replace `Stanislav` with your first name) 1. If your using the GitPod environment, you can run `ex1st "Stanislav sk` -5. Observe the output in the terminal windows used by each worker. 6. As soon as you see a log message in one of the Worker terminals indicating that it has started the Timer, locate the terminal with the message `[ACTIVITY INVOKED]...` and press Ctrl-C in _that_ window to kill that Worker process. -6. Switch to the terminal window for the other Worker process. Within a few seconds, you should observe new output, indicating that it has resumed execution of the Workflow. -7. Once you see log output indicating that translation was successful, switch back to the terminal window where you started the Workflow. +5. Observe the output in the terminal windows used by each worker. +6. As soon as you see a log message in one of the Worker terminals indicating that it has started the Timer, locate the terminal with the message `[ACTIVITY INVOKED]...` and press Ctrl-C in _that_ window to kill that Worker process. +7. Switch to the terminal window for the other Worker process. Within a few seconds, you should observe new output, indicating that it has resumed execution of the Workflow. +8. Once you see log output indicating that translation was successful, switch back to the terminal window where you started the Workflow. After the final step, you should see the translated Hello and Goodbye messages, which confirms that Workflow Execution completed successfully despite the original Worker being killed. diff --git a/exercises/durable-execution/practice/src/main/java/translationworkflow/TranslationActivitiesImpl.java b/exercises/durable-execution/practice/src/main/java/translationworkflow/TranslationActivitiesImpl.java index 46ad777..d6138b1 100644 --- a/exercises/durable-execution/practice/src/main/java/translationworkflow/TranslationActivitiesImpl.java +++ b/exercises/durable-execution/practice/src/main/java/translationworkflow/TranslationActivitiesImpl.java @@ -1,7 +1,6 @@ package translationworkflow; import java.net.HttpURLConnection; -import java.net.ProtocolException; import java.net.URI; import java.net.URL; import java.net.URLEncoder; @@ -10,10 +9,7 @@ import java.io.IOException; import io.temporal.activity.Activity; import io.temporal.failure.ApplicationFailure; -import java.net.HttpURLConnection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import translationworkflow.model.TranslationActivityInput; import translationworkflow.model.TranslationActivityOutput; diff --git a/exercises/durable-execution/practice/src/main/java/translationworkflow/TranslationWorkflowImpl.java b/exercises/durable-execution/practice/src/main/java/translationworkflow/TranslationWorkflowImpl.java index 1c0aa28..8db7a65 100644 --- a/exercises/durable-execution/practice/src/main/java/translationworkflow/TranslationWorkflowImpl.java +++ b/exercises/durable-execution/practice/src/main/java/translationworkflow/TranslationWorkflowImpl.java @@ -39,9 +39,9 @@ public TranslationWorkflowOutput sayHelloGoodbye(TranslationWorkflowInput input) // TODO: Part C - Use Workflow.sleep to create a timer here for 30s + TranslationActivityInput goodbyeInput = new TranslationActivityInput("goodbye", languageCode); // TODO: Add a log statement here at the debug level stating that the Activity is going // to be invoked. Be sure to include the word being translated and the language code. - TranslationActivityInput goodbyeInput = new TranslationActivityInput("goodbye", languageCode); TranslationActivityOutput goodbyeResult = activities.translateTerm(goodbyeInput); String goodbyeMessage = goodbyeResult.getTranslation() + ", " + name; diff --git a/exercises/testing-code/README.md b/exercises/testing-code/README.md index a49b409..2fbd737 100644 --- a/exercises/testing-code/README.md +++ b/exercises/testing-code/README.md @@ -49,9 +49,10 @@ translates the term "Hello" to German. Take a moment to study the test, which you'll find in the `TranslationActivitiesTest.java` file in the `src/test/java/translationworkflow` directory. Since the test runs the Activity, which in turn calls the microservice to do the translation, ensure -that your microservice is running as state above. Then run the test. +that your microservice is running as stated above. Then run the test. -1. Run the `mvn test` command to execute the provided test +1. `cd` into `exercises/testing-code/practice/` +2. Run the `mvn test` command to execute the provided test ## Part B: Write and Run Another Test for the Activity @@ -107,8 +108,8 @@ following steps: 1. Edit the `TranslationWorkflowTest.java` file in the `src/test/java/translationworkflow` directory 2. Add assertions for the following conditions to the `testSuccessfulTranslation` test - - The `helloMessage` field in the result is `Bonjour, Pierre` - - The `goodbyeMessage` field in the result is `Au revoir, Pierre` + - The `helloMessage` field in the output is `Bonjour, Pierre` + - The `goodbyeMessage` field in the output is `Au revoir, Pierre` 3. Save your changes 4. Run `mvn test`. This will fail, due to a bug in the Workflow Definition. 5. Find and fix the bug in the Workflow Definition @@ -153,7 +154,8 @@ when(mockedActivities.translateTerm(new TranslationActivityInput("hello", "fr")) with the `fr` language code specified. 8. Modify the Worker registration line to use the new `mockedActivities` instance. 9. Save your changes -10. Add the following code at the bottom of the `TranslateActivityInput` class. +10. Add the following code at the bottom of the `TranslateActivityInput` class, + and add this import at the top of the file: `import java.util.Objects;`. - Why is this necessary? If you ran the test now as written, it would fail. This is because comparisons of the `TranslateActivityInput` objects (as with all objects in Java) invoke its `equals` method. Because this class From 3250c59a371cc3125172f0d87c79960180ffcd8a Mon Sep 17 00:00:00 2001 From: Grant <14.gsmith.14@gmail.com> Date: Wed, 8 Jan 2025 13:19:05 -0600 Subject: [PATCH 2/7] fix my typo --- exercises/durable-execution/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/durable-execution/README.md b/exercises/durable-execution/README.md index e182c96..d96d8a6 100644 --- a/exercises/durable-execution/README.md +++ b/exercises/durable-execution/README.md @@ -79,7 +79,7 @@ You will now add a Timer between the two Activity calls in the Workflow Definiti 1. After the statement where `helloMessage` is defined, but before the statement where `goodbyeInput` is defined, add a new statement that logs the message `Sleeping between translation calls` at the info level. -2. Just after the new log statement, use `workflow.Sleep(Duration.ofSeconds(10))` to set a Timer for 30 seconds +2. Just after the new log statement, use `workflow.Sleep(Duration.ofSeconds(10))` to set a Timer for 10 seconds ## Part D: Observe Durable Execution From d0734c12db4e2ceb51ab2c9b95c6e63f3c28f87a Mon Sep 17 00:00:00 2001 From: GSmithApps Date: Wed, 8 Jan 2025 13:30:18 -0600 Subject: [PATCH 3/7] removed changes in settings.json --- .vscode/settings.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2643478..658a150 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { + "editor.minimap.enabled": false, "java.format.settings.url": "https://raw.githubusercontent.com/temporalio/edu-versioning-java-code/main/.vscode/custom-eclipse-java-google-style.xml", "java.checkstyle.configuration": "/google_checks.xml", "[java]": { @@ -7,6 +8,9 @@ "go.alternateTools": { "go": "/home/linuxbrew/.linuxbrew/bin/go", }, + "markdown.styles": [ + "style.css" + ], "terminal.integrated.defaultProfile.linux": "bash", "terminal.integrated.profiles.linux": { "bash": { @@ -17,4 +21,7 @@ } }, "workbench.startupEditor": "none", + "workbench.editorAssociations": { + "README.md": "vscode.markdown.preview.editor" + } } \ No newline at end of file From 6b7e17036411a95a5e34e91fa9be1f75624baf3b Mon Sep 17 00:00:00 2001 From: GSmithApps Date: Wed, 8 Jan 2025 13:37:05 -0600 Subject: [PATCH 4/7] removed one of my changes that didn't matter --- exercises/durable-execution/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/durable-execution/README.md b/exercises/durable-execution/README.md index d96d8a6..4ba8b70 100644 --- a/exercises/durable-execution/README.md +++ b/exercises/durable-execution/README.md @@ -79,7 +79,7 @@ You will now add a Timer between the two Activity calls in the Workflow Definiti 1. After the statement where `helloMessage` is defined, but before the statement where `goodbyeInput` is defined, add a new statement that logs the message `Sleeping between translation calls` at the info level. -2. Just after the new log statement, use `workflow.Sleep(Duration.ofSeconds(10))` to set a Timer for 10 seconds +2. Just after the new log statement, use `workflow.Sleep(Duration.ofSeconds(30))` to set a Timer for 30 seconds ## Part D: Observe Durable Execution From 76a74c1aa5efab5b814140a69f0d5283aca31ab1 Mon Sep 17 00:00:00 2001 From: GSmithApps Date: Wed, 8 Jan 2025 13:38:46 -0600 Subject: [PATCH 5/7] removed the note that reminds user to start server --- exercises/debug-activity/README.md | 5 ----- exercises/durable-execution/README.md | 5 ----- 2 files changed, 10 deletions(-) diff --git a/exercises/debug-activity/README.md b/exercises/debug-activity/README.md index ec6d715..de7e538 100644 --- a/exercises/debug-activity/README.md +++ b/exercises/debug-activity/README.md @@ -26,11 +26,6 @@ the code. | `ex3w` | Execute the Exercise 3 Worker. Must be within the appropriate directory for this to succeed. (either `practice` or `solution`) | | `ex3st` | Execute the Exercise 3 Starter. Must be within the appropriate directory for this to succeed. (either `practice` or `solution`) | -## Prerequisite: Ensure the Temporal Service is running - -1. Start the Temporal Service from the command line with - `temporal server start-dev` - ## Part A: Run the Workflow In this part of the exercise, you will start two Workers and run the diff --git a/exercises/durable-execution/README.md b/exercises/durable-execution/README.md index 4ba8b70..e2345cc 100644 --- a/exercises/durable-execution/README.md +++ b/exercises/durable-execution/README.md @@ -27,11 +27,6 @@ environment** 4. Start the microservice 1. `mvn exec:java -Dexec.mainClass="translationapi.Microservice"` -## Prerequisite: Ensure the Temporal Service is running - -1. Start the Temporal Service from the command line with - `temporal server start-dev` - ### GitPod Environment Shortcuts If you are executing the exercises in the provided GitPod environment, you From 5dae09e14bf57f43f473cf4914feb7edef49170d Mon Sep 17 00:00:00 2001 From: Mason Egger Date: Wed, 12 Mar 2025 15:14:09 -0500 Subject: [PATCH 6/7] tweaks --- .../main/java/translationworkflow/TranslationWorkflowImpl.java | 3 ++- .../java/translationworkflow/TranslationActivitiesImpl.java | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/exercises/durable-execution/practice/src/main/java/translationworkflow/TranslationWorkflowImpl.java b/exercises/durable-execution/practice/src/main/java/translationworkflow/TranslationWorkflowImpl.java index 8db7a65..4859e4e 100644 --- a/exercises/durable-execution/practice/src/main/java/translationworkflow/TranslationWorkflowImpl.java +++ b/exercises/durable-execution/practice/src/main/java/translationworkflow/TranslationWorkflowImpl.java @@ -39,9 +39,10 @@ public TranslationWorkflowOutput sayHelloGoodbye(TranslationWorkflowInput input) // TODO: Part C - Use Workflow.sleep to create a timer here for 30s - TranslationActivityInput goodbyeInput = new TranslationActivityInput("goodbye", languageCode); // TODO: Add a log statement here at the debug level stating that the Activity is going // to be invoked. Be sure to include the word being translated and the language code. + + TranslationActivityInput goodbyeInput = new TranslationActivityInput("goodbye", languageCode); TranslationActivityOutput goodbyeResult = activities.translateTerm(goodbyeInput); String goodbyeMessage = goodbyeResult.getTranslation() + ", " + name; diff --git a/exercises/durable-execution/solution/src/main/java/translationworkflow/TranslationActivitiesImpl.java b/exercises/durable-execution/solution/src/main/java/translationworkflow/TranslationActivitiesImpl.java index 41236d5..c2b922f 100644 --- a/exercises/durable-execution/solution/src/main/java/translationworkflow/TranslationActivitiesImpl.java +++ b/exercises/durable-execution/solution/src/main/java/translationworkflow/TranslationActivitiesImpl.java @@ -1,7 +1,6 @@ package translationworkflow; import java.net.HttpURLConnection; -import java.net.ProtocolException; import java.net.URI; import java.net.URL; import java.net.URLEncoder; @@ -10,7 +9,6 @@ import java.io.IOException; import io.temporal.activity.Activity; import io.temporal.failure.ApplicationFailure; -import java.net.HttpURLConnection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; From ef06c9abc7ccad63ce61296d2b067429b079be2e Mon Sep 17 00:00:00 2001 From: Mason Egger Date: Wed, 12 Mar 2025 15:14:46 -0500 Subject: [PATCH 7/7] forgot one --- exercises/testing-code/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exercises/testing-code/README.md b/exercises/testing-code/README.md index 2fbd737..4375a6f 100644 --- a/exercises/testing-code/README.md +++ b/exercises/testing-code/README.md @@ -154,8 +154,7 @@ when(mockedActivities.translateTerm(new TranslationActivityInput("hello", "fr")) with the `fr` language code specified. 8. Modify the Worker registration line to use the new `mockedActivities` instance. 9. Save your changes -10. Add the following code at the bottom of the `TranslateActivityInput` class, - and add this import at the top of the file: `import java.util.Objects;`. +10. Add the following code at the bottom of the `TranslateActivityInput` class. - Why is this necessary? If you ran the test now as written, it would fail. This is because comparisons of the `TranslateActivityInput` objects (as with all objects in Java) invoke its `equals` method. Because this class