1 added + 19 modified, total 20 files
java/trunk/record-util/src/main/java/org/hps/record
--- java/trunk/record-util/src/main/java/org/hps/record/AbstractRecordQueue.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/AbstractRecordQueue.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -66,26 +66,6 @@
public boolean supportsNext() {
return true;
}
-
- @Override
- public boolean supportsPrevious() {
- return false;
- }
-
- @Override
- public boolean supportsIndex() {
- return false;
- }
-
- @Override
- public boolean supportsShift() {
- return false;
- }
-
- @Override
- public boolean supportsRewind() {
- return false;
- }
@Override
public boolean hasCurrent() {
java/trunk/record-util/src/main/java/org/hps/record/composite
--- java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeLoop.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeLoop.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -313,6 +313,10 @@
// Set whether to stop on event processing errors.
setStopOnErrors(config.stopOnErrors);
+ // Set whether to stop on end run EVIO records.
+ if (evioAdapter != null)
+ evioAdapter.setStopOnEndRun(config.stopOnEndRun);
+
// Add EtEventProcessors to loop.
for (EtEventProcessor processor : config.etProcessors) {
etAdapter.addProcessor(processor);
@@ -329,7 +333,6 @@
}
// Add CompositeLoopAdapter which should execute last.
- //System.out.println("compositeLoop.addAdapter(compositeAdapter)");
addAdapter(compositeAdapter);
// Add CompositeRecordProcessors to loop.
java/trunk/record-util/src/main/java/org/hps/record/composite
--- java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeLoopConfiguration.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeLoopConfiguration.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -159,21 +159,41 @@
return this;
}
+ /**
+ * Add an {@link org.hps.record.et.EtEventProcessor} to the loop.
+ * @param processor The EtEventProcessor.
+ * @return This object.
+ */
public CompositeLoopConfiguration add(EtEventProcessor processor) {
etProcessors.add(processor);
return this;
}
-
+
+ /**
+ * Add an {@link org.hps.record.evio.EvioEventProcessor} to the loop.
+ * @param processor The EvioEventProcessor.
+ * @return This object.
+ */
public CompositeLoopConfiguration add(EvioEventProcessor processor) {
evioProcessors.add(processor);
return this;
}
+ /**
+ * Add an org.lcsim <code>Driver</code> to the loop.
+ * @param processor The Driver.
+ * @return This object.
+ */
public CompositeLoopConfiguration add(Driver processor) {
drivers.add(processor);
return this;
}
+ /**
+ * Add a {@link org.hps.record.composite.CompositeRecordProcessor} to the loop.
+ * @param processor The CompositeRecordProcessor.
+ * @return This object.
+ */
public CompositeLoopConfiguration add(CompositeRecordProcessor processor) {
compositeProcessors.add(processor);
return this;
java/trunk/record-util/src/main/java/org/hps/record/composite
--- java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeRecord.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeRecord.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -19,42 +19,82 @@
int sequenceNumber = -1;
int eventNumber = -1;
+ /**
+ * Set the sequence number of this record.
+ * @param sequenceNumber The sequence number.
+ */
public void setSequenceNumber(int sequenceNumber) {
this.sequenceNumber = sequenceNumber;
}
+ /**
+ * Set the event number of this record e.g. from EVIO or LCIO.
+ * @param eventNumber The event number of this recrod.
+ */
public void setEventNumber(int eventNumber) {
this.eventNumber = eventNumber;
}
+ /**
+ * Set a reference to an <code>EtEvent</code>.
+ * @param etEvent The EtEvent.
+ */
public void setEtEvent(EtEvent etEvent) {
this.etEvent = etEvent;
}
+ /**
+ * Set a reference to an <code>EvioEvent</code>.
+ * @param evioEvent The EvioEvent.
+ */
public void setEvioEvent(EvioEvent evioEvent) {
this.evioEvent = evioEvent;
}
+ /**
+ * Set a reference to an org.lcsim LCIO event (EventHeader).
+ * @param lcioEvent The LCIO EventHeader.
+ */
public void setLcioEvent(EventHeader lcioEvent) {
this.lcioEvent = lcioEvent;
}
+ /**
+ * Get the <code>EtEvent</code>.
+ * @return The EtEvent.
+ */
public EtEvent getEtEvent() {
return etEvent;
}
+ /**
+ * Get the <code>EvioEvent</code>.
+ * @return The EvioEvent.
+ */
public EvioEvent getEvioEvent() {
return evioEvent;
}
+ /**
+ * Get the org.lcsim event.
+ * @return The org.lcsim event.
+ */
public EventHeader getLcioEvent() {
return lcioEvent;
}
+ /**
+ * Get the event sequence number.
+ * @return The event sequence number.
+ */
public int getSequenceNumber() {
return sequenceNumber;
}
+ /**
+ * Get the event number.
+ * @return The event number.
+ */
public int getEventNumber() {
return eventNumber;
}
java/trunk/record-util/src/main/java/org/hps/record/composite
--- java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeRecordSource.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeRecordSource.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -6,65 +6,49 @@
import org.freehep.record.source.NoSuchRecordException;
/**
- * A record source providing <code>CompositeRecord</code> objects.
+ * A record source providing <code>CompositeRecord</code> objects
+ * that can be accessed and/or modified by <code>RecordListener</code>
+ * objects on the loop. This is essentially a minimal implementation
+ * that does not support advanced operations like rewind or index.
*/
public final class CompositeRecordSource extends AbstractRecordSource {
CompositeRecord currentRecord;
int sequenceNumber = 1;
+ /**
+ * Load the next record which is then accessible using {@link #getCurrentRecord()}.
+ */
public void next() throws IOException, NoSuchRecordException {
- //System.out.println("CompositeSource.next");
- //System.out.println(" record #" + sequenceNumber);
- //System.out.flush();
currentRecord = new CompositeRecord();
currentRecord.setSequenceNumber(sequenceNumber);
++sequenceNumber;
}
+ /**
+ * Get the current {@link CompositeRecord}.
+ * @return The current CompositeRecord.
+ */
@Override
public Object getCurrentRecord() throws IOException {
return currentRecord;
}
+ /**
+ * Get whether this source supports the next command (true).
+ * @return Whether this source supports the next command.
+ */
@Override
- public boolean supportsCurrent() {
- return true;
- }
-
- @Override
public boolean supportsNext() {
return true;
}
-
+
+ /**
+ * Get whether this source has a current record.
+ * @return Whether this source has a current record.
+ */
@Override
- public boolean supportsPrevious() {
- return false;
- }
-
- @Override
- public boolean supportsIndex() {
- return false;
- }
-
- @Override
- public boolean supportsShift() {
- return false;
- }
-
- @Override
- public boolean supportsRewind() {
- return false;
- }
-
- @Override
public boolean hasCurrent() {
return currentRecord != null;
}
-
- @Override
- public boolean hasNext() {
- // FIXME: Not sure about this one.
- return true;
- }
}
java/trunk/record-util/src/main/java/org/hps/record/composite
--- java/trunk/record-util/src/main/java/org/hps/record/composite/EtEventAdapter.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/EtEventAdapter.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -15,10 +15,20 @@
EtEventSource source;
+ /**
+ * Constructor with an {@link org.hps.record.et.EtEventSource}
+ * that supplies <code>EtEvent</code> records through a network
+ * ET server.
+ * @param source The event source.
+ */
public EtEventAdapter(EtEventSource source) {
this.source = source;
}
+ /**
+ * Process one record which will get the next <code>EtEvent</code>
+ * from the source and set a reference to it on the {@link CompositeRecord}.
+ */
public void recordSupplied(RecordEvent record) {
CompositeRecord compositeRecord = (CompositeRecord) record.getRecord();
try {
java/trunk/record-util/src/main/java/org/hps/record/composite
--- java/trunk/record-util/src/main/java/org/hps/record/composite/EventProcessingThread.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/EventProcessingThread.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -7,11 +7,18 @@
CompositeLoop loop;
+ /**
+ * Constructor requiring the loop object.
+ * @param loop The loop object.
+ */
public EventProcessingThread(CompositeLoop loop) {
super("EventProcessingThread");
this.loop = loop;
}
+ /**
+ * Run this thread, which will process records until the loop is done.
+ */
@Override
public void run() {
java/trunk/record-util/src/main/java/org/hps/record/composite
--- java/trunk/record-util/src/main/java/org/hps/record/composite/EvioEventAdapter.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/EvioEventAdapter.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -23,20 +23,33 @@
AbstractRecordSource source;
boolean stopOnEndRun = true;
+ /**
+ * Constructor that takes a record source.
+ * @param source The record source.
+ */
public EvioEventAdapter(AbstractRecordSource source) {
this.source = source;
}
+ /**
+ * No argument constructor for when ET will be converted to EVIO.
+ */
public EvioEventAdapter() {
}
+ /**
+ * Set whether to stop when end run records are received.
+ * @param stopOnEndRun True to stop on end run EVIO records.
+ */
public void setStopOnEndRun(boolean stopOnEndRun) {
this.stopOnEndRun = stopOnEndRun;
}
+ /**
+ * Process one record which will create an <code>EvioEvent</code> or
+ * get it from the source and set a reference to it on the {@link CompositeRecord}.
+ */
public void recordSupplied(RecordEvent record) {
- //System.out.println("CompositeEvioAdapter.recordSupplied");
- //System.out.flush();
CompositeRecord compositeRecord = (CompositeRecord) record.getRecord();
try {
EvioEvent evioEvent;
java/trunk/record-util/src/main/java/org/hps/record/composite
--- java/trunk/record-util/src/main/java/org/hps/record/composite/LcioEventAdapter.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/LcioEventAdapter.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -25,30 +25,50 @@
LCSimEventBuilder builder;
AbstractRecordSource source;
+ /**
+ * Constructor taking a record source which should supply
+ * LCSim LCIO events.
+ * @param source
+ */
public LcioEventAdapter(AbstractRecordSource source) {
this.source = source;
drivers = new DriverAdapter(top);
}
+ /**
+ * No argument constructor in which case the {@link CompositeRecord}
+ * should supply <code>EvioEvent</code> objects for the builder.
+ */
public LcioEventAdapter() {
drivers = new DriverAdapter(top);
}
+ /**
+ * Add an LCSim <code>Driver</code>
+ * @param driver The Driver to add.
+ */
public void addDriver(Driver driver) {
top.add(driver);
}
+ /**
+ * Set the <code>LCSimEventBuilder</code> that will convert
+ * from EVIO to LCIO events.
+ * @param builder
+ */
public void setLCSimEventBuilder(LCSimEventBuilder builder) {
this.builder = builder;
}
+ /**
+ * Process a {@link CompositeRecord} which will add an LCSim event
+ * and activate registered <code>Driver</code> objects.
+ */
public void recordSupplied(RecordEvent record) {
- //System.out.println("CompositeLcioAdapter.recordSupplied");
- System.out.flush();
CompositeRecord compositeRecord = (CompositeRecord) record.getRecord();
EventHeader lcioEvent = null;
try {
- // Is there an EVIO event?
+ // Is there an EVIO event to use for the conversion to LCIO?
if (compositeRecord.getEvioEvent() != null) {
// Create the EVIO event.
EvioEvent evioEvent = compositeRecord.getEvioEvent();
@@ -61,7 +81,7 @@
return;
}
} else {
- // Try to use an event source to get the next LCIO event.
+ // Try to use the event source to get the next LCIO event.
source.next();
lcioEvent = (EventHeader) source.getCurrentRecord();
}
@@ -70,20 +90,33 @@
RecordEvent recordEvent = new RecordEvent(null, lcioEvent);
drivers.recordSupplied(recordEvent);
+ // Set the reference to the LCIO event on the CompositeRecord.
compositeRecord.setLcioEvent(lcioEvent);
} catch (IOException | NoSuchRecordException e) {
throw new RecordProcessingException("Error creating LCIO event.", e);
}
}
+ /**
+ * Activates the <code>endOfData</code> method on the registered
+ * <code>Driver</code> objects.
+ */
public void finish(LoopEvent loopEvent) {
drivers.finish(loopEvent);
}
+ /**
+ * Activates the <code>startOfData</code> method on registered
+ * <code>Driver</code> objects.
+ */
public void start(LoopEvent loopEvent) {
drivers.start(loopEvent);
}
+ /**
+ * Activates the <code>suspend</code> method on registered
+ * <code>Driver</code> objects.
+ */
public void suspend(LoopEvent loopEvent) {
drivers.suspend(loopEvent);
}
java/trunk/record-util/src/main/java/org/hps/record/composite
--- java/trunk/record-util/src/main/java/org/hps/record/composite/MaxRecordsProcessor.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/MaxRecordsProcessor.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -7,20 +7,28 @@
* A @{link CompositeProcessor} for throwing an error when the
* maximum number of records is reached or exceeded.
*/
+// FIXME: This should be done different by using directly the loop and adapter.
public class MaxRecordsProcessor extends CompositeRecordProcessor {
int maxRecords;
int recordsReceived;
-
+
+ /**
+ * Constructor with the maximum number of records.
+ * @param maxRecords The maximum number of records.
+ */
public MaxRecordsProcessor(int maxRecords) {
this.maxRecords = maxRecords;
}
+ /**
+ * Process a record and check if max number of records was reached.
+ */
public void process(CompositeRecord record) {
if (recordsReceived >= maxRecords)
throw new RecordProcessingException(
"Maximum number of records received.",
new MaxRecordsException("Maximum number of records received.", maxRecords));
++recordsReceived;
- }
+ }
}
java/trunk/record-util/src/main/java/org/hps/record/composite
--- java/trunk/record-util/src/main/java/org/hps/record/composite/RecordProcessorAdapter.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/RecordProcessorAdapter.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -7,30 +7,58 @@
import org.hps.record.RecordProcessingException;
import org.hps.record.RecordProcessor;
+/**
+ * An extension of {@link CompositeLoopAdapter} that has a list of {@link org.hps.record.RecordProcessor}
+ * objects that are activated in the appropriate hook methods.
+ * @param <RecordType> The concrete type of the record being processed.
+ */
public abstract class RecordProcessorAdapter<RecordType> extends CompositeLoopAdapter {
List<RecordProcessor<RecordType>> processors = new ArrayList<RecordProcessor<RecordType>>();
+ /**
+ * Add a <code>RecordProcessor</code>.
+ * @param processor The RecordProcessor to add.
+ */
public void addProcessor(RecordProcessor<RecordType> processor) {
processors.add(processor);
}
+ /**
+ * Remove a <code>RecordProcessor</code>.
+ * @param processor The RecordProcessor to remove.
+ */
public void removeProcessor(RecordProcessor<RecordType> processor) {
processors.remove(processor);
}
+ /**
+ * Activate the <code>startRun</code> methods of the
+ * registered processors.
+ * @param record The current record.
+ */
public void startRun(RecordType record) {
for (RecordProcessor<RecordType> processor : processors) {
processor.startRun(record);
}
}
+ /**
+ * Activate the <code>endRun</code> methods of the
+ * registered processors.
+ * @param record The current record.
+ */
public void endRun(RecordType record) {
for (RecordProcessor<RecordType> processor : processors) {
processor.endRun(record);
}
}
+ /**
+ * Activate the <code>process</code> methods of the
+ * registered processors.
+ * @param record The current record.
+ */
public void process(RecordType record) {
for (RecordProcessor<RecordType> processor : processors) {
try {
@@ -41,18 +69,33 @@
}
}
+ /**
+ * Activate the <code>endJob</code> methods of the
+ * registered processors.
+ * @param The LoopEvent which activated finish.
+ */
public void finish(LoopEvent loopEvent) {
for (RecordProcessor<RecordType> processor : processors) {
processor.endJob();
}
}
+ /**
+ * Activate the <code>startJob</code> methods of the
+ * registered processors.
+ * @param The LoopEvent which activated the start.
+ */
public void start(LoopEvent loopEvent) {
for (RecordProcessor<RecordType> processor : processors) {
processor.startJob();
}
}
+ /**
+ * Activate the <code>suspend</code> methods of the
+ * registered processors.
+ * @param The LoopEvent which activated the suspend.
+ */
public void suspend(LoopEvent loopEvent) {
for (RecordProcessor<RecordType> processor : processors) {
processor.suspend();
java/trunk/record-util/src/main/java/org/hps/record/enums
--- java/trunk/record-util/src/main/java/org/hps/record/enums/DataSourceType.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/enums/DataSourceType.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -11,14 +11,27 @@
String description;
+ /**
+ * Constructor which takes a description.
+ * @param description The description of the data source type.
+ */
private DataSourceType(String description) {
this.description = description;
}
+ /**
+ * Get the description of the data source type.
+ * @return The description of the data source type.
+ */
public String description() {
return description;
}
+ /**
+ * True if the source is file-based
+ * (e.g. not an ET server).
+ * @return
+ */
public boolean isFile() {
return this.ordinal() > ET_SERVER.ordinal();
}
java/trunk/record-util/src/main/java/org/hps/record/enums
--- java/trunk/record-util/src/main/java/org/hps/record/enums/ProcessingStage.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/enums/ProcessingStage.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -1,7 +1,13 @@
package org.hps.record.enums;
/**
-* Processing stages to execute.
+* When set this can be used to limit the number
+* of processing stages that are excecuted by the
+* {@link org.hps.record.composite.CompositeLoop}.
+* For example, if the <code>ProcessingStage</code>
+* is set to <code>EVIO</code> then the <code>ET</code>
+* and <code>EVIO</code> adapters will be activated
+* but LCIO events will not be created or processed.
*/
public enum ProcessingStage {
ET,
java/trunk/record-util/src/main/java/org/hps/record/et
--- java/trunk/record-util/src/main/java/org/hps/record/et/EtConnection.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/et/EtConnection.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -22,7 +22,9 @@
import org.jlab.coda.et.exception.EtWakeUpException;
/**
- * Create an EtSystem and EtAttachment from ConnectionParameters.
+ * A class for encapsulating the connection information
+ * for an ET client including the EtSystem and EtAttachment
+ * objects.
*/
public final class EtConnection {
@@ -35,13 +37,13 @@
int chunkSize;
/**
- * Class constructor.
+ * A class constructor for internal convenience.
* @param param The connection parameters.
* @param sys The ET system.
* @param att The ET attachment.
* @param stat The ET station.
*/
- public EtConnection(
+ private EtConnection(
EtSystem sys,
EtAttachment att,
EtStation stat,
@@ -98,10 +100,12 @@
}
/**
- * Read EtEvent objects from the ET ring.
+ * Read EtEvent objects from the ET server.
+ *
* Preserve all specific Exception types in the throws clause so caller
* may implement their own error and state handling.
- * @return
+ *
+ * @return The array of EtEvents.
* @throws IOException
* @throws EtException
* @throws EtDeadException
java/trunk/record-util/src/main/java/org/hps/record/et
--- java/trunk/record-util/src/main/java/org/hps/record/et/EtEventQueue.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/et/EtEventQueue.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -10,6 +10,10 @@
*/
public final class EtEventQueue extends AbstractRecordQueue<EtEvent> {
+ /**
+ * Get the class of the record that is supplied.
+ * @return The class of the supplied records.
+ */
@Override
public Class<EtEvent> getRecordClass() {
return EtEvent.class;
java/trunk/record-util/src/main/java/org/hps/record/et
--- java/trunk/record-util/src/main/java/org/hps/record/et/EtEventSource.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/et/EtEventSource.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -11,7 +11,7 @@
/**
* Implement a loop record source supplying <tt>EtEvent</tt> objects
- * from an ET ring server connection.
+ * from an ET server connection.
*/
public final class EtEventSource extends AbstractRecordSource {
@@ -19,55 +19,49 @@
EtEvent currentRecord;
Queue<EtEvent> eventQueue = new LinkedBlockingQueue<EtEvent>();
+ /**
+ * Constructor that requires the connection parameters.
+ * @param connection The EtConnection that should have a valid set of ET
+ * connection parameters.
+ */
public EtEventSource(EtConnection connection) {
this.connection = connection;
}
+ /**
+ * Get the current record.
+ * @return The current record.
+ */
@Override
public Object getCurrentRecord() throws IOException {
return currentRecord;
}
+ /**
+ * True because this source supports the <code>next</code> method.
+ * @return True because this source supports next.
+ */
@Override
- public boolean supportsCurrent() {
- return true;
- }
-
- @Override
public boolean supportsNext() {
return true;
}
+ /**
+ * True if the current record is non-null.
+ * @return True if current record is non-null.
+ */
@Override
- public boolean supportsPrevious() {
- return false;
- }
-
- @Override
- public boolean supportsIndex() {
- return false;
- }
-
- @Override
- public boolean supportsShift() {
- return false;
- }
-
- @Override
- public boolean supportsRewind() {
- return false;
- }
-
- @Override
public boolean hasCurrent() {
return currentRecord != null;
}
-
- @Override
- public boolean hasNext() {
- return true;
- }
+ /**
+ * Load the next <code>EtEvent</code> which will either read
+ * a cached record from the queue or fetch more records from
+ * the ET server if the queue is empty.
+ * @throws NoSuchRecordException if the queue is empty and getting
+ * more records from the ET server fails.
+ */
@Override
public void next() throws IOException, NoSuchRecordException {
@@ -84,12 +78,20 @@
}
}
+ /**
+ * Get the number of records which is the size of the current queue.
+ * @return The size of the queue.
+ */
@Override
public long size() {
return this.eventQueue.size();
}
- void readEtEvents() throws IOException {
+ /**
+ * Read the next <code>EtEvent</code> array from the ET server.
+ * @throws IOException if reading events fails.
+ */
+ private void readEtEvents() throws IOException {
try {
EtEvent[] mevs = connection.readEtEvents();
eventQueue.addAll(Arrays.asList(mevs));
@@ -98,6 +100,10 @@
}
}
+ /**
+ * An error that is used to indicate an error in the ET system
+ * for the error handling of the loop.
+ */
public static class EtSourceException extends IOException {
public EtSourceException(String message, Exception cause) {
super(message, cause);
java/trunk/record-util/src/main/java/org/hps/record/evio
--- java/trunk/record-util/src/main/java/org/hps/record/evio/EvioEventQueue.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/EvioEventQueue.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -8,6 +8,10 @@
*/
public final class EvioEventQueue extends AbstractRecordQueue<EvioEvent> {
+ /**
+ * Get the class of the supplied records.
+ * @return The class of the supplied records.
+ */
@Override
public Class<EvioEvent> getRecordClass() {
return EvioEvent.class;
java/trunk/record-util/src/main/java/org/hps/record/evio
--- java/trunk/record-util/src/main/java/org/hps/record/evio/EvioFileProducer.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/EvioFileProducer.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -19,8 +19,9 @@
import org.jlab.coda.jevio.EvioReader;
/**
+ * A utility class for streaming an EVIO file to an ET server.
*
- * This is copied and modified from the EvioProducer class in the ET 12.0 CODA module.
+ * NOTE: Original version was copied from the CODA group's ET java module.
*/
// TODO: Add option to set number of events in the put array.
public final class EvioFileProducer {
@@ -38,6 +39,9 @@
EvioFileProducer() {
}
+ /**
+ * Print usage statement.
+ */
private static void usage() {
System.out.println("\nUsage: java Producer -f <et name> -e <evio file> [-p <server port>] [-host <host>]"
+ " [-d <delay in millisec>] [-g <group #>]\n\n"
@@ -51,14 +55,26 @@
System.exit(1);
}
+ /**
+ * Copy byte buffer to an <code>EtEvent</code>.
+ * @param event The target EtEvent.
+ */
public void copyToEtEvent(EtEvent event) {
event.getDataBuffer().put(byteBuffer);
}
+ /**
+ * The externally accessible main method.
+ * @param args The command line arguments.
+ */
public static void main(String[] args) {
(new EvioFileProducer()).doMain(args); // call wrapper method
}
+ /**
+ * Wrapper method called in main.
+ * @param args The command line arguments.
+ */
public void doMain(String[] args) {
try {
for (int i = 0; i < args.length; i++) {
java/trunk/record-util/src/main/java/org/hps/record/evio
--- java/trunk/record-util/src/main/java/org/hps/record/evio/EvioFileSource.java 2014-09-05 21:01:44 UTC (rev 955)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/EvioFileSource.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -12,9 +12,10 @@
import org.jlab.coda.jevio.EvioReader;
/**
- * A very basic implementation of <tt>AbstractRecordSource</tt> for supplying <tt>EvioEvent</tt>
- * objects to a loop from EVIO files. Unlike the LCIO record source, it has no rewind or
- * indexing capabilities (for now at least).
+ * A basic implementation of an <tt>AbstractRecordSource</tt> for supplying <tt>EvioEvent</tt>
+ * objects to a loop from EVIO files.
+ *
+ * Unlike the LCIO record source, it has no rewind or indexing capabilities.
*/
public final class EvioFileSource extends AbstractRecordSource {
@@ -24,16 +25,28 @@
int fileIndex = 0;
boolean atEnd;
+ /**
+ * Constructor taking a list of EVIO files.
+ * @param files The list of EVIO files.
+ */
public EvioFileSource(List<File> files) {
this.files.addAll(files);
openReader();
}
+ /**
+ * Constructor taking a single EVIO file.
+ * @param file The EVIO file.
+ */
public EvioFileSource(File file) {
this.files.add(file);
openReader();
}
+ /**
+ * Open the EVIO reader on the current file from the list.
+ * @throws RuntimeException if an EvioException or IOException occurs while opening file.
+ */
private void openReader() {
try {
System.out.println("Opening reader for file " + files.get(fileIndex) + " ...");
@@ -44,6 +57,9 @@
}
}
+ /**
+ * Close the current reader.
+ */
private void closeReader() {
try {
reader.close();
@@ -52,15 +68,28 @@
}
}
+ /**
+ * Get the current record which is an <code>EvioEvent</code>.
+ * @return The current record.s
+ */
@Override
public Object getCurrentRecord() throws IOException {
return currentEvent;
}
+ /**
+ * True if there are no more files to open in the list.
+ * @return True if there are no more files in the list.
+ */
boolean endOfFiles() {
return fileIndex > (files.size() - 1);
}
+ /**
+ * Load the next record.
+ * @throws NoSuchRecordException if source is exhausted.
+ * @throws IOException if there is an error creating the next EvioEvent.
+ */
@Override
public void next() throws IOException, NoSuchRecordException {
for (;;) {
@@ -83,42 +112,29 @@
return;
}
}
-
+
+ /**
+ * True because source supports loading next record.
+ * @return True because source supports loading next record.
+ */
@Override
- public boolean supportsCurrent() {
- return true;
- }
-
- @Override
public boolean supportsNext() {
return true;
}
+ /**
+ * True if there is a current record loaded.
+ * @return True if there is a current record loaded.
+ */
@Override
- public boolean supportsPrevious() {
- return false;
- }
-
- @Override
- public boolean supportsIndex() {
- return false;
- }
-
- @Override
- public boolean supportsShift() {
- return false;
- }
-
- @Override
- public boolean supportsRewind() {
- return false;
- }
-
- @Override
public boolean hasCurrent() {
return currentEvent != null;
}
+ /**
+ * True if there are more records to load.
+ * @return True if there are more records to load.
+ */
@Override
public boolean hasNext() {
return !atEnd;
java/trunk/record-util/src/main/java/org/hps/record
--- java/trunk/record-util/src/main/java/org/hps/record/package-info.java (rev 0)
+++ java/trunk/record-util/src/main/java/org/hps/record/package-info.java 2014-09-05 21:23:19 UTC (rev 956)
@@ -0,0 +1,18 @@
+/**
+ * The package <code>org.hps.record</code> and its sub-packages use the
+ * <a href="http://java.freehep.org/freehep-record/">FreeHep Record</a> module
+ * to implement a flexible record processing backend. Its current primary
+ * usage is providing the record processing chain for the HPS Monitoring Application,
+ * but it can be used stand-alone outside of that framework.
+ *
+ * The primary class for user interaction is the {@link org.hps.record.composite.CompositeLoop}
+ * class which implements a record loop that can convert <code>EtEvent</code> objects
+ * to <code>EvioEvent</code> objects and then finally build LCSim event, or <code>EventHeader</event>
+ * objects from the EVIO, using a series of adapter classes on the loop. The loop implementation
+ * is flexible so that it may be configured to use an ET server, an EVIO file or an LCIO file for
+ * the record source. The {@link org.hps.record.composite.CompositeLoopConfiguration} class should be
+ * used to configure the loop by the user.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+package org.hps.record;
\ No newline at end of file
SVNspam 0.1