Ethical Hacker

Programmer, budding Entrepreneur, Father to little angel

Spring Boot With Smartstack - Part I

Service Discovery in Microservices Architecture is the most essential component and requires careful configuration to recover from network partitioning,hardware failures, etc. I am going to present a decentralized and distributed Service Discovery solution based on Airbnb Smartstack and Spring Boot (without the need for Spring Eureka). You can read more about components, architecture and advantages of Smartstack on Airbnb blog.

The core components of Smartstack are Nerve and Synapse. A architecture with Smartstack is given here

When using Spring Boot, Eureka serves as the Service Discovery component which requires configuration to be mentioned in dependent component. But Smartstack will help decouple this.

I am going to reuse the Docker images from newsweaver and use a spring boot based sample project (Caution : Do not use these Docker images in production, one should not rely on public docker images as most of them have vulnerabilities. Rebuild the docker images and use private registry).

Start Zookeeper

Smartstack relies on Zookeeper as a key-value store to keep track of all the discovery information. You can start use your own Zookeeper, or simply start it in container (and expose it to the host on port 2181):

1
    
docker run -d -p 2181:2181 jplock/zookeeper

Inspect the IP address of docker container using (docker inspect jplock/zookeeper)

Connect to Zookeeper Docker container

1
    
sh bin/zkCli.sh -server <ZOOKEEPER_IPADDRESS>:2181

shows lot of verbose and ends in a terminal

1
    2
    
[zkshell: 8] ls /
    [zookeeper]

Run the Spring Boot Webservice

Now I am building Docker container of the sample Spring Boot Rest Webservice with nerve and running it, the code for the project is here

1
    2
    
docker build -t krisharava/smartstack-springboot-demo
    docker run -d -e ZK_HOSTS=<ZOOKEEPER_IPADDRESS>:2181 krisharava/smartstack-springboot

You should be now seeing the service information under nerve

1
    2
    
[zk: 192.168.99.100:2181(CONNECTED) 0] ls /nerve/services/foo_service
    [foo_service_0000000001]

Conclusion

So we achieved service registration in Zookeeper using Smartstack and decoupled the configuration from Spring Boot project. In Part II I will show how to consume this service.

Spring Security - Concurrent Session Management

In a recent interview that I attended, interviewer asked me if I knew the design to configure web application with concurrent session management i.e. if user logs in to the application his previous session (if any and alive) are terminated. While my answer was quick that one can manage state details of users using Session Management and database table field to determine if user is currently logged in / not. 

While the above mentioned is pretty easy to implement, things get complicated if user accidentally closes the application without logging out. Fortunately we have easy solution to implement using Spring Security’s Concurrent Session Management.

ConcurrentSessionControlAuthenticationStrategy allows a configurable maxSessions attribute and here we are setting it to 1. Below is the gist of the core Spring Security Config that one should use

<bean class=”org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy”> <constructor-arg ref=”sessionRegistry”/> <property name=”maximumSessions” value=”1” /> </bean>

The sample project is available on Github

Reference:
http://docs.spring.io/spring-security/site/docs/3.2.0.RC2/reference/htmlsingle/#session-mgmt

How to Apply for New Voter Id Card

Here is your chance to apply for new Voter Id Card, enroll your name in Voters list and participate in the upcoming Indian General Elections slated for next year April 2014, includes step by step instructions and FAQ related to Voter Id Cards. The whole process for an Voter Card to be issued takes a month to complete.

http://www.allindiadaily.com/2013/07/apply-for-voter-id-online.html

