Vine Toolkit - standalone mode

Vine Toolkit may be used in different ways, one of it is standalone mode - it can be used as a library to access different grid resources for example.

Let's assume that '$VINESRC' is the location of the vine source installation package.

In '$VINESRC/projects' directory you can find an example project called: jobmanagertest - it contains simple standalone application.
(if it is not present set the default installer to 'testStandaloneJobManager' by 'ant choose-installer' command and run 'ant fetch' command to get all required projects)

In '$VINESRC/installers' directory you can find an example installer called 'testStandaloneJobManager' which could be used to test the standalone application. The application uses globus gt4, grms broker and unicore6 resources - but
of course it could be changed in the Domain.xml configuration file accordingly by the user requirements.

So first the installer's build.properties:

#----------------------------------------------------------
# Installer title
#----------------------------------------------------------
software.installer.title=Job Manager Test

#----------------------------------------------------------
# Installer type
#----------------------------------------------------------
software.installer.type=dist

#----------------------------------------------------------
# Projects
#----------------------------------------------------------
application.projects=group,grid,voms,glite3,unicore6,bes,grms,opendsp,gt2,gt4,jobmanagertest

#----------------------------------------------------------
# Application type
#----------------------------------------------------------
application.type=main

#----------------------------------------------------------
# Turn off blazeds support
#----------------------------------------------------------
application.web.blazeDsSupport=false

Properties:
- software.installer.title - installer title
- software.installer.type - 'dist' defines the installer is accessible as official installer ('dev' means it won't be visible in 'ant choose-installer' command)
- application.projects - defines all Vine projects which should be installed and used within the standalone application (indirectly by using Vine Tookit API)
- application.type - has to be set to 'main' value what means standalone mode
- application.web.blazeDsSupport - web blazeDs support should be switched off

In the installer's directory 'WEB-INF\vine\resources\' you can find configuration file 'Domain.xml' where target resources could be defined.

So our project is present in the directory: $VINESRC\projects\jobmanagertest

Below you can see the 'project.properties' which could be found in directory $VINESRC\projects\jobmanagertest\ant

project.name=jobmanagertest
project.title=JobManager Test
project.priority=4
project.extends=grid,gt2,unicore6,glite3,gt4,grms

Project extends let you use different classes defined in the projects which become a part of the accessible API (in case of web installation in tomcat are placed in jars in shared/lib directory,
in case of standalone in vine/config/lib)

In the test project there is only one example java class - the example of the standalone application:

Package: org.vinetoolkit.jobmanagertest.spi.impl, java class: JobManagerTest.java

Inside it you can see how to use Vine API to use different grid resources defined in Domain.xml

After the 'testStandaloneJobManager' is set as the default (you can use 'ant choose-installer' for this in the $VINESRC directory)
you can install the Vine Toolkit with standalone apps: ant install (latest updates will be downloaded) or ant reinstall (current version from disk will be installed).

After installation is completed you can see new directory '$VINESRC/applications' - it contains Vine Toolkit in standalone mode.

Now we can go to the vine sub directory and use such command to run out test application:

ant -f ant\jobmanagertest.xml > somelog.txt

Logging information are directed to some file to be able to track the execution.
Our application requires a password argument - so you have to provide it after running or add it as the command line argument.
The password is used to create proxy credential as the suitable authentication module is set in the Domain.xml.
(user's certificate and private key have to be present in the '.globus' directory in the user's profile)

Ant script explanation - it is defined in our test project in directory: $VINESRC\projects\jobmanagertest\src\main\app\ant\jobmanagertest.xml
with properties file: $VINESRC\projects\jobmanagertest\src\main\app\ant\jobmanagertest.properties

The properties content is:

vine.app.main.title=Job Manager Test
vine.app.main.classname=org.vinetoolkit.jobmanagertest.spi.impl.JobManagerTest
vine.app.main.jvmargs=

So just the name, the class of the standalone application class with the main method and optional JVM arguments.

The ant script is always the same in all projects except the value for property 'build.properties.file' which has to be set for every project accordingly:

<project default="execute" basedir=".">

    <property name="build.properties.file" value="jobmanagertest.properties"/>
    <dirname property="build.properties.dir" file="./${build.properties.file}"/>
    <property name="build.properties.path" value="${build.properties.dir}/${build.properties.file}"/>

    <!-- =================================================================== -->
    <!-- Executes vine                                                       -->
    <!-- =================================================================== -->
    <target name="execute" description="Executes Vine">

        <ant antfile="../build.xml"
             inheritAll="false"
             target="execute-main">
            <property name="build.properties.path" value="${build.properties.path}"/>
        </ant>

    </target>

</project>

In this way you can run the Vine Toolkit in standalone mode by using standard build routine and accessible scripts.

Of course it is also possible to run it without using ant and properties.

So for example if we put our standalone application directly in the '$VINESRC/applications' directory it is possible to run the application in such way on Windows for example (script is run directly in the $VINESRC/applications directory, our application main class is accessible out there):

@echo on

set CLASSPATH=.
for %%i in (.\vine\config\lib\*.jar) do SET CLASSPATH=!CLASSPATH!;%%i
SET CLASSPATH=!CLASSPATH!;.\vine\config\classes

java -Dvine.app.home=$VINESRC\applications\vine -classpath !CLASSPATH! org.vinetoolkit.jobmanagertest.spi.impl.JobManagerTest 
somePasswordForCredential'

It is important to set 'vine.app.home' environment variable to declare Vine home directory. This way Vine Toolkit could be shipped with some standalone application a part of it. It is enough just to copy 'vine' directory form $VINESRC/applications.

IMPORTANT! Always remember about classloaders dependencies - Vine and its projects uses different technologies, different versions of jars - so please be careful with it, with the 'classpath' argument for the java and other jar libraries used by your standalone application.