26 November, 2012

AWS Cloud Useful Links (Whitepapers & Presentations)

Migrating Existing Applications to the Cloud
1) Cloud Migration: Migrating Your Existing Applications to the AWS Cloud -by Jinesh Varia
http://www.slideshare.net/jineshvaria/migrating-existing-applications-to-aws-cloud
http://aws.typepad.com/aws/2010/11/new-whitepaper-migrating-your-existing-applications-to-the-aws-cloud.html

2) How to migrate enterprise applications to the Cloud - by Jinesh Varia
http://www.cio.com.au/article/366991/how_migrate_enterprise_applications_cloud_-_part_1/
http://www.cio.com.au/article/367016/how_migrate_enterprise_applications_cloud_-_part_2/

3) Migrate Your Application to Cloud: Practical Top 10 Checklist

http://www.prudentcloud.com/cloud-computing-technology/migration-to-cloud-top-10-checklist-24042010/
4) Migrating Existing Applications to the Cloud

http://www.csscorp.com/cloud/solutions/migrating-existing-applications-to-the-cloud.php


Designing and Building Applications for the Cloud
1) New Whitepaper: Architecting for the Cloud: Best Practices - by Jinesh Varia 
http://www.slideshare.net/jineshvaria/architecting-cloud-apps
http://aws.typepad.com/aws/2010/01/new-whitepaper-architecting-for-the-cloud-best-practices.html

2) The Cloud as a Platform by Jinesh Varia

http://www.slideshare.net/jineshvaria/aws-2013081

3) Best Practices for using AWS EC2
http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/instance-overview.html

4) Best Practices for Using Amazon S3 - 

http://aws.amazon.com/articles/1904?_encoding=UTF8&jiveRedirect=1
 

5) Amazon S3 Error Best Practices
http://docs.amazonwebservices.com/AmazonS3/latest/dev/ErrorBestPractices.html
 

Java/JEE: How to get an asset on a web server behind the firewall?

 

Usage of  request.getLocalName() vs request.getServerName() to get an asset
Here the scenario is accessing the assets like images, templates etc used in a web application.
The "/asset" is a server side program which returns the asset file content by taking a asset file name as input. In this case the assets are kept on the same web server where the web application runs.
There are two methods available to get the name of the server.
1) The request.getServerName() method returns the name of the server that the HTTP request was sent to.
2) The request.getLocalName() method returns the name of the server that actually received the request.
The request.getServerName() which returns the name of the public server on the firewall, but not the web server. So we cannot access the asset.

The request.getLocalName() which returns the name of the web server that received the request, so we access the asset on the web server behind the firewall.



Code Snippet

public static String getAssetUrl(HttpServletRequest request, String fileName) {
    String scheme = request.getScheme();
    String localServerName = request.getLocalName();
    int localServerPort = request.getLocalPort();
    String contextPath = request.getContextPath();
    String pathInfo = request.getPathInfo();

    // Reconstruct original request URL
    String url = scheme + "://" + localServerName + ":" + localServerPort
        + contextPath + "/asset?fileName=/" + fileName;

    if (pathInfo != null) {
        url += pathInfo;
    }     
    return url;
}

20 November, 2012

Testing Web Presentation Layer using HtmlUnit - Part I

Presentation-layer testing means finding bugs in the graphical user interface (GUI) of a web application and portlets.

What is HtmlUnit?
HtmlUnit is an open source Java headless browser framework. It allows tests to imitate programmatically the user of a browser-based web application including portlets. HtmlUnit tests don’t display a user interface. The framework lets you test all aspects of a web application.

In the HtmlUnit context “testing with a web browser,” actually means that we’re testing by emulating a specific web browser.


When to use HtmlUnit?
HtmlUnit is a 100 percent Java headless browser framework that runs in the same virtual machine as your tests. Use HtmlUnit when your application is independent of operating system features and browser-specific implementations not accounted for by HtmlUnit, like JavaScript, DOM, CSS, and so on.

Benefits

  • More efficient than manual testing
  • Less error prone than manual testing
  • Enables collective code ownership
  • Enables refactoring
  • Enables frequent integration
  • Enables browser-specific testing  with less effort
