Discussions

Performance and scalability: how to make sure if a resource is existing on a server??

  1. Hello all,

    I have a situation where I get a .ior file from a server. If URL is OK, everything works fine. If the URL is malformed I catch that exception.
    Now, the problem is if the URL is not malformed, but is not the right one either, my application keep waiting & waiting to get that file which is not even existing there!!

    How should I handle this??

    Please please help.

    Thanks,

    Priya.
  2. Can you provide a sample of the code that you are using to the above?

    Sincerely,

    Artem D. Yegorov
    http://www.activexml.org
  3. Thank you very much for responding..

    here is snippet of my code..
    ...
    ....
    String nsURL = prop.getProperty("dpa_server_nsURL1");
    try {
     //Load the IOR for the Root Context of the Naming Service
     //Open the URL that references the file where the IOR is stored.

      java.net.URL URL = new URL(nsURL);
    .....
    try{
       InputStream is = URL.openStream ( ) ;
       BufferedReader dis = new BufferedReader ( new InputStreamReader ( is ) ) ;
      // Read the content of the file.
       String objStr = null;
       objStr = dis.readLine() ;
     .....
    }
    ....
    catch(IOException i){
    ....
    }
    ....
    }
    catch(MalformedURLException me ){
                    logger.fine("Invalid URL");
                    // do something
                }


    I can send you more if this is not enough to understand. I would really appreciate any input.

    Thanks.

    Priya
  4. switch to nio[ Go to top ]

    use non-blocking i/o, there is lots of good idioms out there one can use to implement this kind of functionality.
  5. I ran your example and in case of file or http protocol I am getting a FileNotFoundException, which is the proper behaviour in case the URL is well-formed but esource does not exist...

    What is the exact situation when it waits?

    Sincerely,

    Artem D. Yegorov
    http://www.activexml.org
  6. Thanks again for responding. I really appreciate it.

    Well, the situation is the testing people are testing by manipulating the url.. but it seems to be the url is within our domain..and possibly router is directing it to somewhere..

    anyway, right now I've fixed this problem by writing a timeout routine.


    Thanks & regards,

    Priya.