You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Chris Nauroth (JIRA)" <ji...@apache.org> on 2012/10/25 01:08:11 UTC

[jira] [Created] (HADOOP-8982) TestSocketIOWithTimeout fails on Windows

Chris Nauroth created HADOOP-8982:
-------------------------------------

             Summary: TestSocketIOWithTimeout fails on Windows
                 Key: HADOOP-8982
                 URL: https://issues.apache.org/jira/browse/HADOOP-8982
             Project: Hadoop Common
          Issue Type: Bug
          Components: net
    Affects Versions: trunk-win
            Reporter: Chris Nauroth
            Assignee: Chris Nauroth


This is a possible race condition or difference in socket handling on Windows.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (HADOOP-8982) TestSocketIOWithTimeout fails on Windows

Posted by "Xuan Gong (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-8982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13506928#comment-13506928 ] 

Xuan Gong commented on HADOOP-8982:
-----------------------------------

	The failure of this test case is, i think, because the partial write is handled differently by mac and windows. We actually write the bytes to channels, the Pipe.SinkChannel we are using here implements a interface WritableByteChannel, from Java Doc about write function of this interface, it said "Some types of channels, depending upon their state, may write only some of the bytes or possibly none at all." That is one reason why I think the differnet OS may cause the failure.
	Bacially, this test opens a pipe channel, and the sink will keep writing to the channel with 4192 bytes each time. When the channel is full, sink will do the parial write(write 3000 bytes to the channel, the channel is full, then the remaining bytes in the Bytebuffer is 1192) when the test is running on the mac environment, on the other hand, when we run this test on the windows environment, if the channel can not fit for the full Bytebuffer size, it will not allow us to write part of it. That means, when we try to write 4192 bytes to the channel when the channel still has 3000 bytes empty size. We can not write at all. The remaining bytes in the Bytebuffer is still 4192. 
	When this partial wirte happens, we check the condition buf.capacity > buf.remaining or not, if yes, we will close the stream. So, that is why the stream is close on Mac environment, but still open in windows environment. So, the next time, when we try to write, we will not go expected "stream is close "exception at Windows environment. 
	So far, this is from my observations. So, the questions is whether the windows and mac handle parital write as I decribed previous ? If it is true, in order to fix this test failure. What we can do is add the function called tryToWriteOneByte() in SocketOutPutStream.java file, this function is only for test purpose.

public void tryToWriteOneByte(){
    try{
	write(1);
	writer.close();
    }catch(IOException e){
	//do nothing
    }
} 

	Calling this function will insert a byte to the channel, if we can do that, that means the channel is not full, and the partial write happens, so we need to close the stream. If we can not do that, we will catch a exception, that means last time we got the exception is not because the partial write is happened, is because the channel is full before we do the next 4192 bytes write.

	Since this test failure is happened on Windows, in the TestSocketIOWithTimeout.java, we can check whether the environment is Windows before we call this function. 
After doIO(null,out,TIMEOUT), we can do
if(System.getProperty("os.name").toLowerCase().indexOf("win")>=0){
	out.tryToWriteOneByte();
}
                
> TestSocketIOWithTimeout fails on Windows
> ----------------------------------------
>
>                 Key: HADOOP-8982
>                 URL: https://issues.apache.org/jira/browse/HADOOP-8982
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: net
>    Affects Versions: trunk-win
>            Reporter: Chris Nauroth
>            Assignee: Chris Nauroth
>
> This is a possible race condition or difference in socket handling on Windows.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (HADOOP-8982) TestSocketIOWithTimeout fails on Windows

Posted by "Chris Nauroth (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-8982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483707#comment-13483707 ] 

Chris Nauroth commented on HADOOP-8982:
---------------------------------------

{code}
Running org.apache.hadoop.net.TestSocketIOWithTimeout
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 5.016 sec <<< FAILURE!
testSocketIOWithTimeout(org.apache.hadoop.net.TestSocketIOWithTimeout)  Time elapsed: 5016 sec  <<< FAILURE!
java.lang.AssertionError: Did not throw
	at org.junit.Assert.fail(Assert.java:91)
	at org.apache.hadoop.net.TestSocketIOWithTimeout.testSocketIOWithTimeout(TestSocketIOWithTimeout.java:149)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
{code}

                
> TestSocketIOWithTimeout fails on Windows
> ----------------------------------------
>
>                 Key: HADOOP-8982
>                 URL: https://issues.apache.org/jira/browse/HADOOP-8982
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: net
>    Affects Versions: trunk-win
>            Reporter: Chris Nauroth
>            Assignee: Chris Nauroth
>
> This is a possible race condition or difference in socket handling on Windows.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira