Configuring SPADE to use a customized placement policy

This article explains how to configure a SPADE deployment so that data it uses a customized PlacingPolicy class rather than the default, which simply places the file in a directory based on the date contained in the files metadata.

NOTE: As of JEE 7 this article is not longer valid. We are working to provide a suitable update.


It is assumed that the SPADE project has been install and running as outlined here, and that the log output of the JBoss server can be seen in a second terminal.

It is also helpful if you have at least read the "Local Warehouse" scenario in order to familiarize yourself with the concepts discussed there as they will be re-used here. Moreover, as this scenario builds upon the "Customized Metadata" scenario to provide data, you should work through that one first.

Also, as in that scenario, the following environmental variables need to be set. They are show here being set to their standard values.

export WILDFLY_HOME=${HOME}/server/wildfly-9.0.2.Final
export SPADE_VERSION=3.0.1
export SPADE_HOME=${HOME}/nest-spade-war-${SPADE_VERSION}
export SPADE_WAR=${SPADE_HOME}/target/spade-${SPADE_VERSION}.war


The placement of files into SPADE's warehouse is controlled by an implementation of the gov.lbl.nest.spade.policy.PlacingPolicy. To set up a customized PlacingPolicy instance, in this case the MirrorPlacing class, you will need to add the following XML to your spade.xml file as part of the <assembly> element, after the <name> element.


The MirrorPlacing class takes the file's original path from its metadata and uses a new path, created by using the mapping specified in the XML above, to place the file in the warehouse.


Execution of this scenario is the same as the scenario upon which it is built, namely the "Customized Metadata" scenario. The following commands show how to run the whole scenario.

${WILDFLY_HOME}/bin/ --connect --command="deploy \
    --name=spade.war ${SPADE_WAR}"
mkdir -p ~/spade/other/directory/mock
cat > ~/spade/other/directory/scenario/ << EOF
put some junk in here
mkdir -p ~/spade/dropbox/scenario/external
echo "../../other/directory/scenario/" > ~/spade/dropbox/scenario/mock.8.nem
# Wait for the "finisher" for this file to stop, e.g. 5 seconds
sleep 5
# Wait for the "finisher" for this file to stop, e.g. 5 seconds
sleep 5
find ~/spade/warehouse -name "mock.8.*"

As you can see from the last command, the placement in the warehouse of the file is now a function of its original location on its source node.


Having successfully completed this scenario you should now undeploy the application using the following command.

${WILDFLY_HOME}/bin/ --connect --command="undeploy spade.war"