Package edu.sc.seis.seisFile.datalink
Class DataLink
java.lang.Object
edu.sc.seis.seisFile.datalink.DataLink
Implements the DataLink protocol, defined at:
https://earthscope.github.io/libdali/datalink-protocol.html
Philip Crotwell
University of South Carolina, 2019
http://www.seis.sc.edu
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final int
static final int
static final String
static final int
static final String
static final String
static final String
static final String
static final String
static final int
static final String
static final int
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
ConstructorsConstructorDescriptionDataLink()
default of IRIS DMCuses the default port of 18000Open DataLink socket connectionOpen DataLink socket connection -
Method Summary
Modifier and TypeMethodDescriptionboolean
true if there is enough data in the instream to possibly read a data record.int
awaitDLCommand
(String command, String dataString) void
close()
Send end and close connection.byte[]
encodeDLCommand
(String command, String dataString) encodes command with optional data section as a string.void
int
getHost()
int
getPort()
boolean
boolean
void
Read a packet.void
Would be really nice to keep state and reconnect plus backfill, but...void
void
sendDLCommand
(String command, String dataString) Sends a DL Command and awaits the response, either OK or ERROR.void
sendId()
void
setVerbose
(boolean verbose) void
setVerboseWriter
(PrintWriter verboseWriter) void
stream()
void
-
Field Details
-
IRIS_HOST
- See Also:
-
IRIS_PORT
public static final int IRIS_PORT- See Also:
-
EEYORE_HOST
- See Also:
-
EEYORE_PORT
public static final int EEYORE_PORT- See Also:
-
DEFAULT_HOST
- See Also:
-
DEFAULT_PORT
public static final int DEFAULT_PORT- See Also:
-
DEFAULT_TIMEOUT_SECOND
public static final int DEFAULT_TIMEOUT_SECOND- See Also:
-
DATALINK_PROTOCOL
- See Also:
-
QUERY_MODE
- See Also:
-
STREAM_MODE
- See Also:
-
MAX_PROC_NUM
public static final int MAX_PROC_NUM- See Also:
-
USER_BROWSER
- See Also:
-
ID
- See Also:
-
OK
- See Also:
-
ERROR
- See Also:
-
INFO
- See Also:
-
MATCH
- See Also:
-
REJECT
- See Also:
-
PACKET
- See Also:
-
STREAM
- See Also:
-
ENDSTREAM
- See Also:
-
MSEED_TYPE
- See Also:
-
-
Constructor Details
-
DataLink
default of IRIS DMC- Throws:
DataLinkException
- if unable to connect
-
DataLink
uses the default port of 18000- Parameters:
host
- host to connect to- Throws:
DataLinkException
- if unable to connect
-
DataLink
Open DataLink socket connection- Parameters:
host
- host to connect toport
- port to connect to- Throws:
DataLinkException
- if unable to connect
-
DataLink
Open DataLink socket connection- Parameters:
host
- host to connect toport
- port to connect totimeoutSeconds
- timeout value- Throws:
DataLinkException
- if unable to connect
-
DataLink
public DataLink(String host, int port, int timeoutSeconds, boolean verbose) throws DataLinkException - Throws:
DataLinkException
-
-
Method Details
-
readPacket
Read a packet. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.- Returns:
- packet if available.
- Throws:
IOException
- if an I/O Exception occurs.DataLinkException
- if not connected- See Also:
-
stream
- Throws:
DataLinkException
-
endStream
- Throws:
DataLinkException
-
match
- Throws:
DataLinkException
-
reject
- Throws:
DataLinkException
-
available
true if there is enough data in the instream to possibly read a data record. This should not block, unlike hasNext() and next().- Returns:
- true if enough data to read a record
- Throws:
IOException
- if input stream throws
-
availableBytes
- Returns:
- available() from the underlying InputStream, in bytes
- Throws:
IOException
- from underlying input stream
-
close
public void close()Send end and close connection. -
isConnected
public boolean isConnected()- Returns:
- true is connected
-
reconnect
Would be really nice to keep state and reconnect plus backfill, but...- Throws:
DataLinkException
- if error with datalink protocol
-
encodeDLCommand
encodes command with optional data section as a string. This works for client generated commands but not for a PACKET, which would have binary data. PACKET is what client receives, but usually never sends if it does not generate data.- Parameters:
command
- command to senddataString
- optional data- Throws:
DataLinkException
- if command is too long
-
sendDLCommand
Sends a DL Command and awaits the response, either OK or ERROR.- Parameters:
command
- command to senddataString
- optional associated data- Throws:
DataLinkException
- if error sending or with response
-
awaitDLCommand
- Throws:
DataLinkException
-
sendId
- Throws:
DataLinkException
-
verbose
-
isVerbose
public boolean isVerbose() -
setVerbose
public void setVerbose(boolean verbose) -
getVerboseWriter
-
setVerboseWriter
-
getHost
-
getPort
public int getPort() -
getServerId
-
getClientIdNum
public int getClientIdNum() -
getUsername
-