Fixes GemFire client/server integratione tests issue when setting JAVA_TOOL_OPTIONS env var
Fixes gh-727
This commit is contained in:
@@ -41,24 +41,34 @@ springBoot {
|
|||||||
|
|
||||||
task runGemFireServer() {
|
task runGemFireServer() {
|
||||||
doLast {
|
doLast {
|
||||||
println 'STARTING GEMFIRE SERVER...'
|
|
||||||
|
|
||||||
ext.port = reservePort()
|
ext.port = reservePort()
|
||||||
|
|
||||||
|
println "Starting GemFire Server on port [$port] ..."
|
||||||
|
|
||||||
|
def out = new StringBuilder()
|
||||||
|
def err = new StringBuilder()
|
||||||
|
|
||||||
String classpath = sourceSets.main.runtimeClasspath.collect { it }.join(File.pathSeparator)
|
String classpath = sourceSets.main.runtimeClasspath.collect { it }.join(File.pathSeparator)
|
||||||
|
|
||||||
String[] commandLine = ['java', '-server', '-ea', '-classpath', classpath,
|
String[] commandLine = [
|
||||||
"-Dgemfire.cache.server.port=$port",
|
'java', '-server', '-ea', '-classpath', classpath,
|
||||||
//"-Dgemfire.log-file=gemfire-server.log",
|
//"-Dgemfire.log-file=gemfire-server.log",
|
||||||
"-Dgemfire.log-level=" + System.getProperty('gemfire.log.level', 'config'),
|
//"-Dgemfire.log-level=config",
|
||||||
'sample.server.GemFireServer']
|
"-Dspring-session-data-gemfire.cache.server.port=$port",
|
||||||
|
"-Dspring-session-data-gemfire.log.level="
|
||||||
|
+ System.getProperty('spring-session-data-gemfire.log.level', 'config'),
|
||||||
|
'sample.server.GemFireServer'
|
||||||
|
]
|
||||||
|
|
||||||
//println commandLine
|
//println commandLine
|
||||||
|
|
||||||
ext.process = commandLine.execute()
|
ext.process = commandLine.execute()
|
||||||
process.in.close()
|
//ext.process = new ProcessBuilder().command(commandLine).redirectErrorStream(true).start();
|
||||||
process.out.close()
|
|
||||||
process.err.close()
|
ext.process.consumeProcessOutput(out, err)
|
||||||
|
|
||||||
|
//println 'OUT: ' + out
|
||||||
|
//println 'ERR: ' + err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,12 +77,15 @@ integrationTest {
|
|||||||
dependsOn runGemFireServer
|
dependsOn runGemFireServer
|
||||||
doFirst {
|
doFirst {
|
||||||
def port = reservePort()
|
def port = reservePort()
|
||||||
systemProperties['server.port'] = port
|
|
||||||
systemProperties['management.port'] = 0
|
systemProperties['management.port'] = 0
|
||||||
systemProperties['gemfire.cache.server.port'] = runGemFireServer.port
|
systemProperties['server.port'] = port
|
||||||
|
//systemProperties['gemfire.log-file'] = "gemfire-client.log"
|
||||||
|
//systemProperties['gemfire.log-level'] = "config"
|
||||||
|
systemProperties['spring-session-data-gemfire.cache.server.port'] = runGemFireServer.port
|
||||||
|
systemProperties['spring-session-data-gemfire.log.level'] = System.getProperty("spring-session-data-gemfire.log.level", "warning")
|
||||||
}
|
}
|
||||||
doLast {
|
doLast {
|
||||||
println 'STOPPING GEMFIRE SERVER...'
|
println 'Stopping GemFire Server...'
|
||||||
runGemFireServer.process?.destroyForcibly()
|
runGemFireServer.process?.destroyForcibly()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||||||
*/
|
*/
|
||||||
// tag::class[]
|
// tag::class[]
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableGemFireHttpSession // <1>
|
@EnableGemFireHttpSession(poolName = "DEFAULT")// <1>
|
||||||
@Controller
|
@Controller
|
||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ public class Application {
|
|||||||
|
|
||||||
static final CountDownLatch LATCH = new CountDownLatch(1);
|
static final CountDownLatch LATCH = new CountDownLatch(1);
|
||||||
|
|
||||||
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "config";
|
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "warning";
|
||||||
static final String INDEX_TEMPLATE_VIEW_NAME = "index";
|
static final String INDEX_TEMPLATE_VIEW_NAME = "index";
|
||||||
static final String PING_RESPONSE = "PONG";
|
static final String PING_RESPONSE = "PONG";
|
||||||
static final String REQUEST_COUNT_ATTRIBUTE_NAME = "requestCount";
|
static final String REQUEST_COUNT_ATTRIBUTE_NAME = "requestCount";
|
||||||
@@ -102,18 +102,17 @@ public class Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String applicationName() {
|
String applicationName() {
|
||||||
return "samples:httpsession-gemfire-boot:"
|
return "spring-session-data-gemfire-boot-sample.".concat(getClass().getSimpleName());
|
||||||
.concat(getClass().getSimpleName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String logLevel() {
|
String logLevel() {
|
||||||
return System.getProperty("gemfire.log-level", DEFAULT_GEMFIRE_LOG_LEVEL);
|
return System.getProperty("spring-session-data-gemfire.log.level", DEFAULT_GEMFIRE_LOG_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
ClientCacheFactoryBean gemfireCache(
|
ClientCacheFactoryBean gemfireCache(
|
||||||
@Value("${gemfire.cache.server.host:localhost}") String host,
|
@Value("${spring-session-data-gemfire.cache.server.host:localhost}") String host,
|
||||||
@Value("${gemfire.cache.server.port:12480}") int port) { // <3>
|
@Value("${spring-session-data-gemfire.cache.server.port:12480}") int port) { // <3>
|
||||||
|
|
||||||
ClientCacheFactoryBean gemfireCache = new ClientCacheFactoryBean();
|
ClientCacheFactoryBean gemfireCache = new ClientCacheFactoryBean();
|
||||||
|
|
||||||
@@ -153,8 +152,8 @@ public class Application {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
BeanPostProcessor gemfireCacheServerReadyBeanPostProcessor(
|
BeanPostProcessor gemfireCacheServerReadyBeanPostProcessor(
|
||||||
@Value("${gemfire.cache.server.host:localhost}") final String host,
|
@Value("${spring-session-data-gemfire.cache.server.host:localhost}") final String host,
|
||||||
@Value("${gemfire.cache.server.port:12480}") final int port) { // <5>
|
@Value("${spring-session-data-gemfire.cache.server.port:12480}") final int port) { // <5>
|
||||||
|
|
||||||
return new BeanPostProcessor() {
|
return new BeanPostProcessor() {
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ import org.springframework.session.data.gemfire.config.annotation.web.http.Enabl
|
|||||||
@EnableGemFireHttpSession(maxInactiveIntervalInSeconds = 20) // <1>
|
@EnableGemFireHttpSession(maxInactiveIntervalInSeconds = 20) // <1>
|
||||||
public class GemFireServer {
|
public class GemFireServer {
|
||||||
|
|
||||||
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "config";
|
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "warning";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication springApplication = new SpringApplication(GemFireServer.class);
|
SpringApplication springApplication = new SpringApplication(GemFireServer.class);
|
||||||
@@ -63,7 +63,6 @@ public class GemFireServer {
|
|||||||
Properties gemfireProperties = new Properties();
|
Properties gemfireProperties = new Properties();
|
||||||
|
|
||||||
gemfireProperties.setProperty("name", applicationName());
|
gemfireProperties.setProperty("name", applicationName());
|
||||||
gemfireProperties.setProperty("mcast-port", "0");
|
|
||||||
//gemfireProperties.setProperty("log-file", "gemfire-server.log");
|
//gemfireProperties.setProperty("log-file", "gemfire-server.log");
|
||||||
gemfireProperties.setProperty("log-level", logLevel());
|
gemfireProperties.setProperty("log-level", logLevel());
|
||||||
//gemfireProperties.setProperty("jmx-manager", "true");
|
//gemfireProperties.setProperty("jmx-manager", "true");
|
||||||
@@ -73,11 +72,11 @@ public class GemFireServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String applicationName() {
|
String applicationName() {
|
||||||
return "samples:httpsession-gemfire-boot:".concat(getClass().getSimpleName());
|
return "spring-session-data-gemfire-boot-sample:".concat(getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
String logLevel() {
|
String logLevel() {
|
||||||
return System.getProperty("gemfire.log-level", DEFAULT_GEMFIRE_LOG_LEVEL);
|
return System.getProperty("spring-session-data-gemfire.log.level", DEFAULT_GEMFIRE_LOG_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@@ -92,9 +91,9 @@ public class GemFireServer {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache,
|
CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache,
|
||||||
@Value("${gemfire.cache.server.bind-address:localhost}") String bindAddress,
|
@Value("${spring-session-data-gemfire.cache.server.bind-address:localhost}") String bindAddress,
|
||||||
@Value("${gemfire.cache.server.hostname-for-clients:localhost}") String hostnameForClients,
|
@Value("${spring-session-data-gemfire.cache.server.hostname-for-clients:localhost}") String hostnameForClients,
|
||||||
@Value("${gemfire.cache.server.port:12480}") int port) { // <4>
|
@Value("${spring-session-data-gemfire.cache.server.port:12480}") int port) { // <4>
|
||||||
|
|
||||||
CacheServerFactoryBean gemfireCacheServer = new CacheServerFactoryBean();
|
CacheServerFactoryBean gemfireCacheServer = new CacheServerFactoryBean();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,186 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014-2016 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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 sample.server;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import com.gemstone.gemfire.cache.Cache;
|
||||||
|
import com.gemstone.gemfire.cache.CacheFactory;
|
||||||
|
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||||
|
import com.gemstone.gemfire.cache.ExpirationAttributes;
|
||||||
|
import com.gemstone.gemfire.cache.Region;
|
||||||
|
import com.gemstone.gemfire.cache.RegionFactory;
|
||||||
|
import com.gemstone.gemfire.cache.RegionShortcut;
|
||||||
|
import com.gemstone.gemfire.cache.server.CacheServer;
|
||||||
|
|
||||||
|
import org.springframework.session.data.gemfire.AbstractGemFireOperationsSessionRepository;
|
||||||
|
import org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link NativeGemFireServer} class uses the GemFire API to create a GemFire (cache) instance.
|
||||||
|
*
|
||||||
|
* @author John Blum
|
||||||
|
* @see com.gemstone.gemfire.cache.Cache
|
||||||
|
* @see com.gemstone.gemfire.cache.Region
|
||||||
|
* @see com.gemstone.gemfire.cache.server.CacheServer
|
||||||
|
* @see org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration
|
||||||
|
* @since 1.3.0
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public final class NativeGemFireServer implements Runnable {
|
||||||
|
|
||||||
|
private static final int GEMFIRE_CACHE_SERVER_PORT =
|
||||||
|
Integer.getInteger("spring-session-data-gemfire.cache.server.port", 12480);
|
||||||
|
|
||||||
|
private static final String GEMFIRE_CACHE_SERVER_HOST = "localhost";
|
||||||
|
private static final String GEMFIRE_CACHE_SERVER_HOSTNAME_FOR_CLIENTS = GEMFIRE_CACHE_SERVER_HOST;
|
||||||
|
private static final String GEMFIRE_LOG_FILENAME_PATTERN =
|
||||||
|
String.format("%s", NativeGemFireServer.class.getSimpleName()).concat("-%s.log");
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
newNativeGemFireServer(args).run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String[] args;
|
||||||
|
|
||||||
|
private static File newGemFireLogFile(String suffix) {
|
||||||
|
return new File(String.format(GEMFIRE_LOG_FILENAME_PATTERN, suffix));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static NativeGemFireServer newNativeGemFireServer(String[] args) {
|
||||||
|
return new NativeGemFireServer(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String[] nullSafeStringArray(String[] array) {
|
||||||
|
return (array != null ? array.clone() : new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void writeStringTo(File file, String fileContents) {
|
||||||
|
PrintWriter fileWriter = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
fileWriter = new PrintWriter(new BufferedWriter(new FileWriter(file, true)), true);
|
||||||
|
fileWriter.println(fileContents);
|
||||||
|
fileWriter.flush();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
throw new RuntimeException(String.format("Failed to write [%s] to file [%s]", fileContents, file), e);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (fileWriter != null) {
|
||||||
|
fileWriter.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private NativeGemFireServer(String[] args) {
|
||||||
|
this.args = nullSafeStringArray(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public void run() {
|
||||||
|
run(this.args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run(String[] args) {
|
||||||
|
try {
|
||||||
|
writeStringTo(newGemFireLogFile("stdout"), "Before");
|
||||||
|
|
||||||
|
registerShutdownHook(addCacheServer(createRegion(gemfireCache(
|
||||||
|
gemfireProperties(applicationName())))));
|
||||||
|
|
||||||
|
writeStringTo(newGemFireLogFile("stdout"), "After");
|
||||||
|
}
|
||||||
|
catch (Throwable e) {
|
||||||
|
writeStringTo(newGemFireLogFile("stderr"), e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String applicationName() {
|
||||||
|
return applicationName(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String applicationName(String applicationName) {
|
||||||
|
return StringUtils.hasText(applicationName) ? applicationName
|
||||||
|
: "spring-session-data-gemfire.boot.sample." + NativeGemFireServer.class.getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Properties gemfireProperties(String applicationName) {
|
||||||
|
Properties gemfireProperties = new Properties();
|
||||||
|
|
||||||
|
gemfireProperties.setProperty("name", applicationName);
|
||||||
|
gemfireProperties.setProperty("log-file", "gemfire-server.log");
|
||||||
|
gemfireProperties.setProperty("log-level", "config");
|
||||||
|
//gemfireProperties.setProperty("jmx-manager", "true");
|
||||||
|
//gemfireProperties.setProperty("jmx-manager-start", "true");
|
||||||
|
|
||||||
|
return gemfireProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Cache gemfireCache(Properties gemfireProperties) {
|
||||||
|
return new CacheFactory(gemfireProperties).create();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Cache createRegion(Cache gemfireCache) {
|
||||||
|
RegionFactory<Object, AbstractGemFireOperationsSessionRepository.GemFireSession> regionFactory =
|
||||||
|
gemfireCache.createRegionFactory(RegionShortcut.PARTITION);
|
||||||
|
|
||||||
|
regionFactory.setKeyConstraint(Object.class);
|
||||||
|
regionFactory.setValueConstraint(AbstractGemFireOperationsSessionRepository.GemFireSession.class);
|
||||||
|
regionFactory.setStatisticsEnabled(true);
|
||||||
|
regionFactory.setEntryIdleTimeout(newExpirationAttributes(1800, ExpirationAction.INVALIDATE));
|
||||||
|
|
||||||
|
Region region = regionFactory.create(
|
||||||
|
GemFireHttpSessionConfiguration.DEFAULT_SPRING_SESSION_GEMFIRE_REGION_NAME);
|
||||||
|
|
||||||
|
return gemfireCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExpirationAttributes newExpirationAttributes(int expirationTime, ExpirationAction expirationAction) {
|
||||||
|
return new ExpirationAttributes(expirationTime, expirationAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Cache addCacheServer(Cache gemfireCache) throws IOException {
|
||||||
|
CacheServer cacheServer = gemfireCache.addCacheServer();
|
||||||
|
|
||||||
|
cacheServer.setBindAddress(GEMFIRE_CACHE_SERVER_HOST);
|
||||||
|
cacheServer.setHostnameForClients(GEMFIRE_CACHE_SERVER_HOSTNAME_FOR_CLIENTS);
|
||||||
|
cacheServer.setPort(GEMFIRE_CACHE_SERVER_PORT);
|
||||||
|
cacheServer.start();
|
||||||
|
|
||||||
|
return gemfireCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Cache registerShutdownHook(final Cache gemfireCache) {
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
if (gemfireCache != null) {
|
||||||
|
gemfireCache.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
return gemfireCache;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
apply from: JAVA_GRADLE
|
apply from: JAVA_GRADLE
|
||||||
|
apply from: SAMPLE_GRADLE
|
||||||
apply from: TOMCAT_7_GRADLE
|
apply from: TOMCAT_7_GRADLE
|
||||||
apply plugin: "application"
|
apply plugin: "application"
|
||||||
apply from: SAMPLE_GRADLE
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':spring-session-data-gemfire'),
|
compile project(':spring-session-data-gemfire'),
|
||||||
@@ -38,27 +38,34 @@ task availablePort() {
|
|||||||
|
|
||||||
task runGemFireServer(dependsOn: availablePort) {
|
task runGemFireServer(dependsOn: availablePort) {
|
||||||
doLast {
|
doLast {
|
||||||
println 'STARTING GEMFIRE SERVER...'
|
println "Starting GemFire Server on port [$port]..."
|
||||||
|
|
||||||
|
def out = new StringBuilder()
|
||||||
|
def err = new StringBuilder()
|
||||||
|
|
||||||
String classpath = sourceSets.main.runtimeClasspath.collect { it }.join(File.pathSeparator)
|
String classpath = sourceSets.main.runtimeClasspath.collect { it }.join(File.pathSeparator)
|
||||||
|
String gemfireLogLevel = System.getProperty('sample.httpsession.gemfire.log-level', 'config')
|
||||||
|
|
||||||
String[] commandLine = ['java', '-server', '-ea',
|
String[] commandLine = [
|
||||||
"-Dspring.session.data.gemfire.port=$port",
|
'java', '-server', '-ea', '-classpath', classpath,
|
||||||
"-Dsample.httpsession.gemfire.log-level="
|
"-Dspring.session.data.gemfire.port=$port",
|
||||||
+ System.getProperty('sample.httpsession.gemfire.log-level', 'warning'),
|
"-Dsample.httpsession.gemfire.log-level=" + gemfireLogLevel,
|
||||||
'-classpath', classpath, 'sample.ServerConfig']
|
'sample.ServerConfig'
|
||||||
|
]
|
||||||
|
|
||||||
//println commandLine
|
//println commandLine
|
||||||
|
|
||||||
process = commandLine.execute()
|
process = commandLine.execute()
|
||||||
process.in.close()
|
|
||||||
process.out.close()
|
process.consumeProcessOutput(out, err)
|
||||||
process.err.close()
|
|
||||||
|
//println 'OUT: ' + out
|
||||||
|
//println 'ERR: ' + err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
integrationTest.doLast {
|
integrationTest.doLast {
|
||||||
println 'STOPPING GEMFIRE SERVER...'
|
println 'Stopping GemFire Server...'
|
||||||
process?.destroyForcibly()
|
process?.destroyForcibly()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,9 @@ public class ClientConfig {
|
|||||||
|
|
||||||
static final CountDownLatch LATCH = new CountDownLatch(1);
|
static final CountDownLatch LATCH = new CountDownLatch(1);
|
||||||
|
|
||||||
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "warning";
|
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "config";
|
||||||
|
static final String PROXY_HOST = "dummy.example.com";
|
||||||
|
static final String PROXY_PORT = "3128";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
|
static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
|
||||||
@@ -54,6 +56,7 @@ public class ClientConfig {
|
|||||||
Properties gemfireProperties() { // <2>
|
Properties gemfireProperties() { // <2>
|
||||||
Properties gemfireProperties = new Properties();
|
Properties gemfireProperties = new Properties();
|
||||||
gemfireProperties.setProperty("name", applicationName());
|
gemfireProperties.setProperty("name", applicationName());
|
||||||
|
// gemfireProperties.setProperty("log-file", "gemfire-client.log");
|
||||||
gemfireProperties.setProperty("log-level", logLevel());
|
gemfireProperties.setProperty("log-level", logLevel());
|
||||||
return gemfireProperties;
|
return gemfireProperties;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,13 +36,12 @@ public class ServerConfig {
|
|||||||
|
|
||||||
static final int SERVER_PORT = 12480;
|
static final int SERVER_PORT = 12480;
|
||||||
|
|
||||||
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "warning";
|
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "config";
|
||||||
static final String SERVER_HOST = "localhost";
|
static final String SERVER_HOST = "localhost";
|
||||||
|
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
public static void main(String[] args) throws IOException { // <5>
|
public static void main(String[] args) throws IOException { // <5>
|
||||||
new AnnotationConfigApplicationContext(ServerConfig.class)
|
new AnnotationConfigApplicationContext(ServerConfig.class).registerShutdownHook();
|
||||||
.registerShutdownHook();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@@ -55,21 +54,20 @@ public class ServerConfig {
|
|||||||
|
|
||||||
gemfireProperties.setProperty("name", applicationName());
|
gemfireProperties.setProperty("name", applicationName());
|
||||||
gemfireProperties.setProperty("mcast-port", "0");
|
gemfireProperties.setProperty("mcast-port", "0");
|
||||||
|
// gemfireProperties.setProperty("log-file", "gemfire-server.log");
|
||||||
gemfireProperties.setProperty("log-level", logLevel());
|
gemfireProperties.setProperty("log-level", logLevel());
|
||||||
gemfireProperties.setProperty("jmx-manager", "true");
|
// gemfireProperties.setProperty("jmx-manager", "true");
|
||||||
gemfireProperties.setProperty("jmx-manager-start", "true");
|
// gemfireProperties.setProperty("jmx-manager-start", "true");
|
||||||
|
|
||||||
return gemfireProperties;
|
return gemfireProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
String applicationName() {
|
String applicationName() {
|
||||||
return "samples:httpsession-gemfire-clientserver:"
|
return "samples:httpsession-gemfire-clientserver:".concat(getClass().getSimpleName());
|
||||||
.concat(getClass().getSimpleName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String logLevel() {
|
String logLevel() {
|
||||||
return System.getProperty("sample.httpsession.gemfire.log-level",
|
return System.getProperty("sample.httpsession.gemfire.log-level", DEFAULT_GEMFIRE_LOG_LEVEL);
|
||||||
DEFAULT_GEMFIRE_LOG_LEVEL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
apply from: JAVA_GRADLE
|
apply from: JAVA_GRADLE
|
||||||
|
apply from: SAMPLE_GRADLE
|
||||||
apply from: TOMCAT_7_GRADLE
|
apply from: TOMCAT_7_GRADLE
|
||||||
apply plugin: "application"
|
apply plugin: "application"
|
||||||
apply from: SAMPLE_GRADLE
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':spring-session-data-gemfire'),
|
compile project(':spring-session-data-gemfire'),
|
||||||
@@ -37,7 +37,10 @@ task availablePort() {
|
|||||||
|
|
||||||
task runGemFireServer(dependsOn: availablePort) {
|
task runGemFireServer(dependsOn: availablePort) {
|
||||||
doLast {
|
doLast {
|
||||||
println 'STARTING GEMFIRE SERVER...'
|
println "Starting GemFire Server on port [$port]..."
|
||||||
|
|
||||||
|
def out = new StringBuilder()
|
||||||
|
def err = new StringBuilder()
|
||||||
|
|
||||||
String classpath = sourceSets.main.runtimeClasspath.collect { it }.join(File.pathSeparator)
|
String classpath = sourceSets.main.runtimeClasspath.collect { it }.join(File.pathSeparator)
|
||||||
|
|
||||||
@@ -50,14 +53,16 @@ task runGemFireServer(dependsOn: availablePort) {
|
|||||||
//println commandLine
|
//println commandLine
|
||||||
|
|
||||||
process = commandLine.execute()
|
process = commandLine.execute()
|
||||||
process.in.close()
|
|
||||||
process.out.close()
|
process.consumeProcessOutput(out, err)
|
||||||
process.err.close()
|
|
||||||
|
//println 'OUT: ' + out
|
||||||
|
//println 'ERR: ' + err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
integrationTest.doLast {
|
integrationTest.doLast {
|
||||||
println 'STOPPING GEMFIRE SERVER...'
|
println 'Stopping GemFire Server...'
|
||||||
process?.destroyForcibly()
|
process?.destroyForcibly()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ import org.springframework.context.annotation.ImportResource;
|
|||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
public static void main(final String[] args) {
|
public static void main(final String[] args) {
|
||||||
new AnnotationConfigApplicationContext(Application.class)
|
new AnnotationConfigApplicationContext(Application.class).registerShutdownHook();
|
||||||
.registerShutdownHook();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// tag::end[]
|
// tag::end[]
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ dependencies {
|
|||||||
dependencyManagement {
|
dependencyManagement {
|
||||||
springIoTestRuntime {
|
springIoTestRuntime {
|
||||||
imports {
|
imports {
|
||||||
mavenBom "io.spring.platform:platform-bom:${springIoVersion}"
|
mavenBom "io.spring.platform:platform-bom:$springIoVersion"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user