// Test the hashring.  Note that when the hash space is expanded in
// hashring1 -> hashring2, we are checking explicitly that apple and
// orange do not move to new nodes.
int main(int argc, char **argv) {
	stats_log_verbose(1);

	hashring_t ring = create_ring("tests/hashring1.txt");
	assert(ring != NULL);
	uint32_t i;
	assert(strcmp(hashring_choose(ring, "apple", &i), "127.0.0.1:9001") == 0);
	assert(i == 2);
	assert(strcmp(hashring_choose(ring, "banana", &i), "127.0.0.1:9001") == 0);
	assert(i == 3);
	assert(strcmp(hashring_choose(ring, "orange", &i), "127.0.0.1:9000") == 0);
	assert(i == 0);
	assert(strcmp(hashring_choose(ring, "lemon", &i), "127.0.0.1:9000") == 0);
	assert(i == 1);
	hashring_dealloc(ring);

	ring = create_ring("tests/hashring2.txt");
	assert(strcmp(hashring_choose(ring, "apple", &i), "127.0.0.1:9001") == 0);
	assert(i == 2);
	assert(strcmp(hashring_choose(ring, "banana", &i), "127.0.0.1:9003") == 0);
	assert(i == 3);
	assert(strcmp(hashring_choose(ring, "orange", &i), "127.0.0.1:9000") == 0);
	assert(i == 0);
	assert(strcmp(hashring_choose(ring, "lemon", &i), "127.0.0.1:9002") == 0);
	assert(i == 1);
	hashring_dealloc(ring);

	return 0;
}
Exemple #2
0
static int start_instance(AFPacket_Context_t *afpc, AFPacketInstance *instance)
{
    struct packet_mreq mr;
    int arptype;

    /* Bind the RX ring to this interface. */
    if (bind_instance_interface(afpc, instance) != 0)
        return -1;

    /* Turn on promiscuous mode for the device. */
    memset(&mr, 0, sizeof(mr));
    mr.mr_ifindex = instance->index;
    mr.mr_type = PACKET_MR_PROMISC;
    if (setsockopt(instance->fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, sizeof(mr)) == -1)
    {
        DPE(afpc->errbuf, "%s: setsockopt: %s", __FUNCTION__, strerror(errno));
        return -1;
    }

    /* Get the link-layer type. */
    arptype = iface_get_arptype(instance);
    if (arptype < 0)
    {
        DPE(afpc->errbuf, "%s: failed to get interface type for device %s: (%d) %s",
                __FUNCTION__, instance->name, errno, strerror(errno));
        return -1;
    }

    if (arptype != ARPHRD_ETHER)
    {
        DPE(afpc->errbuf, "%s: invalid interface type for device %s: %d != %d",
                __FUNCTION__, instance->name, arptype, ARPHRD_ETHER);
        return -1;
    }

    /* Determine which versions of TPACKET the socket supports. */
    if (determine_version(afpc, instance) != DAQ_SUCCESS)
        return -1;

    /* Request the kernel RX ring from af_packet... */
    if (create_ring(afpc, instance, &instance->rx_ring, PACKET_RX_RING) != DAQ_SUCCESS)
        return -1;
    /* ...request the kernel TX ring from af_packet if we're in inline mode... */
    if (instance->peer && create_ring(afpc, instance, &instance->tx_ring, PACKET_TX_RING) != DAQ_SUCCESS)
        return -1;
    /* ...map the memory for the kernel ring(s) into userspace... */
    if (mmap_rings(afpc, instance) != DAQ_SUCCESS)
        return -1;
    /* ...and, finally, set up a userspace ring buffer to represent the kernel RX ring... */
    if (set_up_ring(afpc, instance, &instance->rx_ring) != DAQ_SUCCESS)
        return -1;
    /* ...as well as one for the TX ring if we're in inline mode. */
    if (instance->peer && set_up_ring(afpc, instance, &instance->tx_ring) != DAQ_SUCCESS)
        return -1;

    return 0;
}
Exemple #3
0
int main()
{
	struct lnode *head;
	head = create_ring(21);
	delete_lnode(head, 17);

	return 0;
}
void ShZshapeManager::create_shape(const char* content)
{
	if (content == "cube")
	{
		create_cube();
	}

	if (content == "cylinder")
	{
		create_cylinder();
	}

	if (content == "pipe")
	{
		create_pipe();
	}

	if (content == "cone")
	{
		create_cone();
	}

	if (content == "circle")
	{
		create_circle();
	}

	if (content == "ring")
	{
		create_ring();
	}

	if (content == "pyramid")
	{
		create_pyramid();
	}

	if (content == "triangle")
	{
		create_triangle();
	}

	if (content == "rectangle")
	{
		create_rectangle();
	}

	if (content == "polygon")
	{
		create_polygon();
	}

	if (content == "multigonalStar")
	{
		create_multigonalStar();
	}

}
void ShZshapeManager::create_shape(const char* content, GLdouble positionX, GLdouble positionY, GLdouble positionZ, GLdouble r)
{
	if (content == "circle")
	{
		create_circle(positionX, positionY, positionZ, r);
	}

	if (content == "ring")
	{
		create_ring(positionX, positionY, positionZ, r);
	}

	if (content == "triangle")
	{
		create_triangle(positionX, positionY, positionZ, r);
	}

	if (content == "rectangle")
	{
		create_rectangle(positionX, positionY, positionZ, r);
	}

}