com.devexperts.qd.qtp.file
Class FileConnector

java.lang.Object
  extended by com.devexperts.qd.qtp.AbstractMessageConnector
      extended by com.devexperts.qd.qtp.file.FileConnector
All Implemented Interfaces:
FileConnectorMBean, MessageConnector, MessageConnectorMBean

@MessageConnectorSummary(info="Connects to a file.",
                         addressFormat="file:",
                         properties={"format -- file format (one of \"binary\", \"text\" or \"blob::\")","ignoretime -- ignore \".time\" files even if they present","start -- time to start playing from (if \".time\" file exists)","stop -- time to stop playing","delayed -- delay relatively to current time (basically same as \"start=-\")","cycle -- cycle playback","readAs -- overrides the type of read messages (one of \"ticker_data\", \"stream_data\", \"history_data\", or \"raw_data\", works for binary tape files only)"})
public class FileConnector
extends AbstractMessageConnector
implements FileConnectorMBean

Reads messages from a specified URL or file. By default when reading from some file ".time" file with corresponding name is also read and the messages times are taken from it to mimic delays of original messages. If there is no ".time" file found then all messages are given out at once. It is possible to ignore ".time" files by using boolean option "ignoretime".


Field Summary
 
Fields inherited from class com.devexperts.qd.qtp.AbstractMessageConnector
DEFAULT_READ_AGGREGATION_SIZE, DEFAULT_RECONNECT_DELAY, log
 
Constructor Summary
FileConnector(com.devexperts.connector.proto.ApplicationConnectionFactory factory, java.lang.String address)
          Creates new file connector.
FileConnector(MessageAdapter.Factory factory, java.lang.String address)
          Deprecated. use FileConnector(com.devexperts.connector.proto.ApplicationConnectionFactory , String)
 
Method Summary
 java.lang.String getAddress()
          Returns address string of this connector.
 int getConnectionCount()
          Returns number of established connections.
 long getDelayActual()
           
 TimePeriod getDelayed()
           
 long getDelayTime()
           
 com.devexperts.transport.stats.EndpointStats getEndpointStats()
          Returns statistics for this message connector.
 FileFormat getFormat()
           
 MessageType getReadAs()
           
 java.util.Date getStart()
           
 MessageConnectorState getState()
          Returns message connector state.
 java.util.Date getStop()
           
 TimestampsType getTime()
           
 boolean isActive()
          Returns true if connector is started (not stopped).
 boolean isCycle()
           
 boolean isIgnoreTime()
           
 void setAddress(java.lang.String address)
           
 void setCycle(boolean cycle)
           
 void setDelayed(TimePeriod delay)
           
 void setFormat(FileFormat format)
           
 void setIgnoreTime(boolean ignore)
           
 void setReadAs(MessageType readAs)
           
 void setStart(java.util.Date time)
           
 void setStop(java.util.Date time)
           
 void setTime(TimestampsType time)
           
 void start()
          Starts connector (connection is immediately established).
 void stop()
          Stops connector (connection is immediately dropped).
 
Methods inherited from class com.devexperts.qd.qtp.AbstractMessageConnector
addClosedConnectionStats, addMessageConnectorListener, getFactory, getLogging, getName, getReconnectDelay, getStats, getThreadPriority, notifyMessageConnectorListeners, reconfigure, removeMessageConnectorListener, restart, setName, setReconnectDelay, setStats, setThreadPriority, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.devexperts.qd.qtp.MessageConnectorMBean
getName, getReconnectDelay, getThreadPriority, restart, setName, setReconnectDelay, setThreadPriority
 

Constructor Detail

FileConnector

@Deprecated
public FileConnector(MessageAdapter.Factory factory,
                                java.lang.String address)
Deprecated. use FileConnector(com.devexperts.connector.proto.ApplicationConnectionFactory , String)

Creates new file connector.

Parameters:
factory - message adapter factory to use
address - address of file to use
Throws:
java.lang.NullPointerException - if factory or address is null

FileConnector

public FileConnector(com.devexperts.connector.proto.ApplicationConnectionFactory factory,
                     java.lang.String address)
