Re: Multithread question

View: New views
12 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: Multithread question

by Kay Ramme - Sun Germany - Hamburg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Oscar,

Oscar Picasso wrote:

> Hi,
>
> I have read several threads, without definitive answers, about the
> current support for multhreading when using openoffice as a server.
>
> Basically, I have a web application that, at user request, takes an
> openoffice template, changes some text, based on the user input, and
> generates a pdf file.
>
> In this context is openoffice thread safe? If not was could be the
> result of concurrently calling openoffice to populate a same template
> on behalf of different requests?
OOo tries to be thread-safe ... but unfortunately it is not really. If
you stress it, it dies ...
>
> Crash? Performance? Confusion (mixing or changing the data?).
>
> If the openoffice server is not thread safe, I thought about the web
> requests calling openoffice from the command line. But in that case,
> do concurrent calls use the same openoffice instance? Is it safe from
> the data integrity point of view?
Running one client at a time gives you good chances that the application
does not crash.
>
> In short what is the safest way for openoffice to solve this use case.
Good question ... the safest way is to use the "main-thread" for doing
operations in OOo, though this one is not directly reachable from
another process.
>


Regards


      Kay

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Multithread question

by Mathias Bauer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kay Ramme - Sun Germany - Hamburg wrote:

> Hi Oscar,
>
> Oscar Picasso wrote:
>> Hi,
>>
>> I have read several threads, without definitive answers, about the
>> current support for multhreading when using openoffice as a server.
>>
>> Basically, I have a web application that, at user request, takes an
>> openoffice template, changes some text, based on the user input, and
>> generates a pdf file.
>>
>> In this context is openoffice thread safe? If not was could be the
>> result of concurrently calling openoffice to populate a same template
>> on behalf of different requests?
> OOo tries to be thread-safe ... but unfortunately it is not really. If
> you stress it, it dies ...
>>
>> Crash? Performance? Confusion (mixing or changing the data?).
>>
>> If the openoffice server is not thread safe, I thought about the web
>> requests calling openoffice from the command line. But in that case,
>> do concurrent calls use the same openoffice instance? Is it safe from
>> the data integrity point of view?
> Running one client at a time gives you good chances that the application
> does not crash.
>>
>> In short what is the safest way for openoffice to solve this use case.
> Good question ... the safest way is to use the "main-thread" for doing
> operations in OOo, though this one is not directly reachable from
> another process.

Well, in fact it nowadays is. There is a UNO service that can be called
with an object receiving a callback. This callback will happen in OOo's
main thread and by moving all code into this callback you will have your
code executed as if it was called from e.g. OOo's menu bar.

You still may have problems when your application is written in a
languagge using garbage collection as this can lead to desctructor calls
of OOo objects executed in the garbage collection thread.

Best regards,
Mathias

--
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to "nospamformba@...".
I use it for the OOo lists and only rarely read other mails sent to it.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


2 instances of open office on one machine?

by Aaron Ehrensberger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'd like to start up two instances of OpenOffice on one machine.  One
JVM is my main engine, servicing normal user requests, some of which may
request a document.  A second JVM on my server is a "worker" service,
processing batches of documents at a time.

Ideally, I'd like each JVM to have their own OO instance so that they
don't conflict each other or cause each other latency when processing
their requests.

Is this possible?  Are their drawbacks to having two OO instances on one
machine?  Should I be using libraries or some other way to use OO to do
my file conversions without actually using OO instances?

Thoughts?

Aaron


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: 2 instances of open office on one machine?

by Michael Stahl-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Aaron Ehrensberger wrote:

> Hi,
>
> I'd like to start up two instances of OpenOffice on one machine.  One
> JVM is my main engine, servicing normal user requests, some of which may
> request a document.  A second JVM on my server is a "worker" service,
> processing batches of documents at a time.
>
> Ideally, I'd like each JVM to have their own OO instance so that they
> don't conflict each other or cause each other latency when processing
> their requests.
>
> Is this possible?  Are their drawbacks to having two OO instances on one
> machine?  Should I be using libraries or some other way to use OO to do
> my file conversions without actually using OO instances?

yes, this should be possible. you can start multiple instances of OOo from
a single installation. afaik, an OOo user profile can be used by only one
OOo instance at any one time, so you would have to create two OOo user
profiles. (also, obviously, the two instances can't listen on the same
pipe/port/whatever.)

if you need to do file conversions, then you probably won't get away with
anything less than an OOo instance.

regards,
michael

--
Q: What's yellow, normed, and complete?
A: A Bananach space.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: 2 instances of open office on one machine?

