Hashar has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/71597


Change subject: $wgHTCPMulticastRouting now support multiple hosts
......................................................................

$wgHTCPMulticastRouting now support multiple hosts

The HTCP routing let you split purges to different hosts according to
the URL.  In some case, we want to be able to purge an URL from more
than one multicast group.  A Wikimedia example would be to send text
related purges to the text and mobiles caches while upload purges are
sent to the upload caches.

An abstracted example would be:

$wgHTCPMulticastRouting = array(

        // upload URLs to upload caches
        '/(upload|thumbs)/' => array(
                'host' => '<ip for upload caches>'
        ),

        // Everything else to text & mobile
        '' => array(
                array( 'host' => '<ip for text caches>' ),
                array( 'host' => '<ip for mobile caches>' ),
        ),

);

Change-Id: Ie87f6b81007f47f9cb439371743f3ad9a4b0c774
---
M RELEASE-NOTES-1.22
M includes/DefaultSettings.php
M includes/cache/SquidUpdate.php
3 files changed, 34 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/97/71597/1

diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 6393252..78adc87 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -119,6 +119,9 @@
   watchlists.
 * (bug 40518) mw.toolbar: Implemented mw.toolbar.addButtons for adding multiple
  button objects in one call.
+* $wgHTCPMulticastRouting rules now be passed an array of hosts/ports to send
+  purge too. Can be used whenever several multicast group could be interested
+  by a specific purge.
 
 === Bug fixes in 1.22 ===
 * Disable Special:PasswordReset when $wgEnableEmail is false. Previously one
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 31659f3..13d192c 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -2168,9 +2168,9 @@
  * Each key in this array is a regular expression to match against the purged
  * URL, or an empty string to match all URLs. The purged URL is matched against
  * the regexes in the order specified, and the first rule whose regex matches
- * is used.
+ * is used, all remaining rules will thus be ignored.
  *
- * Example configuration to send purges for upload.wikimedia.org to one
+ * @par Example configuration to send purges for upload.wikimedia.org to one
  * multicast group and all other purges to another:
  * @code
  * $wgHTCPMulticastRouting = array(
@@ -2185,6 +2185,21 @@
  * );
  * @endcode
  *
+ * You can also past an array of hosts to send purges too. This is useful when
+ * you have several multicast groups that should receive a given purge. This
+ * feature has been introduced with MediaWiki 1.22.
+ * @par Example of sending purges to multiple hosts:
+ * @code
+ * $wgHTCPMulticastRouting = array(
+ *     '' => array(
+ *         // Purges to text caches
+ *         array( 'host' => '239.128.0.114', 'port' => '4827' ),
+ *         // Purges to mobile caches
+ *         array( 'host' => '239.128.0.115', 'port' => '4827' ),
+ *     ),
+ * );
+ * @endcode
+ *
  * @since 1.20
  *
  * @see $wgHTCPMulticastTTL
diff --git a/includes/cache/SquidUpdate.php b/includes/cache/SquidUpdate.php
index 6cc59b7..b278354 100644
--- a/includes/cache/SquidUpdate.php
+++ b/includes/cache/SquidUpdate.php
@@ -208,9 +208,16 @@
                                        "No HTCP rule configured for URL $url , 
skipping\n" );
                                continue;
                        }
-                       if ( !isset( $conf['host'] ) || !isset( $conf['port'] ) 
) {
-                               wfProfileOut( __METHOD__ );
-                               throw new MWException( "Invalid HTCP rule for 
URL $url\n" );
+
+                       if( isset( $conf['host'] ) && isset( $conf['port'] ) ) {
+                               // Normalize single entries
+                               $conf = array( $conf );
+                       }
+                       foreach( $conf as $subconf ) {
+                               if ( !isset( $subconf['host'] ) || !isset( 
$subconf['port'] ) ) {
+                                       wfProfileOut( __METHOD__ );
+                                       throw new MWException( "Invalid HTCP 
rule for URL $url\n" );
+                               }
                        }
 
                        // Construct a minimal HTCP request diagram
@@ -232,11 +239,12 @@
                                $htcpLen, $htcpDataLen, $htcpOpCLR,
                                $htcpTransID, $htcpSpecifier, 2 );
 
-                       // Send out
                        wfDebugLog( 'squid', __METHOD__ .
                                "Purging URL $url via HTCP\n" );
-                       socket_sendto( $conn, $htcpPacket, $htcpLen, 0,
-                               $conf['host'], $conf['port'] );
+                       foreach( $conf as $subconf ) {
+                               socket_sendto( $conn, $htcpPacket, $htcpLen, 0,
+                                       $subconf['host'], $subconf['port'] );
+                       }
                }
                wfProfileOut( __METHOD__ );
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/71597
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie87f6b81007f47f9cb439371743f3ad9a4b0c774
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Hashar <has...@free.fr>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to