edu.sdsc.inca
Class AgentClient

java.lang.Object
  extended by edu.sdsc.inca.Component
      extended by edu.sdsc.inca.Client
          extended by edu.sdsc.inca.AgentClient

public class AgentClient
extends Client

This class allows access to the services provided by an Inca Agent. Along with defining an API that understands the Agent protocol, it defines a main method that allows access to an Agent via a telnet-style interface and provides a means for configuring an Inca installation from the command line.


Field Summary
static java.lang.String AGENT_CLIENT_OPTS
           
protected  java.lang.String deployPath
           
protected static org.apache.log4j.Logger logger
           
 
Fields inherited from class edu.sdsc.inca.Client
CLIENT_OPTS, reader, socket, writer
 
Fields inherited from class edu.sdsc.inca.Component
authenticate, cert, certPath, COMPONENT_OPTS, hostname, key, keyPath, logFile, password, port, trusted, trustedPath
 
Constructor Summary
AgentClient()
           
 
Method Summary
 void approve(java.lang.String resource, edu.sdsc.inca.dataModel.inca.IncaDocument approved)
          Approve the enclosed series config changes for the specified resource.
 java.util.Properties[] getCatalog(java.lang.String url)
          Returns properties for all reporters contained within one repository or all repositories known to the Agent.
 java.lang.String getCatalogAsXml(java.lang.String uri)
          Like getCatlog, but returns wraps the catalog information into XML instead of an array of Properties.
 java.lang.String getConfig()
          Returns IncaDocument XML for the Inca deployment configuration.
 java.lang.String getDeployPath()
          Returns the path to the IncaDocument XML deployment file.
 edu.sdsc.inca.dataModel.inca.IncaDocument getProposedChanges(java.lang.String resource)
          Request all proposed changes to the reporter manager that have not yet been committed to the manager.
static void main(java.lang.String[] args)
          A simple main method for exercising the AgentClient.
 void runNow(java.lang.String type, java.lang.String suite)
          Submits the following run now request to the agent
 void setConfig(java.lang.String config)
          Replaces or updates the Inca deployment configuration.
 void setConfiguration(java.util.Properties config)
          A convenience function for setting multiple configuration properties at once.
 void setDeployPath(java.lang.String path)
          Sets the path to the IncaDocument XML deployment file.
 
Methods inherited from class edu.sdsc.inca.Client
close, commandGetLog, commandLogConfig, commandPermit, commandPing, commandRevoke, commandRevokeAll, connect, dialog, getDn, getTempPath, isConnected, read, setServer, setTempPath, telnetDialog, write
 
Methods inherited from class edu.sdsc.inca.Component
addTrustedCert, configComponent, createSocket, getAuthenticate, getCertificate, getCertificatePath, getConfiguration, getDn, getHostname, getKey, getKeyPath, getLogFile, getPassword, getPort, getTrustedCertificates, getTrustedPath, getUri, openResourceStream, readCredentials, readVersion, setAuthenticate, setCertificatePath, setHostname, setKeyPath, setLogFile, setPassword, setPort, setTrustedPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AGENT_CLIENT_OPTS

public static final java.lang.String AGENT_CLIENT_OPTS

logger

protected static final org.apache.log4j.Logger logger

deployPath

protected java.lang.String deployPath
Constructor Detail

AgentClient

public AgentClient()
Method Detail

approve

public void approve(java.lang.String resource,
                    edu.sdsc.inca.dataModel.inca.IncaDocument approved)
             throws java.io.IOException,
                    ProtocolException
Approve the enclosed series config changes for the specified resource.

Parameters:
resource - The resource the changes are being approved for.
approved - IncaDocument XML specifying changes in the configuration
Throws:
java.io.IOException - on read/write error
ProtocolException - on an invalid message

getCatalog

public java.util.Properties[] getCatalog(java.lang.String url)
                                  throws java.io.IOException,
                                         ProtocolException
Returns properties for all reporters contained within one repository or all repositories known to the Agent.

Parameters:
url - the url of the repository to query; if null, a merged catalog from all repositories known to the Agent is returned
Returns:
an array of Properties, each of which represents the attributes of a single repository package
Throws:
java.io.IOException - on read/write error
ProtocolException - on an invalid message

