Resolved Groovy dependencies for numass-storage

This commit is contained in:
Alexander Nozik 2016-11-12 18:11:17 +03:00
parent 6982e97396
commit 5e5ffee64e
4 changed files with 52 additions and 34 deletions

View File

@ -6,17 +6,6 @@ if (!hasProperty('mainClass')) {
mainClassName = mainClass mainClassName = mainClass
task runClient(type: JavaExec) {
description 'Start numass client locally'
// Set main property to name of Groovy script class.
main = 'inr.numass.scripts.TestClient'
// Set classpath for running the Groovy script.
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
}
dependencies { dependencies {
compile project(':numass-storage') compile project(':numass-storage')
compile 'commons-cli:commons-cli:1.3.1' compile 'commons-cli:commons-cli:1.3.1'

View File

@ -1,15 +1,6 @@
description = 'dataforge-server' description = 'dataforge-server'
task runServer(type: JavaExec) {
description 'Start numass server locally'
// Set main property to name of Groovy script class.
main = 'inr.numass.scripts.TestServer'
// Set classpath for running the Groovy script.
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
}
processResources { processResources {
from project(':dataforge-storage:storage-servlet').file('/src/main/resources/ratpack') from project(':dataforge-storage:storage-servlet').file('/src/main/resources/ratpack')

View File

@ -19,7 +19,6 @@ import hep.dataforge.context.GlobalContext;
import hep.dataforge.data.binary.Binary; import hep.dataforge.data.binary.Binary;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import hep.dataforge.io.ColumnedDataReader; import hep.dataforge.io.ColumnedDataReader;
import hep.dataforge.io.envelopes.DefaultEnvelopeReader;
import hep.dataforge.io.envelopes.Envelope; import hep.dataforge.io.envelopes.Envelope;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
@ -36,7 +35,6 @@ import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
@ -180,14 +178,14 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
} }
} }
private static Envelope readStream(InputStream stream) { // private static Envelope readStream(InputStream stream) {
try { // try {
return new DefaultEnvelopeReader().read(stream); // return new DefaultEnvelopeReader().read(stream);
} catch (IOException ex) { // } catch (IOException ex) {
LoggerFactory.getLogger(NumassDataLoader.class).warn("Can't read a fragment from numass zip or directory", ex); // LoggerFactory.getLogger(NumassDataLoader.class).warn("Can't read a fragment from numass zip or directory", ex);
return null; // return null;
} // }
} // }
/** /**
* Read numass point from envelope and apply transformation (e.g. debuncing) * Read numass point from envelope and apply transformation (e.g. debuncing)
@ -196,7 +194,16 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
* @param transformation * @param transformation
* @return * @return
*/ */
public NMPoint readPoint(Envelope envelope, Function<RawNMPoint, NMPoint> transformation) { private NMPoint readPoint(Envelope envelope, Function<RawNMPoint, NMPoint> transformation) {
return transformation.apply(readRawPoint(envelope));
}
/**
* Read raw point. Requires a low of memory.
* @param envelope
* @return
*/
private RawNMPoint readRawPoint(Envelope envelope) {
List<NMEvent> events = new ArrayList<>(); List<NMEvent> events = new ArrayList<>();
ByteBuffer buffer; ByteBuffer buffer;
try { try {
@ -235,12 +242,10 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
if (!segmented && events.size() > MAX_EVENTS_PER_POINT) { if (!segmented && events.size() > MAX_EVENTS_PER_POINT) {
pointTime = events.get(events.size() - 1).getTime() - events.get(0).getTime(); pointTime = events.get(events.size() - 1).getTime() - events.get(0).getTime();
} }
RawNMPoint raw = new RawNMPoint(u, u, return new RawNMPoint(u, u,
events, events,
pointTime, pointTime,
readTime(envelope.meta())); readTime(envelope.meta()));
return transformation.apply(raw);
} }
/** /**
@ -300,6 +305,10 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
return this.getPoints().stream().parallel().map(env -> readPoint(env)).collect(Collectors.toList()); return this.getPoints().stream().parallel().map(env -> readPoint(env)).collect(Collectors.toList());
} }
public List<RawNMPoint> getRawPoints() {
return this.getPoints().stream().parallel().map(env -> readRawPoint(env)).collect(Collectors.toList());
}
private List<Envelope> getPoints() { private List<Envelope> getPoints() {
return getItems().entrySet().stream() return getItems().entrySet().stream()
.filter(entry -> entry.getKey().startsWith(POINT_FRAGMENT_NAME) && entry.getValue() != null) .filter(entry -> entry.getKey().startsWith(POINT_FRAGMENT_NAME) && entry.getValue() != null)

View File

@ -0,0 +1,29 @@
description = "Test module for numass client and server"
task runServer(type: JavaExec) {
description 'Start numass server locally'
// Set main property to name of Groovy script class.
main = 'inr.numass.scripts.TestServer'
// Set classpath for running the Groovy script.
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
}
task runClient(type: JavaExec) {
description 'Start numass client locally'
// Set main property to name of Groovy script class.
main = 'inr.numass.scripts.TestClient'
// Set classpath for running the Groovy script.
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
}
dependencies {
compile project(':numass-storage:numass-client')
compile project(':numass-storage:numass-server')
compile project(':dataforge-grind')
}