forked from yackrru/embulk-output-s3v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractStrategy.java
More file actions
41 lines (34 loc) · 1.27 KB
/
AbstractStrategy.java
File metadata and controls
41 lines (34 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.embulk.output.s3v2.strategy;
import org.embulk.output.s3v2.PluginTask;
import org.embulk.output.s3v2.s3.S3ClientManager;
import org.embulk.output.s3v2.s3.S3MultiPartStatus;
import org.embulk.spi.TransactionalFileOutput;
abstract class AbstractStrategy implements TransactionalFileOutput
{
protected S3ClientManager s3;
protected PluginTask task;
protected int taskIndex;
public AbstractStrategy(PluginTask task, int taskIndex)
{
s3 = new S3ClientManager(task.getEndpoint(), task.getRegion(), task.getEnableProfile(), task.getProfile());
this.task = task;
this.taskIndex = taskIndex;
if (!validate()) {
throw new IllegalArgumentException("Unsupported parameters combination");
}
}
/**
* Validation for PluginTask parameters combination.
* @see PluginTask
*/
protected abstract boolean validate();
protected final String getFileExtension()
{
return task.getExtension().startsWith(".") ? task.getExtension() : "." + task.getExtension();
}
protected final S3MultiPartStatus setUpS3MultiPartStatus()
{
return new S3MultiPartStatus(task.getMaxConcurrentRequests(), task.getMultipartChunksize(),
task.getMultipartThreshold());
}
}