Adding a way to log the infostream of the lucene writer.

Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/badd38f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/badd38f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/badd38f4

Branch: refs/heads/master
Commit: badd38f475c7c2b2492431771577db2ccb323f72
Parents: fe2a63c
Author: Aaron McCurry <[email protected]>
Authored: Tue Nov 4 09:41:49 2014 -0500
Committer: Aaron McCurry <[email protected]>
Committed: Tue Nov 4 09:41:49 2014 -0500

----------------------------------------------------------------------
 .../manager/writer/BlurIndexSimpleWriter.java   |  1 +
 .../blur/manager/writer/LoggingInfoStream.java  | 52 ++++++++++++++++++++
 blur-core/src/test/resources/log4j.xml          |  6 +++
 distribution/src/main/scripts/conf/log4j.xml    | 19 +++++++
 4 files changed, 78 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/badd38f4/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
----------------------------------------------------------------------
diff --git 
a/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
 
b/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
index 1880868..792a7d8 100644
--- 
a/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
+++ 
b/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
@@ -103,6 +103,7 @@ public class BlurIndexSimpleWriter extends BlurIndex {
     _conf.setWriteLockTimeout(TimeUnit.MINUTES.toMillis(5));
     _conf.setCodec(new Blur024Codec(_tableContext.getBlurConfiguration()));
     _conf.setSimilarity(_tableContext.getSimilarity());
+    _conf.setInfoStream(new 
LoggingInfoStream(_tableContext.getTable(),_shardContext.getShard()));
     TieredMergePolicy mergePolicy = (TieredMergePolicy) _conf.getMergePolicy();
     mergePolicy.setUseCompoundFile(false);
     _conf.setMergeScheduler(mergeScheduler.getMergeScheduler());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/badd38f4/blur-core/src/main/java/org/apache/blur/manager/writer/LoggingInfoStream.java
----------------------------------------------------------------------
diff --git 
a/blur-core/src/main/java/org/apache/blur/manager/writer/LoggingInfoStream.java 
b/blur-core/src/main/java/org/apache/blur/manager/writer/LoggingInfoStream.java
new file mode 100644
index 0000000..db9884b
--- /dev/null
+++ 
b/blur-core/src/main/java/org/apache/blur/manager/writer/LoggingInfoStream.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.manager.writer;
+
+import java.io.IOException;
+
+import org.apache.blur.log.Log;
+import org.apache.blur.log.LogFactory;
+import org.apache.lucene.util.InfoStream;
+
+public class LoggingInfoStream extends InfoStream {
+
+  private static final Log LOG = 
LogFactory.getLog("LUCENE_WRITER_INFO_STREAM");
+
+  private final String _table;
+  private final String _shard;
+
+  public LoggingInfoStream(String table, String shard) {
+    _table = table;
+    _shard = shard;
+  }
+
+  @Override
+  public void message(String component, String message) {
+    LOG.info("Table [" + _table + "] Shard [" + _shard + "] Component [" + 
component + "] Message [" + message + "]");
+  }
+
+  @Override
+  public boolean isEnabled(String component) {
+    return LOG.isInfoEnabled();
+  }
+
+  @Override
+  public void close() throws IOException {
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/badd38f4/blur-core/src/test/resources/log4j.xml
----------------------------------------------------------------------
diff --git a/blur-core/src/test/resources/log4j.xml 
b/blur-core/src/test/resources/log4j.xml
index fad9ffa..e1e247e 100644
--- a/blur-core/src/test/resources/log4j.xml
+++ b/blur-core/src/test/resources/log4j.xml
@@ -41,6 +41,12 @@ under the License.
        <level value="ERROR" />
            <appender-ref ref="console"/>
        </logger>
+       
+       <logger name="LUCENE_WRITER_INFO_STREAM" additivity="false">
+               <!-- Make value = "INFO"to enable -->
+       <level value="ERROR" />
+           <appender-ref ref="console"/>
+       </logger>
        <root>
                <priority value="info" />
                <appender-ref ref="console" />

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/badd38f4/distribution/src/main/scripts/conf/log4j.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/scripts/conf/log4j.xml 
b/distribution/src/main/scripts/conf/log4j.xml
index e769551..af92564 100644
--- a/distribution/src/main/scripts/conf/log4j.xml
+++ b/distribution/src/main/scripts/conf/log4j.xml
@@ -66,6 +66,19 @@ under the License.
                </layout>
        </appender>
        
+       <appender name="ASYNC_LUCENE_WRITER_INFO_STREAM_FILE" 
class="org.apache.log4j.AsyncAppender">
+               <appender-ref ref="LUCENE_WRITER_INFO_STREAM_FILE" />
+       </appender>
+       
+       <appender name="LUCENE_WRITER_INFO_STREAM_FILE" 
class="org.apache.log4j.DailyRollingFileAppender">
+               <param name="File" 
value="${blur.logs.dir}/${blur.log.file}_infostream.log" />
+               <param name="DatePattern" value="'.'yyyyMMdd" />
+               <param name="Append" value="true" />
+               <layout class="org.apache.log4j.PatternLayout">
+                       <param name="ConversionPattern" value="%-5p 
%d{yyyyMMdd_HH:mm:ss:SSS_z} [%t] %c{2}: %m%n" />
+               </layout>
+       </appender>
+       
        <logger name="org.apache.hadoop">
        <level value="ERROR" />
            <appender-ref ref="ASYNC"/>
@@ -82,6 +95,12 @@ under the License.
        <level value="ERROR" />
            <appender-ref ref="ASYNC_RESPONSE_LOG_FILE"/>
        </logger>
+       
+       <logger name="LUCENE_WRITER_INFO_STREAM" additivity="false">
+               <!-- Make value = "INFO"to enable -->
+       <level value="ERROR" />
+           <appender-ref ref="ASYNC_LUCENE_WRITER_INFO_STREAM_FILE"/>
+       </logger>
 
        <!--root>
        For production use, the async configuration will be better for 
performance at the cost of not seeing the final flushed log events.

Reply via email to