Commit graph

163 commits

Author SHA1 Message Date
Manfred Karrer
c8ece38889 Use external IP not internal 2014-11-14 03:01:36 +01:00
Manfred Karrer
d6f97c65c4 Add new test (testParallelStartupWithPutGet) 2014-11-14 00:49:23 +01:00
Chris Beams
8d70e23ba5
Use #ofType in commandline parsing for type safety
- Remove Node#getPortAsString; it is now no longer necessary
2014-11-13 12:10:22 +01:00
Chris Beams
c7f7b37572
Expose network information to GUI cleanly
This commit introduces io.bitsquare.network.ClientNode--an interface
whose name and structure will surely change--as a simplistic abstraction
over TomP2PNode that allows for exposing information to the "Network"
tab of the Preferences section of the GUI without actually requiring the
injection of TomP2PNode and other tomp2p internals into the GUI layer.

Changes to 'network' and 'msg' packages:
----------------------------------------

 - Move ConnectionType enum from test into main tree, and expose
   ClientNode#getConnectionType.

 - Both ClientNode and TomP2P are now available for injection. Both
   types are bound to the same TomP2P singleton instance. Note
   especially how NetworkPreferencesViewCB now receives a ClientNode
   instead of a TomP2PNode.

 - Restore package-private visibility to BootstrappedPeerFactory

 - Remove no longer necessary TomP2PNode#getPeerDHT

 - Expose getter for BootstrappedPeerFactory#bootstrapState

Changes to 'gui' package:
-------------------------

 - NetworkPreferencesViewCB has been simplified. All no-op methods have
   been removed, and the class now simply implements JavaFX's
   Initializable interface as opposed to Bitsquare's own ViewCB
   hierarchy, because the latter is not actually necessary (no caching
   is required for the data handled by this controller, etc.

 - In order to make the above possible, PreferencesViewCB now tolerates
   adding non-ViewCB child controllers.

 - NetworkPreferencesPM has been removed (perhaps temporarily), in an
   experiment to see "just how simple" CB controller classes can be.

 - Text fields in NetworkPreferencesView have been renamed.

Notes:
------

The data that now shows up in the "Network" tab is no longer formatted
as it once was; values are essentially nothing more than their #toString
representations. Again, this can be tweaked further, but leaving things
in this raw state provides an opportunity to discuss the current
presentation model approach, ViewCB hierarchy, etc.
2014-11-13 11:47:56 +01:00
Chris Beams
75b7482bf1
Polish formatting 2014-11-12 11:15:28 +01:00
Manfred Karrer
5fe0db7ba8 Use UUID instead of Random 2014-11-12 03:15:55 +01:00
Chris Beams
9adc41e23f
Introduce 'app.version' property and remove hardcoded version 2014-11-11 22:55:33 +01:00
Chris Beams
0136ea2884
Polish and test BitsquareEnvironment
- Introduce a test-time dependency on spring-test module for access to
   MockPropertySource and friends.

 - Add BitsquareEnvironmentTests and test that property source precedence
   works as expected, i.e. that properties supplied on the command line
   have highest precedence, overriding those picked up via environment
   variables, system properties, the bitsquare.properties file or any of
   the other available property sources.
2014-11-11 19:29:26 +01:00
Chris Beams
c8770f96a9
Move io.bitsquare.{=>app.}BitsquareEnvironmentTests 2014-11-11 19:29:25 +01:00
Manfred Karrer
33085b5c2c Refactor Settings model to 2 separate models 2014-11-11 18:43:08 +01:00
Chris Beams
1c0a6ee432
Eliminate remaining uses of @Named("appName")
Changes include:

 - Remove lighthouse.files.AppDirectory. Several methods from this class
   have, as of this commit, been rewritten and moved into the
   BitsquareEnvironment and BitsquareApp classes as appropriate.

 - Rename "appName" property => "app.name" for consistency with other
   configurable properties.

 - Allow configuration of both user and application data directories on
   the command line. See --help menu for details.
2014-11-11 14:57:18 +01:00
Chris Beams
2b3c22d382
Merge branch 'wip-cbeams'
* wip-cbeams:
  Overhaul property management and main class infrastructure

Conflicts:
	build.gradle
2014-11-11 04:28:14 +01:00
Chris Beams
acf44128b2
Overhaul property management and main class infrastructure
Use of the Spring Environment
-----------------------------

This change replaces the use of the argparse4j library and basic
Properties objects with the Spring Framework's Environment abstraction.
The Environment allows for managing any number of 'property sources' in
a hierarchical fashion, such that a call to
`environment.getProperty("someKey")` iterates through an ordered set of
property sources, returning the first value associated with the given
key.

BitsquareEnvironment, introduced in this commit, eliminates the
functionality previously present in ConfigLoader, modeling the
bitsquare.conf and bitsquare.properties files as Spring Resource
objects, and in turn creating ResourcePropertySources out of them. These
custom property sources are combined with standard property sources
based on system environment variables and Java system properties as well
as a property source based on the command-line arguments passed to a
Bitsquare application to form a unified, one-stop configuration
hierarchy.

For example, let's say a Bitsquare user wishes to customize the port
that his Bitsquare application listens on. The simplest approach
(assuming the user is comfortable with the command line), would be the
following:

    java -jar bitsquare.jar --port=1234

where '1234' is the custom port of choice. This is convenient enough for
one-off experimentation, but if the user wishes to make this a permanent
arrangement, he may want to add a `port=1234` entry to his
{bitsquare_app_dir}/bitsquare.conf file.

Alternatively, the user may wish to specify the port value as an
environment variable, e.g.:

    PORT=1234 java -jar bitsquare.jar

or with a JVM system property, e.g.:

    java -jar -DPORT=1234 bitsquare.jar

With BitsquareEnvironment, and its customized set of PropertySources in
place, the value of the port property may be specified in any of the
ways described above, and it is all handled in a unified way.

Restructuring of *Main classes
------------------------------

This commit also introduces significant changes to the structure of
executable Bitsquare applications. For example, prior to this change,
the io.bitsquare.app.gui.Main class was responsible for being both a
JavaFX Application and a standard Java main class.

Now, however, these concerns have been renamed and separated.
BitsquareApp is the JavaFX Application, and BitsquareAppMain is the Java
main class. Likewise, BootstrapNode has been broken out into
BootstrapNode and BootstrapNodeMain.

A common base class for the *Main classes has been extracted, named
BitsquareExecutable, which creates a template for option parsing,
environment creation, and ultimately application execution that applies
both to the BootstrapNode and BitsquareApp cases.

Improved help text
------------------

With the removal of argparse4j and the introduction of JOpt for argument
parsing, the application's help text has been improved. Use --help to
display this text, where you'll see information about default values,
etc. To do this easily from the Gradle build, run any of the following
commands:

    # Display help text
    ./gradlew run -Pargs="--help"

    # Qualify the application name as "Bitsquare-Alice"
    ./gradlew run -Pargs="--appName=Alice"

    # Customize the port
    ./gradlew run -Pargs="--port=7377"

Renaming of FatalException
--------------------------

Finally, the exception formerly known as io.bitsquare.gui.FatalException
has been moved up a package and generalized to
io.bitsquare.BitsquareException, as it is now used more widely.
2014-11-11 04:20:48 +01:00
Manfred Karrer
475be0d676 Add testAddGetWithReconnect test 2014-11-11 02:31:39 +01:00
Manfred Karrer
a3abd2fd69 Remove test classes 2014-11-11 02:17:48 +01:00
Chris Beams
efe6c1bec9
Merge branch 'wip-cbeams'
* wip-cbeams: (24 commits)
  Allow configurability of bitcoin network with --bitcoin.network
  Eliminate BootstrapNodes#DIGITAL_OCEAN_1_DEV
  Move comments regarding default ports to Node#DEFAULT_PORT
  Rename BootstrapNodes#{DEFAULT_BOOTSTRAP_NODE=>DEFAULT}
  Rename app.cli.{SeedNode => BootstrapNode}
  Remove dead code from UtilsDHT2.java
  Remove commented code from SeedNode
  Remove obsolete SeedNodeForTesting class
  Rename networkInterface => interface
  Eliminate the option to use TomP2P disk storage (for now)
  Expose --port command-line option
  Rename Node#{id => name}
  Allow command-line configuration of local node id and port
  Polish whitespace
  Qualify id, ip and port options with 'bootstrap.node.*'
  Extract clientPort constant
  Introduce NETWORK_INTERFACE_UNSPECIFIED contstant
  Move {MessageModule=>TomP2PMessageModule}#NETWORK_INTERFACE_KEY
  Use extracted NETWORK_INTERFACE_KEY consistently
  Polish TomP2PMessageModule#doConfigure
  ...

Conflicts:
	src/test/java/io/bitsquare/msg/TomP2PTests.java
2014-11-10 15:43:46 +01:00
Chris Beams
adfd8b2ac4
Eliminate BootstrapNodes#DIGITAL_OCEAN_1_DEV
Instead of including testing-related bootstrap nodes in the
BootstrapNodes class, this change introduces a Node#withPort method that
allows for obtaining a copy of an existing bootstrap node (e.g.
DIGITAL_OCEAN_1) with a modified port value.

This approach to `with*` methods allows for convenient customization of
value types without sacrificing immutability. See [1] for details.

[1]: http://blog.joda.org/2014/03/valjos-value-java-objects.html
2014-11-10 15:04:43 +01:00
Chris Beams
56409c0177
Rename app.cli.{SeedNode => BootstrapNode}
With this commit we're now using the naming "bootstrap node" everywhere
as opposed to the more fuzzy notion of "seed node" (which was originally
borrowed from Bitcoin Core, but doesn't really describe what we're up to
very well.

As it turns out, Kademlia also uses the terminology "bootstrap node" [1], so
we're in good company with this change.

[1]: https://en.wikipedia.org/wiki/Kademlia#Joining_the_network
2014-11-10 15:04:42 +01:00
Chris Beams
117b4ce5dc
Remove dead code from UtilsDHT2.java 2014-11-10 15:04:42 +01:00
Chris Beams
879ff57789
Remove obsolete SeedNodeForTesting class 2014-11-10 15:04:41 +01:00
Chris Beams
3398a97311
Rename Node#{id => name}
Refer to the "name" of a node rather than its "id". This is reflected in
the command line options as well. Instead of `--id`, now pass `--name`.
Instead of `--bootstrap.node.id`, now pass `--bootstrap.node.id`.
2014-11-10 14:34:30 +01:00
Manfred Karrer
865fe73bfb Remove random ports and static ID 2014-11-10 13:17:06 +01:00
Chris Beams
2ae5949448
Allow command-line configuration of local node id and port
This change does away with the notion of "clientPort" and replaces it,
simply, with "port". There are only two ports we care about in
Bitsquare:

 1. The port that the local node (i.e. a Bitsquare UI running on
    your laptop) listens on. This value is now specified with `--port`

 2. The port of the bootstrap node that the local node will connect to on
    its first run. This value is specified with `--bootstrap.node.port`

So, for example, the following is a valid commandline invocation:

    java -jar bitsquare.jar --port 1234 --bootstrap.node.port=9876

Both of these values default to Node.DEFAULT_PORT (currently 7366)

This commit also introduces the --id flag for configuring the ID of the
local node.
2014-11-10 13:05:14 +01:00
Chris Beams
cb0e214a28
Polish whitespace 2014-11-10 13:04:55 +01:00
Manfred Karrer
775a391be3 Add ChannelClientConfiguration 2014-11-10 01:51:25 +01:00
Manfred Karrer
501a3ccbc2 Merge remote-tracking branch 'origin/master' 2014-11-10 01:35:17 +01:00
Manfred Karrer
2ec1fe1c59 Sync with Thomas changes, add bootstrap call 2014-11-10 01:35:08 +01:00
Manfred Karrer
c1a645500f Remove caching as it has some side effects for failing tests 2014-11-10 01:10:45 +01:00
Chris Beams
e8986aa7a2
Rename NAME_FLAG => APP_NAME_KEY and move to AppModule 2014-11-10 00:50:59 +01:00
Chris Beams
935785e611
Organize imports 2014-11-10 00:44:48 +01:00
Chris Beams
b5f95e00a3
Supply appName via properties as well
Like all other command-line options and/or configuration file
properties, appName is now parsed for early in #main and its value
(default or custom) is then used to populate the Properties object made
available to all Guice modules. See the previous commit for additional
details.
2014-11-09 23:42:57 +01:00
Chris Beams
162fc3da0e
Favor use of Properties vs. for configuration
This reverts a number of changes made in commit 3033a19. Primary changes
include:

 - Restoring the immutability of the Node class

 - The argparse4j Namespace object is no longer passed down through
   Guice modules

 - Instead, arguments are eagerly read from the Namespace object by the
   #main method and these values are used to populate the Properties
   object that is already supplied to each Guice module

Other changes include:

 - The addition of a BootstrapNodes#DEFAULT_BOOTSTRAP_NODE field as
   a convenient alias to BootstrapNodes#DIGITAL_OCEAN_1 (or whatever the
   future default bootstrap node may be)

 - A Node#getPortAsString method has been added for convenience when
   dealing with String-based properties

 - A variant of the Node#at static factory method has been added which
   accepts the port value as a String vs. an int--again this is for
   convenience when dealing with String-based properties

 - Tests have been added to NodeTests to reflect the above
2014-11-09 23:14:46 +01:00
Chris Beams
017ebb3f38
Polish whitespace
Run "Reformat code" and "Optimize Imports" from within IDEA, cleaning up
trailing whitespace and other issues.
2014-11-09 23:10:58 +01:00
Manfred Karrer
d9372383bf Fix test 2014-11-08 16:38:09 +01:00
Manfred Karrer
3033a19b46 Change default port, Add ip to args, pass namespace to messageModule 2014-11-08 16:28:49 +01:00
Manfred Karrer
d72d7299df Add missing RepeatRule, Simplify SeedNodeForTesting 2014-11-07 18:33:59 +01:00
Manfred Karrer
089be0ca16 Use compatible version with latest TomP2P lib 2014-11-07 00:58:24 +01:00
Chris Beams
5d56dc62c9
Merge branch 'wip-cbeams'
Additional changes during the process of isolating TomP2P. High-level
changes include:

 - Beginning to break up the monolithic MessageFacade into modular
   repository classes, starting with the OfferRepository interface and
   its TomP2P implementation

 - Major refactoring of the CreateOfferCoordinator class, eliminating
   the never-completely-implemented resume logic. This class still needs
   quite a bit of work, but it's now considerably simpler than it was

 - Refactoring the Node and BootstrapNode types for greater clarity and
   ease of use

 - Most classes that use the net.tomp2p API have been moved into tomp2p
   subpackages, e.g. io.bitsquare.offer.tomp2p. Classes within have been
   made package private wherever possible.

 - The Guice module structure has evolved. For example, note the
   relationship between offer.OfferModule and offer.tomp2p.TomP2POfferModule,
   and note how the latter is consumed by app.AppModule. This arrangement
   provides for clear contracts as to what is required to assemble a
   functioning Bitsquare application, while allowing implementation-specific
   modules to be swapped in and out with ease and still allowing
   implementation-specific classes to remain package-private.

See extended commit comments for further details.

* wip-cbeams:
  Rename io.bitsquare.{Abstract=>}BitsquareModule
  Move io.bitsquare.{network=>util}.tomp2p.BaseFutureUtil
  Introduce app.gui.MainModule
  Optimize imports
  Introduce io.bitsquare.msg.tomp2p package
  Introduce io.bitsquare.offer.tomp2p package
  Extract isSuccess(BaseFuture) method into util class
  Remove offer creation recovery from CreateOfferCoordinator
  Remove unused MessageFacade from CreateOfferCoordinator
  Inline BroadCastOfferFeeTx#run into CreateOfferCoordinator
  Inline CreateOfferFeeTx#run into CreateOfferCoordinator
  Replace VerifyOffer class with Offer#validate method
  Inline CreateOfferCoordinator#onFailed
  Rename methods used to implement *Handler lambdas
  Rename *Handler methods
  Move generic *Handler types to new util.task package
  Replace AddOfferListener Result/Fault handlers
  Introduce OfferRepository interface and TomP2P impl
2014-11-06 17:05:01 +01:00
Chris Beams
486cd9824e
Introduce app.gui.MainModule 2014-11-06 16:58:23 +01:00
Chris Beams
21098afd45
Optimize imports 2014-11-06 16:58:22 +01:00
Chris Beams
96fa93f608
Introduce io.bitsquare.msg.tomp2p package 2014-11-06 16:58:20 +01:00
Manfred Karrer
1dde1f361f Use compatible version with latest TomP2P lib 2014-11-06 16:43:09 +01:00
Chris Beams
e201bf88ce
Rename i.b.network.{BootstrapNode=>BootstrapNodes} 2014-11-06 14:00:36 +01:00
Chris Beams
640a736ec3
Repeat TomP2PTests tests using @Repeat vs. loops 2014-11-06 13:17:54 +01:00
Chris Beams
1a92b05bf4
Introduce @Repeat and RepeatRule for repeatable @Test methods
With thanks to original author Frank Appel (@fappel)

See:
 - https://gist.github.com/fappel/8bcb2aea4b39ff9cfb6e
 - http://www.codeaffine.com/2013/04/10/running-junit-tests-repeatedly-without-loops/
2014-11-06 13:17:28 +01:00
Chris Beams
8b6f0ac64e
Refactor TomP2PTests
- Introduce use of Node abstraction for concision
 - Use to BootstrapNode#LOCALHOST and #DIGITAL_OCEAN1 vs. repeating info
 - Make all configuration variables static and final constants
2014-11-06 13:17:28 +01:00
Chris Beams
655100e69f
Introduce Node#at static factory and NodeTests 2014-11-06 11:25:52 +01:00
Chris Beams
da163bcc97
Introduce io.bitsquare.network.Node#DEFAULT_PORT 2014-11-06 11:25:51 +01:00
Manfred Karrer
4fb8030a43 Add loops, add extra SeedNode class, remove LanTest class 2014-11-05 20:41:34 +01:00
Manfred Karrer
bcaa8b9946 Fix random ports 2014-11-05 17:02:26 +01:00