getCatalogAsXml

public java.lang.String getCatalogAsXml(java.lang.String uri)
                                 throws java.io.IOException,
                                        ProtocolException
Like getCatlog, but returns wraps the catalog information into XML instead of an array of Properties. The outer tag of the XML is <catalog>, which returns 0 or more <reporter> subtags. Each of these contains zero or more <property> subtags, which list the property name and value in subtags.

Parameters:
uri - the url of the repository to query; if null, a merged catalog from all repositories known to the Agent is returned
Returns:
XML, described above, that gives the contents of the repository
Throws:
java.io.IOException - on read/write error
ProtocolException - on an invalid message

getConfig

public java.lang.String getConfig()
                           throws java.io.IOException,
                                  ProtocolException
Returns IncaDocument XML for the Inca deployment configuration.

Returns:
IncaDocument XML for the deployment configuration
Throws:
java.io.IOException - on read/write error
ProtocolException - on an invalid message

getDeployPath

public java.lang.String getDeployPath()
Returns the path to the IncaDocument XML deployment file.

Returns:
the path to the deployment file

getProposedChanges

public edu.sdsc.inca.dataModel.inca.IncaDocument getProposedChanges(java.lang.String resource)
                                                             throws java.io.IOException,
                                                                    ProtocolException
Request all proposed changes to the reporter manager that have not yet been committed to the manager.

Parameters:
resource - The resource name for the manager we are requesting for
Returns:
IncaDocument containing all of the proposed changes for the manager
Throws:
java.io.IOException - on read/write error
ProtocolException - on an invalid message

runNow

public void runNow(java.lang.String type,
                   java.lang.String suite)
            throws java.io.IOException,
                   ProtocolException
Submits the following run now request to the agent

Parameters:
suite - SuiteDocument XML specifying changes in the configuration
type - A string containing the type of run now request
Throws:
java.io.IOException - on read/write error
ProtocolException - on an invalid message

setConfig

public void setConfig(java.lang.String config)
               throws java.io.IOException,
                      ProtocolException
Replaces or updates the Inca deployment configuration.

Parameters:
config - IncaDocument XML specifying changes in the configuration
Throws:
java.io.IOException - on read/write error
ProtocolException - on an invalid message

setConfiguration

public void setConfiguration(java.util.Properties config)
                      throws ConfigurationException
A convenience function for setting multiple configuration properties at once. In addition to the keys recognized by the superclass, recognizes: "agent", the specification of the Agent; "file", a path to an IncaDocument XML file.

Overrides:
setConfiguration in class Client
Parameters:
config - contains AgentClient configuration values
Throws:
ConfigurationException - on a faulty configuration property value

setDeployPath

public void setDeployPath(java.lang.String path)
Sets the path to the IncaDocument XML deployment file.

Parameters:
path - the path to the deployment file

main

public static void main(java.lang.String[] args)
A simple main method for exercising the AgentClient.
 usage: java inca.AgentClient
-a|--auth boolean Authenticated (secure) connection? -A|--agent str Agent specification; host:port -c|--cert path Path to the authentication certificate -f|--file path Inca installation configuration file path -h|--help null Print help/usage -i|--init path Path to properties file -k|--key path Path to the authentication key -P|--password str Specify how to obtain encryption password -t|--trusted path Path to authentication trusted certificate dir -V|--version null Display program version

Each of these properties, other than --init, can also be specified in the initialization file or in system properties defined via the -D switch. In each of these cases, the configuration name must be prefixed with "inca.agent.", e.g., use "inca.agent.cert" to specify the cert value. Command line arguments override any properties specified in this fashion. If --file is specified, the main method reads the specified file and sends it to the Agent in a setConfig message; otherwise, main allows the user to communicate with the Agent via a telnet-style interface. Supported values for the --password argument are: "no" or "false" (no encryption); "yes", "true", or "stdin:prompt" (read password from stdin after optionally prompting); "pass:text" (specify the password directly--should only be used for testing and, possibly, in the init file).

Parameters:
args - command line arguments, as above.