distributedlog-commits 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] (DL-124) Use Java8 Future rather than twitter Future
Date Sat, 03 Jun 2017 11:12:04 GMT

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

ASF GitHub Bot commented on DL-124:
-----------------------------------

Github user jiazhai commented on a diff in the pull request:

    https://github.com/apache/incubator-distributedlog/pull/133#discussion_r119984743
  
    --- Diff: distributedlog-core/src/main/java/org/apache/distributedlog/impl/ZKLogSegmentMetadataStore.java
---
    @@ -350,40 +349,40 @@ public void process(WatchedEvent event) {
         }
     
         @Override
    -    public Future<LogSegmentMetadata> getLogSegment(String logSegmentPath) {
    +    public CompletableFuture<LogSegmentMetadata> getLogSegment(String logSegmentPath)
{
             return LogSegmentMetadata.read(zkc, logSegmentPath, skipMinVersionCheck);
         }
     
    -    Future<Versioned<List<String>>> zkGetLogSegmentNames(String logSegmentsPath,
Watcher watcher) {
    -        Promise<Versioned<List<String>>> result = new Promise<Versioned<List<String>>>();
    +    CompletableFuture<Versioned<List<String>>> zkGetLogSegmentNames(String
logSegmentsPath, Watcher watcher) {
    +        CompletableFuture<Versioned<List<String>>> result = new CompletableFuture<Versioned<List<String>>>();
             try {
                 zkc.get().getChildren(logSegmentsPath, watcher, this, result);
             } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
    -            result.setException(FutureUtils.zkException(e, logSegmentsPath));
    +            result.completeExceptionally(Utils.zkException(e, logSegmentsPath));
             } catch (InterruptedException e) {
    -            result.setException(FutureUtils.zkException(e, logSegmentsPath));
    +            result.completeExceptionally(Utils.zkException(e, logSegmentsPath));
             }
             return result;
         }
     
         @Override
         @SuppressWarnings("unchecked")
         public void processResult(int rc, String path, Object ctx, List<String> children,
Stat stat) {
    -        Promise<Versioned<List<String>>> result = ((Promise<Versioned<List<String>>>)
ctx);
    +        CompletableFuture<Versioned<List<String>>> result = ((CompletableFuture<Versioned<List<String>>>)
ctx);
             if (KeeperException.Code.OK.intValue() == rc) {
                 /** cversion: the number of changes to the children of this znode **/
                 ZkVersion zkVersion = new ZkVersion(stat.getCversion());
    -            result.setValue(new Versioned(children, zkVersion));
    +            result.complete(new Versioned(children, zkVersion));
             } else if (KeeperException.Code.NONODE.intValue() == rc) {
    -            result.setException(new LogNotFoundException("Log " + path + " not found"));
    +            result.completeExceptionally(new LogNotFoundException("Log " + path + " not
found"));
             } else {
    -            result.setException(new ZKException("Failed to get log segments from " +
path,
    +            result.completeExceptionally(new ZKException("Failed to get log segments
from " + path,
                         KeeperException.Code.get(rc)));
             }
         }
     
         @Override
    -    public Future<Versioned<List<String>>> getLogSegmentNames(String
logSegmentsPath,
    +    public CompletableFuture<Versioned<List<String>>> getLogSegmentNames(String
logSegmentsPath,
                                                                   LogSegmentNamesListener
listener) {
    --- End diff --
    
    Please also do the code alignment change here.


> Use Java8 Future rather than twitter Future
> -------------------------------------------
>
>                 Key: DL-124
>                 URL: https://issues.apache.org/jira/browse/DL-124
>             Project: DistributedLog
>          Issue Type: Bug
>    Affects Versions: 0.4.0
>            Reporter: Gerrit Sundaram
>            Assignee: Sijie Guo
>              Labels: help-wanted
>             Fix For: 0.5.0
>
>
> Since it is written in java, it would be good to leverage java8 future rather than introducing
dependencies on scala.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message