CTlib
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CTlib.CThttp_base Class Reference

Abstract base class which extends CTwriter to support HTTP PUT. More...

Inheritance diagram for CTlib.CThttp_base:
CTlib.CTwriter CTlib.CThttp CTlib.CThttp_HttpClient

Public Member Functions

 CThttp_base (String baseCTOutputFolderI, int numBlocksPerSegmentI, bool bOutputTimesAreMillisI, bool bPackI, bool bZipI, String ctWebHostI)
 Constructor. More...
 
void login (String userI, String pwI)
 Create user credential for all subsequent HTTP PUT operations using the given username and password. More...
 
override void close ()
 Close the source.
 
- Public Member Functions inherited from CTlib.CTwriter
 CTwriter (String baseCTOutputFolderI, int numBlocksPerSegmentI, int numSegmentsToKeepI, bool bOutputTimesAreMillisI, bool bPackI, bool bZipI, bool bDeleteOldDataAtStartupI, bool bVerifyOutputFolderI=true)
 Constructor. More...
 
String getBaseCTOutputFolder ()
 Get baseCTOutputFolder. More...
 
void UseTmpFileForZipData (bool bUseTmpZipFilesI)
 If writing output ZIP files, should we write data first to a temporary file (".tmp") and then rename this to the final ".zip" file? If false, we write directly to the output ZIP file using (what is intended to be) a quick stream operation; this has the possible advantage that an extra intermediary ".tmp" file isn't created temporarily. More...
 
void putData (string[] channamesI, double[] dataI)
 Store an additional double data point in each of the specified channels. More...
 
void putData (string[] channamesI, float[] dataI)
 Store an additional single-precision float data point in each of the specified channels. More...
 
void putData (string channameI, String dataI)
 Store a new string in the given channel. More...
 
void putData (string channameI, double dataI)
 Store a double-precision float data value for the given channel. More...
 
void putData (string channameI, float dataI)
 Store a single-precision float data value for the given channel. More...
 
void putData (string channameI, long dataI)
 Store a long integer data value for the given channel. More...
 
void putData (string channameI, int dataI)
 Store an integer data value for the given channel. More...
 
void putData (string channameI, short dataI)
 Store a short integer data value for the given channel. More...
 
void putData (string channameI, char dataI)
 Store a character data value for the given channel. More...
 
void putData (string channameI, byte[] dataI)
 Store binary data array for the given channel. More...
 
long setTime ()
 Set time for subsequent putData(). This method simply calls setTime(<current_time_millis>). More...
 
void setTime (long timeI)
 Set time for subsequent putData(). To switch back to automatic timestamp mode, call this method with the argument equal to -1. More...
 
void setTime (double timeI)
 Set time for subsequent putData(). To switch back to automatic timestamp mode, call this method with the argument equal to -1.0. More...
 
void setAsync (bool bAsyncI)
 Specify whether flushes should be executed asynchronously. More...
 
void flush ()
 Write out all data that has been queued up for this block.
 

Protected Member Functions

override void writeToStream (String outputDirI, String chanNameI, byte[] dataI)
 Low-level method to write data to the channel using HTTP PUT. More...
 

Protected Attributes

String ctWebHost = ""
 The web host data will be PUT to; for example, "http://localhost:8000" More...
 
NetworkCredential credential = null
 Username/password credentials for logging into the server. More...
 
bool bCredentialsChanged = false
 Flag to indicate that username/password credentials have changed. More...
 
String urlStr = ""
 The URL used for HTTP PUT. More...
 

Detailed Description

Abstract base class which extends CTwriter to support HTTP PUT.

CThttp_base

The .NET Framework offers 3 methods of supporting HTTP:

  1. HttpWebRequest: lower level API; the original method in .NET
  2. WebClient: simpler API, built on top of HttpWebRequest; used in CThttp
  3. HttpClient: newer API, requires .NET 4.5; used in CThttp_HttpClient; has the advantage that I/O calls are asynchronous; see https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=netframework-4.7.1 Articles comparing these methods: http://www.diogonunes.com/blog/webclient-vs-httpclient-vs-httpwebrequest/ https://www.infoworld.com/article/3198673/web-development/my-two-cents-on-webclient-vs-httpclient-vs-httpwebrequest.html https://stackoverflow.com/questions/5140674/how-to-make-a-http-put-request

Constructor & Destructor Documentation

◆ CThttp_base()

CTlib.CThttp_base.CThttp_base ( String  baseCTOutputFolderI,
int  numBlocksPerSegmentI,
bool  bOutputTimesAreMillisI,
bool  bPackI,
bool  bZipI,
String  ctWebHostI 
)
inline

Constructor.

Calls the constructor in the base class. Note that the following values are hard-wired when we call the base CTwriter constructor: numSegmentsToKeepI = 0, indicating to keep all segments bDeleteOldDataAtStartupI = false bVerifyOutputFolderI = false

Parameters
baseCTOutputFolderIThe output source name along with optional additional sub-directory layers. Should be a relative folder path, since the absolute location where data will be written is determined by the HTTP server.
numBlocksPerSegmentINumber of blocks per segment in the source folder hierarchy. Use 0 to not include a segment layer.
bOutputTimesAreMillisIOutput times should be in milliseconds? Needed if blocks are written (i.e., flush() is called) at a rate greater than 1Hz.
bPackIPack data at the block folder level? Packed data times are linearly interpolated from the block start time to the time of the final datapoint in the packed channel.
bZipIZIP data at the block folder level?
ctWebHostIThe web host data will be PUT to.

Member Function Documentation

◆ login()

void CTlib.CThttp_base.login ( String  userI,
String  pwI 
)
inline

Create user credential for all subsequent HTTP PUT operations using the given username and password.

Parameters
userIUsername
pwIPassword

◆ writeToStream()

override void CTlib.CThttp_base.writeToStream ( String  outputDirI,
String  chanNameI,
byte []  dataI 
)
inlineprotectedvirtual

Low-level method to write data to the channel using HTTP PUT.

Parameters
outputDirIWhere the given data should be put on the server.
chanNameIChannel name.
dataIThe data to PUT.

Reimplemented from CTlib.CTwriter.

Reimplemented in CTlib.CThttp_HttpClient.

Member Data Documentation

◆ bCredentialsChanged

bool CTlib.CThttp_base.bCredentialsChanged = false
protected

Flag to indicate that username/password credentials have changed.

◆ credential

NetworkCredential CTlib.CThttp_base.credential = null
protected

Username/password credentials for logging into the server.

◆ ctWebHost

String CTlib.CThttp_base.ctWebHost = ""
protected

The web host data will be PUT to; for example, "http://localhost:8000"

◆ urlStr

String CTlib.CThttp_base.urlStr = ""
protected

The URL used for HTTP PUT.


The documentation for this class was generated from the following file: