11 |
import javax.servlet.http.HttpServletResponse; |
import javax.servlet.http.HttpServletResponse; |
12 |
|
|
13 |
import dk.thoerup.circuitbreaker.CircuitBreakerException; |
import dk.thoerup.circuitbreaker.CircuitBreakerException; |
14 |
|
import dk.thoerup.traininfoservice.Statistics; |
15 |
|
|
16 |
/** |
/** |
17 |
* Servlet implementation class TimetableServlet |
* Servlet implementation class TimetableServlet |
40 |
response.sendError(400, "not enough parameters"); |
response.sendError(400, "not enough parameters"); |
41 |
return; |
return; |
42 |
} |
} |
43 |
|
Statistics.getInstance().incrementTimetableLookups(); |
44 |
|
|
45 |
String train = request.getParameter("train").trim(); |
String train = request.getParameter("train").trim(); |
46 |
String trainID; |
String trainID; |
69 |
response.getWriter().print(responseXML); |
response.getWriter().print(responseXML); |
70 |
} catch (java.io.IOException ioe) { |
} catch (java.io.IOException ioe) { |
71 |
logger.warning("(timetable) Read failed, train="+train + ". " + ioe.getMessage()); |
logger.warning("(timetable) Read failed, train="+train + ". " + ioe.getMessage()); |
72 |
|
Statistics.getInstance().incrementTimetableErrors(); |
73 |
response.sendError(500, "Backend timed out"); |
response.sendError(500, "Backend timed out"); |
74 |
} catch (CircuitBreakerException cbe) { |
} catch (CircuitBreakerException cbe) { |
75 |
logger.warning("Circuitbreaker - failing fast"); |
logger.warning("Circuitbreaker - failing fast"); |
76 |
|
Statistics.getInstance().incrementTimetableErrors(); |
77 |
response.sendError(500); |
response.sendError(500); |
78 |
}catch (Exception e) { |
}catch (Exception e) { |
79 |
logger.log(Level.WARNING, "failure looking up timetable: train=" +train, e); |
logger.log(Level.WARNING, "failure looking up timetable: train=" +train, e); |
80 |
|
Statistics.getInstance().incrementTimetableErrors(); |
81 |
response.sendError(500); |
response.sendError(500); |
82 |
} |
} |
83 |
|
|