分布式系统sheepdog之dog执行流程

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/wendowswd/article/details/78493346
dog部分主要是执行客户端的命令行请求,然后对命令进行解析,通过指定socket发送请求到sheep端,将请求交sheep端处理。具体流程请参考下图。
1、init_commands(&commands)函数将dog支持的命令都初始化在commands中进行调用,包括对vdi、cluster、node的命令操作,
2、setup_commands()函数先比较主命令,然后比较subvommmand,将对应的处理函数赋值给command_fn函数指针,最后调用此函数对命令进行处理


下面给出dog能执行的命令,及操作这些命令的函数

node命令      对应操作函数        功能简介    
kill       node_kill         删除节点
list       node_list          列举节点
info       node_info          显示每个节点的信息
recovery      node_recovery        显示节点的恢复信息
md       node_md            看dog node md得更多信息
log       node_log           显示节点的有关日志信息


vdi命令       对应操作函数        功能简介
check         vdi_check           检查和修复image的一致性
create        vdi_create          创建一个image
snapshot      vdi_snapshot        创建一个快照
clone         vdi_clone           克隆一个image
delete        vdi_delete          删除一个image
rollback      vdi_rollback        回滚到一个快照
list          vdi_list            列举images
tree          vdi_tree            以树的形式显示images
graph         vdi_graph           以图的形式显示images
object        vdi_object          显示image里面对象的信息
track         vdi_track           显示image里面对象的版本踪迹
setattr       vdi_setattr         设置一个vdi的属性
getattr       vdi_getattr         获得一个vdi的属性
resize        vdi_resize          重新设置一个image的大小
read          vdi_read            从一个image里面读数据
write         vdi_write           写数据到一个image里面
backup        vdi_backup          在两个快照之间创建一个增量备份
restore       vdi_restore         从备份里面复原images快照
cache         vdi_cache           运行dog vdi cache得到更多信息


cluster命令   对应操作函数        功能简介
info          cluster_info        显示集群信息
format        cluster_format      创建一个sheepdog存储
shutdown      cluster_shutdown    关闭sheepdog
snapshot      cluster_snapshot    为集群建立快照或复原集群
recover       cluster_recover     看dog cluster recover得更多信息
reweight      cluster_reweight    reweight集群
展开阅读全文

Top Dog

04-25