by Robert Vojta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Apr 21, 2009 at 3:08 PM, Aaron Ehrensberger
<aehrensberger@...> wrote:

Hi Aaron,

> Is this possible?  Are their drawbacks to having two OO instances on one
> machine?  Should I be using libraries or some other way to use OO to do
> my file conversions without actually using OO instances?

yes, it's possible. You can start one instance / one user (= user
settings directory) under normal circumstances. But you can specify
different user settings directory when starting OO.o => you can start
more instances on one machine under one user. To achieve this, you
have to use -env:UserInstallation="" argument when starting OO.o.

My recommendation is to start OpenOffice.org as normal user and
configure it properly (Java, ...). Than quit OpenOffice.org and copy
user settings to several locations. For example
/opt/ooo-server/instance-1, etc. and use these directories in
-env:UserInstallation argument.

OpenOffice.org contains bugs, memory leaks and sometimes crashes. But
don't worry, there are tools to handle all these things. Example can
be oood.py written by Joerg. This daemon has simple XML configuration
file when you can put number of instances, user settings directories,
maximum usage count before instance restart, etc. See
ZIP/CZJUGInternet/Server/oood.py [1]. Ports, redirections to
instances, ... are handled in this daemon as well.

So, the last step is how to connect to instances. I implemented
samples for CZJUG lectures and you can find them in
ZIP/CZJUGInternet/Server/Klient/remote [1]. It's based on Apaches'
PoolableObjectFactory. We use something similar in our commercial
products and they run on Tomcat & Java, so, it should fit your needs
too.

Hope it helps.

[1] http://www.java.cz/dwn/1003/15588_ooffice-java-czjug0812.zip

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Split and Join Docs?

by Aaron Ehrensberger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Is there an api call that can do the following...

1.  Take two docs and call 1 call to join those two documents into one
larger document?

2.  Take one larger document and split that document into two smaller
documents?  I know that I can export different page ranges into PDFs and
this is exactly what I'd want to do, but I'd want the resulting
documents to remain .docs.

Aaron


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


temp files

by Aaron Ehrensberger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We're using OO through the API to convert files into PDFs.

Temp files are apparently created on disk during this process.  And it's
slowing filling up our disk space.

I'm wondering...is there anyway to disable these temp files from being
created?  Can I delete these files after creation?  

Does OS have anything to do with this as one box where temp files are
created is a Windows 2003 Server box and another box, where we're not
having temp file issues, is an XP box.

Aaron


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: temp files

by Cor Nouws :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Aaron,

Aaron Ehrensberger wrote (3-6-2009 20:31)

> We're using OO through the API to convert files into PDFs.
>
> Temp files are apparently created on disk during this process.  And it's
> slowing filling up our disk space.
>
> I'm wondering...is there anyway to disable these temp files from being
> created?  Can I delete these files after creation?  
>
> Does OS have anything to do with this as one box where temp files are
> created is a Windows 2003 Server box and another box, where we're not
> having temp file issues, is an XP box.

There is an issue about the way OOo handles documents (headers/footers)
when doing mail merge.
http://www.openoffice.org/issues/show_bug.cgi?id=40827
Maybe has little to do with your request... but it does tell some
technical stuff, which might be of help.

Regards,
Cor

--
Cor Nouws    -    nl.OpenOffice.org marketing contact
= "2009 - Develop OOo"   =   www.nieuwsteoffice.nl  =

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Multithread question

by Oscar Picasso-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Mathias,

1- The client is written in java so I guess I could run into the "garbage
collection" problems you mentioned. Correct?

2- If so is there a mean to prevent to run into those problems while still
using the UNO service you mentioned. I thought about simply calling OO via a
synchronized method in my client. Any idea if it it would be the correct
approach (well in that case I wouldn't even use OO multithread
capabilities)?
Or maybe a better one?

3- What is the "UNO service that can be called with an object receiving a
callback"? Have you any pointer about it (documentation, sample code etc.)?

Thanks

PS: my application does not let the user interact directly with the OO user
interface. When I wrote "based on the user input" in my explanation, I was
talking about "user input from the web application interface". Maybe it was
not so obvious from what I first wrote.

On Mon, Apr 20, 2009 at 11:11 AM, Mathias Bauer <nospamforMBA@...> wrote:

