本文整理汇总了Golang中github.com/asiainfoLDP/datahub/utils/clog.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: startP2PServer
func startP2PServer() {
p2pListener, err := net.Listen("tcp", ":35800")
if err != nil {
log.Fatal(err)
}
p2psl, err = tcpNew(p2pListener)
if err != nil {
log.Fatal(err)
}
P2pRouter := httprouter.New()
P2pRouter.GET("/", sayhello)
P2pRouter.GET("/pull/:repo/:dataitem/:tag", p2p_pull)
P2pRouter.GET("/health", p2pHealthyCheckHandler)
p2pserver := http.Server{Handler: P2pRouter}
wg.Add(1)
defer wg.Done()
log.Info("p2p server start")
p2pserver.Serve(p2psl)
log.Info("p2p server stop")
}
示例2: commToServer
func commToServer(method, path string, buffer []byte, w http.ResponseWriter) (body []byte, err error) {
//Trace()
s := log.Info("daemon: connecting to", DefaultServer+path)
logq.LogPutqueue(s)
req, err := http.NewRequest(strings.ToUpper(method), DefaultServer+path, bytes.NewBuffer(buffer))
if len(loginAuthStr) > 0 {
req.Header.Set("Authorization", loginAuthStr)
}
//req.Header.Set("User", "admin")
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Error(err)
d := ds.Result{Code: cmd.ErrorServiceUnavailable, Msg: err.Error()}
body, e := json.Marshal(d)
if e != nil {
log.Error(e)
return body, e
}
w.WriteHeader(http.StatusServiceUnavailable)
w.Write(body)
return body, err
}
defer resp.Body.Close()
w.WriteHeader(resp.StatusCode)
body, err = ioutil.ReadAll(resp.Body)
w.Write(body)
log.Info(resp.StatusCode, string(body))
return
}
示例3: delTagsForDelItem
func delTagsForDelItem(reponame, itemname string) error {
log.Println("Begin to remove tags for remove item from db")
sqlrpdmid := fmt.Sprintf(`SELECT RPDMID FROM DH_DP_RPDM_MAP WHERE REPOSITORY='%s' AND DATAITEM='%s' AND STATUS='A';`, reponame, itemname)
row, err := g_ds.QueryRow(sqlrpdmid)
if err != nil {
l := log.Error("select rpdmid from DH_DP_RPDM_MAP error:", err)
logq.LogPutqueue(l)
return err
}
var rpdmId int
row.Scan(&rpdmId)
if rpdmId == 0 {
log.Debug(reponame, itemname, "not exist.")
return nil
}
sqldeltag := fmt.Sprintf(`UPDATE DH_RPDM_TAG_MAP SET STATUS='N' WHERE RPDMID=%d`, rpdmId)
_, err = g_ds.Update(sqldeltag)
log.Info("sqldeltag", sqldeltag)
if err != nil {
l := log.Error("delete tag error:", err)
logq.LogPutqueue(l)
return err
}
return nil
}
示例4: CheckDataAndGetSize
func (s3 *s3driver) CheckDataAndGetSize(dpconn, itemlocation, fileName string) (exist bool, size int64, err error) {
bucket := getAwsInfoFromDpconn(dpconn)
destFullPathFileName := bucket + "/" + itemlocation + "/" + fileName
log.Info(destFullPathFileName)
AWS_REGION = Env("AWS_REGION", false)
svc := s3aws.New(session.New(&aws.Config{Region: aws.String(AWS_REGION)}))
result, err := svc.ListObjects(&s3aws.ListObjectsInput{Bucket: aws.String(bucket),
Prefix: aws.String(itemlocation + "/" + fileName)})
if err != nil {
log.Error("Failed to list objects", err)
return exist, size, err
}
exist = false
for _, v := range result.Contents {
log.Infof("Tag:%s, key:%s, size:%v\n", aws.StringValue(v.ETag), aws.StringValue(v.Key), aws.Int64Value(v.Size))
if aws.StringValue(v.Key) == fileName {
size = aws.Int64Value(v.Size)
exist = true
}
}
return
}
示例5: StoreFile
func (hdfs *hdfsdriver) StoreFile(status, filename, dpconn, dp, itemlocation, destfile string) string {
log.Infof("Begin to upload %v to %v\n", filename, dp)
client, err := getClient(dpconn)
if err != nil {
log.Error("Failed to get a client", err)
status = "put to hdfs err"
return status
}
defer client.Close()
err = client.MkdirAll("/"+itemlocation, 1777)
if err != nil {
log.Error("Failed to mkdirall in hdfs", err)
status = "put to hdfs err"
return status
}
hdfsfile := "/" + itemlocation + "/" + destfile
err = client.CopyToRemote(filename, hdfsfile)
if err != nil {
log.Error("Failed to CopyToRemote", err)
status = "put to hdfs err"
return status
}
status = "put to hdfs ok"
log.Info("Successfully uploaded to", itemlocation, "in hdfs")
return status
}
示例6: CheckDataAndGetSize
func (hdfs *hdfsdriver) CheckDataAndGetSize(dpconn, itemlocation, fileName string) (exist bool, size int64, err error) {
destFullPathFileName := "/" + itemlocation + "/" + fileName
log.Info(destFullPathFileName)
exist = false
client, err := getClient(dpconn)
if err != nil {
log.Error("Failed to get a client", err)
return
}
defer client.Close()
fileinfo, _ := client.Stat(destFullPathFileName)
if fileinfo != nil {
exist = true
cs, _ := client.GetContentSummary(destFullPathFileName)
size = cs.Size()
} else {
err = errors.New("文件不存在")
return
}
return
}
示例7: UpdateStatMsgTagadded
func UpdateStatMsgTagadded(ID, Status int) (err error) {
log.Info("update MSG_TAGADDED status")
sql := fmt.Sprintf(`UPDATE MSG_TAGADDED SET STATUS=%d
WHERE ID=%d;`, Status, ID)
_, err = g_ds.Update(sql)
if err != nil {
l := log.Error(err)
logq.LogPutqueue(l)
return
}
return
}
示例8: getDaemonid
func getDaemonid() (id string) {
log.Println("TODO get daemonid from db.")
s := `SELECT DAEMONID FROM DH_DAEMON;`
row, e := g_ds.QueryRow(s)
if e != nil {
l := log.Error(s, "error.", e)
logq.LogPutqueue(l)
return
}
row.Scan(&id)
log.Info("daemon id is", id)
return id
}
示例9: testserver
func testserver() {
var tsl = new(StoppabletcpListener)
Listener, err := net.Listen("tcp", ":35888")
if err != nil {
log.Fatal(err)
}
tsl, err = tcpNew(Listener)
if err != nil {
log.Fatal(err)
}
tRouter := httprouter.New()
tRouter.GET("/", sayhello)
http.Handle("/", tRouter)
server := http.Server{Handler: tRouter}
log.Info("p2p server start")
server.Serve(tsl)
log.Info("p2p server stop")
}
示例10: epPostHandler
func epPostHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
reqBody, _ := ioutil.ReadAll(r.Body)
ep := cmd.FormatEp{}
if err := json.Unmarshal(reqBody, &ep); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
EntryPoint = ep.Ep
saveEntryPoint(EntryPoint)
msg := ds.MsgResp{Msg: "OK. your entrypoint is: " + EntryPoint + "\n" + "The entrypoint is setted successfully. You can check whether it is available in one minute."}
log.Info(msg.Msg)
resp, _ := json.Marshal(&msg)
fmt.Fprintln(w, string(resp))
return
}
示例11: commToServerGetRsp
func commToServerGetRsp(method, path string, buffer []byte) (resp *http.Response, err error) {
s := log.Info("daemon: connecting to", DefaultServer+path)
logq.LogPutqueue(s)
req, err := http.NewRequest(strings.ToUpper(method), DefaultServer+path, bytes.NewBuffer(buffer))
if len(loginAuthStr) > 0 {
req.Header.Set("Authorization", loginAuthStr)
}
resp, err = http.DefaultClient.Do(req)
if err != nil {
log.Error(err)
return resp, err
}
return resp, nil
}
示例12: PullTagAutomatic
func PullTagAutomatic() {
for {
time.Sleep(30 * time.Second)
//log.Debug("AutomaticPullList.Len()", AutomaticPullList.Len())
var Tags map[int]string
for e := AutomaticPullList.Front(); e != nil; e = e.Next() {
v := e.Value.(ds.DsPull)
log.Info("PullTagAutomatic begin", v.Repository, v.Dataitem)
Tags = GetTagFromMsgTagadded(v.Repository, v.Dataitem, NOTREAD)
log.Println("Tags ", Tags)
go PullItemAutomatic(Tags, v)
}
}
}
示例13: StoreFile
func (s3 *s3driver) StoreFile(status, filename, dpconn, dp, itemlocation, destfile string) string {
bucket := getAwsInfoFromDpconn(dpconn)
//AWS_SECRET_ACCESS_KEY = Env("AWS_SECRET_ACCESS_KEY", false)
//AWS_ACCESS_KEY_ID = Env("AWS_ACCESS_KEY_ID", false)
AWS_REGION = Env("AWS_REGION", false)
file, err := os.Open(filename)
if err != nil {
l := log.Error("Failed to open file", err)
logq.LogPutqueue(l)
status = "put to s3 err"
return status
}
log.Infof("Begin to upload %v to %v\n", filename, dp)
// Not required, but you could zip the file before uploading it
// using io.Pipe read/writer to stream gzip'd file contents.
reader, writer := io.Pipe()
go func() {
gw := gzip.NewWriter(writer)
io.Copy(gw, file)
file.Close()
gw.Close()
writer.Close()
//updateJobQueueStatus(jobid, "puttos3ok")
}()
uploader := s3manager.NewUploader(session.New(&aws.Config{Region: aws.String(AWS_REGION)}))
//uploader := s3manager.NewUploader(session.New(aws.NewConfig()))
result, err := uploader.Upload(&s3manager.UploadInput{
Body: reader,
Bucket: aws.String(bucket),
Key: aws.String( /*dp + "/" + */ itemlocation + "/" + destfile + ".gz"),
})
if err != nil {
log.Error("Failed to upload", err)
status = "put to s3 err"
return status
}
status = "put to s3 ok"
log.Info("Successfully uploaded to", result.Location)
return status
}
示例14: CheckHealthClock
func CheckHealthClock() {
log.Debug("--------->BEGIN")
checkHealth(&Errortagsmap)
timer := time.NewTicker(10 * time.Minute)
for {
select {
case <-timer.C:
now := time.Now()
if now.Hour()%6 == 0 {
log.Info("Time:", now)
checkHealth(&Errortagsmap)
}
}
}
log.Debug("---------->END")
}
示例15: AutomaticPullRmqueue
func AutomaticPullRmqueue(p ds.DsPull) (exist bool) {
exist = false
pullmu.Lock()
defer pullmu.Unlock()
var next *list.Element
for e := AutomaticPullList.Front(); e != nil; e = next {
v := e.Value.(ds.DsPull)
if v.Repository == p.Repository && v.Dataitem == p.Dataitem {
exist = true
AutomaticPullList.Remove(e)
log.Info(v, "removed from the queue.")
break
} else {
next = e.Next()
}
}
return
}