-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add digital twin lifecycle sample #14744
Conversation
2c34588
to
81835bd
Compare
.forEach((twinId, twinContent) -> { | ||
// Call APIs to delete all relationships. | ||
client.listRelationships(twinId, BasicRelationship.class) | ||
.doOnComplete(deleteRelationshipsSemaphore::release) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This runnable is executed when the flux completes successfully.
// Call APIs to delete all relationships. | ||
client.listRelationships(twinId, BasicRelationship.class) | ||
.doOnComplete(deleteRelationshipsSemaphore::release) | ||
.doOnError(throwable -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is executed when the flux completes with an error
@@ -6,7 +6,9 @@ | |||
import com.azure.core.http.policy.HttpLogDetailLevel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have an Async Suffix in the file name to indicate that we are using Async APIs for this sample.
public static void createTwins() throws IOException, InterruptedException { | ||
System.out.println("CREATE DIGITAL TWINS"); | ||
Map<String, String> twins = FileHelper.loadAllFilesInPath(TwinsPath); | ||
final Semaphore createTwinsSemaphore = new Semaphore(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To understand why do we need semaphore here? Do we have some limitations for parallel operations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not really. The semaphore is to ensure that we do not exit before the async operation has completed. We start all async operations and then release the semaphore only once the async call has completed.
That way, the subsequent operations are executed after the previous call has completed -> similar to doing a await on a Task.
Update ReplicationLinks.json in 2021-02-01-preview (Azure#14744) * update ReplicationLinks.json in 2021-02-01-preview * update json file * update examples/ReplicationLinkGet.json
Update ReplicationLinks.json in 2021-02-01-preview (Azure#14744) * update ReplicationLinks.json in 2021-02-01-preview * update json file * update examples/ReplicationLinkGet.json
Add code for sample cleanup and creation of digital twin.
TODO: