Menu

CapsisBridgeServer

Mathieu Fortin Jean-Francois Lavoie

CapsisBridge server

Overview

This module uses gRPC for java to offer RPC Methods allowing access to the a subset of the Capsis simulation platform models. It also uses the Gradle build system (https://gradle.org/). It includes two different packages :

    1. CapsisBridgeService which provides the API service for Capsis access
    2. CapsisBridgeClient which is the API to be used by JAVA client applications to connect to CapsisBridgeService and abstract gRPC

Requisites

Java 1.8 is required and the project can be built using either Eclipse or IntelliJ Idea.
The Gradle build system requires the "Buildship" plugin for Eclipse (https://projects.eclipse.org/projects/tools.buildship).
An access to the CAPSIS repository is also required to build the CAPSIS Bridge Server.

Building

Choosing between lightweight and full builds

CAPSISBridge has two main purposes :

1. Exposing models and simulation methods to allow accessing CAPSIS and its forest growth simulation capabilities.   This mode is called *full build* mode and requires CAPSIS as a dependency. 
2. Exposing metamodel related features only to allow get metamodel predictions using pre-fitted metamodels.  This mode is called *lightweight* build and does not require CAPSIS, but only the REpicea.jar library.

Choosing between the two building modes can be set by setting the following properties in the gradle.properties file located in the root folder :

  • buildUsingCapsis : set this to "true" to enable full builds using CAPSIS, and set to "false" to enable lightweight builds using REpicea. Default value is "false".
  • capsisPath : the location of the CAPSIS folder to build with. Default value is "....\capsis".
  • repiceaPath : the location of the CAPSIS folder to build with. Default value is "....\externallibraries".

Eclipse

Building on Eclipse is done through the Buildship plugin that allows Gradle integration.

  1. Checkout the SVN repository into the desired local folder
  2. Under File menu, choose "Import" to import a new project
  3. In the "Gradle" section, select "Existing Gradle Project" in the "Import" dialog and click "Next"
  4. Specify the location of the local folder used in step 1 in the "Project root directory" field and click "Finish"
  5. Launch the "ShadowJar" Gradle task using the "Gradle Tasks" tab showing in the lower pane window to build CapsisBridgeService
  6. Launch the "InstallDist" Gradle task using the "Gradle Tasks" tab showing in the lower pane window to build CapsisBridgeClient

IntelliJ IDEA

  1. Checkout the SVN repository into the desired local folder
  2. Use "Open" file menu to open the root folder where the code is located
  3. Launch the "ShadowJar" Gradle task using the "Gradle Tasks" tab showing in the lower pane window to build CapsisBridgeService
  4. Launch the "InstallDist" Gradle task using the "Gradle Tasks" tab showing in the lower pane window to build CapsisBridgeClient

The ShadowJar Gradle task will produce the jar file "capsisBridgeServer-all.jar" in the root path of the CAPSIS project. IMPORTANT: the Gradle project assumes that the Capsis folder is found at this relative location: ../../capsis . If the Capsis projet is located somewhere else, this relative location must be changed in order to properly compile the Gradle project. The property that sets the relative location of the Capsis folder is called "capsispath" and it can be changed in the "gradle.properties" file found at the root of the Gradle project.

Packaging

The CapsisBridge server can be packaged as follows:

  1. Open a command line
  2. Go to the root of the Capsis project
  3. Enter the following command:
> ant clean installer-bridge -Dmodules="quebecmrnf/**,artemis/**"

The ant script will create a package called "capsis-bridge-setup.jar" in the root path of the Capsis project. This jar file is a standalone installer of the Capsis project. Double-clicking on the file will start the installation of the CapsisBridge server with only one available model: Artemis. If the double-clicking does not work, the installation can be triggered through a command line:

> java -jar capsis-bridge-setup.jar

Running an instance of CapsisBridge server

Once the server has been installed, it can be started using a command line:

java -jar capsisBridgeServer-all.jar p=50001

Parameter p indicates the port number. Several instances can be started if they listen to different ports. When a particular instance is started, the following message should appear in the console:

Capsis 4.2.6-16940 with pilot capsis.script.Pilot: correct boot at 17 Mar 2021 10:13:53 EDT
Working dir: C:\Users\matforti\Documents\4_GrowthSimulators\CapsisBridgeServer
Updating settings...
Running CAPSIS version 4.2.6-16940
Authors: Jean-Francois Lavoie and Mathieu Fortin
For the Canadian Forest Service
Copyright (c) Her Majesty the Queen in right of Canada
This software uses the gRPC library located at https://www.grpc.io/
which is licensed under the Apache 2.0 license available at
https://www.apache.org/licenses/LICENSE-2.0
2021-03-17 10:13:54 INFO Server started, listening on 50001

Related

Wiki: Home