Returns a SimplePool for given instanceId, or an error if it does not exist. TODO(zviad): right now this scans all instances, thus if there are a lot of instances per partition it can become very slow. If it becomes a problem, fix it!
(instanceId int)
| 427 | // TODO(zviad): right now this scans all instances, thus if there are a lot of |
| 428 | // instances per partition it can become very slow. If it becomes a problem, fix it! |
| 429 | func (pool *LoadBalancedPool) GetInstancePool(instanceId int) (*SimplePool, error) { |
| 430 | pool.lock.RLock() |
| 431 | defer pool.lock.RUnlock() |
| 432 | for _, instancePool := range pool.instanceList { |
| 433 | if instancePool.instanceId == instanceId { |
| 434 | return &instancePool.SimplePool, nil |
| 435 | } |
| 436 | } |
| 437 | return nil, errors.Newf("InstanceId: %v not found in the pool", instanceId) |
| 438 | } |
| 439 | |
| 440 | // Marks instance down till downUntil epoch in seconds. |
| 441 | func (pool *LoadBalancedPool) markInstanceDown( |