-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the issue that apollo initialization logs won't print in eager lo…
…ad mode (#3677)
- Loading branch information
Showing
21 changed files
with
1,135 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
package com.ctrip.framework.apollo.internals; | ||
|
||
import com.ctrip.framework.apollo.build.ApolloInjector; | ||
import com.ctrip.framework.apollo.core.utils.DeferredLoggerFactory; | ||
import com.ctrip.framework.apollo.enums.ConfigSourceType; | ||
import com.ctrip.framework.apollo.util.factory.PropertiesFactory; | ||
import java.util.List; | ||
|
@@ -26,7 +27,6 @@ | |
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.ctrip.framework.apollo.ConfigFile; | ||
import com.ctrip.framework.apollo.ConfigFileChangeListener; | ||
|
@@ -42,7 +42,7 @@ | |
* @author Jason Song([email protected]) | ||
*/ | ||
public abstract class AbstractConfigFile implements ConfigFile, RepositoryChangeListener { | ||
private static final Logger logger = LoggerFactory.getLogger(AbstractConfigFile.class); | ||
private static final Logger logger = DeferredLoggerFactory.getLogger(AbstractConfigFile.class); | ||
private static ExecutorService m_executorService; | ||
protected final ConfigRepository m_configRepository; | ||
protected final String m_namespace; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
*/ | ||
package com.ctrip.framework.apollo.internals; | ||
|
||
import com.ctrip.framework.apollo.core.utils.DeferredLoggerFactory; | ||
import com.ctrip.framework.apollo.enums.ConfigSourceType; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
@@ -29,7 +30,6 @@ | |
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.ctrip.framework.apollo.core.utils.ClassLoaderUtil; | ||
import com.ctrip.framework.apollo.enums.PropertyChangeType; | ||
|
@@ -45,7 +45,8 @@ | |
* @author Jason Song([email protected]) | ||
*/ | ||
public class DefaultConfig extends AbstractConfig implements RepositoryChangeListener { | ||
private static final Logger logger = LoggerFactory.getLogger(DefaultConfig.class); | ||
|
||
private static final Logger logger = DeferredLoggerFactory.getLogger(DefaultConfig.class); | ||
private final String m_namespace; | ||
private final Properties m_resourceProperties; | ||
private final AtomicReference<Properties> m_configProperties; | ||
|
@@ -108,7 +109,9 @@ public String getProperty(String key, String defaultValue) { | |
} | ||
|
||
if (value == null && m_configProperties.get() == null && m_warnLogRateLimiter.tryAcquire()) { | ||
logger.warn("Could not load config for namespace {} from Apollo, please check whether the configs are released in Apollo! Return default value now!", m_namespace); | ||
logger.warn( | ||
"Could not load config for namespace {} from Apollo, please check whether the configs are released in Apollo! Return default value now!", | ||
m_namespace); | ||
} | ||
|
||
return value == null ? defaultValue : value; | ||
|
@@ -152,7 +155,8 @@ public synchronized void onRepositoryChange(String namespace, Properties newProp | |
Properties newConfigProperties = propertiesFactory.getPropertiesInstance(); | ||
newConfigProperties.putAll(newProperties); | ||
|
||
Map<String, ConfigChange> actualChanges = updateAndCalcConfigChanges(newConfigProperties, sourceType); | ||
Map<String, ConfigChange> actualChanges = updateAndCalcConfigChanges(newConfigProperties, | ||
sourceType); | ||
|
||
//check double checked result | ||
if (actualChanges.isEmpty()) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
import com.ctrip.framework.apollo.core.schedule.SchedulePolicy; | ||
import com.ctrip.framework.apollo.core.signature.Signature; | ||
import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory; | ||
import com.ctrip.framework.apollo.core.utils.DeferredLoggerFactory; | ||
import com.ctrip.framework.apollo.core.utils.StringUtils; | ||
import com.ctrip.framework.apollo.enums.ConfigSourceType; | ||
import com.ctrip.framework.apollo.exceptions.ApolloConfigException; | ||
|
@@ -55,13 +56,12 @@ | |
import java.util.concurrent.atomic.AtomicBoolean; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* @author Jason Song([email protected]) | ||
*/ | ||
public class RemoteConfigRepository extends AbstractConfigRepository { | ||
private static final Logger logger = LoggerFactory.getLogger(RemoteConfigRepository.class); | ||
private static final Logger logger = DeferredLoggerFactory.getLogger(RemoteConfigRepository.class); | ||
private static final Joiner STRING_JOINER = Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR); | ||
private static final Joiner.MapJoiner MAP_JOINER = Joiner.on("&").withKeyValueSeparator("="); | ||
private static final Escaper pathEscaper = UrlEscapers.urlPathSegmentEscaper(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.