reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (REEF-2025) A new module containing the new Java bridge
Date Tue, 05 Jun 2018 02:12:02 GMT

    [ https://issues.apache.org/jira/browse/REEF-2025?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16501186#comment-16501186
] 

ASF GitHub Bot commented on REEF-2025:
--------------------------------------

motus commented on a change in pull request #1466: [REEF-2025] A new module containing the
new Java bridge
URL: https://github.com/apache/reef/pull/1466#discussion_r192917786
 
 

 ##########
 File path: lang/java/reef-bridge-proto-java/src/main/java/org/apache/reef/bridge/driver/client/events/FailedContextBridge.java
 ##########
 @@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.reef.bridge.driver.client.events;
+
+import org.apache.reef.driver.context.ActiveContext;
+import org.apache.reef.driver.context.FailedContext;
+import org.apache.reef.driver.evaluator.EvaluatorDescriptor;
+import org.apache.reef.exception.EvaluatorException;
+import org.apache.reef.util.Optional;
+
+/**
+ * Failed context bridge.
+ */
+public final class FailedContextBridge implements FailedContext {
+
+  private final String contextId;
+
+  private final String evaluatorId;
+
+  private final String message;
+
+  private final EvaluatorDescriptor evaluatorDescriptor;
+
+  private final Optional<ActiveContext> parentContext;
+
+  private final Optional<Throwable> reason;
+
+  public FailedContextBridge(
+      final String contextId,
+      final String evaluatorId,
+      final String message,
+      final EvaluatorDescriptor evaluatorDescriptor,
+      final Optional<ActiveContext> parentContext,
+      final Optional<Throwable> reason) {
+    this.contextId = contextId;
+    this.evaluatorId = evaluatorId;
+    this.message = message;
+    this.evaluatorDescriptor = evaluatorDescriptor;
+    this.parentContext = parentContext;
+    this.reason = reason;
+  }
+
+  @Override
+  public Optional<ActiveContext> getParentContext() {
+    return this.parentContext;
+  }
+
+  @Override
+  public String getMessage() {
+    return this.message;
+  }
+
+  @Override
+  public Optional<String> getDescription() {
+    return Optional.of(message);
+  }
+
+  @Override
+  public Optional<Throwable> getReason() {
+    return this.reason;
+  }
+
+  @Override
+  public Optional<byte[]> getData() {
+    return Optional.empty();
+  }
+
+  @Override
+  public Throwable asError() {
+    return new EvaluatorException(this.evaluatorId, this.message);
+  }
+
+  @Override
+  public String getEvaluatorId() {
+    return this.evaluatorId;
+  }
+
+  @Override
+  public Optional<String> getParentId() {
+    return this.parentContext.isPresent() ?
+        Optional.of(this.parentContext.get().getId()) : Optional.<String>empty();
 
 Review comment:
   Hey, this is a monadic lift operation! How about we add something like this to `Optional`:
   ```java
   public abstract class LiftM<V> implements Callable<V> {
     protected final T value = Optional.this.value;
     public Optional<V> get() {
       if (isPresent()) {
         try {
           return ofNullable(call());
         } catch (final Exception ex) {
           throw new RuntimeException("Error in function " + this, ex);
         }
       }
       return empty();
     }
   }
   ```
   Then we can implement `getParentId()` as
   ```java
   return this.parentContext.new LiftM<String>() {
     @Override
     public String call() {
       return value.getId();
     }
   }.get();
   ```
   just kidding; please don't do it 😄 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> A new module containing the new Java bridge
> -------------------------------------------
>
>                 Key: REEF-2025
>                 URL: https://issues.apache.org/jira/browse/REEF-2025
>             Project: REEF
>          Issue Type: Sub-task
>          Components: REEF Bridge
>    Affects Versions: 0.17
>            Reporter: Tyson Condie
>            Assignee: Tyson Condie
>            Priority: Major
>             Fix For: 0.17
>
>
> This Jira introduces the module containing the new bridge. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message