提交 90c85d3e 编写于 作者: J Jason Song

Misc changes.

1. Adjust portal jvm memory size
2. Retry if client get empty response from meta server
3. Fix potential npe issues
上级 a0308f8d
...@@ -22,6 +22,9 @@ public class EntityManagerUtil extends EntityManagerFactoryAccessor { ...@@ -22,6 +22,9 @@ public class EntityManagerUtil extends EntityManagerFactoryAccessor {
public void closeEntityManager() { public void closeEntityManager() {
EntityManagerHolder emHolder = (EntityManagerHolder) EntityManagerHolder emHolder = (EntityManagerHolder)
TransactionSynchronizationManager.getResource(getEntityManagerFactory()); TransactionSynchronizationManager.getResource(getEntityManagerFactory());
if (emHolder == null) {
return;
}
logger.debug("Closing JPA EntityManager in EntityManagerUtil"); logger.debug("Closing JPA EntityManager in EntityManagerUtil");
EntityManagerFactoryUtils.closeEntityManager(emHolder.getEntityManager()); EntityManagerFactoryUtils.closeEntityManager(emHolder.getEntityManager());
} }
......
...@@ -100,7 +100,7 @@ public interface Config { ...@@ -100,7 +100,7 @@ public interface Config {
* exist. * exist.
* *
* @param key the property name * @param key the property name
* @param delimiter * @param delimiter the delimiter regex
* @param defaultValue the default value when key is not found * @param defaultValue the default value when key is not found
* @return * @return
*/ */
......
...@@ -114,9 +114,14 @@ public class ConfigServiceLocator implements Initializable { ...@@ -114,9 +114,14 @@ public class ConfigServiceLocator implements Initializable {
transaction.addData("Url", url); transaction.addData("Url", url);
try { try {
HttpResponse<List<ServiceDTO>> response = m_httpUtil.doGet(request, m_responseType); HttpResponse<List<ServiceDTO>> response = m_httpUtil.doGet(request, m_responseType);
m_configServices.set(response.getBody());
logConfigServicesToCat(response.getBody());
transaction.setStatus(Message.SUCCESS); transaction.setStatus(Message.SUCCESS);
List<ServiceDTO> services = response.getBody();
if (services == null || services.isEmpty()) {
logConfigServiceToCat("Empty response!");
continue;
}
m_configServices.set(services);
logConfigServicesToCat(services);
return; return;
} catch (Throwable ex) { } catch (Throwable ex) {
Cat.logError(ex); Cat.logError(ex);
...@@ -151,7 +156,11 @@ public class ConfigServiceLocator implements Initializable { ...@@ -151,7 +156,11 @@ public class ConfigServiceLocator implements Initializable {
private void logConfigServicesToCat(List<ServiceDTO> serviceDtos) { private void logConfigServicesToCat(List<ServiceDTO> serviceDtos) {
for (ServiceDTO serviceDto : serviceDtos) { for (ServiceDTO serviceDto : serviceDtos) {
Cat.logEvent("Apollo.Config.Services", serviceDto.getHomepageUrl()); logConfigServiceToCat(serviceDto.getHomepageUrl());
} }
} }
private void logConfigServiceToCat(String serviceUrl) {
Cat.logEvent("Apollo.Config.Services", serviceUrl);
}
} }
...@@ -30,6 +30,9 @@ public class TitanSettings { ...@@ -30,6 +30,9 @@ public class TitanSettings {
public String getTitanUrl() { public String getTitanUrl() {
Env env = EnvUtils.transformEnv(Foundation.server().getEnvType()); Env env = EnvUtils.transformEnv(Foundation.server().getEnvType());
if (env == null) {
return "";
}
switch (env) { switch (env) {
case FAT: case FAT:
case FWS: case FWS:
...@@ -46,6 +49,9 @@ public class TitanSettings { ...@@ -46,6 +49,9 @@ public class TitanSettings {
public String getTitanDbname() { public String getTitanDbname() {
Env env = EnvUtils.transformEnv(Foundation.server().getEnvType()); Env env = EnvUtils.transformEnv(Foundation.server().getEnvType());
if (env == null) {
return "";
}
switch (env) { switch (env) {
case FAT: case FAT:
case FWS: case FWS:
......
import com.google.common.base.Strings;
import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigChangeListener; import com.ctrip.framework.apollo.ConfigChangeListener;
import com.ctrip.framework.apollo.ConfigService; import com.ctrip.framework.apollo.ConfigService;
...@@ -39,7 +36,7 @@ public class ApolloConfigDemo implements ConfigChangeListener { ...@@ -39,7 +36,7 @@ public class ApolloConfigDemo implements ConfigChangeListener {
while (true) { while (true) {
System.out.print("> "); System.out.print("> ");
String input = new BufferedReader(new InputStreamReader(System.in)).readLine(); String input = new BufferedReader(new InputStreamReader(System.in)).readLine();
if (Strings.isNullOrEmpty(input)) { if (input == null || input.length() == 0) {
continue; continue;
} }
input = input.trim(); input = input.trim();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
SERVICE_NAME=apollo-portal SERVICE_NAME=apollo-portal
PATH_TO_JAR=$SERVICE_NAME".jar" PATH_TO_JAR=$SERVICE_NAME".jar"
export JAVA_OPTS="-server -Xms4096m -Xmx4096m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1536m -XX:MaxNewSize=1536m -XX:SurvivorRatio=22 -XX:+UseParNewGC -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+UseConcMarkSweepGC -XX:+DisableExplicitGC -XX:+UseCMSInitiatingOccupancyOnly -XX:+ScavengeBeforeFullGC -XX:+UseCMSCompactAtFullCollection -XX:+CMSParallelRemarkEnabled -XX:CMSFullGCsBeforeCompaction=9 -XX:CMSInitiatingOccupancyFraction=60 -XX:+CMSClassUnloadingEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:-ReduceInitialCardMarks -XX:+CMSPermGenSweepingEnabled -XX:CMSInitiatingPermOccupancyFraction=70 -XX:+ExplicitGCInvokesConcurrent -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8" export JAVA_OPTS="-server -Xms8192m -Xmx8192m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=3072m -XX:MaxNewSize=3072m -XX:SurvivorRatio=22 -XX:+UseParNewGC -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+UseConcMarkSweepGC -XX:+DisableExplicitGC -XX:+UseCMSInitiatingOccupancyOnly -XX:+ScavengeBeforeFullGC -XX:+UseCMSCompactAtFullCollection -XX:+CMSParallelRemarkEnabled -XX:CMSFullGCsBeforeCompaction=9 -XX:CMSInitiatingOccupancyFraction=60 -XX:+CMSClassUnloadingEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:-ReduceInitialCardMarks -XX:+CMSPermGenSweepingEnabled -XX:CMSInitiatingPermOccupancyFraction=70 -XX:+ExplicitGCInvokesConcurrent -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8"
export JAVA_OPTS="$JAVA_OPTS -Xloggc:/opt/logs/100003173/heap_trace.txt -XX:HeapDumpPath=/opt/logs/100003173/HeapDumpOnOutOfMemoryError/" export JAVA_OPTS="$JAVA_OPTS -Xloggc:/opt/logs/100003173/heap_trace.txt -XX:HeapDumpPath=/opt/logs/100003173/HeapDumpOnOutOfMemoryError/"
if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册