java - Amazon S3 issue in web applications running in localhost -
please have @ below code.
/* * change license header, choose license headers in project properties. * change template file, choose tools | templates * , open template in editor. */ package s3test; import com.amazonaws.auth.awscredentials; import com.amazonaws.auth.basicawscredentials; import com.amazonaws.services.s3.amazons3; import com.amazonaws.services.s3.amazons3client; import java.io.ioexception; import java.io.printwriter; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; /** * * @author yohan */ public class s3test extends httpservlet { /** * processes requests both http <code>get</code> , <code>post</code> * methods. * * @param request servlet request * @param response servlet response * @throws servletexception if servlet-specific error occurs * @throws ioexception if i/o error occurs */ protected void processrequest(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { printwriter writer = response.getwriter(); system.out.println("i in"); string accesskey = "**********"; string secretkey = "**********"; awscredentials credentials = new basicawscredentials(accesskey, secretkey); amazons3 conn = new amazons3client(credentials); system.out.println("done"); // list<bucket> buckets = conn.listbuckets(); //for (bucket bucket : buckets) { // system.out.println(bucket.getname() + "\t" + // stringutils.fromdate(bucket.getcreationdate())); //} } // <editor-fold defaultstate="collapsed" desc="httpservlet methods. click on + sign on left edit code."> /** * handles http <code>get</code> method. * * @param request servlet request * @param response servlet response * @throws servletexception if servlet-specific error occurs * @throws ioexception if i/o error occurs */ @override protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { processrequest(request, response); } /** * handles http <code>post</code> method. * * @param request servlet request * @param response servlet response * @throws servletexception if servlet-specific error occurs * @throws ioexception if i/o error occurs */ @override protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { processrequest(request, response); } /** * returns short description of servlet. * * @return string containing servlet description */ @override public string getservletinfo() { return "short description"; }// </editor-fold> }
i using code list buckets have in amazon s3. process extremely slow, takes 1 minute or more. not that, takes lot of memory, freezing google chrome. bucket in standard region , application running in pc located in south asia.
the delay in connection configuration.
i using netbeans ide , above code part of servlet. server using apache tomcat 7.
any ideas why taking of time? added jar files came amazon sdk java well. has no use me if takes long.
special note
i noticed not taking time delays when running in non web java applications. ran in simple main
class not web based, , worked fine, fast. happening here?
i noticed not taking time delays when running in non web java applications. ran in simple main class not web based, , worked fine, fast. happening here?
so you're saying code presented runs fast, there's other code elsewhere in code base that's slow? problem lies in other code haven't shown, then.
Comments
Post a Comment