本文整理汇总了Java中org.apache.reef.driver.evaluator.EvaluatorDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java EvaluatorDescriptor类的具体用法?Java EvaluatorDescriptor怎么用?Java EvaluatorDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EvaluatorDescriptor类属于org.apache.reef.driver.evaluator包,在下文中一共展示了EvaluatorDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateMockedEvaluator
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
/**
* Generate mocked {@link AllocatedEvaluator}, which provides {@code getId()} and {@code submitContext()} methods.
* @param numCores the number of cores
* @param memSizeInMB the memory size in MegaBytes
* @return mocked {@link AllocatedEvaluator}
*/
private AllocatedEvaluator generateMockedEvaluator(final int numCores, final int memSizeInMB) {
final String evalId = EVAL_PREFIX + evalIndexCounter.getAndIncrement();
final AllocatedEvaluator mockedEvaluator = mock(AllocatedEvaluator.class);
when(mockedEvaluator.getId()).thenReturn(evalId);
doAnswer(new Answer() {
@Override
public Object answer(final InvocationOnMock invocationOnMock) throws InjectionException {
final Configuration conf = (Configuration) invocationOnMock.getArguments()[0];
eventStage.onNext(generateMockedContext(conf, evalId));
return null;
}
}).when(mockedEvaluator).submitContext(any(Configuration.class));
final EvaluatorDescriptor mockedEvalDescriptor = mock(EvaluatorDescriptor.class);
when(mockedEvalDescriptor.getNumberOfCores()).thenReturn(numCores);
when(mockedEvalDescriptor.getMemory()).thenReturn(memSizeInMB);
when(mockedEvaluator.getEvaluatorDescriptor()).thenReturn(mockedEvalDescriptor);
return mockedEvaluator;
}
示例2: EvaluatorContext
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
public EvaluatorContext(final String contextIdentifier,
final String evaluatorIdentifier,
final EvaluatorDescriptor evaluatorDescriptor,
final Optional<String> parentID,
final ConfigurationSerializer configurationSerializer,
final ContextControlHandler contextControlHandler,
final EvaluatorMessageDispatcher messageDispatcher,
final ExceptionCodec exceptionCodec,
final ContextRepresenters contextRepresenters) {
this.contextIdentifier = contextIdentifier;
this.evaluatorIdentifier = evaluatorIdentifier;
this.evaluatorDescriptor = evaluatorDescriptor;
this.parentID = parentID;
this.configurationSerializer = configurationSerializer;
this.contextControlHandler = contextControlHandler;
this.exceptionCodec = exceptionCodec;
this.contextRepresenters = contextRepresenters;
LOG.log(Level.FINE, "Instantiated 'EvaluatorContext'");
}
示例3: ContextFactory
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
@Inject
ContextFactory(@Parameter(EvaluatorManager.EvaluatorIdentifier.class) final String evaluatorId,
@Parameter(EvaluatorManager.EvaluatorDescriptorName.class)
final EvaluatorDescriptor evaluatorDescriptor,
final ConfigurationSerializer configurationSerializer,
final ExceptionCodec exceptionCodec,
final EvaluatorMessageDispatcher messageDispatcher,
final ContextControlHandler contextControlHandler,
final InjectionFuture<ContextRepresenters> contextRepresenters) {
this.evaluatorId = evaluatorId;
this.evaluatorDescriptor = evaluatorDescriptor;
this.configurationSerializer = configurationSerializer;
this.exceptionCodec = exceptionCodec;
this.messageDispatcher = messageDispatcher;
this.contextControlHandler = contextControlHandler;
this.contextRepresenters = contextRepresenters;
}
示例4: onNext
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
@Override
public void onNext(final CompletedTask task) {
final EvaluatorDescriptor e = task.getActiveContext().getEvaluatorDescriptor();
final String msg = "Task completed " + task.getId() + " on node " + e;
LOG.info(msg);
jobMessageObserver.sendMessageToClient(CODEC_STR.encode(msg));
runningTasks.remove(task.getId());
task.getActiveContext().close();
final boolean noTasks;
synchronized (suspendedTasks) {
LOG.log(Level.INFO, "Tasks running: {0} suspended: {1}", new Object[]{
runningTasks.size(), suspendedTasks.size()});
noTasks = runningTasks.isEmpty() && suspendedTasks.isEmpty();
}
if (noTasks) {
LOG.info("All tasks completed; shutting down.");
}
}
示例5: writeEvaluatorsWebOutput
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
/**
* Get all evaluator ids and send it back to response so that can be displayed on web.
*
* @param response
* @throws IOException
*/
private void writeEvaluatorsWebOutput(final HttpServletResponse response) throws IOException {
LOG.log(Level.INFO, "HttpServerReefEventHandler writeEvaluatorsWebOutput is called");
final PrintWriter writer = response.getWriter();
writer.println("<h1>Evaluators:</h1>");
for (final Map.Entry<String, EvaluatorDescriptor> entry
: this.reefStateManager.getEvaluators().entrySet()) {
final String key = entry.getKey();
final EvaluatorDescriptor descriptor = entry.getValue();
writer.println("Evaluator Id: " + key);
writer.write("<br/>");
writer.println("Evaluator Name: " + descriptor.getNodeDescriptor().getName());
writer.write("<br/>");
}
writer.write("<br/>");
writer.println("Total number of Evaluators: " + this.reefStateManager.getEvaluators().size());
writer.write("<br/>");
writer.println(String.format("Driver Start Time:[%s]", this.reefStateManager.getStartTime()));
}
示例6: toAvro
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
/**
* Build AvroEvaluatorList object.
*/
@Override
public AvroEvaluatorList toAvro(
final Map<String, EvaluatorDescriptor> evaluatorMap,
final int totalEvaluators, final String startTime) {
final List<AvroEvaluatorEntry> evaluatorEntities = new ArrayList<>();
for (final Map.Entry<String, EvaluatorDescriptor> entry : evaluatorMap.entrySet()) {
final EvaluatorDescriptor descriptor = entry.getValue();
evaluatorEntities.add(AvroEvaluatorEntry.newBuilder()
.setId(entry.getKey())
.setName(descriptor.getNodeDescriptor().getName())
.build());
}
return AvroEvaluatorList.newBuilder()
.setEvaluators(evaluatorEntities)
.setTotal(totalEvaluators)
.setStartTime(startTime != null ? startTime : new Date().toString())
.build();
}
示例7: evaluatorInfoSerializerInjectionTest
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
@Test
public void evaluatorInfoSerializerInjectionTest() {
try {
final EvaluatorInfoSerializer serializer =
Tang.Factory.getTang().newInjector().getInstance(EvaluatorInfoSerializer.class);
final List<String> ids = new ArrayList<>();
ids.add("abc");
final EvaluatorDescriptor evaluatorDescriptor =
Tang.Factory.getTang().newInjector(EvaluatorDescriptorConfig.CONF.build())
.getInstance(EvaluatorDescriptor.class);
final Map<String, EvaluatorDescriptor> data = new HashMap<>();
data.put("abc", evaluatorDescriptor);
final AvroEvaluatorsInfo evaluatorInfo = serializer.toAvro(ids, data);
final String evaluatorInfoString = serializer.toString(evaluatorInfo);
Assert.assertEquals(evaluatorInfoString, "{\"evaluatorsInfo\":[{\"evaluatorId\":\"abc\",\"nodeId\":\"\"," +
"\"nodeName\":\"mock\",\"memory\":64,\"type\":\"CLR\",\"internetAddress\":\"\",\"runtimeName\":\"Local\"}]}");
} catch (final InjectionException e) {
Assert.fail("Not able to inject EvaluatorInfoSerializer");
}
}
示例8: evaluatorListSerializerInjectionTest
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
@Test
public void evaluatorListSerializerInjectionTest() {
try {
final EvaluatorListSerializer serializer =
Tang.Factory.getTang().newInjector().getInstance(EvaluatorListSerializer.class);
final List<String> ids = new ArrayList<>();
ids.add("abc");
final EvaluatorDescriptor evaluatorDescriptor =
Tang.Factory.getTang().newInjector(EvaluatorDescriptorConfig.CONF.build())
.getInstance(EvaluatorDescriptor.class);
final Map<String, EvaluatorDescriptor> data = new HashMap<>();
data.put("abc", evaluatorDescriptor);
final AvroEvaluatorList evaluatorList = serializer.toAvro(data, 1, "xxxxxx");
final String evaluatorListString = serializer.toString(evaluatorList);
Assert.assertEquals(evaluatorListString,
"{\"evaluators\":[{\"id\":\"abc\",\"name\":\"mock\"}],\"total\":1,\"startTime\":\"xxxxxx\"}");
} catch (final InjectionException e) {
Assert.fail("Not able to inject EvaluatorListSerializer");
}
}
示例9: setUp
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
@Before
public void setUp() throws InjectionException {
final Tang tang = Tang.Factory.getTang();
final Configuration configuration = tang.newConfigurationBuilder()
.bindImplementation(EvaluatorDescriptor.class, MockEvaluatorDescriptor.class)
.bindImplementation(NodeDescriptor.class, MockNodeDescriptor.class)
.bindImplementation(EvaluatorProcessFactory.class, CLRProcessFactory.class)
.bindNamedParameter(RemoteConfiguration.ManagerName.class, "REEF_TEST_REMOTE_MANAGER")
.bindNamedParameter(RemoteConfiguration.MessageCodec.class, REEFMessageCodec.class)
.bindNamedParameter(JobIdentifier.class, "my job")
.build();
injector = tang.newInjector(configuration);
reefEventStateManager = injector.getInstance(ReefEventStateManager.class);
}
示例10: onNext
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
@Override
public void onNext(final AllocatedEvaluator allocatedEvaluator) {
final EvaluatorDescriptor evalDesc = allocatedEvaluator.getEvaluatorDescriptor();
assertEquals(evalDesc.getNumberOfCores(), numCores);
assertEquals(evalDesc.getMemory(), memSizeInMB);
finishedEvalCounter.countDown();
}
示例11: onNext
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
@Override
public void onNext(AllocatedEvaluator evaluator) {
EvaluatorDescriptor descriptor = evaluator.getEvaluatorDescriptor();
LOG.log(Level.INFO, String.format("New container received, id: %s, mem: %d, cores: %d",
evaluator.getId(), descriptor.getMemory(), descriptor.getNumberOfCores()));
Optional<HeronWorker> result;
HeronWorker worker;
synchronized (containerPlans) {
Set<HeronWorker> workersAwaitingAllocation = getWorkersAwaitingAllocation();
if (workersAwaitingAllocation.isEmpty()) {
LOG.log(Level.INFO, "Could not find any workers waiting for allocation, closing {0}",
evaluator.getId());
evaluator.close();
return;
}
result = findLargestFittingWorker(evaluator, workersAwaitingAllocation, true);
if (!result.isPresent()) {
LOG.warning("Could not find a fitting worker in awaiting workers");
// TODO may need counting of missed allocation
evaluator.close();
return;
}
worker = result.get();
LOG.info(String.format("Worker:%d, cores:%d, mem:%s fits in the allocated container",
worker.workerId, worker.cores, worker.mem));
workersAwaitingAllocation.remove(worker);
multiKeyWorkerMap.assignEvaluatorToWorker(worker, evaluator);
}
LOG.log(Level.INFO, "Activating container {0} for heron worker, id: {1}",
new Object[]{evaluator.getId(), worker.workerId});
Configuration context = createContextConfig(worker.workerId);
evaluator.submitContext(context);
}
示例12: verifyFittingContainer
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
private void verifyFittingContainer(Set<HeronMasterDriver.HeronWorker> containers,
int ram,
int cores,
int expectedContainer) {
EvaluatorDescriptor evaluatorDescriptor = mock(EvaluatorDescriptor.class);
AllocatedEvaluator mockEvaluator = mock(AllocatedEvaluator.class);
when(mockEvaluator.getEvaluatorDescriptor()).thenReturn(evaluatorDescriptor);
when(evaluatorDescriptor.getMemory()).thenReturn(ram);
when(evaluatorDescriptor.getNumberOfCores()).thenReturn(cores);
Optional<HeronMasterDriver.HeronWorker> worker =
spyDriver.findLargestFittingWorker(mockEvaluator, containers, false);
assertTrue(worker.isPresent());
assertEquals(expectedContainer, worker.get().getWorkerId());
}
示例13: createMockEvaluator
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
private AllocatedEvaluator createMockEvaluator(String evaluatorId, int cores, ByteAmount mem) {
EvaluatorDescriptor descriptor = mock(EvaluatorDescriptor.class);
when(descriptor.getMemory()).thenReturn(((Long) mem.asMegabytes()).intValue());
when(descriptor.getNumberOfCores()).thenReturn(cores);
AllocatedEvaluator mockEvaluator = mock(AllocatedEvaluator.class);
when(mockEvaluator.getEvaluatorDescriptor()).thenReturn(descriptor);
when(mockEvaluator.getId()).thenReturn(evaluatorId);
return mockEvaluator;
}
示例14: FailedContextImpl
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
/**
* @param id Identifier of the entity that produced the error.
* @param message One-line error message.
* @param description Long error description.
* @param cause Java Exception that caused the error.
* @param data byte array that contains serialized version of the error.
* @param parentContext the parent context, if there is one.
* @param evaluatorDescriptor the descriptor of the Evaluator this context failed on.
* @param evaluatorID the id of the Evaluator this context failed on.
*/
public FailedContextImpl(final String id,
final String message,
final Optional<String> description,
final Optional<Throwable> cause,
final Optional<byte[]> data,
final Optional<ActiveContext> parentContext,
final EvaluatorDescriptor evaluatorDescriptor,
final String evaluatorID) {
super(id, message, description, cause, data);
this.parentContext = parentContext;
this.evaluatorDescriptor = evaluatorDescriptor;
this.evaluatorID = evaluatorID;
}
示例15: ClosedContextImpl
import org.apache.reef.driver.evaluator.EvaluatorDescriptor; //导入依赖的package包/类
/**
* @param parentContext the parent context.
* @param contextID the id of the closed context
* @param evaluatorId the id of the evaluator on which the context was closed
* @param evaluatorDescriptor the descriptor of the evaluator on which the context was closed.
*/
public ClosedContextImpl(final ActiveContext parentContext,
final String contextID,
final String evaluatorId,
final EvaluatorDescriptor evaluatorDescriptor) {
this.parentContext = parentContext;
this.contextID = contextID;
this.evaluatorId = evaluatorId;
this.evaluatorDescriptor = evaluatorDescriptor;
}