Class SmfConnection
- All Implemented Interfaces:
- com.blackhillsoftware.common.interfaces.Emptyable,- Closeable,- AutoCloseable,- Iterable<byte[]>
 Create the SmfConnection using 
  SmfConnection.forResourceName(String) 
  to get a SmfConnection.Connectable, set connection options as required and call
  connect(). 
   
  
This class implements Closeable and should be used with a try-with-resources block to ensure that the connection is closed when it exits.
  try (SmfConnection connection = 
           SmfConnection.forResourceName("IFASMF.MYRECS")
               .disconnectOnStop()
               .connect())
  {
      for (byte[] smfRecord : connection)
      {
          // process smfRecord
      }
  }
  - 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classClass used to set options for the SmfConnection prior to connection to the in memory resource.
- 
Method SummaryModifier and TypeMethodDescriptionabstract voidclose()Close the connection.static SmfConnection.ConnectableforResourceName(String name) Create a Connectable object for a SMF In Memory Resource name.Get the name of the resource for this connectionbooleanisEmpty()Return true if the internal queue of SMF records is empty and the next record will be read from the in memory resource, potentially waiting until a record is written.Iterator<byte[]> iterator()Get a SMF record Iterator.booleanDeprecated.static List<InMemoryResource> query()Query the list of SMF in memory resources defined to the systembyte[]read()Read a record, waiting if necessary.Spliterator<byte[]> Get a Spliterator for the records from the SMF connection.Stream<byte[]> stream()Get a Java Stream to read SmfRecords as byte arrays from the in memory resource.
- 
Method Details- 
queryQuery the list of SMF in memory resources defined to the system- Returns:
- a list of SMF In Memory Resources
- Throws:
- IOException- if an error occurs getting the list of resources
- See Also:
 
- 
forResourceNameCreate a Connectable object for a SMF In Memory Resource name. Callconnect()to return a usable SmfConnection object or callonMissedData(Consumer)to setup missed data handling.- Parameters:
- name- the name of the in memory resource.
- Returns:
- Connectable the object ready to connect.
 
- 
readRead a record, waiting if necessary.- Returns:
- a record, or null if the connection has been closed.
- Throws:
- IOException- if an error occurs reading the record
 
- 
streamGet a Java Stream to read SmfRecords as byte arrays from the in memory resource.- Returns:
- Stream<byte[]>
- See Also:
 
- 
iteratorGet a SMF record Iterator. Each SMF record is returned as a byte array containing the SMF record data, including the record descriptor word (RDW).Note: The Iterator.hasNext()method will wait if there is no SMF record immediately available. It will return true when the next record is available, or false if the connection is closed. Likewise,Iterator.next()will wait if there is no record currently available.
- 
spliteratorGet a Spliterator for the records from the SMF connection.Note: The Spliterator.tryAdvance(Consumer)method will wait if there is no SMF record immediately available. It will return true when a record has been read and processed, or false if the connection is closed.- Specified by:
- spliteratorin interface- Iterable<byte[]>
 
- 
isEmptypublic boolean isEmpty()Return true if the internal queue of SMF records is empty and the next record will be read from the in memory resource, potentially waiting until a record is written.Multiple records can be read from the in memory resource and queued internally. If there are records queued i.e. (isEmpty() == false) the next record will be returned immediately. If (isEmpty() == true) the next record will be read from the in memory resource, waiting if necessary until a record is available. - Specified by:
- isEmptyin interface- com.blackhillsoftware.common.interfaces.Emptyable
- Returns:
- true if there are no records currently queued and the next record will be read from the in memory resource
 
- 
moreQueuedDeprecated.seeisEmpty()- Returns:
- false if the next record will be read from the in memory resource
 
- 
closeClose the connection.Close can be called from a different thread to the thread reading the records. In that case, close() will wait up to 5 seconds for a read in progress to end. A read started before close() is called might return data after close() has been called from another thread. - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Throws:
- IOException
 
- 
getResourceNameGet the name of the resource for this connection- Returns:
- the resource name
 
 
- 
isEmpty()