2021-10-30 10:06:37 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2018, University Corporation for Atmospheric Research
|
|
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NCS3SDK_H
|
|
|
|
#define NCS3SDK_H 1
|
|
|
|
|
2023-12-03 12:03:59 +08:00
|
|
|
#define AWSHOST ".amazonaws.com"
|
|
|
|
#define GOOGLEHOST "storage.googleapis.com"
|
|
|
|
|
|
|
|
/* Define the "global" default region to be used if no other region is specified */
|
|
|
|
#define AWS_GLOBAL_DEFAULT_REGION "us-east-1"
|
|
|
|
|
2023-10-09 01:22:52 +08:00
|
|
|
/* Track the server type, if known */
|
|
|
|
typedef enum NCS3SVC {NCS3UNK=0, /* unknown */
|
|
|
|
NCS3=1, /* s3.amazon.aws */
|
2024-07-09 19:32:21 +08:00
|
|
|
NCS3GS=2 /* storage.googleapis.com */
|
2023-10-09 01:22:52 +08:00
|
|
|
} NCS3SVC;
|
2023-09-08 05:00:05 +08:00
|
|
|
|
2023-04-26 07:15:06 +08:00
|
|
|
typedef struct NCS3INFO {
|
|
|
|
char* host; /* non-null if other*/
|
|
|
|
char* region; /* region */
|
|
|
|
char* bucket; /* bucket name */
|
|
|
|
char* rootkey;
|
|
|
|
char* profile;
|
2023-10-09 01:22:52 +08:00
|
|
|
NCS3SVC svc;
|
2023-04-26 07:15:06 +08:00
|
|
|
} NCS3INFO;
|
|
|
|
|
2023-12-03 12:03:59 +08:00
|
|
|
struct AWSentry {
|
|
|
|
char* key;
|
|
|
|
char* value;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AWSprofile {
|
|
|
|
char* name;
|
|
|
|
struct NClist* entries; /* NClist<struct AWSentry*> */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Opaque Types */
|
|
|
|
struct NClist;
|
|
|
|
struct NCglobalstate;
|
|
|
|
|
2021-10-30 10:06:37 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2024-05-21 09:15:19 +08:00
|
|
|
/* API for ncs3sdk_XXX.[c|cpp] */
|
2021-11-27 04:59:10 +08:00
|
|
|
EXTERNL int NC_s3sdkinitialize(void);
|
|
|
|
EXTERNL int NC_s3sdkfinalize(void);
|
2021-10-30 10:06:37 +08:00
|
|
|
EXTERNL void* NC_s3sdkcreateclient(NCS3INFO* context);
|
|
|
|
EXTERNL int NC_s3sdkbucketexists(void* s3client, const char* bucket, int* existsp, char** errmsgp);
|
|
|
|
EXTERNL int NC_s3sdkbucketcreate(void* s3client, const char* region, const char* bucket, char** errmsgp);
|
2023-04-26 07:15:06 +08:00
|
|
|
EXTERNL int NC_s3sdkbucketdelete(void* s3client, NCS3INFO* info, char** errmsgp);
|
2021-10-30 10:06:37 +08:00
|
|
|
EXTERNL int NC_s3sdkinfo(void* client0, const char* bucket, const char* pathkey, unsigned long long* lenp, char** errmsgp);
|
|
|
|
EXTERNL int NC_s3sdkread(void* client0, const char* bucket, const char* pathkey, unsigned long long start, unsigned long long count, void* content, char** errmsgp);
|
|
|
|
EXTERNL int NC_s3sdkwriteobject(void* client0, const char* bucket, const char* pathkey, unsigned long long count, const void* content, char** errmsgp);
|
|
|
|
EXTERNL int NC_s3sdkclose(void* s3client0, NCS3INFO* info, int deleteit, char** errmsgp);
|
|
|
|
EXTERNL int NC_s3sdkgetkeys(void* s3client0, const char* bucket, const char* prefix, size_t* nkeysp, char*** keysp, char** errmsgp);
|
|
|
|
EXTERNL int NC_s3sdksearch(void* s3client0, const char* bucket, const char* prefixkey0, size_t* nkeysp, char*** keysp, char** errmsgp);
|
|
|
|
EXTERNL int NC_s3sdkdeletekey(void* client0, const char* bucket, const char* pathkey, char** errmsgp);
|
2023-04-26 07:15:06 +08:00
|
|
|
|
|
|
|
/* From ds3util.c */
|
2024-05-21 09:15:19 +08:00
|
|
|
EXTERNL void NC_s3sdkenvironment(void);
|
2023-12-03 12:03:59 +08:00
|
|
|
|
2023-04-26 07:15:06 +08:00
|
|
|
EXTERNL int NC_getdefaults3region(NCURI* uri, const char** regionp);
|
Mitigate S3 test interference + Unlimited Dimensions in NCZarr
This PR started as an attempt to add unlimited dimensions to NCZarr.
It did that, but this exposed significant problems with test interference.
So this PR is mostly about fixing -- well mitigating anyway -- test
interference.
The problem of test interference is now documented in the document docs/internal.md.
The solutions implemented here are also describe in that document.
The solution is somewhat fragile but multiple cleanup mechanisms
are provided. Note that this feature requires that the
AWS command line utility must be installed.
## Unlimited Dimensions.
The existing NCZarr extensions to Zarr are modified to support unlimited dimensions.
NCzarr extends the Zarr meta-data for the ".zgroup" object to include netcdf-4 model extensions. This information is stored in ".zgroup" as dictionary named "_nczarr_group".
Inside "_nczarr_group", there is a key named "dims" that stores information about netcdf-4 named dimensions. The value of "dims" is a dictionary whose keys are the named dimensions. The value associated with each dimension name has one of two forms
Form 1 is a special case of form 2, and is kept for backward compatibility. Whenever a new file is written, it uses format 1 if possible, otherwise format 2.
* Form 1: An integer representing the size of the dimension, which is used for simple named dimensions.
* Form 2: A dictionary with the following keys and values"
- "size" with an integer value representing the (current) size of the dimension.
- "unlimited" with a value of either "1" or "0" to indicate if this dimension is an unlimited dimension.
For Unlimited dimensions, the size is initially zero, and as variables extend the length of that dimension, the size value for the dimension increases.
That dimension size is shared by all arrays referencing that dimension, so if one array extends an unlimited dimension, it is implicitly extended for all other arrays that reference that dimension.
This is the standard semantics for unlimited dimensions.
Adding unlimited dimensions required a number of other changes to the NCZarr code-base. These included the following.
* Did a partial refactor of the slice handling code in zwalk.c to clean it up.
* Added a number of tests for unlimited dimensions derived from the same test in nc_test4.
* Added several NCZarr specific unlimited tests; more are needed.
* Add test of endianness.
## Misc. Other Changes
* Modify libdispatch/ncs3sdk_aws.cpp to optionally support use of the
AWS Transfer Utility mechanism. This is controlled by the
```#define TRANSFER```` command in that file. It defaults to being disabled.
* Parameterize both the standard Unidata S3 bucket (S3TESTBUCKET) and the netcdf-c test data prefix (S3TESTSUBTREE).
* Fixed an obscure memory leak in ncdump.
* Removed some obsolete unit testing code and test cases.
* Uncovered a bug in the netcdf-c handling of big-endian floats and doubles. Have not fixed yet. See tst_h5_endians.c.
* Renamed some nczarr_tests testcases to avoid name conflicts with nc_test4.
* Modify the semantics of zmap\#ncsmap_write to only allow total rewrite of objects.
* Modify the semantics of zodom to properly handle stride > 1.
* Add a truncate operation to the libnczarr zmap code.
2023-09-27 06:56:48 +08:00
|
|
|
EXTERNL int NC_s3urlprocess(NCURI* url, NCS3INFO* s3, NCURI** newurlp);
|
2023-04-26 07:15:06 +08:00
|
|
|
EXTERNL int NC_s3clear(NCS3INFO* s3);
|
|
|
|
EXTERNL int NC_s3clone(NCS3INFO* s3, NCS3INFO** news3p);
|
2023-12-03 12:03:59 +08:00
|
|
|
EXTERNL const char* NC_s3dumps3info(NCS3INFO* info);
|
|
|
|
EXTERNL void NC_s3freeprofilelist(struct NClist* profiles);
|
|
|
|
EXTERNL int NC_getactives3profile(NCURI* uri, const char** profilep);
|
|
|
|
EXTERNL int NC_s3profilelookup(const char* profile, const char* key, const char** valuep);
|
|
|
|
EXTERNL int NC_authgets3profile(const char* profile, struct AWSprofile** profilep);
|
|
|
|
EXTERNL int NC_iss3(NCURI* uri, enum NCS3SVC*);
|
|
|
|
EXTERNL int NC_s3urlrebuild(NCURI* url, struct NCS3INFO* s3, NCURI** newurlp);
|
|
|
|
EXTERNL int NC_aws_load_credentials(struct NCglobalstate* gstate);
|
2021-10-30 10:06:37 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /*NCS3SDK_H*/
|