Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.clustermate.service.servlet;
 
 
 
 
public class SyncListServlet<K extends EntryKey, E extends StoredEntry<K>>
    extends ServletBase
    protected final SyncHandler<K,E> _syncHandler;
    // may need JSON writer for errors:
    protected final ObjectWriter _jsonWriter;
    protected final AtomicBoolean _terminated = new AtomicBoolean(false);
    
    public SyncListServlet(SharedServiceStuff stuffClusterViewByServer clusterView,
            SyncHandler<K,E> h)
    {
        // null -> use servlet path base as-is
        super(clusterViewnull);
         = h;
         = stuff.jsonWriter();
    }
    @Override
    public void destroy() {
        .set(true);
        super.destroy();
    }
    
    @Override
    public void handleGet(ServletServiceRequest requestServletServiceResponse response,
            OperationDiagnostics statsthrows IOException
    {
        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();
    }
New to GrepCode? Check out our FAQ X