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

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

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

Optional.empty介绍

暂无

代码示例

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

@Override
 public Optional<ContextMessage> getMessage() {
  return Optional.empty();
 }
}

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

CloseEventImpl() {
 this.value = Optional.empty();
}

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

public SetOnce() {
 this.value = Optional.empty();
}

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

/**
 * Create a new ContextRuntime for the root context.
 *
 * @param serviceInjector      the serviceInjector to be used.
 * @param contextConfiguration the Configuration for this context.
 * @throws ContextClientCodeException if the context cannot be instantiated.
 */
ContextRuntime(final Injector serviceInjector,
        final Configuration contextConfiguration) throws ContextClientCodeException {
 this(serviceInjector, contextConfiguration, Optional.<ContextRuntime>empty());
 LOG.log(Level.FINEST, "Instantiating root context");
}

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

/**
 * Submit Context with configuration strings.
 * This method should be called from bridge and the configuration strings are
 * serialized at .Net side.
 * @param evaluatorConfiguration
 * @param contextConfiguration
 */
public void submitContext(final String evaluatorConfiguration, final String contextConfiguration) {
 launchWithConfigurationString(evaluatorConfiguration, contextConfiguration, Optional.<String>empty(),
   Optional.<String>empty());
}

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

/**
 * Called by the child context when it has been closed.
 */
private void resetChildContext() {
 synchronized (this.contextLifeCycle) {
  if (this.childContext.isPresent()) {
   this.childContext = Optional.empty();
  } else {
   throw new IllegalStateException("no child context set");
  }
 }
}

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

/**
 * @return An optional representing the given value, or an empty Optional.
 */
public static <T> Optional<T> ofNullable(final T value) {
 if (null == value) {
  return Optional.empty();
 } else {
  return Optional.of(value);
 }
}

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

@Inject
RootContextLauncher(@Parameter(RootContextConfiguration.class) final String rootContextConfiguration,
          final Injector injector, final ConfigurationSerializer configurationSerializer)
  throws IOException, BindException {
 this.injector = injector;
 this.configurationSerializer = configurationSerializer;
 this.rootContextConfiguration = this.configurationSerializer.fromString(rootContextConfiguration);
 this.rootServiceConfiguration = Optional.empty();
 this.initialTaskConfiguration = Optional.empty();
}

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

/**
 * @return An optional representing the given value, or an empty Optional.
 */
public static <T> Optional<T> ofNullable(final T value) {
 if (null == value) {
  return Optional.empty();
 } else {
  return Optional.of(value);
 }
}

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

@Override
public Optional<Throwable> fromBytes(final byte[] bytes) {
 try {
  return Optional.<Throwable>of((Throwable) SerializationUtils.deserialize(bytes));
 } catch (SerializationException | IllegalArgumentException e) {
  LOG.log(Level.FINE, "Unable to deserialize a Throwable.", e);
  return Optional.empty();
 }
}

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

@Override
public void submitContextAndTask(final Configuration contextConfiguration,
                 final Configuration taskConfiguration) {
 launch(contextConfiguration, Optional.<Configuration>empty(), Optional.of(taskConfiguration));
}

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

/**
 * Create a new Failure object out of protobuf data.
 *
 * @param error Error message as a protocol buffers object.
 */
public FailedRuntime(final RuntimeErrorProto error) {
 super(error.getIdentifier(), error.getMessage(), Optional.<String>empty(), Optional.of(getThrowable(error)),
   Optional.<byte[]>empty());
}

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

@Override
public void submitContextAndService(final Configuration contextConfiguration,
                  final Configuration serviceConfiguration) {
 launch(contextConfiguration, Optional.of(serviceConfiguration), Optional.<Configuration>empty());
}

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

/**
 * Submit Context and Service with configuration strings.
 * This method should be called from bridge and the configuration strings are
 * serialized at .Net side.
 * @param evaluatorConfiguration
 * @param contextConfiguration
 * @param serviceConfiguration
 */
public void submitContextAndService(final String evaluatorConfiguration,
                  final String contextConfiguration,
                  final String serviceConfiguration) {
 launchWithConfigurationString(evaluatorConfiguration, contextConfiguration,
   Optional.of(serviceConfiguration), Optional.<String>empty());
}

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

@Override
public Optional<Throwable> fromBytes(final Optional<byte[]> bytes) {
 if (bytes.isPresent()) {
  return this.fromBytes(bytes.get());
 } else {
  return Optional.empty();
 }
}

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

@Inject
RootContextLauncher(@Parameter(RootContextConfiguration.class) final String rootContextConfiguration,
          final Injector injector,
          @Parameter(RootServiceConfiguration.class) final String rootServiceConfiguration,
          final ConfigurationSerializer configurationSerializer) throws IOException, BindException {
 this.injector = injector;
 this.configurationSerializer = configurationSerializer;
 this.rootContextConfiguration = this.configurationSerializer.fromString(rootContextConfiguration);
 this.rootServiceConfiguration = Optional.of(this.configurationSerializer.fromString(rootServiceConfiguration));
 this.initialTaskConfiguration = Optional.empty();
}

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

@Inject
RootContextLauncher(final Injector injector,
          @Parameter(RootContextConfiguration.class) final String rootContextConfiguration,
          @Parameter(InitialTaskConfiguration.class) final String initialTaskConfiguration,
          final ConfigurationSerializer configurationSerializer) throws IOException, BindException {
 this.injector = injector;
 this.configurationSerializer = configurationSerializer;
 this.rootContextConfiguration = this.configurationSerializer.fromString(rootContextConfiguration);
 this.rootServiceConfiguration = Optional.empty();
 this.initialTaskConfiguration = Optional.of(this.configurationSerializer.fromString(initialTaskConfiguration));
}

代码示例来源: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

@Override
public Optional<String> getParentId() {
 if (this.getParentContext().isPresent()) {
  return Optional.of(this.getParentContext().get().getId());
 } else {
  return Optional.empty();
 }
}

代码示例来源: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);
}

相关文章