My "pensive" - where i simply siphon the excess thoughts from my mind, pour them into the basin (of cloud storage), and examine them at leisure.
Monday, October 21, 2013
Friday, October 18, 2013
Tuesday, October 15, 2013
implementing-rest - Exploring the implementation aspects of the REST architectural style. - Google Project Hosting
This is a place for exploring aspects of implementing applications using the REST architectural style. This may include statements about existing frameworks and libraries, general discussions about the nature of the style and how it may be expressed and/or encouraged via a programming framework, etc.
Featured Content
- Video and Audio Resources NEW
- REST Litmus Test for Web Frameworks
- Documenting REST-ful Applications
- The Key Abstraction
- A RESTful System
- Richardson Maturity Model
- Fielding's REST API Rules
- REST Development Principles
Code::Blocks IDE
An open source IDE i started playing with today. Its fast, beautiful (neat syntax highlighting) and the best thing i liked so far is the code completion unlike i had ever seen before for C/C++ IDE. It also claims to be pretty fast in doing builds and debugging.
'via Blog this'
Sunday, October 13, 2013
RESTful API Design
· 200: Success (upon a successful GET, PUT, or DELETE request)
· 201: Created (upon a successful POST request)
· 400: Resource Invalid (improperly formatted request)
· 401: Unauthorized (incorrect or missing authentication credentials)
· 404: Resource Not Found
· 405: Method Not Allowed (in case some HTTP method of GET/POST/PUT/DELETE is not supported for a given URI).
· 406: Not Acceptable
· 500: Application Error
Friday, October 11, 2013
SPDY Protocol - Road to HTTP/2.0
Its been 13 years since HTTP/1.1 version came into being (in 1999) and has wonderfully managed to keep up with the pace of development and growth in web usage and technologies.
SPDY Protocol (by Google) proposes to enhance HTTP 1.1 by bringing to the table these new core concepts to web delivery:
- Multiplexing (allowing multiple requests to flow over a single connection)
- Prioritization (providing the ability to indicate that one resource is more important than another and should hence jump to the head of the line)
- Compression (making compression universal and extending it to headers)
- Server Push (allowing the server to give content to a user-agent before it is asked for)
- A strong recommendation for encryption (current implementations require it) - dropped from HTTP/2.0
IETF started HTTP/2.0 standards effort based on the proposals from SPDY protocol (as starting point). If everything goes well and according to the working group's stated goals, HTTP/2.0 will be faster, safer, and use fewer resources than HTTP/1.1.
HTTP/2.0 is still a ways away. The httpbis working group is targeting Fall of 2014 for a final draft of the protocol.
Understanding REST
What is REST?
REST stands for Representational State Transfer. It relies on a stateless, client-server, cacheable communications protocol -- mostly, the HTTP protocol is used. REST is an architecture style for designing networked applications. The idea is that, rather than using complex mechanisms such as CORBA, RPC or SOAP to connect between machines, simple HTTP is used to make calls between machines. REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations. Thus, REST is a lightweight alternative to mechanisms like RPC (Remote Procedure Calls) and Web Services (SOAP, WSDL, et al.).
The notion of REST was created in the PhD dissertation of Roy T. Fielding.
Benefits:
REST architecture has all the benefits of Web Service:
- Platform-independent (you don't care if the server is Unix, the client is a Mac, or anything else),
- Language-independent (C# can talk to Java, etc.),
- Standards-based (runs on top of HTTP), and
- Can easily be used in the presence of firewalls.
One thing that is not part of a good REST design is cookies: The "ST" in "REST" stands for "State Transfer", and indeed, in a good REST design operations are self-contained, and each request carries with it (transfers) all the information (state) that the server needs in order to complete it.
Example:
To lookup a user by ID, REST URI is:
http://www.acme.com/phonebook/UserDetails/12345?firstName=John&lastName=Doe
This URL is sent to the server using a simpler GET request, and the HTTP reply is the raw result data. If you need to pass long parameters, or binary ones, you'd normally use HTTP POST requests, and include the parameters in the POST body.
It is a common convention in REST design to use nouns rather than verbs to denote simple resources.
Real- world REST API docs:
1. Twitter - https://dev.twitter.com/docs/api - They use only GET and POST (used for create/update/delete).
- For create - https://api.twitter.com/1.1/direct_messages/new.json
- For Delete - https://api.twitter.com/1.1/direct_messages/destroy.json
2. Amazon S3 - http://docs.aws.amazon.com/AmazonS3/2006-03-01/API/APIRest.html
3. Google Glass' Mirror API - http://www.youtube.com/watch?feature=player_embedded&v=JpWmGX55a40
4. Facebook - https://developers.facebook.com/docs/reference/apis/
5. LinkedIn - http://developer.linkedin.com/apis
- Close Job - DELETE - http://developer.linkedin.com/documents/closing-job
- Post Job - POST - http://developer.linkedin.com/documents/posting-job
- Edit Job - PUT - http://developer.linkedin.com/documents/editing-job
- Lookup Job - GET - http://api.linkedin.com/v1/jobs/1337:(id,company,posting-date)
Components of REST Architecture:
- Resources - identified by logical URLs. Resources are the key element of a true RESTful design, as opposed to "methods" or "services" used in RPC and SOAP Web Services, respectively. You do not issue a "getProductName" and then a "getProductPrice" RPC calls in REST; rather, you view the product data as a resource -- and this resource should contain all the required information (or links to it). Whenever relevant, a resource should contain links to additional information -- just as in web pages.
- There is no connection state; interaction is stateless (although the servers and resources can of course be stateful). Each new request should carry all the information required to complete it, and must not rely on previous interactions with the same client.
- Resources should be cachable whenever possible (with an expiration date/time). The protocol must allow the server to explicitly specify which resources may be cached, and for how long. The HTTP cache-control headers are used for this purpose.
- Queries should not return an overload of data. If needed, provide a paging mechanism. For example, a "product list" GET request should return the first n products (e.g., the first 10), with next/prev links.
- GET access requests should never cause a state change. Anything that changes the server state should be a POST request (or other HTTP verbs, such as DELETE).
- Rather than letting clients construct URLs for additional actions, include the actual URLs with REST responses.
Documenting REST Services:
With version 2.0, WSDL supports all HTTP verbs and it is now considered to be an acceptable method of documenting REST services (WSDL 1.0 only supported HTTP GET and POST verbs).
The second alternative is WADL, the Web Application Description Language which is light weight compared to WSDL and less verbose.
1 <?xml version="1.0"?>
2 <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="http://wadl.dev.java.net/2009/02 wadl.xsd"
4 xmlns:tns="urn:yahoo:yn"
5 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
6 xmlns:yn="urn:yahoo:yn"
7 xmlns:ya="urn:yahoo:api"
8 xmlns="http://wadl.dev.java.net/2009/02">
9 <grammars>
10 <include
11 href="NewsSearchResponse.xsd"/>
12 <include
13 href="Error.xsd"/>
14 </grammars>
15
16 <resources base="http://api.search.yahoo.com/NewsSearchService/V1/">
17 <resource path="newsSearch">
18 <method name="GET" id="search">
19 <request>
20 <param name="appid" type="xsd:string"
21 style="query" required="true"/>
22 <param name="query" type="xsd:string"
23 style="query" required="true"/>
24 <param name="type" style="query" default="all">
25 <option value="all"/>
26 <option value="any"/>
27 <option value="phrase"/>
28 </param>
29 <param name="results" style="query" type="xsd:int" default="10"/>
30 <param name="start" style="query" type="xsd:int" default="1"/>
31 <param name="sort" style="query" default="rank">
32 <option value="rank"/>
33 <option value="date"/>
34 </param>
35 <param name="language" style="query" type="xsd:string"/>
36 </request>
37 <response status="200">
38 <representation mediaType="application/xml"
39 element="yn:ResultSet"/>
40 </response>
41 <response status="400">
42 <representation mediaType="application/xml"
43 element="ya:Error"/>
44 </response>
45 </method>
46 </resource>
47 </resources>
48
49 </application>
- JSR 311 is the Java Specification Request for "JAX-RS: The Java API for RESTful Web Services"
XMPP
- XMPP is communication protocol for message-oriented middleware based on XML.
Originally called Jabber, developed for instant messaging, presence info and contact list maintenance.
XMPP specs published in RFC 6120/21/22.
- RFC 6120: XMPP Core
- RFC 6121: XMPP IM
- RFC 6122: XMPP Address Format
Strengths:
- Mature, Open Standards based technology
- Secure (SASL and TLS)
- Extensible – Several extensions exist today (http://xmpp.org/xmpp-protocols/xmpp-extensions/)
Weaknesses:
- Binary data transfer (e.g. file transfer) is inefficient (as it requires converting to Base64 encoded form).
- XML streaming layer
- Security: SASL and TLS
- Presence: Built-in information about network availability
- Rosters: Presence-enabled contact lists
- Stream – Open XML envelope sent before more XML elements are exchanged between two entities.
- Stanza – XML elements exchanged between 2 entities. 3 types:
- Presence
- Message
- IQ – information or query
IQ – Info/Query.
- Get/Set
- Result
- Error
- Roster - Rosters are stored on the server so that the XMPP client may retrieve the same each time the user logs in. Rosters are a type of IQ Stanza. Example showing IQ message to request for roster.
Presence – the presence info of a user is broadcasted from server to all users in roster list of that user. This works using the PubSub messaging.
Bi-directional streams Over Synchronous HTTP (BOSH)
- It is a long-lived 2 way communication over HTTP.
- Significantly more bandwidth efficient over http (compared to other technologies – such as AJAX)
- Applications requiring both “push” and “pull” communications
- http://xmpp.org/extensions/xep-0124.html
- Avoids http polling for more efficiency and low latency
PubSub
- Each user is assigned a unique Jabber ID.
- XMPP server manages the messages published to a certain node (topic) and delivers the messages to all subscribers for that node.
- Messages may contain payload.
- Messages may be persistent.
XMPP Libraries for Application Programming
- Smack API – Java API for XMPP clients.
- Can be used to:
- Connect to the XMPP server with user’s JID
- Get the user’s roster from XMPP server
- Sending and receiving different type of Stanzas (IQ, Message and Presence).
- Publish messages to nodes
- Subscribe to nodes of interest.
- File transfer/Group chat support also available.
- http://www.igniterealtime.org/projects/smack/index.jsp
- Arista’s CloudVision framework Multi-Switch CLI extension uses XMPP to provide a shared message bus for managing and configuring switches. This is based on the idea from Internet of Things extension for XMPP (http://xmpp.org/extensions/xep-0324.html).
- Arista Switches run an XMPP client and respond to CLI commands.
- User can use any XMPP client (like iChat) on phone or PC to execute CLI on switches.
- A single login to XMPP server gives secure access to all switches.
- Switches can participate in group chats – meaning CLI can be executed on all participating switches in batch.
- A Switch can be in more than one chat room at the same time. Command executed in a given chat room, is executed on all participating switches in that chat room.
- Arista uses ejabberd XMPP server (included with fedora distro).
- Arista uses SleekXMPP client.
- If 2 switches are connected via XMPP, you can run CLI commands on switch A directly from switch B using xmpp send CLI command.
- Primefaces uses Atmosphere framework for implementing server push (PrimePush) - http://blog.primefaces.org/?p=2053.
- Atmosphere comes with a plug-in for BOSH/XMPP (https://github.com/Atmosphere/atmosphere/wiki/Atmosphere-PlugIns-and-Extensions#xmpp)
- Fun with XMPP and Google Talk - http://www.adarshr.com/papers/xmpp
- Smack API - http://www.igniterealtime.org/projects/smack/index.jsp
- XMPP Technology overview - http://xmpp.org/about-xmpp/technology-overview/
- Arista’s Network Management over XMPP - https://eos.aristanetworks.com/2011/08/management-over-xmpp/
Thursday, October 10, 2013
Brocade Content Pack for VMware LogInsight Demo @ VMworld 2013
Just got great demo of #Brocade #loginsight content pack from @Rwatsh at #VMworld. Go check it out! pic.twitter.com/l3sv5cd4Fs
— Jon Herlocker (@herlock) August 27, 2013
Friday, October 04, 2013
Ant build script for a simple Java Web App
<?xml version="1.0"?>
<project name="MyWebApp" default="dist" basedir=".">
<property name="build" location="bin" />
<property name="src" location="src" />
<property name="dist" location="dist" />
<property name="web" location="web" />
<!-- Set up the 'env' prefix for environment variables --><property environment="env" />
<property name="lib" location="lib" />
<property name="version.num" value="1.0" />
<path id="classpath">
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${env.TOMCAT_HOME}/lib">
<include name="**/*.jar" />
</fileset>
</path>
<!-- get the source compile classpath in a printable forms --><pathconvert pathsep="${line.separator}| |-- " property="echo.path.compile" refid="classpath">
</pathconvert>
<!-- 0. Abort the build if TOMCAT_HOME is not set --><target name="checkTomcatHome" unless="env.TOMCAT_HOME">
<fail message="TOMCAT_HOME must be set!" />
</target>
<!-- 0. PRINT DEFAULTS. --><target name="print_default_properties">
<echo message="os.name: ${os.name}" />
<echo message="basdir: ${basedir}" />
<echo message="ant.file: ${ant.file}" />
<echo message="ant.project.name: ${ant.project.name}" />
<echo message="ant.java.version: ${ant.java.version}" />
<echo message="tomcat_base: ${env.TOMCAT_HOME}" />
<echo message="|-- compile classpath" />
<echo message="| |" />
<echo message="| |-- ${echo.path.compile}" />
</target>
<!-- 1. CLEAN the build generated artifacts. --><target name="clean">
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
<!-- 2. INITIALIZE the build. --><target name="init" depends="print_default_properties, checkTomcatHome">
<mkdir dir="${build}" />
</target>
<!-- 3. COMPILE the source files. --><target name="compile" depends="init">
<!-- Compile the java code --><javac srcdir="${src}" destdir="${build}" classpathref="classpath" debug="on" />
</target>
<!-- 4. Create the DISTRIBUTION. --><target name="dist" depends="compile">
<mkdir dir="${dist}" />
<copy todir="${build}">
<fileset dir="${basedir}">
<include name="*.properties" />
<include name="*.xml" />
<include name="*.xsd" />
</fileset>
</copy>
<war destfile="${dist}/${ant.project.name}.war" webxml="${web}/WEB-INF/web.xml">
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Implementation-Version" value="${version.num}" />
<attribute name="Built-Date" value="${TODAY}" />
</manifest>
<fileset dir="${web}" />
<lib dir="${lib}">
<include name="**/*.jar"/>
</lib>
<classes dir="${build}" />
</war>
</target>
<!-- 5. DEPLOY the generated WAR to tomcat. --><target name="deploy" depends="dist">
<echo>Deploying to ${env.TOMCAT_HOME}</echo>
<copy todir="${env.TOMCAT_HOME}/webapps">
<fileset dir="${dist}">
<include name="${ant.project.name}.war" />
</fileset>
</copy>
</target>
<!-- HELP --><target name="help">
<echo message="help - Displays help menu">
</echo>
<echo message="compile - (default) Builds Java classes">
</echo>
<echo message="dist - Creates web applicaiton .war ">
</echo>
<echo message="clean - Delete built .class and .war files, leave directories">
</echo>
<echo message="deploy - Deploy to local tomcat installation">
</echo>
</target>
</project>
</pre>
Wednesday, October 02, 2013
jQuery treetable
'via Blog this'
Visualization: Bar Chart - Google Charts — Google Developers
Google Charts are very easy to use charting components for your web application.
'via Blog this'
Clearcase error when trying to add jquery-x.x.x.min.js to source control
When you add the jquery-x.x.x.min.js to clearcase you have to specify
the file type like this:
cleartool mkelem -eltype compressed_file jquery-x.x.x.min.js
cleartool ci -nc jquery-x.x.x.min.js
A minified javascript file has all the whitespace characters removed to make it more efficient to load the javascript on the client browser. So the entire contents of the javascript source file is compressed into a single line (removing all whitespace). Clearcase still treats it as text file but it needs to be told explicitly if its a compressed text file. I figured there is no way on the UI (clearcase explorer) that lets us do so. So we need to go to command line cleartool and run the above command to make it work.
Wednesday, July 24, 2013
Google Trends - Web Search interest: "java certification", ocmjea - Worldwide, 2004 - present
Wednesday, July 17, 2013
Book Review: The Eleventh Commandment by Jeffery Archer
Jeffery Archer excels as usual in this book by keeping it a fast paced thriller with some good dose of suspense. The story is about a CIA director trying to save her reputation at stake for ordering an assassination in Columbia, and in order to do so, she must get rid of the CIA agent who carried out her order for the assassination in Columbia, and how that agent, who was an american hero, saves himself and his family eventually.
Thursday, June 27, 2013
Essential CPU BIOS settings for virtualization
- 64-bit “Yes” – This is set by default.
- Virtualization Technology “Enabled” – This is disabled by default. You should change this.
- Execute Disable “Enabled” – This is set by default.
Tuesday, May 14, 2013
Toastmaster Speech #2 – An Introduction to Jenkins Continuous Integration Server
Time Limits: 6/7/8 mins
Actual Time Taken: 10 min 02 secs.
Following is the content of the speech:
Jenkins
1. What is Jenkins?
a. It’s a continuous integration server.
b. It is a fork of another CI server project Hudson (started by Koshiko Kawaguchi of erstwhile Sun Microsystems).
c. It is free and open source.
2. Hallmarks of Jenkins CI Server:
1. Automates builds via build triggers.
2. Automates running test suites. Fails the build if test fails. Trending of test failures by builds.
3. Encourages regular commits to the version control
4. Builds on each commit
5. Fast builds – build the module and run unit tests per module. Jenkins even supports clustering and can send the builds for different modules to different nodes in the cluster thus enabling “parallel” builds.
6. Dashboard – web based dashboard for viewing results and other notification methods like sending emails etc.
3. Why Jenkins?
a. All CI servers can poll a version control repo and execute compile and test.
b. Jenkins stands-out due to its easy-to-use web UI (with context sensitive help at each UI control level) and its extensive plugin ecosystem.
c. Due to its plug-in based ecosystem, it integrates with most of the popular version control repos, run builds for multiple languages, and view a host of valuable reports about your code.
4. How it works?
a. Jenkins supports both Ant and Maven build tools.
b. Out of the box Jenkins supports 2 version control repos: CVS and SVN.
c. Jenkin Job – You need to define a job to build a certain project. The important items you need to define are:
i. Source code management
1. Which version control branch, tag or label you are building the source code from. This is the “integration” in the CI as your team will be constantly adding new code to version control.
ii. Build triggers – when should the source code be built? This is the “continuous” of the CI.
1. Periodically – say once a day.
2. Poll SCM – set a duration say every 15 mins (specified as cron-like expresssion). If there is a commit that happened since the last poll the build will be executed.
iii. Build – what build goals/targets of the build script to execute.
d. We can have multiple jobs for the same project executing different parts of the build lifecycle. For example, we can have another job that executes once a day and executes the complete integration test suite on the build.
5. Jenkins Dashboard
a. Last Success(S) – status of the latest build
b. Weather (W) – overall health of the job – how many times build failed, whether the tests passed, and other scenarios depending on configured plugins.
6. Execute a build – can be either done manually or automatically (if polling SCM option selected).
7. Report – We can view the test reports for tests executed (triggered via Jenkins)
8. Plugin Manager – Plugins for code metrics tooling are available:
a. Checkstyle – enforces good coding guidelines.
b. FindBugs
9. Conclusion
•Jenkins an extensible CI server tool with easy to use UI and very easy to deploy.
•Use of CI server like Jenkins will go a long way in improving the quality of the software in an organization.
Saturday, May 11, 2013
Dell XPS 14 Ultrabook Review
Recently I got myself another notebook and for the first time I am trying an ultrabook – the dell xps 14 ultrabook base model which comes with i5 dual core 1.7 GHz processor, 4 GB RAM and 32GB SSD + 500 GB (5400 RPM) HDD.
The configuration is pretty decent for programming and everyday computing purposes but what is most attractive is the build quality – its aluminum body and slim overalls with the 1600x900 resolution screen for a 14” size is a pretty attractive aspect of this ultrabook. From the specs I was expecting this computer to be slow but I am plesantly surprised that over and above the processor the build of the system does make a BIG difference in the overall performance of your system. It is pretty close in look to a macbook pro and though it is not that light weight the feel of using this system is so good that I think this is the best laptop I have ever owned or even had (it surpasses my work laptop which is a dell latitude e6430).
I could not be more happy. It’s a great laptop/ultrabook to have. Especially I got this in a great deal (a refurbished one at $470 when the new ones with same config are from $800-$1000).
Popular micro services patterns
Here are some popular Microservice design patterns that a programmer should know: Service Registry pattern provides a central location fo...
-
At times, you may have wanted to perform some action periodically in your web application. Quartz is an enterprise grade scheduler which can...
-
I hit this issue recently which occurred on only one windows 7 host. The error was caused by this hard to guess reason ( http://support.mic...

