7 Commits
Author SHA1 Message Date
handte 36b5fc7957 Release 1.0.14.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-14 23:37:49 +01:00
handte 8aa383a002 Prevent ejb and war tests to run in parallel.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Add locking to ensure that ejb and war tests are serialized.
Revert changes to arquillian ports since they are useless.
2021-02-14 23:24:56 +01:00
handte 1d3c8335c7 Reduce build duration by running tasks in parallel.
LocationBasedServices/mowesta/pipeline/head There was a failure building this commit
Allow gradle to execute build tasks in parallel.
Change ejb test ports to enable simultaneous execution with war tests.
2021-02-14 21:59:16 +01:00
handte aeee482128 Fix angular elements component styles.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-14 21:18:26 +01:00
handte 6bf3663c81 Add missing cors rules for resources.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-14 20:52:03 +01:00
handte 48519aefa5 Properly handle bitmaps during import.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-14 20:24:47 +01:00
handte 0d05a03f6e Update to 1.0.14-SNAPSHOT.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-14 18:53:33 +01:00
12 changed files with 169 additions and 85 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ android {
applicationId "com.mowesta.android.app"
minSdkVersion 19
targetSdkVersion 29
versionCode 13
versionCode 14
versionName "${version}"
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+35 -1
View File
@@ -1,3 +1,6 @@
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.locks.ReentrantLock
apply plugin: 'maven-publish'
buildscript {
@@ -21,7 +24,7 @@ allprojects {
// set version for our project
group = 'com.mowesta'
version = '1.0.13'
version = '1.0.14'
// set versions for our libraries
ext {
@@ -145,3 +148,34 @@ subprojects {
tasks.register("generatePomFileForMavenPublication") { }
tasks.register("build") { }
// aquire locks to ensure that service-ejb and service-war are not running tests in parallel
def lock = new ReentrantLock()
def available = lock.newCondition()
def busy = new AtomicBoolean()
def serializedTasks = []
def sequentialProjects = [ 'service-ejb', 'service-war' ]
gradle.taskGraph.beforeTask {
if (it.name == 'test' && it.project.name in sequentialProjects) {
serializedTasks << it
it.doFirst {
lock.lock()
while (busy.get()) {
available.await()
}
busy.set(true)
lock.unlock()
}
}
}
gradle.taskGraph.afterTask {
if (it in serializedTasks) {
lock.lock()
busy.set(false)
available.signal()
lock.unlock()
}
}
+2 -1
View File
@@ -1,3 +1,4 @@
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx4g
org.gradle.jvmargs=-Xmx4g
org.gradle.parallel=true
@@ -780,8 +780,7 @@ public class NumericPrediction {
for (int i = 0, s = (int) decoder.getSize(); i < s; i++) {
boolean valid = decoder.hasNext();
double value = decoder.readNext();
if (valid)
result.setValue(current++, value);
if (valid) result.setValue(current++, value);
}
return result;
} finally {
@@ -11,7 +11,7 @@ import com.mowesta.data.grib2.template.data.SimpleData;
*
* @author Marcus
*/
public class SimpleDataDecoder implements StreamDecoder {
public class SimpleDataDecoder {
/**
* The data stream.
@@ -88,7 +88,12 @@ public class SimpleDataDecoder implements StreamDecoder {
return bitmap.hasNext();
}
@Override
/**
* Reads the next grid value.
*
* @return The next value for the grid.
* @throws IOException Thrown if something fails.
*/
public double readNext() throws IOException {
boolean next = bitmap.hasNext();
bitmap.moveNext();
@@ -0,0 +1,36 @@
package com.mowesta.data.grib2.decoder;
import java.io.IOException;
/**
* A stream decoder that provides a streaming interface
* for a simple decoder.
*
* @author Marcus
*/
public class SimpleStreamDecoder implements StreamDecoder {
/**
* The simple decoder.
*/
private SimpleDataDecoder decoder;
/**
* Creates a new stream decoder from the simple decoder.
*
* @param decoder The decoder.
*/
public SimpleStreamDecoder(SimpleDataDecoder decoder) {
this.decoder = decoder;
}
@Override
public double readNext() throws IOException {
while (! decoder.hasNext()) {
decoder.readNext();
}
return decoder.readNext();
}
}
@@ -18,4 +18,5 @@ public interface StreamDecoder {
*/
double readNext() throws IOException;
}
@@ -25,10 +25,10 @@ import javax.inject.Inject;
import org.infinispan.Cache;
import com.mowesta.api.Coordinate;
import com.mowesta.api.weather.WeatherSource;
import com.mowesta.api.weather.SoilType;
import com.mowesta.api.weather.WeatherCondition;
import com.mowesta.api.weather.WeatherForecast;
import com.mowesta.api.weather.WeatherSource;
import com.mowesta.api.weather.WeatherType;
import com.mowesta.api.weather.WindDirection;
import com.mowesta.data.dwd.NumericPrediction;
@@ -37,6 +37,7 @@ import com.mowesta.data.dwd.NumericPrediction.Variable;
import com.mowesta.data.grib2.Grib2Data;
import com.mowesta.data.grib2.Grib2File;
import com.mowesta.data.grib2.decoder.SimpleDataDecoder;
import com.mowesta.data.grib2.decoder.SimpleStreamDecoder;
import com.mowesta.data.process.conversion.KelvinCelsiusConversion;
import com.mowesta.data.process.source.Grib2MixedSource;
import com.mowesta.data.process.source.IDataSource;
@@ -46,33 +47,33 @@ import com.mowesta.service.session.InfinispanSessionBean.MetadataType;
/**
* A bean to synchronize the weather forecasts.
*
*
* @author Marcus
*/
@Stateless
public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
/**
* The class with the metadata about the imported forecast.
*
*
* @author Marcus
*/
public static class ForecastMetadata extends Metadata {
/**
* The serialization version.
*/
private static final long serialVersionUID = -624323280988785919L;
/**
* The timestamps hashed by weather source.
*/
private Map<WeatherSource, Time> times = new HashMap<>();
/**
* Returns the time for the source that has been imported.
*
*
* @param source The source to check.
* @return The time for the source.
*/
@@ -81,20 +82,20 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
if (l == null) return new Time(0, 0, 0);
return l;
}
/**
* Sets the time for the source.
*
*
* @param source The source.
* @param time The time that has been imported.
*/
public void setTime(WeatherSource source, Time time) {
times.put(source, time);
}
/**
* Custom deserializer for times.
*
*
* @param ois The input stream.
* @throws IOException Thrown by the stream.
* @throws ClassNotFoundException Never thrown.
@@ -110,10 +111,10 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
times.put(v[i], new Time(year, month, day));
}
}
/**
* Custom serializer for times.
*
*
* @param oos The output stream.
* @throws IOException Thrown by the stream.
*/
@@ -126,18 +127,18 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
oos.writeInt(t.month);
oos.writeInt(t.day);
}
}
}
}
/**
* The chunk size for batch processing. Larger sizes
* will result in faster processing but will also require
* more memory.
*/
private static final int CHUNK_SIZE = 8000;
/**
* The maximum hour to import during testing.
*/
@@ -157,7 +158,7 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
/**
* Updates the prediction for the current time.
*
*
* @param first A flag to indicate whether this is the first execution.
* @throws Exception Thrown if something fails.
*/
@@ -169,10 +170,10 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
Time time = new Time(c.get(Calendar.YEAR), c.get(Calendar.MONTH) + 1, c.get(Calendar.DAY_OF_MONTH));
syncForecasts(first, time);
}
/**
* Updates the prediction for the specified time.
*
*
* @param first A flag to indicate whether this is the first execcution.
* @param time The time to load from the server.
* @throws Exception Thrown if something fails.
@@ -206,12 +207,12 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
}
}
}
/**
* Checks whether the first entry in the infinispan cache for the
* weather source is available. This checks basically whether the
* cache has been deleted externally without deleting the metadata.
*
*
* @param source The source.
* @return The data.
*/
@@ -219,11 +220,11 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
Long id = WeatherForecastContainer.getId(source, 0);
return infinispanSession.getDataCache().get(id) != null;
}
/**
* Downloads the data for the prediction and returns whether
* something has changed.
*
*
* @param time The time.
* @param prediction The prediction.
* @return True if there was one download.
@@ -250,10 +251,10 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
log.log(Level.INFO, "Ftp sync results are " + counters[0] + " downloaded, " + counters[1] + " maintained and " + counters[2] + " deleted.");
return counters[0] > 0;
}
/**
* Prepares the import of all data from the prediction.
*
* Prepares the import of all data from the prediction.
*
* @param prediction The prediction.
* @param source The source for nice debug output.
* @param time The time.
@@ -265,7 +266,7 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
log.log(Level.INFO, "Preparing data import for " + source + ".");
long startTime = System.currentTimeMillis();
DoubleArray longitudes = prediction.getLongitues(time);
DoubleArray latitudes = prediction.getLatitudes(time);
DoubleArray latitudes = prediction.getLatitudes(time);
int counter = 0;
Set<Integer> hours = new HashSet<>();
for (Variable v: prediction.getVariables()) {
@@ -282,9 +283,9 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
Grib2Data data = grib2.nextData();
hours.add(hour);
SimpleDataDecoder decoder = new SimpleDataDecoder(data);
IDataSource ds = new Grib2MixedSource(longitudes, latitudes, decoder);
IDataSource ds = new Grib2MixedSource(longitudes, latitudes, new SimpleStreamDecoder(decoder));
prepareData(v, hour, ds);
counter += 1;
counter += 1;
} finally {
grib2.close();
}
@@ -298,7 +299,7 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
/**
* Adds the data in chunks to the temporary cache.
*
*
* @param variable The variable.
* @param hour The hour.
* @param source The source.
@@ -321,12 +322,12 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
cache.put(getKey(variable, hour, counter), data);
counter += 1;
}
log.log(Level.FINE, "Finished preparation of variable " + variable.name() + " for hour " + hour + ".");
log.log(Level.FINE, "Finished preparation of variable " + variable.name() + " for hour " + hour + ".");
}
/**
* Imports the data after it has been prepared.
*
*
* @param prediction The prediction to read.
* @param time The time to read.
* @param source The source.
@@ -337,7 +338,7 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
private void importData(NumericPrediction prediction, WeatherSource source, Time time, Set<Integer> hours) throws IOException {
// approximately 45 minutes for ICON_GLOBAL, 30GB cache size (only global)
DoubleArray longitudes = prediction.getLongitues(time);
DoubleArray latitudes = prediction.getLatitudes(time);
DoubleArray latitudes = prediction.getLatitudes(time);
DoubleArray plcov = prediction.getValues(prediction.getFile(Variable.PLCOV, time));
DoubleArray hsurf = prediction.getValues(prediction.getFile(Variable.HSURF, time));
DoubleArray soiltyp = prediction.getValues(prediction.getFile(Variable.SOILTYP, time));
@@ -383,7 +384,7 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
/**
* Creates the weather condition at the specified index for the specified hour.
*
*
* @param prediction The prediction.
* @param source The source of the condition.
* @param index The index.
@@ -414,16 +415,16 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
/**
* Returns the temperature value in centigrade.
*
*
* @param value The temperature in kelvin.
*/
private double getTemperature(double value) {
return new KelvinCelsiusConversion().convert(value);
}
/**
* Returns the wind speed in meter per second.
*
*
* @param u The u wind.
* @param v The v wind.
* @return The wind speed.
@@ -431,20 +432,20 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
private double getWindSpeed(double u, double v) {
return Math.sqrt(Math.pow(u, 2) + Math.pow(v, 2));
}
/**
* Converts the pressure value from pa to hpa.
*
*
* @param pa The pressure value in pa.
* @return The pressure value in hpa.
*/
private double getPressure(double pa) {
return pa / 100.0;
}
/**
* Returns the wind direction.
*
*
* @param u The u wind.
* @param v The v wind.
* @return The wind direction.
@@ -455,11 +456,11 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
int angle = ((int) Math.round(Math.atan2(v, u) * 8d / Math.PI) * -1 + 10) % 8;
return WindDirection.getByCode(angle);
}
/**
* Returns the value for the variable at the index.
*
*
* @param variable The variable.
* @param hour The hour.
* @param chunk The chunk.
@@ -472,18 +473,18 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
if (value == null) {
String key = getKey(variable, hour, chunk);
//log.log(Level.INFO, "Loading from infinispan cache " + key + ".");
value = (double[])infinispanSession.getTempCache().get(key);
value = infinispanSession.getTempCache().get(key);
//log.log(Level.INFO, "Loaded from infinispan cache " + key + ".");
memcache.addData(variable, chunk, hour, value);
}
return value[index];
}
/**
* Returns the key for a particular chunk.
*
*
* @param variable The variable.
* @param hour The hour.
* @param chunk The 0-based chunk index.
@@ -492,19 +493,19 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
private String getKey(Variable variable, int hour, int chunk) {
return variable.name() + "-" + hour + "-" + chunk;
}
/**
* An implementation of a memory cache that should be significantly
* faster than running generated string keys with java's hashmap.
*
*
* @author Marcus
*/
private static class MemoryCache {
/**
* An entry for data by variable.
*
*
* @author Marcus
*/
private static class VariableEntry {
@@ -514,7 +515,7 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
private List<ChunkEntry> entries = new ArrayList<>(1);
/**
* Returns the entry for the chunk.
*
*
* @param chunk The chunk.
* @return The entry or null.
*/
@@ -524,12 +525,12 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
if (e.chunck == chunk) return e;
}
return null;
}
}
}
/**
* An entry for data by chunk.
*
*
* @author Marcus
*/
private static class ChunkEntry {
@@ -543,7 +544,7 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
private Map<Integer, double[]> entries = new HashMap<>(MAX_HOUR);
/**
* Returns the entry for the hour.
*
*
* @param hour The hour.
* @return The entry or null.
*/
@@ -551,15 +552,15 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
return entries.get(Integer.valueOf(hour));
}
}
/**
* The variables.
*/
private VariableEntry[] variables = new VariableEntry[Variable.values().length];
/**
* Adds a data item to the local cache.
*
*
* @param v The vector.
* @param chunk The chunk.
* @param hour The hour.
@@ -577,12 +578,12 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
ce.chunck = chunk;
ve.entries.add(ce);
}
ce.entries.put(Integer.valueOf(hour), data);
ce.entries.put(Integer.valueOf(hour), data);
}
/**
* Returns a data item from the cache.
*
*
* @param v The variable.
* @param chunk The chunk.
* @param hour The hour.
@@ -595,7 +596,7 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
if (ce == null) return null;
else return ce.getHour(hour);
}
/**
* Removes all data from the cache.
*/
@@ -603,9 +604,9 @@ public class WeatherForecastSyncSessionBean extends AbstractSyncSessionBean {
for (int i = variables.length - 1; i >= 0; i--) variables[i] = null;
}
}
}
+3 -3
View File
@@ -28,7 +28,7 @@ task cleanup(type: Delete) {
task ngBuildApp(type: IoNodeTask) {
script = file('node_modules/@angular/cli/bin/ng')
args = ['build', '--prod']
args = ['build', '--prod', '--source-map=false']
inputDir = project.file('./src/')
outputDir = project.file('./build/outputs/mowesta-app/')
}
@@ -41,7 +41,7 @@ task buildApp(type: Copy) {
task ngBuildForecast(type: IoNodeTask) {
script = file('node_modules/@angular/cli/bin/ng')
args = ['build', '--prod', 'mowesta-forecast']
args = ['build', '--prod', '--source-map=false', 'mowesta-forecast']
inputDir = project.file('./src/')
outputDir = project.file('./build/outputs/mowesta-forecast/')
}
@@ -55,7 +55,7 @@ task buildForecast(type: IoNodeTask) {
task ngBuildSearch(type: IoNodeTask) {
script = file('node_modules/@angular/cli/bin/ng')
args = ['build', '--prod', 'mowesta-search']
args = ['build', '--prod', '--source-map=false', 'mowesta-search']
inputDir = project.file('./src/')
outputDir = project.file('./build/outputs/mowesta-search/')
}
@@ -1,3 +1,5 @@
@import "../../styles.scss";
$mws-accent-color: #f9a825;
div { padding: 0; }
@@ -1,3 +1,5 @@
@import "../../styles.scss";
div.element-container {
display: inline-flex;
padding: 0;
@@ -68,7 +68,10 @@ public class AngularRouterServlet extends HttpServlet {
* The path name segments of public files
*/
public static final String[] PUBLIC_FILES = new String[] {
"app/mowesta-forecast", "app/mowesta-search"
"mowesta-forecast", "mowesta-search", // scripts
".eot", ".ttf", ".woff", ".woff2", // fonts
".svg", ".png", ".jpg", // images
".txt" // text files
};
/**