Преглед на файлове

Add cat log in service discovery & Add meta resource placeholder

Yiming Liu преди 9 години
родител
ревизия
e355e6ac7f

+ 0 - 1
.gitignore

@@ -28,4 +28,3 @@ dev
 fat
 uat
 prd
-apollo-env.properties

+ 5 - 1
apollo-biz/src/main/java/com/ctrip/apollo/biz/datasource/TitanEntityManager.java

@@ -9,6 +9,8 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Conditional;
 import org.springframework.stereotype.Component;
 
+import com.dianping.cat.Cat;
+
 @Component
 @Conditional(TitanCondition.class)
 public class TitanEntityManager {
@@ -22,8 +24,10 @@ public class TitanEntityManager {
     Class clazz = Class.forName("com.ctrip.datasource.configure.DalDataSourceFactory");
     Object obj = clazz.newInstance();
     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()}));
+    Cat.logEvent("Apollo.Datasource.Titan", settings.getTitanDbname());
+    return ds;
   }
 
 }

+ 10 - 0
apollo-configservice/src/main/java/com/ctrip/apollo/metaservice/service/DiscoveryService.java

@@ -1,6 +1,7 @@
 package com.ctrip.apollo.metaservice.service;
 
 import com.ctrip.apollo.core.ServiceNameConsts;
+import com.dianping.cat.Cat;
 import com.netflix.appinfo.InstanceInfo;
 import com.netflix.discovery.EurekaClient;
 import com.netflix.discovery.shared.Application;
@@ -19,16 +20,25 @@ public class DiscoveryService {
 
   public List<InstanceInfo> getConfigServiceInstances() {
     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<>();
   }
 
   public List<InstanceInfo> getMetaServiceInstances() {
     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<>();
   }
 
   public List<InstanceInfo> getAdminServiceInstances() {
     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<>();
   }
 }

+ 8 - 0
apollo-core/pom.xml

@@ -41,4 +41,12 @@
 		</dependency>
 		<!-- end of log -->
 	</dependencies>
+	<build>
+		<resources>
+			<resource>
+				<directory>src/main/resources</directory>
+				<filtering>true</filtering>
+			</resource>
+		</resources>
+	</build>
 </project>

+ 8 - 0
apollo-core/src/main/resources/apollo-env.properties

@@ -0,0 +1,8 @@
+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};