1 / 23

SRB API Tuitorial

SRB API Tuitorial. Michael Wan San Diego Supercomputer Center mwan@sdsc.edu SRB URL:http://www.npaci.edu/Research/DI/srb/. SRB client API. Over 80 client API with release 1.1.8 Documented in Appendix A of user manual Function prototype in include/clStubExtern.h. SRB Client API.

lindsay
Download Presentation

SRB API Tuitorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SRB API Tuitorial Michael Wan San Diego Supercomputer Center mwan@sdsc.edu SRB URL:http://www.npaci.edu/Research/DI/srb/

  2. SRB client API Over 80 client API with release 1.1.8 Documented in Appendix A of user manual Function prototype in include/clStubExtern.h

  3. SRB Client API Data operations - srbObjCreate, srbObjOpen, srbObjRead, srbObjWrite, srbObjSeek, srbObjProxyOpr, srbObjReplicate, srbCreatCollect, srbIssueTicket, srbObjOpenWithTicket, API that interact MCAT Metadata query - srbGetDatasetInfo, srbGetdataDirInfo, srbListCollect, .... Metadata manipulation - srbModifyDataset, srbRegisterDataset, …. Admin API - srbRegisterUser, srbModifyUser, srbRegisterUserGrp, srbChkMdasAuth, ….

  4. SRB API – getting started Makefile CL_CFLAGS+=-D$(PORTNAME) CL_CFLAGS+= -I$(srbDir)/src/include CL_CFLAGS+= -I$(srbDir)/src/catalog/include CL_LDADD+=-L$(libDir) -lSrbClient Include file #include "srbClient.h"

  5. Sconnect.c – connect to a srb serversrbConn* srbConnect(char *srbHost, char* srbPort, char* srbAuth, char userName, char *domainName, char *authScheme, char *serverDn) conn = srbConnect (HOST, PORT, SRB_AUTH, USER, DOMAIN, AUTH_SCHEME, SERVER_DN);.clFinish(conn);

  6. Sput.c – import a local file into SRBint srbObjCreate(srbConn* conn, int catType, char *objID, char *dataTypeName, char *resourceName, char collectionName, char *pathName, srb_long_t dataSize) int srbObjWrite(srbConn *conn, int desc, char *buf, int len) int srbObjClose (srbConn* conn, int desc)

  7. Sput.c – code/* Create a srb file = argv[2] */ out_fd = srbObjCreate (conn, MDAS_CATALOG, argv[2], DATATYPE, RESOURCE , COLLECTION, NULL, -1); in_fd = open (argv[1], O_RDONLY, 0);

  8. Sput.c – (cont)while ((bytesRead = read(in_fd, buf, BUFSIZE)) > 0) { /* Write to the data object */ bytesWritten = srbObjWrite(conn, out_fd, buf, bytesRead); if (bytesWritten < bytesRead) { fprintf(stderr, "Error: Read %d bytes, Wrote %d bytes.\n ", bytesRead, bytesWritten); clFinish (conn); free (buf); exit (1); } total += bytesWritten; } srbObjClose (conn, out_fd);

  9. Sget.c – export a file from SRB to local FSint srbObjOpen(srbConn* conn, char *objID, int oflag, char *collectionName) Int srbObjRead(srbConn *conn, int desc, char *buf, int len)

  10. Sput.c – codein_fd = srbObjOpen (conn, argv[1], O_RDONLY, COLLECTION);out_fd = open (argv[2], O_CREAT|O_WRONLY, 0640);

  11. Sget.c – continuewhile ((bytesRead = srbObjRead (conn, in_fd, buf, BUFSIZE)) > 0) { /* Write to the data object */ bytesWritten = write (out_fd, buf, bytesRead); if (bytesWritten < bytesRead) { . . exit (1); } total += bytesWritten; } srbObjClose (conn, in_fd);

  12. Sreplicate.c – replicate a srb fileintsrbObjReplicate (srbConn* conn, int catType, char objID, char *collectionName,char *newResourceName, char *newPathName)

  13. Sreplicate.c – coderetVal = srbObjReplicate (conn, MDAS_CATALOG, argv[1], COLLECTION, RESOURCE, NULL);Sls –lsrb 0 unix-sdsc 990 2002-10-21-14.33 foo100 srb 1 unix-sdsc 990 2002-10-21-14.33 foo100

  14. sgetcopy.c - Export a replica from srb to local fsint srbObjOpen(srbConn* conn, char *objID, int oflag, char *collectionName) * Additionsl conditions can be appended to the objID. * The char '&‘ – start of condition input. * foo&COPY=1 specifies opening replica number 1 of data object "foo".

  15. sgetcopy.c – codeUsage: sput srb-file repl_num local-filesprintf (objName, "%s&COPY=%-d", argv[1], repl_num);in_fd = srbObjOpen (conn, objName, O_RDONLY, COLLECTION);

  16. Stat.c - get the stat a srb fileUsage: sstat [-r] srb-file int srbObjStat(srbConn* conn, int catType, char *path, struct stat *statbuf)int srbObjUnlink (srbConn* conn, char *objID, char *collectionName)

  17. Stat.c – codesprintf (myPath, "%s/%s", COLLECTION, argv[optind]);retVal = srbObjStat (conn, MDAS_CATALOG, myPath, &statbuf);retVal = srbObjUnlink (conn, argv[optind], COLLECTION);

  18. squery.c - replicate a srb fileint srbGetDataDirInfo (srbConn* conn, int catType, char qval[][MAX_TOKEN], int *selval, mdasC_sql_result_struct *myresult, int rowsWanted)* qval[][] and selval[] array to compose SQL queries* Myresult – out query result

  19. squery.c – code* selval[] array specifies a list of attrbutes to select* qval[][] specifies the lists of predicates for the query* Index of the array define in catalog/include/mdasC_db2_externs.h

  20. Squery.c – (cont1)/* Initialize the selval and qval array. */ for (i = 0; i < MAX_DCS_NUM; i++) { selval[i] = 0; sprintf(qval[i],""); }/* set up the query: Given the Collection, select the * filename, size, resource name, file owner and * the creation timestamp */

  21. Squery.c – (cont2)sprintf(qval[DATA_GRP_NAME]," = '%s'",argv[1]); selval[DATA_NAME] = 1; selval[SIZE] = 1; selval[PHY_RSRC_NAME] = 1; selval[DATA_OWNER] = 1; selval[REPL_TIMESTAMP] = 1; /* Send the query request */ if ((retVal = srbGetDataDirInfo(conn, MDAS_CATALOG, qval, selval, &myresult, ROWS_WANTED)) < 0) {

  22. Squery.c – (cont3) while (myresult.continuation_index >= 0) { if ((retVal = srbGetMoreRows (conn, MDAS_CATALOG, myresult.continuation_index, &myresult, ROWS_WANTED)) < 0) break; /* Dump the result */ printSqlResult (&myresult); clearSqlResult (&myresult); }

  23. Squery.c – (cont4)tab_name=sekar.MDAS_AD_REPL, att_name=data_name values=foo1 values=foo100tab_name=sekar.MDAS_ADC_REPL, att_name=modify_timestamp values=2000-06-28-10.48.15 values=2000-06-28-08.08.30tab_name=sekar.MDAS_AD_REPL, att_name=data_size values=6586 values=131089tab_name=sekar.MDAS_AR_PHYSICAL, att_name=phy_rsrc_name values=unix-sdsc values=unix-sdsctab_name=sekar.MDAS_CD_OWNER_USER, att_name=user_name values=cisuser values=cisuser

More Related