embulk-output-kintone 0.3.6 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d405f264473164aaf9581956d1a5343fe993a4a1
|
4
|
+
data.tar.gz: 85988a65971c21fbc058401a9af1e600b8029f1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc2eb92ad6fb1a200f4567aeb4e57baebbdf636a94ab40834c4864d48dc83891fa2fc23152e86e283fe28d7fa9248c1bd08497fd7f0ab4887def5ca3c6f5dafb
|
7
|
+
data.tar.gz: 9a8295b11401e64357a67ffb733e51f45e8321b68377e21e3d66cd50ea3c20f62bbf7c9d28e58d44b9fb805eb483b35af96e72868ecae383fb81d53935c0c6e5
|
Binary file
|
@@ -12,6 +12,7 @@ import java.util.ArrayList;
|
|
12
12
|
import java.util.Arrays;
|
13
13
|
import java.util.Collections;
|
14
14
|
import java.util.List;
|
15
|
+
import java.util.concurrent.TimeUnit;
|
15
16
|
import java.util.stream.Collectors;
|
16
17
|
import org.embulk.config.ConfigException;
|
17
18
|
import org.embulk.config.TaskReport;
|
@@ -21,10 +22,13 @@ import org.embulk.spi.Page;
|
|
21
22
|
import org.embulk.spi.PageReader;
|
22
23
|
import org.embulk.spi.Schema;
|
23
24
|
import org.embulk.spi.TransactionalPageOutput;
|
25
|
+
import org.slf4j.Logger;
|
26
|
+
import org.slf4j.LoggerFactory;
|
24
27
|
|
25
28
|
public class KintonePageOutput implements TransactionalPageOutput {
|
26
29
|
public static final int UPSERT_BATCH_SIZE = 10000;
|
27
30
|
public static final int CHUNK_SIZE = 100;
|
31
|
+
private static final Logger LOGGER = LoggerFactory.getLogger(KintonePageOutput.class);
|
28
32
|
private final PageReader pageReader;
|
29
33
|
private final PluginTask task;
|
30
34
|
private KintoneClient client;
|
@@ -128,6 +132,7 @@ public class KintonePageOutput implements TransactionalPageOutput {
|
|
128
132
|
if (records.size() == CHUNK_SIZE) {
|
129
133
|
client.record().addRecords(task.getAppId(), records);
|
130
134
|
records.clear();
|
135
|
+
sleep();
|
131
136
|
}
|
132
137
|
}
|
133
138
|
if (records.size() > 0) {
|
@@ -171,6 +176,7 @@ public class KintonePageOutput implements TransactionalPageOutput {
|
|
171
176
|
if (updateRecords.size() == CHUNK_SIZE) {
|
172
177
|
client.record().updateRecords(task.getAppId(), updateRecords);
|
173
178
|
updateRecords.clear();
|
179
|
+
sleep();
|
174
180
|
}
|
175
181
|
}
|
176
182
|
if (updateRecords.size() > 0) {
|
@@ -223,7 +229,8 @@ public class KintonePageOutput implements TransactionalPageOutput {
|
|
223
229
|
});
|
224
230
|
}
|
225
231
|
|
226
|
-
private void upsert(ArrayList<Record> records, ArrayList<UpdateKey> updateKeys)
|
232
|
+
private void upsert(ArrayList<Record> records, ArrayList<UpdateKey> updateKeys)
|
233
|
+
throws InterruptedException {
|
227
234
|
if (records.size() != updateKeys.size()) {
|
228
235
|
throw new RuntimeException("records.size() != updateKeys.size()");
|
229
236
|
}
|
@@ -269,9 +276,11 @@ public class KintonePageOutput implements TransactionalPageOutput {
|
|
269
276
|
if (insertRecords.size() == CHUNK_SIZE) {
|
270
277
|
client.record().addRecords(task.getAppId(), insertRecords);
|
271
278
|
insertRecords.clear();
|
279
|
+
sleep();
|
272
280
|
} else if (updateRecords.size() == CHUNK_SIZE) {
|
273
281
|
client.record().updateRecords(task.getAppId(), updateRecords);
|
274
282
|
updateRecords.clear();
|
283
|
+
sleep();
|
275
284
|
}
|
276
285
|
}
|
277
286
|
if (insertRecords.size() > 0) {
|
@@ -316,4 +325,13 @@ public class KintonePageOutput implements TransactionalPageOutput {
|
|
316
325
|
private boolean existsRecord(List<String> distValues, UpdateKey updateKey) {
|
317
326
|
return distValues.stream().anyMatch(v -> v.equals(updateKey.getValue().toString()));
|
318
327
|
}
|
328
|
+
|
329
|
+
private void sleep() throws InterruptedException {
|
330
|
+
if (!task.getIntervalSeconds().isPresent()) {
|
331
|
+
return;
|
332
|
+
}
|
333
|
+
Integer interval = task.getIntervalSeconds().get();
|
334
|
+
LOGGER.info(String.format("sleep %d seconds.", interval));
|
335
|
+
TimeUnit.SECONDS.sleep(interval);
|
336
|
+
}
|
319
337
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-kintone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takeshi fujita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,7 @@ files:
|
|
52
52
|
- README.md
|
53
53
|
- Rakefile
|
54
54
|
- build.gradle
|
55
|
-
- classpath/embulk-output-kintone-0.
|
55
|
+
- classpath/embulk-output-kintone-0.4.0.jar
|
56
56
|
- config/checkstyle/checkstyle.xml
|
57
57
|
- config/checkstyle/default.xml
|
58
58
|
- gradle/wrapper/gradle-wrapper.jar
|