org.apache.reef.util.Optional.ofNullable()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中org.apache.reef.util.Optional.ofNullable()方法的一些代码示例,展示了Optional.ofNullable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Optional.ofNullable()方法的具体详情如下:
包路径:org.apache.reef.util.Optional
类名称:Optional
方法名:ofNullable

Optional.ofNullable介绍

暂无

代码示例

代码示例来源:origin: org.apache.reef/reef-common

private LauncherStatus(final State state, final Throwable ex) {
 this.state = state;
 this.error = Optional.ofNullable(ex);
}

代码示例来源:origin: org.apache.reef/reef-common

CloseEventImpl(final byte[] theBytes) {
 this.value = Optional.ofNullable(theBytes);
}

代码示例来源:origin: org.apache.reef/reef-common

SuspendEventImpl(final byte[] theBytes) {
 this.value = Optional.ofNullable(theBytes);
}

代码示例来源:origin: org.apache.reef/reef-common

DriverMessageImpl(final byte[] theBytes) {
 this.value = Optional.ofNullable(theBytes);
}

代码示例来源:origin: org.apache.reef/reef-runtime-local

/**
 * @param envName
 * @return the value of the environment variable, if there is one.
 */
private static Optional<String> getEnv(final String envName) {
 return Optional.ofNullable(System.getenv(envName));
}

代码示例来源:origin: org.apache.reef/reef-common

/**
 * @param evaluatorId
 * @return the EvaluatorManager for the given id, if one exists.
 */
public synchronized Optional<EvaluatorManager> get(final String evaluatorId) {
 return Optional.ofNullable(this.evaluators.get(evaluatorId));
}

代码示例来源:origin: org.apache.reef/reef-runtime-yarn

/**
 * @param containerId
 * @return the Container stored under this containerId or an empty Optional.
 */
synchronized Optional<Container> getOptional(final String containerId) {
 return Optional.ofNullable(this.containers.get(containerId));
}

代码示例来源:origin: org.apache.reef/reef-common

private ResourceRequestEventImpl(final Builder builder) {
 this.resourceCount = BuilderUtils.notNull(builder.resourceCount);
 this.nodeNameList = BuilderUtils.notNull(builder.nodeNameList);
 this.rackNameList = BuilderUtils.notNull(builder.rackNameList);
 this.memorySize = Optional.ofNullable(builder.memorySize);
 this.priority = Optional.ofNullable(builder.priority);
 this.virtualCores = Optional.ofNullable(builder.virtualCores);
 this.relaxLocality = Optional.ofNullable(builder.relaxLocality);
 this.runtimeName = builder.runtimeName == null ? "" : builder.runtimeName;
}

代码示例来源:origin: org.apache.reef/reef-common

public synchronized void submitContextAndService(final String contextConf, final String serviceConf) {
 submitContextAndService(contextConf, Optional.ofNullable(serviceConf));
}

代码示例来源:origin: org.apache.reef/reef-common

private JobSubmissionEventImpl(final Builder builder) {
 this.identifier = BuilderUtils.notNull(builder.identifier);
 this.remoteId = BuilderUtils.notNull(builder.remoteId);
 this.configuration = BuilderUtils.notNull(builder.configuration);
 this.userName = BuilderUtils.notNull(builder.userName);
 this.globalFileSet = BuilderUtils.notNull(builder.globalFileSet);
 this.localFileSet = BuilderUtils.notNull(builder.localFileSet);
 this.driverMemory = Optional.ofNullable(builder.driverMemory);
 this.priority = Optional.ofNullable(builder.priority);
 this.preserveEvaluators = Optional.ofNullable(builder.preserveEvaluators);
 this.queue = Optional.ofNullable(builder.queue);
 this.maxApplicationSubmissions = Optional.ofNullable(builder.maxApplicationSubmissions);
}

代码示例来源:origin: org.apache.reef/reef-common

@Inject
ClientWireUp(final RemoteManager remoteManager,
       @Parameter(ClientPresent.class) final String clientPresent,
       final RuntimeErrorProtoHandler runtimeErrorProtoHandler,
       final JobStatusMessageHandler jobStatusMessageHandler) {
 this.remoteManager = Optional.ofNullable(remoteManager);
 this.runtimeErrorProtoHandler = runtimeErrorProtoHandler;
 this.jobStatusMessageHandler = jobStatusMessageHandler;
 this.isClientPresent = clientPresent.equals(ClientPresent.YES);
 LOG.log(Level.FINE, "Instantiated 'ClientWireUp'. Client present: " + this.isClientPresent());
}

代码示例来源:origin: org.apache.reef/reef-common

private RuntimeStatusEventImpl(final Builder builder) {
 this.name = BuilderUtils.notNull(builder.name);
 this.state = BuilderUtils.notNull(builder.state);
 this.containerAllocationList = BuilderUtils.notNull(builder.containerAllocationList);
 this.error = Optional.ofNullable(builder.error);
 this.outstandingContainerRequests = Optional.ofNullable(builder.outstandingContainerRequests);
}

