Skip to content

Commit

Permalink
Fix for incorrect rpc url
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailMedvedevAkvelon committed Mar 18, 2021
1 parent aeb471e commit a923846
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.apache.beam.sdk.values.Row;
import org.apache.beam.sdk.values.TupleTag;
import org.apache.beam.sdk.values.TypeDescriptors;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -275,7 +276,7 @@ public static PipelineResult run(DataTokenizationOptions options) {
.via(
(Row errRow) ->
FailsafeElement.of(errRow.getString("line"), errRow.getString("line"))
.setErrorMessage(errRow.getString("err"))))
.setErrorMessage(Strings.nullToEmpty(errRow.getString("err")))))
.apply(
"WriteCsvConversionErrorsToFS",
ErrorConverters.WriteStringMessageErrorsAsCsv.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Throwables;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
Expand Down Expand Up @@ -291,6 +292,10 @@ private ArrayList<Row> getTokenizedRow(Iterable<Row> inputRows) throws IOExcepti
CloseableHttpResponse response =
sendRpc(formatJsonsToRpcBatch(rowsToJsons(inputRows)).getBytes(Charset.defaultCharset()));

if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
LOG.error("Send to RPC '{}' failed with '{}'", this.rpcURI, response.getStatusLine());
}

String tokenizedData =
IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);

Expand Down

0 comments on commit a923846

Please sign in to comment.