embulk 0.6.27 → 0.7.0
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/.ruby-version +1 -0
- data/Gemfile.lock +6 -1
- data/README.md +4 -4
- data/bin/embulk +39 -17
- data/build.gradle +23 -8
- data/embulk-cli/src/main/java/org/embulk/cli/Main.java +11 -2
- data/embulk-core/build.gradle +9 -4
- data/embulk-core/src/main/java/org/embulk/EmbulkEmbed.java +160 -61
- data/embulk-core/src/main/java/org/embulk/EmbulkService.java +1 -0
- data/embulk-core/src/main/java/org/embulk/command/TablePreviewPrinter.java +0 -1
- data/embulk-core/src/main/java/org/embulk/config/CommitReport.java +5 -1
- data/embulk-core/src/main/java/org/embulk/config/ConfigLoader.java +28 -7
- data/embulk-core/src/main/java/org/embulk/config/DataSourceImpl.java +1 -4
- data/embulk-core/src/main/java/org/embulk/config/DataSourceSerDe.java +6 -3
- data/embulk-core/src/main/java/org/embulk/config/ModelManager.java +0 -2
- data/embulk-core/src/main/java/org/embulk/config/TaskReport.java +29 -0
- data/embulk-core/src/main/java/org/embulk/exec/BulkLoader.java +42 -45
- data/embulk-core/src/main/java/org/embulk/exec/ExecModule.java +0 -1
- data/embulk-core/src/main/java/org/embulk/exec/GuessExecutor.java +4 -7
- data/embulk-core/src/main/java/org/embulk/exec/LocalExecutorPlugin.java +5 -6
- data/embulk-core/src/main/java/org/embulk/exec/LoggerProvider.java +0 -1
- data/embulk-core/src/main/java/org/embulk/exec/PooledBufferAllocator.java +0 -3
- data/embulk-core/src/main/java/org/embulk/exec/PreviewExecutor.java +2 -2
- data/embulk-core/src/main/java/org/embulk/exec/ResumeState.java +26 -9
- data/embulk-core/src/main/java/org/embulk/exec/SamplingParserPlugin.java +2 -4
- data/embulk-core/src/main/java/org/embulk/guice/Bootstrap.java +12 -5
- data/embulk-core/src/main/java/org/embulk/guice/CloseableInjector.java +1 -1
- data/embulk-core/src/main/java/org/embulk/guice/LifeCycleInjector.java +26 -0
- data/embulk-core/src/main/java/org/embulk/guice/{CloseableInjectorProxy.java → LifeCycleInjectorProxy.java} +20 -6
- data/embulk-core/src/main/java/org/embulk/jruby/JRubyScriptingModule.java +10 -12
- data/embulk-core/src/main/java/org/embulk/plugin/PluginClassLoaderModule.java +0 -1
- data/embulk-core/src/main/java/org/embulk/plugin/PluginManager.java +14 -1
- data/embulk-core/src/main/java/org/embulk/plugin/compat/InputPluginWrapper.java +102 -0
- data/embulk-core/src/main/java/org/embulk/plugin/compat/PluginWrappers.java +30 -0
- data/embulk-core/src/main/java/org/embulk/plugin/compat/TransactionalFileInputWrapper.java +96 -0
- data/embulk-core/src/main/java/org/embulk/plugin/compat/TransactionalFileOutputWrapper.java +102 -0
- data/embulk-core/src/main/java/org/embulk/plugin/compat/TransactionalPageOutputWrapper.java +95 -0
- data/embulk-core/src/main/java/org/embulk/spi/ColumnConfig.java +0 -2
- data/embulk-core/src/main/java/org/embulk/spi/Exec.java +8 -2
- data/embulk-core/src/main/java/org/embulk/spi/ExecSession.java +7 -1
- data/embulk-core/src/main/java/org/embulk/spi/Extension.java +2 -2
- data/embulk-core/src/main/java/org/embulk/spi/FileInputPlugin.java +3 -3
- data/embulk-core/src/main/java/org/embulk/spi/FileInputRunner.java +12 -10
- data/embulk-core/src/main/java/org/embulk/spi/FileOutputPlugin.java +3 -3
- data/embulk-core/src/main/java/org/embulk/spi/FileOutputRunner.java +11 -9
- data/embulk-core/src/main/java/org/embulk/spi/FilterPlugin.java +0 -3
- data/embulk-core/src/main/java/org/embulk/spi/InputPlugin.java +4 -4
- data/embulk-core/src/main/java/org/embulk/spi/OutputPlugin.java +3 -3
- data/embulk-core/src/main/java/org/embulk/spi/PageReader.java +0 -1
- data/embulk-core/src/main/java/org/embulk/spi/ProcessTask.java +0 -5
- data/embulk-core/src/main/java/org/embulk/spi/SchemaConfig.java +0 -1
- data/embulk-core/src/main/java/org/embulk/spi/TaskState.java +19 -4
- data/embulk-core/src/main/java/org/embulk/spi/TempFileSpace.java +0 -3
- data/embulk-core/src/main/java/org/embulk/spi/Transactional.java +2 -2
- data/embulk-core/src/main/java/org/embulk/spi/TransactionalFileInput.java +2 -2
- data/embulk-core/src/main/java/org/embulk/spi/TransactionalFileOutput.java +2 -2
- data/embulk-core/src/main/java/org/embulk/spi/TransactionalPageOutput.java +2 -2
- data/embulk-core/src/main/java/org/embulk/spi/time/DateTimeZoneSerDe.java +0 -2
- data/embulk-core/src/main/java/org/embulk/spi/time/TimestampFormat.java +0 -3
- data/embulk-core/src/main/java/org/embulk/spi/time/TimestampFormatter.java +0 -1
- data/embulk-core/src/main/java/org/embulk/spi/time/TimestampParser.java +0 -1
- data/embulk-core/src/main/java/org/embulk/spi/time/TimestampSerDe.java +0 -1
- data/embulk-core/src/main/java/org/embulk/spi/type/TypeDeserializer.java +0 -3
- data/embulk-core/src/main/java/org/embulk/spi/unit/LocalFileSerDe.java +0 -3
- data/embulk-core/src/main/java/org/embulk/spi/unit/ToStringMap.java +0 -1
- data/embulk-core/src/main/java/org/embulk/spi/util/Executors.java +15 -12
- data/embulk-core/src/main/java/org/embulk/spi/util/Filters.java +0 -1
- data/embulk-core/src/test/java/org/embulk/spi/TestFileInputRunner.java +7 -7
- data/embulk-core/src/test/java/org/embulk/spi/TestFileOutputRunner.java +8 -8
- data/embulk-docs/src/built-in.rst +27 -30
- data/embulk-docs/src/conf.py +2 -2
- data/embulk-docs/src/release.rst +1 -2
- data/embulk-docs/src/release/release-0.7.0.rst +96 -0
- data/embulk-standards/src/main/java/org/embulk/standards/CsvFormatterPlugin.java +0 -4
- data/embulk-standards/src/main/java/org/embulk/standards/CsvParserPlugin.java +0 -10
- data/embulk-standards/src/main/java/org/embulk/standards/CsvTokenizer.java +1 -5
- data/embulk-standards/src/main/java/org/embulk/standards/LocalFileInputPlugin.java +4 -5
- data/embulk-standards/src/main/java/org/embulk/standards/LocalFileOutputPlugin.java +4 -5
- data/embulk-standards/src/main/java/org/embulk/standards/NullOutputPlugin.java +4 -4
- data/embulk-standards/src/main/java/org/embulk/standards/StandardPluginModule.java +0 -3
- data/embulk-standards/src/main/java/org/embulk/standards/StdoutOutputPlugin.java +4 -6
- data/embulk.gemspec +14 -1
- data/lib/embulk.rb +59 -4
- data/lib/embulk/command/embulk_bundle.rb +56 -0
- data/lib/embulk/command/embulk_main.rb +2 -0
- data/lib/embulk/command/embulk_migrate_plugin.rb +170 -0
- data/lib/embulk/command/embulk_new_plugin.rb +4 -1
- data/lib/embulk/command/embulk_run.rb +188 -227
- data/lib/embulk/data/bundle/.ruby-version +1 -0
- data/lib/embulk/data/bundle/Gemfile +4 -1
- data/lib/embulk/data/bundle/embulk/input/example.rb +4 -4
- data/lib/embulk/data/bundle/embulk/output/example.rb +4 -4
- data/lib/embulk/data/new/README.md.erb +1 -1
- data/lib/embulk/data/new/java/file_input.java.erb +4 -4
- data/lib/embulk/data/new/java/file_output.java.erb +2 -2
- data/lib/embulk/data/new/java/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/embulk/data/new/java/gradle/wrapper/gradle-wrapper.properties +2 -2
- data/lib/embulk/data/new/java/input.java.erb +3 -3
- data/lib/embulk/data/new/java/output.java.erb +2 -2
- data/lib/embulk/data/new/ruby/.ruby-version +1 -0
- data/lib/embulk/data/new/ruby/gemspec.erb +1 -0
- data/lib/embulk/data/new/ruby/input.rb.erb +3 -3
- data/lib/embulk/data/new/ruby/output.rb.erb +4 -4
- data/lib/embulk/data/package_data.rb +1 -15
- data/lib/embulk/guess/charset.rb +10 -1
- data/lib/embulk/input_plugin.rb +12 -12
- data/lib/embulk/java/bootstrap.rb +7 -4
- data/lib/embulk/java/imports.rb +34 -2
- data/lib/embulk/logger.rb +2 -0
- data/lib/embulk/output_plugin.rb +12 -12
- data/lib/embulk/page_builder.rb +1 -1
- data/lib/embulk/plugin.rb +0 -1
- data/lib/embulk/runner.rb +184 -0
- data/lib/embulk/version.rb +1 -1
- metadata +76 -55
- data/embulk-core/src/main/java/org/embulk/command/LiquidTemplate.java +0 -8
- data/embulk-core/src/main/java/org/embulk/command/Runner.java +0 -369
- data/embulk-docs/src/release/release-0.6.26.rst +0 -17
- data/embulk-docs/src/release/release-0.6.27.rst +0 -11
- data/lib/embulk/command/embulk.rb +0 -47
- data/lib/embulk/data/bundle/Gemfile.lock +0 -8
- data/lib/embulk/exec.rb +0 -8
- data/lib/embulk/gems.rb +0 -29
- data/lib/embulk/java/liquid_helper.rb +0 -16
|
@@ -9,12 +9,11 @@ import java.util.concurrent.ExecutionException;
|
|
|
9
9
|
import org.slf4j.Logger;
|
|
10
10
|
import com.google.inject.Inject;
|
|
11
11
|
import org.embulk.config.ConfigSource;
|
|
12
|
-
import org.embulk.config.
|
|
12
|
+
import org.embulk.config.TaskReport;
|
|
13
13
|
import org.embulk.spi.Exec;
|
|
14
14
|
import org.embulk.spi.ExecutorPlugin;
|
|
15
15
|
import org.embulk.spi.ProcessTask;
|
|
16
16
|
import org.embulk.spi.ProcessState;
|
|
17
|
-
import org.embulk.spi.TaskState;
|
|
18
17
|
import org.embulk.spi.Schema;
|
|
19
18
|
import org.embulk.spi.util.Executors;
|
|
20
19
|
import org.embulk.spi.util.Executors.ProcessStateCallback;
|
|
@@ -109,14 +108,14 @@ public class LocalExecutorPlugin
|
|
|
109
108
|
state.getOutputTaskState(taskIndex).start();
|
|
110
109
|
}
|
|
111
110
|
|
|
112
|
-
public void inputCommitted(
|
|
111
|
+
public void inputCommitted(TaskReport report)
|
|
113
112
|
{
|
|
114
|
-
state.getInputTaskState(taskIndex).
|
|
113
|
+
state.getInputTaskState(taskIndex).setTaskReport(report);
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
public void outputCommitted(
|
|
116
|
+
public void outputCommitted(TaskReport report)
|
|
118
117
|
{
|
|
119
|
-
state.getOutputTaskState(taskIndex).
|
|
118
|
+
state.getOutputTaskState(taskIndex).setTaskReport(report);
|
|
120
119
|
}
|
|
121
120
|
});
|
|
122
121
|
return null;
|
|
@@ -2,9 +2,6 @@ package org.embulk.exec;
|
|
|
2
2
|
|
|
3
3
|
import io.netty.buffer.PooledByteBufAllocator;
|
|
4
4
|
import io.netty.buffer.ByteBuf;
|
|
5
|
-
import io.netty.util.ResourceLeakDetector;
|
|
6
|
-
import io.netty.util.internal.logging.InternalLoggerFactory;
|
|
7
|
-
import io.netty.util.internal.logging.JdkLoggerFactory;
|
|
8
5
|
import org.embulk.spi.Buffer;
|
|
9
6
|
import org.embulk.spi.BufferAllocator;
|
|
10
7
|
import com.google.inject.Inject;
|
|
@@ -11,7 +11,7 @@ import org.embulk.config.ConfigDefault;
|
|
|
11
11
|
import org.embulk.config.Task;
|
|
12
12
|
import org.embulk.config.TaskSource;
|
|
13
13
|
import org.embulk.config.ConfigSource;
|
|
14
|
-
import org.embulk.config.
|
|
14
|
+
import org.embulk.config.TaskReport;
|
|
15
15
|
import org.embulk.plugin.PluginType;
|
|
16
16
|
import org.embulk.spi.Schema;
|
|
17
17
|
import org.embulk.spi.Page;
|
|
@@ -91,7 +91,7 @@ public class PreviewExecutor
|
|
|
91
91
|
|
|
92
92
|
try {
|
|
93
93
|
input.transaction(task.getInputConfig(), new InputPlugin.Control() {
|
|
94
|
-
public List<
|
|
94
|
+
public List<TaskReport> run(final TaskSource inputTask, Schema inputSchema, final int taskCount)
|
|
95
95
|
{
|
|
96
96
|
Filters.transaction(filterPlugins, task.getFilterConfigs(), inputSchema, new Filters.Control() {
|
|
97
97
|
public void run(final List<TaskSource> filterTasks, final List<Schema> filterSchemas)
|
|
@@ -4,11 +4,12 @@ import java.util.List;
|
|
|
4
4
|
import com.google.common.base.Optional;
|
|
5
5
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
6
6
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
7
|
+
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
7
8
|
import org.embulk.config.TaskSource;
|
|
8
9
|
import org.embulk.config.ConfigSource;
|
|
10
|
+
import org.embulk.config.TaskReport;
|
|
9
11
|
import org.embulk.config.CommitReport;
|
|
10
12
|
import org.embulk.spi.Schema;
|
|
11
|
-
import org.embulk.spi.ExecSession;
|
|
12
13
|
|
|
13
14
|
public class ResumeState
|
|
14
15
|
{
|
|
@@ -17,8 +18,8 @@ public class ResumeState
|
|
|
17
18
|
private final TaskSource outputTaskSource;
|
|
18
19
|
private final Schema inputSchema;
|
|
19
20
|
private final Schema outputSchema;
|
|
20
|
-
private final List<Optional<
|
|
21
|
-
private final List<Optional<
|
|
21
|
+
private final List<Optional<TaskReport>> inputTaskReports;
|
|
22
|
+
private final List<Optional<TaskReport>> outputTaskReports;
|
|
22
23
|
|
|
23
24
|
@JsonCreator
|
|
24
25
|
public ResumeState(
|
|
@@ -27,16 +28,16 @@ public class ResumeState
|
|
|
27
28
|
@JsonProperty("out_task") TaskSource outputTaskSource,
|
|
28
29
|
@JsonProperty("in_schema") Schema inputSchema,
|
|
29
30
|
@JsonProperty("out_schema") Schema outputSchema,
|
|
30
|
-
@JsonProperty("in_reports") List<Optional<
|
|
31
|
-
@JsonProperty("out_reports") List<Optional<
|
|
31
|
+
@JsonProperty("in_reports") List<Optional<TaskReport>> inputTaskReports,
|
|
32
|
+
@JsonProperty("out_reports") List<Optional<TaskReport>> outputTaskReports)
|
|
32
33
|
{
|
|
33
34
|
this.execSessionConfigSource = execSessionConfigSource;
|
|
34
35
|
this.inputTaskSource = inputTaskSource;
|
|
35
36
|
this.outputTaskSource = outputTaskSource;
|
|
36
37
|
this.inputSchema = inputSchema;
|
|
37
38
|
this.outputSchema = outputSchema;
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
39
|
+
this.inputTaskReports = inputTaskReports;
|
|
40
|
+
this.outputTaskReports = outputTaskReports;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
@JsonProperty("exec_task")
|
|
@@ -70,14 +71,30 @@ public class ResumeState
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
@JsonProperty("in_reports")
|
|
74
|
+
public List<Optional<TaskReport>> getInputTaskReports()
|
|
75
|
+
{
|
|
76
|
+
return inputTaskReports;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@Deprecated
|
|
80
|
+
@JsonIgnore
|
|
81
|
+
@SuppressWarnings("unchecked")
|
|
73
82
|
public List<Optional<CommitReport>> getInputCommitReports()
|
|
74
83
|
{
|
|
75
|
-
return
|
|
84
|
+
return (List) inputTaskReports; // the only implementation of TaskReport is DataSourceImpl which implements CommitReport
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
@JsonProperty("out_reports")
|
|
88
|
+
public List<Optional<TaskReport>> getOutputTaskReports()
|
|
89
|
+
{
|
|
90
|
+
return outputTaskReports;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@Deprecated
|
|
94
|
+
@JsonIgnore
|
|
95
|
+
@SuppressWarnings("unchecked")
|
|
79
96
|
public List<Optional<CommitReport>> getOutputCommitReports()
|
|
80
97
|
{
|
|
81
|
-
return
|
|
98
|
+
return (List) outputTaskReports; // the only implementation of TaskReport is DataSourceImpl which implements CommitReport;
|
|
82
99
|
}
|
|
83
100
|
}
|
|
@@ -5,8 +5,7 @@ import com.google.inject.Inject;
|
|
|
5
5
|
import com.google.common.base.Preconditions;
|
|
6
6
|
import org.embulk.config.TaskSource;
|
|
7
7
|
import org.embulk.config.ConfigSource;
|
|
8
|
-
import org.embulk.config.
|
|
9
|
-
import org.embulk.plugin.PluginType;
|
|
8
|
+
import org.embulk.config.TaskReport;
|
|
10
9
|
import org.embulk.spi.Schema;
|
|
11
10
|
import org.embulk.spi.Exec;
|
|
12
11
|
import org.embulk.spi.Page;
|
|
@@ -16,7 +15,6 @@ import org.embulk.spi.ParserPlugin;
|
|
|
16
15
|
import org.embulk.spi.FileInput;
|
|
17
16
|
import org.embulk.spi.FileInputRunner;
|
|
18
17
|
import org.embulk.spi.PageOutput;
|
|
19
|
-
import org.embulk.exec.ForSystemConfig;
|
|
20
18
|
import static org.embulk.spi.util.Inputs.each;
|
|
21
19
|
|
|
22
20
|
/*
|
|
@@ -34,7 +32,7 @@ public class SamplingParserPlugin
|
|
|
34
32
|
|
|
35
33
|
try {
|
|
36
34
|
runner.transaction(samplingInputConfig, new InputPlugin.Control() {
|
|
37
|
-
public List<
|
|
35
|
+
public List<TaskReport> run(TaskSource taskSource, Schema schema, int taskCount)
|
|
38
36
|
{
|
|
39
37
|
if (taskCount == 0) {
|
|
40
38
|
throw new NoSampleException("No input files to read sample data");
|
|
@@ -100,17 +100,24 @@ public class Bootstrap
|
|
|
100
100
|
return this;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
public
|
|
103
|
+
public LifeCycleInjector initialize()
|
|
104
104
|
{
|
|
105
|
-
|
|
106
|
-
injector.getInstance(LifeCycleManager.class).destroyOnShutdownHook();
|
|
107
|
-
return injector;
|
|
105
|
+
return build(true);
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
public CloseableInjector initializeCloseable()
|
|
109
|
+
{
|
|
110
|
+
return build(false);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private LifeCycleInjectorProxy build(boolean destroyOnShutdownHook)
|
|
111
114
|
{
|
|
112
115
|
Injector injector = start();
|
|
113
|
-
|
|
116
|
+
LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class);
|
|
117
|
+
if (destroyOnShutdownHook) {
|
|
118
|
+
lifeCycleManager.destroyOnShutdownHook();
|
|
119
|
+
}
|
|
120
|
+
return new LifeCycleInjectorProxy(injector, lifeCycleManager);
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
private Injector start()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2015 Sadayuki Furuhashi
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
package org.embulk.guice;
|
|
17
|
+
|
|
18
|
+
import com.google.inject.Injector;
|
|
19
|
+
|
|
20
|
+
public interface LifeCycleInjector
|
|
21
|
+
extends Injector
|
|
22
|
+
{
|
|
23
|
+
boolean isDestroyed();
|
|
24
|
+
|
|
25
|
+
void destroy() throws Exception;
|
|
26
|
+
}
|
|
@@ -17,14 +17,14 @@ package org.embulk.guice;
|
|
|
17
17
|
|
|
18
18
|
import com.google.inject.Injector;
|
|
19
19
|
|
|
20
|
-
class
|
|
20
|
+
class LifeCycleInjectorProxy
|
|
21
21
|
extends InjectorProxy
|
|
22
|
-
implements CloseableInjector
|
|
22
|
+
implements LifeCycleInjector, CloseableInjector
|
|
23
23
|
{
|
|
24
24
|
private final Injector injector;
|
|
25
25
|
private final LifeCycleManager lifeCycleManager;
|
|
26
26
|
|
|
27
|
-
public
|
|
27
|
+
public LifeCycleInjectorProxy(Injector injector, LifeCycleManager lifeCycleManager)
|
|
28
28
|
{
|
|
29
29
|
this.injector = injector;
|
|
30
30
|
this.lifeCycleManager = lifeCycleManager;
|
|
@@ -33,15 +33,29 @@ class CloseableInjectorProxy
|
|
|
33
33
|
@Override
|
|
34
34
|
protected synchronized Injector injector()
|
|
35
35
|
{
|
|
36
|
-
if (
|
|
37
|
-
throw new IllegalStateException("Injector already
|
|
36
|
+
if (isDestroyed()) {
|
|
37
|
+
throw new IllegalStateException("Injector already destroyed");
|
|
38
38
|
}
|
|
39
39
|
return injector;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
@Override
|
|
43
|
-
public synchronized
|
|
43
|
+
public synchronized boolean isDestroyed()
|
|
44
|
+
{
|
|
45
|
+
return lifeCycleManager.isDestroyed();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@Override
|
|
49
|
+
public synchronized void destroy()
|
|
50
|
+
throws Exception
|
|
44
51
|
{
|
|
45
52
|
lifeCycleManager.destroy(); // reentrant
|
|
46
53
|
}
|
|
54
|
+
|
|
55
|
+
@Override
|
|
56
|
+
public void close()
|
|
57
|
+
throws Exception
|
|
58
|
+
{
|
|
59
|
+
destroy();
|
|
60
|
+
}
|
|
47
61
|
}
|
|
@@ -3,13 +3,11 @@ package org.embulk.jruby;
|
|
|
3
3
|
import java.util.List;
|
|
4
4
|
import java.util.ArrayList;
|
|
5
5
|
import java.util.Set;
|
|
6
|
-
import java.io.File;
|
|
7
6
|
import org.slf4j.ILoggerFactory;
|
|
8
7
|
import com.google.common.collect.ImmutableSet;
|
|
9
8
|
import com.google.inject.Module;
|
|
10
9
|
import com.google.inject.Binder;
|
|
11
10
|
import com.google.inject.Scopes;
|
|
12
|
-
import com.google.inject.Provider;
|
|
13
11
|
import com.google.inject.multibindings.Multibinder;
|
|
14
12
|
import com.google.inject.Inject;
|
|
15
13
|
import com.google.inject.Injector;
|
|
@@ -67,16 +65,19 @@ public class JRubyScriptingModule
|
|
|
67
65
|
jruby.setCompatVersion(CompatVersion.RUBY1_9);
|
|
68
66
|
|
|
69
67
|
// Search embulk/java/bootstrap.rb from a $LOAD_PATH.
|
|
70
|
-
// $LOAD_PATH is set by lib/embulk/command/
|
|
68
|
+
// $LOAD_PATH is set by lib/embulk/command/embulk_run.rb if Embulk starts
|
|
71
69
|
// using embulk-cli but it's not set if Embulk is embedded in an application.
|
|
72
70
|
// Here adds this jar's internal resources to $LOAD_PATH for those applciations.
|
|
73
71
|
|
|
74
|
-
List<String> loadPaths = new ArrayList<String>(jruby.getLoadPaths());
|
|
75
|
-
String coreJarPath = JRubyScriptingModule.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
|
76
|
-
if (!loadPaths.contains(coreJarPath)) {
|
|
77
|
-
loadPaths.add(coreJarPath);
|
|
78
|
-
}
|
|
79
|
-
jruby.setLoadPaths(loadPaths);
|
|
72
|
+
// List<String> loadPaths = new ArrayList<String>(jruby.getLoadPaths());
|
|
73
|
+
// String coreJarPath = JRubyScriptingModule.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
|
74
|
+
// if (!loadPaths.contains(coreJarPath)) {
|
|
75
|
+
// loadPaths.add(coreJarPath);
|
|
76
|
+
// }
|
|
77
|
+
// jruby.setLoadPaths(loadPaths);
|
|
78
|
+
|
|
79
|
+
// load embulk.rb
|
|
80
|
+
jruby.runScriptlet("require 'embulk'");
|
|
80
81
|
|
|
81
82
|
// jruby searches embulk/java/bootstrap.rb from the beginning of $LOAD_PATH.
|
|
82
83
|
jruby.runScriptlet("require 'embulk/java/bootstrap'");
|
|
@@ -96,9 +97,6 @@ public class JRubyScriptingModule
|
|
|
96
97
|
jruby.runScriptlet("Embulk::Java::Injected"),
|
|
97
98
|
"const_set", "BufferAllocator", injector.getInstance(BufferAllocator.class));
|
|
98
99
|
|
|
99
|
-
// load embulk.rb
|
|
100
|
-
jruby.runScriptlet("require 'embulk'");
|
|
101
|
-
|
|
102
100
|
// initialize logger
|
|
103
101
|
jruby.callMethod(
|
|
104
102
|
jruby.runScriptlet("Embulk"),
|
|
@@ -7,6 +7,8 @@ import com.google.common.collect.ImmutableList;
|
|
|
7
7
|
import com.google.inject.Inject;
|
|
8
8
|
import com.google.inject.Injector;
|
|
9
9
|
import org.embulk.config.ConfigException;
|
|
10
|
+
import org.embulk.spi.InputPlugin;
|
|
11
|
+
import org.embulk.plugin.compat.PluginWrappers;
|
|
10
12
|
|
|
11
13
|
public class PluginManager
|
|
12
14
|
{
|
|
@@ -22,7 +24,17 @@ public class PluginManager
|
|
|
22
24
|
this.injector = injector;
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
@SuppressWarnings("unchecked")
|
|
25
28
|
public <T> T newPlugin(Class<T> iface, PluginType type)
|
|
29
|
+
{
|
|
30
|
+
T t = newPluginWithoutWrapper(iface, type);
|
|
31
|
+
if (t instanceof InputPlugin) {
|
|
32
|
+
return (T) PluginWrappers.inputPlugin((InputPlugin) t);
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private <T> T newPluginWithoutWrapper(Class<T> iface, PluginType type)
|
|
26
38
|
{
|
|
27
39
|
if (sources.isEmpty()) {
|
|
28
40
|
throw new ConfigException("No PluginSource is installed");
|
|
@@ -36,7 +48,8 @@ public class PluginManager
|
|
|
36
48
|
for (PluginSource source : sources) {
|
|
37
49
|
try {
|
|
38
50
|
return source.newPlugin(iface, type);
|
|
39
|
-
}
|
|
51
|
+
}
|
|
52
|
+
catch (PluginSourceNotMatchException e) {
|
|
40
53
|
exceptions.add(e);
|
|
41
54
|
}
|
|
42
55
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
package org.embulk.plugin.compat;
|
|
2
|
+
|
|
3
|
+
import java.util.List;
|
|
4
|
+
import java.lang.reflect.Method;
|
|
5
|
+
import java.lang.reflect.InvocationTargetException;
|
|
6
|
+
import com.google.common.base.Throwables;
|
|
7
|
+
import org.embulk.config.CommitReport;
|
|
8
|
+
import org.embulk.config.TaskReport;
|
|
9
|
+
import org.embulk.spi.PageOutput;
|
|
10
|
+
import org.embulk.spi.Schema;
|
|
11
|
+
import org.embulk.spi.InputPlugin;
|
|
12
|
+
import org.embulk.config.ConfigSource;
|
|
13
|
+
import org.embulk.config.ConfigDiff;
|
|
14
|
+
import org.embulk.config.TaskSource;
|
|
15
|
+
|
|
16
|
+
public class InputPluginWrapper
|
|
17
|
+
implements InputPlugin
|
|
18
|
+
{
|
|
19
|
+
public static InputPlugin wrapIfNecessary(InputPlugin object)
|
|
20
|
+
{
|
|
21
|
+
Method runMethod = wrapRunMethod(object);
|
|
22
|
+
if (runMethod != null) {
|
|
23
|
+
return new InputPluginWrapper(object, runMethod);
|
|
24
|
+
}
|
|
25
|
+
return object;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private static Method wrapRunMethod(InputPlugin object)
|
|
29
|
+
{
|
|
30
|
+
try {
|
|
31
|
+
Method m = object.getClass().getMethod("run", TaskSource.class, Schema.class, int.class, PageOutput.class);
|
|
32
|
+
if (m.getReturnType().equals(CommitReport.class)) {
|
|
33
|
+
return m;
|
|
34
|
+
} else {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (NoSuchMethodException ex) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private final InputPlugin object;
|
|
44
|
+
private final Method runMethod;
|
|
45
|
+
|
|
46
|
+
private InputPluginWrapper(InputPlugin object,
|
|
47
|
+
Method runMethod)
|
|
48
|
+
{
|
|
49
|
+
this.object = object;
|
|
50
|
+
this.runMethod = runMethod;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Override
|
|
54
|
+
public ConfigDiff transaction(ConfigSource config,
|
|
55
|
+
InputPlugin.Control control)
|
|
56
|
+
{
|
|
57
|
+
return object.transaction(config, control);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Override
|
|
61
|
+
public ConfigDiff resume(TaskSource taskSource,
|
|
62
|
+
Schema schema, int taskCount,
|
|
63
|
+
InputPlugin.Control control)
|
|
64
|
+
{
|
|
65
|
+
return object.resume(taskSource, schema, taskCount, control);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Override
|
|
69
|
+
public void cleanup(TaskSource taskSource,
|
|
70
|
+
Schema schema, int taskCount,
|
|
71
|
+
List<TaskReport> successTaskReports)
|
|
72
|
+
{
|
|
73
|
+
object.cleanup(taskSource, schema, taskCount, successTaskReports);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@Override
|
|
77
|
+
public TaskReport run(TaskSource taskSource,
|
|
78
|
+
Schema schema, int taskIndex,
|
|
79
|
+
PageOutput output)
|
|
80
|
+
{
|
|
81
|
+
if (runMethod != null) {
|
|
82
|
+
try {
|
|
83
|
+
return (TaskReport) runMethod.invoke(object, taskSource, schema, taskIndex, output);
|
|
84
|
+
}
|
|
85
|
+
catch (IllegalAccessException | IllegalArgumentException ex) {
|
|
86
|
+
throw Throwables.propagate(ex);
|
|
87
|
+
}
|
|
88
|
+
catch (InvocationTargetException ex) {
|
|
89
|
+
throw Throwables.propagate(ex.getCause());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
} else {
|
|
93
|
+
return object.run(taskSource, schema, taskIndex, output);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@Override
|
|
98
|
+
public ConfigDiff guess(ConfigSource config)
|
|
99
|
+
{
|
|
100
|
+
return object.guess(config);
|
|
101
|
+
}
|
|
102
|
+
}
|