embulk-input-bigquery_extract_files 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/build.gradle +1 -1
- data/src/main/java/org/embulk/input/bigquery_export_gcs/BigqueryExportGcsFileInputPlugin.java +12 -1
- data/src/main/java/org/embulk/input/bigquery_export_gcs/BigqueryExportUtils.java +18 -13
- data/src/test/java/org/embulk/input/bigquery_export_gcs/TestGoogleCloudAccessData.java +17 -1
- data/src/test/java/org/embulk/input/bigquery_export_gcs/TestPluginFunctions.java +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdb3cb2064c1b19c0748adb981d2593fd30950af
|
4
|
+
data.tar.gz: 4c54a7075d3b4877e0ad66d2e91125fbd2b1af61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e4c7646e18867ef61a6488151eed43bda4001b1935bcffc1d5cb5ef545eaf731f3aa94f3f663a07d8d9e363f60b407072dcfea4c41722c5cd8c4dcb807e48cf
|
7
|
+
data.tar.gz: c5f6d6843afb3848714be3bb0ae9dc249ea68f40cf92db75911222c7d72adf0bd55f4b65c8cb1971a8eb357e8678425d0a06befc6d9fb7e0a6668c93da0c04a3
|
data/build.gradle
CHANGED
data/src/main/java/org/embulk/input/bigquery_export_gcs/BigqueryExportGcsFileInputPlugin.java
CHANGED
@@ -122,7 +122,8 @@ public class BigqueryExportGcsFileInputPlugin implements FileInputPlugin
|
|
122
122
|
@Config("bigquery_job_wait_second")
|
123
123
|
@ConfigDefault("600")
|
124
124
|
public Optional<Integer> getBigqueryJobWaitingSecond();
|
125
|
-
|
125
|
+
public void setBigqueryJobWaitingSecond(Optional<Integer> second);
|
126
|
+
|
126
127
|
@Config("cleanup_gcs_files")
|
127
128
|
@ConfigDefault("false")
|
128
129
|
public boolean getCleanupGcsTempFiles();
|
@@ -174,6 +175,16 @@ public class BigqueryExportGcsFileInputPlugin implements FileInputPlugin
|
|
174
175
|
public boolean getDirectDownloadEnabled();
|
175
176
|
//public Schema getSchemaConfig();
|
176
177
|
//public void setSchameConfig(SchemaConfig schema);
|
178
|
+
|
179
|
+
/**
|
180
|
+
* 2020.11.16 sometimes, bigquery extract job just very slow. not becouse of error. then workflow must throw exception for alert message
|
181
|
+
* @return
|
182
|
+
*/
|
183
|
+
@Config("throw_bigquery_job_wait_timeout")
|
184
|
+
@ConfigDefault("false")
|
185
|
+
public boolean getThrowBigqueryJobWaitTimeout();
|
186
|
+
public void setThrowBigqueryJobWaitTimeout(boolean toThrow);
|
187
|
+
|
177
188
|
}
|
178
189
|
|
179
190
|
@Override
|
@@ -1,11 +1,6 @@
|
|
1
1
|
package org.embulk.input.bigquery_export_gcs;
|
2
2
|
|
3
|
-
import java.io
|
4
|
-
import java.io.FileInputStream;
|
5
|
-
import java.io.FileNotFoundException;
|
6
|
-
import java.io.FileOutputStream;
|
7
|
-
import java.io.IOException;
|
8
|
-
import java.io.InputStream;
|
3
|
+
import java.io.*;
|
9
4
|
import java.math.BigInteger;
|
10
5
|
import java.nio.file.FileSystems;
|
11
6
|
import java.nio.file.Path;
|
@@ -141,7 +136,7 @@ public class BigqueryExportUtils
|
|
141
136
|
|
142
137
|
log.info("query to Table jobId : {} : waiting for job end...",jobId);
|
143
138
|
|
144
|
-
Job lastJob = waitForJob(bigquery, task.getProject(), jobId, task.getLocation().get(), task.getBigqueryJobWaitingSecond().get());
|
139
|
+
Job lastJob = waitForJob(bigquery, task.getProject(), jobId, task.getLocation().get(), task.getBigqueryJobWaitingSecond().get(), task.getThrowBigqueryJobWaitTimeout());
|
145
140
|
|
146
141
|
log.debug("waiting for job end....... {}", lastJob.toPrettyString());
|
147
142
|
}
|
@@ -220,7 +215,10 @@ public class BigqueryExportUtils
|
|
220
215
|
do {
|
221
216
|
objects = listRequest.execute();
|
222
217
|
if(objects.getItems() == null){
|
223
|
-
|
218
|
+
|
219
|
+
String errorMessage = String.format("file not found in gs://%s/%s",bucket,blobName);
|
220
|
+
log.error(errorMessage);
|
221
|
+
|
224
222
|
return builder.build();
|
225
223
|
}
|
226
224
|
for(StorageObject obj : objects.getItems()){
|
@@ -337,14 +335,14 @@ public class BigqueryExportUtils
|
|
337
335
|
log.info("extract jobId : {}",jobId);
|
338
336
|
log.debug("waiting for job end....... ");
|
339
337
|
|
340
|
-
Job lastJob = waitForJob(bigquery, task.getProject(), jobId, task.getLocation().get(), task.getBigqueryJobWaitingSecond().get());
|
338
|
+
Job lastJob = waitForJob(bigquery, task.getProject(), jobId, task.getLocation().get(), task.getBigqueryJobWaitingSecond().get(), task.getThrowBigqueryJobWaitTimeout());
|
341
339
|
|
342
340
|
log.info("table extract result : {}",lastJob.toPrettyString());
|
343
341
|
|
344
342
|
return embulkSchema;
|
345
343
|
}
|
346
344
|
|
347
|
-
public static Job waitForJob(Bigquery bigquery, String project, String jobId, String location, int bigqueryJobWaitingSecond) throws IOException, InterruptedException{
|
345
|
+
public static Job waitForJob(Bigquery bigquery, String project, String jobId, String location, int bigqueryJobWaitingSecond, boolean exceptionWhenTimeout) throws IOException, InterruptedException{
|
348
346
|
int maxAttempts = bigqueryJobWaitingSecond;
|
349
347
|
int initialRetryDelay = 1000; // ms
|
350
348
|
Job pollingJob = null;
|
@@ -358,11 +356,18 @@ public class BigqueryExportUtils
|
|
358
356
|
if (pollingJob.getStatus().getState().equals("DONE")) {
|
359
357
|
break;
|
360
358
|
}
|
361
|
-
log.info("waiting {} ... ",tryCnt);
|
359
|
+
log.info("waiting {} ... {} ", tryCnt,state);
|
362
360
|
Thread.sleep(initialRetryDelay);
|
363
361
|
}
|
364
|
-
if(tryCnt + 1
|
365
|
-
|
362
|
+
if(tryCnt + 1 >= maxAttempts){
|
363
|
+
|
364
|
+
String errorMessage = String.format("Bigquery Job [%s] Waiting timeout : over %s second...", jobId, bigqueryJobWaitingSecond);
|
365
|
+
if(exceptionWhenTimeout){
|
366
|
+
throw new IOException(errorMessage);
|
367
|
+
}else{
|
368
|
+
log.error(errorMessage);
|
369
|
+
}
|
370
|
+
|
366
371
|
}
|
367
372
|
|
368
373
|
return pollingJob;
|
@@ -4,10 +4,13 @@ import java.io.FileNotFoundException;
|
|
4
4
|
import java.io.IOException;
|
5
5
|
import java.io.InputStream;
|
6
6
|
|
7
|
+
import com.google.common.base.Optional;
|
7
8
|
import org.junit.Test;
|
8
9
|
import org.slf4j.Logger;
|
9
10
|
import org.slf4j.LoggerFactory;
|
10
11
|
|
12
|
+
import javax.validation.constraints.AssertTrue;
|
13
|
+
|
11
14
|
public class TestGoogleCloudAccessData extends UnitTestInitializer
|
12
15
|
{
|
13
16
|
private static final Logger log = LoggerFactory.getLogger(TestGoogleCloudAccessData.class);
|
@@ -23,6 +26,19 @@ public class TestGoogleCloudAccessData extends UnitTestInitializer
|
|
23
26
|
|
24
27
|
log.info("file size : {}",org.apache.commons.compress.utils.IOUtils.toByteArray(ins).length);
|
25
28
|
}
|
26
|
-
|
29
|
+
|
30
|
+
|
31
|
+
@Test(expected=Exception.class)
|
32
|
+
public void testJobWaitTimeout() throws FileNotFoundException, IOException
|
33
|
+
{
|
34
|
+
BigqueryExportGcsFileInputPlugin.PluginTask task = config.loadConfig(BigqueryExportGcsFileInputPlugin.PluginTask.class );
|
35
|
+
task.setThrowBigqueryJobWaitTimeout(true);
|
36
|
+
task.setBigqueryJobWaitingSecond(Optional.of(1));
|
37
|
+
plugin.executeBigqueryApi(task);
|
38
|
+
|
39
|
+
InputStream ins = BigqueryExportUtils.openInputStream(task, task.getFiles().get(0));
|
40
|
+
log.info("file size : {}",org.apache.commons.compress.utils.IOUtils.toByteArray(ins).length);
|
41
|
+
|
42
|
+
}
|
27
43
|
|
28
44
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-bigquery_extract_files
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jo8937
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,7 +65,7 @@ files:
|
|
65
65
|
- src/test/java/org/embulk/input/bigquery_export_gcs/UnitTestInitializer.java
|
66
66
|
- classpath/animal-sniffer-annotations-1.14.jar
|
67
67
|
- classpath/checker-compat-qual-2.5.2.jar
|
68
|
-
- classpath/embulk-input-bigquery_extract_files-0.0.
|
68
|
+
- classpath/embulk-input-bigquery_extract_files-0.0.13.jar
|
69
69
|
- classpath/error_prone_annotations-2.1.3.jar
|
70
70
|
- classpath/google-api-client-1.25.0.jar
|
71
71
|
- classpath/google-api-services-bigquery-v2-rev429-1.25.0.jar
|