You are a top-secret, government-employed software engineer assigned to TOP-DOG, the latest military intelligence program. TOP-DOG handles everything from mapping out enemy territory and position to parsing highly encrypted messages from the Commander in Chief.nThe operator of TOP-DOG needs to be able to transfer information from remote computer work-stations onto diskette in case of hardware problems or well-placed enemy fire. All TOP-DOG information is stored in the Oracattle database, but the only way to access the database is through the Dispatcher, an infamous and powerful software layer that only allows access to the database on a "need-to-know" basis. You are in charge of writing a piece of software which will get the desired information from the Oracattle database and store it on a "flat" file which will later be sent out to disk.nnnInput and OutputnnThe first line of each case contains three integers - the number of lines for the three parts.nnThe first part of each case contains the desired tables to be exported. This part will simply contain the names of each table to be exported on separate lines. There will be no blank lines, and each table name will be unique.nnFor each table, you must search the second part which will contain all column names, types, and sizes (if VARCHAR) for each table in the Oracattle database. This is the only information which the Dispatcher allows you access to without begging.nnNote that, for security reasons, not every table in the first part will always be available in the second part. Under each table name is the column name (one unique word), data type, and size (for VARCHAR), each separated by one space. The # sign indicates there are no more columns for the table. There will never be consecutive # signs immediately following each other, and each table will contain at least one column name with the size. The only four data types are VARCHAR, INT, DATE, and LONGINT.nnAn Oracattle SQL statement must be built in order to query the Dispatcher for the desired table data. The Oracattle SQL statement must be precisely built in order to keep the Dispatcher happy (we wouldn't want the Dispatcher to be confused). The statement begins with "SELECT", followed by each column name and generic data type in parenthesis, separated with commas, terminated with "FROM", the table name, and a semicolon. The generic data type is CHAR for VARCHAR and DATE, and NUM for INT and LONGINT. The generic name must be used because the Dispatcher only understands data as CHAR or NUM (it may be powerful, but it's not extremely intelligent). These SELECT statements must be put into the first part of the output.nnIf a table name cannot be found in the second part, a "" is returned for rows with empty fields.nnNote that each line in the third part may contain any number of spaces between words unless it was declared as a NUM. Also, all data is returned by row and table name in the same order it was presented to the Dispatcher. If no data exists in the table, a # sign immediately follows the table name (as in GROUPSPI in the example data).nnYou must now finally integrate all the information you have received from the Dispatcher into the second part of the output. This part will contain all data needed to describe the database tables. This file will later be imported using the Oracattle SqlImporter (OSI), a text to database utility. Lucky for you, all you need to do is get the second part of the output into the OSI format. This can be a little tricky. The first argument to be supplied is the table name, followed by the number of columns in parentheses, followed by the number of records (rows) in parentheses (no spaces on this line).nnNext comes the column name and then the data in quotation marks (a single space should separate the column name and it's data). When the maximum length of the column data is greater than 64, the size must also be supplied in parenthesis immediately following the column name (no space in-between). This is so OSI can allocate more memory for large data.nnNo blank lines are to exist in the second part of the output, and all data must remain on the same line as the column name (no end-of-line characters in-between quotation marks). Once this file has been created, you are all done! There will be a maximum of 100 columns in a single table, but there may exist any number of rows in a single table. The maximum column name and table name length is 25, and the maximum data length is 100. All input will always contain data in an the expected format (as described in these specifications), so there is no need for error checking. Remember, case is iMpOrTaNt - is not the same as .nnProcess to the end of file.nnnSample Inputnn4 25 28nINTELSYSnGROUPSPInSYSINTELnDEPLOYREGnGROUPSPInGRCODE INTnGRSUBNET VARCHAR 20nGRREGION VARCHAR 25nGRACTION VARCHAR 100nGRREF VARCHAR 100n#nINTELSYSnISDATE DATEnISNUM INTnISGEN LONGINTnISSUBGEN VARCHAR 25n#nSYSINTELnSITRANS INTnSISUBLET LONGINTnSINUM INTnSIGEN VARCHAR 10nSIACTION VARCHAR 50nSINOTES VARCHAR 100n#nQUICKFInQFDATE DATEnQFDATA VARCHAR 100n#nINTELSYSn122922T DEC 94n1n2nn111111Z DEC 01n3n4nCONFIRMEDn010101Z DEC 02n5n6nn020202Z DEC 03n7n8nCAN'T SAYn#nGROUPSPIn#nSYSINTELn342n3498938n000nSCOUTAnPURGE DATABASEnUNABLE TO COMPLY WITH A2DD UNDER GENERAL BURK'S COMMANDn#nnnSample OutputnnSELECT (CHAR) ISDATE, (NUM) ISNUM, (NUM) ISGEN, (CHAR) ISSUBGEN FROM INTELSYS;nSELECT (NUM) GRCODE, (CHAR) GRSUBNET, (CHAR) GRREGION, (CHAR) GRACTION, (CHAR) GRREF FROM GROUPSPI;nSELECT (NUM) SITRANS, (NUM) SISUBLET, (NUM) SINUM, (CHAR) SIGEN, (CHAR) SIACTION, (CHAR) SINOTES FROM SYSINTEL;n " statement must be substituted for the SELECT statement in the first part of the output. No blank lines are to be in this file, and only single spaces are to separate SELECT, column names, FROM, and the table name in the SELECT statements. The entire SELECT statement must be on one line.nnSince you currently do not have access to the Dispatcher, we will assume that you have correctly built the first part of the output and that the Dispatcher has processed it and created the table information in the third part. This file contains the table name followed by the data from each row in the Oracattle Database table. ""nISDATE "020202Z DEC 03"nISNUM "7"nISGEN "8"nISSUBGEN "CAN'T SAY"nGROUPSPI(5)(0)nSYSINTEL(6)(1)nSITRANS "342"nSISUBLET "3498938"nSINUM "000"nSIGEN "SCOUTA"nSIACTION "PURGE DATABASE"nSINOTES(100) "UNABLE TO COMPLY WITH A2DD UNDER GENERAL BURK'S COMMAND" nINTELSYS(4)(4)nISDATE "122922T DEC 94"nISNUM "1"nISGEN "2"nISSUBGEN ""nISDATE "111111Z DEC 01"nISNUM "3"nISGEN "4"nISSUBGEN "CONFIRMED"nISDATE "010101Z DEC 02"nISNUM "5"nISGEN "6"nISSUBGEN " 问答

The Dog Task

05-05

