Add a node to a pool
491828
def add_pool_member(self, name, port, pool_name):
        '''
        
        '''
        if not self.check_pool(pool_name):
            raise CommandExecutionError(
                '{0} pool does not exists'.format(pool_name)
            )

        members_seq = self.bigIP.LocalLB.Pool.typefactory.create(
            'Common.IPPortDefinitionSequence'
        )
        members_seq.items = []

        member = self.bigIP.LocalLB.Pool.typefactory.create(
            'Common.IPPortDefinition'
        )

        member.address = name
        member.port = port

        members_seq.items.append(member)

        try:
            self.bigIP.LocalLB.Pool.add_member(pool_names=[pool_name],
                                               members=[members_seq])
        except Exception as e:
            raise Exception(
                'Unable to add `{0}` to `{1}`\n\n{2}'.format(name,
                                                             pool_name,
                                                             e)
            )
        return True
558333
def add_node(node)
      raise Abuelo::Exceptions::NodeAlreadyExistsError if has_node?(node)

      @nodes[node.name] = node
      node.graph = self

      self
    end
1310672
def add_node(self, node):
        """"""
        self.nodes.append(node)

        # add node_ids
        try:
            if node.node_id != b"$stats":
                self.node_ids.append(node.node_id)
        except NotImplementedError:
            raise
        except Exception:
            print("ERROR: getting Node")
744461
def add_node_to_network(self, node, network):
        """"""
        network.add_node(node)
        node.receive()

        environment = network.nodes(type=Environment)[0]
        environment.connect(whom=node)

        gene = node.infos(type=LearningGene)[0].contents
        if (gene == "social"):
            prev_agents = RogersAgent.query\
                .filter(and_(RogersAgent.failed == False,
                             RogersAgent.network_id == network.id,
                             RogersAgent.generation == node.generation - 1))\
                .all()
            parent = random.choice(prev_agents)
            parent.connect(whom=node)
            parent.transmit(what=Meme, to_whom=node)
        elif (gene == "asocial"):
            environment.transmit(to_whom=node)
        else:
            raise ValueError("{} has invalid learning gene value of {}"
                             .format(node, gene))
        node.receive()
247819
def add(self, connection):
        
        if id(connection) in self.connections:
            raise ValueError('Connection already exists in pool')

        if len(self.connections) == self.max_size:
            LOGGER.warning('Race condition found when adding new connection')
            try:
                connection.close()
            except (psycopg2.Error, psycopg2.Warning) as error:
                LOGGER.error('Error closing the conn that cant be used: %s',
                             error)
            raise PoolFullError(self)
        with self._lock:
            self.connections[id(connection)] = Connection(connection)
        LOGGER.debug('Pool %s added connection %s', self.id, id(connection))
657478
public synchronized void addAll(T... nodes) {
        for (T node : nodes)
            addInternal(node,defaultReplication);
        refreshTable();
    }

    /**
     * 
     */
    public synchronized void addAll(Collection<? extends T> nodes) {
        for (T node : nodes)
            addInternal(node,defaultReplication);
        refreshTable();
    }

    /**
     * Calls {@link #add(Object,int)} with all the arguments.
     */
    public synchronized void addAll(Map<? extends T,Integer> nodes) {
        for (Map.Entry<? extends T,Integer> node : nodes.entrySet())
            addInternal(node.getKey(),node.getValue());
        refreshTable();
    }

    /**
     * Removes the node entirely. This is the same as {@code add(node,0)}
     */
    public synchronized void remove(T node) {
        add(node, 0);
    }

    /**
     * Adds a new node with the given number of replica.
     */
    public synchronized void add(T node, int replica) {
        addInternal(node, replica);
        refreshTable();
    }

    private synchronized void addInternal(T node, int replica) {
        if (replica==0) {
            items.remove(node);
        } else {
            Point[] points = new Point[replica];
            String seed = hash.hash(node);
            for (int i=0; i<replica; i++)
                points[i] = new Point(md5(seed+':'+i),node);
            items.put(node,points);
        }
    }

    private synchronized void refreshTable() {
        table = new Table();
    }

    /**
     * Compresses a string into an integer with MD5.
     */
    private int md5(String s) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(s.getBytes());
            byte[] digest = md5.digest();

            // 16 bytes -> 4 bytes
            for (int i=0; i<4; i++)
                digest[i] ^= digest[i+4]+digest[i+8]+digest[i+12];
            return (b2i(digest[0])<< 24)|(b2i(digest[1])<<16)|(b2i(digest[2])<< 8)|b2i(digest[3]);
        } catch (GeneralSecurityException e) {
            throw new RuntimeException("Could not generate MD5 hash", e);
        }
    }

    /**
     * unsigned byte->int.
     */
    private int b2i(byte b) {
        return ((int)b)&0xFF;
    }

    /**
     * Looks up a consistent hash with the given data point.
     *
     * <p>
     * The whole point of this class is that if the same query point is given,
     * it's likely to return the same result even when other nodes are added/removed,
     * or the # of replicas for the given node is changed.
     *
     * @return
     *      null if the consistent hash is empty. Otherwise always non-null.
     */
    public T lookup(int queryPoint) {
        return table.lookup(queryPoint);
    }

    /**
     * Takes a string, hash it with MD5, then calls {@link #lookup(int)}. 
     */
    public T lookup(String queryPoint) {
        return lookup(md5(queryPoint));
    }

    /**
     * Creates a permutation of all the nodes for the given data point.
     *
     * <p>
     * The returned permutation is consistent, in the sense that small change
     * to the consistent hash (like addition/removal/change of replicas) only
     * creates a small change in the permutation.
     *
     * <p>
     * Nodes with more replicas are more likely to show up early in the list
     */
    public Iterable<T> list(final int queryPoint) {
        return new Iterable<T>() {
            public Iterator<T> iterator() {
                return table.list(queryPoint);
            }
        };
    }

    /**
     * Takes a string, hash it with MD5, then calls {@link #list(int)}.
     */
    public Iterable<T> list(String queryPoint) {
        return list(md5(queryPoint));
    }
}
673337
private void add(int previous, int index, Trie.Node node) {

        if (!node.getChildren().isEmpty() && node.hasSinglePath()
                        && node.getChildren().get(0).getKey() != TERMINATING_CHARACTER) { // If node has only one path, put the rest in tail array
            baseBuffer.put(index, tailIndex); // current index of tail array
            addToTail(node.getChildren().get(0));
            checkBuffer.put(index, previous);
            return; // No more child to process
        }

        int startIndex = (compact ? 0 : index);
        int base = findBase(startIndex, node.getChildren());

        baseBuffer.put(index, base);

        if (previous >= 0) {
            checkBuffer.put(index, previous); // Set check value
        }

        for (Trie.Node child : node.getChildren()) { // For each child to double array trie
            if (compact) {
                add(index, base + child.getKey(), child);
            } else {
                add(index, index + base + child.getKey(), child);
            }
        }

    }
