curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [2/8] git commit: more work on CLI - added airlift logging and logging config
Date Wed, 28 May 2014 17:33:52 GMT
more work on CLI - added airlift logging and logging config


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/1927c332
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/1927c332
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/1927c332

Branch: refs/heads/curator-rpc
Commit: 1927c332bb3a137b285edc25e48798ac4fa68c7e
Parents: e11db6d
Author: randgalt <randgalt@apache.org>
Authored: Tue May 27 18:11:03 2014 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Tue May 27 18:11:03 2014 -0500

----------------------------------------------------------------------
 curator-x-rpc/pom.xml                           | 33 ++++++++++++++++
 .../curator/x/rpc/CuratorProjectionServer.java  | 41 +++++++++++++++-----
 pom.xml                                         | 11 ++++++
 3 files changed, 76 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/1927c332/curator-x-rpc/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-rpc/pom.xml b/curator-x-rpc/pom.xml
index cf2442c..f27a383 100644
--- a/curator-x-rpc/pom.xml
+++ b/curator-x-rpc/pom.xml
@@ -14,6 +14,20 @@
         <dependency>
             <groupId>org.apache.curator</groupId>
             <artifactId>curator-recipes</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>log4j-over-slf4j</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>log4j</groupId>
+                    <artifactId>log4j</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
@@ -22,8 +36,27 @@
         </dependency>
 
         <dependency>
+            <groupId>io.airlift</groupId>
+            <artifactId>log-manager</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.curator</groupId>
             <artifactId>curator-test</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>log4j-over-slf4j</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>log4j</groupId>
+                    <artifactId>log4j</artifactId>
+                </exclusion>
+            </exclusions>
             <scope>test</scope>
         </dependency>
     </dependencies>

http://git-wip-us.apache.org/repos/asf/curator/blob/1927c332/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java
b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java
index d91a52d..e2de3f4 100644
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java
@@ -28,6 +28,8 @@ import com.google.common.collect.Maps;
 import io.airlift.configuration.ConfigurationFactory;
 import io.airlift.configuration.ConfigurationLoader;
 import io.airlift.configuration.ConfigurationMetadata;
+import io.airlift.log.Logging;
+import io.airlift.log.LoggingConfiguration;
 import io.airlift.units.DataSize;
 import io.airlift.units.Duration;
 import org.apache.curator.x.rpc.idl.event.EventService;
@@ -76,6 +78,8 @@ public class CuratorProjectionServer
         }
 
         ConfigurationFactory configurationFactory = new ConfigurationFactory(options);
+        initLogging(configurationFactory);
+
         Configuration configuration = configurationFactory.build(Configuration.class);
 
         final CuratorProjectionServer server = new CuratorProjectionServer(configuration);
@@ -93,6 +97,12 @@ public class CuratorProjectionServer
         Runtime.getRuntime().addShutdownHook(hook);
     }
 
+    private static void initLogging(ConfigurationFactory configurationFactory) throws IOException
+    {
+        LoggingConfiguration loggingConfiguration = configurationFactory.build(LoggingConfiguration.class);
+        Logging.initialize().configure(loggingConfiguration);
+    }
+
     public CuratorProjectionServer(Configuration configuration)
     {
         this.configuration = configuration;
@@ -135,17 +145,15 @@ public class CuratorProjectionServer
         System.out.println("\t<field value> ...   list of values that would be in the
JSON configuration file");
         System.out.println();
 
+        Map<String, String> valuesMap = Maps.newTreeMap();
+
+        buildMetaData(valuesMap, ConfigurationMetadata.getConfigurationMetadata(Configuration.class));
+        buildMetaData(valuesMap, ConfigurationMetadata.getConfigurationMetadata(LoggingConfiguration.class));
+
         System.out.println("Values:");
-        ConfigurationMetadata<Configuration> metadata = ConfigurationMetadata.getConfigurationMetadata(Configuration.class);
-        for ( ConfigurationMetadata.AttributeMetadata attributeMetadata : metadata.getAttributes().values()
)
+        for ( String s : valuesMap.values() )
         {
-            ConfigurationMetadata.InjectionPointMetaData injectionPoint = attributeMetadata.getInjectionPoint();
-            System.out.println("\t" + injectionPoint.getProperty() + ": " + attributeMetadata.getGetter().getReturnType().getSimpleName());
-            if ( attributeMetadata.getDescription() != null )
-            {
-                System.out.println("\t\t" + attributeMetadata.getDescription());
-            }
-            System.out.println();
+            System.out.println(s);
         }
 
         System.out.println("Special Types Examples:");
@@ -160,6 +168,21 @@ public class CuratorProjectionServer
         System.out.println();
     }
 
+    private static void buildMetaData(Map<String, String> valuesMap, ConfigurationMetadata<?>
metadata)
+    {
+        for ( ConfigurationMetadata.AttributeMetadata attributeMetadata : metadata.getAttributes().values()
)
+        {
+            int index = 0;
+            ConfigurationMetadata.InjectionPointMetaData injectionPoint = attributeMetadata.getInjectionPoint();
+            valuesMap.put(injectionPoint.getProperty() + index++, "\t" + injectionPoint.getProperty()
+ ": " + attributeMetadata.getGetter().getReturnType().getSimpleName());
+            if ( attributeMetadata.getDescription() != null )
+            {
+                valuesMap.put(injectionPoint.getProperty() + index++, "\t\t" + attributeMetadata.getDescription());
+            }
+            valuesMap.put(injectionPoint.getProperty() + index, "");
+        }
+    }
+
     private static Map<String, String> buildOptions(String[] args) throws IOException
     {
         Map<String, String> options = Maps.newHashMap();

http://git-wip-us.apache.org/repos/asf/curator/blob/1927c332/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 51f050a..c028839 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,6 +85,7 @@
         <guava-version>16.0.1</guava-version>
         <testng-version>6.8.8</testng-version>
         <swift-version>0.12.0</swift-version>
+        <airlift-version>0.88</airlift-version>
 
         <!-- OSGi Properties -->
         <osgi.export.package />
@@ -400,6 +401,10 @@
                         <groupId>junit</groupId>
                         <artifactId>junit</artifactId>
                     </exclusion>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-log4j12</artifactId>
+                    </exclusion>
                 </exclusions>
             </dependency>
 
@@ -426,6 +431,12 @@
                 <artifactId>swift-service</artifactId>
                 <version>${swift-version}</version>
             </dependency>
+
+            <dependency>
+                <groupId>io.airlift</groupId>
+                <artifactId>log-manager</artifactId>
+                <version>${airlift-version}</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 


Mime
View raw message