Commit e355e6ac by Yiming Liu

Add cat log in service discovery & Add meta resource placeholder

parent 12f05863
...@@ -28,4 +28,3 @@ dev ...@@ -28,4 +28,3 @@ dev
fat fat
uat uat
prd prd
apollo-env.properties
...@@ -9,6 +9,8 @@ import org.springframework.context.annotation.Bean; ...@@ -9,6 +9,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.dianping.cat.Cat;
@Component @Component
@Conditional(TitanCondition.class) @Conditional(TitanCondition.class)
public class TitanEntityManager { public class TitanEntityManager {
...@@ -22,8 +24,10 @@ public class TitanEntityManager { ...@@ -22,8 +24,10 @@ public class TitanEntityManager {
Class clazz = Class.forName("com.ctrip.datasource.configure.DalDataSourceFactory"); Class clazz = Class.forName("com.ctrip.datasource.configure.DalDataSourceFactory");
Object obj = clazz.newInstance(); Object obj = clazz.newInstance();
Method method = clazz.getMethod("createDataSource", new Class[] {String.class, String.class}); Method method = clazz.getMethod("createDataSource", new Class[] {String.class, String.class});
return ((DataSource) method.invoke(obj, DataSource ds = ((DataSource) method.invoke(obj,
new Object[] {settings.getTitanDbname(), settings.getTitanUrl()})); new Object[] {settings.getTitanDbname(), settings.getTitanUrl()}));
Cat.logEvent("Apollo.Datasource.Titan", settings.getTitanDbname());
return ds;
} }
} }
package com.ctrip.apollo.metaservice.service; package com.ctrip.apollo.metaservice.service;
import com.ctrip.apollo.core.ServiceNameConsts; import com.ctrip.apollo.core.ServiceNameConsts;
import com.dianping.cat.Cat;
import com.netflix.appinfo.InstanceInfo; import com.netflix.appinfo.InstanceInfo;
import com.netflix.discovery.EurekaClient; import com.netflix.discovery.EurekaClient;
import com.netflix.discovery.shared.Application; import com.netflix.discovery.shared.Application;
...@@ -19,16 +20,25 @@ public class DiscoveryService { ...@@ -19,16 +20,25 @@ public class DiscoveryService {
public List<InstanceInfo> getConfigServiceInstances() { public List<InstanceInfo> getConfigServiceInstances() {
Application application = eurekaClient.getApplication(ServiceNameConsts.APOLLO_CONFIGSERVICE); Application application = eurekaClient.getApplication(ServiceNameConsts.APOLLO_CONFIGSERVICE);
if (application == null) {
Cat.logEvent("Apollo.EurekaDiscovery.NotFound", ServiceNameConsts.APOLLO_CONFIGSERVICE);
}
return application != null ? application.getInstances() : new ArrayList<>(); return application != null ? application.getInstances() : new ArrayList<>();
} }
public List<InstanceInfo> getMetaServiceInstances() { public List<InstanceInfo> getMetaServiceInstances() {
Application application = eurekaClient.getApplication(ServiceNameConsts.APOLLO_METASERVICE); Application application = eurekaClient.getApplication(ServiceNameConsts.APOLLO_METASERVICE);
if (application == null) {
Cat.logEvent("Apollo.EurekaDiscovery.NotFound", ServiceNameConsts.APOLLO_METASERVICE);
}
return application != null ? application.getInstances() : new ArrayList<>(); return application != null ? application.getInstances() : new ArrayList<>();
} }
public List<InstanceInfo> getAdminServiceInstances() { public List<InstanceInfo> getAdminServiceInstances() {
Application application = eurekaClient.getApplication(ServiceNameConsts.APOLLO_ADMINSERVICE); Application application = eurekaClient.getApplication(ServiceNameConsts.APOLLO_ADMINSERVICE);
if (application == null) {
Cat.logEvent("Apollo.EurekaDiscovery.NotFound", ServiceNameConsts.APOLLO_ADMINSERVICE);
}
return application != null ? application.getInstances() : new ArrayList<>(); return application != null ? application.getInstances() : new ArrayList<>();
} }
} }
...@@ -41,4 +41,12 @@ ...@@ -41,4 +41,12 @@
</dependency> </dependency>
<!-- end of log --> <!-- end of log -->
</dependencies> </dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project> </project>
local.meta=http://localhost:8080
dev.meta=${dev};
fat.meta=${fat};
fws.meta=${fws};
uat.meta=${uat};
lpt.meta=${lpt};
tools.meta=${tools};
pro.meta=${pro};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment