当前位置: 首页>>代码示例>>Java>>正文


Java Action1类代码示例

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


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

示例1: createOptimizer

import com.netflix.fenzo.functions.Action1; //导入依赖的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

示例2: MagellanFramework

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
public MagellanFramework(){
    log.log(Level.INFO, "Printing Environment Variables:");
    log.log(Level.INFO, "PRINCIPAL: " + System.getenv("PRINCIPAL"));
    log.log(Level.INFO, "FRAMEWORK_USER: " + System.getenv("FRAMEWORK_USER"));
    log.log(Level.INFO, "MASTER_ADDRESS: " + System.getenv("MASTER_ADDRESS"));
    log.log(Level.INFO, "LIBPROCESS_IP: " + System.getenv("LIBPROCESS_IP"));
    log.log(Level.INFO, "LIBPROCESS_PORT: " + System.getenv("LIBPROCESS_PORT"));
    log.log(Level.INFO, "ZK_IP: " + System.getenv("ZK_IP"));
    log.log(Level.INFO, "ZK_PORT: " + System.getenv("ZK_PORT"));
    log.log(Level.INFO, "EXECUTOR_PATH: " + System.getenv("EXECUTOR_PATH"));

    fenzoScheduler = new TaskScheduler.Builder()
            .withLeaseOfferExpirySecs(1000000000)
            .withLeaseRejectAction(new Action1<VirtualMachineLease>() {
                public void call(VirtualMachineLease lease) {
                    log.log(Level.INFO, "Declining offer on " + lease.hostname());
                    mesosDriver.get().declineOffer(lease.getOffer().getId());
                }
            })
            .build();
}
 
开发者ID:mesos-magellan,项目名称:faleiro,代码行数:22,代码来源:MagellanFramework.java

示例3: AssignableVirtualMachine

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
public AssignableVirtualMachine(ConcurrentMap<String, String> vmIdToHostnameMap,
                                ConcurrentMap<String, String> leaseIdToHostnameMap,
                                String hostname, Action1<VirtualMachineLease> leaseRejectAction,
                                long leaseOfferExpirySecs, TaskTracker taskTracker, boolean singleLeaseMode) {
    this.vmIdToHostnameMap = vmIdToHostnameMap;
    this.leaseIdToHostnameMap = leaseIdToHostnameMap;
    this.hostname = hostname;
    this.leaseRejectAction = getWrappedLeaseRejectAction(leaseRejectAction);
    this.leaseOfferExpirySecs = leaseOfferExpirySecs;
    this.taskTracker = taskTracker;
    this.leasesMap = new HashMap<>();
    this.leasesToExpire = new LinkedBlockingQueue<>();
    expireAllLeasesNow = new AtomicBoolean(false);
    this.workersToUnAssign = new LinkedBlockingQueue<>();
    this.previouslyAssignedTasksMap = new HashMap<>();
    this.assignmentResults = new HashMap<>();
    this.singleLeaseMode = singleLeaseMode;
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:19,代码来源:AssignableVirtualMachine.java

示例4: getTaskScheduler

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
private static TaskScheduler getTaskScheduler() {
    return new TaskScheduler.Builder()
                .withFitnessGoodEnoughFunction(new Func1<Double, Boolean>() {
                    @Override
                    public Boolean call(Double aDouble) {
                        return aDouble >= GOOD_ENOUGH_FITNESS;
                    }
                })
                .withFitnessCalculator(BinPackingFitnessCalculators.cpuBinPacker)
                .withLeaseOfferExpirySecs(1000000)
                .withLeaseRejectAction(new Action1<VirtualMachineLease>() {
                    @Override
                    public void call(VirtualMachineLease lease) {
                        System.err.println("Unexpected to reject lease on " + lease.hostname());
                    }
                })
                .build();
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:19,代码来源:TestLotsOfTasks.java

示例5: testOfferExpiry

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
@Test
public void testOfferExpiry() throws Exception {
    final AtomicBoolean leaseRejected = new AtomicBoolean(false);
    final long leaseExpirySecs=1;
    TaskScheduler myTaskScheduler = new TaskScheduler.Builder()
            .withLeaseOfferExpirySecs(leaseExpirySecs)
            .withLeaseRejectAction(new Action1<VirtualMachineLease>() {
                @Override
                public void call(VirtualMachineLease virtualMachineLease) {
                    leaseRejected.set(true);
                }
            })
            .build();
    List<VirtualMachineLease> leases = LeaseProvider.getLeases(1, 4, 100, 1, 10);
    List<TaskRequest> taskRequests = new ArrayList<>();
    taskRequests.add(TaskRequestProvider.getTaskRequest(5, 10, 1));
    Map<String,VMAssignmentResult> resultMap = myTaskScheduler.scheduleOnce(taskRequests, leases).getResultMap();
    Assert.assertEquals(0, resultMap.entrySet().size());
    leases.clear(); // don't pass in the same lease again.
    // wait for lease to expire
    try{Thread.sleep(leaseExpirySecs*1000+200);}catch (InterruptedException ie){}
    taskRequests.clear();
    taskRequests.add(TaskRequestProvider.getTaskRequest(5, 10, 1)); // make sure task doesn't get assigned
    resultMap = myTaskScheduler.scheduleOnce(taskRequests, leases).getResultMap();
    Assert.assertEquals(true, leaseRejected.get());
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:27,代码来源:BasicSchedulerTests.java

示例6: setUp

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    taskScheduler = new TaskScheduler.Builder()
            .withLeaseOfferExpirySecs(1000000)
            .withLeaseRejectAction(new Action1<VirtualMachineLease>() {
                @Override
                public void call(VirtualMachineLease virtualMachineLease) {
                    System.out.println("Rejecting offer on host " + virtualMachineLease.hostname());
                }
            })
            .build();
    taskScheduler.setActiveVmGroupAttributeName(activeVmGrpAttrName);
    taskScheduler.setActiveVmGroups(Arrays.asList(activeVmGrp));
    Protos.Attribute attribute1 = Protos.Attribute.newBuilder().setName(activeVmGrpAttrName)
            .setType(Protos.Value.Type.TEXT)
            .setText(Protos.Value.Text.newBuilder().setValue("test1")).build();
    attributes1.put(activeVmGrpAttrName, attribute1);
    Protos.Attribute attribute2 = Protos.Attribute.newBuilder().setName(activeVmGrpAttrName)
            .setType(Protos.Value.Type.TEXT)
            .setText(Protos.Value.Text.newBuilder().setValue("test2")).build();
    attributes2.put(activeVmGrpAttrName, attribute2);
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:23,代码来源:ActiveVmGroupsTests.java

示例7: getTaskScheduler

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
private TaskScheduler getTaskScheduler(boolean useBinPacking) {
    TaskScheduler.Builder builder = new TaskScheduler.Builder()
            .withLeaseOfferExpirySecs(1000000)
            .withLeaseRejectAction(new Action1<VirtualMachineLease>() {
                @Override
                public void call(VirtualMachineLease virtualMachineLease) {
                    System.out.println("Rejecting offer on host " + virtualMachineLease.hostname());
                    Assert.fail();
                }
            })
            .withFitnessGoodEnoughFunction(new Func1<Double, Boolean>() {
                @Override
                public Boolean call(Double aDouble) {
                    return aDouble > 1.0;
                }
            });
    if(useBinPacking)
        builder = builder
                .withFitnessCalculator(BinPackingFitnessCalculators.cpuMemBinPacker);
    return builder.build();
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:22,代码来源:ConstraintsTests.java

示例8: getScheduler

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
static TaskScheduler getScheduler(final Action1<VirtualMachineLease> leaseRejectCalback, final Action1<AutoScaleAction> callback,
                                  long delayScaleUpBySecs, long delayScaleDownByDecs,
                                  AutoScaleRule... rules) {
    TaskScheduler.Builder builder = new TaskScheduler.Builder()
            .withAutoScaleByAttributeName(hostAttrName);
    for (AutoScaleRule rule : rules)
        builder.withAutoScaleRule(rule);
    if (callback != null)
        builder.withAutoScalerCallback(callback);
    return builder
            .withDelayAutoscaleDownBySecs(delayScaleDownByDecs)
            .withDelayAutoscaleUpBySecs(delayScaleUpBySecs)
            .withFitnessCalculator(BinPackingFitnessCalculators.cpuMemBinPacker)
            .withLeaseOfferExpirySecs(3600)
            .withLeaseRejectAction(lease -> {
                if (leaseRejectCalback == null)
                    Assert.fail("Unexpected to reject lease " + lease.hostname());
                else
                    leaseRejectCalback.call(lease);
            })
            .build();
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:23,代码来源:AutoScalerTest.java

示例9: getScheduler

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
private TaskScheduler getScheduler(
        long offerExpirySecs, final long leaseReOfferDelaySecs,
        int maxOffersToReject,
        final BlockingQueue<VirtualMachineLease> offersQ,
        final Func1<String, VirtualMachineLease> offerGenerator
) {
    return new TaskScheduler.Builder()
            .withLeaseRejectAction(
                    new Action1<VirtualMachineLease>() {
                        @Override
                        public void call(final VirtualMachineLease virtualMachineLease) {
                            executorService.schedule(
                                    new Runnable() {
                                        @Override
                                        public void run() {
                                            offersQ.offer(offerGenerator.call(virtualMachineLease.hostname()));
                                        }
                                    },
                                    leaseReOfferDelaySecs, TimeUnit.SECONDS);
                        }
                    }
            )
            .withLeaseOfferExpirySecs(offerExpirySecs)
            .withMaxOffersToReject(maxOffersToReject)
            .build();
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:27,代码来源:OfferRejectionsTest.java

示例10: testExpiryOfLease

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
@Test
public void testExpiryOfLease() throws Exception {
    final AtomicInteger expireCount = new AtomicInteger();
    final TaskScheduler scheduler = new TaskScheduler.Builder()
            .withLeaseRejectAction(new Action1<VirtualMachineLease>() {
                @Override
                public void call(VirtualMachineLease virtualMachineLease) {
                    expireCount.incrementAndGet();
                }
            })
            .withLeaseOfferExpirySecs(1000000)
            .build();
    final VirtualMachineLease lease1 = LeaseProvider.getLeaseOffer("host1", 2, 2000, 1, 10);
    scheduler.scheduleOnce(Collections.<TaskRequest>emptyList(), Collections.singletonList(lease1));
    Thread.sleep(100);
    scheduler.expireLease(lease1.getId());
    List<TaskRequest> tasks = new ArrayList<>();
    tasks.add(TaskRequestProvider.getTaskRequest(2, 1000, 1));
    final SchedulingResult result = scheduler.scheduleOnce(tasks, Collections.<VirtualMachineLease>emptyList());
    Assert.assertEquals(0, result.getResultMap().size());
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:22,代码来源:OfferRejectionsTest.java

示例11: getSchedulingService

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
private TaskSchedulingService getSchedulingService(TaskQueue queue, TaskScheduler scheduler, long loopMillis,
                                                   long maxDelayMillis, Action1<SchedulingResult> resultCallback) {
    return new TaskSchedulingService.Builder()
            .withTaskQueue(queue)
            .withLoopIntervalMillis(loopMillis)
            .withMaxDelayMillis(maxDelayMillis)
            .withPreSchedulingLoopHook(new Action0() {
                @Override
                public void call() {
                    //System.out.println("Pre-scheduling hook");
                }
            })
            .withSchedulingResultCallback(resultCallback)
            .withTaskScheduler(scheduler)
            .build();
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:17,代码来源:TaskSchedulingServiceTest.java

示例12: clonePseudoVMsForGroups

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
@Test
public void clonePseudoVMsForGroups() throws Exception {
    AutoScaleRule rule = getAutoScaleRule(attributeVal1, 4);
    Action1<VirtualMachineLease> leaseRejectAction = l -> {};
    final ConcurrentMap<String, String> vmIdTohostNames = new ConcurrentHashMap<>();
    final ConcurrentMap<String, String> leasesToHostnames = new ConcurrentHashMap<>();
    final Map<String, AssignableVirtualMachine> avms = new HashMap<>();
    final TaskTracker taskTracker = new TaskTracker();
    VMCollection vms = createVmCollection(vmIdTohostNames, leasesToHostnames, taskTracker, avms);
    for (int i=0; i < rule.getMaxSize()-1; i++) {
        vms.addLease(LeaseProvider.getLeaseOffer("host"+i, 4, 4000,
                0, 0, ports, attributes1, Collections.singletonMap("GPU", 1.0)));
    }
    for (AssignableVirtualMachine avm: avms.values())
        avm.updateCurrTotalLease();
    final Map<String, List<String>> map = vms.clonePseudoVMsForGroups(
            Collections.singletonMap(rule.getRuleName(), 6), s -> rule,
            lease -> true
    );
    Assert.assertNotNull(map);
    Assert.assertEquals(1, map.size());
    Assert.assertEquals(rule.getRuleName(), map.keySet().iterator().next());
    Assert.assertEquals(1, map.values().iterator().next().size());
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:25,代码来源:VMCollectionTest.java

示例13: createVmCollection

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
private VMCollection createVmCollection(ConcurrentMap<String, String> vmIdTohostNames,
                                        ConcurrentMap<String, String> leasesToHostnames, TaskTracker taskTracker,
                                        Map<String, AssignableVirtualMachine> avms) {
    Action1<VirtualMachineLease> leaseRejectAction = l -> {};
    return new VMCollection(s -> {
        AssignableVirtualMachine avm = new AssignableVirtualMachine(
                vmIdTohostNames,
                leasesToHostnames,
                s,
                leaseRejectAction,
                2,
                taskTracker,
                false
        );
        avms.put(s, avm);
        return avm;
    }, AutoScalerTest.hostAttrName);
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:19,代码来源:VMCollectionTest.java

示例14: getTaskSchedulerWithAutoscale

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
private TaskScheduler getTaskSchedulerWithAutoscale(boolean useBinPacking, Action1<AutoScaleAction> callback, AutoScaleRule... rules) {
    final TaskScheduler.Builder builder = new TaskScheduler.Builder()
            .withLeaseOfferExpirySecs(1000000)
            .withLeaseRejectAction(new Action1<VirtualMachineLease>() {
                @Override
                public void call(VirtualMachineLease virtualMachineLease) {
                    System.out.println("Rejecting offer on host " + virtualMachineLease.hostname());
                }
            })
            .withAutoScaleByAttributeName(hostAttrName)
            .withFitnessGoodEnoughFunction(new Func1<Double, Boolean>() {
                @Override
                public Boolean call(Double aDouble) {
                    return aDouble > 1.0;
                }
            });
    if(callback!=null && rules!=null) {
        builder.withAutoScalerCallback(callback);
        for (AutoScaleRule r : rules)
            builder.withAutoScaleRule(r);
    }
    if(useBinPacking)
        builder
                .withFitnessCalculator(BinPackingFitnessCalculators.cpuMemBinPacker);
    return builder.build();
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:27,代码来源:ResourceSetsTests.java

示例15: getScheduler

import com.netflix.fenzo.functions.Action1; //导入依赖的package包/类
private TaskScheduler getScheduler() {
    Map<String, ResAllocs> resAllocs = new HashMap<>();
    resAllocs.put(grp1, ResAllocsProvider.create(grp1, 4, 4000, Double.MAX_VALUE, Double.MAX_VALUE));
    resAllocs.put(grp2, ResAllocsProvider.create(grp2, 8, 8000, Double.MAX_VALUE, Double.MAX_VALUE));
    return new TaskScheduler.Builder()
            .withInitialResAllocs(resAllocs)
            .withFitnessCalculator(BinPackingFitnessCalculators.cpuBinPacker)
            .withLeaseOfferExpirySecs(3600)
            .withLeaseRejectAction(new Action1<VirtualMachineLease>() {
                @Override
                public void call(VirtualMachineLease lease) {
                    Assert.fail("Unexpected to reject lease " + lease.hostname());
                }
            })
            .build();
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:17,代码来源:ResAllocsTests.java


注:本文中的com.netflix.fenzo.functions.Action1类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。