代码示例来源:origin: org.apache.reef/reef-common

private ResourceStatusEventImpl(final Builder builder) {
 this.identifier = BuilderUtils.notNull(builder.identifier);
 this.state = BuilderUtils.notNull(builder.state);
 this.diagnostics = Optional.ofNullable(builder.diagnostics);
 this.exitCode = Optional.ofNullable(builder.exitCode);
 this.runtimeName = BuilderUtils.notNull(builder.identifier);
}

代码示例来源:origin: org.apache.reef/reef-common

/**
 * A constructor of ReefLoggingScope. It starts the timer and logs the msg
 *
 * @param logger
 * @param msg
 * @param params
 */
LoggingScopeImpl(final Logger logger, final Level logLevel, final String msg, final Object[] params) {
 this.logger = logger;
 this.logLevel = logLevel;
 this.msg = msg;
 this.params = params;
 stopWatch.start();
 this.optionalParams = Optional.ofNullable(params);
 if (logger.isLoggable(logLevel)) {
  final StringBuilder sb = new StringBuilder();
  log(sb.append(START_PREFIX).append(msg).toString());
 }
}

代码示例来源:origin: org.apache.reef/reef-common

private ResourceEventImpl(final Builder builder) {
 this.identifier = BuilderUtils.notNull(builder.identifier);
 this.resourceMemory = builder.recovery ? builder.resourceMemory : BuilderUtils.notNull(builder.resourceMemory);
 this.nodeId = builder.recovery ? builder.nodeId : BuilderUtils.notNull(builder.nodeId);
 this.virtualCores = Optional.ofNullable(builder.virtualCores);
 this.rackName = Optional.ofNullable(builder.rackName);
 this.runtimeName = BuilderUtils.notNull(builder.runtimeName);
}

代码示例来源:origin: apache/reef

/**
 * Must only be called once, by the thread that created this WrappedValue.
 * @return The value returned by valueFetcher
 */
public synchronized V loadAndGet() throws ExecutionException {
 try {
  value = Optional.ofNullable(valueFetcher.call());
 } catch (final Exception e) {
  throw new ExecutionException(e);
 } finally {
  writeTime = Optional.of(currentTime.now());
  this.notifyAll();
 }
 if (!value.isPresent()) {
  throw new ExecutionException(new NullPointerException("valueFetcher returned null"));
 } else {
  return value.get();
 }
}

代码示例来源:origin: org.apache.reef/reef-runtime-yarn

private static Optional<String> getUserBoundJobSubmissionDirectory(final Configuration configuration) {
 try {
  return Optional.ofNullable(Tang.Factory.getTang().newInjector(configuration)
    .getNamedInstance(DriverJobSubmissionDirectory.class));
 } catch (final InjectionException ex) {
  return Optional.empty();
 }
}

代码示例来源:origin: org.apache.reef/reef-common

private NodeDescriptorEventImpl(final Builder builder) {
 this.identifier = BuilderUtils.notNull(builder.identifier);
 this.hostName = BuilderUtils.notNull(builder.hostName);
 this.port = BuilderUtils.notNull(builder.port);
 this.memorySize = BuilderUtils.notNull(builder.memorySize);
 this.rackName = Optional.ofNullable(builder.rackName);
}

代码示例来源:origin: org.apache.reef/reef-common

void setResult(final byte[] result) {
 synchronized (this.heartBeatManager) {
  this.result = Optional.ofNullable(result);
  if (this.state == State.RUNNING) {
   this.setState(State.DONE);
  } else if (this.state == State.SUSPEND_REQUESTED) {
   this.setState(State.SUSPENDED);
  } else if (this.state == State.CLOSE_REQUESTED) {
   this.setState(State.DONE);
  }
  this.check();
  this.heartbeat();
 }
}

代码示例来源:origin: org.apache.reef/reef-common

private void onTaskFailed(final TaskStatusPOJO taskStatus) {
 assert State.FAILED == taskStatus.getState();
 final Optional<ActiveContext> evaluatorContext = Optional.<ActiveContext>of(this.context);
 final Optional<byte[]> bytes = Optional.ofNullable(getResult(taskStatus));
 final Optional<Throwable> exception = this.exceptionCodec.fromBytes(bytes);
 final String message = exception.isPresent() ? exception.get().getMessage() : "No message given";
 final Optional<String> description = Optional.empty();
 final FailedTask failedTask = new FailedTask(
   this.taskId, message, description, exception, bytes, evaluatorContext);
 this.messageDispatcher.onTaskFailed(failedTask);
 this.setState(State.FAILED);
}

相关文章

微信公众号

最新文章

更多