its.app
Class SddAutoExtractReceiver

java.lang.Object
  extended byits.backbone.frame.ItsFrameReceiver
      extended byits.backbone.sdd.SddReceiver
          extended byits.app.SddAutoExtractReceiver
All Implemented Interfaces:
java.lang.Runnable

public class SddAutoExtractReceiver
extends SddReceiver

A sample SDD Receiver that saves incoming SDD information to files on disk. This class demonstrates how to create an SddReceiver object and receive the events it generates. There is also an example of how to handle exceptions thrown within the SddReceiver.

This receiver displays a graphical interface that allows the user to set options about the files it creates. If the default options are accepted, the receiver will create files for the incoming schema, contents, extractor, raw data, and extracted data. If the "Produce SQL data files" option is checked, the extracted data file will be structured as a series of SQL INSERT statements. By default, the arrival of new data causes the previously received extracted data file to be overwritten. If the "Append Data files" option is chosen instead, the receiver will continuously append new data to the existing file.

If both the "Append" option and the "Produce Blob data files" are chosen, the receiver will produce a raw data log file. This file will contain a listing of all the blobs that have been appended into the raw data file. This listing includes the blob's date of creation, size, and its offset within the appended file.

Users who would like to view specific sensor outputs can either make modifications to this code, or parse the desired sensors out of the text data files.

The current implemenation of the receiver does not queue up data events. If, during the course of the extraction process thread, a data event is received, it will be dropped, though users running on faster machines (or with jits) should not see this problem with the current SDD data streams.


Field Summary
 
Fields inherited from class its.backbone.frame.ItsFrameReceiver
ignoreStreamTimeout
 
Constructor Summary
SddAutoExtractReceiver(java.lang.String host, int port)
          constructor initializes the Automagical sdd receiver
SddAutoExtractReceiver(java.lang.String host, int port, boolean makeschema, boolean makecontents, boolean makeextractor, boolean makeblob, boolean makeextracteddata, boolean makesqldata, boolean append)
          constructor initializes the Auto Extract sdd receiver
 
Method Summary
 void contentsReceived(Contents contents, java.lang.String serialNum)
          Method for contents received, takes the contents and overwrites the contents file.
 void dataReceived(byte[] data, java.lang.String serialNum)
          Method for data received, takes the blob data and overwrites the blob file.
 void extractedDataReceived(java.util.Hashtable ht, java.lang.String serialNum)
          evokes the expander thread (if it isn't busy) and overwrites (or appends to) the expanded data file.
 void extractorReceived(byte[] extractor, java.lang.String serialNum)
          Method for receiving the extractor portion of the sdd data flow.
static void main(java.lang.String[] args)
           
 void schemaReceived(Schema schema, java.lang.String serialNum)
          Method for schema received, takes the schema and overwrites the schema file.
 java.lang.String toSQLBuffer(java.lang.String tablename, ContentsData cd)
          Creates a SQL INSERT INTO statement for each row in this ContentsData object.
 java.lang.String toTextBuffer(ContentsData cd)
          Creates a text representation of the data values on all rows
 
Methods inherited from class its.backbone.sdd.SddReceiver
frameReceived, getContentsSerialNumber, getSchemaSerialNumber
 
Methods inherited from class its.backbone.frame.ItsFrameReceiver
getFrameQueue, getInputBuffer, run, start, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SddAutoExtractReceiver

public SddAutoExtractReceiver(java.lang.String host,
                              int port)
                       throws java.lang.IllegalArgumentException,
                              java.io.IOException
constructor initializes the Automagical sdd receiver

Parameters:
host - the sdd data source host name
port - the sdd data host's port number
Throws:
java.lang.IllegalArgumentException - thrown if host is null or port < 0
java.io.IOException

SddAutoExtractReceiver

public SddAutoExtractReceiver(java.lang.String host,
                              int port,
                              boolean makeschema,
                              boolean makecontents,
                              boolean makeextractor,
                              boolean makeblob,
                              boolean makeextracteddata,
                              boolean makesqldata,
                              boolean append)
                       throws java.lang.IllegalArgumentException,
                              java.io.IOException
constructor initializes the Auto Extract sdd receiver

Parameters:
host - the sdd data source host name
port - the sdd data host's port number
makeschema - make schema flag
makecontents - make contents flag
makeextractor - make extractor flag
makeblob - make blob flag
makeextracteddata - make extracted data flag
makesqldata - make sql data flag
append - append or overwrite flag (overwrites if false)
Throws:
java.lang.IllegalArgumentException - thrown if host is null or port < 0
java.io.IOException
Method Detail

schemaReceived

public void schemaReceived(Schema schema,
                           java.lang.String serialNum)
Method for schema received, takes the schema and overwrites the schema file. Creates a schema object, which represents the schema of the sdd data flow.

Overrides:
schemaReceived in class SddReceiver
Throws:
java.lang.IllegalArgumentException - thrown if null event

contentsReceived

public void contentsReceived(Contents contents,
                             java.lang.String serialNum)
Method for contents received, takes the contents and overwrites the contents file. Creates a contents object.

Overrides:
contentsReceived in class SddReceiver
Throws:
java.lang.IllegalArgumentException - thrown if null event

dataReceived

public void dataReceived(byte[] data,
                         java.lang.String serialNum)
Method for data received, takes the blob data and overwrites the blob file.

Overrides:
dataReceived in class SddReceiver
Throws:
java.lang.IllegalArgumentException - thrown if null event

extractedDataReceived

public void extractedDataReceived(java.util.Hashtable ht,
                                  java.lang.String serialNum)
evokes the expander thread (if it isn't busy) and overwrites (or appends to) the expanded data file. This may result in unexpanded blobs depending on how fast the receiving machine is...

Overrides:
extractedDataReceived in class SddReceiver
Throws:
java.lang.IllegalArgumentException - thrown if null event

toTextBuffer

public java.lang.String toTextBuffer(ContentsData cd)
Creates a text representation of the data values on all rows


toSQLBuffer

public java.lang.String toSQLBuffer(java.lang.String tablename,
                                    ContentsData cd)
Creates a SQL INSERT INTO statement for each row in this ContentsData object.


extractorReceived

public void extractorReceived(byte[] extractor,
                              java.lang.String serialNum)
Method for receiving the extractor portion of the sdd data flow. The extractor is a compressed jar file with the classes needed to expand the blob data into its expanded form.

Overrides:
extractorReceived in class SddReceiver
Throws:
java.lang.IllegalArgumentException - thrown if event is null or empty

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        BadTypeException
Throws:
java.io.IOException
BadTypeException