You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ab...@apache.org on 2016/02/17 19:23:43 UTC
[39/51] [partial] incubator-geode git commit: GEODE-917: rename
gemfire subprojects to geode
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/session/bin/cacheserver.bat
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/session/bin/cacheserver.bat b/extensions/geode-modules-assembly/release/session/bin/cacheserver.bat
new file mode 100755
index 0000000..2935cde
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/session/bin/cacheserver.bat
@@ -0,0 +1,56 @@
+@echo off
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements. See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License. You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+rem
+
+setlocal enableextensions
+set scriptdir=%~dp0
+set gf=%scriptdir:\bin\=%
+
+set GEMFIRE_JARS=%gf%\lib\gemfire.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\antlr.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\spring-core-3.1.1.RELEASE.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\spring-shell-1.0.0.RC1.jar
+if exist "%GEMFIRE_JARS%" goto gfok
+echo Could not determine GEMFIRE location
+verify other 2>nul
+goto done
+:gfok
+
+REM Initialize classpath
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\geode-modules-@GEMFIRE_MODULES_VERSION@.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\geode-modules-session-@GEMFIRE_MODULES_VERSION@.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\geode-modules-session-external-@GEMFIRE_MODULES_VERSION@.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\servlet-api-@SERVLET_API_VERSION@.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\slf4j-api-@SLF4J_VERSION@.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\slf4j-jdk14-@SLF4J_VERSION@.jar
+
+REM Add conf directory
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\conf
+
+if defined CLASSPATH set GEMFIRE_JARS=%GEMFIRE_JARS%;%CLASSPATH%
+
+if not defined GF_JAVA (
+REM %GF_JAVA% is not defined, assume it is on the PATH
+set GF_JAVA=java
+)
+
+"%GF_JAVA%" %JAVA_ARGS% -classpath "%GEMFIRE_JARS%" com.gemstone.gemfire.internal.cache.CacheServerLauncher %*
+:done
+set scriptdir=
+set gf=
+set GEMFIRE_JARS=
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/session/bin/cacheserver.sh
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/session/bin/cacheserver.sh b/extensions/geode-modules-assembly/release/session/bin/cacheserver.sh
new file mode 100755
index 0000000..2c12b57
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/session/bin/cacheserver.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Set GEMFIRE to the product toplevel directory
+GEMFIRE=`dirname $0`
+OLDPWD=$PWD
+cd $GEMFIRE
+GEMFIRE=`dirname $PWD`
+cd $OLDPWD
+
+if [ "x$WINDIR" != "x" ]; then
+ echo "ERROR: The variable WINDIR is set indicating this script is running in a Windows OS, please use the .bat file version instead."
+ exit 1
+fi
+
+GEMFIRE_JARS=$GEMFIRE/lib/gemfire.jar
+
+if [ ! -f "${GEMFIRE_JARS}" ]; then
+ echo "ERROR: Could not determine GEMFIRE location."
+ exit 1
+fi
+
+LOG4J_API=$( ls $GEMFIRE/lib/log4j-api*jar )
+LOG4J_CORE=$( ls $GEMFIRE/lib/log4j-core*jar )
+
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/antlr.jar:$LOG4J_API:$LOG4J_CORE
+
+# Initialize classpath
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/geode-modules-@GEMFIRE_MODULES_VERSION@.jar \
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/geode-modules-session-@GEMFIRE_MODULES_VERSION@.jar \
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/servlet-api-@SERVLET_API_VERSION@.jar \
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/geode-modules-session-external-@GEMFIRE_MODULES_VERSION@.jar \
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/slf4j-api-@SLF4J_VERSION@.jar \
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/slf4j-jdk14-@SLF4J_VERSION@.jar
+
+# Add configuration
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/conf
+
+if [ "x$CLASSPATH" != "x" ]; then
+ GEMFIRE_JARS=$GEMFIRE_JARS:$CLASSPATH
+fi
+
+${GF_JAVA:-java} ${JAVA_ARGS} -classpath ${GEMFIRE_JARS} com.gemstone.gemfire.internal.cache.CacheServerLauncher "$@"
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/session/bin/gemfire.bat
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/session/bin/gemfire.bat b/extensions/geode-modules-assembly/release/session/bin/gemfire.bat
new file mode 100755
index 0000000..a66964c
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/session/bin/gemfire.bat
@@ -0,0 +1,53 @@
+@echo off
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements. See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License. You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+rem
+
+setlocal enableextensions
+set scriptdir=%~dp0
+set gf=%scriptdir:\bin\=%
+
+set GEMFIRE_JARS=%gf%\lib\gemfire.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\antlr.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\spring-core-3.1.1.RELEASE.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\spring-shell-1.0.0.RC1.jar
+if exist "%GEMFIRE_JARS%" goto gfok
+echo Could not determine GEMFIRE location
+verify other 2>nul
+goto done
+:gfok
+
+REM Initialize classpath
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\geode-modules-@GEMFIRE_MODULES_VERSION@.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\geode-modules-session-@GEMFIRE_MODULES_VERSION@.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\geode-modules-session-external-@GEMFIRE_MODULES_VERSION@.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\servlet-api-@SERVLET_API_VERSION@.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\slf4j-api-@SLF4J_VERSION@.jar
+set GEMFIRE_JARS=%GEMFIRE_JARS%;%gf%\lib\slf4j-jdk14-@SLF4J_VERSION@.jar
+
+if defined CLASSPATH set GEMFIRE_JARS=%GEMFIRE_JARS%;%CLASSPATH%
+
+if not defined GF_JAVA (
+REM %GF_JAVA% is not defined, assume it is on the PATH
+set GF_JAVA=java
+)
+
+"%GF_JAVA%" %JAVA_ARGS% -classpath "%GEMFIRE_JARS%" com.gemstone.gemfire.internal.SystemAdmin %*
+:done
+set scriptdir=
+set gf=
+set GEMFIRE_JARS=
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/session/bin/gemfire.sh
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/session/bin/gemfire.sh b/extensions/geode-modules-assembly/release/session/bin/gemfire.sh
new file mode 100755
index 0000000..ac11a4d
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/session/bin/gemfire.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Set GEMFIRE to the product toplevel directory
+GEMFIRE=`dirname $0`
+OLDPWD=$PWD
+cd $GEMFIRE
+GEMFIRE=`dirname $PWD`
+cd $OLDPWD
+
+if [ "x$WINDIR" != "x" ]; then
+ echo "ERROR: The variable WINDIR is set indicating this script is running in a Windows OS, please use the .bat file version instead."
+ exit 1
+fi
+
+GEMFIRE_JARS=$GEMFIRE/lib/gemfire.jar
+if [ ! -f "${GEMFIRE_JARS}" ]; then
+ echo "ERROR: Could not determine GEMFIRE location."
+ exit 1
+fi
+
+LOG4J_API=$( ls $GEMFIRE/lib/log4j-api*jar )
+LOG4J_CORE=$( ls $GEMFIRE/lib/log4j-core*jar )
+
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/antlr.jar:$LOG4J_API:$LOG4J_CORE
+
+# Initialize classpath
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/geode-modules-@GEMFIRE_MODULES_VERSION@.jar
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/geode-modules-session-@GEMFIRE_MODULES_VERSION@.jar
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/geode-modules-session-external-@GEMFIRE_MODULES_VERSION@.jar
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/servlet-api-@SERVLET_API_VERSION@.jar
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/slf4j-api-@SLF4J_VERSION@.jar
+GEMFIRE_JARS=$GEMFIRE_JARS:$GEMFIRE/lib/slf4j-jdk14-@SLF4J_VERSION@.jar
+
+if [ "x$CLASSPATH" != "x" ]; then
+ GEMFIRE_JARS=$GEMFIRE_JARS:$CLASSPATH
+fi
+
+# Command line args that start with -J will be passed to the java vm in JARGS.
+# See java --help for a listing of valid vm args.
+# Example: -J-Xmx1g sets the max heap size to 1 gigabyte.
+
+JARGS=
+GEMFIRE_ARGS=
+for i in "$@"
+do
+ if [ "-J" == "${i:0:2}" ]
+ then
+ JARGS="${JARGS} \"${i#-J}\""
+ else
+ GEMFIRE_ARGS="${GEMFIRE_ARGS} \"${i}\""
+ fi
+done
+
+eval ${GF_JAVA:-java} ${JAVA_ARGS} ${JARGS} -classpath ${GEMFIRE_JARS} com.gemstone.gemfire.internal.SystemAdmin ${GEMFIRE_ARGS}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/session/bin/modify_war
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/session/bin/modify_war b/extensions/geode-modules-assembly/release/session/bin/modify_war
new file mode 100755
index 0000000..9c87104
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/session/bin/modify_war
@@ -0,0 +1,392 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+X=`dirname $0`
+EXE_DIR=`cd $X; pwd`
+LIB_DIR=`cd ${X}/../lib; pwd`
+
+SESSION_JAR="${LIB_DIR}/geode-modules-session-external-@GEMFIRE_MODULES_VERSION@.jar"
+
+declare -a OTHER_JARS
+OTHER_JARS=(${LIB_DIR}/gemfire.jar \
+ ${LIB_DIR}/antlr.jar
+ ${LIB_DIR}/geode-modules-@GEMFIRE_MODULES_VERSION@.jar \
+ ${LIB_DIR}/geode-modules-session-@GEMFIRE_MODULES_VERSION@.jar \
+ ${LIB_DIR}/slf4j-api-@SLF4J_VERSION@.jar)
+
+# This is required for GemFire 8.1
+LOG4J_API=$(ls ${LIB_DIR}/log4j-api*jar)
+LOG4J_CORE=$(ls ${LIB_DIR}/log4j-core*jar)
+if [ -f ${LOG4J_API} -a -f ${LOG4J_CORE} ]; then
+ OTHER_JARS[${#OTHER_JARS[*]}]=$LOG4J_API
+ OTHER_JARS[${#OTHER_JARS[*]}]=$LOG4J_CORE
+fi
+
+TMP_DIR="/tmp/modify_war.$$"
+
+ARG_INPUT_FILE=""
+ARG_WAR_LIB_DIR="WEB-INF/lib"
+ARG_EAR_LIB_DIR="lib"
+ARG_OUTPUT_FILE=""
+ARG_TEST_RUN=0
+ARG_CACHE_TYPE="peer-to-peer"
+ARG_PROCESS_LIBS=1
+declare -a ARG_GEMFIRE_PARAMETERS=""
+declare -a ARG_WAR_LIBS="$SESSION_JAR"
+declare -a ARG_EAR_LIBS=""
+declare -a ARG_JVM_OPTS=""
+
+function usage() {
+ cat <<EOF
+USAGE: modify_war <args>
+WHERE <args>:
+
+ -e <jar>
+ Assumes the input file is an .ear file and will add the
+ given jar as a shared, application library. The file will
+ be added in a /lib directory (by default) and any embedded
+ .war files will have a corresponding Class-Path entry added
+ to their MANIFEST.MF file. The option can be given multiple times.
+
+ -h
+ Displays this help message.
+
+ -j <jar>
+ Additional library to add to the input file. Can be given
+ multiple times.
+
+ -J <jvm opt>
+ JVM argument to pass to sub-commands. Typically this might
+ be to define proxy values. For example -J"-Dhttp.proxyHost=my-proxy"
+
+ -l <lib>
+ Library directory where new jars will be placed inside war.
+ Defaults to WEB-INF/lib.
+
+ -m <lib>
+ Library directory where new jars will be placed inside ear.
+ Defaults to /lib.
+
+ -o <file>
+ The output file.
+
+ -p <param=value>
+ Specific parameter for inclusion into the session filter
+ definition as a regular init-param. Can be given multiple times.
+
+ -r
+ Test run which only outputs an updated web.xml file.
+
+ -t <cache-type>
+ Type of cache. Must be one of 'peer-to-peer' or
+ 'client-server'. Default is peer-to-peer.
+
+ -v
+ Verbose output
+
+ -w <war/ear file>
+ The input file - either a WAR or EAR. The following actions
+ will be performed depending on the type of file:
+ WARs will have a <filter> element added to the web.xml and
+ will have the appropriate jars copied to WEB-INF/lib.
+ If the file is an EAR, then the appropriate jars will be
+ copied to lib, within the ear and each embedded war files'
+ manifest will have a Class-Path entry added (if one does
+ not already exist).
+ An appropriate slf4j binding jar must be included for ears
+ or wars using -e or -j respectively. The following jars are
+ provided:
+ slf4j-jdk14
+ slf4j-log4j12
+ geode-modules-slf4j-weblogic
+
+ -x
+ Do not create a self-contained war/ear file by copying all
+ necessary jars into the file. When this option is used,
+ additional jars will need to be made available to the
+ container:
+ gemfire.jar
+ geode-modules.jar
+ geode-modules-session.jar
+ slf4j-api.jar
+ slf4j-jdk14.jar (not for WebLogic)
+ geode-modules-slf4j-weblogic.jar (WebLogic only)
+ This option still modifes any web.xml files.
+
+EOF
+}
+
+
+# Two logging levels - 'I'nfo and 'D'ebug
+function log() {
+ local MSG=$1
+ local LVL=${2:-I}
+
+ if [ "$LVL" == "D" ]; then
+ if [ -n "$DEBUG" ]; then
+ echo "$(date '+%Y-%m-%d %H:%M:%S') $LVL $MSG" >&2
+ fi
+ else
+ echo "$(date '+%Y-%m-%d %H:%M:%S') $LVL $MSG" >&2
+ fi
+}
+
+
+function exiting() {
+ local MSG=$1
+ local CODE=${2:-0}
+
+ if [ -n "$MSG" ]; then
+ echo "ERROR: $MSG"
+ fi
+
+ rm -rf $TMP_DIR
+ exit $CODE
+}
+
+
+function add_war_jars() {
+ local WAR_LIB_DIR=$1/$ARG_WAR_LIB_DIR/
+ mkdir -p $WAR_LIB_DIR
+
+ log "Copying jar(s) into war's '$ARG_WAR_LIB_DIR' directory" D
+ for J in ${ARG_WAR_LIBS[*]}; do
+ log " $J" D
+ cp $J $WAR_LIB_DIR || exiting "Unable to copy $J to temp location $WAR_LIB_DIR" 1
+ done
+}
+
+
+function process_manifest() {
+ local MANIFEST=$1
+ local TMP_MANIFEST
+
+ log "Processing manifest $MANIFEST" D
+
+ CP_LIBS=""
+ for J in ${OTHER_JARS[*]} ${ARG_EAR_LIBS[*]}; do
+ CP_LIBS="$CP_LIBS $ARG_EAR_LIB_DIR/$(basename $J)"
+ done
+
+ TMP_MANIFEST="$TMP_DIR/manifest.mf.$$"
+ cp $MANIFEST $TMP_MANIFEST
+
+ awk -v CP_LIBS="$CP_LIBS" '
+ BEGIN {
+ cp = 0
+ split(CP_LIBS, cp_array)
+ }
+ /^Class-Path/ {print $0 CP_LIBS; cp = 1; getline}
+ /^ *\r?$/ {
+ if (cp == 0) {
+ print "Class-Path:" CP_LIBS
+ cp = 1
+ }
+ }
+ {print $0}
+ END { if (cp == 0) print "Class-Path:" CP_LIBS }
+ ' $TMP_MANIFEST > $MANIFEST
+
+ rm $TMP_MANIFEST
+}
+
+
+function process_web_xml() {
+ local WORK_DIR=$1
+ local ARG_P=""
+ local JVM_OPTS=""
+
+ for i in ${ARG_GEMFIRE_PARAMETERS[*]}; do
+ ARG_P="$ARG_P -p $i"
+ done
+
+ for j in ${ARG_JVM_OPTS[*]}; do
+ JVM_OPTS="$JVM_OPTS $j"
+ done
+
+ WEB_XML=$(find $WORK_DIR -name web.xml)
+ TMP_WEB_XML="${WORK_DIR}/web.xml.$$"
+ JAVA_CMD="java $JVM_OPTS -jar $SESSION_JAR $ARG_P -t $ARG_CACHE_TYPE -w $WEB_XML"
+ log "Executing java cmd: $JAVA_CMD" D
+
+ if [ $ARG_TEST_RUN -eq 0 ]; then
+ eval $JAVA_CMD > $TMP_WEB_XML || exiting "Error updating web.xml" 1
+ cp $TMP_WEB_XML $WEB_XML
+ rm -f $TMP_WEB_XML
+ else
+ eval $JAVA_CMD || exiting "Error updating web.xml" 1
+ fi
+}
+
+
+function process_input_file() {
+ local WORK_DIR=$1
+
+ if [[ "$ARG_INPUT_FILE" =~ \.war$ ]]; then
+ process_web_xml $WORK_DIR
+ add_war_jars $WORK_DIR
+ return
+ fi
+
+ WAR_LIST=$( find $WORK_DIR -name '*.war' )
+ for WAR in $WAR_LIST; do
+ log "Processing embedded war file $WAR" D
+ TMP_WAR_DIR="${WAR}.$$"
+
+ log "Unzipping war to $TMP_WAR_DIR" D
+ unzip -q -o -d $TMP_WAR_DIR $WAR
+
+ process_web_xml $TMP_WAR_DIR
+ if [ $ARG_TEST_RUN -eq 0 ]; then
+ add_war_jars $TMP_WAR_DIR
+
+ MANIFEST=$( find $TMP_WAR_DIR -name MANIFEST.MF )
+
+ if [ $ARG_PROCESS_LIBS -eq 1 -a -n "$MANIFEST" ]; then
+ process_manifest $MANIFEST
+ fi
+
+ log "Creating new war $WAR" D
+ if [ -n "$MANIFEST" ]; then
+ jar cmf $MANIFEST $WAR -C $TMP_WAR_DIR .
+ else
+ jar cf $WAR -C $TMP_WAR_DIR .
+ fi
+ fi
+
+ rm -rf $TMP_WAR_DIR
+ done
+}
+
+trap exiting INT QUIT TERM
+
+mkdir $TMP_DIR
+
+CMD_ARGS="-j $SESSION_JAR"
+
+while getopts "e:hj:J:l:m:o:p:rt:vw:x" OPT; do
+ case $OPT in
+ e)
+ if [ ! -f $OPTARG ]; then
+ exiting "Cannot read file '$OPTARG' given with option -e" 1
+ fi
+ ARG_EAR_LIBS[${#ARG_EAR_LIBS[@]}]=$OPTARG
+ ;;
+ h)
+ usage
+ exiting "" 1
+ ;;
+ j)
+ if [ ! -f $OPTARG ]; then
+ exiting "Cannot read file '$OPTARG' given with option -j" 1
+ fi
+ ARG_WAR_LIBS[${#ARG_WAR_LIBS[@]}]=$OPTARG
+ ;;
+ J)
+ ARG_JVM_OPTS[${#ARG_JVM_OPTS[@]}]=$OPTARG
+ ;;
+ l)
+ ARG_WAR_LIB_DIR=$OPTARG
+ ;;
+ m)
+ ARG_EAR_LIB_DIR=$OPTARG
+ ;;
+ o)
+ ARG_OUTPUT_FILE=$OPTARG
+ ;;
+ p)
+ ARG_GEMFIRE_PARAMETERS[${#ARG_GEMFIRE_PARAMETERS[@]}]=$OPTARG
+ ;;
+ r)
+ ARG_TEST_RUN=1
+ ;;
+ t)
+ case $OPTARG in
+ peer-to-peer|client-server)
+ ARG_CACHE_TYPE=$OPTARG
+ ;;
+ *)
+ exiting "Invalid cache type '$OPTARG' given with option -t. Options are 'peer-to-peer' or 'client-server'." 1
+ ;;
+ esac
+ ;;
+ v)
+ DEBUG=1
+ ;;
+ w)
+ if [ ! -f $OPTARG ]; then
+ exiting "Cannot read file '$OPTARG' given with option -w" 1
+ fi
+ ARG_INPUT_FILE=$OPTARG
+ ;;
+ x)
+ ARG_PROCESS_LIBS=0
+ ;;
+ [?])
+ echo "Unknown option '$OPTARG'"
+ echo
+ usage
+ exit 1
+ ;;
+ :)
+ echo "Option '$OPTARG' requires an argument"
+ echo
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+# Some validation
+if [ -z "$ARG_INPUT_FILE" ]; then
+ exiting "Please supply an input file with the -w option" 1
+fi
+
+if [ -z "$ARG_OUTPUT_FILE" ]; then
+ ARG_OUTPUT_FILE="sessions-$(basename $ARG_INPUT_FILE)"
+fi
+
+if [[ "$ARG_INPUT_FILE" =~ \.war$ && -n "${ARG_EAR_LIBS[*]}" ]]; then
+ log "Input file appears to be a war but -e also specified. EAR processing will be skipped." W
+fi
+
+if [[ "$ARG_INPUT_FILE" =~ \.war$ && $ARG_PROCESS_LIBS -eq 1 ]]; then
+ for J in ${OTHER_JARS[*]}; do
+ ARG_WAR_LIBS[${#ARG_WAR_LIBS[@]}]=$J
+ done
+fi
+
+unzip -q -o -d $TMP_DIR $ARG_INPUT_FILE
+process_input_file $TMP_DIR
+
+if [[ $ARG_TEST_RUN -eq 0 && $ARG_PROCESS_LIBS -eq 1 && "$ARG_INPUT_FILE" =~ \.ear$ ]]; then
+ log "Copying additional jars into ear's '$ARG_EAR_LIB_DIR' directory" D
+ mkdir -p $TMP_DIR/$ARG_EAR_LIB_DIR
+ for i in ${OTHER_JARS[*]} ${ARG_EAR_LIBS[*]}; do
+ log " $i" D
+ cp $i $TMP_DIR/$ARG_EAR_LIB_DIR/ || exiting "Unable to copy $i to $TMP_DIR/$ARG_EAR_LIB_DIR" 1
+ done
+fi
+
+if [ $ARG_TEST_RUN -eq 0 ]; then
+ mkdir -p $TMP_DIR/META-INF
+ touch $TMP_DIR/META-INF/MANIFEST.MF
+ jar cmf $TMP_DIR/META-INF/MANIFEST.MF $ARG_OUTPUT_FILE -C $TMP_DIR .
+ log "Created file: $ARG_OUTPUT_FILE" I
+fi
+
+exiting
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/session/bin/setenv.properties
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/session/bin/setenv.properties b/extensions/geode-modules-assembly/release/session/bin/setenv.properties
new file mode 100644
index 0000000..fc8918b
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/session/bin/setenv.properties
@@ -0,0 +1,6 @@
+java.opt.1=-Xms${initial.vm.heap.size.mb:512}M
+java.opt.2=-Xmx${maximum.vm.heap.size.mb:512}M
+java.opt.hotspot.1=-XX:+UseParNewGC
+java.opt.hotspot.2=-XX:+UseConcMarkSweepGC
+java.opt.hotspot.3=-XX:CMSInitiatingOccupancyFraction=${cms.initiating.heap.percentage:50}
+java.opt.j9.1=-Xgcpolicy:gencon
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-7/context-fragment.xml
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-7/context-fragment.xml b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-7/context-fragment.xml
new file mode 100644
index 0000000..72faee2
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-7/context-fragment.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Context>
+
+ <remove:Manager className="com.gemstone.gemfire.modules.session.catalina.Tomcat6DeltaSessionManager"/>
+
+ <add:Manager className="com.gemstone.gemfire.modules.session.catalina.Tomcat7DeltaSessionManager"
+ enableDebugListener="${enable.debug.listener:false}"
+ enableGatewayReplication="${enable.gateway.replication:false}"
+ enableLocalCache="${enable.local.cache:true}"
+ enableCommitValve="${enable.commit.valve:true}"
+ preferDeserializedForm="${prefer.deserialized.form:true}"
+ regionAttributesId="${region.attributes.id:PARTITION_REDUNDANT}"
+ regionName="${region.name:gemfire_modules_sessions}"/>
+
+</Context>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-7/modules.env
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-7/modules.env b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-7/modules.env
new file mode 100644
index 0000000..1c14a6c
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-7/modules.env
@@ -0,0 +1 @@
+TOMCAT_MAJOR_VER=7
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-8/context-fragment.xml
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-8/context-fragment.xml b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-8/context-fragment.xml
new file mode 100644
index 0000000..72faee2
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-8/context-fragment.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Context>
+
+ <remove:Manager className="com.gemstone.gemfire.modules.session.catalina.Tomcat6DeltaSessionManager"/>
+
+ <add:Manager className="com.gemstone.gemfire.modules.session.catalina.Tomcat7DeltaSessionManager"
+ enableDebugListener="${enable.debug.listener:false}"
+ enableGatewayReplication="${enable.gateway.replication:false}"
+ enableLocalCache="${enable.local.cache:true}"
+ enableCommitValve="${enable.commit.valve:true}"
+ preferDeserializedForm="${prefer.deserialized.form:true}"
+ regionAttributesId="${region.attributes.id:PARTITION_REDUNDANT}"
+ regionName="${region.name:gemfire_modules_sessions}"/>
+
+</Context>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-8/modules.env
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-8/modules.env b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-8/modules.env
new file mode 100644
index 0000000..d220675
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs-tomcat-8/modules.env
@@ -0,0 +1 @@
+TOMCAT_MAJOR_VER=8
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/configuration-prompts.properties
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/configuration-prompts.properties b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/configuration-prompts.properties
new file mode 100644
index 0000000..0ebae97
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/configuration-prompts.properties
@@ -0,0 +1,17 @@
+cache.configuration.file=Please enter the name of the GemFire cache configuration file. Default '${default}':
+critical.heap.percentage=Please enter the percentage of heap at which updates to the cache are refused. 0.0 means disabled. Default '${default}':
+enable.debug.listener=Please specify whether to enable a GemFire listener that logs session create, update, destroy and expiration events. Default '${default}':
+enable.gateway.replication=Please specify whether session modifications should be replicated across the WAN. Default '${default}':
+enable.local.cache=Please specify whether to maintain a local GemFire cache. Default '${default}':
+enable.commit.valve=Please specify whether to commit sessions once per request. Default '${default}':
+prefer.deserialized.form=Please specify whether to prefer keeping attributes in deserialized form. Default '${default}':
+eviction.heap.percentage=Please enter the percentage of heap at which sessions will be evicted from the local cache. Default '${default}':
+log.file=Please enter the name of the file used to log GemFire messages. Default '${default}':
+region.attributes.id=Please enter the id of the attributes of the GemFire region used to cache sessions. Default '${default}':
+region.name=Please enter the name of the GemFire region used to cache sessions. Default '${default}':
+statistic.archive.file=Please enter the name of the file used to store GemFire statistics. Default '${default}':
+statistic.sampling.enabled=Please specify whether GemFire statistic sampling should be enabled. Default '${default}':
+initial.vm.heap.size.mb=Please specify the initial VM heap size in MB (-Xms). Default '${default}':
+maximum.vm.heap.size.mb=Please specify the maximum VM heap size in MB (-Xmx). Default '${default}':
+cms.initiating.heap.percentage=Please specify the percentage of VM heap utilization before a concurrent collection is initiated (--XX:CMSInitiatingOccupancyFraction [Hotspot-only]). Default '${default}':
+tomcat.version=Please enter the major version of Tomcat you will be using (6, 7 or 8). Default '${default}'
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/context-fragment.xml
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/context-fragment.xml b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/context-fragment.xml
new file mode 100644
index 0000000..fac3044
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/context-fragment.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Context>
+
+ <add:Manager className="com.gemstone.gemfire.modules.session.catalina.Tomcat6DeltaSessionManager"
+ enableDebugListener="${enable.debug.listener:false}"
+ enableGatewayReplication="${enable.gateway.replication:false}"
+ enableLocalCache="${enable.local.cache:true}"
+ enableCommitValve="${enable.commit.valve:true}"
+ preferDeserializedForm="${prefer.deserialized.form:true}"
+ regionAttributesId="${region.attributes.id:PARTITION_REDUNDANT}"
+ regionName="${region.name:gemfire_modules_sessions}"/>
+
+</Context>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/modules.env
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/modules.env b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/modules.env
new file mode 100644
index 0000000..9c4c00a
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/modules.env
@@ -0,0 +1 @@
+TOMCAT_MAJOR_VER=6
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/server-fragment.xml
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/server-fragment.xml b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/server-fragment.xml
new file mode 100644
index 0000000..c4adc66
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-cs/server-fragment.xml
@@ -0,0 +1,12 @@
+<?xml version='1.0' encoding='utf-8'?>
+<Server>
+
+ <add:Listener className="com.gemstone.gemfire.modules.session.catalina.ClientServerCacheLifecycleListener"
+ cache-xml-file="${cache.configuration.file:cache-client.xml}"
+ criticalHeapPercentage="${critical.heap.percentage:0.0}"
+ evictionHeapPercentage="${eviction.heap.percentage:80.0}"
+ log-file="${log.file:gemfire_modules.log}"
+ statistic-archive-file="${statistic.archive.file:gemfire_modules.gfs}"
+ statistic-sampling-enabled="${statistic.sampling.enabled:false}"/>
+
+</Server>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-7/context-fragment.xml
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-7/context-fragment.xml b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-7/context-fragment.xml
new file mode 100644
index 0000000..155aa2a
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-7/context-fragment.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Context>
+
+ <remove:Manager className="com.gemstone.gemfire.modules.session.catalina.Tomcat6DeltaSessionManager"/>
+
+ <add:Manager className="com.gemstone.gemfire.modules.session.catalina.Tomcat7DeltaSessionManager"
+ enableDebugListener="${enable.debug.listener:false}"
+ enableGatewayReplication="${enable.gateway.replication:false}"
+ enableLocalCache="${enable.local.cache:false}"
+ enableCommitValve="${enable.commit.valve:true}"
+ preferDeserializedForm="${prefer.deserialized.form:true}"
+ regionAttributesId="${region.attributes.id:REPLICATE}"
+ regionName="${region.name:gemfire_modules_sessions}"/>
+
+</Context>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-7/modules.env
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-7/modules.env b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-7/modules.env
new file mode 100644
index 0000000..1c14a6c
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-7/modules.env
@@ -0,0 +1 @@
+TOMCAT_MAJOR_VER=7
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-8/context-fragment.xml
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-8/context-fragment.xml b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-8/context-fragment.xml
new file mode 100644
index 0000000..155aa2a
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-8/context-fragment.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Context>
+
+ <remove:Manager className="com.gemstone.gemfire.modules.session.catalina.Tomcat6DeltaSessionManager"/>
+
+ <add:Manager className="com.gemstone.gemfire.modules.session.catalina.Tomcat7DeltaSessionManager"
+ enableDebugListener="${enable.debug.listener:false}"
+ enableGatewayReplication="${enable.gateway.replication:false}"
+ enableLocalCache="${enable.local.cache:false}"
+ enableCommitValve="${enable.commit.valve:true}"
+ preferDeserializedForm="${prefer.deserialized.form:true}"
+ regionAttributesId="${region.attributes.id:REPLICATE}"
+ regionName="${region.name:gemfire_modules_sessions}"/>
+
+</Context>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-8/modules.env
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-8/modules.env b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-8/modules.env
new file mode 100644
index 0000000..d220675
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p-tomcat-8/modules.env
@@ -0,0 +1 @@
+TOMCAT_MAJOR_VER=8
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/configuration-prompts.properties
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/configuration-prompts.properties b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/configuration-prompts.properties
new file mode 100644
index 0000000..fdead44
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/configuration-prompts.properties
@@ -0,0 +1,19 @@
+cache.configuration.file=Please enter the name of the GemFire cache configuration file. Default '${default}':
+critical.heap.percentage=Please enter the percentage of heap at which updates to the cache are refused. 0.0 means disabled. Default '${default}':
+enable.debug.listener=Please specify whether to enable a GemFire listener that logs session create, update, destroy and expiration events. Default '${default}':
+enable.gateway.replication=Please specify whether session modifications should be replicated across the WAN. Default '${default}':
+enable.local.cache=Please specify whether to maintain a local GemFire cache. Default '${default}':
+enable.commit.valve=Please specify whether to commit sessions once per request. Default '${default}':
+prefer.deserialized.form=Please specify whether to prefer keeping attributes in deserialized form. Default '${default}':
+eviction.heap.percentage=Please enter the percentage of heap at which sessions will be evicted from the local cache. Default '${default}':
+locators=Please enter the list of locators used by GemFire members to discover each other. The format is a comma-separated list of host[port]. Default '${default}':
+log.file=Please enter the name of the file used to log GemFire messages. Default '${default}':
+rebalance=Please specify whether to rebalance the GemFire cache at startup. Default '${default}':
+region.attributes.id=Please enter the id of the attributes of the GemFire region used to cache sessions. Default '${default}':
+region.name=Please enter the name of the GemFire region used to cache sessions. Default '${default}':
+statistic.archive.file=Please enter the name of the file used to store GemFire statistics. Default '${default}':
+statistic.sampling.enabled=Please specify whether GemFire statistic sampling should be enabled. Default '${default}':
+initial.vm.heap.size.mb=Please specify the initial VM heap size in MB (-Xms). Default '${default}':
+maximum.vm.heap.size.mb=Please specify the maximum VM heap size in MB (-Xmx). Default '${default}':
+cms.initiating.heap.percentage=Please specify the percentage of VM heap utilization before a concurrent collection is initiated (--XX:CMSInitiatingOccupancyFraction [Hotspot-only]). Default '${default}':
+tomcat.version=Please enter the major version of Tomcat you will be using (6, 7 or 8). Default '${default}':
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/context-fragment.xml
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/context-fragment.xml b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/context-fragment.xml
new file mode 100644
index 0000000..2b3d25c
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/context-fragment.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Context>
+
+ <add:Manager className="com.gemstone.gemfire.modules.session.catalina.Tomcat6DeltaSessionManager"
+ enableDebugListener="${enable.debug.listener:false}"
+ enableGatewayReplication="${enable.gateway.replication:false}"
+ enableLocalCache="${enable.local.cache:false}"
+ enableCommitValve="${enable.commit.valve:true}"
+ preferDeserializedForm="${prefer.deserialized.form:true}"
+ regionAttributesId="${region.attributes.id:REPLICATE}"
+ regionName="${region.name:gemfire_modules_sessions}"/>
+
+</Context>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/modules.env
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/modules.env b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/modules.env
new file mode 100644
index 0000000..9c4c00a
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/modules.env
@@ -0,0 +1 @@
+TOMCAT_MAJOR_VER=6
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/server-fragment.xml
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/server-fragment.xml b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/server-fragment.xml
new file mode 100644
index 0000000..cf7dc0d
--- /dev/null
+++ b/extensions/geode-modules-assembly/release/tcserver/gemfire-p2p/server-fragment.xml
@@ -0,0 +1,14 @@
+<?xml version='1.0' encoding='utf-8'?>
+<Server>
+
+ <add:Listener className="com.gemstone.gemfire.modules.session.catalina.PeerToPeerCacheLifecycleListener"
+ cache-xml-file="${cache.configuration.file:cache-peer.xml}"
+ criticalHeapPercentage="${critical.heap.percentage:0.0}"
+ evictionHeapPercentage="${eviction.heap.percentage:80.0}"
+ locators="${locators:localhost[10334]}"
+ log-file="${log.file:gemfire_modules.log}"
+ rebalance="${rebalance:false}"
+ statistic-archive-file="${statistic.archive.file:gemfire_modules.gfs}"
+ statistic-sampling-enabled="${statistic.sampling.enabled:false}"/>
+
+</Server>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-hibernate/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/build.gradle b/extensions/geode-modules-hibernate/build.gradle
new file mode 100644
index 0000000..34a76eb
--- /dev/null
+++ b/extensions/geode-modules-hibernate/build.gradle
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+dependencies {
+ compile project(':extensions/geode-modules')
+ compile 'org.hibernate:hibernate-core:' + project.'hibernate.version'
+ compile 'org.hibernate:hibernate-annotations:' + project.'hibernate.version'
+ compile 'org.eclipse.persistence:javax.persistence:' + project.'javax.persistence-api.version'
+
+ runtime 'dom4j:dom4j:' + project.'dom4j.version'
+
+ testRuntime 'commons-collections:commons-collections:' + project.'commons-collections.version'
+ testRuntime 'org.hibernate:hibernate-commons-annotations:' + project.'hibernate-commons-annotations.version'
+ testRuntime 'org.slf4j:slf4j-jdk14:' + project.'slf4j-api.version'
+ testRuntime 'org.hsqldb:hsqldb:' + project.'hsqldb.version'
+ testRuntime 'org.javassist:javassist:' + project.'javassist.version'
+
+ testCompile project(path: ':geode-junit')
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/EnumType.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/EnumType.java b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/EnumType.java
new file mode 100644
index 0000000..55b824c
--- /dev/null
+++ b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/EnumType.java
@@ -0,0 +1,58 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.gemstone.gemfire.modules.hibernate;
+
+import java.io.Serializable;
+
+import org.hibernate.HibernateException;
+
+/**
+ * Extends {@link org.hibernate.type.EnumType} so as to
+ * override methods responsible for cached representation
+ * of enums in hibernate.
+ * This class must be used in place of {@link org.hibernate.type.EnumType}
+ * in client-server topology when the application classes are
+ * not available on the server.
+ * e.g. a typical enum configuration should look like this:
+ * <pre>
+ * <property name="myEnum">
+ * <type name="<b>com.gemstone.gemfire.modules.hibernate.EnumType</b>">
+ * <param name="enumClass">com.mycompany.MyEntity$MyEnum</param>
+ * <param name="type">12</param>
+ * </type>
+ * </property>
+ * </pre>
+ * @author sbawaska
+ */
+public class EnumType extends org.hibernate.type.EnumType {
+
+ private static final long serialVersionUID = 3414902482639744676L;
+
+ @Override
+ public Object assemble(Serializable cached, Object owner)
+ throws HibernateException {
+ String name = (String) cached;
+ Class<? extends Enum> clazz = returnedClass();
+ return Enum.valueOf(clazz, name);
+ }
+
+ @Override
+ public Serializable disassemble(Object value) throws HibernateException {
+ return ((Enum)value).name();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireCache.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireCache.java b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireCache.java
new file mode 100644
index 0000000..7548061
--- /dev/null
+++ b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireCache.java
@@ -0,0 +1,238 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.gemstone.gemfire.modules.hibernate;
+
+import java.util.Map;
+
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.Timestamper;
+
+import com.gemstone.gemfire.cache.EntryNotFoundException;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.distributed.DistributedLockService;
+import com.gemstone.gemfire.internal.cache.LocalRegion;
+
+public class GemFireCache implements Cache {
+ private Region region;
+
+ private boolean clientRegion = false;
+
+ private final DistributedLockService distributedLockService;
+
+ public GemFireCache(Region region, DistributedLockService lockService) {
+ this.region = region;
+ this.distributedLockService = lockService;
+ this.clientRegion = isClient(region);
+ }
+
+ private boolean isClient(Region region) {
+ return region.getAttributes().getPoolName() != null;
+ }
+
+ /**
+ * Clear the cache
+ */
+ public void clear() throws CacheException {
+ GemFireCacheProvider.getLogger().info("GemFireCache: clear called");
+ region.clear();
+ }
+
+ /**
+ * Clean up
+ */
+ public void destroy() throws CacheException {
+ GemFireCacheProvider.getLogger().info("GemFireCache: destroy called");
+ region.localDestroyRegion();
+ }
+
+ /**
+ * Get an item from the cache
+ *
+ * @param key
+ * @return the cached object or <tt>null</tt>
+ * @throws CacheException
+ */
+ public Object get(Object key) throws CacheException {
+ GemFireCacheProvider.getLogger().debug(
+ "GemFireCache: get called for: " + key);
+ try {
+ Object value = region.get(key);
+ GemFireCacheProvider.getLogger().debug(
+ "GemFireCache: retrieved: " + key + "-->" + value);
+ return value;
+ }
+ catch (com.gemstone.gemfire.cache.CacheException e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /**
+ * The count of entries currently contained in the regions in-memory store.
+ *
+ * @return The count of entries in memory; -1 if unknown or unsupported.
+ */
+ public long getElementCountInMemory() {
+ return ((LocalRegion)region).entryCount();
+ }
+
+ /**
+ * The count of entries currently contained in the regions disk store.
+ *
+ * @return The count of entries on disk; -1 if unknown or unsupported.
+ */
+ public long getElementCountOnDisk() {
+ return -1;
+ }
+
+ /**
+ * Get the name of the cache region
+ */
+ public String getRegionName() {
+ return region.getName();
+ }
+
+ /**
+ * The number of bytes is this cache region currently consuming in memory.
+ *
+ * @return The number of bytes consumed by this region; -1 if unknown or
+ * unsupported.
+ */
+ public long getSizeInMemory() {
+ return -1;
+ }
+
+ /**
+ * Return the lock timeout for this cache.
+ */
+ public int getTimeout() {
+ GemFireCacheProvider.getLogger().debug("GemFireCache: getTimeout");
+ return Timestamper.ONE_MS * 60000;
+ }
+
+ /**
+ * If this is a clustered cache, lock the item
+ */
+ public void lock(Object key) throws CacheException {
+ GemFireCacheProvider.getLogger().info(
+ "GemFireCache: lock called for: " + key);
+
+ if (!clientRegion) {
+ // If we're using GLOBAL scope, we don't have to worry about
+ // locking.
+ if (!Scope.GLOBAL.equals(region.getAttributes().getScope())) {
+ this.distributedLockService.lock(key, -1, -1);
+ }
+ }
+ else {
+ // We assume the server region is GLOBAL for now. Else, use command
+ // pattern to acquire lock on the server
+ GemFireCacheProvider.getLogger().info(
+ "GemFireCache: client region, ignoring lock : " + key);
+ }
+ }
+
+ /**
+ * Generate the next timestamp
+ */
+ public long nextTimestamp() {
+ GemFireCacheProvider.getLogger().debug("GemFireCache: nextTimestamp called");
+ // TODO : Need a counter, cache-wide
+ return Timestamper.next();
+ }
+
+ /**
+ * Add an item to the cache
+ *
+ * @param key
+ * @param value
+ * @throws CacheException
+ */
+ public void put(Object key, Object value) throws CacheException {
+ GemFireCacheProvider.getLogger().debug(
+ "GemFireCache: put called for key: " + key + "value: " + value);
+ try {
+ region.put(key, value);
+ GemFireCacheProvider.getLogger().debug(
+ "GemFireCache: put " + key + "-->" + value);
+ }
+ catch (com.gemstone.gemfire.cache.CacheException e) {
+ throw new CacheException(e);
+ }
+ }
+
+ public Object read(Object key) throws CacheException {
+ GemFireCacheProvider.getLogger().info(
+ "GemFireCache: read called for: " + key);
+ return region.get(key);
+ }
+
+ /**
+ * Remove an item from the cache
+ */
+ public void remove(Object key) throws CacheException {
+ GemFireCacheProvider.getLogger().debug(
+ "GemFireCache: remove called for: " + key);
+ try {
+ region.destroy(key);
+ GemFireCacheProvider.getLogger().debug("GemFireCache: removed: " + key);
+ }
+ catch (EntryNotFoundException e) {
+ // We can silently ignore this
+ }
+ catch (com.gemstone.gemfire.cache.CacheException e) {
+ throw new CacheException(e);
+ }
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Hibernate cache on GemFire region: ");
+ buffer.append(region);
+ return buffer.toString();
+ }
+
+ /**
+ * If this is a clustered cache, unlock the item
+ */
+ public void unlock(Object key) throws CacheException {
+ GemFireCacheProvider.getLogger().info(
+ "GemFireCache: unlock called for: " + key);
+
+ if (!clientRegion) {
+ // If we're using GLOBAL scope, we don't have to worry about locking.
+ if (!Scope.GLOBAL.equals(region.getAttributes().getScope())) {
+ this.distributedLockService.unlock(key);
+ }
+ }
+ else {
+ GemFireCacheProvider.getLogger().info(
+ "GemFireCache: client region, ignoring lock : " + key);
+ }
+ }
+
+ public void update(Object key, Object value) throws CacheException {
+ GemFireCacheProvider.getLogger().info(
+ "GemFireCache: update called for: " + key);
+ this.region.put(key, value);
+ }
+
+ public Map<?, ?> toMap() {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireCacheListener.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireCacheListener.java b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireCacheListener.java
new file mode 100644
index 0000000..e684c7d
--- /dev/null
+++ b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireCacheListener.java
@@ -0,0 +1,54 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.gemstone.gemfire.modules.hibernate;
+
+import java.util.Properties;
+
+import com.gemstone.gemfire.cache.Declarable;
+import com.gemstone.gemfire.cache.EntryEvent;
+import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
+
+public class GemFireCacheListener extends CacheListenerAdapter implements
+ Declarable {
+
+ @Override
+ public void afterCreate(EntryEvent event) {
+ System.out.println("Create : " + event.getKey() + " / "
+ + event.getNewValue());
+ }
+
+ @Override
+ public void afterDestroy(EntryEvent event) {
+ System.out.println("Destroy : " + event.getKey());
+ }
+
+ @Override
+ public void afterInvalidate(EntryEvent event) {
+ System.out.println("Invalidate : " + event.getKey());
+ }
+
+ @Override
+ public void afterUpdate(EntryEvent event) {
+ System.out.println("Update : " + event.getKey() + " / "
+ + event.getNewValue());
+ }
+
+ public void init(Properties props) {
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireCacheProvider.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireCacheProvider.java b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireCacheProvider.java
new file mode 100644
index 0000000..9cd6c88
--- /dev/null
+++ b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireCacheProvider.java
@@ -0,0 +1,200 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.gemstone.gemfire.modules.hibernate;
+
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.execute.FunctionService;
+import com.gemstone.gemfire.distributed.DistributedLockService;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.modules.util.CreateRegionFunction;
+import com.gemstone.gemfire.modules.util.RegionConfiguration;
+import org.apache.logging.log4j.Logger;
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CacheProvider;
+import org.hibernate.cache.Timestamper;
+
+import java.util.Iterator;
+import java.util.Properties;
+
+@SuppressWarnings("deprecation")
+public class GemFireCacheProvider implements CacheProvider {
+
+ private static final Logger logger = LogService.getLogger();
+
+ protected com.gemstone.gemfire.cache.Cache _cache;
+
+ private DistributedLockService distributedLockService;
+
+ private Properties regionAttributes = new Properties();
+
+ private final String DEFAULT_REGION_TYPE = RegionShortcut.REPLICATE_HEAP_LRU
+ .name();
+
+ private final String HIBERNATE_DLOCK_SERVICE_NAME = "hibernate-cache-lock-service";
+ /**
+ * Configure the cache
+ *
+ * @param regionName
+ * the name of the cache region
+ * @param properties
+ * configuration settings
+ * @throws CacheException
+ */
+ public Cache buildCache(String regionName, Properties properties)
+ throws CacheException {
+ logger.info("GemFireCacheProvider: Creating cache: " + regionName);
+ Region region = retrieveOrCreateRegion(regionName);
+ Cache cache = null;
+ if (region == null) {
+ // Doh, blow up
+ throw new RuntimeException("Couldn't find cache region : " + regionName);
+ }
+ else {
+ cache = new GemFireCache(region, this.distributedLockService);
+ }
+ logger.info("GemFireCacheProvider: Created cache: " + regionName + "->" + cache);
+ return cache;
+ }
+
+ public boolean isMinimalPutsEnabledByDefault() {
+ return false;
+ }
+
+ /**
+ * Generate a timestamp
+ */
+ public long nextTimestamp() {
+ return Timestamper.next();
+ }
+
+ /**
+ * Returns the region if already created, otherwise first tries to create it
+ * from cache.xml, if not specified in cache.xml, create the region from the
+ * properties specified in hibernate.cfg.xml. Two types of properties can be
+ * specified in hibernate.cfg.xml
+ * <ol>
+ * <li>gemfire.default-region-attributes-id: the default region type to
+ * create. (default value for this is REPLICATE)
+ * <li>gemfire.region-attributes-for:fullyQualifiedRegionName when a region
+ * wants to override the default region type
+ * </ol>
+ *
+ * @param regionName
+ * @return the region
+ */
+ protected Region retrieveOrCreateRegion(String regionName) {
+ // TODO client regions
+ Region r = _cache.getRegion(regionName);
+ if (r == null) {
+ String regionType = getRegionType(regionName);
+ r = _cache.createRegionFactory(RegionShortcut.valueOf(regionType))
+ .create(regionName);
+ RegionConfiguration regionConfig = new RegionConfiguration();
+ regionConfig.setRegionName(regionName);
+ regionConfig.setRegionAttributesId(regionType);
+ FunctionService.onMembers(_cache.getDistributedSystem())
+ .withArgs(regionConfig).execute(CreateRegionFunction.ID).getResult();
+ }
+ return r;
+ }
+
+ /**
+ * returns the type of region to create by consulting the properties specified
+ * in hibernate.cfg.xml
+ *
+ * @see #retrieveOrCreateRegion(String)
+ * @param regionName
+ * @return string representation of {@link RegionShortcut}
+ */
+ private String getRegionType(String regionName) {
+ String rType = regionAttributes
+ .getProperty("gemfire.default-region-attributes-id");
+ if (rType == null) {
+ rType = DEFAULT_REGION_TYPE;
+ }
+ // iterate to find overridden property for a region
+ Iterator<Object> it = regionAttributes.keySet().iterator();
+ while (it.hasNext()) {
+ String current = (String)it.next();
+ if (current.contains(regionName)) {
+ rType = regionAttributes.getProperty(current);
+ break;
+ }
+ }
+ return rType.toUpperCase();
+ }
+
+ /**
+ * Callback to perform any necessary initialization of the underlying cache
+ * implementation during SessionFactory construction.
+ *
+ * @param properties
+ * current configuration settings.
+ */
+ public void start(Properties properties) throws CacheException {
+ logger.info("GemFireCacheProvider: Creating cache provider");
+
+ // We have to strip out any unknown properties, do so here
+ Properties gemfireOnlyProperties = new Properties();
+ for (Object keyObj : properties.keySet()) {
+ String key = (String)keyObj;
+ if (key.contains("region-attributes")) {
+ regionAttributes.put(key, properties.get(key));
+ }
+ else if (key.startsWith("gemfire.")) {
+ gemfireOnlyProperties.setProperty(key.replace("gemfire.", ""),
+ properties.getProperty(key));
+ }
+ }
+
+ // Create cache and d-lock service
+ try {
+ _cache = new CacheFactory(gemfireOnlyProperties).create();
+ DistributedLockService existing = DistributedLockService.getServiceNamed(HIBERNATE_DLOCK_SERVICE_NAME);
+ if (existing == null) {
+ this.distributedLockService = DistributedLockService.create(
+ HIBERNATE_DLOCK_SERVICE_NAME, _cache.getDistributedSystem());
+ } else {
+ this.distributedLockService = existing;
+ }
+ }
+ catch (com.gemstone.gemfire.cache.CacheException e) {
+ throw new CacheException(e);
+ }
+
+ FunctionService.registerFunction(new CreateRegionFunction());
+
+ logger.info("GemFireCacheProvider: Done creating cache provider");
+ }
+
+ /**
+ * Callback to perform any necessary cleanup of the underlying cache
+ * implementation during SessionFactory.close().
+ */
+ public void stop() {
+ logger.info("GemFireCacheProvider: Stopping");
+ _cache.close();
+ logger.info("GemFireCacheProvider: Stopped");
+ }
+
+ public static Logger getLogger() {
+ return logger;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireQueryCacheFactory.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireQueryCacheFactory.java b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireQueryCacheFactory.java
new file mode 100644
index 0000000..c019436
--- /dev/null
+++ b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireQueryCacheFactory.java
@@ -0,0 +1,39 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.gemstone.gemfire.modules.hibernate;
+
+import java.util.Properties;
+
+import org.hibernate.HibernateException;
+import org.hibernate.cache.QueryCache;
+import org.hibernate.cache.QueryCacheFactory;
+import org.hibernate.cache.UpdateTimestampsCache;
+import org.hibernate.cfg.Settings;
+
+/**
+ * Defines a factory for query cache instances. These factories are responsible
+ * for creating individual QueryCache instances.
+ *
+ */
+public class GemFireQueryCacheFactory implements QueryCacheFactory {
+ public QueryCache getQueryCache(String regionName,
+ UpdateTimestampsCache updateTimestampsCache, Settings settings,
+ Properties props) throws HibernateException {
+ return new org.hibernate.cache.StandardQueryCache(settings, props,
+ updateTimestampsCache, regionName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireRegionFactory.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireRegionFactory.java b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireRegionFactory.java
new file mode 100644
index 0000000..97e5fdf
--- /dev/null
+++ b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/GemFireRegionFactory.java
@@ -0,0 +1,237 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.gemstone.gemfire.modules.hibernate;
+
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.QueryResultsRegion;
+import org.hibernate.cache.RegionFactory;
+import org.hibernate.cache.Timestamper;
+import org.hibernate.cache.TimestampsRegion;
+import org.hibernate.cache.access.AccessType;
+import org.hibernate.cfg.Settings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.GemFireCache;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
+import com.gemstone.gemfire.modules.hibernate.internal.ClientServerRegionFactoryDelegate;
+import com.gemstone.gemfire.modules.hibernate.internal.EntityWrapper;
+import com.gemstone.gemfire.modules.hibernate.internal.GemFireCollectionRegion;
+import com.gemstone.gemfire.modules.hibernate.internal.GemFireEntityRegion;
+import com.gemstone.gemfire.modules.hibernate.internal.GemFireQueryResultsRegion;
+import com.gemstone.gemfire.modules.hibernate.internal.RegionFactoryDelegate;
+import com.gemstone.gemfire.modules.util.Banner;
+
+public class GemFireRegionFactory implements RegionFactory {
+
+
+ private static final String GEMFIRE_QUERY_RESULTS_REGION_NAME = "gemfire.hibernateQueryResults";
+
+ private static final String GEMFIRE_TIMESTAMPS_REGION_NAME = "gemfire.hibernateTimestamps";
+
+ private GemFireCache _cache;
+
+ private RegionFactoryDelegate delegate;
+
+ // TODO get rid of this
+ private boolean isClient;
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private final ExecutorService executorService = Executors.newSingleThreadExecutor();
+
+ private Set<String> gemfireAttributes;
+
+ /**
+ * maps the entity to the region that stores it.
+ */
+ private ConcurrentMap<String, GemFireEntityRegion> entityRegionMap = new ConcurrentHashMap<String, GemFireEntityRegion>();
+
+ public GemFireRegionFactory(Properties props) {
+ log.debug("props:" + props);
+ }
+
+ public ExecutorService getExecutorService() {
+ return this.executorService;
+ }
+
+ @Override
+ public void start(Settings settings, Properties properties)
+ throws CacheException {
+ log.info("Initializing " + Banner.getString());
+ extractGemFireProperties(properties);
+ _cache = delegate.startCache();
+ }
+
+ private void extractGemFireProperties(Properties properties) {
+ // We have to strip out any unknown properties, do so here
+ Properties gemfireProperties = new Properties();
+ Properties regionProperties = new Properties();
+ for (Object keyObj : properties.keySet()) {
+ String key = (String)keyObj;
+ if (key.contains("region-attributes")) {
+ regionProperties.put(key, properties.get(key));
+ }
+ else if (key.equals("gemfire.cache-topology")) {
+ if (properties.getProperty(key).trim()
+ .equalsIgnoreCase("client-server")) {
+ isClient = true;
+ }
+ }
+ else if (key.startsWith("gemfire.") && isGemFireAttribute(key)) {
+ gemfireProperties.setProperty(key.replace("gemfire.", ""),
+ properties.getProperty(key));
+ }
+ }
+ if (isClient) {
+ delegate = new ClientServerRegionFactoryDelegate(gemfireProperties, regionProperties);
+ } else {
+ delegate = new RegionFactoryDelegate(gemfireProperties, regionProperties);
+ }
+ }
+
+ private boolean isGemFireAttribute(String key) {
+ String gfKey = key.replace("gemfire.", "");
+ Set<String> gemfireAttributes = getGemFireAttributesNames();
+ return gemfireAttributes.contains(gfKey);
+ }
+
+ private Set<String> getGemFireAttributesNames() {
+ if (this.gemfireAttributes == null) {
+ //used only to get the list of all gemfire properties
+ DistributionConfig dConfig = new DistributionConfigImpl(new Properties());
+ String[] gemfireAttributeNames = dConfig.getAttributeNames();
+ gemfireAttributes = new HashSet<String>();
+ for (String attrName : gemfireAttributeNames) {
+ gemfireAttributes.add(attrName);
+ }
+ }
+ return gemfireAttributes;
+ }
+
+ @Override
+ public void stop() {
+ // we do not want to close the cache, as there may be other
+ // applications/webapps
+ // using this cache. TODO do we want to close the regions that are created
+ // by this application?
+ }
+
+ @Override
+ public boolean isMinimalPutsEnabledByDefault() {
+ // minimal puts is better for clustered cache
+ return true;
+ }
+
+ @Override
+ public AccessType getDefaultAccessType() {
+ return AccessType.NONSTRICT_READ_WRITE;
+ }
+
+ @Override
+ public long nextTimestamp() {
+ log.debug("nextTimestamp called");
+ // TODO use gemfire cache time here. (which tries to minimize clock skews)
+ return Timestamper.next();
+ }
+
+ @Override
+ public EntityRegion buildEntityRegion(String regionName,
+ Properties properties, CacheDataDescription metadata)
+ throws CacheException {
+ // create the backing region
+ log.debug("creating Entity region {} ", regionName);
+ Region<Object, EntityWrapper> region = delegate.createRegion(regionName);
+ GemFireEntityRegion r = new GemFireEntityRegion(region, isClient, metadata, this);
+ this.entityRegionMap.put(regionName, r);
+ return r;
+ }
+
+ @Override
+ public CollectionRegion buildCollectionRegion(String regionName,
+ Properties properties, CacheDataDescription metadata)
+ throws CacheException {
+ log.debug("creating collection region {}",regionName);
+ Region<Object, EntityWrapper> region = delegate.createRegion(regionName);
+ return new GemFireCollectionRegion(region, isClient, metadata, this);
+ }
+
+ @Override
+ public QueryResultsRegion buildQueryResultsRegion(String regionName,
+ Properties properties) throws CacheException {
+ log.debug("Creating a query results region");
+ Region region = getLocalRegionForQueryCache();
+ return new GemFireQueryResultsRegion(region);
+ }
+
+ private Region getLocalRegionForQueryCache() {
+ return getLocalRegion(GEMFIRE_QUERY_RESULTS_REGION_NAME);
+ }
+
+ private Region getLocalRegionForTimestampsCache() {
+ return getLocalRegion(GEMFIRE_TIMESTAMPS_REGION_NAME);
+ }
+
+ private Region getLocalRegion(String regionName) {
+ Region region = _cache.getRegion(regionName);
+ if (region != null) {
+ return region;
+ }
+ if (isClient) {
+ ClientCache cc = (ClientCache)_cache;
+ region = cc.createClientRegionFactory(ClientRegionShortcut.LOCAL_HEAP_LRU).create(regionName);
+ } else {
+ Cache c = (Cache)_cache;
+ region = c.createRegionFactory(RegionShortcut.LOCAL_HEAP_LRU).create(regionName);
+ }
+ return region;
+ }
+
+ @Override
+ public TimestampsRegion buildTimestampsRegion(String regionName,
+ Properties properties) throws CacheException {
+ Region region = getLocalRegionForTimestampsCache();
+ return new GemFireQueryResultsRegion(region);
+ }
+
+ /**
+ * Given an entity name, gets the region used to store
+ * that entity.
+ * @param name name of the entity
+ * @return the entity region for the given entity name
+ */
+ public GemFireEntityRegion getEntityRegion(String name) {
+ return this.entityRegionMap.get(name);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/internal/Access.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/internal/Access.java b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/internal/Access.java
new file mode 100644
index 0000000..86c6786
--- /dev/null
+++ b/extensions/geode-modules-hibernate/src/main/java/com/gemstone/gemfire/modules/hibernate/internal/Access.java
@@ -0,0 +1,257 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.gemstone.gemfire.modules.hibernate.internal;
+
+import com.gemstone.gemfire.cache.CacheWriterException;
+import com.gemstone.gemfire.cache.EntryExistsException;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.client.ServerOperationException;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.access.SoftLock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class Access implements EntityRegionAccessStrategy {
+
+ private final GemFireEntityRegion region;
+
+ /**Thread local to remember the status of insert, which can be returned in afterInsert*/
+ private ThreadLocal<Map<Object, Boolean>> createStatus = new ThreadLocal<Map<Object, Boolean>>() {
+ @Override
+ protected Map<Object, Boolean> initialValue() {
+ return new HashMap<Object, Boolean>();
+ }
+ };
+
+ private Logger log = LoggerFactory.getLogger(getClass());
+
+ public Access(GemFireEntityRegion region) {
+ this.region = region;
+ }
+
+ @Override
+ public EntityRegion getRegion() {
+ return this.region;
+ }
+
+ @Override
+ public Object get(Object key, long txTimestamp) throws CacheException {
+ KeyWrapper wKey = getWrappedKey(key);
+ if (this.region.isRegisterInterestRequired()) {
+ this.region.registerInterest(wKey);
+ }
+ // first check to see if we have pre-fetched this entity
+ EntityWrapper wrapper = this.region.get(wKey);
+ if (wrapper == null) {
+ wrapper = this.region.getGemFireRegion().get(wKey);
+ }
+ if (wrapper == null) {
+ this.region.getStats().incCacheMiss();
+ log.debug("Cache miss for {} count: {}",wKey, this.region.getStats().getCacheMiss());
+ return null;
+ } else {
+ this.region.getStats().incCacheHit();
+ log.debug("cache hit {} count: {} ", wKey, this.region.getStats().getCacheHits());
+ }
+ return wrapper.getEntity();
+ }
+
+ @Override
+ public boolean putFromLoad(Object key, Object value, long txTimestamp,
+ Object version) throws CacheException {
+ return putFromLoad(key, value, txTimestamp, version, true);
+ }
+
+ @Override
+ public boolean putFromLoad(Object key, Object value, long txTimestamp,
+ Object version, boolean minimalPutOverride) throws CacheException {
+ return create(key, value);
+ }
+
+ private boolean create(Object key, Object value) {
+ KeyWrapper wKey = getWrappedKey(key);
+ EntityWrapper wrapper = new EntityWrapper(value, 1L);
+ log.debug("putting a new entry from load {} value: {}",wKey, wrapper);
+ boolean remove = false;
+ try {
+ this.region.getGemFireRegion().create(wKey, wrapper);
+ } catch (EntryExistsException ee) {
+ log.debug("key {} exists in the cache already, destroying", wKey);
+ remove = true;
+ } catch (CacheWriterException writerEx) {
+ this.region.getStats().incHibernateDestroyJobsScheduled();
+ log.debug("caught a CacheWriterException {} ",writerEx.getMessage());
+ remove = true;
+ } catch (ServerOperationException serverEx) {
+ if (serverEx.getCause() instanceof CacheWriterException) {
+ this.region.getStats().incHibernateDestroyJobsScheduled();
+ log.debug("caught a ServerOperationException caused by CacheWriterException {} ",serverEx.getMessage());
+ } else {
+ throw serverEx;
+ }
+ remove = true;
+ }
+ if (remove) {
+ this.region.getGemFireRegion().remove(wKey);
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public SoftLock lockItem(Object key, Object version) throws CacheException {
+ KeyWrapper wKey = getWrappedKey(key);
+ EntityWrapper wrapper = this.region.getGemFireRegion().get(wKey);
+ Long ver = wrapper == null ? 0L : wrapper.getVersion();
+ log.debug("lockItem:key: {} entityVersion: {}", new Object[] { wKey, ver });
+ return new EntityVersionImpl(ver);
+ }
+
+ @Override
+ public SoftLock lockRegion() throws CacheException {
+ return null;
+ }
+
+ @Override
+ public void unlockItem(Object key, SoftLock lock) throws CacheException {
+ log.debug("unlockItem:key:" + key + " lock:" + lock);
+ }
+
+ @Override
+ public void unlockRegion(SoftLock lock) throws CacheException {
+ }
+
+ @Override
+ public boolean insert(Object key, Object value, Object version)
+ throws CacheException {
+ log.debug("insert:key:{} value:{} version:{}",
+ new Object[]{key, value, version});
+ boolean retVal = create(key, value);
+ createStatus.get().put(key, retVal);
+ return retVal;
+ }
+
+ @Override
+ public boolean afterInsert(Object key, Object value, Object version)
+ throws CacheException {
+ log.info("afterInsert:key:{} value:{} version:{}",
+ new Object[]{key, value, version});
+ return createStatus.get().remove(key);
+ }
+
+ @Override
+ public boolean update(Object key, Object value, Object currentVersion,
+ Object previousVersion) throws CacheException {
+ KeyWrapper wKey = getWrappedKey(key);
+ EntityWrapper oldWrapper = this.region.getGemFireRegion().get(wKey);
+ Long version = oldWrapper == null ? 1L : oldWrapper.getVersion() + 1;
+ EntityWrapper wrapper = new EntityWrapper(value, version);
+ log.debug("put:key:{} value:{} version:{}", new Object[] { wKey, value,
+ version });
+ boolean remove = false;
+ try {
+ if (oldWrapper == null) {
+ remove = this.region.getGemFireRegion().putIfAbsent(wKey, wrapper) != null;
+ } else {
+ remove = !this.region.getGemFireRegion().replace(wKey, oldWrapper, wrapper);
+ }
+ } catch (CacheWriterException writerEx) {
+ this.region.getStats().incHibernateDestroyJobsScheduled();
+ log.debug("caught a CacheWriterException {} ",writerEx.getMessage());
+ remove = true;
+ } catch (ServerOperationException serverEx) {
+ if (serverEx.getCause() instanceof CacheWriterException) {
+ this.region.getStats().incHibernateDestroyJobsScheduled();
+ log.debug("caught a ServerOperationException caused by CacheWriterException {} ",serverEx.getMessage());
+ remove = true;
+ } else {
+ throw serverEx;
+ }
+ }
+ if (remove) {
+ this.region.getGemFireRegion().remove(wKey);
+ return false;
+ }
+ log.debug("put for key {} succeded", wKey);
+ return true;
+ }
+
+ @Override
+ public boolean afterUpdate(Object key, Object value, Object currentVersion,
+ Object previousVersion, SoftLock lock) throws CacheException {
+ log.debug("afterUpdate:key:{} value:{} currVersion:{} previousVersion:{}",
+ new Object[] {key, value, currentVersion, previousVersion});
+ KeyWrapper wKey = getWrappedKey(key);
+ EntityWrapper wrapper = this.region.getGemFireRegion().get(wKey);
+ if (wrapper == null) {
+ // this entry was destroyed during update
+ return false;
+ }
+ Long version = wrapper.getVersion();
+ Long expectedVersion = ((EntityVersion)lock).getVersion() + 1;
+ log.debug("afterPut:key:{} value:{} version:{} expected: {}",
+ new Object[] { wKey, value, version, expectedVersion });
+ if (wrapper.getVersion() != expectedVersion) {
+ log.debug(
+ "for key {} expected version to be {} but was {}, so destroying the key",
+ new Object[] { wKey, expectedVersion, version });
+ this.region.getGemFireRegion().remove(wKey);
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void remove(Object key) throws CacheException {
+ log.debug("removing key {} ",key);
+ this.region.getGemFireRegion().remove(getWrappedKey(key));
+ }
+
+ @Override
+ public void removeAll() throws CacheException {
+ log.debug("removing all keys");
+ this.region.getGemFireRegion().clear();
+ }
+
+ @Override
+ public void evict(Object key) throws CacheException {
+ // TODO we should implement a method on Region to evict
+ // a particular entry, destroying is inefficient
+ log.debug("removing key {} ",key);
+ this.region.getGemFireRegion().remove(getWrappedKey(key));
+ }
+
+ @Override
+ public void evictAll() throws CacheException {
+ log.debug("removing all keys");
+ this.region.getGemFireRegion().clear();
+ }
+
+ protected Region<Object, EntityWrapper> getGemFireRegion() {
+ return this.region.getGemFireRegion();
+ }
+
+ protected KeyWrapper getWrappedKey(Object key) {
+ return new KeyWrapper(key);
+ }
+}
+