The demand for Java-based applications on Windows Azure is increasing as customers are realizing openness of Windows Azure that can provide scalability and high availability to their Java applications .We get a lot of questions about how to design various project components to manage single-tenant and multi-tenant applications, how to integrate project components with Windows Azure services. The challenge often faced by our customers while learning Windows Azure is that there is only a limited amount of informative articles and code samples that cover platforms other than NET.
Windows Azure is often perceived as being a .NET Cloud Platform, which isnΓÇÖt true. This misconception is based on demos and how-to blogs that are written around Microsoft Visual Studio. As it turns out, Windows Azure provides virtual machines that are either Windows Server 2008 SP2 or Windows Server 2008 R2, meaning that most of the Windows-based executable or scripts can be run on Windows Azure.
To increase awareness about the openness of the Windows Azure, we are releasing an Open Source Project, CloudNinja for Java , a reference application to illustrate how to build a multi-tenant application for Windows Azure.
CloudNinja for Java
CloudNinja for Java is a┬ámulti-tenant reference application designed to help the Java community develop Java applications for Windows Azure. In addition, our application also implements best practices and design patterns required for Java multi-tenant applications.
┬áThe CloudNinja for Java application encompasses following features and functionalities:
Tenant-level customization (for example, managing logos)
Per-tenant data isolation
Providing support for log-in via different identity providers (for example, Yahoo!, Google, Windows Live ID)
General purpose task scheduler
This application is built on several common OSS libraries, such as:
Spring for the MVC UI
JDBC and Hibernate for data access and object mapping
The project runs in Windows Azure and was developed entirely using Windows Azure Plugin for Eclipse with Java.
We utilized various Windows Azure services in the development and deployment of CloudNinja for Java. Some of the most important Windows Azure services used in this Java application are:
┬╖┬á┬á┬á┬á┬á┬á┬á┬á Access Control Service (ACS)
┬╖┬á┬á┬á┬á┬á┬á┬á┬á Windows Azure Storage
┬╖┬á┬á┬á┬á┬á┬á┬á┬á SQL Azure Database
┬╖┬á┬á┬á┬á┬á┬á┬á┬á Windows Azure Service Management
We believe that the CloudNinja for Java application will be beneficial to the Java community and encourage the Java developers to create their own applications for Windows Azure.
Interesting Features used in CloudNinja
Here are some featureres we have implemented in CloudNinja for Java.
┬á1. Use Access Control Service (ACS) for aunthentication using multiple Web Identity Providers
Windows Azure ACS Service has out-of-the-box support for popular web identity providers including Windows Live ID, Google, Yahoo!, and Facebook. We used ACS to enable authentication with these Web Identity providers.
2. Use REST APIs for Windows Azure ACS Management
Some Windows Azure features are not yet provided in the Windows Azure SDK for Java. For example, we wanted to manage ACS for creating relying parties from CloudNinja for Java application. As Windows Azure SDK for Java does not have any API for ACS management, we used REST APIs for ACS Management using a REST library (Restlet). The same technique could be used for any other REST-based feature in Windows Azure.
3. Monitor folders using Windows Azure Diagnostics and push the folder┬ádata to Windows Azure Blob Storage
Windows Azure Diagnostics is typically used to collect performance counters like processor idle time and available memory. In addition, it can also monitor a folder for any changes and push the content of the folder to a blob container periodically. We used this functionality to monitor the Tomcat access logs and process them to prepare usage statistics.
4. Reducing the Deployment Size
Windows Azure plugin for Eclipse bundles Java Web Server (such as Apache Tomcat) and JRE into the package to be deployed on Windows Azure. However adding Tomcat and the JRE adds about 70 MB to the package size resulting into longer time to upload the deployment package to Windows Azure. In addition, if we ever want to update the version of Tomcat or the JRE, we have to redeploy the entire package.
To get rid of the above mentioned issues, we stored them in Windows Azure Blob storage. We modified the startup script to download Tomcat/JRE from the Blob storage and then launch Tomcat. For upgrading the deployment to use the latest Tomcat and JRE, we needed to copy new versions to the Blob storage and using Windows Azure portal, we reimaged all virtual machines instances that host our application.
In a typical multi-tenant application, various application resources are shared across all tenants. There are many business models that service provider can use to charge each tenant. We showcased one model which can be used to charge tenant based on their actual usage of each resource (in our case, Windows Azure Storage). For capturing the storage usage for each tenant, we enabled Storage Analytics logging for the Windows Azure Blob storage. This creates the Storage Analytics logs, containing the information about the operations performed on the Windows Azure Blob storage service. Storage Analytics logs also contain the information about the successful and failed requests made to this service. Storage Analytics is a great Windows Azure feature that was especially helpful for CloudNinja for Java, being a multi-tenant application for which we wanted to capture the tenant-level storage usage.
Blog Series on Windows Azure for Java
Watch out this space for in-depth series of blog posts covering the various aspects of Windows Azure for Java, such as:
Usage of the Windows Azure SDK for Java
Accessing the Windows Azure API through REST-based calls
Integrating Windows Azure Access Control Services for authentication and authorization
Apart from this we would also be documenting some interesting observations while implementing Java applications for Windows Azure. So stay tuned for regular and informative posts that will help you learn about Windows Azure for Java.Previous postNext post