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.
<activity> <name>placer-inbound</name> <policy> <class>gov.lbl.nest.spade.policy.impl.MirrorPlacing</class> <init-param> <param-name>mapping</param-name> <param-value>localhost:/home/spade/spade/dropbox/scenario/../../other=example</param-value> </init-param> </policy> </activity>
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/jboss-cli.sh --connect --command="deploy \ --name=spade.war ${SPADE_WAR}" mkdir -p ~/spade/other/directory/mock cat > ~/spade/other/directory/scenario/mock.8.data << EOF put some junk in here EOF mkdir -p ~/spade/dropbox/scenario/external echo "../../other/directory/scenario/mock.8.data" > ~/spade/dropbox/scenario/mock.8.nem ${SPADE_HOME}/src/main/bash/localScan # Wait for the "finisher" for this file to stop, e.g. 5 seconds sleep 5 ${SPADE_HOME}/src/main/bash/inboundScan # Wait for the "finisher" for this file to stop, e.g. 5 seconds sleep 5 ${SPADE_HOME}/src/main/bash/sendConfirmations 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.