Code Monkey home page Code Monkey logo

compute-java-manage-vm-async's Introduction

page_type languages products extensions
sample
java
azure
services platforms
Compute
java

Getting Started with Compute - Manage Virtual Machine Async - in Java

Azure Compute sample for managing virtual machines -

  • Create a virtual machine with managed OS Disk based on Windows OS image
  • Once Network is created start creation of virtual machine based on Linux OS image in the same network
  • Update both virtual machines in parallel
    • for Linux based:
      • add Tag
    • for Windows based:
      • add a data disk
  • List virtual machines and print details
  • Delete all virtual machines.

Running this Sample

To run this sample:

See DefaultAzureCredential and prepare the authentication works best for you. For more details on authentication, please refer to AUTH.md.

git clone https://github.com/Azure-Samples/compute-java-manage-vm-async.git

cd compute-java-manage-vm-async

mvn clean compile exec:java

More information

For general documentation as well as quickstarts on how to use Azure Management Libraries for Java, please see here.

If you find bug in the sample, please create an issue here.

Start to develop applications with Java on Azure here.

If you don't have a Microsoft Azure subscription you can get a FREE trial account here.


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

compute-java-manage-vm-async's People

Contributors

anuchandy avatar anudeepsharma avatar azure-fluent avatar jianghaolu avatar lenala avatar microsoftopensource avatar msftgits avatar supernova-eng avatar v-hearya avatar weidongxu-microsoft avatar xiaofeicao avatar xseeseesee avatar yaohaizh avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

isabella232

compute-java-manage-vm-async's Issues

Azure JAVA sdk struck at the time of starting or tagging virtual machine even though if we use async

"When we try to add tag or remove tag to virtual machines in a bulk request of 500 vms, few of the vm request got struck or hung and not getting response even after waiting more than 10 mins. We are using java azure sdk and we also tried both the azure sync and async approach. It hangs in both the situation for bulk vms. Start and stop vms in bulk hangs for a very long time more than 45 minutes and not getting the response back. Please suggest an approach on the bulk VM operations."

Async methods are not actually Async. They seem to be blocking


PostDeleteChecker checker = new PostDeleteChecker(azure, vmResourceGroup, vmName);
azure.resourceGroups().deleteByNameAsync(vmResourceGroup.name(), checker.deleteServiceCallbackHandler);

ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(checker);
executorService.shutdown();
System.out.println("here");


class PostDeleteChecker implements Runnable
{
Azure azure;
ResourceGroup resourceGroup;
String vmName;

public PostDeleteChecker(Azure azure, ResourceGroup vmResourceGroup, String vmName) {
	this.azure = azure;
	this.resourceGroup = vmResourceGroup;
	this.vmName = vmName;
}

@Override
public void run() {			
	logger.info("Waiting for operation completion...");
}
		
private ServiceCallback<Void> deleteServiceCallbackHandler = new ServiceCallback<Void>(){

	@Override
	public void failure(Throwable arg0) 
	{
		logger.error("Delete operation Error! " + arg0.getMessage());				
	}

	@Override
	public void success(Void arg0) 
	{
		logger.info("Delete operation Success!");
	}
	
};

public ServiceCallback<Void> getDeleteServiceCallbackHandler() {
	return deleteServiceCallbackHandler;
}

}	

If you run the above code, neither System.out.println("here"); nor logger.info("Waiting for operation completion..."); gets executed until the resource group has been deleted completed. Then how is this asynchronous in any way?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.