Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Java Maven build

on: [push]

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Publish to GitHub Packages
run: mvn deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This command will install all the components in your `.m2` directory. To use you

```
<dependency>
<groupId>net.galgus</groupId>
<groupId>tgamforks</groupId>
<artifactId>flink-connector-http</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Expand Down
13 changes: 11 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.galgus</groupId>
<groupId>tgamforks</groupId>
<artifactId>flink-connector-http</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0</version>

<name>flink-connector-http</name>

Expand Down Expand Up @@ -37,4 +37,13 @@
</plugin>
</plugins>
</build>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub globeandmail Apache Maven Packages</name>
<url>https://maven.pkg.github.com/globeandmail/flink-connector-http</url>
</repository>
</distributionManagement>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;

public class HTTPSink<IN> extends RichSinkFunction<IN> {
private static final Logger log = LoggerFactory.getLogger(HTTPSink.class);
Expand All @@ -25,9 +26,10 @@ public HTTPSink(HTTPConnectionConfig httpConnectionConfig) {
public void invoke(IN value, Context context) throws Exception {
if (value != null) {
URL url = new URL(httpConnectionConfig.getEndpoint());


long start = System.nanoTime();

HttpURLConnection conn = httpConnectionConfig.isHttpsEnabled() ? (HttpsURLConnection) url.openConnection() : (HttpURLConnection) url.openConnection();

conn.setDoOutput(true);
conn.setRequestMethod(httpConnectionConfig.getMethod());

Expand Down Expand Up @@ -58,6 +60,10 @@ public void invoke(IN value, Context context) throws Exception {
+ ", headers: " + httpConnectionConfig.getHeaders());

conn.disconnect();
long elapsedNano = System.nanoTime() - start;
long elapsedTime = TimeUnit.NANOSECONDS.toMillis(elapsedNano);
log.info("Request from url = {}, with status = {} and message = {} in duration = {}ms",
conn.getURL(), status, conn.getResponseMessage(), Long.toString(elapsedTime));
}
}
}