当前位置: 首页>>代码示例>>Golang>>正文


Golang lsplog.Vlogf函数代码示例

本文整理汇总了Golang中P1-f12/official/lsplog.Vlogf函数的典型用法代码示例。如果您正苦于以下问题:Golang Vlogf函数的具体用法?Golang Vlogf怎么用?Golang Vlogf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Vlogf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	lsplog.SetVerbose(3)
	lsplog.Vlogf(3, "[Request] Request has started")
	lsplog.Vlogf(3, "[Request] Args: %s", os.Args)
	port, _ := strconv.Atoi(os.Args[1])
	srv, _ = lsp12.NewLspServer(port, &lsp12.LspParams{5, 2000})
	clients = make(map[uint16]*client)
	workers = make(map[uint16]*worker)
	requestBuffer = abuf.NewBuf()
	workersAvailable = abuf.NewBuf()
	go networkHandler()

	//Scheduler
	for {
		workerConnId := workersAvailable.Remove().(uint16)
		req := requestBuffer.Remove().(*request)
		for clients[req.connId] == nil {
			req = requestBuffer.Remove().(*request)
		}
		freeWorker := workers[workerConnId]
		freeWorker.worksForClient = req.connId
		freeWorker.command = req.crackRequest
		srv.Write(workerConnId, []byte(req.crackRequest))
	}
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:25,代码来源:server.go

示例2: WaitServer

