本文整理汇总了Java中com.netflix.fenzo.VMTaskFitnessCalculator类的典型用法代码示例。如果您正苦于以下问题:Java VMTaskFitnessCalculator类的具体用法?Java VMTaskFitnessCalculator怎么用?Java VMTaskFitnessCalculator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VMTaskFitnessCalculator类属于com.netflix.fenzo包,在下文中一共展示了VMTaskFitnessCalculator类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testCalculatorWeightedAverage
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
@Test
public void testCalculatorWeightedAverage() throws Exception {
VMTaskFitnessCalculator fitnessCalculator1 = mock(VMTaskFitnessCalculator.class);
when(fitnessCalculator1.calculateFitness(any(), any(), any())).thenReturn(0.5);
VMTaskFitnessCalculator fitnessCalculator2 = mock(VMTaskFitnessCalculator.class);
when(fitnessCalculator2.calculateFitness(any(), any(), any())).thenReturn(1.0);
List<WeightedFitnessCalculator> weightedFitnessCalculators = Arrays.asList(
new WeightedFitnessCalculator(fitnessCalculator1, 0.5),
new WeightedFitnessCalculator(fitnessCalculator2, 0.5)
);
WeightedAverageFitnessCalculator calculator = new WeightedAverageFitnessCalculator(weightedFitnessCalculators);
double fitness = calculator.calculateFitness(mock(TaskRequest.class), mock(VirtualMachineCurrentState.class), mock(TaskTrackerState.class));
Assert.assertEquals(0.75, fitness, 0.0);
}
开发者ID:Netflix,项目名称:Fenzo,代码行数:17,代码来源:WeightedAverageFitnessCalculatorTest.java
示例2: testCalculatorWeightedAverageWithZero
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
@Test
public void testCalculatorWeightedAverageWithZero() throws Exception {
VMTaskFitnessCalculator fitnessCalculator1 = mock(VMTaskFitnessCalculator.class);
when(fitnessCalculator1.calculateFitness(any(), any(), any())).thenReturn(0.0);
VMTaskFitnessCalculator fitnessCalculator2 = mock(VMTaskFitnessCalculator.class);
when(fitnessCalculator2.calculateFitness(any(), any(), any())).thenReturn(1.0);
List<WeightedFitnessCalculator> weightedFitnessCalculators = Arrays.asList(
new WeightedFitnessCalculator(fitnessCalculator1, 0.3),
new WeightedFitnessCalculator(fitnessCalculator2, 0.7)
);
WeightedAverageFitnessCalculator calculator = new WeightedAverageFitnessCalculator(weightedFitnessCalculators);
double fitness = calculator.calculateFitness(mock(TaskRequest.class), mock(VirtualMachineCurrentState.class), mock(TaskTrackerState.class));
Assert.assertEquals(0.0, fitness, 0.0);
}
开发者ID:Netflix,项目名称:Fenzo,代码行数:17,代码来源:WeightedAverageFitnessCalculatorTest.java
示例3: get
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
/**
* Returns a "soft" constraint, in the form of a {@link VMTaskFitnessCalculator}, based on a specified "hard"
* constraint, in the form of a {@link ConstraintEvaluator}.
*
* @param c the "hard" constraint to convert
* @return a "soft" constraint version of {@code c}
*/
public static VMTaskFitnessCalculator get(final ConstraintEvaluator c) {
// This fitness calculator return 0 or 1. This can possibly be improved upon by the ConstraintEvaluator using its
// own logic.
return new VMTaskFitnessCalculator() {
@Override
public String getName() {
return c.getName();
}
@Override
public double calculateFitness(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState) {
return c.evaluate(taskRequest, targetVM, taskTrackerState).isSuccessful()? 1.0 : 0.0;
}
};
}
开发者ID:Netflix,项目名称:Fenzo,代码行数:22,代码来源:AsSoftConstraint.java
示例4: WeightedFitnessCalculator
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
public WeightedFitnessCalculator(VMTaskFitnessCalculator fitnessCalculator, double weight) {
if (fitnessCalculator == null) {
throw new IllegalArgumentException("Fitness Calculator cannot be null");
}
this.fitnessCalculator = fitnessCalculator;
this.weight = weight;
}
开发者ID:Netflix,项目名称:Fenzo,代码行数:8,代码来源:WeightedAverageFitnessCalculator.java
示例5: asSoftConstraint
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
/**
* Converts this constraint into a "soft" constraint. By default, a balanced host attribute constraint is a
* "hard" constraint, which is to say that Fenzo will guarantee that the constraint is applied and will fail
* to place a task if the only way it can do so is to violate the constraint. This method returns a
* {@link VMTaskFitnessCalculator} that represents this constraint as a "soft" constraint that will permit
* Fenzo to place a task in violation of the constraint if it cannot do so otherwise.
*
* @return a task fitness calculator that represents the balanced host attribute constraint as a soft
* constraint
*/
public VMTaskFitnessCalculator asSoftConstraint() {
return new VMTaskFitnessCalculator() {
@Override
public String getName() {
return name;
}
@Override
public double calculateFitness(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState) {
String targetHostAttrVal = AttributeUtilities.getAttrValue(targetVM.getCurrAvailableResources(), hostAttributeName);
if(targetHostAttrVal==null || targetHostAttrVal.isEmpty()) {
return 0.0;
}
Set<String> coTasks = coTasksGetter.call(taskRequest.getId());
Map<String, Integer> usedAttribsMap = null;
try {
usedAttribsMap = getUsedAttributesMap(coTasks, taskTrackerState);
} catch (Exception e) {
return 0.0;
}
final Integer integer = usedAttribsMap.get(targetHostAttrVal);
if(integer==null)
return 1.0;
if(usedAttribsMap.isEmpty())
return 1.0;
double avg=0.0;
for(Integer i: usedAttribsMap.values())
avg += i;
avg = Math.ceil(avg+1 / Math.max(expectedValues, usedAttribsMap.size()));
if(integer<=avg)
return (avg-(double)integer) / avg;
return 0.0;
}
};
}
开发者ID:Netflix,项目名称:Fenzo,代码行数:46,代码来源:BalancedHostAttrConstraint.java
示例6: testWeightsMustEqualOne
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testWeightsMustEqualOne() throws Exception {
VMTaskFitnessCalculator fitnessCalculator = mock(VMTaskFitnessCalculator.class);
List<WeightedFitnessCalculator> weightedFitnessCalculators = Arrays.asList(
new WeightedFitnessCalculator(fitnessCalculator, 0.3),
new WeightedFitnessCalculator(fitnessCalculator, 0.75)
);
new WeightedAverageFitnessCalculator(weightedFitnessCalculators);
}
开发者ID:Netflix,项目名称:Fenzo,代码行数:10,代码来源:WeightedAverageFitnessCalculatorTest.java
示例7: getSoftConstraints
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
@Override
public List<? extends VMTaskFitnessCalculator> getSoftConstraints() {
return null;
}
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:5,代码来源:JobTaskRequest.java
示例8: getTaskRequest
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
private TaskRequest getTaskRequest() {
final String taskId = nextTaskId();
return new TaskRequest() {
@Override
public String getId() {
return taskId;
}
@Override
public String taskGroupName() {
return frameworkName;
}
@Override
public double getCPUs() {
return taskCPU;
}
@Override
public double getMemory() {
return taskMEM;
}
@Override
public double getNetworkMbps() {
return taskNET;
}
@Override
public double getDisk() {
return taskDISK;
}
@Override
public int getPorts() {
return 1;
}
@Override
public List<? extends ConstraintEvaluator> getHardConstraints() {
List<ConstraintEvaluator> list = new ArrayList<ConstraintEvaluator>();
list.add(new ExclusiveHostConstraint()); // Force a exclusive host as we are using HOST network
if (!hostAttribute[0].equals(TASK_HOST_ATTRIBUTE_NAME_NOT_DEFINED))
{
list.add( new HostAttrValueConstraint(hostAttribute[0], new Func1<java.lang.String,java.lang.String>() {
@Override
public String call(String arg0) {
// TODO, as we only have one framework. Otherwise need a task id to framework map and framework to attribute map
return hostAttribute[1];
}
} ));
}
return list;
}
@Override
public List<? extends VMTaskFitnessCalculator> getSoftConstraints() {
return null;
}
};
}
开发者ID:yanglei99,项目名称:Mesos_Auto_Scale,代码行数:64,代码来源:FenzoScheduler.java
示例9: getSoftConstraints
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
@Override
public List<? extends VMTaskFitnessCalculator> getSoftConstraints() {
return null;
}
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:LaunchableMesosWorker.java
示例10: getSoftConstraints
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
@Override
public List<? extends VMTaskFitnessCalculator> getSoftConstraints() {
return Collections.emptyList();
}
开发者ID:WTIGER001,项目名称:Brigade,代码行数:5,代码来源:ProcessorTask.java
示例11: getTaskRequest
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
private TaskRequest getTaskRequest(final int id) {
final String taskId = "" + id;
final AtomicReference<TaskRequest.AssignedResources> assgndResRef = new AtomicReference<>();
return new TaskRequest() {
@Override
public String getId() {
return taskId;
}
@Override
public String taskGroupName() {
return "";
}
@Override
public double getCPUs() {
return 1.0;
}
@Override
public double getMemory() {
return 1024;
}
@Override
public double getNetworkMbps() {
return 0;
}
@Override
public double getDisk() {
return 10;
}
@Override
public int getPorts() {
return 1;
}
@Override
public Map<String, Double> getScalarRequests() {
return null;
}
@Override
public List<? extends ConstraintEvaluator> getHardConstraints() {
return null;
}
@Override
public List<? extends VMTaskFitnessCalculator> getSoftConstraints() {
return null;
}
@Override
public void setAssignedResources(AssignedResources assignedResources) {
assgndResRef.set(assignedResources);
}
@Override
public AssignedResources getAssignedResources() {
return assgndResRef.get();
}
@Override
public Map<String, NamedResourceSetRequest> getCustomNamedResources() {
return Collections.emptyMap();
}
};
}
开发者ID:Netflix,项目名称:Fenzo,代码行数:71,代码来源:TaskGenerator.java
示例12: getFitnessCalculator
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
public VMTaskFitnessCalculator getFitnessCalculator() {
return fitnessCalculator;
}
开发者ID:Netflix,项目名称:Fenzo,代码行数:4,代码来源:WeightedAverageFitnessCalculator.java
示例13: calculateFitness
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
@Override
public double calculateFitness(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState) {
VMTaskFitnessCalculator cpuBinPacker = BinPackingFitnessCalculators.cpuBinPacker;
return 1 - cpuBinPacker.calculateFitness(taskRequest, targetVM, taskTrackerState);
}
开发者ID:Netflix,项目名称:Fenzo,代码行数:6,代码来源:SpreadingFitnessCalculators.java
示例14: getSoftConstraints
import com.netflix.fenzo.VMTaskFitnessCalculator; //导入依赖的package包/类
@Override
public List<? extends VMTaskFitnessCalculator> getSoftConstraints() {
return Collections.emptyList();
}
开发者ID:Netflix,项目名称:Fenzo,代码行数:5,代码来源:SampleDataGenerator.java
注:本文中的com.netflix.fenzo.VMTaskFitnessCalculator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论