Project

General

Profile

Revision 5763

Added by berkley almost 10 years ago

implemented ping

View differences:

lib/web.xml.tomcat5
405 405
        <servlet-name>RestServlet</servlet-name>
406 406
        <url-pattern>/d1/checksum/*</url-pattern>
407 407
    </servlet-mapping>
408
    
409
    <servlet-mapping>
410
        <servlet-name>RestServlet</servlet-name>
411
        <url-pattern>/d1/monitor/*</url-pattern>
412
    </servlet-mapping>
408 413

  
409 414
    <servlet-mapping>
410 415
        <servlet-name>RestServlet</servlet-name>
src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java
66 66
import edu.ucsb.nceas.metacat.MetacatHandler;
67 67
import edu.ucsb.nceas.metacat.client.InsufficientKarmaException;
68 68
import edu.ucsb.nceas.metacat.dataone.CrudService;
69
import edu.ucsb.nceas.metacat.dataone.HealthService;
69 70
import edu.ucsb.nceas.metacat.properties.PropertyService;
70 71
import edu.ucsb.nceas.metacat.service.SessionService;
71 72
import edu.ucsb.nceas.metacat.util.RequestUtil;
......
207 208
    private static final String RESOURCE_IDENTIFIER = "identifier";
208 209
    private static final String RESOURCE_LOG = "log";
209 210
    private static final String RESOURCE_CHECKSUM = "checksum";
211
    private static final String RESOURCE_MONITOR = "monitor";
210 212
    private static final String RESOURCE_BASE_URL = "d1";
211 213

  
212 214
    /*
......
269 271
            String verb = "";
270 272
            
271 273
            System.out.println("handling verb " + httpVerb + " request with resource '" + resource + "'");
274
            System.out.println("resource: '" + resource + "'");
275
            System.out.println("resource_monitor: '" + RESOURCE_MONITOR + "'");
272 276
            boolean status = false;
273 277
            loadSessionData();
274 278

  
......
478 482
                        }
479 483
                        status = true;
480 484
                    }
485
                } else if(resource.equals(RESOURCE_MONITOR)) {
486
                    //health monitoring calls
487
                    System.out.println("processing monitor request");
488
                    String pathInfo = request.getPathInfo();
489
                    if (httpVerb == GET && pathInfo.toLowerCase().equals("ping")) {
490
                        System.out.println("processing ping request");
491
                        HealthService hs = new HealthService(request, response);
492
                        hs.ping();
493
                    }
494
                    status = true;
481 495
                }
482 496
                    
483 497
                if (!status)
src/edu/ucsb/nceas/metacat/dataone/CrudService.java
121 121
    /**
122 122
     * Initializes new instance by setting servlet context,request and response.
123 123
     */
124
    public CrudService() {
125
    //change crud service into a singleton.  dont pass servlet data structures here
124
    private CrudService() {
126 125
        logMetacat = Logger.getLogger(CrudService.class);
127 126
        logCrud = Logger.getLogger("DataOneLogger");
128 127
        try
......
140 139
            throw new RuntimeException("Error getting servlet url in CrudService: " + e.getMessage());
141 140
        }
142 141
        
143
        /*this.servletContext = servletContext;
144
        this.request = request;
145
        this.response = response;*/
146
        
147 142
        params = new Hashtable<String, String[]>();
148

  
149 143
        handler = new MetacatHandler(new Timer());
150

  
151 144
    }
152 145
    
153 146
    /**

Also available in: Unified diff