// Wait until server has signaled it is done
func (ts *SynchTestSystem) WaitServer() {
	lsplog.Vlogf(6, "Waiting for server\n")
	select {
	case d := <-ts.TChan:
		ts.Tester.Logf("Test reached time limit of %d waiting for server", d)
		ts.Tester.FailNow()
	case <-ts.S2MChan:
	}
	lsplog.Vlogf(6, "Got signal from server\n")
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:11,代码来源:lsp12_s_test.go

示例3: UDPResolve

func UDPResolve(hostport string) (*lspnet.UDPAddr, error) {
	lsplog.Vlogf(3, "Attempting to resolve address of %s", hostport)
	a, e := lspnet.ResolveUDPAddr(NET, hostport)
	if e != nil {
		lsplog.CheckFatal(e)
		return nil, e
	}
	lsplog.Vlogf(3, "Address %s resolved", hostport)
	return a, nil
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:10,代码来源:lsp12-common.go

示例4: lspListen

func (srv *LspServer) lspListen() error {
	lsplog.Vlogf(1, "[Server] Attempting to listen to port to %d", srv.udpAddr.Port)
	conn, e := lspnet.ListenUDP(NET, srv.udpAddr)
	if e != nil {
		lsplog.CheckFatal(e)
		return e
	}
	lsplog.Vlogf(1, "[Server] Listening to port %d", srv.udpAddr.Port)
	srv.udpConn = conn
	return nil
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:11,代码来源:lsp12-server.go

示例5: udpConnect

func (cli *LspClient) udpConnect() error {
	lsplog.Vlogf(1, "[Client] Attempting to connect to %s:%d", cli.udpAddr.IP, cli.udpAddr.Port)
	b, e := lspnet.DialUDP(NET, nil, cli.udpAddr)
	if e != nil {
		lsplog.CheckFatal(e)
		return e
	}
	lsplog.Vlogf(6, "[Client] Connected to %s:%d", cli.udpAddr.IP, cli.udpAddr.Port)
	cli.udpConn = b
	return nil
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:11,代码来源:lsp12-client.go

示例6: lspSend

func (srv *LspServer) lspSend(m *LspMessage, c *clientRepresenter) {
	if m == nil || c == nil {
		lsplog.Vlogf(6, "[Server] Got a send request for m: %+v c:%+v Ignoring message", m, c)
		return
	}
	marshalled, err := json.Marshal(m)
	if err != nil {
		lsplog.CheckFatal(err)
	}
	lsplog.Vlogf(6, "[Server] Marshalled message: %s", marshalled)
	srv.udpConn.WriteToUDP(marshalled, c.addr)
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:12,代码来源:lsp12-server.go

示例7: SynchNetwork

// Enable network & then Wait until it signals that it is done
func (ts *SynchTestSystem) SynchNetwork() {
	lsplog.Vlogf(6, "Enabling Network\n")
	ts.M2NChan <- true
	lsplog.Vlogf(6, "Waiting for network\n")
	select {
	case d := <-ts.TChan:
		ts.Tester.Logf("Test reached time limit of %d waiting for network", d)
		ts.Tester.FailNow()
	case <-ts.N2MChan:
	}
	lsplog.Vlogf(6, "Got signal from network\n")
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:13,代码来源:lsp12_s_test.go

示例8: WaitClients

// Wait until clients have that they're done
func (ts *SynchTestSystem) WaitClients() {
	lsplog.Vlogf(6, "Waiting for clients\n")
	for i := 0; i < ts.Nclients; i++ {
		select {
		case d := <-ts.TChan:
			ts.Tester.Logf("Test reached time limit of %d waiting for client", d)
			ts.Tester.FailNow()
		case <-ts.C2MChan:
		}
	}

	lsplog.Vlogf(6, "Got signals from all clients\n")
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:14,代码来源:lsp12_s_test.go

示例9: networkHandler

func (srv *LspServer) networkHandler() {
	lsplog.Vlogf(3, "[Server] Started the network handler")
	for { // Should loop only if the connection is still on.
		lsplog.Vlogf(6, "[Server] Going to read a packet")
		m, addr, err := srv.readPacket()
		if err != nil {
			lsplog.CheckReport(3, err)
			lsplog.Vlogf(6, "[Server] Ignoring this packet")
			continue
		}
		go srv.packetHandler(m, addr)
	}
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:13,代码来源:lsp12-server.go

示例10: Write

func (con *UDPConn) Write(b []byte) (int, error) {
	ncon := con.ncon
	if dropit(writeDropPercent) {
		lsplog.Vlogf(5, "UDP: DROPPING written packet of length %v\n", len(b))
		// Make it look like write was successful
		return len(b), nil
	} else {
		n, err := ncon.Write(b)
		lsplog.Vlogf(5, "UDP: Wrote packet of length %v\v", n)
		return n, err
	}
	return 0, nil
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:13,代码来源:lspnet.go

示例11: packetHandler

func (srv *LspServer) packetHandler(m *LspMessage, addr *lspnet.UDPAddr) {
	lsplog.Vlogf(6, "[Server] Packet reading has no problems.")
	if IsConnection(m) {
		lsplog.Vlogf(1, "[Server] A new connection request recieved.")
		srv.handleConnectionRequest(addr)
	} else if IsDataPacket(m) {
		lsplog.Vlogf(4, "[Server] A data packet is recieved.")
		client := srv.getClient(addr)
		if client != nil {
			<-client.finished
			client.epochCount = 0
			if m.ConnId == client.connId {
				if m.SeqNum == client.clientSeqNum {
					srv.read.Insert(&readRequest{m.ConnId, m.Payload})
					ack := CreateDataAck(m.ConnId, m.SeqNum)
					srv.lspSend(ack, client)
					client.lastAck = ack
					client.clientSeqNum = (client.clientSeqNum + 1) % math.MaxInt8
				} else {
					lsplog.Vlogf(5, "[Server] Recieved data packet has an unexpected sequence (Getting: %d) (Expected: %d)", m.SeqNum, client.clientSeqNum)
				}
			} else {
				lsplog.Vlogf(4, "[Server] Recieved data packet has a wrong connId (Getting: %d) (Expected: %d)", m.ConnId, client.connId)
			}
			client.finished <- 1
		}
	} else {
		lsplog.Vlogf(4, "[Server] An acknowledgment packet is recieved.")
		client := srv.getClient(addr)
		if client != nil {
			<-client.finished
			client.epochCount = 0
			if m.ConnId == client.connId { // Make sure that the connId is the same as the client.
				<-srv.sentLocker
				deletedElements := list.New() // Delete all the elements that has been acknowledged
				for e := srv.sent.Front(); e != nil; e = e.Next() {
					request := e.Value.(*sentRequest)
					if request.message.SeqNum <= m.SeqNum { // If a higher sequence is recieved, that means that all previous were acknowleged.
						deletedElements.PushBack(e)
					}
				}
				for e := deletedElements.Front(); e != nil; e = e.Next() {
					srv.sent.Remove(e.Value.(*list.Element))
					client.closable--
				}
				srv.sentLocker <- 1
				if client.closeConnection == true && client.closable == 0 {
					//Remove client from map
					key := client.addr.IP.String() + ":" + strconv.Itoa(client.addr.Port)
					srv.clients[key] = nil
				}
			} else {
				lsplog.Vlogf(4, "[Server] Recieved data packet has a wrong connId (Getting: %d) (Expected: %d)", m.ConnId, client.connId)
			}
			client.finished <- 1
		} else {
			lsplog.Vlogf(4, "[Server] Recieved an Acknowledgment packet from an unknown client.")
		}
	}
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:60,代码来源:lsp12-server.go

示例12: WriteToUDP

func (con *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (int, error) {
	ncon := con.ncon
	naddr := &net.UDPAddr{addr.IP, addr.Port}
	if dropit(writeDropPercent) {
		lsplog.Vlogf(5, "UDP: DROPPING written packet of length %v\n", len(b))
		// Make it look like write was successful
		return len(b), nil
	} else {
		n, err := ncon.WriteToUDP(b, naddr)
		lsplog.Vlogf(5, "UDP: Wrote packet of length %v", n)
		return n, err
	}
	return 0, nil
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:14,代码来源:lspnet.go

示例13: runtest

func (ts *TestSystem) runtest(timeoutms int) {
	lspnet.SetWriteDropPercent(ts.DropPercent)
	if ts.Description != "" {
		fmt.Printf("Testing: %s\n", ts.Description)
	}
	go ts.runserver()
	for i := 0; i < ts.NClients; i++ {
		go ts.runclient(i)
	}
	go ts.runtimeout(timeoutms)
	for i := 0; i < ts.NClients; i++ {
		v := <-ts.CChan
		if v < 0 {
			ts.RunFlag = false
			ts.Tester.Logf("Test timed out after %f secs\n",
				float64(timeoutms)/1000.0)
			ts.Tester.FailNow()
		}
	}
	ts.RunFlag = false
	lsplog.Vlogf(0, "Passed: %d clients, %d messages/client, %.2f maxsleep, %.2f drop rate\n",
		ts.NClients, ts.NMessages,
		float64(ts.MaxSleepMilliseconds)/1000.0,
		float64(ts.DropPercent)/100.0)
	lsplog.SetVerbose(DefaultVerbosity)
	lspnet.SetWriteDropPercent(0)
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:27,代码来源:lsp12_test.go

示例14: runclient

// Have client generate n messages and check that they are echoed.
func (ts *TestSystem) runclient(clienti int) {
	if clienti > ts.NClients {
		ts.Tester.Logf("Invalid client number %d\n", clienti)
		ts.Tester.FailNow()
	}
	cli := ts.Clients[clienti]
	for i := 0; i < ts.NMessages && ts.RunFlag; i++ {
		wt := ts.Rgen.Intn(100)
		werr := cli.Write(i2b(i + wt))
		if werr != nil {
			ts.Tester.Logf("Client write got error '%s'\n",
				werr.Error())
			ts.RunFlag = false
			ts.Tester.FailNow()
		}

		b, rerr := cli.Read()
		if rerr != nil {
			ts.Tester.Logf("Client read got error '%s'\n",
				rerr.Error())
			ts.RunFlag = false
			ts.Tester.FailNow()
		}
		v := b2i(b)
		if v != wt+i {
			ts.Tester.Logf("Client got %d.  Expected %d\n",
				v, i+wt)
			ts.RunFlag = false
			ts.Tester.FailNow()
		}
	}
	cli.Close()
	lsplog.Vlogf(0, "Client #%d completed %d messages\n", clienti, ts.NMessages)
	ts.CChan <- 0
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:36,代码来源:lsp12_test.go

示例15: stopNetwork

// Shutting down network communications
func (cli *LspClient) stopNetwork() {
	cli.lspConn.stopNetworkFlag = true
	err := cli.udpConn.Close()
	if lsplog.CheckReport(4, err) {
		lsplog.Vlogf(6, "Client Continuing\n")
	}
}
开发者ID:ammarar,项目名称:DS-P1,代码行数:8,代码来源:lsp12-client.go


注:本文中的P1-f12/official/lsplog.Vlogf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。