aboutsummaryrefslogtreecommitdiffstats
path: root/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils
diff options
context:
space:
mode:
authorRajamohan Raj <rajamohan.raj@intel.com>2019-10-31 23:51:29 +0000
committerMarco Platania <platania@research.att.com>2019-11-04 14:02:09 +0000
commit68d118176bb53c36b31a7060cfa16ad5acac1765 (patch)
treec6dfd74445126f24e8d63457e33720fc5e0d38bb /vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils
parent68042495ef1e1e6dff7fed7fc2691b01cf672fe1 (diff)
HDFS-WriterApp-Fixed all the code review comments
Fixed all the code review comments by Kiran 1. Implemented a boolean channel instead of empty struct channel for signal, use WaitGroup to ensure all writers finish cleanup. 2. Introduce JSON tags for configs 4. remove all panic and fatalf code to ensure that the app doesnt crash anytime. 5. remove unneccessary hdfsWriter null checks. 6.remove the 'run' variable used in the infinite loop, replaced with 'return' Issue-ID: ONAPARC-453 Change-Id: Ic77c59dc75a8898a3cf34999850e6687d40e7faa Signed-off-by: Rajamohan Raj <rajamohan.raj@intel.com>
Diffstat (limited to 'vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils')
-rw-r--r--vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/hdfs-config.go37
-rw-r--r--vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/hdfsUtils.go15
-rw-r--r--vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/kafka-config.go55
-rw-r--r--vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/types.go19
4 files changed, 19 insertions, 107 deletions
diff --git a/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/hdfs-config.go b/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/hdfs-config.go
deleted file mode 100644
index ac33bc6a..00000000
--- a/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/hdfs-config.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package utils
-
-import (
- "os"
-)
-
-// SetHdfsParametersByObjectMap set the value of the hdfs config parameters
-// and return HdfsConfig object
-func SetHdfsParametersByObjectMap(m map[string]interface{}) HdfsConfig{
-
- hc := HdfsConfig{}
- hc.hdfsURL = m["hdfs_url"].(string)
- return hc
-
-}
-
-// SetHdfsParametersByEnvVariables sets the hdfs parameters
-func SetHdfsParametersByEnvVariables() HdfsConfig {
-
- slogger := GetLoggerInstance()
- hdfsConfigObject := HdfsConfig{
- hdfsURL: os.Getenv("HDFS_URL"),
- }
- slogger.Infof("::hdfsURL:: %s", hdfsConfigObject.hdfsURL)
- return hdfsConfigObject
-
-}
-
-// HdfsConfig contains hdfs related config items
-type HdfsConfig struct {
- hdfsURL string
-}
-
-// GetHdfsURL returns HdfsURL
-func (h HdfsConfig) GetHdfsURL() string {
- return h.hdfsURL
-} \ No newline at end of file
diff --git a/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/hdfsUtils.go b/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/hdfsUtils.go
index 1a93a5ad..8edcec19 100644
--- a/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/hdfsUtils.go
+++ b/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/hdfsUtils.go
@@ -3,24 +3,9 @@ package utils
import (
"fmt"
"github.com/colinmarc/hdfs"
- //"sync"
- //"go.uber.org/zap"
)
-//var clientOnce sync.Once
-//var hdfsClient *hdfs.Client
-//var slogger *zap.SugaredLogger
-
-
-//GetHdfsClientInstance returns a singleton hdfsClient instance
-// func GetHdfsClientInstance(hdfsURL string) (*hdfs.Client){
-// clientOnce.Do(func(){
-// hdfsClient = createHdfsClient(hdfsURL)
-// })
-// return hdfsClient
-// }
-
//CreateHdfsClient creates a hdfs client and returns hdfs client
func CreateHdfsClient(hdfsURL string) (*hdfs.Client){
slogger := GetLoggerInstance()
diff --git a/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/kafka-config.go b/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/kafka-config.go
deleted file mode 100644
index 080bfd4b..00000000
--- a/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/kafka-config.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package utils
-
-
-import (
- "os"
-)
-
-// SetKafkaParametersByObjectMap sets the value of the kafka parameters
-// and sets the KafkaConfig object
-func SetKafkaParametersByObjectMap(m map[string]interface{}) KafkaConfig {
- kc := KafkaConfig{}
- kc.broker = m["broker"].(string)
- kc.group = m["group"].(string)
- kc.topic = m["topic"].(string)
-
- return kc
-}
-
-// SetKafkaParametersByEnvVariables sets the kafka parameters
-func SetKafkaParametersByEnvVariables() KafkaConfig {
- slogger := GetLoggerInstance()
-
- kafkaConfigObject := KafkaConfig{
- broker: os.Getenv("BROKER"),
- group: os.Getenv("GROUP"),
- topic: os.Getenv("TOPIC"),
- }
- slogger.Infof("::broker:: %s", kafkaConfigObject.broker)
- slogger.Infof("::group:: %s", kafkaConfigObject.group)
- slogger.Infof("::topic:: %s", kafkaConfigObject.topic)
-
- return kafkaConfigObject
-}
-
-// KafkaConfig contains all the config parameters needed for kafka. This can be extended over time
-type KafkaConfig struct {
- broker string
- group string
- topic string
-}
-
-// GetBroker returns kafka broker configured
-func (k KafkaConfig) GetBroker() string {
- return k.broker
-}
-
-// GetGroup returns kafka group configured
-func (k KafkaConfig) GetGroup() string {
- return k.group
-}
-
-// GetTopic returns kafka topic configured
-func (k KafkaConfig) GetTopic() string {
- return k.topic
-} \ No newline at end of file
diff --git a/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/types.go b/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/types.go
new file mode 100644
index 00000000..3db3e420
--- /dev/null
+++ b/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/types.go
@@ -0,0 +1,19 @@
+package utils
+
+// Pipeline type represents a stucture of a general pipeline
+type Pipeline struct{
+ KafkaConfiguration KafkaConfig `json:"kafkaConfig"`
+ HdfsConfiguration HdfsConfig `json:"hdfsConfig"`
+}
+
+// HdfsConfig type represents the config items of HDFS
+type HdfsConfig struct {
+ HdfsURL string `json:"hdfs_url"`
+}
+
+// KafkaConfig type represents the config items of Kafka
+type KafkaConfig struct {
+ Broker string `json:"broker"`
+ Group string `json:"group"`
+ Topic string `json:"topic"`
+} \ No newline at end of file