<commit_before>package driver

import (
	"encoding/json"
	"fmt"
	"net"
	"net/http"
	"time"

	common "github.com/noironetworks/cilium-net/common"
	cnc "github.com/noironetworks/cilium-net/common/client"
	"github.com/noironetworks/cilium-net/common/plugins"
	"github.com/noironetworks/cilium-net/common/types"

	"github.com/codegangsta/cli"
	"github.com/docker/libnetwork/drivers/remote/api"
	lnTypes "github.com/docker/libnetwork/types"
	"github.com/gorilla/mux"
	l "github.com/op/go-logging"
	"github.com/vishvananda/netlink"
)

var log = l.MustGetLogger("cilium-net-client")

const (
	// ContainerInterfacePrefix is the container's internal interface name prefix.
	ContainerInterfacePrefix = "cilium"
)

// Driver interface that listens for docker requests.
type Driver interface {
	Listen(string) error
}

type driver struct {
	client      *cnc.Client
	nodeAddress net.IP
}

// NewDriver creates and returns a new Driver for the given ctx.
func NewDriver(ctx *cli.Context) (Driver, error) {
	var nodeAddress string
	c, err := cnc.NewDefaultClient()
	if err != nil {
		log.Fatalf("Error while starting cilium-client: %s", err)
	}

	for tries := 10; tries > 0; tries-- {
		if res, err := c.Ping(); err != nil {
			if tries == 1 {
				log.Fatalf("Unable to reach cilium daemon: %s", err)
			} else {
				log.Warningf("Waiting for cilium daemon to come up...")
			}
			time.Sleep(time.Second)
		} else {
			nodeAddress = res.NodeAddress
			log.Infof("Received node address from daemon: %s", nodeAddress)
			break
		}
	}

	d := &driver{
		client:      c,
		nodeAddress: net.ParseIP(nodeAddress),
	}

	log.Infof("New Cilium networking instance on node %s", nodeAddress)

	return d, nil
}

// Listen listens for docker requests on a particular set of endpoints on the given<commit_msg>Increased cilium-docker connection timeout with daemon<commit_after>package driver

import (
	"encoding/json"
	"fmt"
	"net"
	"net/http"
	"time"

	common "github.com/noironetworks/cilium-net/common"
	cnc "github.com/noironetworks/cilium-net/common/client"
	"github.com/noironetworks/cilium-net/common/plugins"
	"github.com/noironetworks/cilium-net/common/types"

	"github.com/codegangsta/cli"
	"github.com/docker/libnetwork/drivers/remote/api"
	lnTypes "github.com/docker/libnetwork/types"
	"github.com/gorilla/mux"
	l "github.com/op/go-logging"
	"github.com/vishvananda/netlink"
)

var log = l.MustGetLogger("cilium-net-client")

const (
	// ContainerInterfacePrefix is the container's internal interface name prefix.
	ContainerInterfacePrefix = "cilium"
)

// Driver interface that listens for docker requests.
type Driver interface {
	Listen(string) error
}

type driver struct {
	client      *cnc.Client
	nodeAddress net.IP
}

// NewDriver creates and returns a new Driver for the given ctx.
func NewDriver(ctx *cli.Context) (Driver, error) {
	var nodeAddress string
	c, err := cnc.NewDefaultClient()
	if err != nil {
		log.Fatalf("Error while starting cilium-client: %s", err)
	}

	for tries := 0; tries < 10; tries++ {
		if res, err := c.Ping(); err != nil {
			if tries == 9 {
				log.Fatalf("Unable to reach cilium daemon: %s", err)
			} else {
				log.Warningf("Waiting for cilium daemon to come up...")
			}
			time.Sleep(time.Duration(tries) * time.Second)
		} else {
			nodeAddress = res.NodeAddress
			log.Infof("Received node address from daemon: %s", nodeAddress)
			break
		}
	}

	d := &driver{
		client:      c,
		nodeAddress: net.ParseIP(nodeAddress),
	}

	log.Infof("New Cilium networking instance on node %s", nodeAddress)

	return d, nil
}

// Listen listens for docker requests on a particular set of endpoints on the given
{'fraction_non_alphanumeric': 0.12444812362030905, 'fraction_numerical': 0.002207505518763797, 'mean_word_length': 3.820478723404255, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4924011', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1253, 'n_words': 323}