hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ravi Prakash (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-10660) GraphiteSink should implement Closeable
Date Tue, 17 Jun 2014 08:49:02 GMT

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

Ravi Prakash commented on HADOOP-10660:
---------------------------------------

1. I should have picked it up in HADOOP-9704, but shouldn't setWriter be private? I'm fine
with doing that in a separate JIRA and assigning it to [~babakbehzad]
2. I wrote this test to check close(). Why does it not pass?
{noformat}
    @Test(expected=MetricsException.class)
    public void testCloseAndWrite() throws IOException {
      GraphiteSink sink = new GraphiteSink();
      List<MetricsTag> tags = new ArrayList<MetricsTag>();
      tags.add(new MetricsTag(MsInfo.Context, "all"));
      tags.add(new MetricsTag(MsInfo.Hostname, "host"));
      Set<AbstractMetric> metrics = new HashSet<AbstractMetric>();
      metrics.add(makeMetric("foo1", 1.25));
      metrics.add(makeMetric("foo2", 2.25));
      MetricsRecord record = new MetricsRecordImpl(MsInfo.Context, (long) 10000, tags, metrics);

      OutputStreamWriter writer = mock(OutputStreamWriter.class);
      ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);

      Log.info("Setting writer");
      sink.setWriter(writer);
      Log.info("Closing sink");
      sink.close();
      Log.info("Putting metrics");
      sink.putMetrics(record);
      Log.info("Put metrics successfully. This shouldn't have happened");
    }
{noformat}
3. [~Ted Yu] You are right. I couldn't find OutputStreamWriter making any guarantee about
closing the underlying stream, so we are fine there.

> GraphiteSink should implement Closeable
> ---------------------------------------
>
>                 Key: HADOOP-10660
>                 URL: https://issues.apache.org/jira/browse/HADOOP-10660
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Ted Yu
>            Assignee: Chen He
>         Attachments: HADOOP-10660-v2.patch, HADOOP-10660-v3.patch, HADOOP-10660.patch
>
>
> GraphiteSink wraps OutputStreamWriter around socket's output stream.
> Currently the socket is never closed.
> GraphiteSink should implement Closeable such that MetricsSystem can close the socket
when it is stopped.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message