SlideShare a Scribd company logo
1 of 26
Download to read offline
Dropwizard MongoDBDropwizard MongoDB
One day prototype usingOne day prototype using ,,
andand
Yun Zhi Lin
DropwizardDropwizard MongoDBMongoDB
Google CloudGoogle Cloud
Yunspace.com +YunZhiLin @YunZhiLin
About - Yun Zhi LinAbout - Yun Zhi Lin
Computer Science @UNSW, Applied Finance @Macquarie
Joined a startup in 2002, then moved into Banking IT
Moonlights as a Web 2.0 (nosql, json, mobile) enthusiast
Loves Java without bloated frameworks or appservers
This project source code in GitHub
SpecSpec
End to end prototype of a Bill Aggregator that mimics vendor API.
See below for detail specifications.
Data ModelData Model
Providers - bill provider
Premises - location being provisioned for
Subscriptions - subscribe to bill by account/reference #
Bill - matching subscriptions trigger notifications
Notifications - Sent to subscription.callbackUrl with
UrlForBillRetrieval
FK: List(Subscriptions)
FK: List(Subscriptions)
FK: Provider.id, Premise.id, Bill.accountNumber, List(Bi
FK: Provider.id, Subscription.referenceNumber
FK: Provider, Premise, Subscription
ActorsActors
Producer - API hosted on Google Compute Engine
API Operations - Insert, List, Get, Remove, Path on all entities,
except Notification and Bill.
Consumer - Use
Sample Data - JSON files provided
Postman HTTP client
RequirementsRequirements
1. HTTP transport
2. JSON payload
3. Use compute engine
4. Authentication
5. API versioning
6. Ops-friendly
7. Data Validation
8. Batch considerations
DesignDesign
Frameworks ChoiceFrameworks Choice
Node.js - full stack JSON, but lacking expertise
Play! Framework - too complex for this exercise
Dropwizard - simple, war-less and proven
Database ChoiceDatabase Choice
Google Cloud Datastore - lacking expertise
MongoDB - perfect for JSON
Dropwizard + MongoDB = Meet RequirementsDropwizard + MongoDB = Meet Requirements
1. HTTP - Jersey RESTful web services
2. JSON - Jackson with Mongo-Jack, fastest Java parser
3. Use compute engine - Both API jar and DB hosted on GCE
4. Authentication - OAuth2 or custom Providers
5. API versioning - annotation based url mappings
6. Ops-friendly - healchecks and Codahale metrics
7. Data Validation - Hibernate Validatior
8. Batch considerations - use JSON lists
PlanPlan
Due to the time contraint, it's important to decide on the approach
taken to plan out a successfull prototype:
Start to End - build each component fully one by one, can only
partially demonstrate the story
Minimum Viable Product - selectively build only critical
operations for all components. So that together they tell a full
story
Scope AdjustmentScope Adjustment
Authentication - excluded
API versioning - excluded
Batch - simplified to single JSON parsing
Queuing - another consideration for the real world, excluded
Notification - manually triggered.
Final Use CaseFinal Use Case
Only the following Operations demonstrate the core processes of
subscription, notification and bill retrieval:
1. create a subscriptoin
2. Manually trigger notification, where UrlForBillRetrieval =
subscription.callbackURL + billID
3. retrieve a Bill
PUT /subscription/
GET /subscription/trigger/{subscriptoinID}/{billID}/
GET /bill/?billID={billID}
ImplementationImplementation
1. Build Tool
2. Configuration
3. MongoDB
4. Healthcheck
5. JSON POJOs
6. Resources
7. Application Glue
Build ToolBuild Tool
Gradle combines the best of Ant and Maven
repositories {
mavenLocal()
mavenCentral()
}
project.ext {
dropwizardVersion = '0.7.0-SNAPSHOT'
mongojackVersion = '2.0.0-RC5'
dropWizardConfig = './src/main/resources/billproto.y
}
dependencies {
compile 'io.dropwizard:dropwizard-core:' + dropwizar
compile 'org.mongojack:mongojack:' + mongojackVersio
testCompile group: 'junit', name: 'junit', version:
}
run {
args 'server', dropWizardConfig
} ConfigurationConfiguration
YAML
POJO
mongo:
host: ds039487.mongolab.com
port: 39487
db: tycoon-mongo
user: ####
password: ####
public class MongoConfiguration {
@NotNull
public String host;
@Min(1)
@Max(65535)
@NotNull
public int port;
@NotNull
public String db;
@NotNull
MongoDBMongoDB
public String user;
@NotNull
public String password;
}
Hosting - GCE option
Connection
JacksonDBCollection
DB Import (must be list of single line json files)
MongLab
mongo = new Mongo(mongoConfig.host, mongoConfig.port);
db = mongo.getDB(mongoConfig.db);
db.authenticate(mongoConfig.user, mongoConfig.password.t
bills = wrap(db.getCollection("bill"), Bill.class, Strin
dbCursor = bills.find().is("_id", billID);
if (dbCursor.hasNext()) { Bill result = cursor.next();}
mongoimport --host --username --password --db --collecti
HealthCheckHealthCheck
Code
Healthy
Not healthy:
@Override
protected Result check() throws Exception {
mongo.getDB(dbname).getCollectionNames();
return Result.healthy();
}
{"MongoHealthCheck":{"healthy":true},"deadlocks":{"healt
{"MongoHealthCheck":{"healthy":false,
"message":"not authorized for query on tycoon-mo
"error":{"message":"not authorized for query on
"stack":[...]JSON POJOsJSON POJOs
"deadlocks":{"healthy":true}}Use . Then apply simple
annotations for Jackson and Hibernate Validatior.
http://www.jsonschema2pojo.org/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Notification {
@Id
public String notificationID;
@NotNull
public String subscriptionID;
@NotNull
public String notificationURLForBillDataRetrival;
@NotNull
public String notificationURLForBillImageRetrival;
}
ResourcesResources
NOTE: Use @Id for UUID, not @ObjectIdAnnotate opertion, metrics, url path and output format.
Jackson automatically parse POJO into specified mediaType.
@GET
@Timed
@Path("trigger/{subscriptionID}/{billID}")
@Produces(MediaType.APPLICATION_JSON)
public Notification triggerNotification(
@PathParam("subscriptionID") String subscription
@PathParam("billID") String billID) {
...
notification = new Notification();
notification.notificationID = UUID.randomUUID().toSt
notification.subscriptionID = subscriptionID;
notification.notificationURLForBillDataRetrival =
subscription.subscriptionCallBackURL + "?billID=
return notification;
}
Application GlueApplication Glue
Putting all of the above together
@Override
public void run(
BillprotoConfiguration configuration,
Environment environment) throws Exception {
MongoManaged mongoManaged =
new MongoManaged(configuration.mongo);
environment.lifecycle().manage(mongoManaged);
environment.healthChecks().register(
"MongoHealthCheck", new MongoHealthCheck(mongoMa
environment.jersey().register(new SubscriptionResour
environment.jersey().register(new BillResource(mongo
}
DeployDeploy
1. Install Java (defaults to OpenJDK)
2. Open firewall ports 8080 and 8081
3. Copy file to server
4. Run fatjar
sudo apt-get install java7-runtime-headless
gcutil addfirewall rest --description="http" --allowed
gcutil addfirewall admin --description="Iadmin" --allo
gcutil --project={project-id} push {instance-name} {lo
java -jar billproto-0.2-fat.jar server billproto.yml
TestingTesting
REST urlsREST urls
Subscription:
Trigger:
Bill:
Healthcheck:
162.222.183.244:8080/subscription/
162.222.183.244:8080/subscription/{subscriptionID}/{billID}
162.222.183.244:8080/bill/?billID={billID}
162.222.183.244:8081
ConclusionConclusion
By building just the bare minimum operations in each components
that work well together, we were able to cover the core user story
and better assess our API feasibility.
We also managed to test out a new framework and built a template
that can be fleshed out for future applications.
Links and CreditsLinks and Credits
built with
dropwizard.io
mongojack.org
gradle.org
This project source code in GitHub
This Slide reveal.js Export to PDF
QuestionsQuestions

More Related Content

What's hot

Introduction to Restkit
Introduction to RestkitIntroduction to Restkit
Introduction to Restkitpetertmarks
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code維佋 唐
 
Performance and Security Enhancements in MongoDB's BI Connector
Performance and Security Enhancements in MongoDB's BI ConnectorPerformance and Security Enhancements in MongoDB's BI Connector
Performance and Security Enhancements in MongoDB's BI ConnectorMongoDB
 
NoSQL meets Microservices - Michael Hackstein
NoSQL meets Microservices - Michael HacksteinNoSQL meets Microservices - Michael Hackstein
NoSQL meets Microservices - Michael Hacksteindistributed matters
 
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...MongoDB
 
201410 2 fiware-orion-contextbroker
201410 2 fiware-orion-contextbroker201410 2 fiware-orion-contextbroker
201410 2 fiware-orion-contextbrokerFIWARE
 
FIWARE Developers Week_ Introduction to Managing Context Information at Large...
FIWARE Developers Week_ Introduction to Managing Context Information at Large...FIWARE Developers Week_ Introduction to Managing Context Information at Large...
FIWARE Developers Week_ Introduction to Managing Context Information at Large...FIWARE
 
What's new in iOS 7
What's new in iOS 7What's new in iOS 7
What's new in iOS 7barcelonaio
 
Spca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_serviceSpca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_serviceNCCOMMS
 
MongoDB.local Sydney: How and When to Use Multi-Document Distributed Transact...
MongoDB.local Sydney: How and When to Use Multi-Document Distributed Transact...MongoDB.local Sydney: How and When to Use Multi-Document Distributed Transact...
MongoDB.local Sydney: How and When to Use Multi-Document Distributed Transact...MongoDB
 
What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?Trisha Gee
 
Web Integration Patterns in the Era of HTML5
Web Integration Patterns in the Era of HTML5Web Integration Patterns in the Era of HTML5
Web Integration Patterns in the Era of HTML5johnwilander
 
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the AirAvitoTech
 
MongoDB Stitch Tutorial
MongoDB Stitch TutorialMongoDB Stitch Tutorial
MongoDB Stitch TutorialMongoDB
 
Refatorando com a API funcional do Java
Refatorando com a API funcional do JavaRefatorando com a API funcional do Java
Refatorando com a API funcional do JavaGiovane Liberato
 
Angular Restmod (english version)
Angular Restmod (english version)Angular Restmod (english version)
Angular Restmod (english version)Marcin Gajda
 
MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...
MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...
MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...MongoDB
 

What's hot (18)

Introduction to Restkit
Introduction to RestkitIntroduction to Restkit
Introduction to Restkit
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
Performance and Security Enhancements in MongoDB's BI Connector
Performance and Security Enhancements in MongoDB's BI ConnectorPerformance and Security Enhancements in MongoDB's BI Connector
Performance and Security Enhancements in MongoDB's BI Connector
 
NoSQL meets Microservices - Michael Hackstein
NoSQL meets Microservices - Michael HacksteinNoSQL meets Microservices - Michael Hackstein
NoSQL meets Microservices - Michael Hackstein
 
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
 
201410 2 fiware-orion-contextbroker
201410 2 fiware-orion-contextbroker201410 2 fiware-orion-contextbroker
201410 2 fiware-orion-contextbroker
 
FIWARE Developers Week_ Introduction to Managing Context Information at Large...
FIWARE Developers Week_ Introduction to Managing Context Information at Large...FIWARE Developers Week_ Introduction to Managing Context Information at Large...
FIWARE Developers Week_ Introduction to Managing Context Information at Large...
 
What's new in iOS 7
What's new in iOS 7What's new in iOS 7
What's new in iOS 7
 
Understanding AJAX
Understanding AJAXUnderstanding AJAX
Understanding AJAX
 
Spca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_serviceSpca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_service
 
MongoDB.local Sydney: How and When to Use Multi-Document Distributed Transact...
MongoDB.local Sydney: How and When to Use Multi-Document Distributed Transact...MongoDB.local Sydney: How and When to Use Multi-Document Distributed Transact...
MongoDB.local Sydney: How and When to Use Multi-Document Distributed Transact...
 
What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?
 
Web Integration Patterns in the Era of HTML5
Web Integration Patterns in the Era of HTML5Web Integration Patterns in the Era of HTML5
Web Integration Patterns in the Era of HTML5
 
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
 
MongoDB Stitch Tutorial
MongoDB Stitch TutorialMongoDB Stitch Tutorial
MongoDB Stitch Tutorial
 
Refatorando com a API funcional do Java
Refatorando com a API funcional do JavaRefatorando com a API funcional do Java
Refatorando com a API funcional do Java
 
Angular Restmod (english version)
Angular Restmod (english version)Angular Restmod (english version)
Angular Restmod (english version)
 
MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...
MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...
MongoDB World 2018: Time for a Change Stream - Using MongoDB Change Streams t...
 

Viewers also liked

Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBMongoDB
 
A Tale of Contemporary Software
A Tale of Contemporary SoftwareA Tale of Contemporary Software
A Tale of Contemporary SoftwareYun Zhi Lin
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and FriendsYun Zhi Lin
 
Nano Segmentation - A Docker Security Journey
Nano Segmentation - A Docker Security JourneyNano Segmentation - A Docker Security Journey
Nano Segmentation - A Docker Security JourneyYun Zhi Lin
 
Top 5 Things to Know About Integrating MongoDB into Your Data Warehouse
Top 5 Things to Know About Integrating MongoDB into Your Data WarehouseTop 5 Things to Know About Integrating MongoDB into Your Data Warehouse
Top 5 Things to Know About Integrating MongoDB into Your Data WarehouseMongoDB
 
Microservices and Friends
Microservices and FriendsMicroservices and Friends
Microservices and FriendsYun Zhi Lin
 
4 Success stories in 3 years - A Docker Production Journey
4 Success stories in 3 years - A Docker Production Journey4 Success stories in 3 years - A Docker Production Journey
4 Success stories in 3 years - A Docker Production JourneyYun Zhi Lin
 

Viewers also liked (7)

Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
A Tale of Contemporary Software
A Tale of Contemporary SoftwareA Tale of Contemporary Software
A Tale of Contemporary Software
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and Friends
 
Nano Segmentation - A Docker Security Journey
Nano Segmentation - A Docker Security JourneyNano Segmentation - A Docker Security Journey
Nano Segmentation - A Docker Security Journey
 
Top 5 Things to Know About Integrating MongoDB into Your Data Warehouse
Top 5 Things to Know About Integrating MongoDB into Your Data WarehouseTop 5 Things to Know About Integrating MongoDB into Your Data Warehouse
Top 5 Things to Know About Integrating MongoDB into Your Data Warehouse
 
Microservices and Friends
Microservices and FriendsMicroservices and Friends
Microservices and Friends
 
4 Success stories in 3 years - A Docker Production Journey
4 Success stories in 3 years - A Docker Production Journey4 Success stories in 3 years - A Docker Production Journey
4 Success stories in 3 years - A Docker Production Journey
 

Similar to Dropwizard with MongoDB and Google Cloud

MongoTx: Transactions with Sharding and Queries
MongoTx: Transactions with Sharding and QueriesMongoTx: Transactions with Sharding and Queries
MongoTx: Transactions with Sharding and QueriesHiroshi Horii
 
InfluxDB Client Libraries and Applications | Miroslav Malecha | Bonitoo
InfluxDB Client Libraries and Applications | Miroslav Malecha | BonitooInfluxDB Client Libraries and Applications | Miroslav Malecha | Bonitoo
InfluxDB Client Libraries and Applications | Miroslav Malecha | BonitooInfluxData
 
Lowering the Barrier to Stream Processing With Alex Morley | Current 2022
Lowering the Barrier to Stream Processing With Alex Morley | Current 2022Lowering the Barrier to Stream Processing With Alex Morley | Current 2022
Lowering the Barrier to Stream Processing With Alex Morley | Current 2022HostedbyConfluent
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchMongoDB
 
Build resource server & client for OCF Cloud (2018.8.30)
Build resource server & client for OCF Cloud (2018.8.30)Build resource server & client for OCF Cloud (2018.8.30)
Build resource server & client for OCF Cloud (2018.8.30)남균 김
 
High Availability by Design
High Availability by DesignHigh Availability by Design
High Availability by DesignDavid Prinzing
 
Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Application to the Next Level...
Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Application to the Next Level...Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Application to the Next Level...
Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Application to the Next Level...MongoDB
 
Serverless Design Patterns (London Dev Community)
Serverless Design Patterns (London Dev Community)Serverless Design Patterns (London Dev Community)
Serverless Design Patterns (London Dev Community)Yan Cui
 
Remote Config REST API and Versioning
Remote Config REST API and VersioningRemote Config REST API and Versioning
Remote Config REST API and VersioningJumpei Matsuda
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBChun-Kai Wang
 
Benefit of CodeIgniter php framework
Benefit of CodeIgniter php frameworkBenefit of CodeIgniter php framework
Benefit of CodeIgniter php frameworkBo-Yi Wu
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBTobias Trelle
 
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling Sencha
 
Running MongoDB Enterprise on Kubernetes
Running MongoDB Enterprise on KubernetesRunning MongoDB Enterprise on Kubernetes
Running MongoDB Enterprise on KubernetesAriel Jatib
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCLFastly
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB
 

Similar to Dropwizard with MongoDB and Google Cloud (20)

MongoTx: Transactions with Sharding and Queries
MongoTx: Transactions with Sharding and QueriesMongoTx: Transactions with Sharding and Queries
MongoTx: Transactions with Sharding and Queries
 
InfluxDB Client Libraries and Applications | Miroslav Malecha | Bonitoo
InfluxDB Client Libraries and Applications | Miroslav Malecha | BonitooInfluxDB Client Libraries and Applications | Miroslav Malecha | Bonitoo
InfluxDB Client Libraries and Applications | Miroslav Malecha | Bonitoo
 
Lowering the Barrier to Stream Processing With Alex Morley | Current 2022
Lowering the Barrier to Stream Processing With Alex Morley | Current 2022Lowering the Barrier to Stream Processing With Alex Morley | Current 2022
Lowering the Barrier to Stream Processing With Alex Morley | Current 2022
 
ql.io at NodePDX
ql.io at NodePDXql.io at NodePDX
ql.io at NodePDX
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB Stitch
 
Build resource server & client for OCF Cloud (2018.8.30)
Build resource server & client for OCF Cloud (2018.8.30)Build resource server & client for OCF Cloud (2018.8.30)
Build resource server & client for OCF Cloud (2018.8.30)
 
High Availability by Design
High Availability by DesignHigh Availability by Design
High Availability by Design
 
Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Application to the Next Level...
Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Application to the Next Level...Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Application to the Next Level...
Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Application to the Next Level...
 
Serverless Design Patterns (London Dev Community)
Serverless Design Patterns (London Dev Community)Serverless Design Patterns (London Dev Community)
Serverless Design Patterns (London Dev Community)
 
Remote Config REST API and Versioning
Remote Config REST API and VersioningRemote Config REST API and Versioning
Remote Config REST API and Versioning
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Siddhi - cloud-native stream processor
Siddhi - cloud-native stream processorSiddhi - cloud-native stream processor
Siddhi - cloud-native stream processor
 
Benefit of CodeIgniter php framework
Benefit of CodeIgniter php frameworkBenefit of CodeIgniter php framework
Benefit of CodeIgniter php framework
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
 
Knative Outro
Knative OutroKnative Outro
Knative Outro
 
Running MongoDB Enterprise on Kubernetes
Running MongoDB Enterprise on KubernetesRunning MongoDB Enterprise on Kubernetes
Running MongoDB Enterprise on Kubernetes
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDB
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 

More from Yun Zhi Lin

AWS Lambda Containers - bridging the gap between serverless and containers on...
AWS Lambda Containers - bridging the gap between serverless and containers on...AWS Lambda Containers - bridging the gap between serverless and containers on...
AWS Lambda Containers - bridging the gap between serverless and containers on...Yun Zhi Lin
 
Applied AI, Open Banking and Continuous Innovation the Easy Way - AI Days Mel...
Applied AI, Open Banking and Continuous Innovation the Easy Way - AI Days Mel...Applied AI, Open Banking and Continuous Innovation the Easy Way - AI Days Mel...
Applied AI, Open Banking and Continuous Innovation the Easy Way - AI Days Mel...Yun Zhi Lin
 
Art of Serverless Business Value - Serverless Days Sydney 2019
Art of Serverless Business Value - Serverless Days Sydney 2019Art of Serverless Business Value - Serverless Days Sydney 2019
Art of Serverless Business Value - Serverless Days Sydney 2019Yun Zhi Lin
 
Anticorrupting the Enterprise - Serverlessconf NYC 2017
Anticorrupting the Enterprise - Serverlessconf NYC 2017Anticorrupting the Enterprise - Serverlessconf NYC 2017
Anticorrupting the Enterprise - Serverlessconf NYC 2017Yun Zhi Lin
 
Financial Forecasting using Recurrent Neural Network, Social Media and Cloud
Financial Forecasting using Recurrent Neural Network, Social Media and CloudFinancial Forecasting using Recurrent Neural Network, Social Media and Cloud
Financial Forecasting using Recurrent Neural Network, Social Media and CloudYun Zhi Lin
 
Amazingly Simple Serverless Go
Amazingly Simple Serverless GoAmazingly Simple Serverless Go
Amazingly Simple Serverless GoYun Zhi Lin
 
Easy Serverless Golang
Easy Serverless GolangEasy Serverless Golang
Easy Serverless GolangYun Zhi Lin
 

More from Yun Zhi Lin (7)

AWS Lambda Containers - bridging the gap between serverless and containers on...
AWS Lambda Containers - bridging the gap between serverless and containers on...AWS Lambda Containers - bridging the gap between serverless and containers on...
AWS Lambda Containers - bridging the gap between serverless and containers on...
 
Applied AI, Open Banking and Continuous Innovation the Easy Way - AI Days Mel...
Applied AI, Open Banking and Continuous Innovation the Easy Way - AI Days Mel...Applied AI, Open Banking and Continuous Innovation the Easy Way - AI Days Mel...
Applied AI, Open Banking and Continuous Innovation the Easy Way - AI Days Mel...
 
Art of Serverless Business Value - Serverless Days Sydney 2019
Art of Serverless Business Value - Serverless Days Sydney 2019Art of Serverless Business Value - Serverless Days Sydney 2019
Art of Serverless Business Value - Serverless Days Sydney 2019
 
Anticorrupting the Enterprise - Serverlessconf NYC 2017
Anticorrupting the Enterprise - Serverlessconf NYC 2017Anticorrupting the Enterprise - Serverlessconf NYC 2017
Anticorrupting the Enterprise - Serverlessconf NYC 2017
 
Financial Forecasting using Recurrent Neural Network, Social Media and Cloud
Financial Forecasting using Recurrent Neural Network, Social Media and CloudFinancial Forecasting using Recurrent Neural Network, Social Media and Cloud
Financial Forecasting using Recurrent Neural Network, Social Media and Cloud
 
Amazingly Simple Serverless Go
Amazingly Simple Serverless GoAmazingly Simple Serverless Go
Amazingly Simple Serverless Go
 
Easy Serverless Golang
Easy Serverless GolangEasy Serverless Golang
Easy Serverless Golang
 

Recently uploaded

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 

Recently uploaded (20)

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 

Dropwizard with MongoDB and Google Cloud

  • 1. Dropwizard MongoDBDropwizard MongoDB One day prototype usingOne day prototype using ,, andand Yun Zhi Lin DropwizardDropwizard MongoDBMongoDB Google CloudGoogle Cloud Yunspace.com +YunZhiLin @YunZhiLin
  • 2. About - Yun Zhi LinAbout - Yun Zhi Lin Computer Science @UNSW, Applied Finance @Macquarie Joined a startup in 2002, then moved into Banking IT Moonlights as a Web 2.0 (nosql, json, mobile) enthusiast Loves Java without bloated frameworks or appservers This project source code in GitHub
  • 3. SpecSpec End to end prototype of a Bill Aggregator that mimics vendor API. See below for detail specifications.
  • 4. Data ModelData Model Providers - bill provider Premises - location being provisioned for Subscriptions - subscribe to bill by account/reference # Bill - matching subscriptions trigger notifications Notifications - Sent to subscription.callbackUrl with UrlForBillRetrieval FK: List(Subscriptions) FK: List(Subscriptions) FK: Provider.id, Premise.id, Bill.accountNumber, List(Bi FK: Provider.id, Subscription.referenceNumber FK: Provider, Premise, Subscription
  • 5. ActorsActors Producer - API hosted on Google Compute Engine API Operations - Insert, List, Get, Remove, Path on all entities, except Notification and Bill. Consumer - Use Sample Data - JSON files provided Postman HTTP client
  • 6. RequirementsRequirements 1. HTTP transport 2. JSON payload 3. Use compute engine 4. Authentication 5. API versioning 6. Ops-friendly 7. Data Validation 8. Batch considerations
  • 8. Frameworks ChoiceFrameworks Choice Node.js - full stack JSON, but lacking expertise Play! Framework - too complex for this exercise Dropwizard - simple, war-less and proven
  • 9. Database ChoiceDatabase Choice Google Cloud Datastore - lacking expertise MongoDB - perfect for JSON
  • 10. Dropwizard + MongoDB = Meet RequirementsDropwizard + MongoDB = Meet Requirements 1. HTTP - Jersey RESTful web services 2. JSON - Jackson with Mongo-Jack, fastest Java parser 3. Use compute engine - Both API jar and DB hosted on GCE 4. Authentication - OAuth2 or custom Providers 5. API versioning - annotation based url mappings 6. Ops-friendly - healchecks and Codahale metrics 7. Data Validation - Hibernate Validatior 8. Batch considerations - use JSON lists
  • 11. PlanPlan Due to the time contraint, it's important to decide on the approach taken to plan out a successfull prototype: Start to End - build each component fully one by one, can only partially demonstrate the story Minimum Viable Product - selectively build only critical operations for all components. So that together they tell a full story
  • 12. Scope AdjustmentScope Adjustment Authentication - excluded API versioning - excluded Batch - simplified to single JSON parsing Queuing - another consideration for the real world, excluded Notification - manually triggered.
  • 13. Final Use CaseFinal Use Case Only the following Operations demonstrate the core processes of subscription, notification and bill retrieval: 1. create a subscriptoin 2. Manually trigger notification, where UrlForBillRetrieval = subscription.callbackURL + billID 3. retrieve a Bill PUT /subscription/ GET /subscription/trigger/{subscriptoinID}/{billID}/ GET /bill/?billID={billID}
  • 14. ImplementationImplementation 1. Build Tool 2. Configuration 3. MongoDB 4. Healthcheck 5. JSON POJOs 6. Resources 7. Application Glue Build ToolBuild Tool
  • 15. Gradle combines the best of Ant and Maven repositories { mavenLocal() mavenCentral() } project.ext { dropwizardVersion = '0.7.0-SNAPSHOT' mongojackVersion = '2.0.0-RC5' dropWizardConfig = './src/main/resources/billproto.y } dependencies { compile 'io.dropwizard:dropwizard-core:' + dropwizar compile 'org.mongojack:mongojack:' + mongojackVersio testCompile group: 'junit', name: 'junit', version: } run { args 'server', dropWizardConfig } ConfigurationConfiguration YAML
  • 16. POJO mongo: host: ds039487.mongolab.com port: 39487 db: tycoon-mongo user: #### password: #### public class MongoConfiguration { @NotNull public String host; @Min(1) @Max(65535) @NotNull public int port; @NotNull public String db; @NotNull MongoDBMongoDB
  • 17. public String user; @NotNull public String password; } Hosting - GCE option Connection JacksonDBCollection DB Import (must be list of single line json files) MongLab mongo = new Mongo(mongoConfig.host, mongoConfig.port); db = mongo.getDB(mongoConfig.db); db.authenticate(mongoConfig.user, mongoConfig.password.t bills = wrap(db.getCollection("bill"), Bill.class, Strin dbCursor = bills.find().is("_id", billID); if (dbCursor.hasNext()) { Bill result = cursor.next();} mongoimport --host --username --password --db --collecti HealthCheckHealthCheck
  • 18. Code Healthy Not healthy: @Override protected Result check() throws Exception { mongo.getDB(dbname).getCollectionNames(); return Result.healthy(); } {"MongoHealthCheck":{"healthy":true},"deadlocks":{"healt {"MongoHealthCheck":{"healthy":false, "message":"not authorized for query on tycoon-mo "error":{"message":"not authorized for query on "stack":[...]JSON POJOsJSON POJOs
  • 19. "deadlocks":{"healthy":true}}Use . Then apply simple annotations for Jackson and Hibernate Validatior. http://www.jsonschema2pojo.org/ @JsonInclude(JsonInclude.Include.NON_NULL) public class Notification { @Id public String notificationID; @NotNull public String subscriptionID; @NotNull public String notificationURLForBillDataRetrival; @NotNull public String notificationURLForBillImageRetrival; } ResourcesResources
  • 20. NOTE: Use @Id for UUID, not @ObjectIdAnnotate opertion, metrics, url path and output format. Jackson automatically parse POJO into specified mediaType. @GET @Timed @Path("trigger/{subscriptionID}/{billID}") @Produces(MediaType.APPLICATION_JSON) public Notification triggerNotification( @PathParam("subscriptionID") String subscription @PathParam("billID") String billID) { ... notification = new Notification(); notification.notificationID = UUID.randomUUID().toSt notification.subscriptionID = subscriptionID; notification.notificationURLForBillDataRetrival = subscription.subscriptionCallBackURL + "?billID= return notification; }
  • 21. Application GlueApplication Glue Putting all of the above together @Override public void run( BillprotoConfiguration configuration, Environment environment) throws Exception { MongoManaged mongoManaged = new MongoManaged(configuration.mongo); environment.lifecycle().manage(mongoManaged); environment.healthChecks().register( "MongoHealthCheck", new MongoHealthCheck(mongoMa environment.jersey().register(new SubscriptionResour environment.jersey().register(new BillResource(mongo } DeployDeploy
  • 22. 1. Install Java (defaults to OpenJDK) 2. Open firewall ports 8080 and 8081 3. Copy file to server 4. Run fatjar sudo apt-get install java7-runtime-headless gcutil addfirewall rest --description="http" --allowed gcutil addfirewall admin --description="Iadmin" --allo gcutil --project={project-id} push {instance-name} {lo java -jar billproto-0.2-fat.jar server billproto.yml
  • 24. ConclusionConclusion By building just the bare minimum operations in each components that work well together, we were able to cover the core user story and better assess our API feasibility. We also managed to test out a new framework and built a template that can be fleshed out for future applications.
  • 25. Links and CreditsLinks and Credits built with dropwizard.io mongojack.org gradle.org This project source code in GitHub This Slide reveal.js Export to PDF