|
@@ -63,11 +63,13 @@ type FitPredicateFactory func(PluginFactoryArgs) predicates.FitPredicate
|
|
|
// DEPRECATED
|
|
|
// Use Map-Reduce pattern for priority functions.
|
|
|
type PriorityFunctionFactory func(PluginFactoryArgs) priorities.PriorityFunction
|
|
|
+type CustomPriorityFunctionFactory func(PluginFactoryArgs) priorities.CustomPriorityFunction
|
|
|
|
|
|
// PriorityFunctionFactory2 produces map & reduce priority functions
|
|
|
// from a given args.
|
|
|
// FIXME: Rename to PriorityFunctionFactory.
|
|
|
type PriorityFunctionFactory2 func(PluginFactoryArgs) (priorities.PriorityMapFunction, priorities.PriorityReduceFunction)
|
|
|
+type CustomPriorityFunctionFactory2 func(PluginFactoryArgs) (priorities.CustomPriorityMapFunction, priorities.CustomPriorityReduceFunction)
|
|
|
|
|
|
// PriorityConfigFactory produces a PriorityConfig from the given function and weight
|
|
|
type PriorityConfigFactory struct {
|
|
@@ -76,6 +78,12 @@ type PriorityConfigFactory struct {
|
|
|
Weight int
|
|
|
}
|
|
|
|
|
|
+type CustomPriorityConfigFactory struct {
|
|
|
+ Function CustomPriorityFunctionFactory
|
|
|
+ MapReduceFunction CustomPriorityFunctionFactory2
|
|
|
+ Weight int
|
|
|
+}
|
|
|
+
|
|
|
var (
|
|
|
schedulerFactoryMutex sync.RWMutex
|
|
|
|
|
@@ -83,7 +91,10 @@ var (
|
|
|
fitPredicateMap = make(map[string]FitPredicateFactory)
|
|
|
mandatoryFitPredicates = sets.NewString()
|
|
|
priorityFunctionMap = make(map[string]PriorityConfigFactory)
|
|
|
- algorithmProviderMap = make(map[string]AlgorithmProviderConfig)
|
|
|
+ //custom
|
|
|
+ customPriorityFunctionMap = make(map[string]CustomPriorityConfigFactory)
|
|
|
+ //custom
|
|
|
+ algorithmProviderMap = make(map[string]AlgorithmProviderConfig)
|
|
|
|
|
|
// Registered metadata producers
|
|
|
priorityMetadataProducer PriorityMetadataProducerFactory
|
|
@@ -294,6 +305,38 @@ func RegisterPriorityFunction2(
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+//------------------------------------------------------------------------------------------------
|
|
|
+//------------------------------------------------------------------------------------------------
|
|
|
+// ---------START OF CUSTOMIZATION----------------------------------------------------------------
|
|
|
+//------------------------------------------------------------------------------------------------
|
|
|
+//------------------------------------------------------------------------------------------------
|
|
|
+func CustomRegisterPriorityFunction2(
|
|
|
+ name string,
|
|
|
+ mapFunction priorities.CustomPriorityMapFunction,
|
|
|
+ reduceFunction priorities.CustomPriorityReduceFunction,
|
|
|
+ weight int) string {
|
|
|
+ return CustomRegisterPriorityConfigFactory(name, CustomPriorityConfigFactory{
|
|
|
+ MapReduceFunction: func(PluginFactoryArgs) (priorities.CustomPriorityMapFunction, priorities.CustomPriorityReduceFunction) {
|
|
|
+ return mapFunction, reduceFunction
|
|
|
+ },
|
|
|
+ Weight: weight,
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func CustomRegisterPriorityConfigFactory(name string, pcf CustomPriorityConfigFactory) string {
|
|
|
+ schedulerFactoryMutex.Lock()
|
|
|
+ defer schedulerFactoryMutex.Unlock()
|
|
|
+ validateAlgorithmNameOrDie(name)
|
|
|
+ customPriorityFunctionMap[name] = pcf
|
|
|
+ return name
|
|
|
+}
|
|
|
+
|
|
|
+//------------------------------------------------------------------------------------------------
|
|
|
+//------------------------------------------------------------------------------------------------
|
|
|
+// ---------START OF CUSTOMIZATION----------------------------------------------------------------
|
|
|
+//------------------------------------------------------------------------------------------------
|
|
|
+//------------------------------------------------------------------------------------------------
|
|
|
+
|
|
|
// RegisterPriorityConfigFactory registers a priority config factory with its name.
|
|
|
func RegisterPriorityConfigFactory(name string, pcf PriorityConfigFactory) string {
|
|
|
schedulerFactoryMutex.Lock()
|