Storage servlet upgrade + fixes

This commit is contained in:
Alexander Nozik 2016-10-01 23:13:16 +03:00
parent 1da1d628c2
commit 0490b8c8d6
5 changed files with 31 additions and 27 deletions

View File

@ -47,6 +47,7 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.ParseException;
import java.time.Duration;
import java.time.Instant;
import java.util.Collection;
import java.util.ResourceBundle;
@ -156,6 +157,8 @@ public class PKT8MainViewController implements Initializable, DeviceListener, Me
*/
private synchronized void setupPlotFrame(Meta plotFrameMeta) {
plottables = new TimePlottableGroup();
plottables.setMaxItems(plotFrameMeta.getInt("maxItems",3000));
plottables.setMaxAge(Duration.parse(plotFrameMeta.getString("maxAge","PT2H")));
plotArea.getChildren().clear();
plotFrame = new JFreeChartFrame(plotFrameMeta);
PlotUtils.setXAxis(plotFrame, "timestamp", null, "time");

View File

@ -25,7 +25,7 @@
coefs="[23.894, -358.42, 2355.2, -7509.8, 12893.0, -10454.0, 3403.9]"/>
<!-- Plot configuration -->
<plotConfig>
<plotConfig maxItems="5000">
<eachPlot thickness="3"/>
</plotConfig>
</device>

View File

@ -15,12 +15,16 @@
*/
package inr.numass.scripts
import hep.dataforge.storage.filestorage.FileStorage
import hep.dataforge.storage.filestorage.VFSUtils
import inr.numass.server.NumassServer
import inr.numass.storage.NumassStorage
import org.apache.commons.vfs2.FileObject
String path = "D:\\temp\\test\\numass-server\\"
FileStorage storage = FileStorage.in(new File(path), null);
FileObject file = VFSUtils.getLocalFile(new File(path))
NumassStorage storage = new NumassStorage(file,null)
println "Starting test numass listener in "+path

View File

@ -25,17 +25,17 @@ import hep.dataforge.storage.commons.LoaderFactory;
import hep.dataforge.storage.commons.StorageManager;
import hep.dataforge.storage.filestorage.FileStorage;
import inr.numass.storage.NumassStorage;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ratpack.handling.Chain;
import ratpack.server.BaseDir;
import ratpack.server.RatpackServer;
import ratpack.server.RatpackServerSpec;
import ratpack.server.ServerConfigBuilder;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
/**
*
* @author darksnake
@ -83,7 +83,7 @@ public class NumassServer extends AbstractNetworkListener {
int port = meta().getInt("ratpack.port", 8336);
ratpack = RatpackServer.start((RatpackServerSpec server) -> server
.serverConfig((ServerConfigBuilder config) -> config
.baseDir(BaseDir.find())
.findBaseDir()
.address(InetAddress.getLocalHost())
.port(port))
.handlers((Chain chain) -> chain

View File

@ -7,28 +7,25 @@ package inr.numass.server;
import freemarker.template.Template;
import hep.dataforge.exceptions.StorageException;
import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.storage.api.ObjectLoader;
import hep.dataforge.storage.api.PointLoader;
import hep.dataforge.storage.api.Storage;
import hep.dataforge.storage.servlet.StorageRatpackHandler;
import hep.dataforge.storage.servlet.Utils;
import org.slf4j.LoggerFactory;
import ratpack.handling.Context;
import java.io.StringWriter;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.slf4j.LoggerFactory;
import ratpack.handling.Context;
/**
*
* @author Alexander Nozik
*/
public class NumassStorageHandler extends StorageRatpackHandler {
@ -69,20 +66,20 @@ public class NumassStorageHandler extends StorageRatpackHandler {
}
@Override
protected String pointLoaderPlotOptions(PointLoader loader) {
protected MetaBuilder pointLoaderPlotOptions(PointLoader loader) {
MetaBuilder builder = super.pointLoaderPlotOptions(loader);
if (loader.getName().contains("msp") || loader.getName().contains("vac")) {
return " legend: { \n"
+ " position: 'bottom' \n"
+ " },\n"
+ " title: '" + loader.getName() + "',\n"
+ " vAxis:{\n"
+ " logScale: true\n"
+ " }";
} else {
return super.pointLoaderPlotOptions(loader);
builder.putValue("legend.position", "bottom");
builder.putValue("title", "\"" + loader.getName() + "\"");
builder.putNode(new MetaBuilder("vAxis")
.putValue("logScale", true)
.putValue("format", "scientific")
);
}
return builder;
}
private String render(NumassNote note) {
return String.format("<strong id=\"%s\">%s</strong> %s", note.ref(), formatter.format(note.time()), note.content());
}
@ -94,7 +91,7 @@ public class NumassStorageHandler extends StorageRatpackHandler {
*/
@SuppressWarnings("unchecked")
private Stream<NumassNote> getNotes(ObjectLoader noteLoader) {
return noteLoader.fragmentNames().stream().<NumassNote>map(new Function<String, NumassNote>() {
return noteLoader.fragmentNames().stream().map(new Function<String, NumassNote>() {
@Override
public NumassNote apply(String name) {
try {