Creates new file connector.

Parameters:
factory - application connection factory to use
address - address of file to use
Throws:
java.lang.NullPointerException - if factory or address is null
Method Detail

start

public void start()
Description copied from interface: MessageConnectorMBean
Starts connector (connection is immediately established). Does nothing if connector is already started.

Specified by:
start in interface MessageConnectorMBean
Specified by:
start in class AbstractMessageConnector

stop

public void stop()
Description copied from interface: MessageConnectorMBean
Stops connector (connection is immediately dropped). Does nothing if connector is stopped.

Specified by:
stop in interface MessageConnectorMBean
Specified by:
stop in class AbstractMessageConnector

getAddress

public java.lang.String getAddress()
Description copied from interface: MessageConnectorMBean
Returns address string of this connector. It is "[host1[:port1],host2[:port2],...]:port" for client socket connector and ":port" for server socket connector.

Specified by:
getAddress in interface MessageConnectorMBean
Returns:
address string of this connector

setAddress

public void setAddress(java.lang.String address)
Specified by:
setAddress in interface FileConnectorMBean

getFormat

public FileFormat getFormat()
Specified by:
getFormat in interface FileConnectorMBean

setFormat

public void setFormat(FileFormat format)
Specified by:
setFormat in interface FileConnectorMBean

isActive

public boolean isActive()
Description copied from interface: MessageConnectorMBean
Returns true if connector is started (not stopped).

Specified by:
isActive in interface MessageConnectorMBean
Returns:
true if connector is started (not stopped)

getState

public MessageConnectorState getState()
Description copied from interface: MessageConnectorMBean
Returns message connector state.

Specified by:
getState in interface MessageConnectorMBean
Returns:
message connector state.

getConnectionCount

public int getConnectionCount()
Description copied from interface: MessageConnectorMBean
Returns number of established connections.

Specified by:
getConnectionCount in interface MessageConnectorMBean
Returns:
number of established connections

getEndpointStats

public com.devexperts.transport.stats.EndpointStats getEndpointStats()
Description copied from interface: MessageConnectorMBean
Returns statistics for this message connector.

Specified by:
getEndpointStats in interface MessageConnectorMBean
Overrides:
getEndpointStats in class AbstractMessageConnector
Returns:
statistics for this message connector

getStart

public java.util.Date getStart()
Specified by:
getStart in interface FileConnectorMBean

setStart

public void setStart(java.util.Date time)
Specified by:
setStart in interface FileConnectorMBean

getStop

public java.util.Date getStop()
Specified by:
getStop in interface FileConnectorMBean

setStop

public void setStop(java.util.Date time)
Specified by:
setStop in interface FileConnectorMBean

getDelayTime

public long getDelayTime()

getDelayed

@Monitored(name="delayed",
           description="Configured delaying time period")
public TimePeriod getDelayed()
Specified by:
getDelayed in interface FileConnectorMBean

setDelayed

public void setDelayed(TimePeriod delay)
Specified by:
setDelayed in interface FileConnectorMBean

getTime

public TimestampsType getTime()

setTime

public void setTime(TimestampsType time)

isIgnoreTime

public boolean isIgnoreTime()
Specified by:
isIgnoreTime in interface FileConnectorMBean

setIgnoreTime

public void setIgnoreTime(boolean ignore)
Specified by:
setIgnoreTime in interface FileConnectorMBean

isCycle

public boolean isCycle()
Specified by:
isCycle in interface FileConnectorMBean

setCycle

public void setCycle(boolean cycle)
Specified by:
setCycle in interface FileConnectorMBean

getReadAs

public MessageType getReadAs()
Specified by:
getReadAs in interface FileConnectorMBean

setReadAs

public void setReadAs(MessageType readAs)
Specified by:
setReadAs in interface FileConnectorMBean

getDelayActual

@Monitored(name="delay_actual",
           description="Actual delay in ms or delay time if not connected yet")
public long getDelayActual()
Specified by:
getDelayActual in interface FileConnectorMBean