Your SlideShare is downloading. ×
0
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Dont call me cache april 17
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Dont call me cache april 17

2,232

Published on

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,232
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Powering Your Application with XAP(Using payment processing as an example)“Don’t call me cache”
  • 2. Short Intro to Caching EvolutionCacheIn process cachingof Key->Value datastructureDistribute CachePartitioned cachenodesIMDGPartitioned systemof recordIn MemoryApplication PlatformCollocated IMDG andProcessingCacheCache is good for repetitive data readsBut it is limited in capacityIt also doesn’t handle write-heavy scenarios
  • 3. Short Intro to Caching EvolutionCacheIn process cachingof Key->Value datastructureDistribute CachePartitioned cachenodesIMDGPartitioned systemof recordIn MemoryApplication PlatformCollocated IMDG andProcessingDistribute CacheAllows you to distribute your cache over numerous machines so you getIncreased CapacityBut it doesn’t support write heavy scenariosIt’s also Limited to query by IdWhat about the rest of your app? - Business logic & messaging??
  • 4. Short Intro to Caching EvolutionCacheIn process cachingof Key->Value datastructureDistribute CachePartitioned cachenodesIMDGPartitioned systemof recordIn MemoryApplication PlatformCollocated IMDG andProcessingIMDG solves these problems!You get increased capacityIMDG is also a System of Record with:Query APIsOptimized data accessData integrityIt solves your write scalability problem.
  • 5. Short Intro to Caching EvolutionCacheIn process cachingof Key->Value datastructureDistribute CachePartitioned cachenodesIMDGPartitioned systemof recordIn MemoryApplication PlatformCollocated IMDG andProcessingIn Memory Application PlatformXAP for end to end scalingIts an IMDG that hosts your Businesslogic & has messaging services!It Provides Parallel processing of dataYou get linear scalabilityYou get high availabilityHow does XAP work?
  • 6. Here’s What a Payment Authorization Process Looks LikePaymentAuthorizationRequestBasic Validation User Profile CheckMerchantProfile CheckPaymentAuthorizationApproved
  • 7. Write the Payment Object to XAPCash RegisterApplication PaymentUser payment Cluster@SpaceId()public Long getId() {return id;}@SpaceRoutingpublic Long getUserId() {return userId;}}@SpaceIndexpublic Long getCardId() {return cardId;}}The primary key of this object in the gridThe grid will use this attribute to routethe object to a particular partitionPayment objectA secondary index for query optimization
  • 8. Write the Payment Object to XAPCash RegisterApplicationUser payment ClusterPayment@SpaceId()public Long getId() {return id;}@SpaceRoutingpublic Long getUserId() {return userId;}}@SpaceIndexpublic Long getCardId() {return cardId;}}The primary key of this object in the gridThe grid will use this attribute to routethe object to a particular partitionPayment objectA Secondary index for query optimization
  • 9. Write the Payment Object to XAPCash RegisterApplicationUser payment ClusterPaymentIndexA Secondary index for query optimization@SpaceId()public Long getId() {return id;}@SpaceRoutingpublic Long getUserId() {return userId;}}@SpaceIndexpublic Long getCardId() {return cardId;}}The primary key of this object in the gridThe grid will use this attribute to routethe object to a particular partitionPayment object
  • 10. Lets Talk About Data Model for a Second
  • 11. User Id (Routing)| User Name|…Card Id| Card Data | UserID (Routing)…Transaction ID | CardId | User ID (Routing)…1  *1  *Data Model
  • 12. Lets Get Back to the Process
  • 13. Payment Validation@EventTemplatepublic SQLQuery<Payment> newPayment(){SQLQuery<Payment> query = new SQLQuery(“ status = ? ”)query.setParameter(1,”New”)return query;}QueuePaymentValidator
  • 14. Payment Validation@SpaceDataEventPayment authorizePayment(Payment payment) {space.read(new User(payment.getUserId())space.read(new Card(payment.getCardId())if (paymentIsValid(payment) {Space.write(new UserPaymentMsg(payment,getUserId()));Space.write(new VendorPaymentMsg(payment,getUserId()));space.write(new PaymentAutorization(paymentId,Initial))} else {space.write(new PaymentAutorization(paymentId,Rejected))}}QueuePaymentClass PaymentAuthorization{Status status;Boolean userCheck;Boolean vendorCheck;}ValidatorPayment Authorization
  • 15. Basic Validationif (validatePayment(payment,user,card)) {gigaSpace.write(userPaymentMsg);gigaSpace.write(vendorPaymentMsg);gigaSpace.write(paymentAuthorization);payment.setPaymentStatus(Payment.PaymentStatus.Processing);} else {payment.setPaymentStatus(Payment.PaymentStatus.SuspectedFraud);}Class PaymentAutorization {Status status;Boolean userCheck;Boolean vendorCheck;}UserValidationVendorValidationPaymentAuthorizationQueueQueueQueue Validator
  • 16. User Validation@SpaceDataEventvoid processUserPaymentValidation() {space.readMultiple(new Card(userId))space.readMultiple(new Payment(userId))if (valid()) {IdQuery<PaymentAutjorzation> idQuery = newIdQuery<PaymentAuthorization>(PaymentAuthorization.class, paymentId);space.change(idQuery, new ChangeSet().set(“userCheck", true));} else { ... }}Class PaymentAuthorization{Enum StatusBoolean userCheckBoolean vendorCheck}ReadMessageProcessQueueUserCreditCardPaymentQuerying
  • 17. User Validation@SpaceDataEventvoid processUserPaymentValidation() {space.readMultiple(new Card(userId))space.readMultiple(new Payment(userId))if (valid()) {IdQuery<PaymentAuthoirzation> idQuery = newIdQuery<PaymentAuthorization>(PaymentAuthorization.class, paymentId);space.change(idQuery, new ChangeSet().set(“userCheck", true));} else { ... }}ReadMessageProcessQueueUserCreditCardPaymentClass PaymentAuthorization {Status status;Boolean userCheck;Boolean vendorCheck;}Querying
  • 18. User ValidationReadMessageProcessQueueUserCreditCardPayment@SpaceDataEventvoid processUserPaymentValidation() {space.readMultiple(new Card(userId))space.readMultiple(new Payment(userId))if (valid()) {IdQuery<PaymentAutjorzation> idQuery = newIdQuery<PaymentAuthorization>(PaymentAuthoirzation.class, paymentId);space.change(idQuery, new ChangeSet().set(“userCheck", true));} else { ... }}Class PaymentAuthorization {Status status;Boolean userCheck;Boolean vendorCheck;}Querying
  • 19. Vendor Validationpublic void validateVendor(VendorPaymentMsg vendorPaymentMsg,GigaSpace gigaSpace) {AsyncFuture<Boolean> future = vendorGigaSpace.execute(new VendorValidationTask(vendorPaymentMsg),vendorPaymentMsg.getMerchant());IdQuery<PaymentAuthorization> idQuery = newIdQuery<PaymentAuthorization>(PaymentAuthorization.class,vendorPaymentMsg.getPaymentId());if (future.get()) gigaSpace.change(idQuery, new ChangeSet().set("vendorCheck", true));else gigaSpace.change(idQuery, new ChangeSet().set("vendorCheck”, false));}ReadMessageProcessQueueTaskclass PaymentAuthoirzation {Status status;Boolean userCheck;Boolean vendorCheck;}
  • 20. Vendor Validation@SpaceDataEventpublic void processVendorPaymentValidation() {AsyncFuture<Boolean> result= space.execute(new DistributedTask(new VendorValidationTask(Payment)))if (result.get()) {IdQuery<PaymentAutjorzation> idQuery = newIdQuery<PaymentAuthorization>(PaymentAuthorization.class,paymentId);space.change(idQuery, new ChangeSet().set(“vendorCheck”, true));} else { ... }}Payment ClusterTaskVendor ClusterClass PaymentAuthorization {Status status;Boolean userCheck;Boolean vendorCheck;}
  • 21. Vendor Validationpublic void validateVendor(VendorPaymentMsg vendorPaymentMsg,GigaSpace gigaSpace) {AsyncFuture<Boolean> future = vendorGigaSpace.execute(newVendorValidationTask(vendorPaymentMsg),vendorPaymentMsg.getMerchant());IdQuery<PaymentAuthorization> idQuery = newIdQuery<PaymentAuthorization>(PaymentAuthorization.class,vendorPaymentMsg.getPaymentId());if (future.get()) gigaSpace.change(idQuery, newChangeSet().set("vendorCheck", true));else gigaSpace.change(idQuery, new ChangeSet().set("vendorCheck", false));}Payment Cluster Vendor ClusterTaskClass PaymentAuthorization {Status status;Boolean userCheck;Boolean vendorCheck;}
  • 22. Vendor ValidationPayment Cluster Vendor ClusterTaskpublic void validateVendor(VendorPaymentMsg vendorPaymentMsg,GigaSpace gigaSpace) {AsyncFuture<Boolean> future = vendorGigaSpace.execute(newVendorValidationTask(vendorPaymentMsg),vendorPaymentMsg.getMerchant());IdQuery<PaymentAuthorization> idQuery = newIdQuery<PaymentAuthorization>(PaymentAuthorization.class,vendorPaymentMsg.getPaymentId());if (future.get()) gigaSpace.change(idQuery, newChangeSet().set("vendorCheck", true));else gigaSpace.change(idQuery, new ChangeSet().set("vendorCheck", false));}Class PaymentAuthorization {Status status;Boolean userCheck;Boolean vendorCheck;}
  • 23. Vendor Validation Check@Overridepublic Boolean execute() throws Exception {return validatePayment(vendorPaymentMsg);}TaskDealsMerchantClass PaymentAuthorization {Status status;Boolean userCheck;Boolean vendorCheck;}Querying
  • 24. Vendor Validation CheckTaskDealsMerchant@Overridepublic Boolean execute() throws Exception {return validatePayment(vendorPaymentMsg);}Class PaymentAuthorization {Status status;Boolean userCheck;Boolean vendorCheck;}Querying
  • 25. Vendor ValidationPayment Cluster Vendor ClusterCallback Taskpublic void validateVendor(VendorPaymentMsg vendorPaymentMsg,GigaSpace gigaSpace) {AsyncFuture<Boolean> future = vendorGigaSpace.execute(newVendorValidationTask(vendorPaymentMsg),vendorPaymentMsg.getMerchant());IdQuery<PaymentAuthorization> idQuery = newIdQuery<PaymentAuthorization>(PaymentAuthorization.class,vendorPaymentMsg.getPaymentId());if (future.get()) gigaSpace.change(idQuery, newChangeSet().set("vendorCheck", true));else gigaSpace.change(idQuery, new ChangeSet().set("vendorCheck", false));}Class PaymentAuthorization {Status status;Boolean userCheck;Boolean vendorCheck;}
  • 26. Yey! Payment Has Been Authorized@EventTemplatepublic PaymentAuthorization getNewPayment() {return new PaymentAuthorization(null, true, true, PaymentAuthorizationStatus.New);}QueuePaymentAuthorization

×