-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an SdkHarnessOption that controls whether logging is redirected t…
…hrough the FnApi logging service. Redirection through the logging service is enabled by default.
- Loading branch information
Showing
6 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/logging/LoggingClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.apache.beam.fn.harness.logging; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public interface LoggingClient extends AutoCloseable { | ||
|
||
CompletableFuture<?> terminationFuture(); | ||
} |
42 changes: 42 additions & 0 deletions
42
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/logging/LoggingClientFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.apache.beam.fn.harness.logging; | ||
|
||
import io.grpc.ManagedChannel; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.function.Function; | ||
import org.apache.beam.model.pipeline.v1.Endpoints; | ||
import org.apache.beam.sdk.options.PipelineOptions; | ||
import org.apache.beam.sdk.options.SdkHarnessOptions; | ||
|
||
/** | ||
* A factory for {@link LoggingClient}s. Provides {@link BeamFnLoggingClient} if the logging service | ||
* is enabled, otherwise provides a no-op client. | ||
*/ | ||
public class LoggingClientFactory { | ||
|
||
private LoggingClientFactory() {} | ||
|
||
/** | ||
* A factory for {@link LoggingClient}s. Provides {@link BeamFnLoggingClient} if the logging | ||
* service is enabled, otherwise provides a no-op client. | ||
*/ | ||
public static LoggingClient createAndStart( | ||
PipelineOptions options, | ||
Endpoints.ApiServiceDescriptor apiServiceDescriptor, | ||
Function<Endpoints.ApiServiceDescriptor, ManagedChannel> channelFactory) { | ||
if (options.as(SdkHarnessOptions.class).getEnableLoggingService()) { | ||
return BeamFnLoggingClient.createAndStart(options, apiServiceDescriptor, channelFactory); | ||
} else { | ||
return new NoOpLoggingClient(); | ||
} | ||
} | ||
|
||
static final class NoOpLoggingClient implements LoggingClient { | ||
@Override | ||
public CompletableFuture<?> terminationFuture() { | ||
return CompletableFuture.completedFuture(new Object()); | ||
} | ||
|
||
@Override | ||
public void close() throws Exception {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters