You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2021/07/15 16:38:16 UTC

[tika] branch main updated: TIKA-3480 -- add pipesClientId as property to the classpath in the forked process

This is an automated email from the ASF dual-hosted git repository.

tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/main by this push:
     new 1bf7965  TIKA-3480 -- add pipesClientId as property to the classpath in the forked process
1bf7965 is described below

commit 1bf79652e3c2094a9e8532bb5e6694d07803b2b8
Author: tallison <ta...@apache.org>
AuthorDate: Thu Jul 15 12:37:54 2021 -0400

    TIKA-3480 -- add pipesClientId as property to the classpath in the forked process
---
 .../java/org/apache/tika/pipes/PipesClient.java    |  6 ++++
 tika-core/src/test/resources/log4j.properties      | 25 -----------------
 tika-core/src/test/resources/log4j2.xml            | 32 ++++++++++++++++++++++
 3 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/tika-core/src/main/java/org/apache/tika/pipes/PipesClient.java b/tika-core/src/main/java/org/apache/tika/pipes/PipesClient.java
index 1d12f2c..995e33a 100644
--- a/tika-core/src/main/java/org/apache/tika/pipes/PipesClient.java
+++ b/tika-core/src/main/java/org/apache/tika/pipes/PipesClient.java
@@ -33,6 +33,7 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.FutureTask;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -45,14 +46,18 @@ public class PipesClient implements Closeable {
 
     private static final Logger LOG = LoggerFactory.getLogger(PipesClient.class);
     private static final int MAX_BYTES_BEFORE_READY = 20000;
+    private static AtomicInteger CLIENT_COUNTER = new AtomicInteger(0);
+
     private Process process;
     private final PipesConfigBase pipesConfig;
     private DataOutputStream output;
     private DataInputStream input;
+    private final int pipesClientId;
     private final ExecutorService executorService = Executors.newFixedThreadPool(1);
 
     public PipesClient(PipesConfigBase pipesConfig) {
         this.pipesConfig = pipesConfig;
+        this.pipesClientId = CLIENT_COUNTER.getAndIncrement();
     }
 
     private int filesProcessed = 0;
@@ -316,6 +321,7 @@ public class PipesClient implements Closeable {
         if (! hasLog4j) {
             commandLine.add("-Dlog4j.configurationFile=classpath:pipes-fork-server-default-log4j2.xml");
         }
+        commandLine.add("-DpipesClientId=" + pipesClientId);
         commandLine.addAll(configArgs);
         commandLine.add("org.apache.tika.pipes.PipesServer");
         commandLine.add(
diff --git a/tika-core/src/test/resources/log4j.properties b/tika-core/src/test/resources/log4j.properties
deleted file mode 100644
index 8c10642..0000000
--- a/tika-core/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# 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.
-
-#info,debug, error,fatal ...
-log4j.rootLogger=info,stdout
-
-#console
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-
-# Pattern to output the caller's file name and line number.
-log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
diff --git a/tika-core/src/test/resources/log4j2.xml b/tika-core/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..5f946e6
--- /dev/null
+++ b/tika-core/src/test/resources/log4j2.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<Configuration status="INFO">
+  <Appenders>
+    <Console name="console" target="SYSTEM_ERR">
+      <PatternLayout
+          pattern="%-5p [%t] %d{HH:mm:ss,SSS} %c %m%n" />
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Root level="info" additivity="false">
+      <AppenderRef ref="console" />
+    </Root>
+  </Loggers>
+</Configuration>