HDFSWriter microservice working copy
[demo.git] / vnfs / DAaaS / microservices / GoApps / src / go-hdfs-writer / pkg / utils / hdfsUtils.go
1 package utils
2
3 import (
4         "fmt"
5         "github.com/colinmarc/hdfs"
6         //"sync"
7         //"go.uber.org/zap"
8 )
9
10
11 //var clientOnce sync.Once
12 //var hdfsClient *hdfs.Client
13 //var slogger *zap.SugaredLogger
14
15
16 //GetHdfsClientInstance returns a singleton hdfsClient instance
17 // func GetHdfsClientInstance(hdfsURL string) (*hdfs.Client){
18 //      clientOnce.Do(func(){
19 //              hdfsClient = createHdfsClient(hdfsURL)
20 //      })
21 //      return hdfsClient
22 // }
23
24 //CreateHdfsClient creates a hdfs client and returns hdfs client
25 func CreateHdfsClient(hdfsURL string) (*hdfs.Client){
26         slogger := GetLoggerInstance()
27         hdfsClient, hdfsConnectError := hdfs.New(hdfsURL)
28         if hdfsConnectError !=nil {
29                 slogger.Fatalf(":::Error in create hdfsClient::: %v", hdfsConnectError)
30                 fmt.Printf("::Unable to initialize hdfsURL, check logs")
31         }
32         return hdfsClient
33 }