int main() { int i; user_dir_t * u; bucket_t * b; object_t * o; init_name_space(); put_user(U1); put_user(U2); put_user(U3); put_user(U4); put_user(U5); put_user(U6); put_user(U7); put_user(U8); put_user(U9); put_user(U10); put_user(U11); put_user(U12); prt_ulist(); prt_uhash(); printf("----------------------\n"); put_bucket(B1,U5); put_bucket(B2,U5); put_bucket(B3,U5); put_bucket(B4,U5); put_bucket(B5,U5); prt_bhash(); printf("----------------------\n"); if(put_object(O1,B3,U5) == 0){ printf("put o1 ok\n"); } if(put_object(O2,B3,U5) == 0){ printf("put o2 ok\n"); } if(put_object(O3,B3,U5) == 0){ printf("put o3 ok\n"); } if(put_object(O4,B3,U5) == 0){ printf("put o4 ok\n"); } if(put_object(O5,B3,U5) == 0){ printf("put o5 ok\n"); } if(put_object(O6,B3,U5) == 0){ printf("put o6 ok\n"); } if(put_object(O7,B3,U5) == 0){ printf("put o7 ok\n"); } prt_ohash(); get_bucket(B3,U5,LIST_OBJECT_FILE); get_user(U5,LIST_BUCKET_FILE,GU_LIST_BUCKETS); get_user(U5,ALL_BUCKETS_OBJECTS_FILE,GU_LIST_ALL_BUCKETS_OBJECTS); return 0; }
int KvMetaService::handle(common::BasePacket* packet) { assert(NULL != packet); int ret = TFS_SUCCESS; int32_t pcode = packet->getPCode(); if (!is_inited_) { ret = EXIT_NOT_INIT_ERROR; } else { switch (pcode) { case REQ_KVMETA_GET_SERVICE_MESSAGE: ret = get_service(dynamic_cast<ReqKvMetaGetServiceMessage*>(packet)); break; case REQ_KVMETA_PUT_OBJECT_MESSAGE: ret = put_object(dynamic_cast<ReqKvMetaPutObjectMessage*>(packet)); break; case REQ_KVMETA_GET_OBJECT_MESSAGE: ret = get_object(dynamic_cast<ReqKvMetaGetObjectMessage*>(packet)); break; case REQ_KVMETA_DEL_OBJECT_MESSAGE: ret = del_object(dynamic_cast<ReqKvMetaDelObjectMessage*>(packet)); break; case REQ_KVMETA_HEAD_OBJECT_MESSAGE: ret = head_object(dynamic_cast<ReqKvMetaHeadObjectMessage*>(packet)); break; case REQ_KVMETA_PUT_OBJECT_USER_METADATA_MESSAGE: ret = put_object_user_metadata(dynamic_cast<ReqKvMetaPutObjectUserMetadataMessage*>(packet)); break; case REQ_KVMETA_DEL_OBJECT_USER_METADATA_MESSAGE: ret = del_object_user_metadata(dynamic_cast<ReqKvMetaDelObjectUserMetadataMessage*>(packet)); break; case REQ_KVMETA_PUT_BUCKET_MESSAGE: ret = put_bucket(dynamic_cast<ReqKvMetaPutBucketMessage*>(packet)); break; case REQ_KVMETA_GET_BUCKET_MESSAGE: ret = get_bucket(dynamic_cast<ReqKvMetaGetBucketMessage*>(packet)); break; case REQ_KVMETA_DEL_BUCKET_MESSAGE: ret = del_bucket(dynamic_cast<ReqKvMetaDelBucketMessage*>(packet)); break; case REQ_KVMETA_HEAD_BUCKET_MESSAGE: ret = head_bucket(dynamic_cast<ReqKvMetaHeadBucketMessage*>(packet)); break; case REQ_KVMETA_SET_LIFE_CYCLE_MESSAGE: ret = set_file_lifecycle(dynamic_cast<ReqKvMetaSetLifeCycleMessage*>(packet)); break; case REQ_KVMETA_GET_LIFE_CYCLE_MESSAGE: ret = get_file_lifecycle(dynamic_cast<ReqKvMetaGetLifeCycleMessage*>(packet)); break; case REQ_KVMETA_RM_LIFE_CYCLE_MESSAGE: ret = rm_file_lifecycle(dynamic_cast<ReqKvMetaRmLifeCycleMessage*>(packet)); break; case REQ_KVMETA_PUT_BUCKET_ACL_MESSAGE: ret = put_bucket_acl(dynamic_cast<ReqKvMetaPutBucketAclMessage*>(packet)); break; case REQ_KVMETA_GET_BUCKET_ACL_MESSAGE: ret = get_bucket_acl(dynamic_cast<ReqKvMetaGetBucketAclMessage*>(packet)); break; default: ret = EXIT_UNKNOWN_MSGTYPE; TBSYS_LOG(ERROR, "unknown msg type: %d", pcode); break; } } if (ret != TFS_SUCCESS) { packet->reply_error_packet(TBSYS_LOG_LEVEL(INFO), ret, "execute message failed"); } return EASY_OK; }
bool KvMetaService::handlePacketQueue(tbnet::Packet *packet, void *args) { int ret = true; BasePacket* base_packet = NULL; if (!(ret = BaseService::handlePacketQueue(packet, args))) { TBSYS_LOG(ERROR, "call BaseService::handlePacketQueue fail. ret: %d", ret); } else { base_packet = dynamic_cast<BasePacket*>(packet); switch (base_packet->getPCode()) { case REQ_KVMETA_GET_SERVICE_MESSAGE: ret = get_service(dynamic_cast<ReqKvMetaGetServiceMessage*>(base_packet)); break; case REQ_KVMETA_PUT_OBJECT_MESSAGE: ret = put_object(dynamic_cast<ReqKvMetaPutObjectMessage*>(base_packet)); break; case REQ_KVMETA_GET_OBJECT_MESSAGE: ret = get_object(dynamic_cast<ReqKvMetaGetObjectMessage*>(base_packet)); break; case REQ_KVMETA_DEL_OBJECT_MESSAGE: ret = del_object(dynamic_cast<ReqKvMetaDelObjectMessage*>(base_packet)); break; case REQ_KVMETA_HEAD_OBJECT_MESSAGE: ret = head_object(dynamic_cast<ReqKvMetaHeadObjectMessage*>(base_packet)); break; case REQ_KVMETA_PUT_OBJECT_USER_METADATA_MESSAGE: ret = put_object_user_metadata(dynamic_cast<ReqKvMetaPutObjectUserMetadataMessage*>(base_packet)); break; case REQ_KVMETA_DEL_OBJECT_USER_METADATA_MESSAGE: ret = del_object_user_metadata(dynamic_cast<ReqKvMetaDelObjectUserMetadataMessage*>(base_packet)); break; case REQ_KVMETA_PUT_BUCKET_MESSAGE: ret = put_bucket(dynamic_cast<ReqKvMetaPutBucketMessage*>(base_packet)); break; case REQ_KVMETA_GET_BUCKET_MESSAGE: ret = get_bucket(dynamic_cast<ReqKvMetaGetBucketMessage*>(base_packet)); break; case REQ_KVMETA_DEL_BUCKET_MESSAGE: ret = del_bucket(dynamic_cast<ReqKvMetaDelBucketMessage*>(base_packet)); break; case REQ_KVMETA_HEAD_BUCKET_MESSAGE: ret = head_bucket(dynamic_cast<ReqKvMetaHeadBucketMessage*>(base_packet)); break; case REQ_KVMETA_SET_LIFE_CYCLE_MESSAGE: ret = set_file_lifecycle(dynamic_cast<ReqKvMetaSetLifeCycleMessage*>(base_packet)); break; case REQ_KVMETA_GET_LIFE_CYCLE_MESSAGE: ret = get_file_lifecycle(dynamic_cast<ReqKvMetaGetLifeCycleMessage*>(base_packet)); break; case REQ_KVMETA_RM_LIFE_CYCLE_MESSAGE: ret = rm_file_lifecycle(dynamic_cast<ReqKvMetaRmLifeCycleMessage*>(base_packet)); break; case REQ_KVMETA_PUT_BUCKET_ACL_MESSAGE: ret = put_bucket_acl(dynamic_cast<ReqKvMetaPutBucketAclMessage*>(base_packet)); break; case REQ_KVMETA_GET_BUCKET_ACL_MESSAGE: ret = get_bucket_acl(dynamic_cast<ReqKvMetaGetBucketAclMessage*>(base_packet)); break; default: ret = EXIT_UNKNOWN_MSGTYPE; TBSYS_LOG(ERROR, "unknown msg type: %d", base_packet->getPCode()); break; } } if (ret != TFS_SUCCESS && NULL != base_packet) { base_packet->reply_error_packet(TBSYS_LOG_LEVEL(INFO), ret, "execute message failed"); } // always return true. packet will be freed by caller return true; }