Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit 123f1b6

Browse files
authored
Merge pull request #42 from GoogleCloudPlatform/gcs-s3-inspect
Fix DLP client version conflict with beam 2.16 and change window strategy for S3 scan
2 parents cfb29c4 + ec134f5 commit 123f1b6

2 files changed

Lines changed: 4 additions & 13 deletions

File tree

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ dependencies {
7070
compile group: 'org.apache.beam', name: 'beam-runners-direct-java', version: dataflowBeamVersion
7171
compile group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.7.5'
7272
compile 'com.google.cloud:google-cloud-kms:0.70.0-beta'
73-
compile 'com.google.cloud:google-cloud-dlp:0.74.0-beta'
7473
compile 'com.google.guava:guava:27.0-jre'
74+
compile group: 'com.google.cloud', name: 'google-cloud-dlp', version: '0.100.0-beta'
7575
compile 'com.google.api-client:google-api-client:1.27.0'
76-
//compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.546'
7776
compile group: 'com.google.apis', name: 'google-api-services-cloudkms', version: 'v1-rev53-1.23.0'
7877
compile group: 'org.apache.beam', name: 'beam-sdks-java-io-amazon-web-services', version: dataflowBeamVersion
7978
compile "com.google.auto.value:auto-value-annotations:1.6.2"

src/main/java/com/google/swarm/tokenization/S3Import.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
import org.apache.beam.sdk.transforms.WithKeys;
6060
import org.apache.beam.sdk.transforms.splittabledofn.OffsetRangeTracker;
6161
import org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker;
62-
import org.apache.beam.sdk.transforms.windowing.AfterPane;
63-
import org.apache.beam.sdk.transforms.windowing.AfterProcessingTime;
6462
import org.apache.beam.sdk.transforms.windowing.AfterWatermark;
6563
import org.apache.beam.sdk.transforms.windowing.FixedWindows;
6664
import org.apache.beam.sdk.transforms.windowing.Window;
@@ -85,8 +83,8 @@ public class S3Import {
8583
private static Integer BATCH_SIZE = 520000;
8684
private static Integer DLP_PAYLOAD_LIMIT = 524288;
8785
private static final String BQ_TABLE_NAME = String.valueOf("S3_DLP_INSPECT_FINDINGS");
88-
private static final Duration DEFAULT_POLL_INTERVAL = Duration.standardSeconds(30);
89-
private static final Duration WINDOW_INTERVAL = Duration.standardSeconds(5);
86+
private static final Duration DEFAULT_POLL_INTERVAL = Duration.standardSeconds(60);
87+
private static final Duration WINDOW_INTERVAL = Duration.standardSeconds(10);
9088
private static final DateTimeFormatter TIMESTAMP_FORMATTER =
9189
DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
9290

@@ -122,12 +120,7 @@ public static void main(String[] args) {
122120
s3Files.apply(
123121
"Fixed Window",
124122
Window.<KV<String, ReadableFile>>into(FixedWindows.of(WINDOW_INTERVAL))
125-
.triggering(
126-
AfterWatermark.pastEndOfWindow()
127-
.withEarlyFirings(
128-
AfterProcessingTime.pastFirstElementInPane()
129-
.plusDelayOf(Duration.standardSeconds(10)))
130-
.withLateFirings(AfterPane.elementCountAtLeast(1)))
123+
.triggering(AfterWatermark.pastEndOfWindow())
131124
.discardingFiredPanes()
132125
.withAllowedLateness(Duration.ZERO));
133126

@@ -275,7 +268,6 @@ public void processElement(ProcessContext c) throws IOException {
275268

276269
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
277270
if (!c.element().getValue().isEmpty()) {
278-
279271
ContentItem contentItem =
280272
ContentItem.newBuilder().setValue(c.element().getValue()).build();
281273
this.requestBuilder.setItem(contentItem);

0 commit comments

Comments
 (0)