本文整理汇总了Golang中github.com/control-center/serviced/zzk.GetLocalConnection函数的典型用法代码示例。如果您正苦于以下问题:Golang GetLocalConnection函数的具体用法?Golang GetLocalConnection怎么用?Golang GetLocalConnection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetLocalConnection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RemoveService
func (zk *zkf) RemoveService(service *service.Service) error {
// acquire the service lock to prevent that service from being scheduled
// as it is being deleted
conn, err := zzk.GetLocalConnection(zzk.GeneratePoolPath(service.PoolID))
if err != nil {
return err
}
// remove the global list of all vhosts deployed
if rootconn, err := zzk.GetLocalConnection("/"); err != nil {
return err
} else if err := zkservice.RemoveServiceVhosts(rootconn, service); err != nil {
return err
}
// Ensure that the service's pool is locked for the duration
finish := make(chan interface{})
defer close(finish)
if err := zkservice.EnsureServiceLock(nil, finish, conn); err != nil {
return err
}
// FIXME: this may be a long-running operation, should we institute a timeout?
return zkservice.RemoveService(conn, service.ID)
}
示例2: getTestConn
func getTestConn(c *C, path string) client.Connection {
root, err := zzk.GetLocalConnection("/")
c.Assert(err, IsNil)
err = root.CreateDir(path)
c.Assert(err, IsNil)
conn, err := zzk.GetLocalConnection(path)
c.Assert(err, IsNil)
return conn
}
示例3: GetRunningServicesForHost
func (this *ControlPlaneDao) GetRunningServicesForHost(hostID string, services *[]dao.RunningService) error {
// we initialize the data container to something here in case it has not been initialized yet
*services = make([]dao.RunningService, 0)
myHost, err := this.facade.GetHost(datastore.Get(), hostID)
if err != nil {
glog.Errorf("Unable to get host %v: %v", hostID, err)
return err
} else if myHost == nil {
return nil
}
poolBasedConn, err := zzk.GetLocalConnection(zzk.GeneratePoolPath(myHost.PoolID))
if err != nil {
glog.Errorf("Error in getting a connection based on pool %v: %v", myHost.PoolID, err)
return err
}
*services, err = zkservice.LoadRunningServicesByHost(poolBasedConn, hostID)
if err != nil {
glog.Errorf("zkservice.LoadRunningServicesByHost (conn: %+v host: %v) failed: %v", poolBasedConn, hostID, err)
return err
}
return nil
}
示例4: GetRunningServices
func (this *ControlPlaneDao) GetRunningServices(request dao.EntityRequest, allRunningServices *[]dao.RunningService) error {
// we initialize the data container to something here in case it has not been initialized yet
*allRunningServices = make([]dao.RunningService, 0)
allPools, err := this.facade.GetResourcePools(datastore.Get())
if err != nil {
glog.Error("runningservice.go failed to get resource pool")
return err
} else if allPools == nil || len(allPools) == 0 {
return fmt.Errorf("no resource pools found")
}
for _, aPool := range allPools {
poolBasedConn, err := zzk.GetLocalConnection(zzk.GeneratePoolPath(aPool.ID))
if err != nil {
glog.Error("runningservice.go Failed to get connection based on pool: %v", aPool.ID)
return err
}
singlePoolRunningServices := []dao.RunningService{}
singlePoolRunningServices, err = zkservice.LoadRunningServices(poolBasedConn)
if err != nil {
glog.Errorf("Failed GetAllRunningServices: %v", err)
return err
}
for _, rs := range singlePoolRunningServices {
*allRunningServices = append(*allRunningServices, rs)
}
}
return nil
}
示例5: CheckRunningVHost
func (z *zkf) CheckRunningVHost(vhostName, serviceID string) error {
rootBasedConnection, err := zzk.GetLocalConnection("/")
if err != nil {
return err
}
vr, err := zkregistry.VHostRegistry(rootBasedConnection)
if err != nil {
glog.Errorf("Error getting vhost registry: %v", err)
return err
}
vhostEphemeralNodes, err := vr.GetVHostKeyChildren(rootBasedConnection, vhostName)
if err != nil {
glog.Errorf("GetVHostKeyChildren failed %v: %v", vhostName, err)
return err
}
if len(vhostEphemeralNodes) > 0 {
if vhost := vhostEphemeralNodes[0]; vhost.ServiceID != serviceID {
err := fmt.Errorf("virtual host %s is already running under service %s", vhostName, vhost.ServiceID)
return err
}
}
return nil
}
示例6: GetRunningService
func (this *ControlPlaneDao) GetRunningService(request dao.ServiceStateRequest, running *dao.RunningService) error {
glog.V(3).Infof("ControlPlaneDao.GetRunningService: request=%v", request)
*running = dao.RunningService{}
serviceID := request.ServiceID
poolID, err := this.facade.GetPoolForService(datastore.Get(), serviceID)
if err != nil {
glog.Errorf("Unable to get service %v: %v", serviceID, err)
return err
}
poolBasedConn, err := zzk.GetLocalConnection(zzk.GeneratePoolPath(poolID))
if err != nil {
glog.Errorf("Error in getting a connection based on pool %v: %v", poolID, err)
return err
}
if thisRunning, err := zkservice.LoadRunningService(poolBasedConn, request.ServiceID, request.ServiceStateID); err != nil {
glog.Errorf("zkservice.LoadRunningService failed (conn: %+v serviceID: %v): %v", poolBasedConn, request.ServiceID, err)
return err
} else {
if thisRunning != nil {
*running = *thisRunning
}
}
return nil
}
示例7: UpdateResourcePool
func (z *zkf) UpdateResourcePool(pool *pool.ResourcePool) error {
conn, err := zzk.GetLocalConnection("/")
if err != nil {
return err
}
return zkservice.UpdateResourcePool(conn, pool)
}
示例8: UpdateHost
func (z *zkf) UpdateHost(host *host.Host) error {
conn, err := zzk.GetLocalConnection(zzk.GeneratePoolPath(host.PoolID))
if err != nil {
return err
}
return zkhost.UpdateHost(conn, host)
}
示例9: IsLocked
func (dfs *DistributedFilesystem) IsLocked() (bool, error) {
conn, err := zzk.GetLocalConnection("/")
if err != nil {
return false, err
}
return zkservice.IsServiceLocked(conn)
}
示例10: RemoveResourcePool
func (z *zkf) RemoveResourcePool(poolID string) error {
conn, err := zzk.GetLocalConnection("/")
if err != nil {
return err
}
return zkservice.RemoveResourcePool(conn, poolID)
}
示例11: RemoveVirtualIP
func (z *zkf) RemoveVirtualIP(virtualIP *pool.VirtualIP) error {
conn, err := zzk.GetLocalConnection(zzk.GeneratePoolPath(virtualIP.PoolID))
if err != nil {
return err
}
return zkvirtualip.RemoveVirtualIP(conn, virtualIP.IP)
}
示例12: GetRunningServicesForService
func (this *ControlPlaneDao) GetRunningServicesForService(serviceID string, services *[]dao.RunningService) error {
// we initialize the data container to something here in case it has not been initialized yet
*services = make([]dao.RunningService, 0)
poolID, err := this.facade.GetPoolForService(datastore.Get(), serviceID)
if err != nil {
glog.Errorf("Unable to get service %v: %v", serviceID, err)
return err
}
poolBasedConn, err := zzk.GetLocalConnection(zzk.GeneratePoolPath(poolID))
if err != nil {
glog.Errorf("Error in getting a connection based on pool %v: %v", poolID, err)
return err
}
svcs, err := zkservice.LoadRunningServicesByService(poolBasedConn, serviceID)
if err != nil {
glog.Errorf("LoadRunningServicesByService failed (conn: %+v serviceID: %v): %v", poolBasedConn, serviceID, err)
return err
}
for _, svc := range svcs {
*services = append(*services, svc)
}
return nil
}
示例13: StopServiceInstance
func (zk *zkf) StopServiceInstance(poolID, hostID, stateID string) error {
conn, err := zzk.GetLocalConnection(zzk.GeneratePoolPath(poolID))
if err != nil {
return err
}
return zkservice.StopServiceInstance(conn, hostID, stateID)
}
示例14: GetActiveHosts
func (z *zkf) GetActiveHosts(poolID string, hosts *[]string) error {
conn, err := zzk.GetLocalConnection(zzk.GeneratePoolPath(poolID))
if err != nil {
return err
}
*hosts, err = zkhost.GetActiveHosts(conn)
return err
}
示例15: UpdateService
func (zk *zkf) UpdateService(service *service.Service) error {
conn, err := zzk.GetLocalConnection(zzk.GeneratePoolPath(service.PoolID))
if err != nil {
return err
}
if err := zkservice.UpdateService(conn, service); err != nil {
return err
}
rootconn, err := zzk.GetLocalConnection("/")
if err != nil {
return err
}
return zkservice.UpdateServiceVhosts(rootconn, service)
}