Skip to content

Commit

Permalink
refactor(): rollback meaningless change
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawven committed Oct 12, 2024
1 parent 5e310b7 commit 75ad161
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 42 deletions.
22 changes: 11 additions & 11 deletions apollo-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@
<artifactId>mockserver-netty</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.noconnor</groupId>
<artifactId>junitperf</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.noconnor</groupId>
<artifactId>junitperf</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- end of test -->
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,4 @@ public interface ConfigManager {
* @return the config file instance for the namespace
*/
ConfigFile getConfigFile(String namespace, ConfigFileFormat configFileFormat);


}
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,41 @@
package com.ctrip.framework.apollo.internals;

import static com.ctrip.framework.apollo.monitor.internal.ApolloClientMonitorConstant.*;
import com.ctrip.framework.apollo.build.ApolloInjector;

import com.ctrip.framework.apollo.core.ApolloClientSystemConsts;
import com.ctrip.framework.apollo.core.ServiceNameConsts;
import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
import com.ctrip.framework.apollo.core.utils.DeferredLoggerFactory;
import com.ctrip.framework.apollo.core.utils.DeprecatedPropertyNotifyUtil;
import com.ctrip.framework.foundation.Foundation;
import com.google.common.util.concurrent.RateLimiter;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;

import org.slf4j.Logger;

import com.ctrip.framework.apollo.build.ApolloInjector;
import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
import com.ctrip.framework.apollo.exceptions.ApolloConfigException;
import com.ctrip.framework.apollo.tracer.Tracer;
import com.ctrip.framework.apollo.tracer.spi.Transaction;
import com.ctrip.framework.apollo.util.ConfigUtil;
import com.ctrip.framework.apollo.util.ExceptionUtil;
import com.ctrip.framework.apollo.util.http.HttpClient;
import com.ctrip.framework.apollo.util.http.HttpRequest;
import com.ctrip.framework.apollo.util.http.HttpResponse;
import com.ctrip.framework.foundation.Foundation;
import com.ctrip.framework.apollo.util.http.HttpClient;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.escape.Escaper;
import com.google.common.net.UrlEscapers;
import com.google.common.util.concurrent.RateLimiter;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import org.slf4j.Logger;

public class ConfigServiceLocator {
private static final Logger logger = DeferredLoggerFactory.getLogger(ConfigServiceLocator.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@
* @author Jason Song([email protected])
*/
public class DefaultConfigManager implements ConfigManager {

protected Map<String, Config> m_configs = Maps.newConcurrentMap();
protected Map<String, Object> m_configLocks = Maps.newConcurrentMap();
protected Map<String, ConfigFile> m_configFiles = Maps.newConcurrentMap();
protected Map<String, Object> m_configFileLocks = Maps.newConcurrentMap();
private ConfigFactoryManager m_factoryManager;

private Map<String, Config> m_configs = Maps.newConcurrentMap();
private Map<String, Object> m_configLocks = Maps.newConcurrentMap();
private Map<String, ConfigFile> m_configFiles = Maps.newConcurrentMap();
private Map<String, Object> m_configFileLocks = Maps.newConcurrentMap();

public DefaultConfigManager() {
m_factoryManager = ApolloInjector.getInstance(ConfigFactoryManager.class);

}

@Override
public Config getConfig(String namespace) {
Config config = m_configs.get(namespace);

if (config == null) {
Object lock = m_configLocks.computeIfAbsent(namespace, key -> new Object());
synchronized (lock) {
Expand All @@ -61,16 +61,15 @@ public Config getConfig(String namespace) {
}
}
}
if(!ConfigSourceType.NONE.equals(config.getSourceType())) {
Tracer.logMetricsForCount(APOLLO_CLIENT_NAMESPACE_USAGE+":"+namespace);
if (!ConfigSourceType.NONE.equals(config.getSourceType())) {
Tracer.logMetricsForCount(APOLLO_CLIENT_NAMESPACE_USAGE + ":" + namespace);
}

return config;
}

@Override
public ConfigFile getConfigFile(String namespace,
ConfigFileFormat configFileFormat) {
public ConfigFile getConfigFile(String namespace, ConfigFileFormat configFileFormat) {
String namespaceFileName = String.format("%s.%s", namespace, configFileFormat.getValue());
ConfigFile configFile = m_configFiles.get(namespaceFileName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import com.google.inject.Singleton;
import java.util.List;

;

/**
* Guice injector
* @author Jason Song([email protected])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private void doLongPollingRefresh(String appId, String cluster, String dataCente
transaction.setStatus(ex);
long sleepTimeInSecond = m_longPollFailSchedulePolicyInSecond.fail();
if (ex.getCause() instanceof SocketTimeoutException) {
Tracer.logEvent(APOLLO_CLIENT_NAMESPACE_TIMEOUT,assembleNamespaces());
Tracer.logEvent(APOLLO_CLIENT_NAMESPACE_TIMEOUT, assembleNamespaces());
}
logger.warn(
"Long polling failed, will retry in {} seconds. appId: {}, cluster: {}, namespaces: {}, long polling url: {}, reason: {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ protected synchronized void sync() {
Transaction transaction = Tracer.newTransaction("Apollo.ConfigService", "syncRemoteConfig");

try {

ApolloConfig previous = m_configCache.get();
ApolloConfig current = loadApolloConfig();

Expand All @@ -161,7 +160,6 @@ protected synchronized void sync() {
logger.debug("Remote Config refreshed!");
m_configCache.set(current);
this.fireRepositoryChange(m_namespace, this.getConfig());

}

if (current != null) {
Expand Down

0 comments on commit 75ad161

Please sign in to comment.