• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java VirtualMachineLease类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.netflix.fenzo.VirtualMachineLease的典型用法代码示例。如果您正苦于以下问题:Java VirtualMachineLease类的具体用法?Java VirtualMachineLease怎么用?Java VirtualMachineLease使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

VirtualMachineLease类属于com.netflix.fenzo包,在下文中一共展示了VirtualMachineLease类的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: assertRunOneIteration

点赞 3

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
@Test
public void assertRunOneIteration() throws Exception {
    when(facadeService.getEligibleJobContext()).thenReturn(Lists.newArrayList(
            JobContext.from(CloudJobConfigurationBuilder.createCloudJobConfiguration("failover_job", CloudJobExecutionType.DAEMON, 1), ExecutionType.FAILOVER)));
    Map<String, VMAssignmentResult> vmAssignmentResultMap = new HashMap<>();
    vmAssignmentResultMap.put("rs1", new VMAssignmentResult("localhost", Lists.<VirtualMachineLease>newArrayList(new VMLeaseObject(OfferBuilder.createOffer("offer_0"))),
            Sets.newHashSet(mockTaskAssignmentResult("failover_job", ExecutionType.FAILOVER))));
    when(taskScheduler.scheduleOnce(ArgumentMatchers.<TaskRequest>anyList(), ArgumentMatchers.<VirtualMachineLease>anyList())).thenReturn(new SchedulingResult(vmAssignmentResultMap));
    when(facadeService.load("failover_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("failover_job")));
    when(facadeService.getFailoverTaskId(any(TaskContext.MetaInfo.class)))
            .thenReturn(Optional.of(String.format("%[email protected]@[email protected]@%[email protected]@[email protected]@0", "failover_job",  ExecutionType.FAILOVER.name())));
    when(taskScheduler.getTaskAssigner()).thenReturn(mock(Action2.class));
    taskLaunchScheduledService.runOneIteration();
    verify(facadeService).removeLaunchTasksFromQueue(ArgumentMatchers.<TaskContext>anyList());
    verify(facadeService).loadAppConfig("test_app");
    verify(jobEventBus).post(ArgumentMatchers.<JobStatusTraceEvent>any());
}
 

开发者ID:elasticjob,
项目名称:elastic-job-cloud,
代码行数:18,
代码来源:TaskLaunchScheduledServiceTest.java

示例2: assertRunOneIterationWithScriptJob

点赞 3

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
@Test
public void assertRunOneIterationWithScriptJob() throws Exception {
    when(facadeService.getEligibleJobContext()).thenReturn(Lists.newArrayList(
            JobContext.from(CloudJobConfigurationBuilder.createScriptCloudJobConfiguration("script_job", 1), ExecutionType.READY)));
    Map<String, VMAssignmentResult> vmAssignmentResultMap = new HashMap<>();
    vmAssignmentResultMap.put("rs1", new VMAssignmentResult("localhost", Lists.<VirtualMachineLease>newArrayList(new VMLeaseObject(OfferBuilder.createOffer("offer_0"))),
            Sets.newHashSet(mockTaskAssignmentResult("script_job", ExecutionType.READY))));
    when(taskScheduler.scheduleOnce(ArgumentMatchers.<TaskRequest>anyList(), ArgumentMatchers.<VirtualMachineLease>anyList())).thenReturn(new SchedulingResult(vmAssignmentResultMap));
    when(facadeService.loadAppConfig("test_app")).thenReturn(Optional.of(CloudAppConfigurationBuilder.createCloudAppConfiguration("test_app")));
    when(facadeService.load("script_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createScriptCloudJobConfiguration("script_job", 1)));
    when(taskScheduler.getTaskAssigner()).thenReturn(mock(Action2.class));
    taskLaunchScheduledService.runOneIteration();
    verify(facadeService).removeLaunchTasksFromQueue(ArgumentMatchers.<TaskContext>anyList());
    verify(facadeService).isRunning(TaskContext.from(String.format("%[email protected]@[email protected]@%[email protected]@[email protected]@0", "script_job", ExecutionType.READY)));
    verify(facadeService).loadAppConfig("test_app");
    verify(jobEventBus).post(ArgumentMatchers.<JobStatusTraceEvent>any());
}
 

开发者ID:elasticjob,
项目名称:elastic-job-cloud,
代码行数:18,
代码来源:TaskLaunchScheduledServiceTest.java

示例3: createOptimizer

点赞 3

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
/**
 * Creates the Fenzo optimizer (builder).
 * The builder is an indirection to facilitate unit testing of the Launch Coordinator.
 */
private static TaskSchedulerBuilder createOptimizer() {
	return new TaskSchedulerBuilder() {
		TaskScheduler.Builder builder = new TaskScheduler.Builder();

		@Override
		public TaskSchedulerBuilder withLeaseRejectAction(Action1<VirtualMachineLease> action) {
			builder.withLeaseRejectAction(action);
			return this;
		}

		@Override
		public TaskScheduler build() {
			return builder.build();
		}
	};
}
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:21,
代码来源:MesosResourceManager.java

示例4: calculateFitness

点赞 3

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
@Override
public double calculateFitness(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState) {
    return calculateResourceFitness(taskRequest, targetVM, taskTrackerState,
            new Func1<TaskRequest, Double>() {
                @Override
                public Double call(TaskRequest request) {
                    return request.getCPUs();
                }
            },
            new Func1<VirtualMachineLease, Double>() {
                @Override
                public Double call(VirtualMachineLease l) {
                    return l.cpuCores();
                }
            });
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:17,
代码来源:BinPackingFitnessCalculators.java

示例5: calculateResourceFitness

点赞 3

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
private static double calculateResourceFitness(TaskRequest request, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState,
                                               Func1<TaskRequest, Double> taskResourceGetter,
                                               Func1<VirtualMachineLease, Double> leaseResourceGetter) {
    double totalRes = leaseResourceGetter.call(targetVM.getCurrAvailableResources());
    Iterator<TaskRequest> iterator = targetVM.getRunningTasks().iterator();
    double oldJobsTotal=0.0;
    while(iterator.hasNext())
        oldJobsTotal += taskResourceGetter.call(iterator.next());
    double usedResource = taskResourceGetter.call(request);
    Iterator<TaskAssignmentResult> taskAssignmentResultIterator = targetVM.getTasksCurrentlyAssigned().iterator();
    while(taskAssignmentResultIterator.hasNext())
        usedResource += taskResourceGetter.call(taskAssignmentResultIterator.next().getRequest());
    totalRes += oldJobsTotal;
    usedResource += oldJobsTotal;
    return usedResource / totalRes;
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:17,
代码来源:BinPackingFitnessCalculators.java

示例6: getOfferIDs

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
private List<Protos.OfferID> getOfferIDs(final List<VirtualMachineLease> leasesUsed) {
    List<Protos.OfferID> result = new ArrayList<>();
    for (VirtualMachineLease virtualMachineLease: leasesUsed) {
        result.add(virtualMachineLease.getOffer().getId());
    }
    return result;
}
 

开发者ID:elasticjob,
项目名称:elastic-job-cloud,
代码行数:8,
代码来源:TaskLaunchScheduledService.java

示例7: getTaskScheduler

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
private TaskScheduler getTaskScheduler() {
    return new TaskScheduler.Builder()
            .withLeaseOfferExpirySecs(1000000000L)
            .withLeaseRejectAction(new Action1<VirtualMachineLease>() {
                
                @Override
                public void call(final VirtualMachineLease lease) {
                    log.warn("Declining offer on '{}'", lease.hostname());
                    schedulerDriver.declineOffer(lease.getOffer().getId());
                }
            }).build();
}
 

开发者ID:elasticjob,
项目名称:elastic-job-cloud,
代码行数:13,
代码来源:SchedulerService.java

示例8: setUp

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    taskScheduler = new TaskScheduler.Builder().withLeaseOfferExpirySecs(1000000000L).withLeaseRejectAction(new Action1<VirtualMachineLease>() {
        
        @Override
        public void call(final VirtualMachineLease virtualMachineLease) {
        }
    }).build();
}
 

开发者ID:elasticjob,
项目名称:elastic-job-cloud,
代码行数:10,
代码来源:AppConstraintEvaluatorTest.java

示例9: getLease

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
private VirtualMachineLease getLease(final int index, final double cpus, final double mem) {
    return new VMLeaseObject(Protos.Offer.newBuilder()
            .setId(Protos.OfferID.newBuilder().setValue("offer" + index))
            .setSlaveId(Protos.SlaveID.newBuilder().setValue("S" + index))
            .setHostname("slave" + index)
            .setFrameworkId(Protos.FrameworkID.newBuilder().setValue("f1"))
            .addResources(Protos.Resource.newBuilder().setName("cpus").setType(Protos.Value.Type.SCALAR).setScalar(Protos.Value.Scalar.newBuilder().setValue(cpus)))
            .addResources(Protos.Resource.newBuilder().setName("mem").setType(Protos.Value.Type.SCALAR).setScalar(Protos.Value.Scalar.newBuilder().setValue(mem)))
            .build());
}
 

开发者ID:elasticjob,
项目名称:elastic-job-cloud,
代码行数:11,
代码来源:AppConstraintEvaluatorTest.java

示例10: Framework

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
/**
 * Constructor for the framework
 * 
 * @param processor
 *            The processor that this framework is responsible for
 * @param configuration
 *            Configuration that came from environment variables
 */
public Framework(Processor processor, Configuration configuration) {
	this.configuration = configuration;
	this.leasesQueue = new LinkedBlockingQueue<>();

	scheduler = new TaskScheduler.Builder().withLeaseOfferExpirySecs(10)
			.withLeaseRejectAction(new Action1<VirtualMachineLease>() {
				@Override
				public void call(VirtualMachineLease lease) {
					LOG.trace("Declining offer on " + lease.hostname());
					ref.get().declineOffer(lease.getOffer().getId());
				}
			}).build();

	// Construct the Framework
	String frameworkName = configuration.frameworkName + "_" + processor.name + "_" + VERSION;
	Protos.FrameworkInfo framework = Protos.FrameworkInfo.newBuilder().setName(frameworkName).setUser("").build();

	// Build the Kafka components
	input = new KafkaInput(this, configuration, processor);
	output = new KafkaOutput(this, configuration, processor);

	// Build the Scheduler
	Scheduler mesosScheduler = new MesosScheduler(scheduler, leasesQueue, input, this);
	mesosSchedulerDriver = new MesosSchedulerDriver(mesosScheduler, framework, configuration.mesosMaster);
	ref.set(mesosSchedulerDriver);
}
 

开发者ID:WTIGER001,
项目名称:Brigade,
代码行数:35,
代码来源:Framework.java

示例11: SampleFramework

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
/**
 * Create a sample mesos framework with the given task queue and mesos master connection string. As would be typical
 * for frameworks that wish to use Fenzo task scheduler, a lease queue is created for mesos scheduler callback to
 * insert offers received from mesos. This sample implementation obtains the tasks to run via a task queue. The
 * {@link SampleFramework#runAll()} method implements the scheduling loop that continuously takes pending tasks from
 * the queue and uses Fenzo's task scheduler to assign resources to them.
 *
 * The task scheduler created in this sample is a rather simple one, with no advanced features.
 *
 * @param taskQueue The task queue.
 * @param mesosMaster Connection string for mesos master.
 * @param onTaskComplete A single argument action trigger to invoke upon task completion, with task ID is the argument.
 * @param taskCmdGetter A single argument function to invoke to get the command line to execute for a given task ID,
 *                      passed as the only argument.
 */
public SampleFramework(BlockingQueue<TaskRequest> taskQueue, String mesosMaster, Action1<String> onTaskComplete,
                       Func1<String, String> taskCmdGetter) {
    this.taskQueue = taskQueue;
    this.leasesQueue = new LinkedBlockingQueue<>();
    this.onTaskComplete = onTaskComplete;
    this.taskCmdGetter = taskCmdGetter;
    launchedTasks = new HashMap<>();
    scheduler = new TaskScheduler.Builder()
            .withLeaseOfferExpirySecs(1000000000)
            .withLeaseRejectAction(new Action1<VirtualMachineLease>() {
                @Override
                public void call(VirtualMachineLease lease) {
                    System.out.println("Declining offer on " + lease.hostname());
                    ref.get().declineOffer(lease.getOffer().getId());
                }
            })
            .build();
    Protos.FrameworkInfo framework = Protos.FrameworkInfo.newBuilder()
            .setName("Sample Fenzo Framework")
            .setUser("")
            .build();
    Scheduler mesosScheduler = new MesosScheduler();
    mesosSchedulerDriver = new MesosSchedulerDriver(mesosScheduler, framework, mesosMaster);
    ref.set(mesosSchedulerDriver);
    new Thread() {
        public void run() {
            mesosSchedulerDriver.run();
        }
    }.start();
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:46,
代码来源:SampleFramework.java

示例12: BalancedScaleDownConstraintEvaluator

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
public BalancedScaleDownConstraintEvaluator(Function<VirtualMachineLease, String> keyExtractor,
                                            double initialScore,
                                            double initialStep) {
    this.keyExtractor = keyExtractor;
    this.initialScore = initialScore;
    this.initialStep = initialStep;
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:8,
代码来源:BalancedScaleDownConstraintEvaluator.java

示例13: evaluate

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
@Override
public Result<Map<String, Integer>> evaluate(VirtualMachineLease candidate, Optional<Map<String, Integer>> optionalContext) {
    Map<String, Integer> context = optionalContext.orElseGet(HashMap::new);
    String group = findGroup(candidate);

    int groupCount = context.getOrDefault(group, 0);
    context.put(group, groupCount + 1);

    double score = computeScore(groupCount);

    return Result.of(score, context);
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:13,
代码来源:BalancedScaleDownConstraintEvaluator.java

示例14: findGroup

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
private String findGroup(VirtualMachineLease l) {
    String groupName;
    try {
        groupName = keyExtractor.apply(l);
    } catch (Exception e) {
        groupName = FAILURE_GROUP;
    }
    return groupName;
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:10,
代码来源:BalancedScaleDownConstraintEvaluator.java

示例15: evaluate

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
@Override
public List<Set<VirtualMachineLease>> evaluate(Collection<VirtualMachineLease> candidates) {
    Set<VirtualMachineLease> active = new HashSet<>();
    Set<VirtualMachineLease> inactive = new HashSet<>();
    candidates.forEach(l -> {
        if (isInactive(l)) {
            inactive.add(l);
        } else {
            active.add(l);
        }
    });
    inactive.addAll(active);

    return asList(inactive, active);
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:16,
代码来源:InactiveClusterScaleDownConstraintEvaluator.java

示例16: isInactive

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
private boolean isInactive(VirtualMachineLease lease) {
    try {
        Boolean inactive = isInactive.apply(lease);
        return inactive != null && inactive;
    } catch (Exception ignore) {
        // We expect callback provider to handle all exceptions, and this is just a safeguard for Fenzo evaluator
    }
    return false;
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:10,
代码来源:InactiveClusterScaleDownConstraintEvaluator.java

示例17: getAttrValue

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
static String getAttrValue(VirtualMachineLease lease, String hostAttributeName) {
    switch (hostAttributeName) {
        case DEFAULT_ATTRIBUTE:
            return lease.hostname();
        default:
            Map<String,Protos.Attribute> attributeMap = lease.getAttributeMap();
            if(attributeMap==null)
                return null;
            Protos.Attribute attribute = attributeMap.get(hostAttributeName);
            if(attribute==null)
                return null;
            return attribute.getText().getValue();
    }
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:15,
代码来源:AttributeUtilities.java

示例18: getAttrValue

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
private String getAttrValue(VirtualMachineLease lease) {
    switch (hostAttributeName) {
        case HOSTNAME:
            return lease.hostname();
        default:
            Map<String,Protos.Attribute> attributeMap = lease.getAttributeMap();
            if(attributeMap==null)
                return null;
            Protos.Attribute attribute = attributeMap.get(hostAttributeName);
            if(attribute==null)
                return null;
            return attribute.getText().getValue();
    }
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:15,
代码来源:HostAttrValueConstraint.java

示例19: evaluateAndVerify

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
private Optional<Map<String, Integer>> evaluateAndVerify(VirtualMachineLease lease,
                                                         Optional<Map<String, Integer>> context,
                                                         double expectedScore) {
    Result<Map<String, Integer>> result = evaluator.evaluate(lease, context);
    assertThat(result.getScore(), is(equalTo(expectedScore)));
    return result.getContext();
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:8,
代码来源:BalancedScaleDownConstraintEvaluatorTest.java

示例20: leasesWithIds

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
public static List<VirtualMachineLease> leasesWithIds(String... ids) {
    List<VirtualMachineLease> leases = new ArrayList<>(ids.length);
    for (String id : ids) {
        leases.add(new TestableVirtualMachineLease(id));
    }
    return leases;
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:8,
代码来源:TestableVirtualMachineLease.java

示例21: drainTo

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
/**
 * 出栈队列资源.
 * 
 * @return 队列资源集合
 */
public List<VirtualMachineLease> drainTo() {
    List<VirtualMachineLease> result = new ArrayList<>(queue.size());
    queue.drainTo(result);
    return result;
}
 

开发者ID:elasticjob,
项目名称:elastic-job-cloud,
代码行数:11,
代码来源:LeasesQueue.java

示例22: MesosScheduler

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
public MesosScheduler(TaskScheduler scheduler, BlockingQueue<VirtualMachineLease> leasesQueue, KafkaInput source, Framework framework) {
	this.scheduler = scheduler;
	this.leasesQueue = leasesQueue;
	this.source = source;
	this.framework = framework;
}
 

开发者ID:WTIGER001,
项目名称:Brigade,
代码行数:7,
代码来源:MesosScheduler.java

示例23: InactiveClusterScaleDownConstraintEvaluator

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
public InactiveClusterScaleDownConstraintEvaluator(Function<VirtualMachineLease, Boolean> isInactive) {
    this.isInactive = isInactive;
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:4,
代码来源:InactiveClusterScaleDownConstraintEvaluator.java

示例24: evaluate

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
@Override
public List<Set<VirtualMachineLease>> evaluate(Collection<VirtualMachineLease> candidates) {
    Set<VirtualMachineLease> singleGroup = new HashSet<>();
    singleGroup.addAll(candidates);
    return Collections.singletonList(singleGroup);
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:7,
代码来源:NoOpScaleDownOrderEvaluator.java

示例25: keyExtractor

点赞 2

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
private String keyExtractor(VirtualMachineLease lease) {
    return "myZone";
}
 

开发者ID:Netflix,
项目名称:Fenzo,
代码行数:4,
代码来源:BalancedScaleDownConstraintEvaluatorTest.java

示例26: withLeaseRejectAction

点赞 1

import com.netflix.fenzo.VirtualMachineLease; //导入依赖的package包/类
/**
 * Set the callback action for rejecting a lease.
 */
TaskSchedulerBuilder withLeaseRejectAction(Action1<VirtualMachineLease> action);
 

开发者ID:axbaretto,
项目名称:flink,
代码行数:5,
代码来源:TaskSchedulerBuilder.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)