Ejemplo n.º 1
0
package etcd

import (
	"time"

	"github.com/cloudfoundry-incubator/auctioneer"
	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/cloudfoundry/gunk/workpool"
	"github.com/pivotal-golang/lager"
)

const (
	convergeTaskRunsCounter = metric.Counter("ConvergenceTaskRuns")
	convergeTaskDuration    = metric.Duration("ConvergenceTaskDuration")

	tasksKickedCounter = metric.Counter("ConvergenceTasksKicked")
	tasksPrunedCounter = metric.Counter("ConvergenceTasksPruned")

	pendingTasks   = metric.Metric("TasksPending")
	runningTasks   = metric.Metric("TasksRunning")
	completedTasks = metric.Metric("TasksCompleted")
	resolvingTasks = metric.Metric("TasksResolving")
)

type compareAndSwappableTask struct {
	OldIndex uint64
	NewTask  *models.Task
}

func (db *ETCDDB) ConvergeTasks(
Ejemplo n.º 2
0
package auctioneer

import "github.com/cloudfoundry-incubator/runtime-schema/metric"

const (
	LRPAuctionsStarted  = metric.Counter("AuctioneerLRPAuctionsStarted")
	LRPAuctionsFailed   = metric.Counter("AuctioneerLRPAuctionsFailed")
	TaskAuctionsStarted = metric.Counter("AuctioneerTaskAuctionsStarted")
	TaskAuctionsFailed  = metric.Counter("AuctioneerTaskAuctionsFailed")
	FetchStatesDuration = metric.Duration("AuctioneerFetchStatesDuration")
)
Ejemplo n.º 3
0
	"github.com/cloudfoundry-incubator/garden"
	GardenClient "github.com/cloudfoundry-incubator/garden/client"
	GardenConnection "github.com/cloudfoundry-incubator/garden/client/connection"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/pivotal-golang/archiver/compressor"
	"github.com/pivotal-golang/archiver/extractor"
	"github.com/pivotal-golang/clock"
	"github.com/pivotal-golang/lager"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/grouper"
)

const (
	PingGardenInterval             = time.Second
	StalledMetricHeartbeatInterval = 5 * time.Second
	stalledDuration                = metric.Duration("StalledGardenDuration")
	maxConcurrentUploads           = 5
	metricsReportInterval          = 1 * time.Minute
	containerMetricsReportInterval = 30 * time.Second
)

type executorContainers struct {
	gardenClient garden.Client
	owner        string
}

func (containers *executorContainers) Containers() ([]garden.Container, error) {
	return containers.gardenClient.Containers(garden.Properties{
		gardenstore.ContainerOwnerProperty: containers.owner,
	})
}
Ejemplo n.º 4
0
package harmonizer

import (
	"os"
	"time"

	"github.com/cloudfoundry-incubator/rep/evacuation/evacuation_context"
	"github.com/cloudfoundry-incubator/rep/generator"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/pivotal-golang/clock"
	"github.com/pivotal-golang/lager"
	"github.com/pivotal-golang/operationq"
)

const repBulkSyncDuration = metric.Duration("RepBulkSyncDuration")

type Bulker struct {
	logger lager.Logger

	pollInterval           time.Duration
	evacuationPollInterval time.Duration
	evacuationNotifier     evacuation_context.EvacuationNotifier
	clock                  clock.Clock
	generator              generator.Generator
	queue                  operationq.Queue
}

func NewBulker(
	logger lager.Logger,
	pollInterval time.Duration,
	evacuationPollInterval time.Duration,
Ejemplo n.º 5
0
	"net/http"
	"time"

	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/runtime-schema/cc_messages"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/cloudfoundry-incubator/stager/backend"
	"github.com/cloudfoundry-incubator/stager/cc_client"
	"github.com/pivotal-golang/clock"
	"github.com/pivotal-golang/lager"
)

const (
	// Metrics
	stagingSuccessCounter  = metric.Counter("StagingRequestsSucceeded")
	stagingSuccessDuration = metric.Duration("StagingRequestSucceededDuration")
	stagingFailureCounter  = metric.Counter("StagingRequestsFailed")
	stagingFailureDuration = metric.Duration("StagingRequestFailedDuration")
)

