Пример #1
0
void HTMLButcherListEditDialog::OnDuplicate(wxCommandEvent& event)
{
    wxListBox *lb = (wxListBox*) FindWindow(ID_ITEMS);

    if (lb->GetSelection() != wxNOT_FOUND) {
        do_duplicate(static_cast<ButcherListIdClientData*>(lb->GetClientObject(lb->GetSelection()))->GetId());
    }
}
   int request_processor::process (request_zrem * request, bool &send_return)
   {
	 PROC_BEFORE(response_zrem);
	 rc = tair_mgr->zrem (request->area, request->key, request->value,
			 request->version, request->expire);

     do_duplicate(rc, request);

	 return PROC_AFTER;
   }
   int request_processor::process (request_zremrangebyscore * request, bool &send_return)
   {
	 PROC_BEFORE(response_zremrangebyscore);
	 rc = tair_mgr->zremrangebyscore (request->area, request->key, request->start,
			request->end, request->version, request->expire, &(resp->retnum));

     do_duplicate(rc, request);

	 return PROC_AFTER;
   }
   int request_processor::process (request_zincrby * request, bool & send_return)
   {
	 PROC_BEFORE(response_zincrby);
     rc = tair_mgr->zincrby (request->area, request->key, request->value,
 			    request->addscore, &(resp->retnum), request->version, request->expire);

     do_duplicate(rc, request);

	 return PROC_AFTER;
   }
   int request_processor::process (request_hdel * request, bool & send_return)
   {
	 PROC_BEFORE(response_hdel);
     rc = tair_mgr->hdel (request->area, request->key, request->field,
             request->version, request->expire);

     do_duplicate(rc, request);

	 return PROC_AFTER;
   }
   int request_processor::process (request_hmset * request, bool & send_return)
   {
	 PROC_BEFORE(response_hmset);
     rc = tair_mgr->hmset(request->area, request->key, request->field_values,
             &(resp->retvalue), request->version, request->expire);

     do_duplicate(rc, request);

	 return PROC_AFTER;
   }
   int request_processor::process (request_ltrim * request, bool & send_return)
   {
	 PROC_BEFORE(response_ltrim);
	 rc = tair_mgr->ltrim (request->area, request->key,
 			  request->start, request->end, request->version, request->expire);

     do_duplicate(rc, request);

	 return PROC_AFTER;
   }
   int request_processor::process (request_lrpush * request,
 				  bool & send_return)
   {
     int pcode = request->getPCode ();

     if (tair_mgr->is_working () == false) {
       return TAIR_RETURN_SERVER_CAN_NOT_WORK;
     }

     uint64_t target_server_id = 0;
     if (request->hash_code != -1 &&
             tair_mgr->should_proxy(request->hash_code, target_server_id)) {
         return TAIR_RETURN_SHOULD_PROXY;
     }

     response_lrpush *resp = NULL;

     if (pcode == TAIR_REQ_LPUSH_PACKET)
       resp = new response_lrpush (IS_NOT_EXIST, IS_LEFT);
     else if (pcode == TAIR_REQ_RPUSH_PACKET)
       resp = new response_lrpush (IS_NOT_EXIST, IS_RIGHT);
     else if (pcode == TAIR_REQ_LPUSHX_PACKET)
       resp = new response_lrpush (IS_EXIST, IS_LEFT);
     else
       resp = new response_lrpush (IS_EXIST, IS_RIGHT);

     int rc = tair_mgr->lrpush (request->area, request->key, request->values,
 			   &(resp->pushed_num), &(resp->list_len), pcode, 0,
                request->version, request->expire);

     do_duplicate(rc, request);

     resp->setChannelId (request->getChannelId ());
     resp->set_meta (heart_beat->get_client_version (), rc);
     if (request->get_connection ()->postPacket (resp) == false)
     {
       delete resp;
       resp = 0;
     }

     send_return = false;
     return rc;
   }
   int request_processor::process(request_inc_dec *request, bool &send_return)
   {
      int rc = TAIR_RETURN_SUCCESS;
      if (tair_mgr->is_working() == false) {
         return TAIR_RETURN_SERVER_CAN_NOT_WORK;
      }

      uint64_t target_server_id = 0;
      if (request->hash_code != -1 &&
              tair_mgr->should_proxy(request->hash_code, target_server_id)) {
         return TAIR_RETURN_SHOULD_PROXY;
      }

      response_inc_dec *resp = new response_inc_dec();
      if (resp == NULL) {
          send_return = true;
          return TAIR_RETURN_FAILED;
      }

      rc = tair_mgr->add_count(request->area, request->key,
              request->add_count, request->init_value, &resp->value,request->expired);

      do_duplicate(rc, request);

      if (rc != TAIR_RETURN_SUCCESS) {
          delete resp;
          send_return = true;
      } else {
          resp->config_version = heart_beat->get_client_version();
          resp->set_code(rc);
          resp->setChannelId(request->getChannelId());
          if (request->get_connection()->postPacket(resp) == false) {
              delete resp;
          }
          send_return = false;
      }

      return rc;
   }
   int request_processor::process(request_putnx *request, bool &send_return)
   {
      int rc = 0;

      if (tair_mgr->is_working() == false) {
         return TAIR_RETURN_SERVER_CAN_NOT_WORK;
      }

      uint64_t target_server_id = 0;
      if (request->hash_code != -1 &&
              tair_mgr->should_proxy(request->hash_code, target_server_id)) {
         return TAIR_RETURN_SHOULD_PROXY;
      }

      request->key.server_flag = request->server_flag;
      request->key.data_meta.version = request->version;
      send_return = true;
      rc = tair_mgr->putnx(request->area, request->key, request->data, request->expired);

      do_duplicate(rc, request);

      return rc;
   }