Пример #1
0
CaSelector::CaSelector(QWidget *parent) :
	QDialog(parent),
	ca_type_edit("ca type"),
	formula_edit("ca formula:"),
	input_edit("input formula:"),
	button_box( new QDialogButtonBox(
		QDialogButtonBox::Ok |
		QDialogButtonBox::Cancel,
		Qt::Horizontal,
		this)
		)
{
	ca_type_edit.widget().addItem("formula");
	ca_type_edit.widget().addItem("file");
	ca_type_edit.widget().addItem("custom name");
	ca_type_edit.widget().setDisabled(true);

	vbox_main.addLayout(&ca_type_edit.layout());
	vbox_main.addLayout(&formula_edit.layout());
	vbox_main.addLayout(&input_edit.layout());
	vbox_main.addWidget(button_box);
	setLayout(&vbox_main);

	connect(button_box, SIGNAL(accepted()), this, SLOT(try_accept()));
	connect(button_box, SIGNAL(rejected()), this, SLOT(reject()));
}
Пример #2
0
static void
proposer_handle_msg(struct evproposer* p, struct bufferevent* bev)       //proposer处理各种类型的消息
{
	paxos_msg msg;
	struct evbuffer* in;
	char buffer[PAXOS_MAX_VALUE_SIZE];

	in = bufferevent_get_input(bev);
	evbuffer_remove(in, &msg, sizeof(paxos_msg));            //将消息文件头从输入buffer移动到msg中
	if (msg.data_size > PAXOS_MAX_VALUE_SIZE) {           //消息内容过大,丢弃
		evbuffer_drain(in, msg.data_size);
		paxos_log_error("Discarding message of size %ld. Maximum is %d",
			msg.data_size, PAXOS_MAX_VALUE_SIZE);
		return;
	}
	evbuffer_remove(in, buffer, msg.data_size);         //将消息的内容移动到buffer中
	
	switch (msg.type) {
		case prepare_acks:
			proposer_handle_prepare_ack(p, (prepare_ack*)buffer);
			break;
		case accept_acks:
			proposer_handle_accept_ack(p, (accept_ack*)buffer);
			break;
		case submit:
			proposer_handle_client_msg(p, buffer, msg.data_size);
			break;
		default:
			paxos_log_error("Unknow msg type %d not handled", msg.type);
			return;
	}
	
	try_accept(p);
}
Пример #3
0
static void
proposer_handle_accepted(struct proposer *p, struct paxos_accepted *ack)
{
    if (proposer_receive_accepted(p, ack)) {
        rte_log(RTE_LOG_DEBUG, RTE_LOGTYPE_USER8,
                "Reach Quorum. Instance: %d\n",
                ack->iid);
        rte_atomic32_add(&stat, 1);
        try_accept(p);
    }
}
Пример #4
0
static void
proposer_handle_promise(struct proposer *p, struct paxos_promise *promise)
{
    struct paxos_message msg;
    msg.type = PAXOS_PREPARE;
    int preempted = proposer_receive_promise(p, promise, &msg.u.prepare);
    if (preempted) {
        rte_log(RTE_LOG_DEBUG, RTE_LOGTYPE_USER8,
                "%s Prepare instance %d ballot %d\n",
                __func__, msg.u.prepare.iid, msg.u.prepare.ballot);
        send_paxos_message(&msg);
    }
    try_accept(p);
}
Пример #5
0
/*proposer处理网络消息接口*/
static void proposer_handle_msg(struct evproposer* p, struct bufferevent* bev)
{
	paxos_msg msg;
	struct evbuffer* in;
	char* buffer = NULL;

	/*解读消息头*/
	in = bufferevent_get_input(bev);
	evbuffer_remove(in, &msg, sizeof(paxos_msg));

	/*解读消息体*/
	if (msg.data_size > 0) {
		buffer = malloc(msg.data_size);
		evbuffer_remove(in, buffer, msg.data_size);
	}

	/*处理消息*/
	switch (msg.type){
	case prepare_acks:
		proposer_handle_prepare_ack(p, (prepare_ack*)buffer);
		break;
	case accept_acks:
		proposer_handle_accept_ack(p, (accept_ack*)buffer);
		break;
	case submit:
		proposer_handle_client_msg(p, buffer, msg.data_size);
		break;
	default:
		paxos_log_error("Unknow msg type %d not handled", msg.type);
		return;
	}

	/*尝试发起提议的第二阶段,阶段性检查*/
	try_accept(p);

	if (buffer != NULL)
		free(buffer);
}
Пример #6
0
 void dispatch(
     bool&                           old_down,
     bool                            new_down,
     MouseAcceptInfo&                accept_info,
     const zw::win::offset_type&     position,
     MouseButtonType                 button )
 {
     if( !old_down ) {
         if( new_down ) {
             // start
             MouseAcceptInfo a = try_accept( position, button );
             if( a.receiver ) { // accept
                 accept_info = a;
                 a.receiver->on_down(
                     calcurate_local_mouse_position(
                         accept_info, position ) );
             }
             old_down = true;
         } else { /* do nothing */ }
     } else {
         if( accept_info.receiver ) {
             if( new_down ) {
                 // drag
                 accept_info.receiver->on_drag(
                     calcurate_local_mouse_position(
                         accept_info, position ) );
             } else {
                 // end
                 accept_info.receiver->on_up(
                     calcurate_local_mouse_position(
                         accept_info, position ) );
             }
         } else { /* do nothing */ }
         old_down = new_down;
     }
 }
Пример #7
0
static void
proposer_handle_accept(struct proposer *p, struct paxos_accept *ack)
{
    proposer_propose(p, ack->value.paxos_value_val, ack->value.paxos_value_len);
    try_accept(p);
}