Summary
  • HtmlUnit is a 100 percent Java solution with no external requirements; it offers a complete HTML object model, which, although creating rather verbose test code, offers great flexibility. 
  • Use HtmlUnit when your application is independent of operating system features and browser-specific implementations of JavaScript, DOM, CSS, and so on.

References

  • http://htmlunit.sourceforge.net/
  • JUnit in Action, Second Edition

Understanding Business Process using BPM and BPEL


Table of Contents

What is BPM?. 1
Process modelling terms. 1
BPM Acid Test 2
Standards. 2
BPEL in a Nutshell 2
Business Process Lifecycle. 2
RMS (Resource Management System) 3
- Value Proposition. 3
- Functional Overview. 3
- Resource Request Process
References
. 3

What is BPM?

Business process management is a natural and holistic management approach for operating business that produces highly efficient, agile, innovative and adoptive organization that far exceeds that achievable through traditional management approaches.

Business Process Management include
  • Business Process Modelling
  • Study of “As Is” and “To Be” business processes using Simulation techniques and optimizing the process
  • Define key performance indicators to track process performance
  • Automating the process using BPM tools
  • Business Activity Monitoring to collect metrics on real time process performance
  • Continuous improvement of the process based on the business metrics collected

Thus Business process management is not a mere technology solution. It is more towards a Methodology to optimize the business processes enabled by right set of tools. BPM brings in a lot of synergy between business and IT, thus helps produce highly agile systems. The basis of business process management is the explicit representation of business processes with their activities and the execution constraints between them. 

Process modelling terms

Being algorithmic, a process can potentially be run by some sort of process engine. As long as the process can be expressed in a form that is syntactically and semantically unambiguous—that is, in a programming language or other interpretable form—the engine can accept it as input, set it in motion, and drive its flow of control. To be precise, the engine creates and runs instances of a given process definition. The steps of the process are called activities or tasks.

The following list summarizes the most important process modelling terms and their relationships to each other:
  • Process definition - The basic algorithm or behavior of the process.
  • Process instance - An occurrence of a process for specific input. Each instance of the travel reservation process, for example, is tied to a specific customer's itinerary.
  • Activity or task - A step in a process, such as sending a flight request to the airline.
  • Automated activity or automated task - A step in a process that is performed directly by the execution engine.
  • Manual activity or manual task - A step in a process that is meant to be performed by a human process participant.

BPM Acid Test

BPM is suited only for applications with an essential sense of state or process—that is, applications that are process-oriented. An application passes the BPM acid test if it is legitimately process-oriented. The resource management application, for example, passes the test because it is best understood in terms of the state of the resource request and is defined at all times by how far the resource request has gotten. Other typical characteristics of a process-oriented application include the following:

  • Long-running: From start to finish, the process spans hours, days, weeks, months, or more.
  • Persisted state:  Because the process is long-lived, its state is persisted to a database so that it outlasts the server hosting it.
  • Triggered by events: The process spends most of its time asleep, waiting for the next triggering event to occur, at which point it wakes up and performs a flurry of activities.
  • Orchestration of system or human communications: The process is responsible for managing and coordinating the communications of various system or human actors.
Some process-oriented applications have only a subset of these characteristics.

Standards

Some of the most important of BPM standards include the OASIS group's BPEL standard , BPMI's BPML and BPMN standards, etc.  BPEL is the BPM specification with the strongest backing (IBM, Microsoft, Oracle, BEA) and the greatest chance to win the standards war

BPEL in a Nutshell

  • A BPEL process is a web service with an associated process definition defined in an XML-based language.
  • The behavior of a BPEL process is to act on, and be acted on by, other processes; put differently, a BPEL process can invoke another web service or be invoked as a web service.
  • BPEL descends from two very different process languages: Microsoft's XLANG and IBM's Web Services Flow Language (WSFL).
  • The essential BPEL language constructs designers will need to understand to create a BPEL process: the basic process structure, variables and assignments, exception handling and compensation, split and join, loops, participant exchange, transactions, and extensions.
  • The flow of a BPEL process includes service touch points (receive, invoke, reply) and control flow elements (wait, while, switch, flow, sequence, scope).

Business Process Lifecycle

A business process lifecycle covers the following phases:
  • Process discovery
  • Process design
  • Process Implementation
  • Process execution & monitoring
  • Process simulation
  • Process optimization

RMS (Resource Management System)

RMS is a solution powered by BPM. This section the value proposition and functional overview of RMS business process.

Value Proposition

RMS uses BPM tool to add value to resource request handling process as listed below:
  • Facilitates modelling of an existing resource request handling process workflow
  • Allows identification of the pain areas in the work flow and their resolution before process implementation in production (using the simulation features of BPM tools)
  • Ensures close alignment of business and IT by virtue of the business model driving the IT development downstream
  • Allows definition and change of business rules with the help of rule component, increasing business agility in response to market changes.
  • Reduces time and cost
  • Provides 24X7 availability using ubiquitous standard interfaces

Functional Overview

RMS captures resource request handling process end to end.

RMS is a web based system used by managers in the IT services company to capture resource request required in a project assignment of his organization. Once the Manager (Consumer) of a business unit captures/creates the resource request details, the resource request handling process is initiated.  Then the resource request is verified and processed by Resource Managers (Dispatcher) of the company.

Resource Request Process

  
 

 
Steps involved in Resource Request Handling Process:-
  • Consumer creates a resource request for an opportunity and submits the request to Dispatcher.
  • Dispatcher searches matching employee profiles and analyzes matching for suitability and availability.
  • If there are matching profiles then Dispatcher allocates the matching profiles to resource request and sends them to Consumer for acceptance.
  • If there are no matching profiles then Dispatcher sends the resource request back to Consumer for clarification.
  • Consumer validates all the employee profiles allocated for the resource request by the Dispatcher and confirms acceptance if the employee profiles match the requirement.  Otherwise the Consumer declines the profiles.
  • If the employee profiles are accepted then the Dispatcher approves the allocation of the identified employee profiles for the resource request and the request is marked as allocated.

References

- Essential Business Process Modelling By Michael Havey
 

07 March, 2012

Sonar in a nutshell and using Sonar Eclipse

What is Sonar?
Sonar is an open platform to manage code quality. Sonar runs as a server application that collects data from your code through a Maven plugin. The analyzed data can either be viewed in the browser or through the Eclipse plugin. Sonar allows to combine metrics altogether and also to mix them with historical measures.

Sonar covers these aspects of code quality :
  • Architecture & Design
  • Coding rules
  • Complexity 
  • Duplications
  • Unit tests
  • Potential bugs
  • Comments
Language Support
Java is built in. Open Source and commercial plugins enable to cover C, C#, Flex, Natural, PHP, PL/SQL, Cobol and Visual Basic 6.

Sonar Plugins
Listed below are few of the plugins to produce additional metrics:
  • JMeter - Retrieve JMeter test results in SONAR.
  • Useless Code - Reports on the number of lines that can be reduced in an application.
  • Artifact Size - Reports on the size of the artifact generated by projects.
  • Quality Index - Calculates a global Quality Index based on coding rules, Style, Complexity and Coverage by unit tests.
Listed below are few of the integration plugins available:
  • Bamboo
  • Hudson/Jenkins
  • Google Calendar
  • Twitter
Integrate to Eclipse

1) Installing and Using Sonar Eclipse
Install Sonar using this site and restart Eclipse. Sonar - http://dist.sonar-ide.codehaus.org/eclipse/
After installation, Eclipse restarts in Sonar perspective.

2) How to do Sonar analysis in the Eclipse?
  • Select your project and right click. In the context menu select Sonar > Analyse > Locally and then select Sonar > Run Local Analysis.
  • This will run checks using FindBugs, Checkstyle, PMD etc. The output reports will be stored in your <<{workspace}\target\sonar-embedder-work>> folder.
  • Check Measures tab
  • Select the root source folder or any package to see Violations.  e.g. Select src/main/java.
3) How to do Sonar Analysis remotely?
  • Goto Window > Preferences > Add. Enter Sonar server URL and click Finish.
  • Associate with Sonar - Select the project and right click. Configure > Associate with Sonar. Select the project the, Enter GroupId and ArtifactId.
  • Access remotely installed Sonar - Select the project and right click. In the context menu select Sonar > Analyse > Remotely, to retrieve results/reports.
  • Check Web tab for the summary of analysis data.
  • Check Hotspots tab to see classified analysis data.

Prerequisites
  • Sonar 2.4 installed on localhost or remote server
  • Eclipse 3.5.x, 3.6.x, 3.7.x
  • Maven 3.x
  • Sample Java project with Maven build
References