本文整理了Java中org.apache.reef.util.Optional.get()
方法的一些代码示例,展示了Optional.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Optional.get()
方法的具体详情如下:
包路径:org.apache.reef.util.Optional
类名称:Optional
方法名:get
暂无
代码示例来源:origin: org.apache.reef/reef-runtime-yarn
/**
* @return the registered registration.
*/
synchronized RegisterApplicationMasterResponse getRegistration() {
return registration.get();
}
代码示例来源:origin: org.apache.reef/reef-utils
public synchronized V waitAndGet() {
while (!value.isPresent()) {
try {
this.wait();
} catch (final InterruptedException ignored) {
// Ignore, as while loop will be re-entered
}
}
return value.get();
}
}
代码示例来源:origin: org.apache.reef/reef-utils
/**
* @param other
* @return the value of this Optional or other, if no value exists.
*/
public T orElse(final T other) {
if (isPresent()) {
return this.get();
} else {
return other;
}
}
代码示例来源:origin: apache/reef
/**
* @param other
* @return the value of this Optional or other, if no value exists.
*/
public T orElse(final T other) {
if (isPresent()) {
return this.get();
} else {
return other;
}
}
代码示例来源:origin: apache/reef
public synchronized V waitAndGet() {
while (!value.isPresent()) {
try {
this.wait();
} catch (final InterruptedException ignored) {
// Ignore, as while loop will be re-entered
}
}
return value.get();
}
}
代码示例来源:origin: org.apache.reef/reef-utils
private void expireEntriesAtTime(final long now) {
for (final Entry<K, WrappedValue<V>> entry : internalMap.entrySet()) {
if (entry.getValue() != null) {
final Optional<Long> writeTime = entry.getValue().getWriteTime();
if (writeTime.isPresent() && writeTime.get() + timeoutMillis < now) {
invalidate(entry.getKey());
}
}
}
}
代码示例来源:origin: apache/reef
private void expireEntriesAtTime(final long now) {
for (final Entry<K, WrappedValue<V>> entry : internalMap.entrySet()) {
if (entry.getValue() != null) {
final Optional<Long> writeTime = entry.getValue().getWriteTime();
if (writeTime.isPresent() && writeTime.get() + timeoutMillis < now) {
invalidate(entry.getKey());
}
}
}
}
代码示例来源:origin: org.apache.reef/reef-common
/**
* Closes the remote manager, if there was one.
*/
synchronized void close() {
if (this.remoteManager.isPresent()) {
try {
this.remoteManager.get().close();
} catch (final Exception e) {
LOG.log(Level.WARNING, "Exception while shutting down the RemoteManager.", e);
}
}
}
}
代码示例来源:origin: org.apache.reef/reef-common
synchronized void performWireUp() {
if (this.isWired) {
throw new IllegalStateException("performWireUp is only to be called once.");
}
if (this.remoteManager.isPresent()) {
LOG.log(Level.FINEST, "Wiring up communications channels to the Driver.");
final RemoteManager rm = this.remoteManager.get();
rm.registerHandler(ReefServiceProtos.RuntimeErrorProto.class, this.runtimeErrorProtoHandler);
rm.registerHandler(ReefServiceProtos.JobStatusProto.class, this.jobStatusMessageHandler);
LOG.log(Level.FINE, "Wired up communications channels to the Driver.");
}
this.isWired = true;
}
代码示例来源:origin: org.apache.reef/reef-io
private static AvroActiveContext unwrapOptionalActiveContext(final Optional<ActiveContext> optionalActiveContext) {
if (optionalActiveContext.isPresent()) {
return toAvroActiveContext(optionalActiveContext.get());
}
return null;
}
代码示例来源:origin: org.apache.reef/reef-common
@Override
public String toString() {
if (this.error.isPresent()) {
return this.state + "(" + this.error.get() + ")";
} else {
return this.state.toString();
}
}
代码示例来源:origin: org.apache.reef/reef-common
synchronized String getRemoteManagerIdentifier() {
if (!this.isClientPresent() || !this.remoteManager.isPresent()) {
throw new RuntimeException("No need to setup the remote manager.");
} else {
return this.remoteManager.get().getMyIdentifier();
}
}
代码示例来源:origin: org.apache.reef/reef-runtime-yarn
private synchronized Resource getResource(final ResourceRequestEvent resourceRequestEvent) {
final Resource result = Records.newRecord(Resource.class);
final int memory = getMemory(resourceRequestEvent.getMemorySize().get());
final int core = resourceRequestEvent.getVirtualCores().get();
LOG.log(Level.FINEST, "Resource requested: memory = {0}, virtual core count = {1}.", new Object[]{memory, core});
result.setMemory(memory);
result.setVirtualCores(core);
return result;
}
代码示例来源: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
private synchronized void onRMFailure(final RuntimeStatusEvent runtimeStatusEvent) {
assert runtimeStatusEvent.getState() == State.FAILED;
this.resourceManagerErrorHandler.onNext(runtimeStatusEvent.getError().get());
}
代码示例来源:origin: org.apache.reef/reef-runtime-hdinsight
/**
* Extracts the resource demands from the jobSubmissionEvent.
*/
private Resource getResource(
final JobSubmissionEvent jobSubmissionEvent) {
return new Resource()
.setMemory(jobSubmissionEvent.getDriverMemory().get())
.setvCores(1);
}
代码示例来源:origin: org.apache.reef/reef-runtime-yarn
/**
* NM Callback: NM accepts the starting container request.
* @param containerId ID of a new container being started.
* @param stringByteBufferMap a Map between the auxiliary service names and their outputs. Not used.
*/
@Override
public void onContainerStarted(final ContainerId containerId, final Map<String, ByteBuffer> stringByteBufferMap) {
final Optional<Container> container = this.containers.getOptional(containerId.toString());
if (container.isPresent()) {
this.nodeManager.getContainerStatusAsync(containerId, container.get().getNodeId());
}
}
代码示例来源: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);
}
代码示例来源:origin: org.apache.reef/reef-runtime-hdinsight
/**
* Assembles the command to execute the Driver in list form.
*/
private List<String> getCommandList(
final JobSubmissionEvent jobSubmissionEvent) {
return new JavaLaunchCommandBuilder()
.setJavaPath("%JAVA_HOME%/bin/java")
.setConfigurationFilePaths(Collections.singletonList(this.filenames.getDriverConfigurationPath()))
.setClassPath(this.classpath.getDriverClasspath())
.setMemory(jobSubmissionEvent.getDriverMemory().get())
.setStandardErr(ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/" + this.filenames.getDriverStderrFileName())
.setStandardOut(ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/" + this.filenames.getDriverStdoutFileName())
.build();
}
内容来源于网络,如有侵权,请联系作者删除!