You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@twill.apache.org by chtyim <gi...@git.apache.org> on 2017/08/29 01:40:03 UTC

[GitHub] twill pull request #61: (TWILL-244) Make resource report available to TwillR...

GitHub user chtyim opened a pull request:

    https://github.com/apache/twill/pull/61

    (TWILL-244) Make resource report available to TwillRunnable

    - Make resource report available to TwillContext
      - Enhance tracker service to provide more resource related endpoints
        - Provide endpoints to fetch specific part of the report to reduce bandwidth
        - Added a ResourceReporter API to provide programmatic access
      - Make resource report available via TwillContext
    - Fixed a concurrent modification bug in ZKDiscoveryService.close

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/chtyim/twill feature/TWILL-244-resource-report-runnable

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/twill/pull/61.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #61
    
----
commit 53312962b33cc20c2f272b217d076730c498644d
Author: Terence Yim <ch...@apache.org>
Date:   2017-08-28T23:47:45Z

    (TWILL-244) Make resource report available to TwillContext
    
    - Enhance tracker service to provide more resource related endpoints
      - Provide endpoints to fetch specific part of the report to reduce
        bandwidth
      - Added a ResourceReporter API to provide programmatic access
    - Make resource report available via TwillContext

commit 31facdf2f7f93f06c8fd131960be6d4c52fd646e
Author: Terence Yim <ch...@apache.org>
Date:   2017-08-29T01:33:53Z

    Fix a concurrent modification bug in ZKDiscoveryService.close

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] twill pull request #61: (TWILL-244) Make resource report available to TwillR...

Posted by chtyim <gi...@git.apache.org>.
Github user chtyim commented on a diff in the pull request:

    https://github.com/apache/twill/pull/61#discussion_r137130751
  
    --- Diff: twill-core/src/main/java/org/apache/twill/internal/ResourceReportClient.java ---
    @@ -0,0 +1,116 @@
    +/*
    + * 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.twill.internal;
    +
    +import com.google.common.base.Charsets;
    +import org.apache.twill.api.ResourceReport;
    +import org.apache.twill.api.ResourceReporter;
    +import org.apache.twill.api.TwillRunResources;
    +import org.apache.twill.internal.json.ResourceReportAdapter;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.BufferedReader;
    +import java.io.IOException;
    +import java.io.InputStreamReader;
    +import java.io.Reader;
    +import java.lang.reflect.Type;
    +import java.net.URL;
    +import java.util.Collection;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +import javax.annotation.Nullable;
    +
    +/**
    + * A {@link ResourceReporter} that fetches reports from the given set of URLs.
    + */
    +public final class ResourceReportClient implements ResourceReporter {
    +
    +  private static final Logger LOG = LoggerFactory.getLogger(ResourceReportClient.class);
    +
    +  private final List<URL> resourceUrls;
    +
    +  public ResourceReportClient(List<URL> resourceUrls) {
    +    this.resourceUrls = resourceUrls;
    +  }
    +
    +  @Nullable
    +  @Override
    +  public ResourceReport getResourceReport() {
    +    for (URL url : resourceUrls) {
    +      try {
    +        return fetchURL(url, "", ResourceReport.class);
    +      } catch (IOException e) {
    +        // Just log a trace as it's ok to not able to fetch resource report
    +        LOG.trace("Exception raised when getting resource report from {}.", url, e);
    +      }
    +    }
    --- End diff --
    
    That's the contract of the `ResourceReporter`. If the report is not available for whatever reason, it'll just return `null` / empty collection.


---

[GitHub] twill pull request #61: (TWILL-244) Make resource report available to TwillR...

Posted by chtyim <gi...@git.apache.org>.
Github user chtyim closed the pull request at:

    https://github.com/apache/twill/pull/61


---

[GitHub] twill pull request #61: (TWILL-244) Make resource report available to TwillR...

Posted by anwar6953 <gi...@git.apache.org>.
Github user anwar6953 commented on a diff in the pull request:

    https://github.com/apache/twill/pull/61#discussion_r136476455
  
    --- Diff: twill-core/src/main/java/org/apache/twill/internal/ResourceReportClient.java ---
    @@ -0,0 +1,116 @@
    +/*
    + * 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.twill.internal;
    +
    +import com.google.common.base.Charsets;
    +import org.apache.twill.api.ResourceReport;
    +import org.apache.twill.api.ResourceReporter;
    +import org.apache.twill.api.TwillRunResources;
    +import org.apache.twill.internal.json.ResourceReportAdapter;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.BufferedReader;
    +import java.io.IOException;
    +import java.io.InputStreamReader;
    +import java.io.Reader;
    +import java.lang.reflect.Type;
    +import java.net.URL;
    +import java.util.Collection;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +import javax.annotation.Nullable;
    +
    +/**
    + * A {@link ResourceReporter} that fetches reports from the given set of URLs.
    + */
    +public final class ResourceReportClient implements ResourceReporter {
    +
    +  private static final Logger LOG = LoggerFactory.getLogger(ResourceReportClient.class);
    +
    +  private final List<URL> resourceUrls;
    +
    +  public ResourceReportClient(List<URL> resourceUrls) {
    +    this.resourceUrls = resourceUrls;
    +  }
    +
    +  @Nullable
    +  @Override
    +  public ResourceReport getResourceReport() {
    +    for (URL url : resourceUrls) {
    +      try {
    +        return fetchURL(url, "", ResourceReport.class);
    +      } catch (IOException e) {
    +        // Just log a trace as it's ok to not able to fetch resource report
    +        LOG.trace("Exception raised when getting resource report from {}.", url, e);
    +      }
    +    }
    --- End diff --
    
    even if all urls fail to fetch - why is that ok?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---