Highlighted
BiggyAQL
6 Indium

Upload file on path

Jump to solution

Hi,

I use in my java web application the atmos lib 1.4.1 to upload a file in a path (Es. bil123.pdf to /BILLING/bil123.pdf),

whit this library, which is now deprecated, i use the method createObjectOnPath().

I want to update the libraries using last version 2.1.2, but I not found a method that allows me to upload a file to a directory.

It's possible?

Labels (2)
0 Kudos
1 Solution

Accepted Solutions
8 Krypton

Re: Upload file on path

Jump to solution

All of the object create methods have been generalized to use a CreateObjectRequest, but there are a few additional convenience methods in the interface.  To create an object on a path, simply provide an ObjectPath as the identifier in the appropriate create method like so:

ObjectPath identifier = new ObjectPath( "/BILLING/bil123.pdf" );

File file = new File( "bil123.pdf" );

atmosApi.createObject( identifier, file, "application/pdf" );

If you need to include metadata or other options, you'll have to use the AtmosApi.createObject( CreateObjectRequest ) method.

0 Kudos
7 Replies
8 Krypton

Re: Upload file on path

Jump to solution

All of the object create methods have been generalized to use a CreateObjectRequest, but there are a few additional convenience methods in the interface.  To create an object on a path, simply provide an ObjectPath as the identifier in the appropriate create method like so:

ObjectPath identifier = new ObjectPath( "/BILLING/bil123.pdf" );

File file = new File( "bil123.pdf" );

atmosApi.createObject( identifier, file, "application/pdf" );

If you need to include metadata or other options, you'll have to use the AtmosApi.createObject( CreateObjectRequest ) method.

0 Kudos
BiggyAQL
6 Indium

Re: Upload file on path

Jump to solution

Hello Chris,
thank you for your reply, I have another question,
in my web application you connect more than 100 users, all make uploading and downloading files and sometimes I get a:

com.emc.esu.api.EsuException: Error connecting to server

I have made a recursive ping to the server atmos and are not lost packages.
I fear it is a problem of library or architecture.

I currently use a static method that returns the object EsuAPI, this method is used by the JSF backing bean, is that correct or do you think I can do differently?

0 Kudos
8 Krypton

Re: Upload file on path

Jump to solution

EsuApi and AtmosApi are both thread-safe.  Creating a new client instance (especially AtmosApiClient) is a rather expensive operation, so try to use a singleton when possible.

Can you provide the entire stack trace?  And is your endpoint a load-balancer or are you connecting directly to individual nodes?

0 Kudos
BiggyAQL
6 Indium

Re: Re: Upload file on path

Jump to solution
For the moment we haven't balancing, active users are up to 150 and there are few simultaneous operations that could put stress on the server.

The web application (beta test) is simply deployed to a CentOS server with Glassfish 3.1.2. the web server have one node and only one web-apps

this is the stack-trace:

com.emc.esu.api.EsuException: Error connecting to server

                at com.emc.esu.api.rest.EsuRestApi.createObjectFromSegmentOnPath(EsuRestApi.java:525)

                at com.emc.esu.api.rest.UploadHelper.createObjectOnPath(UploadHelper.java:245)

                at it.acqualatina.magellano.backing.request.FileBB.copyFileToAtmos(FileBB.java:167)

                at sun.reflect.GeneratedMethodAccessor844.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:601)

                at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:779)

                at javax.el.BeanELResolver.invoke(BeanELResolver.java:528)

                at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:257)

                at com.sun.el.parser.AstValue.invoke(AstValue.java:248)

                at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:302)

                at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)

                at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:148)

                at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)

                at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)

                at javax.faces.component.UICommand.broadcast(UICommand.java:300)

                at javax.faces.component.UIData.broadcast(UIData.java:1093)

                at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

                at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)

                at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

                at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)

                at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:77)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

                at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

                at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)

                at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)

                at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)

                at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)

                at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)

                at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)

                at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)

                at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)

                at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)

                at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)

                at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)

                at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)

                at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)

                at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)

                at com.sun.grizzly.ContextTask.run(ContextTask.java:71)

                at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)

                at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)

                at java.lang.Thread.run(Thread.java:722)

Caused by: java.net.SocketException: Unexpected end of file from server

                at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:727)

                at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:589)

                at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1319)

                at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)

                at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)

                at com.emc.esu.api.rest.EsuRestApi.createObjectFromSegmentOnPath(EsuRestApi.java:511)

                ... 52 more

0 Kudos
8 Krypton

Re: Re: Upload file on path

Jump to solution

That may be too much load for a single node.  Although, you should get a 503 if that's the case.  What version of Atmos services are you running?  Is there a proxy between your app and the Atmos node?

I would spread the requests across the nodes and see if you still have the same issue.  The Java clients (both EsuApi and AtmosApi) provide load-balancing using a simple round-robin algorithm.  For EsuApi, construct a LBEsuRestApi instance (instead of EsuRestApi) providing a list of hosts in the constructor.  For AtmosApi, simply add endpoints to the AtmosConfig constructor.

If client instantiation is isolated (i.e. in a static getter), this is a quick change.

0 Kudos
BiggyAQL
6 Indium

Re: Upload file on path

Jump to solution
The Atmos services are supplied to us by an outside provider (Telecom Italy) do not know the version of the service, but I can ask.

The provider has given us https url and TokenId.

The connection does not have proxy and uses a line to 10MB dedicated between our server and the provider, the connection to services is only possible by the subnet of our Linux server with https.

How do I add an endpoint to the manufacturer AtmosConfig?

Thank you for your precious support

0 Kudos
8 Krypton

Re: Upload file on path

Jump to solution

If you're hitting Telecom Italia's cloud, then you are already using a load balancer.  I would open a support ticket with TI.

0 Kudos