-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTTP-42-BatchRequest - add support for batch request processing in HT…
…TP sink #4 Signed-off-by: Krzysztof Chmielewski <[email protected]>
- Loading branch information
1 parent
8c314fe
commit 9467a83
Showing
31 changed files
with
300 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/com/getindata/connectors/http/internal/config/SinkRequestSubmitMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.getindata.connectors.http.internal.config; | ||
|
||
public enum SinkRequestSubmitMode { | ||
|
||
PER_REQUEST("PerRequest"), | ||
BATCH("Batch"); | ||
|
||
private final String mode; | ||
|
||
SinkRequestSubmitMode(String mode) { | ||
this.mode = mode; | ||
} | ||
|
||
public String getMode() { | ||
return mode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
.../com/getindata/connectors/http/internal/sink/httpclient/BatchRequestSubmitterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.getindata.connectors.http.internal.sink.httpclient; | ||
|
||
import java.util.Properties; | ||
|
||
import org.apache.flink.util.StringUtils; | ||
|
||
import com.getindata.connectors.http.internal.config.ConfigException; | ||
import com.getindata.connectors.http.internal.config.HttpConnectorConfigProperties; | ||
|
||
public class BatchRequestSubmitterFactory implements RequestSubmitterFactory { | ||
|
||
private final String maxBatchSize; | ||
|
||
public BatchRequestSubmitterFactory(int maxBatchSize) { | ||
this.maxBatchSize = String.valueOf(maxBatchSize); | ||
} | ||
|
||
@Override | ||
public RequestSubmitter createSubmitter(Properties properties, String[] headersAndValues) { | ||
String batchRequestSize = | ||
properties.getProperty(HttpConnectorConfigProperties.SINK_HTTP_BATCH_REQUEST_SIZE); | ||
if (StringUtils.isNullOrWhitespaceOnly(batchRequestSize)) { | ||
properties.setProperty( | ||
HttpConnectorConfigProperties.SINK_HTTP_BATCH_REQUEST_SIZE, | ||
maxBatchSize | ||
); | ||
} else { | ||
try { | ||
// TODO Create property validator someday. | ||
int batchSize = Integer.parseInt(batchRequestSize); | ||
if (batchSize < 1) { | ||
throw new ConfigException( | ||
String.format("Property %s must be greater than 0 but was: %s", | ||
HttpConnectorConfigProperties.SINK_HTTP_BATCH_REQUEST_SIZE, | ||
batchRequestSize) | ||
); | ||
} | ||
} catch (NumberFormatException e) { | ||
// TODO Create property validator someday. | ||
throw new ConfigException( | ||
String.format("Property %s must be an integer but was: %s", | ||
HttpConnectorConfigProperties.SINK_HTTP_BATCH_REQUEST_SIZE, | ||
batchRequestSize), | ||
e | ||
); | ||
} | ||
} | ||
return new BatchRequestSubmitter(properties, headersAndValues); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...getindata/connectors/http/internal/sink/httpclient/PerRequestRequestSubmitterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.getindata.connectors.http.internal.sink.httpclient; | ||
|
||
import java.util.Properties; | ||
|
||
public class PerRequestRequestSubmitterFactory implements RequestSubmitterFactory { | ||
|
||
@Override | ||
public RequestSubmitter createSubmitter(Properties properties, String[] headersAndValues) { | ||
return new PerRequestSubmitter(properties, headersAndValues); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
.../java/com/getindata/connectors/http/internal/sink/httpclient/RequestSubmitterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.getindata.connectors.http.internal.sink.httpclient; | ||
|
||
import java.util.Properties; | ||
|
||
public interface RequestSubmitterFactory { | ||
|
||
RequestSubmitter createSubmitter(Properties properties, String[] headersAndValues); | ||
|
||
} |
Oops, something went wrong.