embulk-input-mysql 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/build.gradle +1 -1
- data/classpath/{embulk-input-jdbc-0.6.0.jar → embulk-input-jdbc-0.6.1.jar} +0 -0
- data/classpath/embulk-input-mysql-0.6.1.jar +0 -0
- data/src/main/java/org/embulk/input/MySQLInputPlugin.java +2 -3
- data/src/main/java/org/embulk/input/mysql/MySQLInputConnection.java +2 -1
- data/src/test/java/org/embulk/input/mysql/EmbulkPluginTester.java +23 -29
- data/src/test/java/org/embulk/input/mysql/MySQLInputPluginTest.java +8 -10
- metadata +4 -6
- data/classpath/embulk-input-mysql-0.6.0.jar +0 -0
- data/src/test/java/org/embulk/input/mysql/ChildFirstClassLoader.java +0 -42
- data/src/test/java/org/embulk/input/mysql/EmptyConfigSource.java +0 -105
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 926a4a94fc9d68597a855726bff1ee7f0aa9642f
|
4
|
+
data.tar.gz: 65fb022951c42b95037d989f0e8f0229a500ac60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba17b951e574ce78a5605a0ae2c1970b1de516044fd7d627fb6e55c7b62ae55f084a9b21ac5033f5c684534093b3f6352b25e52c10fd7dcab7064471ca733eed
|
7
|
+
data.tar.gz: 4363441acac9ce2d250d85f1a6bf425d961e07b9276d2190c98f0d2b0a89f3c8769d5a963401e794e49414879199b33333faa7a681eac1d7226bb9f6813d1577
|
data/README.md
CHANGED
@@ -30,6 +30,8 @@ MySQL input plugins for Embulk loads records from MySQL.
|
|
30
30
|
- If this value is set to -1:
|
31
31
|
- It uses a client-side built statement and fetches all rows at once. This may cause OutOfMemoryError.
|
32
32
|
- Internally, `useCursorFetch=false` is used and `java.sql.Statement.setFetchSize` is not set.
|
33
|
+
- **connect_timeout**: timeout for socket connect. 0 means no timeout. (integer (seconds), default: 300)
|
34
|
+
- **socket_timeout**: timeout on network socket operations. 0 means no timeout. (integer (seconds), default: 1800)
|
33
35
|
- **options**: extra JDBC properties (hash, default: {})
|
34
36
|
- **default_timezone**: If the sql type of a column is `date`/`time`/`datetime` and the embulk type is `string`, column values are formatted int this default_timezone. You can overwrite timezone for each columns using column_options option. (string, default: `UTC`)
|
35
37
|
- **column_options**: advanced: a key-value pairs where key is a column name and value is options for the column.
|
data/build.gradle
CHANGED
Binary file
|
Binary file
|
@@ -4,7 +4,6 @@ import java.util.Properties;
|
|
4
4
|
import java.sql.Connection;
|
5
5
|
import java.sql.Driver;
|
6
6
|
import java.sql.SQLException;
|
7
|
-
import com.google.common.base.Throwables;
|
8
7
|
import org.embulk.config.Config;
|
9
8
|
import org.embulk.config.ConfigDefault;
|
10
9
|
import org.embulk.input.jdbc.AbstractJdbcInputPlugin;
|
@@ -58,8 +57,8 @@ public class MySQLInputPlugin
|
|
58
57
|
|
59
58
|
props.setProperty("useCompression", "true");
|
60
59
|
|
61
|
-
props.setProperty("connectTimeout",
|
62
|
-
props.setProperty("socketTimeout",
|
60
|
+
props.setProperty("connectTimeout", String.valueOf(t.getConnectTimeout() * 1000)); // milliseconds
|
61
|
+
props.setProperty("socketTimeout", String.valueOf(t.getSocketTimeout() * 1000)); // milliseconds
|
63
62
|
|
64
63
|
// Enable keepalive based on tcp_keepalive_time, tcp_keepalive_intvl and tcp_keepalive_probes kernel parameters.
|
65
64
|
// Socket options TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL are not configurable.
|
@@ -16,7 +16,7 @@ public class MySQLInputConnection
|
|
16
16
|
}
|
17
17
|
|
18
18
|
@Override
|
19
|
-
protected BatchSelect newBatchSelect(String select, int fetchRows) throws SQLException
|
19
|
+
protected BatchSelect newBatchSelect(String select, int fetchRows, int queryTimeout) throws SQLException
|
20
20
|
{
|
21
21
|
logger.info("SQL: " + select);
|
22
22
|
PreparedStatement stmt = connection.prepareStatement(select, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); // TYPE_FORWARD_ONLY and CONCUR_READ_ONLY are default
|
@@ -30,6 +30,7 @@ public class MySQLInputConnection
|
|
30
30
|
// useCursorFetch=true is enabled. MySQL creates temporary table and uses multiple select statements to fetch rows.
|
31
31
|
stmt.setFetchSize(fetchRows);
|
32
32
|
}
|
33
|
+
// Because socketTimeout is set in Connection, don't need to set quertyTimeout.
|
33
34
|
return new SingleSelect(stmt);
|
34
35
|
}
|
35
36
|
}
|
@@ -2,19 +2,14 @@ package org.embulk.input.mysql;
|
|
2
2
|
|
3
3
|
import java.io.File;
|
4
4
|
import java.util.ArrayList;
|
5
|
-
import java.util.Arrays;
|
6
5
|
import java.util.List;
|
7
6
|
|
8
|
-
import org.embulk.
|
9
|
-
import org.embulk.
|
7
|
+
import org.embulk.EmbulkEmbed;
|
8
|
+
import org.embulk.EmbulkEmbed.Bootstrap;
|
10
9
|
import org.embulk.config.ConfigSource;
|
11
|
-
import org.embulk.exec.BulkLoader;
|
12
|
-
import org.embulk.exec.ExecutionResult;
|
13
10
|
import org.embulk.plugin.InjectedPluginSource;
|
14
|
-
import org.embulk.spi.ExecSession;
|
15
11
|
|
16
12
|
import com.google.inject.Binder;
|
17
|
-
import com.google.inject.Injector;
|
18
13
|
import com.google.inject.Module;
|
19
14
|
|
20
15
|
public class EmbulkPluginTester
|
@@ -37,7 +32,7 @@ public class EmbulkPluginTester
|
|
37
32
|
|
38
33
|
private final List<PluginDefinition> plugins = new ArrayList<PluginDefinition>();
|
39
34
|
|
40
|
-
|
35
|
+
private EmbulkEmbed embulk;
|
41
36
|
|
42
37
|
public EmbulkPluginTester()
|
43
38
|
{
|
@@ -55,30 +50,29 @@ public class EmbulkPluginTester
|
|
55
50
|
|
56
51
|
public void run(String ymlPath) throws Exception
|
57
52
|
{
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
if (embulk == null) {
|
54
|
+
Bootstrap bootstrap = new EmbulkEmbed.Bootstrap();
|
55
|
+
bootstrap.addModules(new Module()
|
61
56
|
{
|
62
|
-
|
57
|
+
@Override
|
58
|
+
public void configure(Binder binder)
|
63
59
|
{
|
64
|
-
|
65
|
-
|
66
|
-
{
|
67
|
-
for (PluginDefinition plugin : plugins) {
|
68
|
-
InjectedPluginSource.registerPluginTo(binder, plugin.iface, plugin.name, plugin.impl);
|
69
|
-
}
|
60
|
+
for (PluginDefinition plugin : plugins) {
|
61
|
+
InjectedPluginSource.registerPluginTo(binder, plugin.iface, plugin.name, plugin.impl);
|
70
62
|
}
|
71
|
-
}
|
72
|
-
}
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
63
|
+
}
|
64
|
+
});
|
65
|
+
embulk = bootstrap.initializeCloseable();
|
66
|
+
}
|
67
|
+
|
68
|
+
ConfigSource config = embulk.newConfigLoader().fromYamlFile(new File(ymlPath));
|
69
|
+
embulk.run(config);
|
70
|
+
}
|
71
|
+
|
72
|
+
public void destroy() {
|
73
|
+
if (embulk != null) {
|
74
|
+
embulk.destroy();
|
75
|
+
embulk = null;
|
82
76
|
}
|
83
77
|
}
|
84
78
|
|
@@ -16,6 +16,7 @@ import java.util.List;
|
|
16
16
|
|
17
17
|
import org.embulk.input.MySQLInputPlugin;
|
18
18
|
import org.embulk.spi.InputPlugin;
|
19
|
+
import org.junit.AfterClass;
|
19
20
|
import org.junit.BeforeClass;
|
20
21
|
import org.junit.Test;
|
21
22
|
|
@@ -24,6 +25,7 @@ import static org.junit.Assert.assertEquals;
|
|
24
25
|
public class MySQLInputPluginTest
|
25
26
|
{
|
26
27
|
private static boolean prepared = false;
|
28
|
+
private static EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "mysql", MySQLInputPlugin.class);
|
27
29
|
|
28
30
|
@BeforeClass
|
29
31
|
public static void prepare() throws SQLException
|
@@ -115,11 +117,16 @@ public class MySQLInputPluginTest
|
|
115
117
|
}
|
116
118
|
}
|
117
119
|
|
120
|
+
@AfterClass
|
121
|
+
public static void dispose()
|
122
|
+
{
|
123
|
+
tester.destroy();
|
124
|
+
}
|
125
|
+
|
118
126
|
@Test
|
119
127
|
public void test() throws Exception
|
120
128
|
{
|
121
129
|
if (prepared) {
|
122
|
-
EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "mysql", MySQLInputPlugin.class);
|
123
130
|
tester.run(convertPath("/yml/input.yml"));
|
124
131
|
assertEquals(Arrays.asList(
|
125
132
|
"c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15",
|
@@ -133,7 +140,6 @@ public class MySQLInputPluginTest
|
|
133
140
|
public void testString() throws Exception
|
134
141
|
{
|
135
142
|
if (prepared) {
|
136
|
-
EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "mysql", MySQLInputPlugin.class);
|
137
143
|
tester.run(convertPath("/yml/input-string.yml"));
|
138
144
|
assertEquals(Arrays.asList(
|
139
145
|
"c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15",
|
@@ -147,7 +153,6 @@ public class MySQLInputPluginTest
|
|
147
153
|
public void testBoolean() throws Exception
|
148
154
|
{
|
149
155
|
if (prepared) {
|
150
|
-
EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "mysql", MySQLInputPlugin.class);
|
151
156
|
tester.run(convertPath("/yml/input-boolean.yml"));
|
152
157
|
assertEquals(Arrays.asList(
|
153
158
|
"c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15",
|
@@ -161,7 +166,6 @@ public class MySQLInputPluginTest
|
|
161
166
|
public void testLong() throws Exception
|
162
167
|
{
|
163
168
|
if (prepared) {
|
164
|
-
EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "mysql", MySQLInputPlugin.class);
|
165
169
|
tester.run(convertPath("/yml/input-long.yml"));
|
166
170
|
assertEquals(Arrays.asList(
|
167
171
|
"c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15",
|
@@ -175,7 +179,6 @@ public class MySQLInputPluginTest
|
|
175
179
|
public void testDouble() throws Exception
|
176
180
|
{
|
177
181
|
if (prepared) {
|
178
|
-
EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "mysql", MySQLInputPlugin.class);
|
179
182
|
tester.run(convertPath("/yml/input-double.yml"));
|
180
183
|
assertEquals(Arrays.asList(
|
181
184
|
"c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15",
|
@@ -189,7 +192,6 @@ public class MySQLInputPluginTest
|
|
189
192
|
public void testTimestamp1() throws Exception
|
190
193
|
{
|
191
194
|
if (prepared) {
|
192
|
-
EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "mysql", MySQLInputPlugin.class);
|
193
195
|
tester.run(convertPath("/yml/input-timestamp1.yml"));
|
194
196
|
assertEquals(Arrays.asList(
|
195
197
|
"c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15",
|
@@ -203,7 +205,6 @@ public class MySQLInputPluginTest
|
|
203
205
|
public void testTimestamp2() throws Exception
|
204
206
|
{
|
205
207
|
if (prepared) {
|
206
|
-
EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "mysql", MySQLInputPlugin.class);
|
207
208
|
tester.run(convertPath("/yml/input-timestamp2.yml"));
|
208
209
|
assertEquals(Arrays.asList(
|
209
210
|
"c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15",
|
@@ -217,7 +218,6 @@ public class MySQLInputPluginTest
|
|
217
218
|
public void testTimestamp3() throws Exception
|
218
219
|
{
|
219
220
|
if (prepared) {
|
220
|
-
EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "mysql", MySQLInputPlugin.class);
|
221
221
|
tester.run(convertPath("/yml/input-timestamp3.yml"));
|
222
222
|
assertEquals(Arrays.asList(
|
223
223
|
"c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15",
|
@@ -231,7 +231,6 @@ public class MySQLInputPluginTest
|
|
231
231
|
public void testValueTypeString() throws Exception
|
232
232
|
{
|
233
233
|
if (prepared) {
|
234
|
-
EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "mysql", MySQLInputPlugin.class);
|
235
234
|
tester.run(convertPath("/yml/input-valuetype-string.yml"));
|
236
235
|
assertEquals(Arrays.asList(
|
237
236
|
"c1",
|
@@ -244,7 +243,6 @@ public class MySQLInputPluginTest
|
|
244
243
|
public void testValueTypeDecimal() throws Exception
|
245
244
|
{
|
246
245
|
if (prepared) {
|
247
|
-
EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "mysql", MySQLInputPlugin.class);
|
248
246
|
tester.run(convertPath("/yml/input-valuetype-decimal.yml"));
|
249
247
|
assertEquals(Arrays.asList(
|
250
248
|
"c1",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-mysql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Selects records from a table.
|
14
14
|
email:
|
@@ -22,9 +22,7 @@ files:
|
|
22
22
|
- lib/embulk/input/mysql.rb
|
23
23
|
- src/main/java/org/embulk/input/MySQLInputPlugin.java
|
24
24
|
- src/main/java/org/embulk/input/mysql/MySQLInputConnection.java
|
25
|
-
- src/test/java/org/embulk/input/mysql/ChildFirstClassLoader.java
|
26
25
|
- src/test/java/org/embulk/input/mysql/EmbulkPluginTester.java
|
27
|
-
- src/test/java/org/embulk/input/mysql/EmptyConfigSource.java
|
28
26
|
- src/test/java/org/embulk/input/mysql/MySQLInputPluginTest.java
|
29
27
|
- src/test/resources/yml/input-boolean.yml
|
30
28
|
- src/test/resources/yml/input-double.yml
|
@@ -36,8 +34,8 @@ files:
|
|
36
34
|
- src/test/resources/yml/input-valuetype-decimal.yml
|
37
35
|
- src/test/resources/yml/input-valuetype-string.yml
|
38
36
|
- src/test/resources/yml/input.yml
|
39
|
-
- classpath/embulk-input-jdbc-0.6.
|
40
|
-
- classpath/embulk-input-mysql-0.6.
|
37
|
+
- classpath/embulk-input-jdbc-0.6.1.jar
|
38
|
+
- classpath/embulk-input-mysql-0.6.1.jar
|
41
39
|
- classpath/mysql-connector-java-5.1.34.jar
|
42
40
|
homepage: https://github.com/embulk/embulk-input-jdbc
|
43
41
|
licenses:
|
Binary file
|
@@ -1,42 +0,0 @@
|
|
1
|
-
package org.embulk.input.mysql;
|
2
|
-
|
3
|
-
import java.net.URL;
|
4
|
-
import java.net.URLClassLoader;
|
5
|
-
import java.util.List;
|
6
|
-
|
7
|
-
public class ChildFirstClassLoader
|
8
|
-
extends URLClassLoader
|
9
|
-
{
|
10
|
-
public ChildFirstClassLoader(List<URL> urls, ClassLoader parent)
|
11
|
-
{
|
12
|
-
super(urls.toArray(new URL[urls.size()]), parent);
|
13
|
-
}
|
14
|
-
|
15
|
-
@Override
|
16
|
-
protected Class<?> loadClass(String name, boolean resolve)
|
17
|
-
throws ClassNotFoundException
|
18
|
-
{
|
19
|
-
synchronized (getClassLoadingLock(name)) {
|
20
|
-
Class<?> loadedClass = findLoadedClass(name);
|
21
|
-
if (loadedClass != null) {
|
22
|
-
return resolveClass(loadedClass, resolve);
|
23
|
-
}
|
24
|
-
|
25
|
-
try {
|
26
|
-
return resolveClass(findClass(name), resolve);
|
27
|
-
} catch (ClassNotFoundException ignored) {
|
28
|
-
}
|
29
|
-
|
30
|
-
return super.loadClass(name, resolve);
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
private Class<?> resolveClass(Class<?> clazz, boolean resolve)
|
35
|
-
{
|
36
|
-
if (resolve) {
|
37
|
-
resolveClass(clazz);
|
38
|
-
}
|
39
|
-
return clazz;
|
40
|
-
}
|
41
|
-
|
42
|
-
}
|
@@ -1,105 +0,0 @@
|
|
1
|
-
package org.embulk.input.mysql;
|
2
|
-
|
3
|
-
import java.util.Collections;
|
4
|
-
import java.util.List;
|
5
|
-
import java.util.Map.Entry;
|
6
|
-
|
7
|
-
import org.embulk.config.ConfigSource;
|
8
|
-
import org.embulk.config.DataSource;
|
9
|
-
|
10
|
-
import com.fasterxml.jackson.databind.JsonNode;
|
11
|
-
import com.fasterxml.jackson.databind.node.ObjectNode;
|
12
|
-
|
13
|
-
public class EmptyConfigSource implements ConfigSource
|
14
|
-
{
|
15
|
-
|
16
|
-
@Override
|
17
|
-
public <E> E get(Class<E> type, String attrName)
|
18
|
-
{
|
19
|
-
return null;
|
20
|
-
}
|
21
|
-
|
22
|
-
@Override
|
23
|
-
public <E> E get(Class<E> type, String attrName, E defaultValue)
|
24
|
-
{
|
25
|
-
return defaultValue;
|
26
|
-
}
|
27
|
-
|
28
|
-
@Override
|
29
|
-
public List<String> getAttributeNames()
|
30
|
-
{
|
31
|
-
return Collections.emptyList();
|
32
|
-
}
|
33
|
-
|
34
|
-
@Override
|
35
|
-
public Iterable<Entry<String, JsonNode>> getAttributes()
|
36
|
-
{
|
37
|
-
return Collections.emptyList();
|
38
|
-
}
|
39
|
-
|
40
|
-
@Override
|
41
|
-
public ObjectNode getObjectNode()
|
42
|
-
{
|
43
|
-
return null;
|
44
|
-
}
|
45
|
-
|
46
|
-
@Override
|
47
|
-
public boolean isEmpty()
|
48
|
-
{
|
49
|
-
return true;
|
50
|
-
}
|
51
|
-
|
52
|
-
@Override
|
53
|
-
public ConfigSource deepCopy()
|
54
|
-
{
|
55
|
-
return this;
|
56
|
-
}
|
57
|
-
|
58
|
-
@Override
|
59
|
-
public ConfigSource getNested(String s)
|
60
|
-
{
|
61
|
-
return null;
|
62
|
-
}
|
63
|
-
|
64
|
-
@Override
|
65
|
-
public ConfigSource getNestedOrSetEmpty(String s)
|
66
|
-
{
|
67
|
-
return null;
|
68
|
-
}
|
69
|
-
|
70
|
-
@Override
|
71
|
-
public <T> T loadConfig(Class<T> class1)
|
72
|
-
{
|
73
|
-
return null;
|
74
|
-
}
|
75
|
-
|
76
|
-
@Override
|
77
|
-
public ConfigSource merge(DataSource datasource)
|
78
|
-
{
|
79
|
-
return null;
|
80
|
-
}
|
81
|
-
|
82
|
-
@Override
|
83
|
-
public ConfigSource set(String s, Object obj)
|
84
|
-
{
|
85
|
-
return null;
|
86
|
-
}
|
87
|
-
|
88
|
-
@Override
|
89
|
-
public ConfigSource setAll(DataSource datasource)
|
90
|
-
{
|
91
|
-
return null;
|
92
|
-
}
|
93
|
-
|
94
|
-
@Override
|
95
|
-
public ConfigSource setNested(String s, DataSource datasource)
|
96
|
-
{
|
97
|
-
return null;
|
98
|
-
}
|
99
|
-
|
100
|
-
@Override
|
101
|
-
public ConfigSource remove(String arg0) {
|
102
|
-
return null;
|
103
|
-
}
|
104
|
-
|
105
|
-
}
|