> Kay Ramme - Sun Germany - Hamburg wrote:
>
> > Hi Oscar,
> >
> > Oscar Picasso wrote:
> >> Hi,
> >>
> >> I have read several threads, without definitive answers, about the
> >> current support for multhreading when using openoffice as a server.
> >>
> >> Basically, I have a web application that, at user request, takes an
> >> openoffice template, changes some text, based on the user input, and
> >> generates a pdf file.
> >>
> >> In this context is openoffice thread safe? If not was could be the
> >> result of concurrently calling openoffice to populate a same template
> >> on behalf of different requests?
> > OOo tries to be thread-safe ... but unfortunately it is not really. If
> > you stress it, it dies ...
> >>
> >> Crash? Performance? Confusion (mixing or changing the data?).
> >>
> >> If the openoffice server is not thread safe, I thought about the web
> >> requests calling openoffice from the command line. But in that case,
> >> do concurrent calls use the same openoffice instance? Is it safe from
> >> the data integrity point of view?
> > Running one client at a time gives you good chances that the application
> > does not crash.
> >>
> >> In short what is the safest way for openoffice to solve this use case.
> > Good question ... the safest way is to use the "main-thread" for doing
> > operations in OOo, though this one is not directly reachable from
> > another process.
>
> Well, in fact it nowadays is. There is a UNO service that can be called
> with an object receiving a callback. This callback will happen in OOo's
> main thread and by moving all code into this callback you will have your
> code executed as if it was called from e.g. OOo's menu bar.
>
> You still may have problems when your application is written in a
> languagge using garbage collection as this can lead to desctructor calls
> of OOo objects executed in the garbage collection thread.
>
> Best regards,
> Mathias
>
> --
> Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
> OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
> Please don't reply to "nospamformba@...".
> I use it for the OOo lists and only rarely read other mails sent to it.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@...
> For additional commands, e-mail: dev-help@...
>
>

Re: Multithread question

by Mathias Bauer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Oscar,

Oscar Picasso wrote:

> Hi Mathias,
>
> 1- The client is written in java so I guess I could run into the "garbage
> collection" problems you mentioned. Correct?

Yes.

> 2- If so is there a mean to prevent to run into those problems while still
> using the UNO service you mentioned. I thought about simply calling OO via a
> synchronized method in my client. Any idea if it it would be the correct
> approach (well in that case I wouldn't even use OO multithread
> capabilities)?
> Or maybe a better one?

If your problem is the Garbage Collection, this wouldn't help. But if
not, this could solve your problem.

> 3- What is the "UNO service that can be called with an object receiving a
> callback"? Have you any pointer about it (documentation, sample code etc.)?

I'll dig that out.

Regards,
Mathias

--
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to "nospamformba@...".
I use it for the OOo lists and only rarely read other mails sent to it.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Multithread question

by Oscar Picasso-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Mathias,

> 3- What is the "UNO service that can be called with an object receiving a
> > callback"? Have you any pointer about it (documentation, sample code
> etc.)?
>
> I'll dig that out.
>
>
Thanks for your help.

As I need anyway to use a java client, this UNO service does not seem to
help. I am still curious but I am starting another thread about how to use
OO as a local server in most *reliable* way even if doing so implies that
the client access the server in a single thread.

Re: Multithread question

by Mathias Bauer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Oscar,

Oscar Picasso wrote:

> Hi Mathias,
>
>> 3- What is the "UNO service that can be called with an object receiving a
>> > callback"? Have you any pointer about it (documentation, sample code
>> etc.)?
>>
>> I'll dig that out.
>>
>>
> Thanks for your help.
>
> As I need anyway to use a java client, this UNO service does not seem to
> help. I am still curious but I am starting another thread about how to use
> OO as a local server in most *reliable* way even if doing so implies that
> the client access the server in a single thread.

Sorry, I forgot about your question. :-[

Working in the main thread of OOo will increase stability in every case.
Here's how to do it: use "com.sun.star.awt.AsyncCallback" service to get
a callback from the office main thread. You will need an own object
implementing the com::sun::star::awt::XCallback interface.
This object will be provided to the
om::sun::star::awt::XRequestCallback::addCallback() call.

How does it work?

When a remote application calls a UNO API method through the remote
bridge, a new thread is created in OOo that executes the API call. Both
threads (the thread on OOo side and the thread on remote side) are
assigned to each other. As now we have at least two threads running in
OOo that can call into the application code, race conditions caused by
some bugs here and there are possible.

If you use the AyncCallback service, it will call the remote application
from inside the main thread and this will create another thread on the
remote application side that is assigned to OOo's main thread. Every
call done in this thread will not create multi threading problems for
OOo's own processing.

Regards,
Mathias

--
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to "nospamformba@...".
I use it for the OOo lists and only rarely read other mails sent to it.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...