[
https://issues.apache.org/jira/browse/BEAM-14048?focusedWorklogId=746422&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-746422
]
ASF GitHub Bot logged work on BEAM-14048:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 23/Mar/22 08:53
Start Date: 23/Mar/22 08:53
Worklog Time Spent: 10m
Work Description: Amar3tto commented on a change in pull request #17051:
URL: https://github.com/apache/beam/pull/17051#discussion_r833005810
##########
File path:
sdks/java/io/cdap/src/main/java/org/apache/beam/sdk/io/cdap/ConfigWrapper.java
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.cdap;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.cdap.cdap.api.plugin.PluginConfig;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Class for building {@link PluginConfig} object of the specific class
{@param <T>}. */
+public class ConfigWrapper<T extends PluginConfig> {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(ConfigWrapper.class);
+
+ @Nullable private Map<String, Object> paramsMap = null;
+ private final Class<T> configClass;
+
+ public ConfigWrapper(Class<T> configClass) {
+ this.configClass = configClass;
+ }
+
+ public ConfigWrapper<T> fromJsonString(String jsonString) {
+ TypeReference<HashMap<String, Object>> typeRef =
+ new TypeReference<HashMap<String, Object>>() {};
+ try {
+ paramsMap = new ObjectMapper().readValue(jsonString, typeRef);
+ } catch (IOException e) {
+ LOG.error("Can not read json string to params map", e);
Review comment:
Done
##########
File path:
sdks/java/io/cdap/src/main/java/org/apache/beam/sdk/io/cdap/ConfigWrapper.java
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.cdap;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.cdap.cdap.api.plugin.PluginConfig;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Class for building {@link PluginConfig} object of the specific class
{@param <T>}. */
+public class ConfigWrapper<T extends PluginConfig> {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(ConfigWrapper.class);
+
+ @Nullable private Map<String, Object> paramsMap = null;
+ private final Class<T> configClass;
+
+ public ConfigWrapper(Class<T> configClass) {
+ this.configClass = configClass;
+ }
+
+ public ConfigWrapper<T> fromJsonString(String jsonString) {
+ TypeReference<HashMap<String, Object>> typeRef =
+ new TypeReference<HashMap<String, Object>>() {};
+ try {
+ paramsMap = new ObjectMapper().readValue(jsonString, typeRef);
+ } catch (IOException e) {
+ LOG.error("Can not read json string to params map", e);
+ }
+ return this;
+ }
+
+ public ConfigWrapper<T> fromJsonFile(File jsonFile) {
+ TypeReference<HashMap<String, Object>> typeRef =
+ new TypeReference<HashMap<String, Object>>() {};
+ try {
+ paramsMap = new ObjectMapper().readValue(jsonFile, typeRef);
+ } catch (IOException e) {
+ LOG.error("Can not read json file to params map", e);
Review comment:
Done.
##########
File path:
sdks/java/io/cdap/src/main/java/org/apache/beam/sdk/io/cdap/ConfigWrapper.java
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.cdap;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.cdap.cdap.api.plugin.PluginConfig;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Class for building {@link PluginConfig} object of the specific class
{@param <T>}. */
+public class ConfigWrapper<T extends PluginConfig> {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(ConfigWrapper.class);
+
+ @Nullable private Map<String, Object> paramsMap = null;
+ private final Class<T> configClass;
+
+ public ConfigWrapper(Class<T> configClass) {
+ this.configClass = configClass;
+ }
+
+ public ConfigWrapper<T> fromJsonString(String jsonString) {
+ TypeReference<HashMap<String, Object>> typeRef =
+ new TypeReference<HashMap<String, Object>>() {};
+ try {
+ paramsMap = new ObjectMapper().readValue(jsonString, typeRef);
+ } catch (IOException e) {
+ LOG.error("Can not read json string to params map", e);
Review comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 746422)
Time Spent: 14h 40m (was: 14.5h)
> [CdapIO] Design and implement ConfigWrapper for building CDAP PluginConfigs
> ---------------------------------------------------------------------------
>
> Key: BEAM-14048
> URL: https://issues.apache.org/jira/browse/BEAM-14048
> Project: Beam
> Issue Type: Task
> Components: io-java-cdap
> Reporter: Elizaveta Lomteva
> Assignee: Vitaly Terentyev
> Priority: P2
> Labels: cdap-io-sprint-1
> Time Spent: 14h 40m
> Remaining Estimate: 0h
>
> h3. Context:
> CDAP plugins use their configuration classes (ex.
> {{{}SalesforceSinkConfig{}}}) to set the required parameters to prepare and
> run a pipeline in Source or Sink classes (ex. {{{}SalesforceBatchSink{}}}).
> The config instance is accepted as a Source/Sink constructor argument.
> The configuration classes are usually placed in the {{{}cdap/plugin/\{<plugin
> name>}/plugin/\{sink|source}/{batch|streaming{}}}} folder (ex. [Salesforce
> repo|https://github.com/data-integrations/salesforce/tree/d0d83fd82bbdbbb7ef07168f3b1698eebdc90c3e/src/main/java/io/cdap/plugin/salesforce/plugin]).
> h3. Task Description:
> Required to design wrapper class(es) for the CDAP plugin config class so that
> the CDAP plugin config instance can be created in the Apache Beam connector
> based on user input and used when creating CDAP Source or Sink.
> h3. Acceptance criteria:
> Design and source code of CDAP Config wrapper that will
> # accept custom parameters as constructor arguments (JSON/string or
> something else)
> # return an instance of plugins configuration class (ex.
> {{{}SalesforceSinkConfig{}}})
--
This message was sent by Atlassian Jira
(v8.20.1#820001)