I was able to complete and submit the application in under 30 minutes.(The application flow was slightly different from what was shown in the link http://www.ceoandhra.nic.in/ceonew/home.aspx -> E-Registration->Form-6)

If you are from Andhra Pradesh, one can submit the application in ESeva / MeSeva centers too.

Please do share it with your friends.

My Thoughts on IPL Mess

I havent spoken out for long time and wanted to share another perspective of the IPL mess.
When the first news came out, I was heartbroken to watch talented young player like Sreesanth went for the trap.

Arjuna Ranathunga rightly pointed that IPL is monster that’s ruining Indian Cricket.
After matches IPL Parties - boozing, girls and sex are the most common things cricketers do after the games. (And of course they get a chance our bookies too here). Like a movie story, this monster full of creeps from Bollywood and Politicians who have no interest in holding the respect for the game.

The Gentleman Game now is run by gamblers with the patronage of political parties both the congress and opposition. This investigation is a mere eyewash and will die down soon (Public has short memory, remember Coal Scam !!).

Lets come back to the point when this all started, were Rajasthan Royals management not aware of the antics of a person like Sreesanth and Chandila? Apparently a party was thrown on April 6th by a bookie in Gurgaon and Chandila attended the party.

Now would you be a owner of 130 million dollars worth club not keep a watch on team players. Otherwise Shilpa Shetty and other RR team management be so dumb they must be thinking “Oh Chandila has gone to Guragon to attend Bookie’s Party and we will play clean” oh thats great. The first one to be held responsible should be team owners and management, someone must be knowing what was going to happen.

Second - The legends of the game (those who are now working as commentators, board members, selectors) have failed to take BCCI head on. They are too guilty, they gladly accepted lucrative offers and be part of the corrupt system.

BCCI know they will thrive to make enough money to spend on parties at Five Star Hotels, special charted flights. But morality and spirit of the game have hit new low and there is no recovering of it from this point, unless miracle happens.

Pay Toll to Get on to This HELL WAY (WTF)

If you happened to be in Chennai,India do not ever get on to IT express corridor way.

Unfortunately I was to taking it everyday to reach office. Not just me, an estimated 2 lakh people take it everyday to reach their destination. This expressway is the only way to reach SIPCOT SEZ (special economic zone / IT hub. Believe it or not this place was once dump yard .. yak!) This expressway is dirty stretch of 20 Kms from Thirvanmayur to Siruseri, with incomplete roads and footpaths.

This dirty stretch has incomplete encroached footpaths, roads layed without any special U turn approach roads and constant straying of cows and dogs

Yet to use this way four wheeler owner needs to pay 35 rupees for using this way. It kind of shows how much poor governance is part of bureaucratic system in India.

Are You Not Happy With Your IT Job?

I met some of my buddies yesterday. And one thing that is often common in conversations in these meetings is everyone tell’s me about how much their job sucks in Indian IT consultancy companies. Most of these companies have poor standards, ethics and ridiculous work cultures. These so called professionals jobs are mere low end support / maintenance related roles. And enterprise software sucks.

On the other side companies like Apple and Google have given power to developers. Developers can now write and monetize applications using Android Market, Chrome Web store, Apple App Store. Other places where developers / consultants can look for work on is freelancer.com. These are just few instances, there are millions of places on the internet where we can look for work.

I work for another Indian IT consultancy but I do enjoy technology as much as I can. I work most of free time on the internet. In the past I have done lot of work like building websites, jailbreaking iphones & android phones, learning new concepts about networking and security. I have written my own operating system based on linux. My ambition is to join Google one day.

Here is how I will break it down learn something new:

1) The best way to start is to start

Yes, start with something you thought was interesting. It need not be about programming or something related to you current role. It could be something that you always baffled about. Like how does an operating system work / What is hacking / How does internet work / What technologies is facebook using to support 600 million users?

Internet has all the answers. So keep browsing till you find answers (get a smartphone to browse the internet, it is very handy and productive). This will help you find to narrow down to your interests.

2) Choose your interest

Talk to your friends / colleagues to discuss about your new interests. They can help you choose and narrow down your options. Also you will get an insight into career’s that are flourishing.

3) Plan for a course

While I dont recommend to going back to College / special tutorial classes, lectures such as these are available online. So use google search to find lectures. Or borrow / rent books. Prepare a scheduled plan for your course.

You need to have strong will to stick to implement the plan. But this course will surely help you to learn and enjoy technology. Technology is fun for most home based hackers (I am one such). In due course it can be eventually turned into full time career. For one to become successful it takes years, so be patient my friend things will not happen overnight.

I can quote number of CEO’s of startup in Silicon valley who have switched jobs and followed their interests / passion to become successful (like this one).

So best of luck and share any information in comments below this post.

Comments

Lakshmi
Hey Chaitanya….nice article!!!!
Druthi
Loved your posting and the way you keep up your interest!!! all the best with your future endeavors …. Its a quest for self satisfaction and it should take time….lekapothe em maza kada :)

Google Translate Converts Real Time Speech

The new free Android app from Google - Google Translate (requires android 2.1 or greater version) is available for download from Android Market. It converts speech in realtime and it implies that it can act as a translator.

Check out the below video.


Youtube Remote Is Cool

I have really enjoyed using Youtube Remote on my G2. Its so cool …

Check this video to understand what I mean

Comments

Srinivas Jayaram
This is so cool … I love it

Oh simplytelangana.com Admin Owns simplyandhra.com

I was so much mad about this website simplytelangana.com. Their articles were riducles. So I just checked who is owing the website. It turns out the administrator also owned the website simplyandhra.com.

See the below details:

http://serversiders.com/simplytelangana.com

Who is details:

http://www.whois.net/whois/simplytelangana.com
http://www.whois.net/whois/simplyandhra.com

Both the websites are registered with the same network 1and1.com
And when you try simplyandhra.com the domain is forwarding to simplytelangana.com. So it means the admin cashed on the fever of Telanagana and changed his initial website from simplyandhra.com to simplytelangana.com

So who else cashed on Telangana fever? Let me know your opinion in comments

Comments

Sharath
Jai Telangana Bro… Don't humiliate the sentiment of Telangana Bro.. thats our RIGHT, thats our Sentiment, thats our MOTHER LAND, thats our Respect, thats OUR BREAD & Butter…

Don't link Telangana with Business….cheers
every body in the world can come down and live in telangana, no worries but if anybody try to humiliate "KABARDAAR"…

Jai Jai Telangana…