Commit Graph

92 Commits

Author SHA1 Message Date
Brion Vibber
26fdf0c9d2 XMPP queued output & initial retooling of DB queue manager to support non-Notice objects.
Queue handlers for XMPP individual & firehose output now send their XML stanzas
to another output queue instead of connecting directly to the chat server. This
lets us have as many general processing threads as we need, while all actual
XMPP input and output go through a single daemon with a single connection open.

This avoids problems with multiple connected resources:
* multiple windows shown in some chat clients (psi, gajim, kopete)
* extra load on server
* incoming message delivery forwarding issues

Database changes:
* queue_item drops 'notice_id' in favor of a 'frame' blob.
  This is based on Craig Andrews' work branch to generalize queues to take any
  object, but conservatively leaving out the serialization for now.
  Table updater (preserves any existing queued items) in db/rc3to09.sql

Code changes to watch out for:
* Queue handlers should now define a handle() method instead of handle_notice()
* QueueDaemon and XmppDaemon now share common i/o (IoMaster) and respawning
  thread management (RespawningDaemon) infrastructure.
* The polling XmppConfirmManager has been dropped, as the message is queued
  directly when saving IM settings.
* Enable $config['queue']['debug_memory'] to output current memory usage at
  each run through the event loop to watch for memory leaks

To do:
* Adapt XMPP i/o to component connection mode for multi-site support.
* XMPP input can also be broken out to a queue, which would allow the actual
  notice save etc to be handled by general queue threads.
* Make sure there are no problems with simply pushing serialized Notice objects
  to queues.
* Find a way to improve interactive performance of the database-backed queue
  handler; polling is pretty painful to XMPP.
* Possibly redo the way QueueHandlers are injected into a QueueManager. The
  grouping used to split out the XMPP output queue is a bit awkward.
2010-01-21 16:42:50 -08:00
Brion Vibber
0e1f2d4b47 Fix regressions in XMPP output during inbox refactoring
- NOTICE_INBOX_SOURCE_* constants moved to common.php since Notice_inbox.php not always loaded
- fixed typo in User::staticGet() call which caused user #1 to receive messages once for each subscriber instead of for him/herself
- 'continue' -> 'continue 2' inside switch() statement to fix loop escape (PHP considers switch() a looping construct for break & continue)
2010-01-13 18:17:36 +00:00
Evan Prodromou
23599da91e refactor jabber broadcast for notice_inbox removal 2010-01-13 01:13:49 -08:00
Brion Vibber
ec145b73fc Major refactoring of queue handlers to support running multiple sites in one daemon.
Key changes:
* Initialization code moved from common.php to StatusNet class;
  can now switch configurations during runtime.
* As a consequence, configuration files must now be idempotent...
  Be careful with constant, function or class definitions.
* Control structure for daemons/QueueManager/QueueHandler has been refactored;
  the run loop is now managed by IoMaster run via scripts/queuedaemon.php
  IoManager subclasses are woken to handle socket input or polling, and may
  cover multiple sites.
* Plugins can implement notice queue handlers more easily by registering a
  QueueHandler class; no more need to add a daemon.

The new QueueDaemon runs from scripts/queuedaemon.php:

* This replaces most of the old *handler.php scripts; they've been refactored
  to the bare handler classes.
* Spawns multiple child processes to spread load; defaults to CPU count on
  Linux and Mac OS X systems, or override with --threads=N
* When multithreaded, child processes are automatically respawned on failure.
* Threads gracefully shut down and restart when passing a soft memory limit
  (defaults to 90% of memory_limit), limiting damage from memory leaks.
* Support for UDP-based monitoring: http://www.gitorious.org/snqmon

Rough control flow diagram:
QueueDaemon -> IoMaster -> IoManager
                           QueueManager [listen or poll] -> QueueHandler
                           XmppManager [ping & keepalive]
                           XmppConfirmManager [poll updates]

Todo:

* Respawning features not currently available running single-threaded.
* When running single-site, configuration changes aren't picked up.
* New sites or config changes affecting queue subscriptions are not yet
  handled without a daemon restart.
* SNMP monitoring output to integrate with general tools (nagios, ganglia)
* Convert XMPP confirmation message sends to use stomp queue instead of polling
* Convert xmppdaemon.php to IoManager?
* Convert Twitter status, friends import polling daemons to IoManager
* Clean up some error reporting and failure modes
* May need to adjust queue priorities for best perf in backlog/flood cases

Detailed code history available in my daemon-work branch:
http://www.gitorious.org/~brion/statusnet/brion-fixes/commits/daemon-work
2010-01-12 20:45:09 -08:00
Ciaran Gultnieks
14421d9db3 Correction to previous commit 2010-01-07 21:01:07 +00:00
Ciaran Gultnieks
deeaafe712 Fixes to bugs where non-local messages were being wrong put in the public timeline and public xmpp feed 2010-01-07 20:59:31 +00:00
Evan Prodromou
c0d4e0990f revert adding avatar IMG to jabber output; shows entire URL in some Jabber clients 2009-11-20 03:38:24 -05:00
Craig Andrews
59e8896212 Add the [noticeid] to the end of text only jabber messages 2009-11-11 18:03:07 -05:00
Craig Andrews
074b9faee0 Remove alt text on avatar url (so pidgin doesn't show it)
surround notice_id with [], looks nicer
2009-11-11 18:00:58 -05:00
Brion Vibber
088081675f Revert "Remove more contractions"
This reverts commit 5ab709b739.

Missed this one yesterday...
2009-11-09 20:01:46 +01:00
Siebrand Mazeland
5ab709b739 Remove more contractions
* doesn't
* won't
* isn't
* don't
2009-11-08 23:32:15 +01:00
Craig Andrews
5fd7ed5b14 Display user avatar in the XMPP message
Include notice id and conversation link the XMPP message

Thanks to Deepspawn for this idea and initial code
2009-10-27 23:31:49 -04:00
Evan Prodromou
df86aa7214 define LACONICA and accept LACONICA for backwards compatibility 2009-08-26 10:41:36 -04:00
Evan Prodromou
865b716f09 change LACONICA to STATUSNET 2009-08-25 18:42:34 -04:00
Evan Prodromou
ae883ceb9b change controlyourself.ca to status.net 2009-08-25 18:19:04 -04:00
Evan Prodromou
d35b2d3f3c change laconi.ca to status.net 2009-08-25 18:16:46 -04:00
Evan Prodromou
c8b8f07af1 change Laconica and Control Yourself to StatusNet in PHP files 2009-08-25 18:12:20 -04:00
Evan Prodromou
03200235b1 use select() to bring down xmpp latency 2009-07-09 12:09:20 -04:00
CiaranG
fc6b7e28d4 Fixed jabber code broken in 3ef4f251ac 2009-03-23 22:45:03 +00:00
Evan Prodromou
3ef4f251ac One function for producing Atom entry for a Notice
Took the various places that we create an atom entry for a notice, and
jammed them together into one function of the notice class, and then
used that function. Also, added Atom threading extension and
categories for hashtags.
2009-03-22 16:58:38 -04:00
CiaranG
2133d5a4e7 PostgreSQL - some more fixes to make queries compatible with both databases. (submitted by oxygene) 2009-03-08 16:16:10 +00:00
Zach Copley
02184df7c8 Fixed arguments to syslog (LOG_ERR, not LOG_ERROR) and removed unused function 2009-02-13 10:08:11 -08:00
Evan Prodromou
d345c746b9 add related link to Atom for feeds for some downstream users 2009-02-11 08:34:21 -05:00
Evan Prodromou
343cd6f205 Move common_avatar_* functions to Avatar
Moved the common_avatar_* functions to the Avatar class. Typically
either as methods on the object or as static methods. Replaced all the
uses of the functions in other modules.
2009-02-06 03:55:48 -05:00
Ciaran Gultnieks
53274a6d93 PostgreSQL - code changes to avoid problems where user table is referenced in ad-hoc queries 2009-01-30 01:12:58 +00:00
Evan Prodromou
04b3add162 only send group notices through Jabber to users with notices enabled 2009-01-28 23:03:03 -05:00
Evan Prodromou
21d156c05b Keep checking who's received stuff in jabber broadcast 2009-01-23 03:58:18 +01:00
Evan Prodromou
4bd3eae79d Make sure group messages go out over Jabber 2009-01-23 03:29:26 +01:00
Evan Prodromou
8cd89d80f1 reformat lib/jabber.php for phpcs, including doc comments
darcs-hash:20081222173249-84dde-202ba409e32e2b27089a1bc5431507c9d8a2782e.gz
2008-12-22 12:32:49 -05:00
Evan Prodromou
4b93bc9924 on broadcast jabber and sms to people with the flags set
darcs-hash:20081210024706-5ed1f-fd54b76630656f7d4f7617309d2e4f87f25b006b.gz
2008-12-09 21:47:06 -05:00
Evan Prodromou
fcca462c11 use profile URL instead of local URL
darcs-hash:20080930210542-5ed1f-7432cf920da782ea220ef6b9e156cf1ea650a5b8.gz
2008-09-30 17:05:42 -04:00
Evan Prodromou
0c71340c9f free and unset DB_DataObjects after we're done with them
darcs-hash:20080906015501-84dde-e787962b9805759224389dd42a211dfa21da3473.gz
2008-09-05 21:55:01 -04:00
Evan Prodromou
be075ed642 add some processTime() to the send loops to avoid filling the buffer
darcs-hash:20080904213257-84dde-c046a708c6ac9f8f7ed2135f29241d70abe4104f.gz
2008-09-04 17:32:57 -04:00
Evan Prodromou
fa123bef67 restore HTML in output, remove rump pubsub event code
darcs-hash:20080902030403-84dde-5f1576104104ea57d3e23401b59493c03d5a84d4.gz
2008-09-01 23:04:03 -04:00
Evan Prodromou
ab92ba78ba slightly more robust connection code
darcs-hash:20080902030331-84dde-bb2db886d90623785f930bb7c5c3c406d407f808.gz
2008-09-01 23:03:31 -04:00
Evan Prodromou
c6c3cd40f6 separate out presence from connection, send different presence types from queuehandlers
darcs-hash:20080902012604-84dde-073a583da9b09c80e5e9a47a5eddd144fad8e87a.gz
2008-09-01 21:26:04 -04:00
Evan Prodromou
c31afa795f halt sending HTML in Jabber
darcs-hash:20080831114642-84dde-c1e486fe03752882e212bd6e3930477042f993be.gz
2008-08-31 07:46:42 -04:00
Evan Prodromou
c46f152697 forgot to use the array for avoiding dupes
darcs-hash:20080830094252-84dde-bf6c17d7036c84bfeaf41d2fc704cc8656a083c1.gz
2008-08-30 05:42:52 -04:00
Evan Prodromou
72d8bb12e1 use priority in connection
darcs-hash:20080830091522-84dde-75121e8794f2a43b8a4c5bff7ec42cac40d5520c.gz
2008-08-30 05:15:22 -04:00
Evan Prodromou
6c42bdc448 get rid of Laconica_XMPP and ignore priority
darcs-hash:20080830084423-84dde-7749d00c4c2fcada9e0f30af044637c48c0512c3.gz
2008-08-30 04:44:23 -04:00
Evan Prodromou
19147201c8 forgot to get the profile in public queue handler
darcs-hash:20080830071232-84dde-90bad1be7a7e141927175e42d39cb21d7bba337e.gz
2008-08-30 03:12:32 -04:00
Evan Prodromou
b17bb9861c lost $sent_to in jabber_public_notice
darcs-hash:20080829200859-84dde-d1c4c5897096a06dec8be14e81499d70a79c78d2.gz
2008-08-29 16:08:59 -04:00
Evan Prodromou
f5fe013657 many jabber queue management changes
Added a method to QueueManager to let subclasses do stuff when idle.
Needed so that XMPP queue manager can service its message queue.

Cleaned up jabber_broadcast_message quite a bit. Use custom joins
instead of loop-and-query, should fix some problems with users who are
getting messages even after turning off notification. Only build $msg
and $entry once, and use the XMPPHP function for messages with a
payload, rather than rolling our own.

darcs-hash:20080829200352-84dde-427e4ca8c81d4222a36f78e7c580b611ff0bf765.gz
2008-08-29 16:03:52 -04:00
Evan Prodromou
c4d6789275 split public stream to its own queue handler
Add another queue handler for the public stream. Should further
parallelize the work of sending out messages.

darcs-hash:20080829181702-84dde-594505aa73d2380b13bd98917b70b02bac597d12.gz
2008-08-29 14:17:02 -04:00
Evan Prodromou
2be3be1c29 correct presence in jabber function
darcs-hash:20080828001936-84dde-e4ec2fef30c49d1254d5358624a4391930811832.gz
2008-08-27 20:19:36 -04:00
Evan Prodromou
b9f0ea6f0e break up monolithic xmppdaemon into multiple queue handlers
Eventually, the poor xmppdaemon has become overloaded with extra
tasks. So, I've broken it up. Now, we have 5 background scripts, and
more coming:

* xmppdaemon.php - handles incoming XMPP messages only.
* xmppqueuehandler.php - sends notices from the queue out through XMPP.
* smsqueuehandler.php - sends notices from the queue out over SMS
* ombqueuehandler.php - sends notices from the queue out over OMB
* xmppconfirmhandler.php - sends confirmation requests out over XMPP.

This is in addition to maildaemon.php, which takes incoming messages.

None of these are "true" daemons -- they don't daemonize themselves
automatically. Use nohup or another tool to background them. monit can
also be useful to keep them running.

At some point, these might become fork()'ing daemons, able to handle
more than one notice at a time. For now, I'm just running multiple
instances, hoping they don't interfere.

darcs-hash:20080827205407-84dde-97884a12f5f4e54c93bc785bd280683d1ee7e749.gz
2008-08-27 16:54:07 -04:00
Evan Prodromou
0bc0568e66 only send local messages to public XMPP stream
darcs-hash:20080826205341-84dde-04c1641f4b9c5aa5318b76512664ee9df170d779.gz
2008-08-26 16:53:41 -04:00
Evan Prodromou
782fe0130f optionally turn encryption on or off in the XMPP connection
For identi.ca, we had some problems with the XMPP daemon getting
"stuck" in I/O through the encrypted (by default) XMPP socket. Turning
off encryption helped. So, now it's an option.

darcs-hash:20080826131814-84dde-2c4a809c6fb666dfb4b96d0d61205fe418f4e4b4.gz
2008-08-26 09:18:14 -04:00
CiaranG
192a673472 Prevent jabber.php error by checking key exists
darcs-hash:20080823053548-f6e2c-dfc8a0acd9fb8589ed37e54c7d0d3d38afff34f5.gz
2008-08-23 01:35:48 -04:00
CiaranG
6593092bfd Escape profile url in xmpp in case fancy urls off (Ticket #521)
darcs-hash:20080823052534-f6e2c-aa452a8c2c6ee33399f4079d0bf2224847e1450a.gz
2008-08-23 01:25:34 -04:00