Skip to main content

MasterClient

Struct MasterClient 

Source
pub struct MasterClient { /* private fields */ }
Expand description

Client for Goosefs FileSystemMasterClientService (Master:9200).

In HA mode, the client holds a reference to the MasterInquireClient and can automatically re-discover the Primary Master when RPCs fail.

§Authentication

The client supports NOSASL and SIMPLE authentication modes. When config.auth_type is Simple, the client performs a SASL PLAIN handshake after establishing the gRPC channel, then injects a channel-id metadata header into all subsequent RPCs.

Implementations§

Source§

impl MasterClient

Source

pub async fn connect(config: &GoosefsConfig) -> Result<Self>

Connect to the Goosefs Master.

In single-master mode, connects directly to config.master_addr. In HA mode (multiple addresses in config.master_addrs), uses PollingMasterInquireClient to discover the Primary first.

Authentication is performed according to config.auth_type.

Source

pub async fn connect_with_inquire( config: &GoosefsConfig, inquire_client: Arc<dyn MasterInquireClient>, ) -> Result<Self>

Connect using an externally-provided MasterInquireClient.

This is useful when sharing a single inquire client across multiple client types (e.g. MasterClient + WorkerManagerClient).

Source

pub fn from_channel(channel: Channel, config: GoosefsConfig) -> Self

Create from an existing tonic channel (useful for testing / channel sharing).

Note: This bypasses authentication. The channel is wrapped with a no-op channel-id interceptor for API compatibility.

Source

pub async fn get_status(&self, path: &str) -> Result<FileInfo>

Get the file/directory status (equivalent to stat / head).

Source

pub async fn list_status( &self, path: &str, recursive: bool, ) -> Result<Vec<FileInfo>>

List the contents of a directory. Returns all FileInfo entries.

This wraps a server-side streaming RPC — the server sends multiple ListStatusPResponse messages, each containing a batch of FileInfo.

Source

pub async fn create_file( &self, path: &str, options: CreateFilePOptions, ) -> Result<FileInfo>

Create a new file. Returns the FileInfo of the created file.

Source

pub async fn complete_file( &self, path: &str, ufs_length: Option<i64>, operation_id: Option<FsOpPId>, ) -> Result<()>

Mark a file as completed (called after all blocks are written).

§Idempotent operation ID

operation_id is used by the Master for exactly-once semantics: if the RPC is retried after a network hiccup the Master detects the duplicate via FsOpPId and returns success without applying the operation twice.

The caller (GoosefsFileWriter) generates a fresh uuid::Uuid at construction time and reuses it across all complete_file calls for the same write session. The UUID is split into two i64 halves via Uuid::as_u64_pair():

(high, low) = uuid.as_u64_pair()
FsOpPId { most_significant_bits: high as i64,
          least_significant_bits: low  as i64 }

This matches Java UUID.getMostSignificantBits() / getLeastSignificantBits() as verified in DefaultFileSystemMaster.completeFile().

§Note on Go SDK bug

The Go SDK base_filesystem.go:394-400 accepts an operationID parameter but never writes it to the proto request. The Rust implementation fixes this: operation_id is always wired into CompleteFilePOptions.

Source

pub async fn remove_blocks(&self, block_ids: Vec<i64>) -> Result<()>

Request the Master to free block metadata for the given block IDs.

This is the preferred cleanup path for GoosefsFileWriter::cancel(): it removes only the block metadata on the Master without touching the file-system namespace entry (the INCOMPLETE inode).

Falls back to delete_with_options(unchecked=true) when this RPC fails.

§Java authority

Matches FileSystemMasterClientServiceHandler.removeBlocks()DefaultFileSystemMaster.removeBlocks(blockIds).

Source

pub async fn delete_with_options( &self, path: &str, opts: DeleteOptions, ) -> Result<()>

Delete a file or directory with fine-grained options.

Prefer this over the legacy delete wrapper when you need unchecked or goosefs_only semantics.

See DeleteOptions for field semantics and Java authority notes.

Source

pub async fn delete(&self, path: &str, recursive: bool) -> Result<()>

Delete a file or directory (simple recursive wrapper).

For unchecked or goosefs_only deletion use delete_with_options directly.

Source

pub async fn rename(&self, src: &str, dst: &str) -> Result<()>

Rename (move) a file or directory.

Source

pub async fn create_directory(&self, path: &str, recursive: bool) -> Result<()>

Create a directory (recursive by default).

Sets a default mode of 0755 (rwxr-xr-x) so that the corresponding UFS directory created by Goosefs has usable permissions.

Source

pub async fn schedule_async_persistence( &self, path: &str, persistence_wait_time: Option<i64>, ) -> Result<()>

Schedule asynchronous persistence for a file. This will persist the file to the underlying storage system.

Source

pub fn config(&self) -> &GoosefsConfig

Get a reference to the underlying config.

Source

pub fn inquire_client(&self) -> &Arc<dyn MasterInquireClient>

Get a reference to the underlying inquire client.

Useful for sharing the same inquire client with WorkerManagerClient.

Trait Implementations§

Source§

impl Clone for MasterClient

Source§

fn clone(&self) -> MasterClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more