Regarding NIO SocketChannel and SelectorKey

Basics: I have a SocketChannel which is supposed to read and write.
Context: My query is regarding the SelectoinKey for this channel. I understand that While I am writing onto this channel I would set the Key to OP_WRITE and soon after the write function is completed I should reset the SelectionKey to OP_READ
Querry: amid the write operation, if there is some data coming from the remote entity onto the same channel then the SelectionKey being in OP_WRITE mode will I lose the incoming data?
thanks in advance
Amit

While I am writing onto this channel I would set the
Key to OP_WRITE and soon after the write function is
completed I should reset the SelectionKey to OP_READNo. When you have data to write and you can't write it (i.e. you get a return value of zero from the channel.write() call) you should set the key to OP_WRITE, and when this event fires in the Selector (key.isWritable()) retry the write. When it succeeds completely, you then set the key back to OP_READ.
Query: amid the write operation, if there is
some data coming from the remote entity onto the same
channel then the SelectionKey being in OP_WRITE mode
will I lose the incoming data?No.

Similar Messages

  • Nio ByteBuffer and memory-mapped file size limitation

    I have a question/issue regarding ByteBuffer and memory-mapped file size limitations. I recently started using NIO FileChannels and ByteBuffers to store and process buffers of binary data. Until now, the maximum individual ByteBuffer/memory-mapped file size I have needed to process was around 80MB.
    However, I need to now begin processing larger buffers of binary data from a new source. Initial testing with buffer sizes above 100MB result in IOExceptions (java.lang.OutOfMemoryError: Map failed).
    I am using 32bit Windows XP; 2GB of memory (typically 1.3 to 1.5GB free); Java version 1.6.0_03; with -Xmx set to 1280m. Decreasing the Java heap max size down 768m does result in the ability to memory map larger buffers to files, but never bigger than roughly 500MB. However, the application that uses this code contains other components that require the -xMx option to be set to 1280.
    The following simple code segment executed by itself will produce the IOException for me when executed using -Xmx1280m. If I use -Xmx768m, I can increase the buffer size up to around 300MB, but never to a size that I would think I could map.
    try
    String mapFile = "C:/temp/" + UUID.randomUUID().toString() + ".tmp";
    FileChannel rwChan = new RandomAccessFile( mapFile, "rw").getChannel();
    ByteBuffer byteBuffer = rwChan.map( FileChannel.MapMode.READ_WRITE,
    0, 100000000 );
    rwChan.close();
    catch( Exception e )
    e.printStackTrace();
    I am hoping that someone can shed some light on the factors that affect the amount of data that may be memory mapped to/in a file at one time. I have investigated this for some time now and based on my understanding of how memory mapped files are supposed to work, I would think that I could map ByteBuffers to files larger than 500MB. I believe that address space plays a role, but I admittedly am no OS address space expert.
    Thanks in advance for any input.
    Regards- KJ

    See the workaround in http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4724038

  • Request & Response in NIO SocketChannel

    Hi
    I just reading NIO, SocketChannel.
    Here I found short tutorial with examples:
    http://developer.java.sun.com/developer/technicalArticles/releases/nio/
    in ReadURL.java says about send some request
    <Socket Channels>
    String request = "GET / \r\n\r\n";
    channel.write(encoder.encode(CharBuffer.wrap(request)));
    Q?: What is response to this request and how generate this request?
    <Non-Blocking Servers>
    in Server.java is sending back a canned text message for each request
    Q?: How I can read request that send client (ReadURL) then hence send response?
    any suggestions or other tutorial links,
    Thanks,
    ~Hill

    http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-merlin.html

  • Is there a major flaw with Iphoto in regards to organizing and backing up?

    Is there a major flaw with Iphoto in regards to organizing and backing up? And how should I proceed??
    Here is my story. I have moved roughly 15,000 photos from 7 computers (4 PCs and 3 Macs - basically everyone's computer in the family) onto one external hard drive. The photos were taken by many different digital cameras, are sparsely labeled, and have the most random names and folders. There are a LOT of duplicates. MY MISSION - label and back them up.
    The way I normally deal with photos/DATA is this: I plug my camera into my Mac and immediately think about organizing and backing them up. With "Preview" I look at photos (and decide which one I like), create a folder called "where-ever I took these photos" and drag them into that folder. The problem with Iphoto is that you have no ability to control folders, unlike many other applications.
    For example, in Itunes you can rename an artist, or even an album, and it will automatically appear in an updated folder. If you alter a photo in Photoshop, it makes you save it is a new file. In Iphoto you cannot make the same "root level" changes without making duplicates. From what I understand, you can place photos into an Album and then export that album (which makes duplicates). Iphoto will rename each duplicate file and then place it in the correct folder. The problem here is I have no idea where the original is to delete it.
    Basically I want to create folders called "Trip to Italy 2003" or "Rachel's Wedding" and place all the photos associated with that event in those folders. The problem I run into is that I have a bunch of duplicates. I have heard of a program called Duplicate Annihilator which has gotten favorable reviews. If I import them into Iphoto all the photos are placed in random named folders. I say random because some of the photos were taken on cameras that didn't have the date set correctly. Hence some of my photos will appear in a labyrinth of folders called "Modified / 2001 / Roll 17 / DCM482 / Image25874654.jpg"
    I am totally willing to wipe my Iphoto library clean and start again if there is a way to organize the photos as described above. Eventually I will take these folders and save them on a data DVD.
    Thanks to anyone who can help.
    Gary

    You do not need to delve into the folders within the iPhoto Library via the finder to access any photo. That is all done within iPhoto itself. If you need a photo for use outside of iPhoto read Terence Devlin's treatise on file access. iPhoto is a DAM application - Digital Asset Management, not a folder manager. There's a big difference. You can use keywords, album and smart albums to organize your photos.
    If you still have the original files you might consider what I do. I rename each file with the date it was taken using the international date format: YYYY-MM-DD-001.jpg. You can download the demo version ofMedia Expression and automatically rename each folder of photos with the EXIF date and a sequential number. This makes chronological searching and sorting much easier both in iPhoto and the Finder.
    If you want to not only manage the photos but the folders then Expression Media will let you do both. It will let you rename files after being imported into a catalog, move them between folders, add ITPC metadata to the files, create virtual albums called Supplemental categories, and much, much more. I use it as my primary DAM and iPhoto for special projects like books, slideshows, calendars, etc.

  • Hi, i am having an issue with a basic motion scroll effect.  I already watched and read every tutorial out there regarding this topic and even tried the adobe chat support, but the guy on the other end of the line disconnected me-, probably he didn't unde

    Hi, i am having an issue with a basic motion scroll effect.
    I already watched and read every tutorial out there regarding this topic and even tried the adobe chat support, but the guy on the other end of the line disconnected me…, probably he didn't understand what i wanted from him because english is not my native language, so a will try to be very, very clear about this one..
    please note, that i am new to muse, this is my first project ever.
    my idea is as following:
    when the customer comes to our companies site, he just sees our logo on a white Background. the logo consists of, say, four elements. when the customer scrolls down, the logo starts to disassamble: first the first part of the logo flies out the left side of the site, then the second part of the logo vanishes down, then the third part of the logo flies to the right, then the fourth part of the logo flies to the top and out of the customers view. given what i have seen, it is possible to do that….
    so…..
    now i have the four parts of my logo imported as png files into muse and assembled them in design view to build our companies logo. I select every one of the four parts and go into the scroll effects tab left beside the layers tab. first i enter the same values for every one of the four parts: initial motion: 0x and 0x again for the left and right motion; key position ( t-handle) : 0px; final motion: 0x and 0x again for the left and right value.
    now i hit "preview".: the logo is "pinned" at the correct position, i can scroll but the logo stays where it is. so far so good….
    now i select all the four elements again and go to the scroll effecs tab. at "final motion", i click the down arrows and enter 1x. I hit Preview…
    when i am scrolling down the WHOLE logo goes down…. so far so good.
    NOW i want the first part of the logo to go down, THEN the second part to go left, THEN the third part to go up, THEN the fourth part to go right.
    so i select ONLY the first part, go to the scroll motion tab, at "final motion" i click the left arrows, then i enter 1x.( the up-down value, i set to 0 again).. i hit Preview…
    the first part of the logo goes left as soon as i start scrolling, the other three parts still go down at the same time…
    NOW i want the second part of the logo to start moving, when the first part has left the scene, not at the same time as the first part.
    SO I SELECT THE SECOND PART AND DRAG ITS T-HANDLE (KEY POSITION) DOWN TO, LETS SAY, 200PX. SO IT STARTS MOVING ONLY AFTER THE CUSTOMER HAS REACHED THAT POINT, RIGHT?
    BUT WHEN I PREVIEW THAT ****, THE LOGO IS NOT TOGETHER ANYMORE, THE SECOND PART IS FLOATING ANYWHERE ELSE BUT WHERE IT SHOULD BE…..WTFF????
    short: when i move the t handle, the initial position of the object changes. thats what i said to the adobe employee, but he said, that thats the expected behavior….
    but if thats so, how can i have my four parts correctly together, so they form my logo, but with different t handles, so that they all start to move at different times??
    Pleeease help me, i am dying of frustration here…..:( that behavior cant be right, right?
    Thanks so much to everyone who actually reads this post and tries to help…….
    All the best,
    Niki Lapan

    Thank you so much for helping,
    But i really wonder how you did that. did you always switch between design view and preview view, then change the key position for 2px then switch back, to align the four letters? because i imagine that can get really frustrating, if you have a logo consisting of 58 parts instead of 4!:)
    Anyway thank you very much for your time and effort!!!!

  • Questions regarding xft fonts, and awesome wm

    Hi, I just tried ArchLinux yesterday and loving it!
    I use JWM, but am very interested in dwm/awesome wm. I do have some questions:
    1. On a thread in the forum, it is mentioned that dwm has no Xft support. How useful exactly is Xft? Would it impact on design work involving GIMP/Inkscape/Scribus?
    2. Does awesome have Xft support?
    3. I installed awesome, but I have no idea on what keys to use. The shortcuts are different from dwm. I tried to look for quick tutorial just to get the basics (dwm has one on their website), but seems like all documentation I found have none of that section and go straight to configuration.
    Do I actually have to configure the wm before I can use it at a very basic level?
    4. I would like to do some more comparison between wms, trying to find a good balance for me in regards of lightness and functions I need. However, I have no idea on what to use to keep track of cpu/memory usage for all the wms. What's a good way to do this?
    Thank you in advance.

    Welcome to Arch!
    1. The lack of xft support in dwm mostly just means that you won't get anti-aliased fonts in the status bar. Individual applications will still have the same font support they had before you used dwm.
    2. Awesome uses pango for font rendering, which is even better than xft.
    3. Look at the man page for default key bindings. It's more or less usable out of the box, but you will definitely want to customize it somehow.
    4. A good system monitor is htop. Install it from the repos and run it from a terminal.
    Last edited by fflarex (2009-02-23 18:44:45)

  • Queries regarding Flash Builder and Augmented Reality.

    I am Sarat from India. I'm a software engineer with working knowledge of Java, so Flash AS and OOP are understandable for me. I am working on an augmented reality project. I am quite new to Flash, Adobe Community and I've got some queries regarding Augmented Reality and Flash Builder:
    1. Flash Builder 4.6 comes with a default Flex 4.6 SDK. However, Flex 4.6 SDK wasn't allowing me to compile and run some example files. So I've downloaded Flex 4.0A version from Adobe.com. Now the examples are running fine, but would there be any problem if i try deploying such projects in a website or as a desktop app? Once the code is compiled into a swf file, the flex framework used doesn't make much difference, does it?
    2. Would the AR project run effectively on a website, given various internet/processor speeds worldwide? Would the effectiveness of the AR project, deployed on a website, depend on the number of triangles in the 3D models i.e. dae files? Because as per my understanding heavy models implies more time to download the flash app into the local browser from the internet and more time to render them by the papervision 3D engine right?
    3. Can we develop a stand alone desktop AR app using Flash Builder? Using Adobe AIR we can, i guess. Please refer some tutorial, if possible.
    4. I've seen that we can implement multiple-marker-tracking AR using vectors/arrays in AS. Would there be any performance issues depending on the size of the vectors/arrays used.
    5. Can someone please mention some tips to improve performance of an AR app (desktop app and web app)?
    6. What would be, approximately, the cost of FLARManager, FLARToolkit commercial versions, if you have any idea? I've gone through their website but they did not mention the costs.
    7. Would applying bitmap material to the dae models pull down the web app/mobile app/desktop app performance, given some 4 to 5 dae models in the scene?
    8. Is it advisable to use multiple markers with multiple dae models or single marker with Flash-based GUI option to load different models onto the same marker?
    It would be very helpful for me if someone could answer my above queries.
    Sarat.

    #1, If it compiles then you have no issue. There's no reason at this point not to use 4.6. You should bundle a captive runtime to assure the users computer won't need to have AIR installed at all.
    #2, Papervision is old. Use the Stage3D and/or a wrapper framework. As far as the generic "If I download lots of data will it take the user more time to load it", well, of course. Just don't make the loading experience painful. Entertain them while they way or find ways of displaying data sooner than later. If it's desirable on the web has more to do with the context of the app and the device displaying it. In other words, a phone user would find it easy but obviously not a desktop user.
    #3, Definitely referring you to Google on that one.
    #4, Size always matters, it's common sense. The more you process the harder it is. While I haven't done AR I've used the Microsoft Kinect SDK and ANE and tracking was extremely fast but limited. From what I've seen and your basic built in location and direction hardware on any mobile device you shouldn't have much trouble. Depends on what you're doing.
    #5, This discussion would be way too large for a forum. You'd need to consult a firm experienced in AR development.
    #6, "Applications using the commercial license do not have to provide source code, but must pay a licensing fee. Contact ARToolworks at [email protected] for more information." They will base your price on your product, there is no single price.
    #7, The models could be huge and elaborate or tiny and simple which changes the answer. Consult the answer in #4. Ultimately most people are getting on fast networks with mobile and excessively fast on desktop/wifi. Size matters a lot less than 3 years ago.
    #8, Depends on what you're doing. You have to explain it.

  • Regarding case statement and decode function

    Hi Experts,
    I have question.....regarding case statement and decode statement....
    Can you please explain me that which one will be efficient,to place in insert statement...
    insert statement(
    (case when ........then
                         case when ....then
                         else
                         end)
      else
    end)
    or
    insert statement(
    case when.....then
    decode(....)
    else
    end)
    Can you people explain me which one is more efficient method?
    Thanks in advance.......

    The are major differences to talk about in case of CASE vs DECODE, but performance wise both are pretty much the same.
    Have a look at Tom's thread
    Ask Tom &amp;quot;better performance - case or decode&amp;quot;
    I would suggest to use CASE whenever possible. Don't worry about the performance part.

  • Quick question regarding best practice and dedicating NIC's for traffic seperation.

    Hi all,
    I have a quick question regarding best practice and dedicating NIC's for traffic seperation for FT, NFS, ISCSI, VM traffic etc.  I get that its best practice to try and separate traffic where you can and especially for things like FT however I just wondered if there was a preferred method to achieving this.  What I mean is ...
    -     Is it OK to have everything on one switch but set each respective portgroup to having a primary and failover NIC i.e FT, ISCSI and all the others failover (this would sort of give you a backup in situations where you have limited physical NICs.
    -    Or should I always aim to separate things entirely with their own respective NICs and their own respective switches?
    During the VCAP exam for example (not knowing in advance how many physical NIC's will be available to me) how would I know which stuff I should segregate on its own separate switch?  Is there some sort of ranking order of priority /importance?  FT for example I would rather not stick on its own dedicated switch if I could only afford to give it a single NICs since this to me seems like a failover risk.

    I know the answer to this probably depends on however many physical NICs you have at your disposal however I wondered if there are any golden 100% rules for example FT must absolutely be on its own switch with its own NICs even at the expence of reduced resiliency should the absolute worst happen?  Obviously I know its also best practice to seperate NICs by vender and hosts by chassis and switch etc 

  • Question regarding the "mcxquery" and "dscl -mcxread" commands:

    Question regarding the mcxquery and dscl -mcxread commands:
    Does anyone know why the mcxquery and the dscl . -mcxread commands don't show any info about MCX managed login items & printers? The System Profiler's "Managed Client" section does. Id like to see info regarding managed printers and managed login items using the mcx tools. I have Mac users running 10.5.2 with both login items and printers that are pushed out to them via MCX. The System Profiler app shows all of their policies, but the dscl . -mcxread and mcxquery tools dont. Why not?
    -D
    Message was edited by: Daniel Stranathan
    null

    How do you "call procedures/functions" without sql code? You need at least the call statement like
    {call myProc(?,?,?)}that you wrap into a CallableStatement.
    Other than that: when you switch off autocommit, you need to call commit/rollback at the end. Usually, if you don't commit/rollback a non-autocommitted connection, the transaction get's committed/rollbacked when you close the connection - that depends on the JDBC driver. But it's never a good idea to ommit the commit/rollback calls on a non-autocommit connection. Usually you enclose your code in a try/catch block like this:
    con.setAutocommit(false);
    try {
       con.commit();
    } catch (Exception e) {
       con.rollback();
    } finally {
        con.setAutocommit(true); //or:
        con.close();
    }

  • App store police regarding free downloads and 0 balance in bank account

    What is the app store police regarding free downloads and 0 balance in bank account.

    You must have a credit or debit card account on file to download free or purchased apps. Apple verifies your account credentials with every download.

  • Info regarding Diswarrior 4 and Leopard compatibility

    I emailed Alsoft regarding Diskwarrior 4 and Leopard compatibility. Here is the response I got.
    +DiskWarrior 4.0 will successfully rebuild a disk that has Mac OS X 10.5+
    +Leopard installed or a disk that has been attached to a computer running+
    Leopard.
    +However, some operating system functionality has changed within Leopard+
    +itself. As such, there are some compatibility issues when running an+
    +installed copy of DiskWarrior 4.0 while started up from Mac OS X 10.5+
    +Leopard. Alsoft currently recommends that you do not run DiskWarrior 4.0+
    +while the computer is started from Mac OS X 10.5 Leopard.+
    +Instead, to run DiskWarrior, you should start up the computer from either:+
    +1) A DiskWarrior 4.0 CD.+
    +2) Any disk that starts up in 10.4.x and then run DiskWarrior 4.0.+
    +An updated version of DiskWarrior that has complete Leopard+
    +compatibility will be released soon as a free download for existing+
    +owners of DiskWarrior 4.0.+
    +-- What you can expect when running DiskWarrior 4.0 under Mac OS X+
    +10.4.x and rebuilding a Leopard disk.+
    +All features work as expected with one exception: FileVaults created+
    +while started from Leopard are not visible to DiskWarrior 4.0 and cannot+
    +be rebuilt (repaired).+
    +-- What you can expect when running DiskWarrior 4.0 under Mac OS X 10.5+
    +and rebuilding a Leopard disk.+
    +While not recommended (and discouraged), if you do run DiskWarrior 4.0+
    +while started from Mac OS X 10.5 you might encounter some problems such as:+
    +1) There is a lengthy delay whenever DiskWarrior is determining which+
    +drives are currently attached. This delay is dependent upon the number+
    +of attached drives and may last up to 2 or 3 minutes. You will+
    +experience this delay when first starting DiskWarrior, whenever a disk+
    +is attached or detached while DiskWarrior is running but idle, and+
    +whenever a rebuild is completed or canceled.+
    +2) You cannot rebuild FileVaults or disk images.+
    +3) In step 9 (comparing directories) of a rebuild, the progress bar+
    +might get to 100% even though the comparison step is not finished.+
    +4) When performing Check All Files and Folders the progress bar might+
    +get to 100% even though the check is not finished.+
    +5) After rebuilding a disk, DiskWarrior may report that some files or+
    +folders have had their permissions changed. This is inaccurate and the+
    +permissions have not been changed.+
    +To repeat, an updated version of DiskWarrior that has complete Leopard+
    +compatibility will be released soon as a free download for existing+
    +owners of DiskWarrior 4.0.+
    +-- What about DiskWarrior 3?+
    +DiskWarrior 3 and earlier versions are not compatible with Mac OS X 10.5+
    +(Leopard). Alsoft does not recommend running DiskWarrior 3 or earlier on+
    +a disk that has Mac OS X 10.5 Leopard installed or a disk that has been+
    +attached to a computer running Leopard.+
    +-- Marc+
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Marc Moorash, Alsoft Technical Support+
    +Email: [email protected]+
    So, it seems it will work but you need to run it from the disk or if you have it installed on a external drive running Tiger, it will work.
    Thom

    If you open your Tiger Address Book, select all cards, drag them to the desktop, it will make one big "mega-VCF" card with a name like "Alan Adams and 543 others.vcf" Dump that to a flash drive or email it to yourself, then doubleclick on it on the Leopard machine. They will all import just fine into your Leopard Address Book.
    Try doing something similar with your iCal data, Open the application, choose your calendars one at a time, and select File > Export. That should make a big "mega-ics" calendar card with a name like "work.ics" or "home.ics, i.e., "originalcalendarname.ics" with all the events of that calendar. Then same drill: dump that to a flash drive or email it to yourself, then doubleclick on it on the Leopard machine.
    Both generation methods create text files, which should import just fine into the Leopard applications.

  • Regarding Shared Services and Essbase Access

    Hello,
    I am curious on few things regarding how Essbase and Shared services are interlinked.
    Basically we have created Essbase Filters to limit the User access to specific entities , my concern is if a User is trying to Run a report or retrieve through Smart View and if they don't have access to any one of the list of Filter definitions say if there are X , Y ,Z entities in the Spread sheet for Smart View retrieval or in a report and the user does not have privilege for Z do they still get terminated from the entire Essbase Applications. I encountered similar type of problem with one of the users today.
    Any comments.
    Thanks !

    Thanks for the reply Glenn , yes it should not get disconnected or have any connection issue. But below is what the error we get when using Essbase security filter.
    **** Cannot Open Member Selection. Essbase Error(1001064):You do not have sufficient access to perform read on this database ****

  • Few questions regarding Oracle Scorecard and strategy management.

    Hi,
    I have following questions regarding Oracle Scorecard and strategy management:
    1. What are the ways in which i can show status of a KPI, like we have colors and symbols, what are others?
    2. can we keep log of KPIs, store them, keep report of feedback/action taken on that?
    3. Does Scorecard and strategy management have ability to retain history on feedback and log of
    entries i.e. date/time, user name?
    4. Does Scorecard and strategy management have ability to use common mathematical formulas e.g. median, average, percentiles. Describe.?
    Thanks in advance for your help.

    bump.

  • Logic regarding EVENTS OnFilter and OnLeadSelect for table ui element

    provide me logic regarding EVENTS OnFilter and OnLeadSelect for table ui element for webdynpro abap application.

    OnLeadSelect - What kind of logic do you want?  There are many different things that you could do inthe OnLeadSelect
    onFilter- Generally you use IF_WD_TABLE_METHOD_HNDL~APPLY_FILTER  to perform the filter operation.
    In the onFilter itself you probably just have one line of code:
    wd_this->table_method_hndl->apply_filter( ).
    In your WDDOMODIFYVIEW you probably have this code to capture the table_method_hndl object:
    if first_time = abap_true.
      * Get reference of the table view element
      l_table ?= view->get_element( 'TABLE' ).
    * Get reference to the Filter & Sorting API
      wd_this->table_method_hndl ?= l_table->_method_handler.
    endif.

Maybe you are looking for