@@ -292,19 +292,17 @@ func (m *Manager) TryAllocate(treeName string, consumerID string) (response *cor
292292 m .mutex .Lock ()
293293 defer m .mutex .Unlock ()
294294
295+ if m .mode != Normal {
296+ return nil , fmt .Errorf ("manager is not in normal mode" )
297+ }
295298 agent , consumer , err := m .preAllocate (treeName , consumerID )
296299 if err == nil && agent .controller .IsConsumerAllocated (consumerID ) {
297300 err = fmt .Errorf ("consumer %s already allocated on tree %s" , consumerID , treeName )
298301 }
299302 if err != nil {
300303 return nil , err
301304 }
302- if m .mode == Normal {
303- response = agent .controller .TryAllocate (consumer )
304- } else {
305- response = agent .controller .ForceAllocate (consumer , consumer .GetGroupID ())
306- }
307- if ! response .IsAllocated () {
305+ if response = agent .controller .TryAllocate (consumer ); ! response .IsAllocated () {
308306 return nil , fmt .Errorf (response .GetMessage ())
309307 }
310308 return response , err
@@ -499,6 +497,9 @@ func (m *Manager) TryAllocateForest(forestName string, consumerID string) (respo
499497 m .mutex .Lock ()
500498 defer m .mutex .Unlock ()
501499
500+ if m .mode != Normal {
501+ return nil , fmt .Errorf ("manager is not in normal mode" )
502+ }
502503 forestController , forestConsumer , err := m .preAllocateForest (forestName , consumerID )
503504 if err == nil && forestController .IsConsumerAllocated (consumerID ) {
504505 err = fmt .Errorf ("consumer %s already allocated on forest %s" , consumerID , forestName )
@@ -507,15 +508,7 @@ func (m *Manager) TryAllocateForest(forestName string, consumerID string) (respo
507508 return nil , err
508509 }
509510
510- if m .mode == Normal {
511- response = forestController .TryAllocate (forestConsumer )
512- } else {
513- groupIDs := make (map [string ]string )
514- for treeName , consumer := range forestConsumer .GetConsumers () {
515- groupIDs [treeName ] = consumer .GetGroupID ()
516- }
517- response = forestController .ForceAllocate (forestConsumer , groupIDs )
518- }
511+ response = forestController .TryAllocate (forestConsumer )
519512 if ! response .IsAllocated () {
520513 return nil , fmt .Errorf (response .GetMessage ())
521514 }
0 commit comments