mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-27 16:06:39 +00:00
Merge remote-tracking branch 'server/master'
This commit is contained in:
+65
-91
@@ -72,7 +72,7 @@ import com.sap.sailing.gwt.ui.shared.components.Component;
|
||||
public abstract class AbstractChartPanel<SettingsType extends ChartSettings> extends RaceChart implements
|
||||
CompetitorSelectionChangeListener, RequiresResize {
|
||||
private static final int LINE_WIDTH = 1;
|
||||
private CompetitorsRaceDataDTO chartData;
|
||||
private static final int MAX_SERIES_POINTS = 10000;
|
||||
private boolean compactChart;
|
||||
private final Label noCompetitorsSelectedLabel;
|
||||
private final Map<CompetitorDTO, Series> dataSeriesByCompetitor;
|
||||
@@ -95,7 +95,6 @@ public abstract class AbstractChartPanel<SettingsType extends ChartSettings> ext
|
||||
this.allowTimeAdjust = allowTimeAdjust;
|
||||
dataSeriesByCompetitor = new HashMap<CompetitorDTO, Series>();
|
||||
markPassingSeriesByCompetitor = new HashMap<CompetitorDTO, Series>();
|
||||
chartData = null;
|
||||
setSize("100%", "100%");
|
||||
|
||||
noCompetitorsSelectedLabel = new Label(stringMessages.selectAtLeastOneCompetitor() + ".");
|
||||
@@ -196,53 +195,27 @@ public abstract class AbstractChartPanel<SettingsType extends ChartSettings> ext
|
||||
}
|
||||
}
|
||||
|
||||
private void loadData(final Date from, final Date to, List<CompetitorDTO> competitors, boolean append) {
|
||||
if(chartData != null && chartData.getDetailType() != selectedDetailType) {
|
||||
chartData = null;
|
||||
}
|
||||
|
||||
private void loadData(final Date from, final Date to, final List<CompetitorDTO> competitors, final boolean append) {
|
||||
showLoading(stringMessages.loadingCompetitorData());
|
||||
ArrayList<CompetitorDTO> competitorsToLoad = new ArrayList<CompetitorDTO>();
|
||||
for (CompetitorDTO competitorDTO : competitors) {
|
||||
competitorsToLoad.add(competitorDTO);
|
||||
}
|
||||
|
||||
// Date chartDataDateOfNewestData = chartData.getDateOfNewestData();
|
||||
// Date competitorDateOfNewestData = chartData.contains(competitor) ? chartData.getCompetitorData(competitor)
|
||||
// .getDateOfNewestData() : null;
|
||||
// if (!chartData.contains(competitor)) {
|
||||
// competitorsToLoad.add(new Pair<Date, CompetitorDTO>(new Date(0), competitor));
|
||||
// } else if (competitorDateOfNewestData.before(chartDataDateOfNewestData)
|
||||
// || competitorDateOfNewestData.before(timeRangeWithZoomProvider.getToTime())) {
|
||||
// competitorsToLoad.add(new Pair<Date, CompetitorDTO>(new Date(competitorDateOfNewestData.getTime()
|
||||
// + getStepSize()), competitor));
|
||||
// }
|
||||
|
||||
showLoading(stringMessages.loadingCompetitorData());
|
||||
GetCompetitorsRaceDataAction getCompetitorsRaceDataAction = new GetCompetitorsRaceDataAction(sailingService,
|
||||
selectedRaceIdentifier, competitorsToLoad, from, to, getStepSize(),
|
||||
getSelectedDetailType(), new AsyncCallback<CompetitorsRaceDataDTO>() {
|
||||
@Override
|
||||
public void onSuccess(CompetitorsRaceDataDTO result) {
|
||||
if (result != null) {
|
||||
timeOfEarliestRequestInMillis = result.getRequestedFromTime().getTime();
|
||||
timeOfLatestRequestInMillis = result.getRequestedToTime().getTime();
|
||||
|
||||
if(chartData == null) {
|
||||
chartData = result;
|
||||
} else {
|
||||
for (CompetitorRaceDataDTO competitorData : result.getAllRaceData()) {
|
||||
if (chartData.contains(competitorData.getCompetitor())) {
|
||||
chartData.addCompetitorRaceData(competitorData);
|
||||
chartData.setCompetitorMarkPassingsData(competitorData);
|
||||
} else {
|
||||
chartData.setCompetitorData(competitorData.getCompetitor(), competitorData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onSuccess(final CompetitorsRaceDataDTO result) {
|
||||
hideLoading();
|
||||
|
||||
drawChartData();
|
||||
if (result != null) {
|
||||
updateChartSeries(result, append);
|
||||
} else {
|
||||
if (!append) {
|
||||
clearChart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -291,63 +264,72 @@ public abstract class AbstractChartPanel<SettingsType extends ChartSettings> ext
|
||||
/**
|
||||
* Creates the series for all selected competitors if these aren't created yet.<br />
|
||||
* Fills the series for the selected competitors with the data in {@link AbstractChartPanel#chartData}.<br />
|
||||
* Removes series of competitors, which aren't selected and adds series for competitors, which are newly selected.<br />
|
||||
* Also {@link #forceTimeLineUpdate() updates} the {@link #timeLineSeries} if {@link #timeLineNeedsUpdate} is
|
||||
* <code>true</code>.<br />
|
||||
* <br />
|
||||
*
|
||||
* The data for all {@link #getSelectedCompetitors() visible competitors} needs to be filled before calling this
|
||||
* method.
|
||||
*/
|
||||
private synchronized void drawChartData() {
|
||||
private synchronized void updateChartSeries(CompetitorsRaceDataDTO chartData, boolean append) {
|
||||
// Make sure the busy indicator is removed at this point, or plotting the data results in an exception
|
||||
setWidget(chart);
|
||||
|
||||
if (chartData != null) {
|
||||
List<Series> chartSeries = Arrays.asList(chart.getSeries());
|
||||
for (CompetitorDTO competitor : getSelectedCompetitors()) {
|
||||
Series competitorDataSeries = getOrCreateCompetitorDataSeries(competitor);
|
||||
Series markPassingSeries = getOrCreateCompetitorMarkPassingSeries(competitor);
|
||||
CompetitorRaceDataDTO competitorData = chartData.getCompetitorData(competitor);
|
||||
if (competitorData != null) {
|
||||
Date toDate = new Date(System.currentTimeMillis() - timer.getLivePlayDelayInMillis());
|
||||
|
||||
List<Triple<String, Date, Double>> markPassingsData = competitorData.getMarkPassingsData();
|
||||
List<Point> markPassingPoints = new ArrayList<Point>();
|
||||
for (Triple<String, Date, Double> markPassingData : markPassingsData) {
|
||||
if (markPassingData.getB() != null && markPassingData.getC() != null) {
|
||||
if (markPassingData.getB().before(toDate)) {
|
||||
Point markPassingPoint = new Point(markPassingData.getB().getTime(),
|
||||
markPassingData.getC());
|
||||
markPassingPoint.setName(markPassingData.getA());
|
||||
markPassingPoints.add(markPassingPoint);
|
||||
}
|
||||
List<Series> chartSeries = Arrays.asList(chart.getSeries());
|
||||
for (CompetitorDTO competitor : chartData.getCompetitors()) {
|
||||
Series competitorDataSeries = getOrCreateCompetitorDataSeries(competitor);
|
||||
Series markPassingSeries = getOrCreateCompetitorMarkPassingSeries(competitor);
|
||||
CompetitorRaceDataDTO competitorData = chartData.getCompetitorData(competitor);
|
||||
if (competitorData != null) {
|
||||
Date toDate = new Date(System.currentTimeMillis() - timer.getLivePlayDelayInMillis());
|
||||
|
||||
List<Triple<String, Date, Double>> markPassingsData = competitorData.getMarkPassingsData();
|
||||
List<Point> markPassingPoints = new ArrayList<Point>();
|
||||
for (Triple<String, Date, Double> markPassingData : markPassingsData) {
|
||||
if (markPassingData.getB() != null && markPassingData.getC() != null) {
|
||||
if (markPassingData.getB().before(toDate)) {
|
||||
Point markPassingPoint = new Point(markPassingData.getB().getTime(),
|
||||
markPassingData.getC());
|
||||
markPassingPoint.setName(markPassingData.getA());
|
||||
markPassingPoints.add(markPassingPoint);
|
||||
}
|
||||
}
|
||||
markPassingSeries.setPoints(markPassingPoints.toArray(new Point[0]));
|
||||
}
|
||||
markPassingSeries.setPoints(markPassingPoints.toArray(new Point[0]), false);
|
||||
|
||||
Point[] compSeriesPoints = competitorDataSeries.getPoints();
|
||||
Date dateOfNewestSeriesPoint = compSeriesPoints.length == 0 ? null : new Date(
|
||||
compSeriesPoints[compSeriesPoints.length - 1].getX().longValue());
|
||||
List<Pair<Date, Double>> raceData = dateOfNewestSeriesPoint == null ? competitorData.getRaceData()
|
||||
: competitorData.getRaceDataAfterDate(dateOfNewestSeriesPoint);
|
||||
for (Pair<Date, Double> data : raceData) {
|
||||
if (data.getA() != null && data.getB() != null) {
|
||||
if (data.getA().before(toDate)) {
|
||||
Point competitorPoint = new Point(data.getA().getTime(), data.getB());
|
||||
competitorDataSeries.addPoint(competitorPoint);
|
||||
}
|
||||
Point[] oldRaceDataPoints = competitorDataSeries.getPoints();
|
||||
List<Pair<Date, Double>> raceData = competitorData.getRaceData();
|
||||
|
||||
Point[] raceDataPointsToAdd = new Point[raceData.size()];
|
||||
int currentPointIndex = 0;
|
||||
for (Pair<Date, Double> raceDataPoint : raceData) {
|
||||
Double dataPointValue = raceDataPoint.getB();
|
||||
if(dataPointValue != null) {
|
||||
long dataPointTimeAsMillis = raceDataPoint.getA().getTime();
|
||||
if(append == false || (timeOfEarliestRequestInMillis == null || dataPointTimeAsMillis < timeOfEarliestRequestInMillis) ||
|
||||
timeOfLatestRequestInMillis == null || dataPointTimeAsMillis > timeOfLatestRequestInMillis) {
|
||||
raceDataPointsToAdd[currentPointIndex++] = new Point(dataPointTimeAsMillis, dataPointValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Adding the series if chart doesn't contain it
|
||||
if (!chartSeries.contains(competitorDataSeries)) {
|
||||
chart.addSeries(competitorDataSeries);
|
||||
chart.addSeries(markPassingSeries);
|
||||
}
|
||||
Point[] newRaceDataPoints;
|
||||
if (append) {
|
||||
newRaceDataPoints = new Point[oldRaceDataPoints.length + currentPointIndex];
|
||||
System.arraycopy(oldRaceDataPoints, 0, newRaceDataPoints, 0, oldRaceDataPoints.length);
|
||||
System.arraycopy(raceDataPointsToAdd, 0, newRaceDataPoints, oldRaceDataPoints.length, currentPointIndex);
|
||||
} else {
|
||||
newRaceDataPoints = new Point[currentPointIndex];
|
||||
System.arraycopy(raceDataPointsToAdd, 0, newRaceDataPoints, 0, currentPointIndex);
|
||||
}
|
||||
|
||||
competitorDataSeries.setPoints(newRaceDataPoints, false);
|
||||
|
||||
// Adding the series if chart doesn't contain it
|
||||
if (!chartSeries.contains(competitorDataSeries)) {
|
||||
chart.addSeries(competitorDataSeries);
|
||||
chart.addSeries(markPassingSeries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
timeOfEarliestRequestInMillis = chartData.getRequestedFromTime().getTime();
|
||||
timeOfLatestRequestInMillis = chartData.getRequestedToTime().getTime();
|
||||
|
||||
// if (!isZoomed) {
|
||||
// chart.getXAxis().setMin(timeRangeWithZoomProvider.getFromTime().getTime());
|
||||
// chart.getXAxis().setMax(timeRangeWithZoomProvider.getToTime().getTime());
|
||||
@@ -377,6 +359,7 @@ public abstract class AbstractChartPanel<SettingsType extends ChartSettings> ext
|
||||
.setMarker(new Marker().setEnabled(false).setHoverState(new Marker().setEnabled(true).setRadius(4)))
|
||||
.setShadow(false).setHoverStateLineWidth(LINE_WIDTH)
|
||||
.setColor(competitorSelectionProvider.getColor(competitor)).setSelected(true));
|
||||
result.setOption("turboThreshold", MAX_SERIES_POINTS);
|
||||
dataSeriesByCompetitor.put(competitor, result);
|
||||
}
|
||||
return result;
|
||||
@@ -435,7 +418,6 @@ public abstract class AbstractChartPanel<SettingsType extends ChartSettings> ext
|
||||
* Clears the whole chart and empties cached data.
|
||||
*/
|
||||
protected void clearChart() {
|
||||
setChartData(null);
|
||||
timeOfEarliestRequestInMillis = null;
|
||||
timeOfLatestRequestInMillis = null;
|
||||
dataSeriesByCompetitor.clear();
|
||||
@@ -540,14 +522,6 @@ public abstract class AbstractChartPanel<SettingsType extends ChartSettings> ext
|
||||
return hasDetailTypeChanged;
|
||||
}
|
||||
|
||||
protected CompetitorsRaceDataDTO getChartData() {
|
||||
return chartData;
|
||||
}
|
||||
|
||||
protected void setChartData(CompetitorsRaceDataDTO chartData) {
|
||||
this.chartData = chartData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRaceSelectionChange(List<RegattaAndRaceIdentifier> selectedRaces) {
|
||||
if (selectedRaces != null && !selectedRaces.isEmpty()) {
|
||||
|
||||
+5
-3
@@ -45,9 +45,11 @@ public class ChartPanel extends AbstractChartPanel<ChartSettings> implements Com
|
||||
|
||||
@Override
|
||||
public void updateSettings(ChartSettings newSettings) {
|
||||
updateSettingsOnly(newSettings);
|
||||
clearChart();
|
||||
timeChanged(timer.getTime());
|
||||
boolean settingsChanged = updateSettingsOnly(newSettings);
|
||||
if(settingsChanged) {
|
||||
clearChart();
|
||||
timeChanged(timer.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ public class MultiChartPanel extends AbstractChartPanel<MultiChartSettings> impl
|
||||
boolean settingsChanged = updateSettingsOnly(newSettings);
|
||||
boolean selectedDetailTypeChanged = setSelectedDetailType(newSettings.getDetailType());
|
||||
if (selectedDetailTypeChanged || settingsChanged) {
|
||||
clearChart();
|
||||
timeChanged(timer.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -60,6 +60,8 @@ import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
|
||||
|
||||
public class WindChart extends RaceChart implements Component<WindChartSettings>, RequiresResize {
|
||||
private static final int LINE_WIDTH = 1;
|
||||
private static final int MAX_SERIES_POINTS = 10000;
|
||||
|
||||
private final WindChartSettings settings;
|
||||
|
||||
/**
|
||||
@@ -283,6 +285,7 @@ public class WindChart extends RaceChart implements Component<WindChartSettings>
|
||||
.setType(Series.Type.LINE)
|
||||
.setName(stringMessages.fromDeg()+" "+WindSourceTypeFormatter.format(windSource, stringMessages))
|
||||
.setYAxis(0)
|
||||
.setOption("turboThreshold", MAX_SERIES_POINTS)
|
||||
.setPlotOptions(new LinePlotOptions().setColor(colorMap.getColorByID(windSource)).setSelected(true));
|
||||
return newSeries;
|
||||
}
|
||||
@@ -297,6 +300,7 @@ public class WindChart extends RaceChart implements Component<WindChartSettings>
|
||||
.setType(Series.Type.LINE)
|
||||
.setName(stringMessages.windSpeed()+" "+WindSourceTypeFormatter.format(windSource, stringMessages))
|
||||
.setYAxis(1) // use the second Y-axis
|
||||
.setOption("turboThreshold", MAX_SERIES_POINTS)
|
||||
.setPlotOptions(new LinePlotOptions().setDashStyle(PlotLine.DashStyle.SHORT_DOT)
|
||||
.setLineWidth(3).setHoverStateLineWidth(3)
|
||||
.setColor(colorMap.getColorByID(windSource)).setSelected(true)); // show only the markers, not the connecting lines
|
||||
@@ -307,7 +311,7 @@ public class WindChart extends RaceChart implements Component<WindChartSettings>
|
||||
* Updates the wind charts with the wind data from <code>result</code>. If <code>append</code> is <code>true</code>, previously
|
||||
* existing points in the chart are left unchanged. Otherwise, the existing wind series are replaced.
|
||||
*/
|
||||
public void updateStripChartSeries(WindInfoForRaceDTO result, boolean append) {
|
||||
public void updateChartSeries(WindInfoForRaceDTO result, boolean append) {
|
||||
final NumberFormat numberFormat = NumberFormat.getFormat("0");
|
||||
Long newMinTimepoint = timeOfEarliestRequestInMillis;
|
||||
Long newMaxTimepoint = timeOfLatestRequestInMillis;
|
||||
@@ -428,7 +432,7 @@ public class WindChart extends RaceChart implements Component<WindChartSettings>
|
||||
|
||||
/**
|
||||
* Sets the visibilities of the wind source series based on the new settings. Note that this does not
|
||||
* re-load any wind data. This has to happen by calling {@link #updateStripChartSeries(WindInfoForRaceDTO, boolean)}.
|
||||
* re-load any wind data. This has to happen by calling {@link #updateChartSeries(WindInfoForRaceDTO, boolean)}.
|
||||
*/
|
||||
@Override
|
||||
public void updateSettings(WindChartSettings newSettings) {
|
||||
@@ -473,7 +477,7 @@ public class WindChart extends RaceChart implements Component<WindChartSettings>
|
||||
@Override
|
||||
public void onSuccess(WindInfoForRaceDTO result) {
|
||||
if (result != null) {
|
||||
updateStripChartSeries(result, append);
|
||||
updateChartSeries(result, append);
|
||||
updateVisibleSeries();
|
||||
} else {
|
||||
if (!append) {
|
||||
|
||||
+37
-9
@@ -2,10 +2,13 @@ package com.sap.sailing.monitoring;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -41,13 +44,24 @@ public abstract class AbstractPortMonitor extends Thread {
|
||||
|
||||
this.endpoints = new Endpoint[prop_endpoints.length];
|
||||
for (int i=0; i<prop_endpoints.length;i++) {
|
||||
String[] data = prop_endpoints[i].split(":");
|
||||
|
||||
try {
|
||||
EndpointImpl e = new EndpointImpl(new InetSocketAddress(InetAddress.getByName(data[0].trim()), Integer.parseInt(data[1].trim())));
|
||||
this.endpoints[i] = e;
|
||||
} catch (Exception ex) {
|
||||
log.severe("Could not parse endpoint definition " + prop_endpoints[i]);
|
||||
if (prop_endpoints[i].trim().startsWith("http")) {
|
||||
try {
|
||||
URL url = new URL(prop_endpoints[i].trim());
|
||||
EndpointImpl e = new EndpointImpl(url);
|
||||
this.endpoints[i] = e;
|
||||
} catch (MalformedURLException ex) {
|
||||
log.severe("Could not parse endpoint definition " + prop_endpoints[i]);
|
||||
}
|
||||
} else {
|
||||
String[] data = prop_endpoints[i].split(":");
|
||||
|
||||
try {
|
||||
EndpointImpl e = new EndpointImpl(new InetSocketAddress(InetAddress.getByName(data[0].trim()), Integer.parseInt(data[1].trim())));
|
||||
this.endpoints[i] = e;
|
||||
} catch (Exception ex) {
|
||||
log.severe("Could not parse endpoint definition " + prop_endpoints[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,9 +91,23 @@ public abstract class AbstractPortMonitor extends Thread {
|
||||
for (int i = 0; i < endpoints.length; i++) {
|
||||
currentendpoint = endpoints[i];
|
||||
|
||||
Socket sn = new Socket();
|
||||
sn.connect(currentendpoint.getAddress(), timeout);
|
||||
sn.close();
|
||||
if (!currentendpoint.isURL()) {
|
||||
Socket sn = new Socket();
|
||||
sn.connect(currentendpoint.getAddress(), timeout);
|
||||
sn.close();
|
||||
} else {
|
||||
|
||||
/* despite its name this does NOT open a real TCP connection */
|
||||
HttpURLConnection conn = (HttpURLConnection)currentendpoint.getURL().openConnection();
|
||||
conn.setConnectTimeout(timeout);
|
||||
conn.setRequestMethod("GET");
|
||||
conn.connect();
|
||||
|
||||
int code = conn.getResponseCode();
|
||||
if (code != 200)
|
||||
throw new ConnectException("Could not successfully connect to endpoint " + currentendpoint.toString());
|
||||
|
||||
}
|
||||
|
||||
log.info("Connection succeeded to " + currentendpoint.toString());
|
||||
handleConnection(currentendpoint);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.monitoring;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Definition of an endpoint that submits to checks by
|
||||
@@ -12,10 +13,27 @@ import java.net.InetSocketAddress;
|
||||
*/
|
||||
public interface Endpoint {
|
||||
|
||||
/**
|
||||
* @return the address of this endpoint
|
||||
*/
|
||||
InetSocketAddress getAddress();
|
||||
|
||||
/**
|
||||
* @return the name of this endpoint. This information can be used
|
||||
* to reference other services.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return true if this endpoint represents an url
|
||||
*/
|
||||
boolean isURL();
|
||||
|
||||
/**
|
||||
* @return the associated URL or null if there is none
|
||||
*/
|
||||
URL getURL();
|
||||
|
||||
long lastSucceeded();
|
||||
|
||||
long lastFailed();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.monitoring;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URL;
|
||||
|
||||
|
||||
/**
|
||||
@@ -13,12 +14,22 @@ public class EndpointImpl implements Endpoint {
|
||||
|
||||
private InetSocketAddress address;
|
||||
private String name = "";
|
||||
private URL url;
|
||||
private boolean is_url = false;
|
||||
private long last_success = 0;
|
||||
private long last_fail = 0;
|
||||
private boolean already_checked = false;
|
||||
|
||||
public EndpointImpl(InetSocketAddress address) {
|
||||
this.address = address;
|
||||
this.is_url = false;
|
||||
this.url = null;
|
||||
}
|
||||
|
||||
public EndpointImpl(URL input) {
|
||||
this.address = null;
|
||||
this.is_url = true;
|
||||
this.url = input;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,7 +67,7 @@ public class EndpointImpl implements Endpoint {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getAddress().toString();
|
||||
return isURL() ? getURL().toString() : getAddress().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,4 +80,14 @@ public class EndpointImpl implements Endpoint {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isURL() {
|
||||
return is_url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getURL() {
|
||||
return url;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+18
-18
@@ -1,6 +1,5 @@
|
||||
package com.sap.sailing.monitoring;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -17,7 +16,7 @@ import org.osgi.framework.BundleException;
|
||||
|
||||
/**
|
||||
* This monitor tries to restart registered services
|
||||
* on failure. It also send out email to fixed recipients.
|
||||
* on failure. It also sends out email to fixed recipients.
|
||||
*
|
||||
* @author Simon Pamies (info@pamies.de)
|
||||
* @since Nov 26, 2012
|
||||
@@ -25,17 +24,10 @@ import org.osgi.framework.BundleException;
|
||||
public class OSGiRestartingPortMonitor extends AbstractPortMonitor {
|
||||
Logger log = Logger.getLogger(OSGiRestartingPortMonitor.class.getName());
|
||||
|
||||
HashMap<String, Bundle> bundles = new HashMap<String, Bundle>();
|
||||
|
||||
public OSGiRestartingPortMonitor(Properties properties) {
|
||||
super(properties);
|
||||
|
||||
/* store bundles so that we can reference them later without iterating every time */
|
||||
for (Bundle bundle : Activator.getContext().getBundles()) {
|
||||
bundles.put(bundle.getSymbolicName(), bundle);
|
||||
}
|
||||
|
||||
String[] prop_services = properties.getProperty("monitor.services").split(",");
|
||||
String[] prop_services = properties.getProperty("monitor.bundles").split(",");
|
||||
|
||||
for (int i=0; i<endpoints.length;i++) {
|
||||
endpoints[i].setName(prop_services[i].trim());
|
||||
@@ -44,7 +36,7 @@ public class OSGiRestartingPortMonitor extends AbstractPortMonitor {
|
||||
|
||||
@Override
|
||||
public void handleFailure(Endpoint endpoint) {
|
||||
Bundle bundle = bundles.get(endpoint.getName());
|
||||
Bundle bundle = getBundleByName(endpoint.getName());
|
||||
|
||||
if (bundle.getState() == BundleEvent.STARTED || bundle.getState() == BundleEvent.STOPPED) {
|
||||
try {
|
||||
@@ -63,13 +55,13 @@ public class OSGiRestartingPortMonitor extends AbstractPortMonitor {
|
||||
log.info("Bundle " + endpoint.getName() + " restarted");
|
||||
|
||||
/* only send mail if service has not failed before */
|
||||
if (!endpoint.hasFailed()) {
|
||||
if (!endpoint.hasFailed() /*before*/) {
|
||||
try {
|
||||
Session session = Session.getDefaultInstance(this.properties, new SMTPAuthenticator());
|
||||
MimeMessage msg = new MimeMessage(session);
|
||||
|
||||
msg.setSubject("Bundle " + endpoint.getName() + " restarted");
|
||||
msg.setContent("The Bundle " + endpoint.getName() + " has been restarted - port check on " + endpoint.getAddress().getPort() + " didn't respond!\n" +
|
||||
msg.setContent("The Bundle " + endpoint.getName() + " has been restarted - check on " + endpoint + " didn't respond!\n" +
|
||||
"This Mail won't be send again if service continues to fail.", "text/plain");
|
||||
msg.addRecipient(RecipientType.TO, new InternetAddress(this.properties.getProperty("mail.to")));
|
||||
|
||||
@@ -83,6 +75,19 @@ public class OSGiRestartingPortMonitor extends AbstractPortMonitor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleConnection(Endpoint endpoint) {
|
||||
}
|
||||
|
||||
protected Bundle getBundleByName(String name) {
|
||||
for (Bundle bundle : Activator.getContext().getBundles()) {
|
||||
if (bundle.getSymbolicName().equalsIgnoreCase(name))
|
||||
return bundle;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private class SMTPAuthenticator extends javax.mail.Authenticator {
|
||||
public PasswordAuthentication getPasswordAuthentication() {
|
||||
String username = properties.getProperty("mail.smtp.user");
|
||||
@@ -90,9 +95,4 @@ public class OSGiRestartingPortMonitor extends AbstractPortMonitor {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleConnection(Endpoint endpoint) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<div id='contentWrapper'>
|
||||
<!-- start keyVisual -->
|
||||
<div id='keyVisual'>
|
||||
<img alt='Sailer' src='../images/key-visual.png' />
|
||||
<img alt='Sailer' src='../images/ess40-key-visual.jpg' />
|
||||
<div id='infoBox'>
|
||||
<h1 id='pageHeadline'>Extreme Sailing Series 2012</h1>
|
||||
<p>
|
||||
@@ -43,11 +43,11 @@
|
||||
<div class='innerContent'>
|
||||
<h3 class='articleSubheadline'>6th - 9th December</h3>
|
||||
<div class='leaderBoardGroup'>
|
||||
<a class='btn-cta' href='http://ess40-2012.sapsailing.com/gwt/Leaderboard.html?name=Extreme%2040%20Rio&showRaceDetails=true'>
|
||||
<a class='btn-cta' href='http://ess40-2012.sapsailing.com/gwt/Leaderboard.html?name=Extreme%2040%20Rio&showRaceDetails=true&refreshIntervalMillis=10000'>
|
||||
<span>Live Rio Act Leaderboard</span>
|
||||
</a>
|
||||
<div class='clearer'></div>
|
||||
<a class='btn-cta' href='http://ess40-2012.sapsailing.com/gwt/Leaderboard.html?name=Extreme%20Sailing%20Series%202012%20Overall&showRaceDetails=true&displayName=Overall%20Standings&leaderboardGroupName=Extreme%20Sailing%20Series%202012&root=leaderboardGroupPanel'>
|
||||
<a class='btn-cta' href='http://ess40-2012.sapsailing.com/gwt/Leaderboard.html?name=Extreme%20Sailing%20Series%202012%20Overall&showRaceDetails=true&refreshIntervalMillis=10000&displayName=Overall%20Standings&leaderboardGroupName=Extreme%20Sailing%20Series%202012&root=leaderboardGroupPanel'>
|
||||
<span>Live Series Leaderboard</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
</p>
|
||||
</div>
|
||||
<div id='navigation'>
|
||||
<a class='navButton event' href='http://ess40-2012.sapsailing.com/gwt/Leaderboard.html?name=Extreme%2040%20Rio&showRaceDetails=true'>
|
||||
Live Rio Act Leaderboard
|
||||
<a class='navButton event' href='http://ess40-2012.sapsailing.com/gwt/Leaderboard.html?name=Extreme%2040%20Rio&refreshIntervalMillis=10000&lastN=3&raceDetail=DISPLAY_LEGS'>
|
||||
Live Rio Act Leaderboard
|
||||
</a>
|
||||
<a class='navButton overall' href='http://ess40-2012.sapsailing.com/gwt/Leaderboard.html?name=Extreme%20Sailing%20Series%202012%20Overall&showRaceDetails=true&displayName=Overall%20Standings&leaderboardGroupName=Extreme%20Sailing%20Series%202012&root=leaderboardGroupPanel'>
|
||||
<a class='navButton overall' href='http://ess40-2012.sapsailing.com/gwt/Leaderboard.html?name=Extreme%20Sailing%20Series%202012%20Overall&showRaceDetails=false&refreshIntervalMillis=10000&displayName=Overall%20Standings&leaderboardGroupName=Extreme%20Sailing%20Series%202012&root=leaderboardGroupPanel'>
|
||||
Live Series Leaderboard
|
||||
</a>
|
||||
</div>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 390 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
@@ -67,7 +67,7 @@ body {
|
||||
font-size: 12px;
|
||||
font-family: OpenSansRegular, Arial, Verdana, sans-serif;
|
||||
font-weight: normal;
|
||||
background-image: url(images/bg-image.jpg);
|
||||
background-image: url(images/ess40-bg-image.jpg);
|
||||
background-attachment: fixed;
|
||||
background-color: #222222;
|
||||
background-position: 50% 0%;
|
||||
|
||||
@@ -17,11 +17,19 @@ monitor.timeout = 2000
|
||||
# provided in milliseconds
|
||||
monitor.wait_after_failure = 60000
|
||||
|
||||
# endpoints that should be checked, separate by comma, each in the format host:port, e.g., test.something.com:80
|
||||
monitor.endpoints = 127.0.0.1:8888, 127.0.0.1:8889
|
||||
# endpoints that should be checked, separate by comma
|
||||
# two formats are valid, each yielding a different check
|
||||
# - address:port
|
||||
# This format leads to a simple port check. Use this if
|
||||
# you want to check if a server is still running (e.g. jetty)
|
||||
#
|
||||
# - http://domain_or_address/path/to/check
|
||||
# This format leads to a check that only succeeds if a status
|
||||
# code of 200 is returned.
|
||||
monitor.endpoints = http://127.0.0.1:8889/gwt/RaceBoard.html, http://127.0.0.1:8889/
|
||||
|
||||
# service name associated to endpoints
|
||||
monitor.services = com.sap.sailing.server, com.sap.sailing.server
|
||||
# bundle associated to endpoints
|
||||
monitor.bundles = com.sap.sailing.gwt.ui, com.sap.sailing.www
|
||||
|
||||
# mail configuration
|
||||
mail.from = info@sapsailing.com
|
||||
|
||||
Reference in New Issue
Block a user