From 7a74185288ff9df0298e75dba8c4140974e53b0d Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Fri, 22 Jul 2016 05:30:59 +0300 Subject: Keep track of connections, introduce per-vhost limits Part of rabbitmq/rabbitmq-server#500. Squashed commit of the following: commit 2f0a08dde4a027e0e9e768a36c4ee93807189809 Author: Michael Klishin Date: Thu Jul 21 03:20:07 2016 +0300 Name is already a binary commit 0678f00e6f1ee1c71a8bcb57d95205a13fb2d021 Merge: f16db88 e1905b5 Author: Michael Klishin Date: Thu Jul 21 03:06:02 2016 +0300 Merge branch 'master' into rabbitmq-server-500 commit f16db88f3daa6eb82aed015f3a23279aa72aeb84 Author: Michael Klishin Date: Wed Jul 20 18:30:13 2016 +0300 Missing file from earlier commit commit f284cf96bbdee413199d5843015a8b30ca784962 Merge: 6998e6a 35c7a8d Author: Michael Klishin Date: Wed Jul 20 18:29:57 2016 +0300 Merge branch 'master' into rabbitmq-server-500 commit 6998e6a865bdf29ca9d294467d7b047c6499c94f Author: Michael Klishin Date: Mon Jul 18 11:15:19 2016 +0300 Move connection record to rabbit.hrl So that it can be used outside of rabbit_reader. commit 1f1f6a1a71b8c6d84129734bb19109041e4cc1d7 Merge: d35bb6e ee2295a Author: Michael Klishin Date: Thu Jul 14 15:26:03 2016 +0300 Merge branch 'master' into rabbitmq-server-500 commit d35bb6ef590fd93935ef19ff48e63f028793be36 Merge: 26bff83 14219ef Author: Michael Klishin Date: Thu Jul 7 13:45:17 2016 +0300 Merge branch 'master' into rabbitmq-server-500 commit 26bff832f8824d5df8b9c2b705984f2956db5851 Author: Michael Klishin Date: Wed Jul 6 12:31:47 2016 +0300 Connection re-registration after network split WIP commit 9cc96f0253001db46cbff525f7bba80b400b6a6b Author: Michael Klishin Date: Sun Jul 3 15:25:15 2016 +0300 Move set_partition_handling_mode_globally/2 and set_partition_handling_mode/3 to broker helpers commit 5997e06987e73573babe3b5bff234a5920da47ea Author: Michael Klishin Date: Sun Jul 3 03:54:02 2016 +0300 Move block_traffic_between/2, allow_traffic_between/2 from partition_SUITE commit c9bb2d2a22c6d0d08051a183a7db0a3ab12cf622 Merge: 1395888 c7a192e Author: Michael Klishin Date: Sun Jul 3 03:14:36 2016 +0300 Merge branch 'master' into rabbitmq-server-500 commit 1395888dcaed3aa397755464aff904b6bd85735f Author: Michael Klishin Date: Sun Jul 3 02:38:51 2016 +0300 Move dist_proxy helpers from partitions_SUITE commit af11e9e6cdc288e53e3fded642dfd2f9dccd31c2 Author: Michael Klishin Date: Sat Jul 2 22:27:39 2016 +0300 Test helpers for managing permissions commit e56b20c8dee9070153d5cb7c48c37331d200ac40 Author: Michael Klishin Date: Sat Jul 2 17:28:01 2016 +0300 Missing exports commit 7a458e16e7bd6776fa3cabdb9e23f8de7cbb2a35 Author: Michael Klishin Date: Sat Jul 2 17:26:07 2016 +0300 Introduce rabbit_ct_broker_helpers:{add,delete}_vhost/2 commit 6bbcaa2a0698ba83e10833dd30e28aa5fbebd2c4 Author: Michael Klishin Date: Sat Jul 2 15:02:09 2016 +0300 Export tracked_connection/0 commit 6381608e49b42423e9f6feccdcac624fe81bd982 Merge: c082ad9 fa95b43 Author: Michael Klishin Date: Sat Jul 2 02:44:05 2016 +0300 Merge branch 'master' into rabbitmq-server-500 commit c082ad94847f5cb973f819d6d5a98b5fd029152e Merge: 0ba62eb 80ebc45 Author: Michael Klishin Date: Wed Jun 29 14:26:53 2016 +0300 Merge branch 'master' into rabbitmq-server-500 commit 0ba62eb0e1bf0f027179b9928f0d244682bc016c Author: Michael Klishin Date: Thu Mar 31 01:53:36 2016 +0300 Move new types from rabbitmq-server commit d4a9ecac1e09ddad14ebc46da0682e0584bd919e Merge: b78d3d2 8284e88 Author: Michael Klishin Date: Thu Mar 31 01:50:45 2016 +0300 Merge branch 'master' into rabbitmq-server-500 commit b78d3d23d6b08fae0d108c4dc762a0f56e3a6560 Author: Michael Klishin Date: Thu Feb 18 17:08:33 2016 +0300 Enforce per-vhost connection limit commit 7e34dcaf7e852eacc6b4cb06045f044d096cab41 Merge: c7f941d 3aff671 Author: Michael Klishin Date: Wed Feb 10 12:23:43 2016 +0300 Merge branch 'master' into rabbitmq-server-500 commit c7f941d9b1f63abde695f59fe40536741fc7e4df Merge: 827b854 4ed7cfb Author: Michael Klishin Date: Fri Feb 5 23:48:31 2016 +0300 Merge branch 'master' into rabbitmq-server-500 commit 827b854e33d8d567130ac6ba68cef444e18309b2 Merge: 9720d12 0ba4756 Author: Michael Klishin Date: Wed Feb 3 11:20:21 2016 +0300 Merge branch 'master' into rabbitmq-server-500 commit 9720d12e3374a93440f22c161c26b5435d1dd74c Author: Michael Klishin Date: Wed Feb 3 11:19:01 2016 +0300 Track connection node and username commit 73756460e041cf45150607bd0da61c53962149b4 Author: Michael Klishin Date: Tue Jan 19 18:14:28 2016 +0300 Include connection name into connection_closed events commit d1f96c48cd57194b6f78cfb4a83f0978f3786dfc Author: Michael Klishin Date: Tue Jan 19 17:53:35 2016 +0300 Add protocol to tracked_connection commit 56db86a6a289d590116c4537e9e91da6825f914c Author: Michael Klishin Date: Tue Jan 19 14:45:26 2016 +0300 Introduce tracked_connection commit 0f765dc6f89851359d819e6a1917a60a288d15cb Author: Michael Klishin Date: Fri Jan 8 19:13:23 2016 +0300 Change second vhost record field to be limits --- deps/rabbit_common/include/rabbit.hrl | 84 ++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) (limited to 'deps/rabbit_common/include/rabbit.hrl') diff --git a/deps/rabbit_common/include/rabbit.hrl b/deps/rabbit_common/include/rabbit.hrl index e20a303230..34ad4f5ea8 100644 --- a/deps/rabbit_common/include/rabbit.hrl +++ b/deps/rabbit_common/include/rabbit.hrl @@ -39,7 +39,65 @@ -record(user_vhost, {username, virtual_host}). -record(user_permission, {user_vhost, permission}). --record(vhost, {virtual_host, dummy}). +%% Represents a vhost. +%% +%% Historically this record had 2 arguments although the 2nd +%% was never used (`dummy`, always undefined). This is because +%% single field records were/are illegal in OTP. +%% +%% As of 3.6.x, the second argument is vhost limits, +%% which is actually used and has the same default. +%% Nonetheless, this required a migration, see rabbit_upgrade_functions. +-record(vhost, { + %% vhost name as a binary + virtual_host, + %% proplist of limits configured, if any + limits}). + +%% Client connection, used by rabbit_reader +%% and related modules. +-record(connection, { + %% e.g. <<"127.0.0.1:55054 -> 127.0.0.1:5672">> + name, + %% used for logging: same as `name`, but optionally + %% augmented with user-supplied name + log_name, + %% server host + host, + %% client host + peer_host, + %% server port + port, + %% client port + peer_port, + %% protocol implementation module, + %% e.g. rabbit_framing_amqp_0_9_1 + protocol, + user, + %% heartbeat timeout value used, 0 means + %% heartbeats are disabled + timeout_sec, + %% maximum allowed frame size, + %% see frame_max in the AMQP 0-9-1 spec + frame_max, + %% greatest channel number allowed, + %% see channel_max in the AMQP 0-9-1 spec + channel_max, + vhost, + %% client name, version, platform, etc + client_properties, + %% what lists protocol extensions + %% does this client support? + capabilities, + %% authentication mechanism used + %% as a pair of {Name, Module} + auth_mechanism, + %% authentication mechanism state, + %% initialised by rabbit_auth_mechanism:init/1 + %% implementations + auth_state, + %% time of connection + connected_at}). -record(content, {class_id, @@ -138,6 +196,30 @@ dependency_version_requirements %% [{atom(), [string()]}] }). +%% used to track connections across virtual hosts +%% so that limits can be enforced +-record(tracked_connection_per_vhost, + {vhost, connection_count}). + +%% Used to track detailed information +%% about connections. +-record(tracked_connection, { + %% {Node, Name} + id, + node, + vhost, + name, + pid, + protocol, + %% client host + peer_host, + %% client port + peer_port, + username, + %% time of connection + connected_at + }). + %%---------------------------------------------------------------------------- -define(COPYRIGHT_MESSAGE, "Copyright (C) 2007-2016 Pivotal Software, Inc."). -- cgit v1.2.1