Skip to content

Commit

Permalink
service#atomic?
Browse files Browse the repository at this point in the history
When fetching services through the api

api/services
  expand=resources
  attributes=picture,
             picture.image_href,
             chargeback_report,
             evm_owner.userid,
             v_total_vms,
             power_state,
             all_service_children,
             tags
  filter[]=ancestry=null

  sort_by=created_at
  sort_options=
  sort_order=desc
  limit=20
  offset=0

reduce calls to database

|       ms |       bytes | objects |query |  qry ms |     rows |comments
|      ---:|         ---:|     ---:|  ---:|     ---:|      ---:| ---
|    570.4 | 25,230,444* | 334,164 |  165 |    50.8 |       53 |orig
|    537.5 | 24,482,568* | 328,012 |  145 |    51.6 |       53 |atomic

\* Memory usage does not reflect 4 freed objects.
  • Loading branch information
kbrock committed Feb 11, 2019
1 parent 6fa6891 commit ff8ee93
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/models/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,21 @@ def power_states_match?(action)
end

def all_states_match?(action)
return true if composite? && (power_states.uniq == map_power_states(action))
return true if atomic? && (power_states[0] == POWER_STATE_MAP[action])
false
if composite?
power_states.uniq == map_power_states(action)
else
power_states[0] == POWER_STATE_MAP[action]
end
end

# @return true if this is a composite service
def composite?
children.present?
end

# @return true if this is a single service (not made up of multiple services)
def atomic?
children.empty?
!composite?
end

def orchestration_stacks
Expand Down

0 comments on commit ff8ee93

Please sign in to comment.