@@ -292,19 +292,17 @@ func (m *Manager) TryAllocate(treeName string, consumerID string) (response *cor
292
292
m .mutex .Lock ()
293
293
defer m .mutex .Unlock ()
294
294
295
+ if m .mode != Normal {
296
+ return nil , fmt .Errorf ("manager is not in normal mode" )
297
+ }
295
298
agent , consumer , err := m .preAllocate (treeName , consumerID )
296
299
if err == nil && agent .controller .IsConsumerAllocated (consumerID ) {
297
300
err = fmt .Errorf ("consumer %s already allocated on tree %s" , consumerID , treeName )
298
301
}
299
302
if err != nil {
300
303
return nil , err
301
304
}
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 () {
308
306
return nil , fmt .Errorf (response .GetMessage ())
309
307
}
310
308
return response , err
@@ -499,6 +497,9 @@ func (m *Manager) TryAllocateForest(forestName string, consumerID string) (respo
499
497
m .mutex .Lock ()
500
498
defer m .mutex .Unlock ()
501
499
500
+ if m .mode != Normal {
501
+ return nil , fmt .Errorf ("manager is not in normal mode" )
502
+ }
502
503
forestController , forestConsumer , err := m .preAllocateForest (forestName , consumerID )
503
504
if err == nil && forestController .IsConsumerAllocated (consumerID ) {
504
505
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
507
508
return nil , err
508
509
}
509
510
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 )
519
512
if ! response .IsAllocated () {
520
513
return nil , fmt .Errorf (response .GetMessage ())
521
514
}
0 commit comments