@@ -488,45 +488,15 @@ struct CloudManifestDelta {
488
488
std::string epoch; // epoch for the new manifest file
489
489
};
490
490
491
- //
492
- // The Cloud file system
493
- //
494
- // NOTE: The AWS SDK must be initialized before the CloudFileSystem is
495
- // constructed, and remain active (Aws::ShutdownAPI() not called) as long as any
496
- // CloudFileSystem objects exist.
491
+ /* * Extension of the FileSystem API for "the Cloud" */
497
492
class CloudFileSystem : public FileSystem {
498
- protected:
499
- CloudFileSystemOptions cloud_fs_options;
500
- std::shared_ptr<FileSystem> base_fs_; // The underlying file system
501
-
502
- // Creates a new CompositeEnv from "env" and "this".
503
- // The returned Env must not outlive "this"
504
- std::unique_ptr<Env> NewCompositeEnvFromThis (Env* env);
505
-
506
- CloudFileSystem (const CloudFileSystemOptions& options,
507
- const std::shared_ptr<FileSystem>& base,
508
- const std::shared_ptr<Logger>& logger);
509
-
510
493
public:
511
- mutable std::shared_ptr<Logger> info_log_; // informational messages
512
-
513
- virtual ~CloudFileSystem ();
514
-
515
- static void RegisterCloudObjects (const std::string& mode = " " );
516
- static Status CreateFromString (const ConfigOptions& config_options,
517
- const std::string& id,
518
- std::unique_ptr<CloudFileSystem>* fs);
519
- static Status CreateFromString (const ConfigOptions& config_options,
520
- const std::string& id,
521
- const CloudFileSystemOptions& cloud_options,
522
- std::unique_ptr<CloudFileSystem>* fs);
523
494
static const char * kCloud () { return " cloud" ; }
524
495
static const char * kAws () { return " aws" ; }
525
- virtual const char * Name () const { return " cloud-env " ; }
496
+
526
497
// Returns the underlying file system
527
- const std::shared_ptr<FileSystem>& GetBaseFileSystem () const {
528
- return base_fs_;
529
- }
498
+ virtual const std::shared_ptr<FileSystem>& GetBaseFileSystem () const = 0;
499
+
530
500
virtual IOStatus PreloadCloudManifest (const std::string& local_dbname) = 0;
531
501
// This method will migrate the database that is using pure RocksDB into
532
502
// RocksDB-Cloud. Call this before opening the database with RocksDB-Cloud.
@@ -550,52 +520,6 @@ class CloudFileSystem : public FileSystem {
550
520
virtual IOStatus DeleteDbid (const std::string& bucket_prefix,
551
521
const std::string& dbid) = 0;
552
522
553
- Logger* GetLogger () const { return info_log_.get (); }
554
- const std::shared_ptr<CloudStorageProvider>& GetStorageProvider () const {
555
- return cloud_fs_options.storage_provider ;
556
- }
557
-
558
- const std::shared_ptr<CloudLogController>& GetLogController () const {
559
- return cloud_fs_options.cloud_log_controller ;
560
- }
561
-
562
- // The SrcBucketName identifies the cloud storage bucket and
563
- // GetSrcObjectPath specifies the path inside that bucket
564
- // where data files reside. The specified bucket is used in
565
- // a readonly mode by the associated DBCloud instance.
566
- const std::string& GetSrcBucketName () const {
567
- return cloud_fs_options.src_bucket .GetBucketName ();
568
- }
569
- const std::string& GetSrcObjectPath () const {
570
- return cloud_fs_options.src_bucket .GetObjectPath ();
571
- }
572
- bool HasSrcBucket () const { return cloud_fs_options.src_bucket .IsValid (); }
573
-
574
- // The DestBucketName identifies the cloud storage bucket and
575
- // GetDestObjectPath specifies the path inside that bucket
576
- // where data files reside. The associated DBCloud instance
577
- // writes newly created files to this bucket.
578
- const std::string& GetDestBucketName () const {
579
- return cloud_fs_options.dest_bucket .GetBucketName ();
580
- }
581
- const std::string& GetDestObjectPath () const {
582
- return cloud_fs_options.dest_bucket .GetObjectPath ();
583
- }
584
-
585
- bool HasDestBucket () const { return cloud_fs_options.dest_bucket .IsValid (); }
586
- bool SrcMatchesDest () const {
587
- if (HasSrcBucket () && HasDestBucket ()) {
588
- return cloud_fs_options.src_bucket == cloud_fs_options.dest_bucket ;
589
- } else {
590
- return false ;
591
- }
592
- }
593
-
594
- // returns the options used to create this object
595
- const CloudFileSystemOptions& GetCloudFileSystemOptions () const {
596
- return cloud_fs_options;
597
- }
598
-
599
523
// Deletes file from a destination bucket.
600
524
virtual IOStatus DeleteCloudFileFromDest (const std::string& fname) = 0;
601
525
// Copies a local file to a destination bucket.
@@ -663,6 +587,117 @@ class CloudFileSystem : public FileSystem {
663
587
const std::string& dbname,
664
588
const std::vector<std::string>& active_cookies) = 0;
665
589
590
+ // returns the options used to create this object
591
+ virtual const CloudFileSystemOptions& GetCloudFileSystemOptions () const = 0;
592
+
593
+ // The SrcBucketName identifies the cloud storage bucket and
594
+ // GetSrcObjectPath specifies the path inside that bucket
595
+ // where data files reside. The specified bucket is used in
596
+ // a readonly mode by the associated DBCloud instance.
597
+ virtual const std::string& GetSrcBucketName () const = 0;
598
+ virtual const std::string& GetSrcObjectPath () const = 0;
599
+ virtual bool HasSrcBucket () const = 0;
600
+
601
+ // The DestBucketName identifies the cloud storage bucket and
602
+ // GetDestObjectPath specifies the path inside that bucket
603
+ // where data files reside. The associated DBCloud instance
604
+ // writes newly created files to this bucket.
605
+ virtual const std::string& GetDestBucketName () const = 0;
606
+ virtual const std::string& GetDestObjectPath () const = 0;
607
+ virtual bool HasDestBucket () const = 0;
608
+
609
+ virtual bool SrcMatchesDest () const = 0;
610
+
611
+ // Get the storage provider for the FileSystem.
612
+ virtual const std::shared_ptr<CloudStorageProvider>& GetStorageProvider ()
613
+ const = 0;
614
+
615
+ virtual Logger* GetLogger () const = 0;
616
+ };
617
+
618
+ //
619
+ // The Cloud file system
620
+ //
621
+ // NOTE: The AWS SDK must be initialized before the CloudFileSystem is
622
+ // constructed, and remain active (Aws::ShutdownAPI() not called) as long as any
623
+ // CloudFileSystem objects exist.
624
+ class CloudFileSystemEnv : public CloudFileSystem {
625
+ protected:
626
+ CloudFileSystemOptions cloud_fs_options;
627
+ std::shared_ptr<FileSystem> base_fs_; // The underlying file system
628
+
629
+ // Creates a new CompositeEnv from "env" and "this".
630
+ // The returned Env must not outlive "this"
631
+ std::unique_ptr<Env> NewCompositeEnvFromThis (Env* env);
632
+
633
+ CloudFileSystemEnv (const CloudFileSystemOptions& options,
634
+ const std::shared_ptr<FileSystem>& base,
635
+ const std::shared_ptr<Logger>& logger);
636
+
637
+ public:
638
+ mutable std::shared_ptr<Logger> info_log_; // informational messages
639
+
640
+ virtual ~CloudFileSystemEnv ();
641
+
642
+ static void RegisterCloudObjects (const std::string& mode = " " );
643
+ static Status CreateFromString (const ConfigOptions& config_options,
644
+ const std::string& id,
645
+ std::unique_ptr<CloudFileSystem>* fs);
646
+ static Status CreateFromString (const ConfigOptions& config_options,
647
+ const std::string& id,
648
+ const CloudFileSystemOptions& cloud_options,
649
+ std::unique_ptr<CloudFileSystem>* fs);
650
+
651
+ const char * Name () const override { return " cloud-env" ; }
652
+
653
+ const std::shared_ptr<FileSystem>& GetBaseFileSystem () const override {
654
+ return base_fs_;
655
+ }
656
+
657
+ Logger* GetLogger () const override { return info_log_.get (); }
658
+
659
+ const std::shared_ptr<CloudStorageProvider>& GetStorageProvider ()
660
+ const override {
661
+ return cloud_fs_options.storage_provider ;
662
+ }
663
+
664
+ const std::shared_ptr<CloudLogController>& GetLogController () const {
665
+ return cloud_fs_options.cloud_log_controller ;
666
+ }
667
+
668
+ const std::string& GetSrcBucketName () const override {
669
+ return cloud_fs_options.src_bucket .GetBucketName ();
670
+ }
671
+ const std::string& GetSrcObjectPath () const override {
672
+ return cloud_fs_options.src_bucket .GetObjectPath ();
673
+ }
674
+ bool HasSrcBucket () const override {
675
+ return cloud_fs_options.src_bucket .IsValid ();
676
+ }
677
+
678
+ const std::string& GetDestBucketName () const override {
679
+ return cloud_fs_options.dest_bucket .GetBucketName ();
680
+ }
681
+ const std::string& GetDestObjectPath () const override {
682
+ return cloud_fs_options.dest_bucket .GetObjectPath ();
683
+ }
684
+
685
+ bool HasDestBucket () const override {
686
+ return cloud_fs_options.dest_bucket .IsValid ();
687
+ }
688
+ bool SrcMatchesDest () const override {
689
+ if (HasSrcBucket () && HasDestBucket ()) {
690
+ return cloud_fs_options.src_bucket == cloud_fs_options.dest_bucket ;
691
+ } else {
692
+ return false ;
693
+ }
694
+ }
695
+
696
+ // returns the options used to create this object
697
+ const CloudFileSystemOptions& GetCloudFileSystemOptions () const override {
698
+ return cloud_fs_options;
699
+ }
700
+
666
701
// Create a new AWS file system.
667
702
// src_bucket_name: bucket name suffix where db data is read from
668
703
// src_object_prefix: all db objects in source bucket are prepended with this
0 commit comments