Hunter Bob often walks with his dog Ralph. Bob walks with a constant speed and his route is a polygonal line (possibly self-intersecting) whose vertices are specified by N pairs of integers (Xi, Yi) - their Cartesian coordinates.nnRalph walks on his own way but always meets his master at the specified N points. The dog starts his journey simultaneously with Bob at the point (X1, Y1) and finishes it also simultaneously with Bob at the point (XN, YN). nnRalph can travel at a speed that is up to two times greater than his master's speed. While Bob travels in a straight line from one point to another the cheerful dog seeks trees, bushes, hummocks and all other kinds of interesting places of the local landscape which are specified by M pairs of integers (Xj', Yj'). However, after leaving his master at the point (Xi, Yi) (where 1 <= i < N) the dog visits at most one interesting place before meeting his master again at the point (Xi+1, Yi+1). nnYour task is to find the dog's route, which meets the above requirements and allows him to visit the maximal possible number of interesting places. The answer should be presented as a polygonal line that represents Ralph's route. The vertices of this route should be all points (Xi, Yi) and the maximal number of interesting places (Xj', Yj'). The latter should be visited (i.e. listed in the route description) at most once.nnAn example of Bob's route (solid line), a set of interesting places (dots) and one of the best Ralph's routes (dotted line) are presented in the following picture:nnnnnInputnnThe first line of the input contains two integers N and M, separated by a space (2 <= N <= 100, 0 <= M <= 100). The second line contains N pairs of integers X1, Y1, ..., XN, YN, separated by spaces, that represent Bob's route. The third line contains M pairs of integers X1', Y1', ..., XM', YM', separated by spaces, that represent interesting places.nnAll points in the input are different and their coordinates are integers not greater than 1000 by the absolute value.nnnOutputnnThe first line of the output should contain the single integer K - the number of vertices of the best dog's route. The second line should contain K pairs of coordinates X1", Y1", ..., XK", YK", separated by spaces, that represent this route. If there are several such routes, then you may write any of them.nnnThis problem contains multiple test cases!nnThe first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.nnThe output format consists of N output blocks. There is a blank line between output blocks.nnSample Inputnn1nn4 5n1 4 5 7 5 2 -2 4n-4 -2 3 9 1 2 -1 3 8 -3nnnSample Outputnn6n1 4 3 9 5 7 5 2 1 2 -2 4n 问答

The dog task

08-16

DescriptionnnHunter Bob often walks with his dog Ralph. Bob walks with a constant speed and his route is a polygonal line (possibly self-intersecting) whose vertices are specified by N pairs of integers (Xi, Yi) ? their Cartesian coordinates. nRalph walks on his own way but always meets his master at the specified N points. The dog starts his journey simultaneously with Bob at the point (X1, Y1) and finishes it also simultaneously with Bob at the point (XN, YN). nRalph can travel at a speed that is up to two times greater than his master's speed. While Bob travels in a straight line from one point to another the cheerful dog seeks trees, bushes, hummocks and all other kinds of interesting places of the local landscape which are specified by M pairs of integers (Xj',Yj'). However, after leaving his master at the point (Xi, Yi) (where 1 <= i < N) the dog visits at most one interesting place before meeting his master again at the point (Xi+1, Yi+1). nYour task is to find the dog's route, which meets the above requirements and allows him to visit the maximal possible number of interesting places. The answer should be presented as a polygonal line that represents Ralph's route. The vertices of this route should be all points (Xi, Yi) and the maximal number of interesting places (Xj',Yj'). The latter should be visited (i.e. listed in the route description) at most once. nAn example of Bob's route (solid line), a set of interesting places (dots) and one of the best Ralph's routes (dotted line) are presented in the following picture: n![](http://poj.org/images/1034/dog.gif)nInputnnThe first line of the input contains two integers N and M, separated by a space ( 2 <= N <= 100 ,0 <= M <=100 ). The second line contains N pairs of integers X1, Y1, ..., XN, YN, separated by spaces, that represent Bob's route. The third line contains M pairs of integers X1',Y1',...,XM',YM', separated by spaces, that represent interesting places. nAll points in the input file are different and their coordinates are integers not greater than 1000 by the absolute value. nOutputnnThe first line of the output should contain the single integer K ? the number of vertices of the best dog's route. The second line should contain K pairs of coordinates X1'',Y1'' , ...,Xk'',Yk'', separated by spaces, that represent this route. If there are several such routes, then you may write any of them.nSample Inputnn4 5n1 4 5 7 5 2 -2 4n-4 -2 3 9 1 2 -1 3 8 -3nSample Outputnn6n1 4 3 9 5 7 5 2 1 2 -2 4 问答

没有更多推荐了,返回首页