Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.transistore.basic;
  
com.fasterxml.clustermate.api.RequestPathStrategy implementation for Basic TransiStore configuration.

Paths are mapped as follows:

  • Store entries under ".../store/":
    • ".../store/entry" for single-entry access
    • ".../store/entries" for range (ordered multi-entry) access
    • ".../store/status" for store status (admin interface)
    • ".../store/findEntry" for redirecting single-entry
    • ".../store/findList" for redirecting range access
  • Node status entries under ".../node/":
    • ".../node/status" for basic status
    • ".../node/metrics" for various metrics
  • Sync entries under ".../sync/":
    • ".../sync/list" for accessing metadata for changes
    • ".../sync/pull" for pulling entries to sync
  •  
     @SuppressWarnings("unchecked")
     public class BasicTSPaths extends RequestPathStrategy
     {
         protected final static String FIRST_SEGMENT_STORE = "store";
         protected final static String FIRST_SEGMENT_NODE = "node";
         protected final static String FIRST_SEGMENT_SYNC = "sync";
     
         protected final static String SECOND_SEGMENT_STORE_ENTRY = "entry";
         protected final static String SECOND_SEGMENT_STORE_ENTRIES"entries";
         protected final static String SECOND_SEGMENT_STORE_STATUS = "status";
         protected final static String SECOND_SEGMENT_STORE_FIND_ENTRY = "findEntry";
         protected final static String SECOND_SEGMENT_STORE_FIND_ENTRIES = "findEntries";
     
         protected final static String SECOND_SEGMENT_NODE_STATUS = "status";
         protected final static String SECOND_SEGMENT_NODE_METRICS = "metrics";
     
         protected final static String SECOND_SEGMENT_SYNC_LIST = "list";
         protected final static String SECOND_SEGMENT_SYNC_PULL = "pull";
         
         /*
         /**********************************************************************
         /* Path building
         /**********************************************************************
          */
     
         @Override
         public <B extends RequestPathBuilder> B appendPath(B basePath,
                 PathType type)
         {
             switch (type) {
             case :
                 return (B) _nodePath(basePath).addPathSegment();
             case :
                 return (B) _nodePath(basePath).addPathSegment();
     
             case :
                 return (B) _storePath(basePath).addPathSegment();
             case :
                 return (B) _storePath(basePath).addPathSegment();
             case :
                 return (B) _storePath(basePath).addPathSegment();
             case :
                 return (B) _storePath(basePath).addPathSegment();
             case :
                 return (B) _storePath(basePath).addPathSegment();
     
             case :
                 return (B) _syncPath(basePath).addPathSegment();
             case :
                 return (B) _syncPath(basePath).addPathSegment();
             }
             throw new IllegalStateException();
         }
     
         /*
         /**********************************************************************
         /* Path matching (decoding)
         /**********************************************************************
          */
     
         @Override
         public PathType matchPath(DecodableRequestPath pathDecoder)
         {
            String full = pathDecoder.getPath();
            if (pathDecoder.matchPathSegment()) {
                if (pathDecoder.matchPathSegment()) {
                    return .;
                }
                if (pathDecoder.matchPathSegment()) {
                    return .;
                }
            } else if (pathDecoder.matchPathSegment()) {
                if (pathDecoder.matchPathSegment()) {
                    return .;
                }
                if (pathDecoder.matchPathSegment()) {
                    return .;
                }
            } else if (pathDecoder.matchPathSegment()) {
                if (pathDecoder.matchPathSegment()) {
                    return .;
                }
                if (pathDecoder.matchPathSegment()) {
                    return .;
                }
            }
            // if no match, need to reset
            pathDecoder.setPath(full);
            return null;
        }
        
        /*
        /**********************************************************************
        /* Internal methods
        /**********************************************************************
         */
        
        protected <K extends RequestPathBuilder> K _storePath(K nodeRoot) {
            return (K) nodeRoot.addPathSegment();
        }
        protected <K extends RequestPathBuilder> K _nodePath(K nodeRoot) {
            return (K) nodeRoot.addPathSegment();
        }
        protected <K extends RequestPathBuilder> K _syncPath(K nodeRoot) {
            return (K) nodeRoot.addPathSegment();
        }
    New to GrepCode? Check out our FAQ X