diff --git a/dax/controller/balancer/balancer.go b/dax/controller/balancer/balancer.go index e01fa7bc4..d6f08cc1f 100644 --- a/dax/controller/balancer/balancer.go +++ b/dax/controller/balancer/balancer.go @@ -640,8 +640,6 @@ func (b *Balancer) WorkersForTable(tx dax.Transaction, roleType dax.RoleType, qt } func (b *Balancer) WorkerCount(tx dax.Transaction, qdbid dax.QualifiedDatabaseID) (int, error) { - // print the database id - // fmt.Println(qdbid) return b.current.WorkerCount(tx, "", qdbid) } diff --git a/dax/controller/client/client.go b/dax/controller/client/client.go index e88fe3943..e7149c61e 100644 --- a/dax/controller/client/client.go +++ b/dax/controller/client/client.go @@ -703,28 +703,24 @@ func (c *Client) SnapshotTable(ctx context.Context, qtid dax.QualifiedTableID) e } func (c *Client) GetDatabaseNumberOfWorkers(ctx context.Context, orgID string, databaseID string) (int, error) { - // baseEndpoint := c.address.WithScheme(defaultScheme) - baseEndpoint := "http://localhost:8080/controller" + baseEndpoint := c.address.WithScheme(defaultScheme) url := fmt.Sprintf("%s/database-number-of-workers/%s/%s", baseEndpoint, orgID, databaseID) - // print something - //fmt.Println("GetDatabaseNumberOfWorkers url: %s", url) - c.logger.Debugf("GetDatabaseNumberOfWorkers url: %s", url) resp, err := c.httpClient.Get(url) if err != nil { - return -3, errors.Wrap(err, "getting database-number-of-workers") + return -1, errors.Wrap(err, "getting database-number-of-workers") } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { b, _ := io.ReadAll(resp.Body) - return -4, errors.Errorf("status code: %d: %s", resp.StatusCode, b) + return -1, errors.Errorf("status code: %d: %s", resp.StatusCode, b) } var workers int if err := json.NewDecoder(resp.Body).Decode(&workers); err != nil { - return -5, errors.Wrap(err, "reading response body") + return -1, errors.Wrap(err, "reading response body") } return workers, nil diff --git a/dax/controller/controller.go b/dax/controller/controller.go index f90fcd4c2..d8589f003 100644 --- a/dax/controller/controller.go +++ b/dax/controller/controller.go @@ -787,8 +787,6 @@ func (c *Controller) Databases(ctx context.Context, orgID dax.OrganizationID, id // get the list of workers being used by a database func (c *Controller) GetDatabaseNumberOfWorkers(ctx context.Context, qdbid dax.QualifiedDatabaseID) (int, error) { - // print the id of the database - // c.logger.Debugf("GetDatabaseNumberOfWorkers %+v", qdbid) tx, err := c.Transactor.BeginTx(ctx, false) if err != nil { return -1, errors.Wrap(err, "beginning tx") diff --git a/dax/controller/http/handler.go b/dax/controller/http/handler.go index 6953de786..709f394b5 100644 --- a/dax/controller/http/handler.go +++ b/dax/controller/http/handler.go @@ -215,15 +215,6 @@ func (s *server) patchDatabaseOptions(w http.ResponseWriter, r *http.Request) { } } -// get the number of workers for a database -// receive request - -// decode the id - -// send the id into the controller, get the number of workers back - -// send that number back to the client via request - // create a response struct func (s *server) getDatabaseNumberOfWorkers(w http.ResponseWriter, r *http.Request) { // get the context diff --git a/dax/controller/sqldb/workerjob.go b/dax/controller/sqldb/workerjob.go index 774f8dac7..7acb6dab8 100644 --- a/dax/controller/sqldb/workerjob.go +++ b/dax/controller/sqldb/workerjob.go @@ -70,34 +70,23 @@ func jobsForWorker(dt *DaxTransaction, worker *models.Worker, roleType dax.RoleT } func (w *workerJobService) WorkerCount(tx dax.Transaction, roleType dax.RoleType, qdbid dax.QualifiedDatabaseID) (int, error) { - // print the database id - fmt.Println("database id: ", qdbid.DatabaseID) - dt, ok := tx.(*DaxTransaction) if !ok { - // print that the transaction is not valid - fmt.Println("transaction is not valid") - return -2, dax.NewErrInvalidTransaction("*sqldb.DaxTransaction") + return -1, dax.NewErrInvalidTransaction("*sqldb.DaxTransaction") } - // print that the transaction is valid - fmt.Println("transaction is valid") worker := &models.Worker{} query := dt.C.Q() if roleType != "" { - // print the role type query = query.Where(fmt.Sprintf("role_%s = true", roleType)) } if qdbid.DatabaseID != "" { - // print the database id - fmt.Println("database id: [", qdbid.DatabaseID, "]") query = query.Where("database_id = ?", qdbid.DatabaseID) } count, err := query.Count(worker) - return count, errors.Wrap(err, "getting count") }