type CompletionHandler interface {
	StagingComplete(resp http.ResponseWriter, req *http.Request)
}

type completionHandler struct {
	ccClient cc_client.CcClient
	backends map[string]backend.Backend
	logger   lager.Logger
	clock    clock.Clock
}
Ejemplo n.º 6
0
	"sync"
	"sync/atomic"
	"time"

	"github.com/cloudfoundry-incubator/auctioneer"
	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry/gunk/workpool"

	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/pivotal-golang/clock"
	"github.com/pivotal-golang/lager"
)

const (
	convergeLRPRunsCounter = metric.Counter("ConvergenceLRPRuns")
	convergeLRPDuration    = metric.Duration("ConvergenceLRPDuration")

	malformedSchedulingInfosMetric = metric.Counter("ConvergenceLRPPreProcessingMalformedSchedulingInfos")
	malformedRunInfosMetric        = metric.Counter("ConvergenceLRPPreProcessingMalformedRunInfos")
	actualLRPsDeleted              = metric.Counter("ConvergenceLRPPreProcessingActualLRPsDeleted")
	orphanedRunInfosMetric         = metric.Counter("ConvergenceLRPPreProcessingOrphanedRunInfos")

	domainMetricPrefix = "Domain."

	desiredLRPs   = metric.Metric("LRPsDesired")
	claimedLRPs   = metric.Metric("LRPsClaimed")
	unclaimedLRPs = metric.Metric("LRPsUnclaimed")
	runningLRPs   = metric.Metric("LRPsRunning")

	missingLRPs = metric.Metric("LRPsMissing")
	extraLRPs   = metric.Metric("LRPsExtra")
Ejemplo n.º 7
0
package metrics

import (
	"os"
	"time"

	"github.com/cloudfoundry-incubator/bbs/db/etcd"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/pivotal-golang/clock"
	"github.com/pivotal-golang/lager"
)

const (
	metricsReportingDuration = metric.Duration("MetricsReportingDuration")

	bbsMasterElected = metric.Counter("BBSMasterElected")
)

type PeriodicMetronNotifier struct {
	Interval    time.Duration
	ETCDOptions *etcd.ETCDOptions
	Logger      lager.Logger
	Clock       clock.Clock
}

func NewPeriodicMetronNotifier(logger lager.Logger,
	interval time.Duration,
	etcdOptions *etcd.ETCDOptions,
	clock clock.Clock,
) *PeriodicMetronNotifier {
	return &PeriodicMetronNotifier{
Ejemplo n.º 8
0
	"fmt"
	"os"
	"sort"
	"time"

	"github.com/cloudfoundry-incubator/bbs/db"
	"github.com/cloudfoundry-incubator/bbs/db/etcd"
	"github.com/cloudfoundry-incubator/bbs/encryption"
	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/pivotal-golang/clock"
	"github.com/pivotal-golang/lager"
)

const (
	migrationDuration = metric.Duration("MigrationDuration")
)

type Manager struct {
	logger         lager.Logger
	db             db.DB
	cryptor        encryption.Cryptor
	storeClient    etcd.StoreClient
	migrations     []Migration
	migrationsDone chan<- struct{}
	clock          clock.Clock
}

func NewManager(
	logger lager.Logger,
	db db.DB,
Ejemplo n.º 9
0
	"github.com/cloudfoundry-incubator/bbs"
	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/cf_http"
	"github.com/cloudfoundry-incubator/nsync/helpers"
	"github.com/cloudfoundry-incubator/nsync/recipebuilder"
	"github.com/cloudfoundry-incubator/routing-info/cfroutes"
	"github.com/cloudfoundry-incubator/runtime-schema/cc_messages"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/cloudfoundry/gunk/workpool"
	"github.com/pivotal-golang/clock"
	"github.com/pivotal-golang/lager"
)

const (
	syncDesiredLRPsDuration = metric.Duration("DesiredLRPSyncDuration")
	invalidLRPsFound        = metric.Metric("NsyncInvalidDesiredLRPsFound")
)

type Processor struct {
	bbsClient             bbs.Client
	pollingInterval       time.Duration
	domainTTL             time.Duration
	bulkBatchSize         uint
	updateLRPWorkPoolSize int
	skipCertVerify        bool
	logger                lager.Logger
	fetcher               Fetcher
	builders              map[string]recipebuilder.RecipeBuilder
	clock                 clock.Clock
}
Ejemplo n.º 10
0
package encryptor

import (
	"errors"
	"os"

	"github.com/cloudfoundry-incubator/bbs/db"
	"github.com/cloudfoundry-incubator/bbs/encryption"
	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/pivotal-golang/clock"
	"github.com/pivotal-golang/lager"
)

const (
	encryptionDuration = metric.Duration("EncryptionDuration")
)

type Encryptor struct {
	logger     lager.Logger
	db         db.EncryptionDB
	keyManager encryption.KeyManager
	cryptor    encryption.Cryptor
	clock      clock.Clock
}

func New(
	logger lager.Logger,
	db db.EncryptionDB,
	keyManager encryption.KeyManager,
	cryptor encryption.Cryptor,
Ejemplo n.º 11
0
import (
	"io"
	"sync"
	"time"

	"github.com/cloudfoundry-incubator/executor"
	"github.com/cloudfoundry-incubator/executor/depot/event"
	"github.com/cloudfoundry-incubator/executor/depot/keyed_lock"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/cloudfoundry/gunk/workpool"
	"github.com/pivotal-golang/lager"
)

const ContainerInitializationFailedMessage = "failed to initialize container"
const ContainerStoppedBeforeRunMessage = "Container stopped by user"
const GardenContainerCreationDuration = metric.Duration("GardenContainerCreationDuration")

type client struct {
	*clientProvider
	logger lager.Logger
}

type clientProvider struct {
	totalCapacity        executor.ExecutorResources
	gardenStore          GardenStore
	allocationStore      AllocationStore
	eventHub             event.Hub
	containerLockManager keyed_lock.LockManager
	resourcesLock        *sync.Mutex
	creationWorkPool     *workpool.WorkPool
	deletionWorkPool     *workpool.WorkPool
Ejemplo n.º 12
0
package handlers

import (
	"net/http"
	"time"

	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/pivotal-golang/lager"
)

const (
	requestLatency = metric.Duration("RequestLatency")
	requestCount   = metric.Counter("RequestCount")
)

func LogWrap(logger lager.Logger, handler http.Handler) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		requestLog := logger.Session("request", lager.Data{
			"method":  r.Method,
			"request": r.URL.String(),
		})

		requestLog.Info("serving")
		handler.ServeHTTP(w, r)
		requestLog.Info("done")
	}
}

func UnavailableWrap(handler http.Handler, serviceReady <-chan struct{}) http.HandlerFunc {
	handler = NewUnavailableHandler(handler, serviceReady)
Ejemplo n.º 13
0
	"github.com/cloudfoundry-incubator/bbs/events"
	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/route-emitter/nats_emitter"
	"github.com/cloudfoundry-incubator/route-emitter/routing_table"
	"github.com/cloudfoundry-incubator/route-emitter/syncer"
	"github.com/cloudfoundry-incubator/routing-info/cfroutes"
	"github.com/cloudfoundry-incubator/runtime-schema/metric"
	"github.com/pivotal-golang/clock"
	"github.com/pivotal-golang/lager"
)

var (
	routesTotal  = metric.Metric("RoutesTotal")
	routesSynced = metric.Counter("RoutesSynced")

	routeSyncDuration = metric.Duration("RouteEmitterSyncDuration")

	routesRegistered   = metric.Counter("RoutesRegistered")
	routesUnregistered = metric.Counter("RoutesUnregistered")
)

type Watcher struct {
	bbsClient  bbs.Client
	clock      clock.Clock
	table      routing_table.RoutingTable
	emitter    nats_emitter.NATSEmitter
	syncEvents syncer.Events
	logger     lager.Logger
}

type syncEndEvent struct {