Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/ytoolshed/pogo
Browse files Browse the repository at this point in the history
  • Loading branch information
Yogesh Natarajan committed May 23, 2011
2 parents 50dd7f5 + a1ad22b commit 9eb93e2
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
38 changes: 29 additions & 9 deletions lib/Pogo/Engine/Namespace.pm
Expand Up @@ -244,6 +244,8 @@ sub fetch_all_slots
{
$hostslots{$hostname} = [];

#$DB::single = 1;

foreach my $app ( @{ $hostinfo->{apps} } )
{
foreach my $envtype ( keys %{ $hostinfo->{envs} } )
Expand All @@ -267,10 +269,10 @@ sub fetch_all_slots
}
push @{ $hostslots{$hostname} }, $slot;

next unless exists $const->{$app} and
exists $const->{$app}->{$envtype};
next unless exists $const->{$envtype} and
exists $const->{$envtype}->{$app};

my $concur = $const->{$app}->{$envtype};
my $concur = $const->{$envtype}->{$app};
if ( $concur !~ m{^(\d+)%$} )
{
# not a percentage, a literal
Expand Down Expand Up @@ -434,6 +436,8 @@ sub set_conf

delete $conf_in->{envs};

#$DB::single = 1;

# constraint processing
foreach my $c_env_type ( keys %{ $conf_in->{constraints} } )
{
Expand Down Expand Up @@ -476,9 +480,8 @@ sub set_conf
# $second requires $first to go first within $env
# $first is a predecessor of $second
# $second is a successor of $first
# we just make sure these exist, don't define them
$conf->{seq}->{pred}->{$c_env_type}->{$second}->{$first};
$conf->{seq}->{succ}->{$c_env_type}->{$first}->{$second};
$conf->{seq}->{pred}->{$c_env_type}->{$second}->{$first} = 1;
$conf->{seq}->{succ}->{$c_env_type}->{$first}->{$second} = 1;
}
}

Expand Down Expand Up @@ -637,7 +640,7 @@ sub get_cur
{
my ( $self, $app, $key ) = @_;
my $c = store->get( $self->{path} . "/conf/cur/$app/$key" );
return $c;
return JSON->new->utf8->allow_nonref->decode($c);
}

sub get_curs
Expand All @@ -657,6 +660,23 @@ sub get_all_curs
return { map { $_ => $self->get_curs($_) } store->get_children($path) };
}

sub app_members {
my $self = shift;
my $app = shift;

my $path = $self->{path} . "/conf/apps/$app";
return store->get_children("$path");
}

sub env_members {
my $self = shift;
my $envtype = shift;
my $envvalue = shift;

my $path = $self->{path} . "/conf/envs/$envtype/$envvalue";
return store->get_children("$path");
}

sub get_all_seqs
{
my $self = shift;
Expand Down Expand Up @@ -929,8 +949,8 @@ Env settings:
Sequences:
/pogo/ns/nsname/conf/seq/pred/coast/frontend: []
/pogo/ns/nsname/conf/seq/succ/coast/backend: []
/pogo/ns/nsname/conf/seq/pred/coast/frontend/backend
/pogo/ns/nsname/conf/seq/succ/coast/backend/frontend
And even the plugin gets stored:
Expand Down
23 changes: 12 additions & 11 deletions t/13_unit_constrained.t
Expand Up @@ -49,7 +49,7 @@ use File::Basename;
use Pogo::Engine::Store qw(store);
use Data::Dumper;

# Log::Log4perl->easy_init({ level => $DEBUG, layout => "%F{1}-%L-%M: %m%n" });
Log::Log4perl->easy_init({ level => $DEBUG, layout => "%F{1}-%L-%M: %m%n" });

my $ns = Pogo::Engine::Namespace->new(
nsname => "wonk",
Expand Down Expand Up @@ -135,29 +135,30 @@ my $job = Pogo::Engine::Job->new({
exe_data => "wonk",
});

$job->start(
sub { ok 0, "err cont on start(): @_" },
sub { ok 1, "success cont on start()";
my($nqueued, $nwaiting) = @_;
is($nqueued, 4, "4 hosts enqueued");
is($nwaiting, 0, "0 hosts waiting");
},
);

$ns->fetch_runnable_hosts(
$job,
$host_meta,
sub { die "err cont: ", Dumper( \@_ ); },
sub { $result = \@_;
print "result=", Dumper( \@_ );
},
);

ok(1, "at the end" );

# print store->_dump();
print store->_dump();

__END__
$job->start(
sub { ok 0, "err cont on start(): @_" },
sub { ok 1, "success cont on start()";
my($nqueued, $nwaiting) = @_;
is($nqueued, 4, "4 hosts enqueued");
is($nwaiting, 0, "0 hosts waiting");
},
);
print Dumper($result);
__END__
Expand Down
4 changes: 3 additions & 1 deletion t/conf/example.yaml
Expand Up @@ -14,6 +14,8 @@ apps:
backend:
- bar[1-10].east.example.com
- bar[1-10].west.example.com
tail:
- zar[1-10].west.example.com

envs:
coast:
Expand All @@ -30,4 +32,4 @@ constraints:
- frontend: 25%
- backend: 1
sequence:
- [ backend, frontend ]
- [ backend, frontend, tail ]

0 comments on commit 9eb93e2

Please sign in to comment.