From 91668b3a4cae2e9868c1bb7b3db2e587bf1ccc44 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Mon, 9 Jan 2017 10:22:02 +0100 Subject: [PATCH 1/2] removed windStatusJson servlet; it wasn't used at all according to our 2016 server logs (AWStats) Change-Id: I018c6a6a7ea0f0c369a8e875ad5a32333d7f316f --- .../SailingGWT sdm.launch | 156 +++++++++--------- java/com.sap.sailing.gwt.ui/SailingGWT.launch | 150 ++++++++--------- .../WEB-INF/web.xml | 8 - .../gateway/impl/WindStatusJsonServlet.java | 140 ---------------- 4 files changed, 153 insertions(+), 301 deletions(-) delete mode 100644 java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/impl/WindStatusJsonServlet.java diff --git a/java/com.sap.sailing.gwt.ui/SailingGWT sdm.launch b/java/com.sap.sailing.gwt.ui/SailingGWT sdm.launch index 4a15fa5eb4b..4c3271a52ac 100644 --- a/java/com.sap.sailing.gwt.ui/SailingGWT sdm.launch +++ b/java/com.sap.sailing.gwt.ui/SailingGWT sdm.launch @@ -1,78 +1,78 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/com.sap.sailing.gwt.ui/SailingGWT.launch b/java/com.sap.sailing.gwt.ui/SailingGWT.launch index 05d195e0e53..0c4449938c3 100644 --- a/java/com.sap.sailing.gwt.ui/SailingGWT.launch +++ b/java/com.sap.sailing.gwt.ui/SailingGWT.launch @@ -1,75 +1,75 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/com.sap.sailing.server.gateway/WEB-INF/web.xml b/java/com.sap.sailing.server.gateway/WEB-INF/web.xml index b8795dece22..9752cc0f343 100644 --- a/java/com.sap.sailing.server.gateway/WEB-INF/web.xml +++ b/java/com.sap.sailing.server.gateway/WEB-INF/web.xml @@ -139,14 +139,6 @@ WindStatusHtmlServlet /windStatus - - WindStatusJsonServlet - com.sap.sailing.server.gateway.impl.WindStatusJsonServlet - - - WindStatusJsonServlet - /windStatusJson - TrackFilesExportPostServlet com.sap.sailing.server.gateway.trackfiles.impl.TrackFilesExportPostServlet diff --git a/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/impl/WindStatusJsonServlet.java b/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/impl/WindStatusJsonServlet.java deleted file mode 100644 index 856f1abb4b6..00000000000 --- a/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/impl/WindStatusJsonServlet.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.sap.sailing.server.gateway.impl; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Deque; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; - -import com.sap.sailing.domain.igtimiadapter.BulkFixReceiver; -import com.sap.sailing.domain.igtimiadapter.IgtimiWindListener; -import com.sap.sse.common.Duration; -import com.sap.sse.common.TimePoint; -import com.sap.sse.common.impl.MillisecondsTimePoint; - -/** - * Shows the state of wind receivers regardless of them being attached to a race. - * Currently Igtimi is supported. - * - * @author Simon Marcel Pamies - * - */ -public class WindStatusJsonServlet extends WindStatusServlet implements IgtimiWindListener, BulkFixReceiver { - - private static final long serialVersionUID = 6091476602985063675L; - private static final String PARAM_SHOW_DUMMY_DATA = "showDummyData"; - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - String reinitializeWindReceiverParameter = req.getParameter(PARAM_RELOAD_WIND_RECEIVER); - String showDummyDataAsString = req.getParameter(PARAM_SHOW_DUMMY_DATA); - resp.setContentType("application/json"); - PrintWriter out = resp.getWriter(); - boolean showDummyData = showDummyDataAsString != null && showDummyDataAsString.equalsIgnoreCase("true"); - if (showDummyData) { - out.print(generateDummyData().toJSONString()); - } else { - initializeWindReceiver(reinitializeWindReceiverParameter != null && reinitializeWindReceiverParameter.equalsIgnoreCase("true")); - JSONObject windInformation = new JSONObject(); - windInformation.put("windFixesReceivedSoFar", getIgtimiMessagesRawCount()+getLastExpeditionMessages().size()); - JSONArray windFixesIgtimi = new JSONArray(); - if (getLastIgtimiMessages() != null && !getLastIgtimiMessages().isEmpty()) { - for(Entry> deviceAndMessagesList: getLastIgtimiMessages().entrySet()) { - final Deque copyOfLastIgtimiMessages; - synchronized (deviceAndMessagesList.getValue()) { - copyOfLastIgtimiMessages = new ArrayDeque<>(deviceAndMessagesList.getValue()); - } - if(copyOfLastIgtimiMessages.size() > 0) { - TimePoint latestTimePoint = copyOfLastIgtimiMessages.peek().getWind().getTimePoint(); - long lastFixDiffInMs = System.currentTimeMillis() - latestTimePoint.asMillis(); - windInformation.put("lastWindFixMillisecondsAgo", lastFixDiffInMs); - } - Iterator messageIt = copyOfLastIgtimiMessages.iterator(); - while (messageIt.hasNext()){ - JSONObject windFix = new JSONObject(); - windFix.put("sensorId", deviceAndMessagesList.getKey()); - IgtimiMessageInfo message = messageIt.next(); - windFix.put("sensorPositionLatitude", message.getWind().getPosition().getLatDeg()); - windFix.put("sensorPositionLongitude", message.getWind().getPosition().getLngDeg()); - windFix.put("windFromInDegrees", message.getWind().getFrom().getDegrees()); - windFix.put("windToInDegrees", message.getWind().getFrom().reverse().getDegrees()); - windFix.put("windSpeedInMetersPerSecond", message.getWind().getMetersPerSecond()); - windFix.put("windSpeedInStatuteMilesPerHour", message.getWind().getStatuteMilesPerHour()); - windFix.put("windSpeedInKilometersPerHour", message.getWind().getKilometersPerHour()); - windFix.put("windSpeedInKnots", message.getWind().getKnots()); - windFix.put("measurementTimePointAsMillis", message.getWind().getTimePoint().asMillis()); - windFixesIgtimi.add(windFix); - } - } - } - windInformation.put("windFixes", windFixesIgtimi); - out.print(windInformation.toJSONString()); - } - out.close(); - } - - @SuppressWarnings("serial") - private JSONObject generateDummyData() { - List> dummyWindFixes = new ArrayList>(); - dummyWindFixes.add(new HashMap() {{ - put("sensorId", "DD-EE-HG"); - put("sensorPositionLatitude", 49.2511599999); - put("sensorPositionLongitude", 8.624829999); - put("windFromInDegrees", 90.0); - put("windToInDegrees", 270.0); - put("windSpeedInMetersPerSecond", 6.944444); - put("windSpeedInKilometersPerHour", 25.0); - put("windSpeedInStatuteMilesPerHour", 15.43); - put("windSpeedInKnots", 13.498920086); - put("measurementTimePointAsMillis", MillisecondsTimePoint.now().minus(Duration.ONE_SECOND.times(4)).asMillis()); - }}); - dummyWindFixes.add(new HashMap() {{ - put("sensorId", "DD-AA-EF"); - put("sensorPositionLatitude", 49.244489999); - put("sensorPositionLongitude", 8.6253399999); - put("windFromInDegrees", 100.0); - put("windToInDegrees", 280.0); - put("windSpeedInMetersPerSecond", 6.944444); - put("windSpeedInKilometersPerHour", 25.0); - put("windSpeedInStatuteMilesPerHour", 15.43); - put("windSpeedInKnots", 13.498920086); - put("measurementTimePointAsMillis", MillisecondsTimePoint.now().minus(Duration.ONE_SECOND.times(5)).asMillis()); - }}); - dummyWindFixes.add(new HashMap() {{ - put("sensorId", "DD-UU-KL"); - put("sensorPositionLatitude", 49.243539999); - put("sensorPositionLongitude", 8.6146099999); - put("windFromInDegrees", 85.0); - put("windToInDegrees", 265.0); - put("windSpeedInMetersPerSecond", 6.944444); - put("windSpeedInKilometersPerHour", 25.0); - put("windSpeedInStatuteMilesPerHour", 15.43); - put("windSpeedInKnots", 13.498920086); - put("measurementTimePointAsMillis", MillisecondsTimePoint.now().minus(Duration.ONE_SECOND.times(6)).asMillis()); - }}); - JSONObject windInformation = new JSONObject(); - windInformation.put("windFixesReceivedSoFar", 3); - JSONArray windFixesIgtimi = new JSONArray(); - windInformation.put("lastWindFixMillisecondsAgo", 1239876); - for (Map windDummyFix : dummyWindFixes) { - JSONObject windFix = new JSONObject(); - windFix.putAll(windDummyFix); - windFixesIgtimi.add(windFix); - } - windInformation.put("windFixes", windFixesIgtimi); - return windInformation; - } - -} From a09823d20a5c7fec5c1cc9d5fcec7e9993a1d5f6 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Mon, 9 Jan 2017 11:54:30 +0100 Subject: [PATCH 2/2] use Class object instead of class name to create service tracker Change-Id: I3ed24acc8547391111e6397f80c5d750efbdf68f --- .../src/com/sap/sailing/server/impl/RacingEventServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/com.sap.sailing.server/src/com/sap/sailing/server/impl/RacingEventServiceImpl.java b/java/com.sap.sailing.server/src/com/sap/sailing/server/impl/RacingEventServiceImpl.java index 878cba359df..5b386c00f69 100644 --- a/java/com.sap.sailing.server/src/com/sap/sailing/server/impl/RacingEventServiceImpl.java +++ b/java/com.sap.sailing.server/src/com/sap/sailing/server/impl/RacingEventServiceImpl.java @@ -3327,7 +3327,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes result = Collections.singleton((WindTrackerFactory) ExpeditionWindTrackerFactory.getInstance()); } else { ServiceTracker tracker = new ServiceTracker( - bundleContext, WindTrackerFactory.class.getName(), null); + bundleContext, WindTrackerFactory.class, null); tracker.open(); result = new HashSet<>(); for (WindTrackerFactory factory : tracker.getServices(new WindTrackerFactory[0])) {