Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.clustermate.service.servlet;
  
  
Specialized sub-type of Entry servlet that will either serve request locally (if data available), or return redirect code to indicate client who to call instead.

TODO: complete -- not yet ready

 
 @SuppressWarnings("serial")
 public class RoutingEntryServlet<K extends EntryKey, E extends StoredEntry<K>>
     extends StoreEntryServlet<K,E>
 {
     public RoutingEntryServlet(StoreEntryServlet<K,E> base)
     {
         // true -> share metrics with the "real" servlet. Can separate in future if need be
         super(basetrue);
     }
     
     /*
     /**********************************************************************
     /* Overridable helper methods
     /**********************************************************************
      */
 
     protected int _findRetryCount(ServletServiceRequest request)
     {
         if (str != null) {
             str = str.trim();
             if (str.length() > 0) {
                 try {
                     return Integer.parseInt(str);
                 } catch (NumberFormatException e) { }
             }
         }
         return -1;
     }
 
     /*
     /**********************************************************************
     /* Overridden handler methods
     /**********************************************************************
      */
 
     @Override
             OperationDiagnostics stats, K key)
         throws IOException
     {
         NodeState node = _findRedirect(requestresponsekey);
         if (node == null) {
             response = (ServletServiceResponse.getEntry(requestresponsekeystats);
             _addStdHeaders(response);
             return response;
         }
         // TODO: routing!
         throw new IllegalStateException("Not yet implemented!");
     }
 
     @Override
             OperationDiagnostics stats, K key)
         throws IOException
     {
         NodeState node = _findRedirect(requestresponsekey);
         if (node == null) {
             .getEntryStats(requestresponsekeystats);
             _addStdHeaders(response);
             return response;
         }
         // TODO: routing!
         throw new IllegalStateException("Not yet implemented!");
     }
 
     @Override
             OperationDiagnostics stats, K key)
         throws IOException
     {
         NodeState node = _findRedirect(requestresponsekey);
         if (node == null) {
             .putEntry(requestresponsekeyrequest.getInputStream(),
                     stats);
             _addStdHeaders(response);
             return response;
         }
         throw new IllegalStateException("Not yet implemented!");
         // TODO: routing!
     }
 
    @Override
            OperationDiagnostics stats, K key)
        throws IOException
    {
        NodeState node = _findRedirect(requestresponsekey);
        if (node == null) {
            .removeEntry(requestresponsekeystats);
            _addStdHeaders(response);
            return response;
        }
        throw new IllegalStateException("Not yet implemented!");
        // TODO: routing!
    }
    /*
    /**********************************************************************
    /* Helper methods
    /**********************************************************************
     */
            K key)
    {
        // First: retry count always affects things
        int retry = _findRetryCount(request);
        // except for one case; first try, and we have entry locally
        boolean hasLocally = _isStoredLocally(key);
        if (hasLocally && (retry == 0)) {
            return null;
        }
        // otherwise need to find ordered set of targets
        
        // !!! TODO
        return null;
    }
    protected boolean _isStoredLocally(K key) {
        return .containsLocally(key);
    }
New to GrepCode? Check out our FAQ X