MongoDB/Op/_FSyncUnlock.pm

filter: Statementstmt 78.4% 40 / 51 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 12 / 15 Podpod 0.0% 0 / 1 totaltotal 75.3% 52 / 69 CC 2 SCAR 5.6
CC
2
Cov
75%
execute
6.0
_command_fsync_unlock
2.0
_legacy_fsync_unlock
2.0
CRAP 1.8
« MongoDB/_Constants.pm ↑ Summary MongoDB/_Types.pm »
1 # Copyright 2015 - present MongoDB, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14  
15 59 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 59 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 package MongoDB::Op::_FSyncUnlock;
18  
19 # Encapsulate collection list operations; returns arrayref of collection
20 # names
21  
22 59 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 59 our $VERSION = 'v2.2.2';
24  
25 59 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 59 ▶use MongoDB::Op::_Command;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 59 ▶use MongoDB::Op::_Query;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 59 ▶use MongoDB::ReadConcern;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 59 ▶use MongoDB::ReadPreference;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 59 ▶use MongoDB::_Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
32 Document
33 59 );
34 59 ▶use Types::Standard qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
35 InstanceOf
36 59 );
37 59 ▶use Tie::IxHash;
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 59 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 59 has client => (
42 is => 'ro',
43 required => 1,
44 isa => InstanceOf['MongoDB::MongoClient'],
45 );
46  
47 59 with $_ for qw(
48 MongoDB::Role::_PrivateConstructor
49 MongoDB::Role::_DatabaseOp
50 );
51  
52 0 ▶sub execute {
Subroutine execute: not called CC=2 SCAR=17.9
Pod undocumented
53 0 my ( $self, $link, $topology ) = @_;
54  
55 0 ▶ my $res =
Branch: 1 branch
BranchTrueFalseTotal
$link->supports_fsync_command ? : 0 0 0
56 $link->supports_fsync_command
57 ? $self->_command_fsync_unlock( $link, $topology )
58 : $self->_legacy_fsync_unlock( $link, $topology );
59  
60 0 return $res;
61 }
62  
63 0 ▶sub _command_fsync_unlock {
Subroutine _command_fsync_unlock: not called CC=1 SCAR=6.9
64 0 my ( $self, $link, $topology ) = @_;
65  
66 0 my $cmd = Tie::IxHash->new(
67 fsyncUnlock => 1,
68 );
69  
70 0 my $op = MongoDB::Op::_Command->_new(
71 db_name => $self->db_name,
72 query => $cmd,
73 query_flags => {},
74 read_preference => MongoDB::ReadPreference->new,
75 bson_codec => $self->bson_codec,
76 monitoring_callback => $self->monitoring_callback,
77 );
78  
79 0 my $res = $op->execute( $link, $topology );
80  
81 0 return $res->{output};
82 }
83  
84 0 ▶sub _legacy_fsync_unlock {
Subroutine _legacy_fsync_unlock: not called CC=1 SCAR=6.9
85 0 my ( $self, $link, $topology ) = @_;
86  
87 0 my $op = MongoDB::Op::_Query->_new(
88 bson_codec => $self->bson_codec,
89 client => $self->client,
90 coll_name => '$cmd.sys.unlock',
91 db_name => 'admin',
92 filter => {},
93 full_name => 'admin.$cmd.sys.unlock',
94 options => MongoDB::Op::_Query->precondition_options( { limit => -1 } ),
95 read_concern => MongoDB::ReadConcern->new,
96 read_preference => MongoDB::ReadPreference->new,
97 monitoring_callback => $self->monitoring_callback,
98 );
99  
100 0 return $op->execute( $link, $topology )->next;
101 }
102  
103 59 1;
« MongoDB/_Constants.pm ↑ Summary MongoDB/_Types.pm »