Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
12a6a5f4
Commit
12a6a5f4
authored
Jun 06, 2003
by
Mac Newbold
Browse files
Checkpoint changes for StateWait module. Mostly just stubs now, so it
obviously doesn't get used anywhere yet.
parent
914b4b9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
event/stated/GNUmakefile.in
View file @
12a6a5f4
...
...
@@ -16,4 +16,5 @@ all:
include $(TESTBED_SRCDIR)/GNUmakerules
install: $(addprefix $(INSTALL_SBINDIR)/, stated) \
$(addprefix $(INSTALL_LIBDIR)/, TimeoutQueue.pm)
$(addprefix $(INSTALL_LIBDIR)/, TimeoutQueue.pm) \
$(addprefix $(INSTALL_LIBDIR)/, StateWait.pm)
event/stated/StateWait.pm
0 → 100755
View file @
12a6a5f4
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2003-2003 University of Utah and the Flux Group.
# All rights reserved.
#
#
# StateWait.pm
#
# A library for waiting for nodes to reach certain states.
#
# $rv = initStateWait(\@states, @nodes);
#
# Call this first. Make sure to call it _before_ performing any
# action that may trigger one or more of the states you're
# expecting to see. Each node must see the list of states in the
# proper order, ie if @states=(stateA, stateB), it will not
# complete until the first time stateB is seen after stateA has
# been seen. Returns 0 on success.
#
# $rv = waitForState(\@failed);
#
# Do the actual waiting. Blocks until each node has either reached
# the desired state(s) or failed. Returns number of failures.
#
# $rv = endStateWait();
#
# Stop listening for states. Call this soon after waitForState.
# This must be called before calling initStateWait again.
#
package
StateWait
;
use
Exporter
;
@ISA
=
"
Exporter
";
@EXPORT
=
qw (
initStateWait
waitForState
endStateWait
);
# Any 'use' or 'require' stuff must come here, after 'package'
use
event
;
my
$server
=
"
boss
";
my
$port
=
"";
my
$URL
=
"
elvin://
$server
";
#
# Exported Sub-Routines / Functions
#
sub
initStateWait
( $@ ) {
my
(
$states
,
@nodes
)
=
@_
;
# states is an arrayref
print
"
initStateWait: states=(
"
.
join
("
,
",
@$states
)
.
"
) nodes=(
"
.
join
("
,
",
@nodes
)
.
"
)
\n
";
return
0
;
}
sub
waitForState
( $ ) {
my
(
$failed
)
=
@_
;
# failed is an arrayref
@$failed
=
();
print
"
waitForState: failed=(
"
.
join
("
,
",
@$failed
)
.
"
)
\n
";
return
0
;
}
sub
endStateWait
()
{
print
"
endStateWait
\n
";
return
0
;
}
if
(
1
)
{
# do some testing...
my
@states
=
("
SHUTDOWN
","
ISUP
");
my
@failed
=
("
foo
");
print
"
Failed was (
"
.
join
("
,
",
@failed
)
.
"
)
\n
";
initStateWait
(["
ISUP
"],
pc52
);
waitForState
(
\
@failed
);
endStateWait
();
print
"
Failed was (
"
.
join
("
,
",
@failed
)
.
"
)
\n
";
initStateWait
(
\
@states
,
pc31
,
pc32
);
waitForState
(
\
@failed
);
endStateWait
();
print
"
Failed was (
"
.
join
("
,
",
@failed
)
.
"
)
\n
";
}
# Always end a package successfully!
1
;
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment