Thursday, December 30, 2010
Heap Dumps - Introduction
Wednesday, December 8, 2010
Cloud Computing - 10 min Introduction
IaaS involves building a distribution stack comprising of hardware and virutalized instance (the first two tiers), and rolling it out to users. Users are then free to install any OS on top of this stack with services, frameworks, and servers that can be tailored to support their needs. An example of this model is Amazon's EC2 public cloud. Under this model, user has freedom to choose anything from and above the operating system.
PaaS involves a service model with its distribution stack composed of hardware, VMM and elements from all other tiers upto frameworks; user applications are deployed on top of vendor provided framework, an example is windows Azure. Users do not manage servers or storage and can only deploy apps on the cloud; above all their apps need to be coded to the framework built in PaaS.
Thursday, December 2, 2010
Virtualization - An Introduction
Virtualization functions and external interfaces as their counterparts, but that differ in attributes, such as size, performance, and cost. These substitutes are called virtual resources, and their users are typically unaware of the substitution. Virtualization is commonly applied to physical hardware resources by combining multiple physical resources into shared pools from which users receive virtual resources. With virtualization, you can make one physical resource look like multiple virtual resources. Virtualization has been here for quite a while in different forms like, storage, VLAN, VIP, JVM, etc., but of late it has entered at the system level (OS).
System virtualization independent operating environments that use virtual resources. System virtualization can be approached through hardware partitioning or hypervisor technology. Hardware partitioning subdivides a physical server into fractions, each of which can run an operating system, our old dual boot systems. These fractions are typically created with coarse units of allocation, such as whole processors or physical boards. This type of virtualization allows for hardware consolidation, but does not have the full benefits of resource sharing and emulation offered by "hypervisors". To better understand hypervisors one need to understand the existing and most widely used x86 architecture below,
- Virtualization using binary translation
- OS assisted virtualization or paravirtualization
- Bare Metal virtualization
All these techniques support not just CPU virutalization but also memory, device and I/O virtualization.
Wednesday, November 24, 2010
SOAD an introduction - I
To work on SOA projects, one may have to analyze, design and make architectural decisions at various layers like operational system or legacy layer, Enterprise component layer, Services layer, Business process or orchestration layer and the Integration layer.
Legacy layer : This consists of existing custom built applications, including existing CRM and ERP packaged applications, and older object-oriented system implementations, as well as business intelligence applications. The composite layered architecture of an SOA can leverage existing systems and integrate them using service-oriented integration techniques, which is a common case in most businesses.
Enterprise components layer: This is the layer of enterprise components that are responsible for realizing functionality and maintaining the QoS of the exposed services. This layer typically uses container-based technologies such as application servers to implement the components, workload management, high-availability, and load balancing. For example, components in these layers could be enterprise beans, asynch beans, message queues, thread pools, resource adapters, etc.,
Services layer: The services the business chooses to expose reside in this layer. They can be discovered or be statically bound and then invoked, or even, choreographed into a composite service. This service exposure layer also provides for the mechanism to take enterprise wide components, business unit specific components, and in some cases, project-specific components, and externalizes a subset of their interfaces in the form of service descriptions. Thus, the enterprise components provide service realization at runtime using the functionality provided by their interfaces. The interfaces get exported out as service descriptions in this layer, where they are exposed for use. They can exist in isolation or as a composite service.
Business process composition or choreography layer: Compositions and choreographies of services exposed in Service layer are defined in this layer. Services are bundled into a flow through orchestration or choreography, and thus act together as a single application. These applications support specific use cases and business processes.
Integration (ESB) Layer: This layer enables the integration of services through the introduction of a reliable set of capabilities, such as intelligent routing, protocol mediation, and other transformation mechanisms, often described as the ESB (the EDI equivalent). Web Services Description Language (WSDL) specifies a binding, which implies a location where the service is provided. On the other hand, an ESB provides a location independent mechanism for integration.
QoS Layer: This layer provides the capabilities required to monitor, manage, and maintain QoS such as performance, reliability, transaction, and availability. Some of these attributes are implemented at the Enterprise component layer (like transaction, security) whereas the others are monitored via background process that check the health of SOA applications.
As it can be seen now, design strategy for a SOA does not start from bottom-up as is often the case with a Web services-based approach. SOA is more strategic and business-aligned, Web services are a tactical implementation of SOA. A number of important activities and decisions exist that influence not just integration architecture but enterprise and application architectures as well.
Monday, November 22, 2010
What is Reliability?
There are actually two components that impact the reliability of a system
- How long it will work before it fails
- How long it will take to fix it.
One can also define,
- If a system is split into k parts, the resulting system network will be more than k times as reliable as the original system and still will deliver k/k-1 of the system capacity in the event of an outage.
- If a system is split into k parts, the chance of losing more than 1/k of its capacity is many, many times less than the chance that the single system will lose all of its capacity.
Friday, November 19, 2010
JavaScript Threads
setTimeout(), setInterval(), XMLHttpRequest, and event handlers. All of these features run asynchronously, but non-blocking doesn't necessarily mean concurrency. Asynchronous events are processed after the current executing script has yielded. This is the primary reason why some page onload or javascript controlled behaviors for page rendering work most of the times but not always. Often these issues are blamed to slow network because you may not notice such behaviors every day.Worker object in your main page. The constructor takes the name of the worker script:var worker = new Worker('task.js');If the specified file exists, the browser will spawn a new worker thread, which is downloaded asynchronously. The worker will not begin until the file has completely downloaded and executed. If the path to your worker returns an 404, the worker will fail silently. As with java threading, javascript threads do not return values or allow you to trap failures.After instantiating the worker, you start it by calling the
postMessage() method:worker.postMessage(); // Start the worker.
<page onload="prepReport()"/> <output id="result"/>
<script>
function prepReport() {
worker.postMessage({'cmd': 'submitReq', 'msg': reportParams});
}
var worker = new Worker('doRptWork.js');
worker.addEventListener('message', function(e) {
document.getElementById('result').textContent = e.data;
}, false);
</script>...
...
self.addEventListener('message', function(e) {
var data = e.data;
switch (data.cmd) {
case 'submitReq':
self.postMessage('WORKER STARTED TO PROCESS REPORT REQ: ' + data.msg);- The
navigatorobject - The
locationobject (read-only) XMLHttpRequestsetTimeout()/clearTimeout()andsetInterval()/clearInterval()- The Application Cache
- Importing external scripts using the
importScripts()method - Spawning other web workers
- The DOM (it's not thread-safe)
- The
windowobject - The
documentobject - The
parentobject
Thursday, November 18, 2010
Shorter URI for Web - II
It turned out these shorter versions are staged via url shortening service providers who registers and associates your longer version with some randomly generated alphanumeric token. When you distribute your urls, it will basically carry the service provider's domain along with this token; when users cilick on this shortened version, their browser is redirected to the longer version of the page. Personally, I do not like such URL's as they are often source of spams and phising; you need to trust the person sending the link as you cannot trust the link.
There are many players in this field like bit.ly, tr.im, cli.gs, etc., and such URL shortening is more popular with twitters. This link provides good comparision of features among all the players and feature set (http://searchengineland.com/analysis-which-url-shortening-service-should-you-use-17204)
HTML5 AppCache
- Offline browsing - users can navigate your full site when they're offline. For business applications that require valid session, this scenrio could translate to caching static resources on user machines.
- Speed - cached resources are local, and therefore load faster.
- Reduced server load - the browser will only download resources from the server that have changed.
The manifest attribute should be included on every page of your web application and can point to an absolute URL or relative path to your .manifest file. The file does not need to end in ".manifest", but needs to be served with the correct mime-type (see below).
A .manifest file must be served with the mime-type text/cache-manifest. You may need to add a custom file type to your web server or .htaccess configuration.
For example, to serve this mime-type in Apache, add this line to your config file:
AddType text/cache-manifest .manifest
The cache manifest file is a simple text file that lists the resources the browser should cache for offline access and may look something like this:
CACHE MANIFEST
index.html
stylesheet.css
images/logo.png
scripts/main.js
This example will cache four files on the site. The CACHE MANIFEST string is the first line and is required. Every URL or site is limited to 5MB worth of cached data.
A manifest can have three distinct sections: CACHE, NETWORK, and FALLBACK.
CACHE:
This is the default section for entries. Files listed under this header (or immediately after the CACHE MANIFEST) will be explicitly cached after they're downloaded for the first time.
NETWORK:
Files listed under this section are white-listed resources that require a connection to the server. All requests to these resources bypass the cache, even if the user is offline.
FALLBACK:
An optional section specifying fallback pages if a resource is inaccessible. The first URI is the resource, the second is the fallback. Both URIs must be relative and from the same origin as the .manifest file
A complex example like the one below can illustrate better on how these sections work,
CACHE MANIFEST
# Explicitly cached entries
CACHE:
index.html
stylesheet.css
images/logo.png
scripts/main.js
# Resources that require the user to be online.
NETWORK:
login.jsp
/mycontroller
http*://my.domain.com
# static.html will be served if main.py is inaccessible
# offline.jpg will be served in place of all images in images/large/
FALLBACK:
/main.htm /static.html
images/large/ images/offline.jpg
Resources configured under cache manifest can be updated/purged based on events fired by appcache API such as download progress, updating the app cache, and error conditions or programatically checking for life cycle status of the appcache object.
Cookie - 101
Under the hood there are two types, session and persistent cookies. The former has no lifetime beyond opening and closing of browser window, whereas the later can be retained for unlimited period of time and when created is written into browser cookie store on client machines. Besides, expiration intervals cookies have affinitiy to domains from which they originate. For example, "myspace.com", "client1.myspace.com", "secure.myspace.com", etc., can share the same cookie because they are either domains or subdomains of same type. This is easily achieved by explicitly setting "domain" property of cookie object to the other subdomain before streaming the output response (Most languages/scripts have cookie API with domain property). User apps can then navigate to and reference to links, images, scripts or resources within each other. However, if your infrastructure has systems in "myspace.com" and "myotherspace.com", then you will not be able to cross reference resources from each other. That would amount to cross site scripting attack and you may have to workaround at DNS level spoofing the IP addresses of these domains so that browsers can work without throwing "Internal Server Error".
One other issue with cookies related to timeout emerge from modern browsers having tab feature. Users opening multiple browsers or tabs end up sharing the same cookie, meaning users are logged once but have multiple handles to the same server side session. This could pose serious problems to your applications depending on what they are trying to do. For example, user on one browser frame window may update a record and in parallel try to delete that record from other window or tab. Now that this user is attached to the same server session, there could be a data collision.
If your application can allow multiple view access to same server session, for most part a convenience for users to compare and work across screens, then you may likely be limiting users to one session cookie and do not mind if they use multiple tab windows. However, if you want one and only one view representation of your system you just simply cannot rely on cookies. Cookies are controlled by window frame process and is shared across tab processes (in most browsers). On IE8, you have a feature to start a new session on your tab which decouples that tab from frame process thus establishing a new session with server. For browsers that do not have this feature, developers need to create home grown solutions like generating, encoding and attaching a windows handle ID to every URL request just like what one would do with sessionID if there were no cookies. On the server end you would associate this handle to one particular session token, user requests from other tabs or window processes will have different handle that will now be rejected. There are some server side frameworks (eg. Spring 3.2+) that can create cookies specific to tab handle instead of a javascript approach.
Wednesday, November 17, 2010
IBM WESB Tips and Aches - part II
First, to talk about tracing which is somewhat similar to logger, is quite handy at development time which simply streams your entire xml graph onto a specified/default file location. In production, you may enable/disable this feature by promoting and configuring boolean property. When you extend this feature across all modules you may want to have a generic reusable logger rather than one for each module. This is accomplished using mediation subflow that includes tracing primitive wired between its IN and OUT terminals.
Mediation subflows by design are intended to be reused across all modules and applications and therefore when working with those, care should be taken so that they are not created within "Application" or "Module" construct, but instead within a "Library" construct. This allows reuse across multiple modules or applications (ofcourse it also depends on what you have created within subflow).
One interesting note with mediation subflow, is accessing contextual information within the flow. Context information can either be correlation, transient or user context. Normally your business objects or custom BO's are bound to context and if you wanted to access those from within mediation subflow at design time, you may not find a handle to it. This is by design of mediation subflows which are supposed to be agnostic to your application or module and thus any type of contextual information. One way to get around this is to use "MessageSetter" prmitive as the first element within subflow and cast appropriate context (user, transient or correlation) with your business object. This facilitates visibility of context information within subflow for any wiring or transformation.
Tuesday, November 2, 2010
SOA operations verbage
• Acknowledge
• Cancel
• Change
• Confirm
• Get
• Sync
• Show
• Update
• Load
• Post
• Process
• Respond
For example, any one providing a financial calculator service may include capabilities like GetRate, ShowAnnualReturn, and UpdateAPY in their WSDL instead of some non-standard nomenclatures.
Thursday, September 9, 2010
Password security
Security is a cross cutting concern, meaning these sensitive packets need to be encrypted the moment they leave user view space and maintained in the same form during transmission, reception, processing, and storage. It should not be decrypted at any stage, not even by your application (since those may end up in some log file).
The most common form is MD5 one way hashing where you cannot recover the original message. However, developers need to keep in mind this type of encryption has dependency on OS address space, i.e 32-bit or 64-bit and applied character encoding. You may not be able to produce a matching MD5 output when one of your app produces MD5 on 32-bit and another app validates MD5 of the same text using 64-bit.
Wednesday, August 18, 2010
Who is an Architect
Enterprise Architecture when defined from an information and technology perspective explicitly describes an organization through a set of independent, non-redundant artifacts, defining how these artifacts interrelate with each other, and developing a set of prioritized, aligned initiatives and road maps to understand the organization, communicate this understanding to stakeholders, and move the organization forward to its desired state.
From a Business perspective, Enterprise Architecture illuminates how an organization and all of its members can achieve its objectives, through the creation of a series of engineered models and project initiatives, that can be easily understood by all of the people associated with the organization.
If an individuals contribution is to just about talk on these artifacts (or even worse BS on those) and not work towards creating them, please stop calling yourself an Enterprise Architect. May be they can be called as "Art Vandelay" Architect as in one of SeinField's episode.
Monday, August 9, 2010
Websphere JNDI resource scoping
Interestingly this wasn't true. Even though IBM marks resources created at cell level with broader scope, when it comes to connections each node gets its own share. Despite the scope of a defined resource, the resource properties apply at an individual server level only.The application scope has precedence over all the scopes.
- The server scope has precedence over the node and cell scopes.
- The node scope has precedence over the cell scope.
For example, if you define the scope of a data source at the cell level, all the users in that cell can look up and use that data source, which is unique within that cell. However, resource property settings are local to each server in the cell. For example, if you define the maximum connections as 10, then each server in that cell can have 10 connections.
The cell scope is the most general scope and does not override any other scope. The recommendation is that you generally specify a more specific scope than the cell scope. When you define a resource at a more specific scope, you provide greater isolation for the resource. When you define a resource at a more general scope, you provide less isolation. Greater exposure to cross-application conflicts occur for a resource that you define at a more general scope.
Saturday, August 7, 2010
MDB controller
I came across a requirement to fetch messages dropped into the queue only at defined intervals and not just when message was available. Websphere JMX AdminService API exposes provides operations that can interrogate available J2CMessage bindings and issue commands to either pause, resume the endpoint listeners. One caveat though is these activation specs need to be initialized within your application for AdminService to look them up. In other words, if you have multiple EAR's encapsulated with MDB's and if you wish to control them centrally through another EAR (all deployed on same cell), you will not be able to passivate without them being activated first.
String endPointlistener = "*:*,type=J2CMessageEndpoint";
javax.management.ObjectName queryName =
new javax.management.ObjectName( endPointlistener);
AdminService adminService = AdminServiceFactory.getAdminService();
Set s = adminService.queryNames(queryName, null);
Iterator it = s.iterator();
List mbeans = new ArrayList();
while (it.hasNext()) {
ObjectName mBean = (ObjectName) it.next();
result = adminService.invoke(mBean, operationName, params,
signature);
}
Wednesday, August 4, 2010
Dynamic JCA Connection Factory Substitution
In websphere you can set custom properties using the prefix "CP"
For example, to you may have a Connection factory marked against a file resource adapter, with JNDI com/eis/myFileCF dedicated for I/O write operations. Supposing, there are many folders that are operated by certain users who have privilige to delete while others have only write access it may become a daunting task to create dedicated connection factories to isolate these set of users. Instead application developers can lookup the connection factory by JNDI and inject any property variances such as username and password, in this case, like
conn.setProperty("CPuserName", "user");
conn.setProperty("CPpassword", "{xor}49dksdldk");
Note, the password is masked using xor alogrithm. Websphere encodes J2C credentials while saving into file system and later decodes when sending them out to appropriate endpoints; your dynamic injection should encode the same way for proper processing.
Friday, June 18, 2010
Shorter URI's for web apps
Some non serious IT service cos develop web apps and roll it out to customers without paying attention to little details like URI's, UI component names they choose in HTTP communication, information they drop in cookies, etc., They little realize these oversights pose potential security risk to their application, especially when they are exposed over internet not to mention how silly it looks to expose your class name or object responsibility to users of the system. Some common examples look like,
http://my.domain.com/myapp/RegistrationServlet?userid=abc&password=bbb&address=blah
Issue 1: You indicate what technology you implement and which object is working your request; the complex your app the longer the url normally tend to be.
Issue 2: Whether you do FORM POST or pass it in as URL args, attaching element names like userid, password, etc., provide obvious clues to what you intend to do. Not a good practice.
With such apps the common dilemma we all face is not wanting to invest time working on nomenclatures. Luckily, webservers come to our rescue
Based on your deployment architecture, whether you have an application server + webserver or just webserver, one can use either mod_rewrite or mod_proxy modules of apache that can shield longer URL's from user with a short one.
If your app lives only on webserver, say a php or asp based application you can rewrite the above example like,
RewriteEngine onRewriteRule ^/reg$ /myapp/RegistrationServletRewriteCond %{QUERY_STRING} id=([-a-zA-Z0-9_+]+)
RewriteRule ^/?reg$ %1? [R=301,L]which is basically same as http://my.domain.com/reg/abc/abb/blah
If your app has webserver fronting an application server you cannot just rewrite, you may have to forward proxy short url requests to long one internally before some kind of plugin can forward that request to application server.
Saturday, June 12, 2010
SQL Gotchas
Problem: Issue of a static sql statement returns expected results, same statement issued as a prepared statment with parameters fails.
Static statement:
SELECT
nvl(sum(BATCHREL), 0) as CNT
FROM
userapplications a,
users b,
customers c
WHERE
a.USERRID = b.RID and
b.CUSTOMERKEY = c.RID AND
lower(c.ID) = '900100ev' AND
lower(b.ID) = 'admin1'
Prepared statment template:
SELECT
nvl(sum(BATCHREL), 0) as CNT
FROM
userapplications a,
users b,
customers c
WHERE
a.USERRID = b.RID and
b.CUSTOMERKEY = c.RID AND
lower(c.ID) = ? AND
lower(b.ID) = ?
Parameter values: '900100ev','admin1'
What I saw happening:
The c.id metadata was CHAR(20) and did not match the parameter passed in using prepared stmt, unless I padded it with spaces (to meet the length), however when I chose a literal string it worked w/out issues. I had to modify the prepared statement as follows (and it works)
SELECT
nvl(sum(BATCHREL), 0) as CNT
FROM
userapplications a,
users b,
customers c
WHERE
a.USERRID = b.RID and
b.CUSTOMERKEY = c.RID AND
RTRIM(lower(c.ID)) = #companyid# AND
lower(b.ID) = #operatorid#
Parameter values: '900100ev','admin1'
Friday, June 4, 2010
Mobile Web Applications
Here are some lessons learnt from my experience -
- Feature phones usually come in candy bar, clamshell or slider form. They have a 12-key layout.
- Smart phones share the same features as a feature phone with two primary differences: Its ability to run additional third-party applications and a slightly larger screen. Smart phones typically use a more full featured operating system.
- PDAs often include QWERTY keyboard and stylus in place of the 12-key layout on normal phones.They also feature a larger screen.
Design constraints:
- Mobile browsers may stop scrolling vertically on pressing the down key when a link appears in the currently viewed section of the page.
- Some user plans may be tied to data bandwidth and therefore keep the data traffic to a minimum.
- Mobile devices have limited memory, limited CPU and run on slower networks than desktop computers, running scripts on client side will drain the battery. Keep such stuff to a minimum.
- Mobiles do not support popups/frames/etc. Not all mobiles support scripting/styling. Identify mobile device and then render pages as per device support features. Page Design will need to take account for diff. screen sizes, devices.
- The W3C suggest that all the images on a page should total less than 10KB. Keep page size to less than 25kb.
- You should consider how your page will render when the images are not available
Rules to Follow:
- Use HTML Validator firefox extn to validate markups for every page.
- Use style based layout instead of tables to produce pages. Page layout will be split as header, content. while you should state the dimensions of your images (width="120" height="107") when designing for mobile devices, don't state the pixel units. Keep dimensions dynamic that will be supplied from, say a DeviceBean.
- Use accesskeys to links and limit links to less than 10. Navigation can be performed using keys instead of browsing.
- Use Wireless CSS
- Adopt a short URL
- Do not mask user input when entering a password.
- Read http://www.w3.org/TR/mobile-bp/
IBM WESB tips and aches - I
Instead of building from Dev-> QA ->Staging->Prod in that order, our learned friends chose the reverse order so that development was not impacted. They were assuming repeatable and reliable behavior of topology images from a tool they had no prior experience. Alas, surprise in store, all went well in Prod but when executing the same instructions in Staging we noticed weird issues pointing to SpringFramework and J2C transactions. The surprise initially was not the failure issues but the springframework in IBM, our corporate folks always shunned from open source tools and were a big fan of IBM, EJB, et al and vehemently opposed introducing Spring. Now here it is backed by the big blue spewing errors that no one can make sense.
Tuesday, March 2, 2010
Java 5 Thread framework
Recently, I encountered one such implementation developed during Java 2.0 days. It was homegrown framework designed to handle critical batch jobs of high volume. It seem to have worked well for business which surprised me and after a little bit of probing, it was evident the application support would intervene and restart the job processes if there were failures, and besides batches were not bound by any SLA. To speed up execution cycle developers were spawning threads in a loop controlled by sleep intervals. Not a design one would want if it executes critical business processes.
With Java 5.0+, a lot has changed in the threading space with the inclusion of concurrent libraries (earlier these were standalone third party binaries without concurrent collections and scheduling framework). Concurrency utilities provide many advantages to developer community like,
# Reduced programming effort. It is far easier to use a standard class than to develop it yourself.
# Increased performance. The implementations in the Concurrency Utilities were developed and peer-reviewed by concurrency and performance experts; these implementations are likely to be faster and more scalable than a typical implementation, even by a skilled developer.
# Increased reliability. By using standardized, extensively tested concurrency building blocks, many potential sources of threading hazards such as deadlock, starvation, race conditions, or excessive context switching are eliminated.
# Improved maintainability. Programs which use standard library classes are easier to understand and maintain than those which rely on complicated, homegrown classes.
# Increased productivity. Now that it is part of Java API, developers are more likely to be familiar than any third party libraries and behavior.



