kg.apc.perfmon.client
Class AbstractTransport

java.lang.Object
  extended by kg.apc.perfmon.client.AbstractTransport
All Implemented Interfaces:
Transport

public abstract class AbstractTransport
extends Object
implements Transport

Class that solved most of communication tasks for Transport interface and only readln() and writeln() methods left to be implemented

Author:
undera
See Also:
Transport

Field Summary
protected  PipedInputStream pis
           
protected  PipedOutputStream pos
           
 
Constructor Summary
AbstractTransport()
           
 
Method Summary
 void disconnect()
          Disconnects client from server agent
 String getAddressLabel()
          Returns address string if one was set by setAddressLabel
protected  String getNextLine(int newlineCount)
          Method retrieves next line from received bytes sequence
 String[] readMetrics()
          Method to be used after startWithMetrics Returns array containing collected metric values
 void setAddressLabel(String label)
          Set connected address string to be used in labels, since SocketAddress does not provide any info.
 void setInterval(long interval)
          Sets metrics collection interval
 void shutdownAgent()
          Commands server agent to close all connections and shutdown the process
 void startWithMetrics(String[] metricsArray)
          Asks agent to start metrics transmission.
 boolean test()
          Method to test if transport connection established with applicable server agent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface kg.apc.perfmon.client.Transport
readln, writeln
 

Field Detail

pos

protected final PipedOutputStream pos

pis

protected final PipedInputStream pis
Constructor Detail

AbstractTransport

public AbstractTransport()
                  throws IOException
Throws:
IOException
Method Detail

readMetrics

public String[] readMetrics()
Description copied from interface: Transport
Method to be used after startWithMetrics Returns array containing collected metric values

Specified by:
readMetrics in interface Transport
Returns:
metric values

setInterval

public void setInterval(long interval)
Description copied from interface: Transport
Sets metrics collection interval

Specified by:
setInterval in interface Transport

shutdownAgent

public void shutdownAgent()
Description copied from interface: Transport
Commands server agent to close all connections and shutdown the process

Specified by:
shutdownAgent in interface Transport

startWithMetrics

public void startWithMetrics(String[] metricsArray)
                      throws IOException
Description copied from interface: Transport
Asks agent to start metrics transmission.

Specified by:
startWithMetrics in interface Transport
Parameters:
metricsArray - String array containing metric description
Throws:
IOException

disconnect

public void disconnect()
Description copied from interface: Transport
Disconnects client from server agent

Specified by:
disconnect in interface Transport

test

public boolean test()
Description copied from interface: Transport
Method to test if transport connection established with applicable server agent

Specified by:
test in interface Transport
Returns:
success

getNextLine

protected String getNextLine(int newlineCount)
                      throws IOException
Method retrieves next line from received bytes sequence

Parameters:
newlineCount -
Returns:
next command line
Throws:
IOException

getAddressLabel

public String getAddressLabel()
Description copied from interface: Transport
Returns address string if one was set by setAddressLabel

Specified by:
getAddressLabel in interface Transport
Returns:
address string

setAddressLabel

public void setAddressLabel(String label)
Description copied from interface: Transport
Set connected address string to be used in labels, since SocketAddress does not provide any info.

Specified by:
setAddressLabel in interface Transport
Parameters:
label - the label to set


Copyright © 2013. All Rights Reserved.