Commit 6a3140fa authored by Robert Ricci's avatar Robert Ricci

Most of the time, findVlan() retries up to 10 times to find a VLAN, to

account for the time it may take for changes made at the master to
propagate to the slaves. Added a paramter to override this, as sometimes,
we know that we're talking to the master so the delay does not come into
play.

This should improve the running time of snmpit by about 10 seconds per VLAN
created, since we can tell right away if the VLAN already exists or not.
parent d2d02a3a
...@@ -370,16 +370,24 @@ sub vlanUnlock($;$) { ...@@ -370,16 +370,24 @@ sub vlanUnlock($;$) {
# #
# Given a VLAN identifier from the database, find the cisco-specific VLAN # Given a VLAN identifier from the database, find the cisco-specific VLAN
# number that is assigned to that VLAN # number that is assigned to that VLAN. Retries several times (to account
# for propagation delays) unless the $no_retry option is given.
# #
# usage: findVlan($self, $vlan_id) # usage: findVlan($self, $vlan_id,$no_retry)
# returns the VLAN number for the given vlan_id if it exists # returns the VLAN number for the given vlan_id if it exists
# returns undef if the VLAN id is not found # returns undef if the VLAN id is not found
# #
sub findVlan($$) { sub findVlan($$;$) {
my $self = shift; my $self = shift;
my $vlan_id = shift; my $vlan_id = shift;
my $max_tries = 10; my $no_retry = shift;
my $max_tries;
if ($no_retry) {
$max_tries = 1;
} else {
$max_tries = 10;
}
my $VlanName = "vtpVlanName"; # index by 1.vlan # my $VlanName = "vtpVlanName"; # index by 1.vlan #
...@@ -410,8 +418,10 @@ sub findVlan($$) { ...@@ -410,8 +418,10 @@ sub findVlan($$) {
# #
# Wait before we try again # Wait before we try again
# #
$self->debug("VLAN find failed, trying again\n"); if ($try != $max_tries) {
sleep 1; $self->debug("VLAN find failed, trying again\n");
sleep 1;
}
} }
# #
# Didn't find it # Didn't find it
......
...@@ -293,7 +293,7 @@ sub vlanExists($$) { ...@@ -293,7 +293,7 @@ sub vlanExists($$) {
# #
# The leader holds the list of which VLANs exist # The leader holds the list of which VLANs exist
# #
if ($self->{LEADER}->findVlan($vlan_id)) { if ($self->{LEADER}->findVlan($vlan_id,1)) {
return 1; return 1;
} else { } else {
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment