Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28472

Re: Upload using java nio

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.CARNet.hr!Iskon!garrison.bnet.hr!gregory.BNet.hr!not-for-mail
From Josip Almasi <joe@vrspace.org>
Newsgroups comp.lang.java.programmer
Subject Re: Upload using java nio
Date Wed, 14 May 2014 13:46:14 +0200
Organization B.net Hrvatska d.o.o.
Lines 35
Message-ID <lkvl26$vls$1@gregory.bnet.hr> (permalink)
References <459ec56a-b369-4261-b819-a4f232362f74@googlegroups.com>
NNTP-Posting-Host cpe-94-253-176-38.zg.cable.xnet.hr
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace gregory.bnet.hr 1400067974 32444 94.253.176.38 (14 May 2014 11:46:14 GMT)
X-Complaints-To abuse@globalnet.hr
NNTP-Posting-Date Wed, 14 May 2014 11:46:14 +0000 (UTC)
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
In-Reply-To <459ec56a-b369-4261-b819-a4f232362f74@googlegroups.com>
Xref csiph.com comp.lang.java.programmer:28472

Show key headers only | View raw


On 05/13/2014 08:37 PM, William Lopes wrote:
> Hi, I'm building a network test with source code (basically) here: http://toolongdidntread.com/android/android-multipart-post-with-progress-bar/
>
> My server contains a php script that contains just a field with name = $_FILES['uploaded_file']['name']
>
> But, this java script file isn't very good, it is using the io lib, and I want change to the nio lib, because of the perfomance.

I gave up nio because it introduces a number of platform specific 
troubles. 'Troubles' being both OS and JVM impl dependent.
You may get OOM with bogus description.
IBM JVM gives more precise OOM explanation, like was it ENOMEM or 
ENOBUFS, which gives you more info on how to tune OS.

Furthermore, there's just a few nio methods that actually utilize proper 
OS functions in order to avoid unnecessary transfer between kernel mem 
and userspace mem.
IIRC, with sun jvm on linux, I've found exactly one nio method that 
actually does the job. And apache mina did not use it:> So neither did 
software using it, many many server software.
(netty does though)

I have no idea how android nio works.

But as the man said, nio is not faster than io - it all depends on other 
threads and their synchronization.
In your case, setProgress() is blocking and synchronized.
Blocking = transfer waits for bar to render.
Synchronized = slow.

Recommendiation:
Make a thread to update progress bar(s). Let it have non-blocking calls 
to update volatile/atomic internal counter(s). Use these calls instead 
of setProgress(). Make it sleep for 100-1000 ms, then render bar(s).

Regards...

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-13 11:37 -0700
  Re: Upload using java nio Arne Vajhøj <arne@vajhoej.dk> - 2014-05-13 20:37 -0400
    Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-13 18:38 -0700
    Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-13 18:38 -0700
      Re: Upload using java nio Arne Vajhøj <arne@vajhoej.dk> - 2014-05-13 22:00 -0400
        Re: Upload using java nio Arne Vajhøj <arne@vajhoej.dk> - 2014-05-13 22:08 -0400
          Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-13 19:35 -0700
            Re: Upload using java nio markspace <markspace@nospam.nospam> - 2014-05-13 20:22 -0700
              Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-14 11:35 -0700
  Re: Upload using java nio Josip Almasi <joe@vrspace.org> - 2014-05-14 13:46 +0200
    Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-14 11:38 -0700

csiph-web