AnyEvent-MP

 view release on metacpan or  search on metacpan

MP.pm  view on Meta::CPAN


A node ID is a string that uniquely identifies the node within a
network. Depending on the configuration used, node IDs can look like a
hostname, a hostname and a port, or a random string. AnyEvent::MP itself
doesn't interpret node IDs in any way except to uniquely identify a node.

=item binds - C<ip:port>

Nodes can only talk to each other by creating some kind of connection to
each other. To do this, nodes should listen on one or more local transport
endpoints - binds.

Currently, only standard C<ip:port> specifications can be used, which
specify TCP ports to listen on. So a bind is basically just a tcp socket
in listening mode that accepts connections from other nodes.

=item seed nodes

When a node starts, it knows nothing about the network it is in - it
needs to connect to at least one other node that is already in the
network. These other nodes are called "seed nodes".

MP.pm  view on Meta::CPAN

nodes. For large networks, it can be useful to specify "regional" seed
nodes for most nodes in an area, and use all seed nodes as seed nodes for
each other. What's important is that all seed nodes connections form a
complete graph, so that the network cannot split into separate subnets
forever.

Seed nodes are represented by seed IDs.

=item seed IDs - C<host:port>

Seed IDs are transport endpoint(s) (usually a hostname/IP address and a
TCP port) of nodes that should be used as seed nodes.

=item global nodes

An AEMP network needs a discovery service - nodes need to know how to
connect to other nodes they only know by name. In addition, AEMP offers a
distributed "group database", which maps group names to a list of strings
- for example, to register worker ports.

A network needs at least one global node to work, and allows every node to

MP/DataConn.pm  view on Meta::CPAN

   my $state = $STATE{$id}
      or return;

   my $addr = $AnyEvent::MP::Global::addr{$node};

   @$addr
      or return $state->{done}(undef, "$node: no listeners found");

   # I love hardcoded constants  !
   $state->{next} = AE::timer 0, 2, sub {
      my $endpoint = shift @$addr
         or return delete $state->{next};

      my ($host, $port) = AnyEvent::Socket::parse_hostport $endpoint
         or return;

      my $transport; $transport = AnyEvent::MP::Transport::mp_connect
         $host, $port,
         protocol => "aemp-dataconn",
         local_greeting => { dataconn_id => $id },
         sub { $transport->destroy }, #TODO: destroys handshaked connections too early
      ;
   };
}

MP/Node.pm  view on Meta::CPAN

   AE::log 9 => "connecting to $self->{id} with [@$addresses]";

   my $monitor  = $AnyEvent::MP::Kernel::CONFIG->{monitor_timeout};
   my $interval = $AnyEvent::MP::Kernel::CONFIG->{connect_interval};

   $interval = ($monitor - $interval) / @$addresses
      if ($monitor - $interval) / @$addresses < $interval;

   $interval = 0.4 if $interval < 0.4;

   my @endpoints = reverse @$addresses;

   $self->{connect_w} = AE::timer 0, $interval * (0.9 + 0.1 * rand), sub {
      my $endpoint = pop @endpoints
         or return;

      AE::log 9 => "connecting to $self->{id} at $endpoint";

      $self->{trial}{$endpoint} ||= do {
         my ($host, $port) = AnyEvent::Socket::parse_hostport $endpoint
            or return AE::log critical => "$self->{id}: '$endpoint' is not a resolved node reference.";

         AnyEvent::MP::Transport::mp_connect
            $host, $port,
            sub { delete $self->{trial}{$endpoint} },
      };
   };
}

sub kill {
   my ($self, $port, @reason) = @_;

   $self->{send} (["", kil1 => $port, @reason]);
}

README  view on Meta::CPAN

    node ID - "[A-Za-z0-9_\-.:]*"
        A node ID is a string that uniquely identifies the node within a
        network. Depending on the configuration used, node IDs can look like
        a hostname, a hostname and a port, or a random string. AnyEvent::MP
        itself doesn't interpret node IDs in any way except to uniquely
        identify a node.

    binds - "ip:port"
        Nodes can only talk to each other by creating some kind of
        connection to each other. To do this, nodes should listen on one or
        more local transport endpoints - binds.

        Currently, only standard "ip:port" specifications can be used, which
        specify TCP ports to listen on. So a bind is basically just a tcp
        socket in listening mode that accepts connections from other nodes.

    seed nodes
        When a node starts, it knows nothing about the network it is in - it
        needs to connect to at least one other node that is already in the
        network. These other nodes are called "seed nodes".

README  view on Meta::CPAN

        For small networks, it's best if every node uses the same set of
        seed nodes. For large networks, it can be useful to specify
        "regional" seed nodes for most nodes in an area, and use all seed
        nodes as seed nodes for each other. What's important is that all
        seed nodes connections form a complete graph, so that the network
        cannot split into separate subnets forever.

        Seed nodes are represented by seed IDs.

    seed IDs - "host:port"
        Seed IDs are transport endpoint(s) (usually a hostname/IP address
        and a TCP port) of nodes that should be used as seed nodes.

    global nodes
        An AEMP network needs a discovery service - nodes need to know how
        to connect to other nodes they only know by name. In addition, AEMP
        offers a distributed "group database", which maps group names to a
        list of strings - for example, to register worker ports.

        A network needs at least one global node to work, and allows every
        node to be a global node.



( run in 0.260 second using v1.01-cache-2.11-cpan-b61123c0432 )