本文整理匯總了Golang中github.com/golang/glog.Error函數的典型用法代碼示例。如果您正苦於以下問題:Golang Error函數的具體用法?Golang Error怎麽用?Golang Error使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Error函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewClient
// NewClient returns a new Client to handle requests to the
// service at the other end of the connection.
// A watcher is used to get updates about service endpoints
func NewClient(serviceName string, watcher watch.Watcher) *Client {
// Dial with no addresses means adding no endpoints
client, err := Dial()
if err != nil {
glog.Fatal(err)
}
// Handle updates about service endpoints
serviceChannel := make(chan watch.ServiceUpdate)
go util.Forever(func() {
serviceUpdate := <-serviceChannel
switch serviceUpdate.Op {
case watch.ADD:
if err := client.endpoints.add(serviceUpdate.Value); err != nil {
glog.Error(err)
}
case watch.REMOVE:
if err := client.endpoints.del(serviceUpdate.Value); err != nil {
glog.Error(err)
}
default:
glog.Warning("zrpc: unknown service update op")
}
}, time.Second)
// Register as a listener for passed service name
watcher.Watch(serviceName, serviceChannel)
return client
}
示例2: Load
// Load [...]
func (g *Graph) Load(csvFile io.Reader) error {
startT := time.Now()
defer func() { log.Info("Graph.Load", time.Since(startT)) }()
csvReader := csv.NewReader(csvFile)
csvReader.TrailingComma = true
for {
fields, err := csvReader.Read()
if err == io.EOF {
break
}
if err != nil {
log.Error(err)
continue
}
if len(fields) != 3 {
log.Error("Nothing there ", fields)
continue
}
if fields[0] == SPEMPTY || fields[1] == SPEMPTY {
log.Error("Invalid line ", fields)
continue
}
g.Add(fields[0], fields[1], fields[2])
}
return nil
}
示例3: HandleSaveAndEnqueueGroup
func (client *Client) HandleSaveAndEnqueueGroup(sae *SAEMessage) {
if sae.msg == nil {
log.Error("sae msg is nil")
return
}
if sae.msg.cmd != MSG_GROUP_IM {
log.Error("sae msg cmd:", sae.msg.cmd)
return
}
appid := sae.appid
gid := sae.receiver
//保證群組消息以id遞增的順序發出去
t := make(chan int64)
f := func() {
msgid := storage.SaveGroupMessage(appid, gid, sae.device_id, sae.msg)
s := FindGroupClientSet(appid, gid)
for c := range s {
log.Info("publish group message")
am := &AppMessage{appid: appid, receiver: gid, msgid: msgid, device_id: sae.device_id, msg: sae.msg}
m := &Message{cmd: MSG_PUBLISH_GROUP, body: am}
c.wt <- m
}
if len(s) == 0 {
log.Infof("can't publish group message:%d", gid)
}
t <- msgid
}
c := GetGroupChan(gid)
c <- f
msgid := <-t
result := &MessageResult{}
result.status = 0
buffer := new(bytes.Buffer)
binary.Write(buffer, binary.BigEndian, msgid)
result.content = buffer.Bytes()
msg := &Message{cmd: MSG_RESULT, body: result}
SendMessage(client.conn, msg)
group := group_manager.FindGroup(gid)
if group != nil {
members := group.Members()
off_members := make([]int64, 0)
im := sae.msg.body.(*IMMessage)
for uid, _ := range members {
if !IsGroupUserOnline(appid, gid, uid) {
off_members = append(off_members, uid)
}
}
if len(off_members) > 0 {
client.PublishGroupMessage(appid, off_members, im)
}
}
}
示例4: waitInitReady
func waitInitReady(ctx *VmContext) {
conn, err := utils.UnixSocketConnect(ctx.HyperSockName)
if err != nil {
glog.Error("Cannot connect to hyper socket ", err.Error())
ctx.Hub <- &InitFailedEvent{
Reason: "Cannot connect to hyper socket " + err.Error(),
}
return
}
glog.Info("Wating for init messages...")
msg, err := ReadVmMessage(conn.(*net.UnixConn))
if err != nil {
glog.Error("read init message failed... ", err.Error())
ctx.Hub <- &InitFailedEvent{
Reason: "read init message failed... " + err.Error(),
}
conn.Close()
} else if msg.Code == INIT_READY {
glog.Info("Get init ready message")
ctx.Hub <- &InitConnectedEvent{conn: conn.(*net.UnixConn)}
go waitCmdToInit(ctx, conn.(*net.UnixConn))
} else {
glog.Warningf("Get init message %d", msg.Code)
ctx.Hub <- &InitFailedEvent{
Reason: fmt.Sprintf("Get init message %d", msg.Code),
}
conn.Close()
}
}
示例5: deleteAll
func deleteAll(fm kubeFramework, ns string, services []*kube_api.Service, rcs []*kube_api.ReplicationController) {
var err error
for _, rc := range rcs {
if err = fm.DeleteRC(ns, rc); err != nil {
glog.Error(err)
}
}
for _, service := range services {
if err = fm.DeleteService(ns, service); err != nil {
glog.Error(err)
}
}
if err = removeDockerImage(*heapsterImage); err != nil {
glog.Error(err)
}
if err = removeDockerImage(*influxdbImage); err != nil {
glog.Error(err)
}
if err = removeDockerImage(*grafanaImage); err != nil {
glog.Error(err)
}
var nodes []string
if nodes, err = fm.GetNodes(); err == nil {
for _, node := range nodes {
cleanupRemoteHost(node)
}
} else {
glog.Errorf("failed to cleanup nodes - %v", err)
}
}
示例6: syncNetworkStatus
// syncNetworkStatus updates the network state, ensuring that the network is
// configured correctly if the kubelet is set to configure cbr0:
// * handshake flannel helper if the flannel experimental overlay is being used.
// * ensure that iptables masq rules are setup
// * reconcile cbr0 with the pod CIDR
func (kl *Kubelet) syncNetworkStatus() {
var err error
if kl.configureCBR0 {
if kl.flannelExperimentalOverlay {
podCIDR, err := kl.flannelHelper.Handshake()
if err != nil {
glog.Infof("Flannel server handshake failed %v", err)
return
}
kl.updatePodCIDR(podCIDR)
}
if err := ensureIPTablesMasqRule(kl.iptClient, kl.nonMasqueradeCIDR); err != nil {
err = fmt.Errorf("Error on adding ip table rules: %v", err)
glog.Error(err)
kl.runtimeState.setNetworkState(err)
return
}
podCIDR := kl.runtimeState.podCIDR()
if len(podCIDR) == 0 {
err = fmt.Errorf("ConfigureCBR0 requested, but PodCIDR not set. Will not configure CBR0 right now")
glog.Warning(err)
} else if err = kl.reconcileCBR0(podCIDR); err != nil {
err = fmt.Errorf("Error configuring cbr0: %v", err)
glog.Error(err)
}
if err != nil {
kl.runtimeState.setNetworkState(err)
return
}
}
kl.runtimeState.setNetworkState(kl.networkPlugin.Status())
}
示例7: procClientID
func (self *ProtoProc) procClientID(cmd protocol.Cmd, session *libnet.Session) error {
glog.Info("procClientID")
var err error
ID := cmd.GetArgs()[0]
sessionStoreData := storage.NewSessionStoreData(cmd.GetArgs()[0], session.Conn().RemoteAddr().String(),
self.msgServer.cfg.LocalIP, strconv.FormatUint(session.Id(), 10))
glog.Info(sessionStoreData)
args := make([]string, 0)
args = append(args, cmd.GetArgs()[0])
CCmd := protocol.NewCmdInternal(protocol.STORE_SESSION_CMD, args, sessionStoreData)
glog.Info(CCmd)
if self.msgServer.channels[protocol.SYSCTRL_CLIENT_STATUS] != nil {
_, err = self.msgServer.channels[protocol.SYSCTRL_CLIENT_STATUS].Channel.Broadcast(libnet.Json(CCmd))
if err != nil {
glog.Error(err.Error())
return err
}
}
self.msgServer.sessions[cmd.GetArgs()[0]] = session
self.msgServer.sessions[cmd.GetArgs()[0]].State = base.NewSessionState(true, cmd.GetArgs()[0])
err = self.procOfflineMsg(session, ID)
if err != nil {
glog.Error(err.Error())
return err
}
return nil
}
示例8: RemoveNic
func (lc *LibvirtContext) RemoveNic(ctx *hypervisor.VmContext, n *hypervisor.InterfaceCreated, callback hypervisor.VmEvent) {
if lc.domain == nil {
glog.Error("Cannot find domain")
ctx.Hub <- &hypervisor.DeviceFailed{
Session: nil,
}
return
}
nicXml, err := nicXml(n.Bridge, n.HostDevice, n.MacAddr, n.PCIAddr, ctx.Boot)
if err != nil {
glog.Error("generate detach-nic-xml failed, ", err.Error())
ctx.Hub <- &hypervisor.DeviceFailed{
Session: callback,
}
return
}
err = lc.domain.DetachDeviceFlags(nicXml, libvirtgo.VIR_DOMAIN_DEVICE_MODIFY_LIVE)
if err != nil {
glog.Error("detach nic failed, ", err.Error())
ctx.Hub <- &hypervisor.DeviceFailed{
Session: callback,
}
return
}
ctx.Hub <- callback
}
示例9: Launch
func (lc *LibvirtContext) Launch(ctx *hypervisor.VmContext) {
domainXml, err := lc.domainXml(ctx)
if err != nil {
glog.Error("Fail to get domain xml configuration:", err)
ctx.Hub <- &hypervisor.VmStartFailEvent{Message: err.Error()}
return
}
glog.V(3).Infof("domainXML: %v", domainXml)
var domain libvirtgo.VirDomain
if ctx.Boot.BootFromTemplate {
domain, err = lc.driver.conn.DomainCreateXML(domainXml, libvirtgo.VIR_DOMAIN_START_PAUSED)
} else {
domain, err = lc.driver.conn.DomainCreateXML(domainXml, libvirtgo.VIR_DOMAIN_NONE)
}
if err != nil {
glog.Error("Fail to launch domain ", err)
ctx.Hub <- &hypervisor.VmStartFailEvent{Message: err.Error()}
return
}
lc.domain = &domain
err = lc.domain.SetMemoryStatsPeriod(1, 0)
if err != nil {
glog.Errorf("SetMemoryStatsPeriod failed for domain %v", ctx.Id)
}
}
示例10: StoragePageData
func StoragePageData(path string, cfg conf.Config) error {
rh := NewReqHttp(path, "GET", cfg.Spider.CrawlTimeout)
rh.AddHeader("User-agent", USER_AGENT)
httpRes, err := rh.DoGetData()
if err != nil {
glog.Error(err.Error())
return err
}
body, err := ioutil.ReadAll(httpRes.Body)
if err != nil {
glog.Error(err.Error())
return err
}
encodeStr := base64.StdEncoding.EncodeToString([]byte(path))
fout, err := os.Create(cfg.Spider.OutputDirectory + "/" + encodeStr)
defer fout.Close()
if err != nil {
glog.Error(err.Error())
return err
}
fout.Write(body)
return nil
}
示例11: AddNic
func (lc *LibvirtContext) AddNic(ctx *hypervisor.VmContext, host *hypervisor.HostNicInfo, guest *hypervisor.GuestNicInfo, result chan<- hypervisor.VmEvent) {
if lc.domain == nil {
glog.Error("Cannot find domain")
result <- &hypervisor.DeviceFailed{
Session: nil,
}
return
}
nicXml, err := nicXml(host.Bridge, host.Device, host.Mac, guest.Busaddr, ctx.Boot)
if err != nil {
glog.Error("generate attach-nic-xml failed, ", err.Error())
result <- &hypervisor.DeviceFailed{
Session: nil,
}
return
}
glog.V(3).Infof("nicxml: %s", nicXml)
err = lc.domain.AttachDeviceFlags(nicXml, libvirtgo.VIR_DOMAIN_DEVICE_MODIFY_LIVE)
if err != nil {
glog.Error("attach nic failed, ", err.Error())
result <- &hypervisor.DeviceFailed{
Session: nil,
}
return
}
result <- &hypervisor.NetDevInsertedEvent{
Index: guest.Index,
DeviceName: guest.Device,
Address: guest.Busaddr,
}
}
示例12: inflate
// inflate decodes and decompresses the data generated by codegen
func inflate(data string) (string, error) {
t := trackTime("inflate")
defer t.finish()
// fix some url-safeness that codegen does...
var fixed string
fixed = strings.Replace(data, "-", "+", -1)
fixed = strings.Replace(fixed, "_", "/", -1)
decoded, err := base64.StdEncoding.DecodeString(fixed)
if err != nil {
glog.Error(err)
return "", err
}
r, err := zlib.NewReader(bytes.NewReader(decoded))
if err != nil {
glog.Error(err)
return "", err
}
defer r.Close()
var buf bytes.Buffer
buf.ReadFrom(r)
inflated := buf.String()
return inflated, nil
}
示例13: run
func (c *channel) run() {
head := &EventHeader{Id: uuid.NewV4().String(), Version: PROTOCAL_VERSION}
req := &ServerResponse{head, "_zpc_hb", make([]interface{}, 0)}
o, err := req.MarshalMsg(nil)
if err != nil {
glog.Error(err)
return
}
for {
select {
case <-c.ticker.C:
c.codec.mutex.Lock()
glog.Error(o)
_, err = c.codec.zsock.SendMessageDontwait(c.identity, o)
if err != nil {
c.ticker.Stop()
c.codec = nil
c.counter = 0
glog.Error(err)
}
c.codec.mutex.Unlock()
return
case <-c.closed:
c.ticker.Stop()
c.codec = nil
c.ticker = nil
return
}
}
}
示例14: LoadOfflineMessage
func (storage *Storage) LoadOfflineMessage(appid int64, uid int64) []*EMessage {
log.Infof("load offline message appid:%d uid:%d\n", appid, uid)
c := make([]*EMessage, 0, 10)
start := fmt.Sprintf("%d_%d_1", appid, uid)
end := fmt.Sprintf("%d_%d_9223372036854775807", appid, uid)
r := &util.Range{Start: []byte(start), Limit: []byte(end)}
iter := storage.db.NewIterator(r, nil)
for iter.Next() {
value := iter.Value()
msgid, err := strconv.ParseInt(string(value), 10, 64)
if err != nil {
log.Error("parseint err:", err)
continue
}
log.Info("offline msgid:", msgid)
msg := storage.LoadMessage(msgid)
if msg == nil {
log.Error("can't load offline message:", msgid)
continue
}
c = append(c, &EMessage{msgid: msgid, msg: msg})
}
iter.Release()
err := iter.Error()
if err != nil {
log.Warning("iterator err:", err)
}
log.Info("offline count:", len(c))
return c
}
示例15: CreateVolume
func CreateVolume(poolName, volName, dev_id string, size int, restore bool) error {
glog.Infof("/dev/mapper/%s", volName)
if _, err := os.Stat("/dev/mapper/" + volName); err == nil {
return nil
}
if restore == false {
parms := fmt.Sprintf("dmsetup message /dev/mapper/%s 0 \"create_thin %s\"", poolName, dev_id)
if res, err := exec.Command("/bin/sh", "-c", parms).CombinedOutput(); err != nil {
glog.Error(string(res))
return fmt.Errorf(string(res))
}
}
parms := fmt.Sprintf("dmsetup create %s --table \"0 %d thin /dev/mapper/%s %s\"", volName, size/512, poolName, dev_id)
if res, err := exec.Command("/bin/sh", "-c", parms).CombinedOutput(); err != nil {
glog.Error(string(res))
return fmt.Errorf(string(res))
}
if restore == false {
parms = fmt.Sprintf("mkfs.ext4 \"/dev/mapper/%s\"", volName)
if res, err := exec.Command("/bin/sh", "-c", parms).CombinedOutput(); err != nil {
glog.Error(string(res))
return fmt.Errorf(string(res))
}
}
return nil
}