Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.clustermate.service.servlet;
  
  
  
 
 
 @SuppressWarnings("serial")
 public class SyncListServlet<K extends EntryKey, E extends StoredEntry<K>>
     extends ServletWithMetricsBase
 {
     protected final SyncHandler<K,E> _syncHandler;
 
     // may need JSON writer for errors:
     protected final ObjectWriter _jsonWriter;
 
     protected final AtomicBoolean _terminated = new AtomicBoolean(false);
 
     protected final OperationMetrics _listMetrics;
     
     public SyncListServlet(SharedServiceStuff stuffClusterViewByServer clusterView,
             SyncHandler<K,E> h)
     {
         // null -> use servlet path base as-is
         super(stuffclusterViewnull);
          = h;
          = stuff.jsonWriter();
         final ServiceConfig serviceConfig = stuff.getServiceConfig();
         if (serviceConfig.metricsEnabled) {
              = OperationMetrics.forListingOperation(serviceConfig"syncList");
         } else {
              = null;
         }
     }
 
     @Override
     public void destroy() {
         .set(true);
         super.destroy();
     }
 
     @Override
     public void fillOperationMetrics(AllOperationMetrics metrics) {
         metrics.SYNCLIST = ExternalOperationMetrics.create();
     }
 
     @Override
     public void handleGet(ServletServiceRequest requestServletServiceResponse response,
             OperationDiagnostics statsthrows IOException
     {
         final OperationMetrics metrics = ;
         Context timer = (metrics == null) ? null : metrics.start();
         try {
             if (str == null) {
                 response = .missingArgument(response.);
             } else {
                 long since = -1;
                 try {
                     since = Long.parseLong(str);
                 } catch (NumberFormatException e) { }
                 if (since < 0L) {
                     response = .invalidArgument(response.str);
                 } else {
                     try {
                         response = .listEntries(requestresponsesincestats);
                     } catch (IllegalStateException e) {
                         // Swallow during shutdown
                         if (!.get()) {
                             .error("Failed syncHandler.listEntries(): "+e.getMessage(), e);
                         }
                         response.internalError("Failed syncHandler.listEntries(): "+e.getMessage());
                     } catch (InterruptedException e) {
                         // Swallow during shutdown (mostly during tests)
                         if (!.get()) {
                             throw new IOException(e);
                         }
                         .info("SyncListServlet interupted due to termination, ignoring");
                         return;
                     }
                     _addStdHeaders(response);
                 }
             }
             response.writeOut();
         } finally {
            if (metrics != null) {
                metrics.finish(timerstats);
           }
        }
    }
New to GrepCode? Check out our FAQ X