Package i5.las2peer.tools
Class L2pNodeLauncher
java.lang.Object
i5.las2peer.tools.L2pNodeLauncher
las2peer node launcher
It is the main tool for service developers / node maintainers to start their services, upload agents to the network
and to test their service methods directly in the p2p network. The launcher both supports the start of a new network
as well as starting a node that connects to an already existing network via a bootstrap.
All methods to be executed can be stated via additional command line parameters to the
main(java.lang.String[])
method.-
Method Summary
Modifier and TypeMethodDescriptionObject[]
Searches for the given agent in the las2peer network.Object[]
findService
(String serviceNameVersion) Looks for the given service in the las2peer network.getEnvelope
(String id) Get the envelope with the given idget the information stored about the local NodeGets a list of local running services on this nodeget information about other nodes (probably neighbors in the ring etc)getNode()
getServiceMethods
(String serviceNameVersion) Returns a list of available methods for the given service class name.static String
Gets the las2peer version as String.void
start interactive console mode based on aCommandPrompt
Invokes a service method as the current agent, choosing an approptiate service version.boolean
static L2pNodeLauncher
launchConfiguration
(L2pNodeLauncherConfiguration launcherConfiguration) static L2pNodeLauncher
launchSingle
(int port, String bootstrap, SharedStorage.STORAGE_MODE storageMode, boolean observer, String sLogDir, Iterable<String> serviceDirectories, Long nodeIdSeed, Iterable<String> commands) Deprecated.static L2pNodeLauncher
launchSingle
(Iterable<String> args) Deprecated.UselaunchConfiguration(L2pNodeLauncherConfiguration)
instead.loadAgentFromXml
(String filename) load an agent from an XML file and return it for later usagestatic void
Main method for command line processing.static void
Prints a help message for command line usage.static void
Prints the las2peer version.void
registerUserAgent
(UserAgentImpl agent) Register the given agent at the las2peer node and for later usage withinvoke(java.lang.String, java.lang.String, java.lang.String)
.void
registerUserAgent
(UserAgentImpl agent, String passphrase) Register the given agent at the las2peer node and for later usage withinvoke(java.lang.String, java.lang.String, java.lang.String)
.boolean
registerUserAgent
(String idOrLogin, String passphrase) Try to register the user of the given id at the node and for later usage in this launcher, i.e.void
shutdown()
Closes the current node.void
startConnector
(String connectorClass) Starts a connector given by its classname.void
Deprecated.UsestartWebConnector()
instead.void
startService
(AgentImpl serviceAgent) start the service defined by the given (Service-)Agentvoid
startService
(String serviceNameVersion) Starts a service with a known agent or generate a new agent for the service (using a random passphrase) Will create an xml file for the generated agent and store the passphrase lcoallyvoid
startService
(String serviceNameVersion, String defaultPass) start a service with a known agent or generate a new agent for the service will create an xml file for the generated agent and store the passphrase lcoallystartServiceXml
(String file, String passphrase) start a service defined by an XML file of the corresponding agentvoid
Starts the WebConnectorvoid
stopConnector
(String connectorClass) Stops a connector given by its classname.void
Deprecated.UsestopWebConnector()
instead.void
stopService
(String serviceNameVersion) stop the given service needs name and versionvoid
Stops the WebConnectorvoid
unlockAgent
(PassphraseAgentImpl agent, String passphrase) try to unlock the private key of the given agent with the given pass phrasevoid
Unregister the current user from the las2peer node and from this launcher.void
uploadServicePackage
(String serviceJarFile, String developerAgentXMLFile, String developerPassword) Uploads the service jar file and its dependencies into the shared storage to be used for network class loading.void
uploadServicePackage
(String serviceJarFile, String developerAgentXMLFile, String developerPassword, String supplement) Uploads the service jar file and its dependencies into the shared storage to be used for network class loading.void
Upload the contents of the startup sub directory to the global storage of the las2peer network.void
uploadStartupDirectory
(String directory) Uploads the contents of the given directory to the global storage of the las2peer network.
-
Method Details
-
isFinished
public boolean isFinished() -
getNode
-
getNodeAsEthereumNode
-
getEnvelope
public String getEnvelope(String id) throws NumberFormatException, EnvelopeNotFoundException, EnvelopeException, SerializationException Get the envelope with the given id- Parameters:
id
-- Returns:
- the XML-representation of an envelope as a String
- Throws:
EnvelopeException
EnvelopeNotFoundException
NumberFormatException
SerializationException
-
findAgent
Searches for the given agent in the las2peer network.- Parameters:
agentId
-- Returns:
- node handles
- Throws:
AgentNotRegisteredException
-
findService
Looks for the given service in the las2peer network. Needs an active user- Parameters:
serviceNameVersion
- Exact name and version, same syantax as instartService(String)
- Returns:
- node handles
- Throws:
AgentException
- See Also:
-
shutdown
public void shutdown()Closes the current node. -
uploadStartupDirectory
Uploads the contents of the given directory to the global storage of the las2peer network. Each contained .xml-file is used as an artifact or - in case the name of the file starts with agent- - as an agent to upload. If agents are to be uploaded, make sure, that the startup directory contains a passphrases.txt file giving the passphrases for the agents.- Parameters:
directory
-
-
uploadStartupDirectory
public void uploadStartupDirectory()Upload the contents of the startup sub directory to the global storage of the las2peer network. Each contained .xml-file is used as an artifact or - in case the name of the file starts with agent- - as an agent to upload. If agents are to be uploaded, make sure, that the startup directory contains a passphrases.txt file giving the passphrases for the agents. -
uploadServicePackage
public void uploadServicePackage(String serviceJarFile, String developerAgentXMLFile, String developerPassword) throws ServicePackageException, EnvelopeAlreadyExistsException Uploads the service jar file and its dependencies into the shared storage to be used for network class loading.- Parameters:
serviceJarFile
- The service jar file that should be uploaded.developerAgentXMLFile
- The XML file of the developers agent.developerPassword
- The password for the developer agent.- Throws:
ServicePackageException
EnvelopeAlreadyExistsException
-
uploadServicePackage
public void uploadServicePackage(String serviceJarFile, String developerAgentXMLFile, String developerPassword, String supplement) throws ServicePackageException, EnvelopeAlreadyExistsException Uploads the service jar file and its dependencies into the shared storage to be used for network class loading.- Parameters:
serviceJarFile
- The service jar file that should be uploaded.developerAgentXMLFile
- The XML file of the developers agent.developerPassword
- The password for the developer agent.supplement
- Additional service metadata string.- Throws:
ServicePackageException
EnvelopeAlreadyExistsException
-
startWebConnector
public void startWebConnector()Starts the WebConnector -
stopWebConnector
public void stopWebConnector()Stops the WebConnector -
startNodeAdminConnector
Deprecated.UsestartWebConnector()
instead. -
stopNodeAdminConnector
Deprecated.UsestopWebConnector()
instead. -
startConnector
Starts a connector given by its classname.- Parameters:
connectorClass
-
-
stopConnector
Stops a connector given by its classname.- Parameters:
connectorClass
-
-
registerUserAgent
Try to register the user of the given id at the node and for later usage in this launcher, i.e. for service method calls viainvoke(java.lang.String, java.lang.String, java.lang.String)
.- Parameters:
idOrLogin
- id or login of the agent to loadpassphrase
- passphrase to unlock the private key of the agent- Returns:
- the registered agent
-
registerUserAgent
public void registerUserAgent(UserAgentImpl agent) throws InternalSecurityException, AgentAlreadyRegisteredException, AgentException, AgentAccessDeniedException Register the given agent at the las2peer node and for later usage withinvoke(java.lang.String, java.lang.String, java.lang.String)
. Make sure, that the private key of the agent is unlocked before registering- Parameters:
agent
-- Throws:
InternalSecurityException
AgentAlreadyRegisteredException
AgentException
AgentAccessDeniedException
-
registerUserAgent
public void registerUserAgent(UserAgentImpl agent, String passphrase) throws InternalSecurityException, AgentException, AgentAccessDeniedException Register the given agent at the las2peer node and for later usage withinvoke(java.lang.String, java.lang.String, java.lang.String)
. If the private key of the agent is not unlocked and a pass phrase has been given, an attempt to unlock the key is started before registering.- Parameters:
agent
-passphrase
-- Throws:
InternalSecurityException
AgentAlreadyRegisteredException
AgentException
AgentAccessDeniedException
-
unregisterCurrentAgent
public void unregisterCurrentAgent()Unregister the current user from the las2peer node and from this launcher. -
invoke
public Serializable invoke(String serviceIdentifier, String serviceMethod, String parameters) throws AgentLockedException, ServiceInvocationException Invokes a service method as the current agent, choosing an approptiate service version. The arguments must be passed via ONE String separated by "-".- Parameters:
serviceIdentifier
-serviceMethod
-parameters
- pass an empty string if you want to call a method without parameters- Returns:
- Returns the invocation result
- Throws:
ServiceInvocationException
AgentLockedException
- See Also:
-
getServiceMethods
public ListMethodsContent getServiceMethods(String serviceNameVersion) throws InternalSecurityException, AgentException, InterruptedException, EncodingFailedException, SerializationException, TimeoutException Returns a list of available methods for the given service class name.- Parameters:
serviceNameVersion
- Exact service name and version, same syntax as instartService(String)
- Returns:
- list of methods encapsulated in a ListMethodsContent
- Throws:
InternalSecurityException
AgentException
InterruptedException
SerializationException
EncodingFailedException
TimeoutException
-
startService
Starts a service with a known agent or generate a new agent for the service (using a random passphrase) Will create an xml file for the generated agent and store the passphrase lcoally- Parameters:
serviceNameVersion
- Specify the service name and version to run: package.serviceClass@Version. Exact match required.- Throws:
Exception
- on error
-
startService
start a service with a known agent or generate a new agent for the service will create an xml file for the generated agent and store the passphrase lcoally- Parameters:
serviceNameVersion
- the exact name and version of the service to be starteddefaultPass
- this pass will be used to generate the agent if no agent exists- Throws:
Exception
- on error
-
startServiceXml
start a service defined by an XML file of the corresponding agent- Parameters:
file
- path to the file containing the servicepassphrase
- passphrase to unlock the service agent- Returns:
- the service agent
- Throws:
Exception
- on error
-
startService
public void startService(AgentImpl serviceAgent) throws AgentAlreadyRegisteredException, InternalSecurityException, AgentException start the service defined by the given (Service-)Agent- Parameters:
serviceAgent
-- Throws:
AgentAlreadyRegisteredException
InternalSecurityException
AgentException
-
stopService
public void stopService(String serviceNameVersion) throws AgentNotRegisteredException, NodeException, ServiceNotFoundException stop the given service needs name and version- Parameters:
serviceNameVersion
-- Throws:
AgentNotRegisteredException
NodeException
ServiceNotFoundException
-
loadAgentFromXml
load an agent from an XML file and return it for later usage- Parameters:
filename
- name of the file to load- Returns:
- the loaded agent
- Throws:
AgentException
-
unlockAgent
public void unlockAgent(PassphraseAgentImpl agent, String passphrase) throws AgentAccessDeniedException, AgentOperationFailedException try to unlock the private key of the given agent with the given pass phrase- Parameters:
agent
-passphrase
-- Throws:
AgentAccessDeniedException
AgentOperationFailedException
- If the agent's private key can not be deserialized.
-
interactive
public void interactive()start interactive console mode based on aCommandPrompt
-
getLocalNodeInfo
get the information stored about the local Node- Returns:
- a node information
- Throws:
CryptoException
-
getNetInfo
get information about other nodes (probably neighbors in the ring etc)- Returns:
- string with node information
-
getLocalServices
Gets a list of local running services on this node- Returns:
- Returns a list of local running services
-
launchSingle
@Deprecated public static L2pNodeLauncher launchSingle(Iterable<String> args) throws CryptoException, NodeException Deprecated.UselaunchConfiguration(L2pNodeLauncherConfiguration)
instead. Launches a single node.- Parameters:
args
-- Returns:
- the L2pNodeLauncher instance
- Throws:
CryptoException
- If the system encryption self test fails. See log/output for details.NodeException
- If an issue with the launched node occurs.IllegalArgumentException
- If an issue occurs with a configuration argument.
-
launchConfiguration
public static L2pNodeLauncher launchConfiguration(L2pNodeLauncherConfiguration launcherConfiguration) throws CryptoException, NodeException, IllegalArgumentException - Parameters:
launcherConfiguration
-- Returns:
- Returns the launcher instance.
- Throws:
CryptoException
- If the system encryption self test fails. See log/output for details.NodeException
- If an issue with the launched node occurs.IllegalArgumentException
- If an issue occurs with a configuration argument.
-
printHelp
public static void printHelp()Prints a help message for command line usage. -
getVersion
Gets the las2peer version as String.- Returns:
- Returns the las2peer version as "major.minor.build" or "DEBUG" if not set.
-
printVersion
public static void printVersion()Prints the las2peer version. -
main
Main method for command line processing. The method will start a node and try to invoke all command line parameters as parameterless methods of this class.- Parameters:
argv
-
-
launchConfiguration(L2pNodeLauncherConfiguration)
instead.