Re: Share info across different sessions servers
Hi! what about treating this problem as a chat system? You want to broadcast messages, right? Maybe http://cometd.org/ is of any help (did not use it now personally) Jens Sent from my iPhone On 04.07.2013, at 00:14, Vince Stewart stewart.vi...@gmail.com wrote: Hi Jose, a couple of things, 1) I use embedded Tomcat to build my application and this has allowed me to maintain 2 single-line patches in tribes classes by adding tribes source code to my compilations. However those patches are only necessary with large messages that take more than 3 seconds to be transmitted from the transmitting machine to the Internet Service Provider machine (approx 0.5 meg for my system). There is a config setting (Sender/Transport/timeout) that's supposed to alter this 3 second timeout limit but I'm not sure it works. 2) The implementation is not at all trivial. You have to register StaticMember objects because usual member discovery does not work over wide-area network (WAN). I allocate one machine as SuperServer and all other machines have to enroll with SuperServer at startup. All machines need to have a unique combination of Ipv4 address and port number (which might represent a redirection port for use by the router whereupon networked machines also need LAN addresses set). Once registration is complete, all sub-Server machines can send/receive SuperServer and vice versa. There is a tutorial on-line which is adequate but not for WAN. I think you have at least two weeks of work in front of you using tribes but I am very happy I used this method. None of my code would add much (except confusion) to that in the tutorial. Make sure you start without multicast enabled as it currently is suitable only for LAN. ///Class Constructor public ServerMessaging() throws SocketException{ this.myChannel=new GroupChannel(); ChannelListener msgListener = new ServerMessaging.MyMessageListener(); MembershipListener mbrListener = new ServerMessaging.MyMemberListener(); myChannel.addMembershipListener(mbrListener); myChannel.addChannelListener(msgListener); try{ myChannel.start(Channel.MBR_TX_SEQ|Channel.MBR_RX_SEQ|Channel.SND_TX_SEQ|Channel.SND_RX_SEQ);//no multicast } catch(ChannelException e){ U.log(e); } } public void detectOrderNumber_EnrollWithSuperServer() throws ChannelException{ setMyServerOrderStatus(); // machine reads its mac address or some file; then from a table will set serverOrderNumber to 0 for superserver ; others 1,2,3... if(this.getServerOrderNumber()==0){ meaning this is the superserver someObject.doSomeThingMaybe(); } else{ this.sendAckRequiredMessage(0,Enrollment); /// first argument specifies SuperServer, member 0 (a table will need to be provided to hold IPv4 address and port for each member) } } - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Share info across different sessions servers
Hi! What kind of data do you want to share? Just a view bytes? Is there an requirement concerning durability/persistence/performance? Is this user=session related or do you want to share data in general? Usually if you have a session id the lb will route your user always to the same container? What about session replication, a database, terracotta? JMS: i doubt this will be working... you need a persistent message or a container started after the change was send will not noticed about it... Jens Sent from my iPhone On 02.07.2013, at 08:45, Jose María Zaragoza demablo...@gmail.com wrote: Hello: I need to share data between sessions running in different Tomcat server. I 'd been thinking about using a JMS broker (as ActiveMQ ): - when a new session is created in Tomcat A, it's created a new unique topic for this session - the session registers itself as listener of that topic ( the only one listener ) - publish the name of this topic by some way , so it can be found by another session in Tomcat B I don't know if somebody has used something like this sometime, and how he/she did it Any suggestion/opinion ? I'm not sure either use only one topic for all session created or one topic per session ? I think that one topic per session is more safe because if I use one topic for all sessions, if one message is not read quickly by one consumer ( a session ), could block the topic, Obviously , i'll define a TTL for messages/topic Thanks and regards - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Best practices for shared classloader use?
Hi Don! You can try to move only common libs shared by all yor different webapps to the shared classloader but leave the application core in seperate war files? Jens Sent from my iPhone On 04.06.2013, at 17:36, Don Asper don.as...@sas.com wrote: I am considering using the Tomcat 7 shared classloader to reduce the memory footprint of my web apps. But, I'm afraid that loading my application jar files into a single classloader will cause lots of problems. I'm aware that the shared classpath should not specify multiple versions of the same class. But I suspect, for example, that classes that have static properties must not be shared. Am I correct in thinking this? Are there other problems that I should anticipate? Thanks! - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Best practices for shared classloader use?
Hi Don! Usually each Webapp has its own classloader thus two webapps can have different versions of the same class. Classloaders are chained so if a class is not found search continues in the next classloader. Shared just means one classloader is used by different webapps thus you may run into trouble if each webapp requires a different class version (changed method signature) as you can not predict which version you get. As long you can align the shared libs across all webapps this is not an issue. I do not see your static field problem, though? Share functionality like using the same jars? If all use the same version you can push it to the shared imho. Jens Sent from my iPhone On 04.06.2013, at 18:03, Don Asper don.as...@sas.com wrote: Sorry, I was not clear in my first post. I want to load the jars containing functionality that is common to my web apps using the shared classloader. I anticipate that there can be problems if different versions of the same class are on the shared classpath. I also suspect that any common jars or classes will cause a problem if they contain static fields. Am I correct in this? Are there other problems that typically occur when attempting to share classes? What should I watch out for when trying to share functionality between my web apps? Thanks. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Ideal way to minimize resources used by Tomcat for sessions
Why do you need a Webserver at all? What about plain Java Sockets instead? Jens Von meinem iPad gesendet Am 19.11.2012 um 03:34 schrieb Baron Von Awsm baronvona...@gmail.com: My web app consists of a single servlet, no JSPs and no static content. The servlet retrieves XML from POST submissions and hands the XML and IP address of the client to an API/engine. This engine can work outside of a web container and has no knowledge of a web container. It has its own mechanism for managing sessions. For this reason, for this web application, I require no session management overhead by Tomcat. I would like to disable all aspects (that I can) of Tomcat session management, including session cookies and/or url rewriting. Searches on the topic yielded the following suggestions, 1. Never call getSession(). That makes sense - if its never called then things are never stored in the session and, perhaps, Tomcat doesn't create some things that it might have. But I have some question marks over this suggestion. Does Tomcat still utilise resources simply by having the standard session manager in place? Does tomcat still set cookies and/or rewrite URLs? If I never call getSession() will this lead to as little resources being used when compared to a solution that replaces the standard manager with a 'do nothing' manager implementation? 2. Set the 'cookies' attribute of the context to false. To me, I would not think this addresses my issue at all. 3. Write a Manager implementation that does the bare minimum. This would seem like the best solution to me, although, the most time consuming. My question - Given that I do not require the use of http sessions in Tomcat, what would be the best way for me to minimise the resources Tomcat devotes to session management? I would prefer if the solution disabled session cookie writing and/or url rewriting, as neither serves a purpose as there are no sessions to track (from my application's perspective). Cheers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: high CPU usage on tomcat 7
Well, if you have 4 cores and all cores are looping tomcat definitely will not respond any more... Von meinem iPad gesendet Am 30.09.2012 um 12:42 schrieb Jeff MAURY jeffma...@jeffmaury.com: I don't think a cpu loop will make tomcat stopping responding to requests I will make it very slow to respond But a shortage on memory is hard to recover Jeff Le vendredi 28 septembre 2012, mailingl...@j-b-s.de a écrit : Maybe an infinite loop? We observed something similar due to a bug in the java regex impl and certain user input causes this regex looping behaviour. As this locked one core but to the user it simply looked like server was not responding, guess what happend? Right: they press refresh page and next core gone :-) So running state might be evil, too. Switch on GC logging, maybe its just related to a full gc. In case this happens again take a thread dump and search similarities. Take multiple dumps in a 5 sec interval. Try to find long running threads (in our case we noticed the regex bug) Jens Sent from my iPhone On 27.09.2012, at 22:05, Kirill Kireyev kir...@instagrok.com wrote: Thanks for all the advice everyone! There is a possibility that the CPU is caused by an app thread - I am looking into that possibility. Will let you know when I find out more. Thanks, Kirill On 9/27/12 12:17 PM, Shanti Suresh wrote: Hi Kirill, Like Mark, Bill and Jeff said, those threads are normal request-processing threads. I have included a script that might help with isolating high CPU issues with Tomcat. Also, I think it might be helpful to see how the Java heap is performing as well. Please bring up Jconsole and let it run over the week. Inspect the graphs for Memory, CPU and threads. Since you say that high CPU occurs intermittently several times during the week and clears itself, I wonder if it is somehow related with the garbage collection options you are using for the server. Or it may be a code-related problem. Things to look at may include: (1) Are high CPU times related to Java heap reductions happening at the same time? == GC possibly needs tuning (2) Are high CPU times related to increase in thread usage? == possible livelock in looping code? (3) how many network connections come into the Tomcat server during high-CPU times?Possible overload-related? Here is the script. I made a couple of small changes, for e.g., changing the username. But didn't test it after the change. During high-CPU times, invoke the script a few times, say 30 seconds apart. And then compare the thread-dumps. I like to use TDA for thread-dump analysis of Tomcat thread-dumps. Mark, et al, please feel free to help me refine this script. I would like to have a script to catch STUCK threads too :-) Let me know if anyone has a script already. Thanks. --high_cpu_diagnostics.pl:- #!/usr/bin/perl # use Cwd; # Make a dated directory for capturing current diagnostics my ($sec,$min,$hour,$mday,$mon,$year, $wday,$yday,$isdst) = localtime time; $year += 1900; $mon += 1; my $pwd = cwd(); my $preview_diag_dir = /tmp/Preview_Diag.$year-$mon-$mday-$hour:$min:$sec; print $preview_diag_dir\n; mkdir $preview_diag_dir, 0755; chdir($preview_diag_dir) or die Can't chdir into $preview_diag_dir $!\n; # Capture Preview thread dump my $process_pattern = preview; my $preview_pid = `/usr/bin/pgrep -f $process_pattern`; my $login = getpwuid($) ; if (kill 0, $preview_pid){ #Possible to send a signal to the Preview Tomcat - either webinf or root my $count = kill 3, $preview_pid; }else { # Not possible to send a signal to the VCM - use sudo system (/usr/bin/sudo /bin/kill -3 $preview_pid); } # Capture Preview thread dump system (/usr/bin/jmap -dump:format=b,file=$preview_diag_dir/preview_heapdump.hprof $preview_pid); # Gather the top threads; keep around for reference on what other threads are running @top_cmd = (/usr/bin/top, -H, -n1, -b); @sort_cmd = (/bin/sort, -r, -n, -k, 9,9); @sed_cmd = (/bin/sed, -n, '8,$p'); system(@top_cmd 1 top_all_threads.log); # Get your tomcat user's threads, i.e. threads of user, webinf system('/usr/bin/tail -n+6 top_all_threads.log | /bin/sort -r -n -k 9,9 | /bin/grep webinf top_all_threads.log 1 top_user_webinf_threads.log'); # Get the thread dump instaGrok_sml.png -- Jeff MAURY Legacy code often differs from its suggested alternative by actually working and scaling. - Bjarne Stroustrup http://www.jeffmaury.com http://riadiscuss.jeffmaury.com http://www.twitter.com/jeffmaury - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: high CPU usage on tomcat 7
Maybe an infinite loop? We observed something similar due to a bug in the java regex impl and certain user input causes this regex looping behaviour. As this locked one core but to the user it simply looked like server was not responding, guess what happend? Right: they press refresh page and next core gone :-) So running state might be evil, too. Switch on GC logging, maybe its just related to a full gc. In case this happens again take a thread dump and search similarities. Take multiple dumps in a 5 sec interval. Try to find long running threads (in our case we noticed the regex bug) Jens Sent from my iPhone On 27.09.2012, at 22:05, Kirill Kireyev kir...@instagrok.com wrote: Thanks for all the advice everyone! There is a possibility that the CPU is caused by an app thread - I am looking into that possibility. Will let you know when I find out more. Thanks, Kirill On 9/27/12 12:17 PM, Shanti Suresh wrote: Hi Kirill, Like Mark, Bill and Jeff said, those threads are normal request-processing threads. I have included a script that might help with isolating high CPU issues with Tomcat. Also, I think it might be helpful to see how the Java heap is performing as well. Please bring up Jconsole and let it run over the week. Inspect the graphs for Memory, CPU and threads. Since you say that high CPU occurs intermittently several times during the week and clears itself, I wonder if it is somehow related with the garbage collection options you are using for the server. Or it may be a code-related problem. Things to look at may include: (1) Are high CPU times related to Java heap reductions happening at the same time? == GC possibly needs tuning (2) Are high CPU times related to increase in thread usage? == possible livelock in looping code? (3) how many network connections come into the Tomcat server during high-CPU times?Possible overload-related? Here is the script. I made a couple of small changes, for e.g., changing the username. But didn't test it after the change. During high-CPU times, invoke the script a few times, say 30 seconds apart. And then compare the thread-dumps. I like to use TDA for thread-dump analysis of Tomcat thread-dumps. Mark, et al, please feel free to help me refine this script. I would like to have a script to catch STUCK threads too :-) Let me know if anyone has a script already. Thanks. --high_cpu_diagnostics.pl:- #!/usr/bin/perl # use Cwd; # Make a dated directory for capturing current diagnostics my ($sec,$min,$hour,$mday,$mon,$year, $wday,$yday,$isdst) = localtime time; $year += 1900; $mon += 1; my $pwd = cwd(); my $preview_diag_dir = /tmp/Preview_Diag.$year-$mon-$mday-$hour:$min:$sec; print $preview_diag_dir\n; mkdir $preview_diag_dir, 0755; chdir($preview_diag_dir) or die Can't chdir into $preview_diag_dir $!\n; # Capture Preview thread dump my $process_pattern = preview; my $preview_pid = `/usr/bin/pgrep -f $process_pattern`; my $login = getpwuid($) ; if (kill 0, $preview_pid){ #Possible to send a signal to the Preview Tomcat - either webinf or root my $count = kill 3, $preview_pid; }else { # Not possible to send a signal to the VCM - use sudo system (/usr/bin/sudo /bin/kill -3 $preview_pid); } # Capture Preview thread dump system (/usr/bin/jmap -dump:format=b,file=$preview_diag_dir/preview_heapdump.hprof $preview_pid); # Gather the top threads; keep around for reference on what other threads are running @top_cmd = (/usr/bin/top, -H, -n1, -b); @sort_cmd = (/bin/sort, -r, -n, -k, 9,9); @sed_cmd = (/bin/sed, -n, '8,$p'); system(@top_cmd 1 top_all_threads.log); # Get your tomcat user's threads, i.e. threads of user, webinf system('/usr/bin/tail -n+6 top_all_threads.log | /bin/sort -r -n -k 9,9 | /bin/grep webinf top_all_threads.log 1 top_user_webinf_threads.log'); # Get the thread dump my @output=`/usr/bin/jstack -l ${preview_pid}`; open (my $file, '', 'preview_threaddump.txt') or die Could not open file: $!; print $file @output; close $file; open LOG, top_user_webinf_threads.log or die $!; open (STDOUT, | tee -ai top_cpu_preview_threads.log); print PID\tCPU\tMem\tJStack Info\n; while ($l = LOG) { chop $l; $pid = $l; $pid =~ s/webinf.*//g; $pid =~ s/ *//g; ## Hex PID is available in the Sun HotSpot Stack Trace */ $hex_pid = sprintf(%#x, $pid); @values = split(/\s+/, $l); $pct = $values[8]; $mem = $values[9]; # Debugger breakpoint: $DB::single = 1; # Find the Java thread that corresponds to the thread-id from the TOP output for my $j (@output) { chop $j; ($j =~ m/nid=$hex_pid/)print $hex_pid . \t . $pct . \t . $mem . \t . $j . \n; } } close (STDOUT); close LOG; --end of script -- Thanks. -Shanti On Thu, Sep 27, 2012 at
Re: R: how to read files in file system
Try: URI uri = new URI(file//c:/..); // win Or file:///yourdir/.. on unix (note 3 /). From uri you can get the url and from here you can open an inputstream or you can use new File(url.toFile()) To access a resource from your classpath the following will do: URL url = Thread.currentThread().getContextClassloader().getResource(relativeNameOfFile); Basically this should work, but its untested as my phone does not provide a java compiler :-) Jens Sent from my iPhone On 18.09.2012, at 08:21, Ge Gestione Elaboratori\(IBM Business Partner\) case...@gmail.com wrote: Excuse me Dan: attached the screenshot. paolo -Messaggio originale- Da: Daniel Mikusa [mailto:dmik...@vmware.com] Inviato: martedì 11 settembre 2012 13.51 A: Tomcat Users List Oggetto: Re: how to read files in file system On Sep 11, 2012, at 3:11 AM, IBM partner Gestione Elaboratori wrote: With jsp i can read files in the file system only if there are located under the directory webapps/application/file. If I read a file ,for example, in c:/filename Tomcats signals an error (se atthachment) Again, there is no attachment. The list is probably removing it. Please try pasting the content into your email. Please also include the error that is given. Without that, we can only guess at what is happening. Dan How to read files located everywere in the file system? paoloc - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: redirecting people to maintenance mode
What about a non-tomcat solution like a load balancer (apache, nginx?) in front of your tomcats? Sent from my iPhone On 21.08.2012, at 12:25, Miguel González Castaños miguel_3_gonza...@yahoo.es wrote: Dear all, I have a Tomcat web server. From time to time, I need to do some maintenance and want people not to interact with the Tomcat server while I'm doing it. The key thing here is that the Tomcat server is up and running. This is what I want to achieve: - I want all people to be redirected from 80/443 port at server1 to a different URL http://server2/maintenance.html except my IP address (so I can check Tomcat myself). - If possible, I want this to be transparent to the user, so they get a http redirect showing the server1 in the client's browser, not server2 (but this is not that important). I assume I can use iptables to redirect people to a different web server, but how can I know that I need to redirect them to the maintenance.html if that server is serving other web pages too? Regards, Miguel This message and any attachments are intended for the use of the addressee or addressees only. The unauthorised disclosure, use, dissemination or copying (either in whole or in part) of its content is not permitted. If you received this message in error, please notify the sender and delete it from your system. Emails can be altered and their integrity cannot be guaranteed by the sender. Please consider the environment before printing this email. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: [OT] Observer pattern?
JMS (like ActiceMQ) Terracotta DSO? Jens Sent from my iPhone On 13.06.2012, at 06:12, Albert Kam moonblade.w...@gmail.com wrote: If you are talking about how to notify other webapps, i think you're actually talking about integration between existing applications here, which can be done using RMI (java only and using a specific port), Hessian/Burlap (support several languages + http, but not java serialization) , or even Spring's HttpInvoker (java + spring + use http). But i think it's more usual for people to just implement web services, either the RESTful way or the SOAP way, which makes use of HTTP (which doesnt normally get blocked by firewall). But if the weight of your question is on the observer pattern, which is kinda like publish / subscribe, for example, publishing change event, and the listener of that type of event will execute some code (perhaps invoking external web services), i suggest you to look at google guava's EventBus code.google.com/p/guava-libraries/wiki/EventBusExplained Updating the view without user intervention is about realtime user experience, which could involve polling or pushing changes. I am not quite familiar in this, but i think polling is about using a smart timer in javascript to fetch any data changes and then update the view appropriately. For pushing data from backend to frontend, perhaps html 5's websocket could do, and perhaps comet also ? On Wed, Jun 13, 2012 at 5:00 AM, Leo Donahue - PLANDEVX leodona...@mail.maricopa.gov wrote: Could someone point me in the right direction. If three different web applications all rely on knowing when a piece of data changes, how does webapp #1 who makes the update, notify webapp #2 and webapp #3 that they need to make a request to update their view? For example: User of webapp #1 updates the status of something in a database and needs to inform the users of webapp #2 and webapp #3, who are updating other data yet watching for that status to change, that they need to update their view (fetch updated data from a database, or call some other method based on the changed status value). It sounds like the Observer pattern, but I don't know. Leo -- Do not pursue the past. Do not lose yourself in the future. The past no longer is. The future has not yet come. Looking deeply at life as it is in the very here and now, the practitioner dwells in stability and freedom. (Thich Nhat Hanh) - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org