kfaraz commented on code in PR #18341:
URL: https://github.com/apache/druid/pull/18341#discussion_r2244481280
##########
indexing-service/src/main/java/org/apache/druid/guice/IndexingServiceTaskLogsModule.java:
##########
@@ -39,13 +42,22 @@ public class IndexingServiceTaskLogsModule implements Module
public void configure(Binder binder)
{
PolyBind.createChoice(binder, "druid.indexer.logs.type",
Key.get(TaskLogs.class), Key.get(FileTaskLogs.class));
+ PolyBind.createChoice(binder, "druid.indexer.logs.delegate.type",
Key.get(TaskLogs.class, Names.named("delegate")), Key.get(FileTaskLogs.class));
Review Comment:
It can be a little confusing to have say these props set on the Overlord:
```properties
druid.indexer.logs.type=external
druid.indexer.logs.delegate.type=file
```
It is unclear why we need a delegate if we just wanted `FileTaskLogs`.
I think the intention is to direct task reports, status and payload to one
place and logs to another.
So we need some kind of `switching` or `composite` task logs type, which
would give us these props:
```properties
druid.indexer.logs.type=switching
druid.indexer.logs.switching.reportsType=file
druid.indexer.logs.switching.logsType=hdfs
```
With this, we just need a `SwitchingTaskLogs` implementation which takes in
a `reportsType` and a `logsType`, both of which would be `TaskLogs`
implementations.
##########
indexing-service/src/main/java/org/apache/druid/indexing/common/tasklogs/ExternalLogStreamer.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * 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.druid.indexing.common.tasklogs;
+
+import com.google.common.base.Optional;
+import org.apache.druid.tasklogs.TaskLogStreamer;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class ExternalLogStreamer implements TaskLogStreamer
Review Comment:
This might not be needed if we go the `switching` route.
##########
indexing-service/src/main/java/org/apache/druid/indexing/common/tasklogs/ExternalTaskLogs.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.druid.indexing.common.tasklogs;
+
+import com.google.common.base.Optional;
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.apache.druid.tasklogs.TaskLogs;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class ExternalTaskLogs implements TaskLogs
+{
+ private static final EmittingLogger log = new
EmittingLogger(ExternalTaskLogs.class);
+ private final TaskLogs delegate;
+ private final ExternalLogStreamer logStreamer;
+
+ @Inject
+ public ExternalTaskLogs(@Named("delegate") TaskLogs delegate,
ExternalLogStreamer logStreamer)
+ {
+ this.delegate = delegate;
+ this.logStreamer = logStreamer;
+ }
+
+ @Override
+ public Optional<InputStream> streamTaskLog(String taskid, long offset)
throws IOException
+ {
+ return logStreamer.streamTaskLog(taskid, offset);
+ }
+
+ @Override
+ public Optional<InputStream> streamTaskReports(final String taskid) throws
IOException
+ {
+ return delegate.streamTaskReports(taskid);
+ }
+
+ @Override
+ public Optional<InputStream> streamTaskStatus(final String taskid) throws
IOException
+ {
+ return delegate.streamTaskReports(taskid);
+ }
+
+ @Override
+ public void pushTaskLog(String taskid, File logFile)
+ {
+ log.debug("Skipping task log push for task[%s]", taskid);
Review Comment:
I think log pushing should be enabled by default.
But there should be a config so that we can turn it off if needed.
The same config could be used for controlling log killing as well.
##########
indexing-service/src/main/java/org/apache/druid/guice/IndexingServiceTaskLogsModule.java:
##########
@@ -39,13 +42,22 @@ public class IndexingServiceTaskLogsModule implements Module
public void configure(Binder binder)
{
PolyBind.createChoice(binder, "druid.indexer.logs.type",
Key.get(TaskLogs.class), Key.get(FileTaskLogs.class));
+ PolyBind.createChoice(binder, "druid.indexer.logs.delegate.type",
Key.get(TaskLogs.class, Names.named("delegate")), Key.get(FileTaskLogs.class));
Review Comment:
To ensure that extensions register themselves correctly as a valid type for
say `druid.indexer.logs.switching.logsType`, you would need to add a utility
method in `Binders`, say `bindTaskLogs`.
```java
public static <T extends TaskLogs> void bindTaskLogs(Binder binder, String
type, Class<T> clazz) {
// bind to `druid.indexer.logs.type`
// bind to `druid.indexer.logs.switching.reportsType`
// bind to `druid.indexer.logs.switching.logsType`
}
```
##########
indexing-service/src/main/java/org/apache/druid/indexing/common/tasklogs/ExternalTaskLogs.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.druid.indexing.common.tasklogs;
+
+import com.google.common.base.Optional;
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.apache.druid.tasklogs.TaskLogs;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class ExternalTaskLogs implements TaskLogs
Review Comment:
Technically, all implementations of `TaskLogs` are external to Druid anyway.
If we go the `switching` route, this can be renamed to `SwitchingTaskLogs`
or equivalent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]