blob: 1a93a5ad846ea5bc6392b2d31602ccf003d96078 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
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()
hdfsClient, hdfsConnectError := hdfs.New(hdfsURL)
if hdfsConnectError !=nil {
slogger.Fatalf(":::Error in create hdfsClient::: %v", hdfsConnectError)
fmt.Printf("::Unable to initialize hdfsURL, check logs")
}
return hdfsClient
}
|