359042
public void add(T node) {
		for (int i = 0; i < numberOfReplicas; i++) {
			circle.put(hashFunc.hash(node.toString() + i), node);
		}
	}
988730
def add_node(self, node, weight=1):
        
        self._nodes.add(node)
        self._weights[node] = weight
        self._hashring = dict()
        self._sorted_keys = []

        self._build_circle()
1284157
public boolean add(Object o) {
        synchronized (pool) {
            if (index < pool.length) {
                pool[index++] = o;
                // if (DEBUG && tc.isDebugEnabled() )
                // Tr.debug(tc,"added to pool " + name + " at " + index);
                return true;
            }
        }
        // if (DEBUG && tc.isDebugEnabled() )
        // Tr.debug(tc,"pool " + name + " is full");
        return false;
    }
266157
def add_node(self, node):
        """"""
        other_nodes = [n for n in self.nodes() if n.id != node.id]
        if len(self.nodes()) > 11:
            parents = [max(other_nodes, key=attrgetter("creation_time"))]
        else:
            parents = [n for n in other_nodes if isinstance(n, Source)]

        for parent in parents:
            parent.connect(whom=node)
762539
def addNode(self, node):
        
        LOGGER.info('Adding node {}({})'.format(node.name, node.address))
        message = {
            'addnode': {
                'nodes': [{
                    'address': node.address,
                    'name': node.name,
                    'node_def_id': node.id,
                    'primary': node.primary,
                    'drivers': node.drivers,
                    'hint': node.hint
                }]
            }
        }
        self.send(message)
331599
def add_node(self, node):
        """"""
        nodes = [n for n in self.nodes() if not isinstance(n, Source)]
        num_agents = len(nodes)
        curr_generation = int((num_agents - 1) / float(self.generation_size))
        node.generation = curr_generation

        if curr_generation == 0:
            if self.initial_source:
                source = min(
                    self.nodes(type=Source),
                    key=attrgetter('creation_time'))
                source.connect(whom=node)
                source.transmit(to_whom=node)
        else:
            prev_agents = Node.query\
                .filter_by(failed=False,
                           network_id=self.id,
                           generation=(curr_generation - 1))\
                .all()
            prev_fits = [p.fitness for p in prev_agents]
            prev_probs = [(f / (1.0 * sum(prev_fits))) for f in prev_fits]

            rnd = random.random()
            temp = 0.0
            for i, probability in enumerate(prev_probs):
                temp += probability
                if temp > rnd:
                    parent = prev_agents[i]
                    break

            parent.connect(whom=node)
            parent.transmit(to_whom=node)
216041
function add(node, parent) {
      var children = parent ? parent.children : tokens
      var prev = children[children.length - 1]
      var fn

      if (
        prev &&
        node.type === prev.type &&
        (node.type === 'text' || node.type === 'blockquote') &&
        mergeable(prev) &&
        mergeable(node)
      ) {
        fn = node.type === 'text' ? mergeText : mergeBlockquote
        node = fn.call(self, prev, node)
      }

      if (node !== prev) {
        children.push(node)
      }

      if (self.atStart && tokens.length !== 0) {
        self.exitStart()
      }

      return node
    }
254582
def add_node(node, parent):
    '''
    '''
    newNode = dict(node_id=node.id, children=[])
    parent["children"].append(newNode)
    if node.left: add_node(node.left, newNode)
    if node.right: add_node(node.right, newNode)
1005170
def add_node(self, payload):
        
        self.nodes.append(Node(len(self.nodes), payload))
        return len(self.nodes) - 1
189294
def append(self, node):
        ""
        if not isinstance(node, self.__class__):
            raise TypeError('Expected Node instance, got %r' % node)
        self.nodes.append(node)