23
23
read /3 , next_segment_boundary /1 , bounds /1 , start /2 , stop /1 ]).
24
24
25
25
-export ([add_queue_ttl /0 , avoid_zeroes /0 , store_msg_size /0 , store_msg /0 ]).
26
- -export ([scan_queue_segments /3 ]).
26
+ -export ([scan_queue_segments /3 , scan_queue_segments / 4 ]).
27
27
28
28
% % Migrates from global to per-vhost message stores
29
29
-export ([move_to_per_vhost_stores /1 ,
264
264
265
265
-spec erase (rabbit_amqqueue :name ()) -> 'ok' .
266
266
267
- erase (Name ) ->
268
- # qistate { dir = Dir } = blank_state (Name ),
267
+ erase (# resource { virtual_host = VHost } = Name ) ->
268
+ VHostDir = rabbit_vhost :msg_store_dir_path (VHost ),
269
+ # qistate { dir = Dir } = blank_state (VHostDir , Name ),
269
270
erase_index_dir (Dir ).
270
271
271
272
% % used during variable queue purge when there are no pending acks
@@ -287,8 +288,9 @@ reset_state(#qistate{ queue_name = Name,
287
288
-spec init (rabbit_amqqueue :name (),
288
289
on_sync_fun (), on_sync_fun ()) -> qistate ().
289
290
290
- init (Name , OnSyncFun , OnSyncMsgFun ) ->
291
- State = # qistate { dir = Dir } = blank_state (Name ),
291
+ init (# resource { virtual_host = VHost } = Name , OnSyncFun , OnSyncMsgFun ) ->
292
+ VHostDir = rabbit_vhost :msg_store_dir_path (VHost ),
293
+ State = # qistate { dir = Dir } = blank_state (VHostDir , Name ),
292
294
false = rabbit_file :is_file (Dir ), % % is_file == is file or dir
293
295
State # qistate {on_sync = OnSyncFun ,
294
296
on_sync_msg = OnSyncMsgFun }.
@@ -299,9 +301,10 @@ init(Name, OnSyncFun, OnSyncMsgFun) ->
299
301
{'undefined' | non_neg_integer (),
300
302
'undefined' | non_neg_integer (), qistate ()}.
301
303
302
- recover (Name , Terms , MsgStoreRecovered , ContainsCheckFun ,
303
- OnSyncFun , OnSyncMsgFun ) ->
304
- State = blank_state (Name ),
304
+ recover (# resource { virtual_host = VHost } = Name , Terms , MsgStoreRecovered ,
305
+ ContainsCheckFun , OnSyncFun , OnSyncMsgFun ) ->
306
+ VHostDir = rabbit_vhost :msg_store_dir_path (VHost ),
307
+ State = blank_state (VHostDir , Name ),
305
308
State1 = State # qistate {on_sync = OnSyncFun ,
306
309
on_sync_msg = OnSyncMsgFun },
307
310
CleanShutdown = Terms /= non_clean_shutdown ,
@@ -558,17 +561,16 @@ erase_index_dir(Dir) ->
558
561
false -> ok
559
562
end .
560
563
561
- blank_state (QueueName ) ->
562
- Dir = queue_dir (QueueName ),
564
+ blank_state (VHostDir , QueueName ) ->
565
+ Dir = queue_dir (VHostDir , QueueName ),
563
566
blank_state_name_dir_funs (QueueName ,
564
567
Dir ,
565
568
fun (_ ) -> ok end ,
566
569
fun (_ ) -> ok end ).
567
570
568
- queue_dir (# resource { virtual_host = VHost } = QueueName ) ->
571
+ queue_dir (VHostDir , QueueName ) ->
569
572
% % Queue directory is
570
573
% % {node_database_dir}/msg_stores/vhosts/{vhost}/queues/{queue}
571
- VHostDir = rabbit_vhost :msg_store_dir_path (VHost ),
572
574
QueueDir = queue_name_to_dir_name (QueueName ),
573
575
filename :join ([VHostDir , " queues" , QueueDir ]).
574
576
@@ -734,9 +736,13 @@ queue_index_walker_reader(QueueName, Gatherer) ->
734
736
end , ok , QueueName ),
735
737
ok = gatherer :finish (Gatherer ).
736
738
737
- scan_queue_segments (Fun , Acc , QueueName ) ->
739
+ scan_queue_segments (Fun , Acc , # resource { virtual_host = VHost } = QueueName ) ->
740
+ VHostDir = rabbit_vhost :msg_store_dir_path (VHost ),
741
+ scan_queue_segments (Fun , Acc , VHostDir , QueueName ).
742
+
743
+ scan_queue_segments (Fun , Acc , VHostDir , QueueName ) ->
738
744
State = # qistate { segments = Segments , dir = Dir } =
739
- recover_journal (blank_state (QueueName )),
745
+ recover_journal (blank_state (VHostDir , QueueName )),
740
746
Result = lists :foldr (
741
747
fun (Seg , AccN ) ->
742
748
segment_entries_foldr (
@@ -1468,10 +1474,11 @@ drive_transform_fun(Fun, Hdl, Contents) ->
1468
1474
drive_transform_fun (Fun , Hdl , Contents1 )
1469
1475
end .
1470
1476
1471
- move_to_per_vhost_stores (# resource {} = QueueName ) ->
1477
+ move_to_per_vhost_stores (# resource {virtual_host = VHost } = QueueName ) ->
1472
1478
OldQueueDir = filename :join ([queues_base_dir (), " queues" ,
1473
1479
queue_name_to_dir_name_legacy (QueueName )]),
1474
- NewQueueDir = queue_dir (QueueName ),
1480
+ VHostDir = rabbit_vhost :msg_store_dir_path (VHost ),
1481
+ NewQueueDir = queue_dir (VHostDir , QueueName ),
1475
1482
rabbit_log_upgrade :info (" About to migrate queue directory '~s ' to '~s '" ,
1476
1483
[OldQueueDir , NewQueueDir ]),
1477
1484
case rabbit_file :is_dir (OldQueueDir ) of
0 commit comments