Powering Your Application with XAP(Using payment processing as an example)“Don’t call me cache”
Short Intro to Caching EvolutionCacheIn process cachingof Key->Value datastructureDistribute CachePartitioned cachenodesIM...
Short Intro to Caching EvolutionCacheIn process cachingof Key->Value datastructureDistribute CachePartitioned cachenodesIM...
Short Intro to Caching EvolutionCacheIn process cachingof Key->Value datastructureDistribute CachePartitioned cachenodesIM...
Short Intro to Caching EvolutionCacheIn process cachingof Key->Value datastructureDistribute CachePartitioned cachenodesIM...
Here’s What a Payment Authorization Process Looks LikePaymentAuthorizationRequestBasic Validation User Profile CheckMercha...
Write the Payment Object to XAPCash RegisterApplication PaymentUser payment Cluster@SpaceId()public Long getId() {return i...
Write the Payment Object to XAPCash RegisterApplicationUser payment ClusterPayment@SpaceId()public Long getId() {return id...
Write the Payment Object to XAPCash RegisterApplicationUser payment ClusterPaymentIndexA Secondary index for query optimiz...
Lets Talk About Data Model for a Second
User Id (Routing)| User Name|…Card Id| Card Data | UserID (Routing)…Transaction ID | CardId | User ID (Routing)…1  *1  *...
Lets Get Back to the Process
Payment Validation@EventTemplatepublic SQLQuery<Payment> newPayment(){SQLQuery<Payment> query = new SQLQuery(“ status = ? ...
Payment Validation@SpaceDataEventPayment authorizePayment(Payment payment) {space.read(new User(payment.getUserId())space....
Basic Validationif (validatePayment(payment,user,card)) {gigaSpace.write(userPaymentMsg);gigaSpace.write(vendorPaymentMsg)...
User Validation@SpaceDataEventvoid processUserPaymentValidation() {space.readMultiple(new Card(userId))space.readMultiple(...
User Validation@SpaceDataEventvoid processUserPaymentValidation() {space.readMultiple(new Card(userId))space.readMultiple(...
User ValidationReadMessageProcessQueueUserCreditCardPayment@SpaceDataEventvoid processUserPaymentValidation() {space.readM...
Vendor Validationpublic void validateVendor(VendorPaymentMsg vendorPaymentMsg,GigaSpace gigaSpace) {AsyncFuture<Boolean> f...
Vendor Validation@SpaceDataEventpublic void processVendorPaymentValidation() {AsyncFuture<Boolean> result= space.execute(n...
Vendor Validationpublic void validateVendor(VendorPaymentMsg vendorPaymentMsg,GigaSpace gigaSpace) {AsyncFuture<Boolean> f...
Vendor ValidationPayment Cluster Vendor ClusterTaskpublic void validateVendor(VendorPaymentMsg vendorPaymentMsg,GigaSpace ...
Vendor Validation Check@Overridepublic Boolean execute() throws Exception {return validatePayment(vendorPaymentMsg);}TaskD...
Vendor Validation CheckTaskDealsMerchant@Overridepublic Boolean execute() throws Exception {return validatePayment(vendorP...
Vendor ValidationPayment Cluster Vendor ClusterCallback Taskpublic void validateVendor(VendorPaymentMsg vendorPaymentMsg,G...
Yey! Payment Has Been Authorized@EventTemplatepublic PaymentAuthorization getNewPayment() {return new PaymentAuthorization...
Upcoming SlideShare
Loading in...5
×

Dont call me cache april 17

2,262

Published on

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

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

No notes for slide

Transcript of "Dont call me cache april 17"

  1. 1. Powering Your Application with XAP(Using payment processing as an example)“Don’t call me cache”
  2. 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. 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. 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. 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. 6. Here’s What a Payment Authorization Process Looks LikePaymentAuthorizationRequestBasic Validation User Profile CheckMerchantProfile CheckPaymentAuthorizationApproved
  7. 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. 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. 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. 10. Lets Talk About Data Model for a Second
  11. 11. User Id (Routing)| User Name|…Card Id| Card Data | UserID (Routing)…Transaction ID | CardId | User ID (Routing)…1  *1  *Data Model
  12. 12. Lets Get Back to the Process
  13. 13. Payment Validation@EventTemplatepublic SQLQuery<Payment> newPayment(){SQLQuery<Payment> query = new SQLQuery(“ status = ? ”)query.setParameter(1,”New”)return query;}QueuePaymentValidator
  14. 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. 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. 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. 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. 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. 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. 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. 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. 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. 23. Vendor Validation Check@Overridepublic Boolean execute() throws Exception {return validatePayment(vendorPaymentMsg);}TaskDealsMerchantClass PaymentAuthorization {Status status;Boolean userCheck;Boolean vendorCheck;}Querying
  24. 24. Vendor Validation CheckTaskDealsMerchant@Overridepublic Boolean execute() throws Exception {return validatePayment(vendorPaymentMsg);}Class PaymentAuthorization {Status status;Boolean userCheck;Boolean vendorCheck;}Querying
  25. 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. 26. Yey! Payment Has Been Authorized@EventTemplatepublic PaymentAuthorization getNewPayment() {return new PaymentAuthorization(null, true, true, PaymentAuthorizationStatus.New);}QueuePaymentAuthorization

×