Mongo db bangalore

download Mongo db bangalore

of 27

  • date post

  • Category


  • view

  • download


Embed Size (px)

Transcript of Mongo db bangalore

  • 1.Bring Spatial Love to your Java ApplicationShekhar Gulati@shekhargulatiOpenShift Evangelist, Red Hat1

2. Building A Location Aware Job Search App2 3. User StoriesAs a User, I should be able to find all the jobs.As a User, I should be able to find all the jobs near tomy location. As a User, I should be able to find all MongoDB (orany skill) jobs near to my location. As a User, I should be able to find all the MongoDB (orany other skill) jobs near to my location with distance.3 4. Assumptions: as a developer ...Want to prototype quicklyNeed quick feedbackDont want to manage infrastructureDont want to spend much money on infrastructure. Or, evenbetter, you want it to be free.Use your existing knowledgeShould be able to use the best tool for the job4 5. Technology ChoicesMongoDBOpenShiftJava 6Spring 3.1.2.RELEASESpring 1.1.0.M1GITSSH5 6. Why MongoDB ?Easy to get runningOpen SourceActive communityRich documentsGeospatial indexing.Writes are very fast. You can customize it usingWriteConcern.6 7. Rich Document7 8. Geospatial Indexing BasicsWhat is it for? Find all the MongoDB jobs near me Find all the MongoDB jobs within PuneSupports only two dimensional indexes.You can only have one geospatial index per collection.The spatial functionality MongoDB currently has is: Near Containment 9. How to make it work1) Put your coordinates into an array{ loc : [ 50 , 30 ] } //SUGGESTED OPTION{ loc : { x : 50 , y : 30 } }{ loc : { foo : 50 , y : 30 } }{ loc : { lon : 40.739037, lat: 73.992964 } }1) Make a 2d index db.places.ensureIndex( { loc : "2d" } )9 10. Why OpenShift ? Supports MongoDB. Also supports MySQL and PostgreSQL. Multi-language support. Supports Java, Node.js, Perl, Python, PHP and Ruby. No need to learn anything new. Scalable. FREE!10 11. 11 12. What else do I get and what is the catch? OpenShift is free-as-in-beer & free-as-in-freedom You get three free gears, each with 512MB memoryand 1GB of disk space. Need more resources, just ask! The catch is we are in developer preview right now12 13. Lets get our hands dirty13 14. Create an OpenShift Account Promo code is bangalore14 15. Installing Client Tools Install Ruby 1.8.7 or greater Install Git Install rhc OpenShift gem Refer to documentation15 16. Setup your OpenShift Environmentrhc setup -l 16 17. Creating an OpenShift Application rhc app create -a localjobs -t jbossas-7 -d17 18. Adding MongoDB and RockMongo Cartridgerhc app cartridge add -a localjobs -c mongodb-2.0 rhc app cartridge add -a localjobs -c rockmongo-1.118 19. Play with MongoDB running in the Cloud ssh into instance Type mongo on the shell Create a sample db Insert some documents in the collection Run some queries19 20. Lets take a look at GIT Distributed version control A local repository on your laptop A remote repository on some other machine, usually a server20 21. You need to understand at least 3 commands in Git 1. Git add . (means add all news files as being tracked inthe local repository) 2. Git commit am your message (means commit allmy changes to the local repository with this message) 3. Git push (means push from your local repository to therepository on your OpenShift gear)21 22. Pulling the code from GitHub git rm -rf src pom.xml git commit -am removed default files git remote add localjobs -m mastergit:// git pull -s recursive -X theirs localjobs master22 23. Importing Data into MongoDB rhc app show -a localjobs -l scp -r jobs-data.json :localjobs/data ssh mongoimport -d localjobs -c jobs --file jobs-data.json -u$OPENSHIFT_NOSQL_DB_USERNAME -p$OPENSHIFT_NOSQL_DB_PASSWORD -h$OPENSHIFT_NOSQL_DB_HOST -port$OPENSHIFT_NOSQL_DB_PORT{"location":"2d"})23 24. Show some geospatial queries24 25. Deploy the code to OpenShift git push25 26. Code Walkthrough26 27. Conclusion 1. MongoDB makes it very easy to build location awareapplications. 2. OpenShift is very easy to use and embraces rapiddevelopment. 3. Did I mention Free? 4. What are you waiting for? Try it out.27