Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Starting A las2peer Network
This tutorial will guide you through the process of starting your first las2peer network. It is highly recommended that you read the step by step First Service tutorial first to have an idea of how to build your service. This tutorial builds up on it. It is split into two parts: The first part explains the build up of a las2peer instance, giving you some insight into how you can configure your node. The second part deals with starting a las2peer node with the L2pNodeLauncher.
Build-Up of a las2peer Instance
After having successfully completed the first tutorial, you should have a las2peer instance that is ready to run. It should look something like this:
To give you an insight into the configuration of a las2peer instance, let us take a look at the different directories:
This directory contains a start script that is used in the second part of this tutorial and two agent generator scripts. The agent generator scripts
are used to create agent XML files that are stored in the
etc directory. This directory is thus not directly necessary for running a las2peer
instance, but the scripts ease the handling.
This directory contains all configuration files.
nodeInfo.xmlfile contains some information about the node that can be requested by everybody. Currently, it contains a mail and description field that can be filled arbitrary.
- The second file in the directory is a property file of the Web-Connector. These property files can be created for each service
or connector. Just add a new file, named according to your service package, to this directory and the line
setFieldValues()to the constructor of your main services class, and las2peer will read this file at your service startup. If your service contains a global variable named the same as a variable specified in the configuration file of your service, it will be set to the value of your configuration file. Take a look at the connector`s configuration file for the syntax.
ant_configurationdirectory was already discussed in the previous tutorial. The ANT script used in this template project uses the agent generator scripts to create a service and an user agent according to the values it reads from the files of this directory.
ivydirectory is used by the ANT script to fetch the dependencies needed to build and run the project. You can take a look at the
ivy.xmlto see, which dependencies are loaded.
- The third directory is called
startup. Everything in here can be loaded into a las2peer network by passing the command
uploadStartupDirectoryto the L2pNodeLauncher. Currently, it should hold agent definitions for services and a couple of users agent that are generated by the Ant build script. The third file is called
passphrases.txtand contains the passphrases needed to unlock these agents (for uploading). It is also generated by the build script.
This directory contains the libraries needed to start a las2peer network. It is created (and filled) by the Ant script.
This is the default directory for all log files.
This is the default directory for all services. It should contain your service jar, since the ANT script puts it there
automatically (apart from adding it to the
You might also recognize some additional folders. The
.las2peer folder is used by a las2peer instance for storing
(encrypted) content of the network. You can think of it as the storage of a node. After a node shuts down, this
content is not deleted, but you can not access it anymore. So after a node has shut down, you can delete the corresponding
(sub-)directory if you want. The
export folder contains your service Jar and the documentation generated from your source
code. You can also find your test reports there. As well as the
.settings directories (and the other
files located at the root directory), these folders are not used by a las2peer instance itself, but are rather part of your
project configuration. You can delete them if you just want to deploy a node somewhere.
Starting a las2peer Node / Network
Now that you have configured your node, you can start it with the
start_network script in your
All you have to know is a port that you can open at your machine. If you want to join an existing network, you need to know the address and
port of one participant.
You need to add parameters to the last line of the script, according to the following schema:
[..] i5.las2peer.tools.L2pNodeLauncher -s [PORT] ['-'|IP] [optional: additional commands and / or 'interactive']
The [PORT] determines, at which port your node should be started. The second parameter indicates, whether a new network shall be started (
or if the node shall join an existing network. In that case, you need to add the IP and port here. After this, you can add additional parameters
from the L2pNodeLauncher. If you add
interactive, the launcher will enter the interactive mode after the node's startup (see the
L2pNodeLauncher tutorial for more information on this topic).
As an example, you could do the following:
Start a new network with your node starting at port 9001:
[..] i5.las2peer.tools.L2pNodeLauncher -s 9001 -
Add an additional node to your network at port 9002 and enter the interactive mode:
[..] i5.las2peer.tools.L2pNodeLauncher -s 9002 YOUR_IP:9001 interactive
Each started node will continue to run if the last command is not the
You can stop the complete run using Ctrl-C at any point.
You can find detailed log files for each node in the directory
To end this tutorial, here is a list of commands that can be executed at a node in interactive mode to start and use the service we developed in the tutorials (please note that you might have to slightly adjust the names according to the ones you chose):
uploadStartupDirectory startService('i5.las2peer.services.myNewService.MyNewServiceMainClass@1.0', 'someNewPass') registerUserAgent('UserA', 'userAPass') invoke('i5.las2peer.services.myNewService.MyNewServiceMainClass', 'validateLogin', '') invoke('i5.las2peer.services.myNewService.MyNewServiceMainClass', 'exampleMethod', 'What a beautiful service!')
The result should look something like this (open in new window):
For more information about the L2pNodeLauncher and its usage, please visit the L2pNodeLauncher Tutorial.