Skip to content

Commit

Permalink
go scheduler: merge and storage eligibility by runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-wh committed Jan 8, 2020
1 parent b792882 commit b4e733f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
22 changes: 20 additions & 2 deletions go/consensus/tendermint/apps/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,16 @@ func (app *schedulerApplication) isSuitableComputeWorker(n *node.Node, rt *regis
}

func (app *schedulerApplication) isSuitableStorageWorker(n *node.Node, rt *registry.Runtime, ts time.Time) bool {
return n.HasRoles(node.RoleStorageWorker)
if !n.HasRoles(node.RoleStorageWorker) {
return false
}
for _, nrt := range n.Runtimes {
if !nrt.ID.Equal(&rt.ID) {
continue
}
return true
}
return false
}

func (app *schedulerApplication) isSuitableTransactionScheduler(n *node.Node, rt *registry.Runtime, ts time.Time) bool {
Expand All @@ -393,7 +402,16 @@ func (app *schedulerApplication) isSuitableTransactionScheduler(n *node.Node, rt
}

func (app *schedulerApplication) isSuitableMergeWorker(n *node.Node, rt *registry.Runtime, ts time.Time) bool {
return n.HasRoles(node.RoleComputeWorker)
if !n.HasRoles(node.RoleComputeWorker) {
return false
}
for _, nrt := range n.Runtimes {
if !nrt.ID.Equal(&rt.ID) {
continue
}
return true
}
return false
}

// Operates on consensus connection.
Expand Down
11 changes: 6 additions & 5 deletions go/registry/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ var (

// RuntimesRequiredRoles are the Node roles that require runtimes.
RuntimesRequiredRoles = node.RoleComputeWorker |
node.RoleStorageWorker |
node.RoleKeyManager

// ConsensusAddressRequiredRoles are the Node roles that require Consensus Address.
Expand Down Expand Up @@ -1145,15 +1146,15 @@ func SanityCheckNodes(nodes []*node.SignedNode, seenEntities map[signature.Publi
return fmt.Errorf("registry: sanity check failed: compute worker node must have runtime(s)")
}

if n.HasRoles(node.RoleKeyManager) && len(n.Runtimes) == 0 {
return fmt.Errorf("registry: sanity check failed: key manager node must have runtime(s)")
if n.HasRoles(node.RoleStorageWorker) && len(n.Runtimes) == 0 {
return fmt.Errorf("registry: sanity check failed: storage worker node must have runtime(s)")
}

if n.HasRoles(node.RoleStorageWorker) && !n.HasRoles(node.RoleComputeWorker) && !n.HasRoles(node.RoleKeyManager) && len(n.Runtimes) > 0 {
return fmt.Errorf("registry: sanity check failed: storage worker node shouldn't have any runtimes")
if n.HasRoles(node.RoleKeyManager) && len(n.Runtimes) == 0 {
return fmt.Errorf("registry: sanity check failed: key manager node must have runtime(s)")
}

if n.HasRoles(node.RoleValidator) && !n.HasRoles(node.RoleComputeWorker) && !n.HasRoles(node.RoleKeyManager) && len(n.Runtimes) > 0 {
if n.HasRoles(node.RoleValidator) && !n.HasRoles(node.RoleComputeWorker) && !n.HasRoles(node.RoleStorageWorker) && !n.HasRoles(node.RoleKeyManager) && len(n.Runtimes) > 0 {
return fmt.Errorf("registry: sanity check failed: validator node shouldn't have any runtimes")
}

Expand Down

0 comments on commit b4e733f

Please sign in to comment.