[jboss-cvs] JBossCache/migration/examples/cacheloader-migration ...
Galder Zamarreno
galder.zamarreno at jboss.com
Wed Mar 7 18:32:05 EST 2007
User: gzamarreno
Date: 07/03/07 18:32:05
Added: migration/examples/cacheloader-migration readme.txt
log4j-cache.xml build.bat build.sh build.xml
build.properties
Log:
[JBCACHE-964] Work committed:
- Transforming Cache Loaders implemented and unit tests provided
- migration folder structure. See JIRA.
- build.xml modified to compile, jar, create manifest for migration jar
and also added examples and migration jar to distros.
- example created and tested; it includes readme.txt with details of the
example and how to run it.
Still TODO:
- Unit tests for transforming cache loaders need to run from build.xml
- Documentation for transforming cache loaders in users guide, what are
they, when to use them,...etc.
- Fix JBCACHE-877 that occurrs when unzipping JBossCache-core-2.0.0.BETA2.zip
and running the examples. Workaround is to bring trove.jar into its lib.
- Get examples/cacheloader-migration/build.sh working
- Move JDBCCacheLoaderOld to the migration side. It's not that straightforward due to classes in
/src having dependencies on it. Needs further study.
Revision Changes Path
1.1 date: 2007/03/07 23:32:05; author: gzamarreno; state: Exp;JBossCache/migration/examples/cacheloader-migration/readme.txt
Index: readme.txt
===================================================================
This is an example that illustrates how to migrate existing file or jdbc cache
stores generated with JBoss Cache 1.x to a format that it's readable by JBossCache
2.x.
Both of the examples rely on zipped cache stores containing the following structure
stored in it:
/
/Europe
/Austria {capital="Vienna",currency="Euro",population=8184691}
/England {capital="London",currency="British Pound",population=8184691}
/Albania {capital="Tirana",currency="Lek",population=3563112,area=28748}
/Hungary {capital="Budapest",currency="Forint",population=10006835,area=93030}
The idea of this example, both for the jdbc and the file versions, is to loop through
the data stored in 1.x format, and put it back again in the cache store in 2.x format.
So, in both cases, the example starts creating an instance of a transform*-service.xml
whose only difference with the original one is that it uses a transforming cache loader
which reads in 1.x and writes in 2.x format.
Starting from the root node, the example then loops through the whole cache, which will
delegate the get() calls into the cache store. Each node retrieved is put back into the
cache, which results on the node being put in the new format. You should see INFO level
messages indicating the success of the transformation.
At this point, the transforming cache instance is stopped and destroyed, and a new cache
instance is created with the original cache configuration file, i.e original*-service.xml,
which specifies the traditional cache loader.
The example now loops through the entire cache again, checking that it can get the newly
transformed node and prints out its details.
To run the JDBC cache store version:
- Run "build.bat run.jdbccacheloader.example". It first unzips data/jbossdb-1x.zip into the
current directory and uses this generated DB (Apache Derby) as store for the example.
- Run "build.bat run.filecacheloader.example". It first unzips data/filecacheloader-1x.zip
into the /tmp directory (C:\tmp in Windows) and uses this generated file store for the
example.
1.1 date: 2007/03/07 23:32:05; author: gzamarreno; state: Exp;JBossCache/migration/examples/cacheloader-migration/log4j-cache.xml
Index: log4j-cache.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- ===================================================================== -->
<!-- -->
<!-- Log4j Configuration -->
<!-- -->
<!-- ===================================================================== -->
<!-- $Id: log4j-cache.xml,v 1.1 2007/03/07 23:32:05 gzamarreno Exp $ -->
<!--
| For more configuration infromation and examples see the Jakarta Log4j
| owebsite: http://jakarta.apache.org/log4j
-->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->
<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/tmp/jbosscache.log"/>
<param name="Append" value="false"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<!-- Rollover at the top of each hour
<param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
-->
<!-- param name="Threshold" value="TRACE"/ -->
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
<!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
-->
</layout>
</appender>
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="DEBUG"/>
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c{1}] (%t) %m%n"/>
</layout>
</appender>
<!-- ================ -->
<!-- Limit categories -->
<!-- ================ -->
<!-- Limit JBoss categories to INFO
<category name="org.jboss">
<priority value="INFO"/>
</category>
-->
<!--
| An example of enabling the custom TRACE level priority that is used
| by the JBoss internals to diagnose low level details. This example
| turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
| subpackages. This will produce A LOT of logging output.
<category name="org.jboss.system">
<priority value="TRACE"/>
</category>
-->
<category name="org.jboss.cache">
<priority value="TRACE"/>
</category>
<category name="org.jboss.serial">
<priority value="TRACE"/>
</category>
<category name="org.jboss.tm">
<priority value="WARN"/>
</category>
<category name="org.jgroups">
<priority value="WARN"/>
</category>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
<root>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</log4j:configuration>
1.1 date: 2007/03/07 23:32:05; author: gzamarreno; state: Exp;JBossCache/migration/examples/cacheloader-migration/build.bat
Index: build.bat
===================================================================
@echo off
set ANT_HOME=..\..\ant-dist
REM java -cp %ANT_HOME%/lib/ant.jar;%ANT_HOME%/lib/optional.jar;%ANT_HOME%/lib/junit.jar;%JAVA_HOME%/lib/tools.jar org.apache.tools.ant.Main %*
%ANT_HOME%\bin\ant %*
1.1 date: 2007/03/07 23:32:05; author: gzamarreno; state: Exp;JBossCache/migration/examples/cacheloader-migration/build.sh
Index: build.sh
===================================================================
#!/bin/sh
CACHE_HOME=`dirname $0`
ANT_HOME=$CACHE_HOME/../../ant-dist
CLASSPATH=$ANT_HOME/lib/ant.jar:$ANT_HOME/lib/optional.jar:$ANT_HOME/lib/junit.jar:$JAVA_HOME/lib/tools.jar
# OS specific support (must be 'true' or 'false').
cygwin=false;
case "`uname`" in
CYGWIN*)
cygwin=true
;;
esac
if [ $cygwin = "true" ]; then
# Note that JAVA_HOME evn needs to be set under cygwin explictly,
# /cygdrive/e:/j2sdkxxx, for this to work correctly. Otherwise,
# javac can't be located correctly.
CP=`cygpath -wp $CLASSPATH`
else
CP=$CLASSPATH
fi
#java -cp $CP org.apache.tools.ant.Main "$@"
$ANT_HOME/bin/ant "$@"
1.1 date: 2007/03/07 23:32:05; author: gzamarreno; state: Exp;JBossCache/migration/examples/cacheloader-migration/build.xml
Index: build.xml
===================================================================
<?xml version="1.0"?>
<project name="JBossCache examples Cache Loader Migration" default="help">
<property file="./build.properties"/>
<property name="output" value="${basedir}/output"/>
<property name="source" value="${basedir}/src"/>
<property name="resources" value="${basedir}/resources"/>
<property name="data" value="${basedir}/data"/>
<property name="build" value="${output}/classes"/>
<property name="db.dir" value="jbossdb-1x"/>
<property name="db.zip" value="jbossdb-1x.zip"/>
<property name="tmp.dir" value="/tmp"/>
<property name="filestore.dir" value="filecacheloader-1x"/>
<property name="filestore.zip" value="filecacheloader-1x.zip"/>
<path id="lib.classpath">
<fileset dir="${cache.lib}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="user.classpath">
<pathelement path="${build}"/>
<path refid="lib.classpath"/>
</path>
<target name="help" description="help page">
<echo message="build.sh <command> where command is:"/>
<echo message=" compile -- compile the examples code"/>
<echo message=" run.jdbccacheloader.example -- run JDBC store migration example"/>
<echo message=" run.filecacheloader.example -- run file store migration example"/>
</target>
<target name="init" description="Prepare to build.">
<tstamp/>
<mkdir dir="${build}"/>
</target>
<target name="clean" description="Clean up compiled classes">
<delete dir="${output}"/>
<delete dir="${db.dir}"/>
</target>
<target name="compile" depends="init" description="Build example">
<javac srcdir="${source}"
destdir="${build}"
includes="**/**"
debug="true"
deprecation="true">
<classpath>
<path refid="lib.classpath"/>
</classpath>
</javac>
<copy todir="${build}">
<fileset dir="${resources}">
<include name="**/*"/>
</fileset>
</copy>
</target>
<target name="run.jdbccacheloader.example" depends="compile" description="run JDBC store migration example.">
<delete dir="${db.dir}"/>
<unzip src="${data}/${db.zip}" dest="."/>
<java classname="examples.TransformStore" fork="yes">
<jvmarg value="-Dcacheloader.type=jdbccl"/>
<jvmarg value="-Dlog4j.configuration=file:/${basedir}/log4j-cache.xml"/>
<classpath refid="lib.classpath"/>
<classpath path="${build}"/>
</java>
</target>
<target name="run.filecacheloader.example" depends="compile" description="run file store migration example.">
<delete dir="${tmp.dir}/${filestore.dir}"/>
<mkdir dir="${tmp.dir}"/>
<unzip src="${data}/${filestore.zip}" dest="${tmp.dir}"/>
<java classname="examples.TransformStore" fork="yes">
<jvmarg value="-Dcacheloader.type=fcl"/>
<jvmarg value="-Dlog4j.configuration=file:/${basedir}/log4j-cache.xml"/>
<classpath refid="lib.classpath"/>
<classpath path="${build}"/>
</java>
</target>
</project>
1.1 date: 2007/03/07 23:32:05; author: gzamarreno; state: Exp;JBossCache/migration/examples/cacheloader-migration/build.properties
Index: build.properties
===================================================================
# set up environment
#
#
# Below should be transparent to you.
#
# basedir is a project attribute
#
# create directory structure
#
cachehome=${basedir}/../..
cache.lib=${cachehome}/lib
#Directory for Junit test result. Subdirectory html contains the result in html format.
reports=${output}/reports
More information about the jboss-cvs-commits
mailing list