Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace target with restate-data as the default storage directory #1277

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# will have compiled files and executables
/target/

# Restate's data directory
/restate-data

# These are backup files generated by rustfmt
**/*.rs.bk

Expand Down
18 changes: 2 additions & 16 deletions crates/benchmarks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,12 @@ pub fn flamegraph_options<'a>() -> Options<'a> {

pub fn restate_configuration() -> Configuration {
let meta_options = MetaOptionsBuilder::default()
.storage_path(
tempfile::tempdir()
.expect("tempdir failed")
.into_path()
.into_os_string()
.into_string()
.unwrap(),
)
.storage_path(tempfile::tempdir().expect("tempdir failed").into_path())
.build()
.expect("building meta options should work");

let rocksdb_options = RocksdbOptionsBuilder::default()
.path(
tempfile::tempdir()
.expect("tempdir failed")
.into_path()
.into_os_string()
.into_string()
.unwrap(),
)
.path(tempfile::tempdir().expect("tempdir failed").into_path())
.build()
.expect("building rocksdb options should work");

Expand Down
4 changes: 3 additions & 1 deletion crates/bifrost/src/loglets/file_loglet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ use std::sync::Arc;

use async_trait::async_trait;
use restate_types::logs::Payload;
use restate_types::DEFAULT_STORAGE_DIRECTORY;
use serde_json::json;
use std::path::Path;

use crate::loglet::{Loglet, LogletBase, LogletOffset, LogletProvider};
use crate::metadata::LogletParams;
use crate::{Error, LogRecord, Options};

pub fn default_config() -> serde_json::Value {
json!( {"path": "target/logs/"})
json!( {"path": Path::new(DEFAULT_STORAGE_DIRECTORY).join("logs")})
}

#[derive(Debug)]
Expand Down
12 changes: 7 additions & 5 deletions crates/meta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod storage;
use restate_schema_impl::Schemas;
use restate_service_client::AssumeRoleCacheMode;
use restate_types::retries::RetryPolicy;
use std::path::{Path, PathBuf};

pub use error::Error;
pub use restate_service_client::{
Expand All @@ -28,6 +29,7 @@ use std::time::Duration;

use codederror::CodedError;
use restate_schema_api::subscription::SubscriptionValidator;
use restate_types::DEFAULT_STORAGE_DIRECTORY;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

Expand All @@ -49,23 +51,23 @@ pub struct Options {
/// # Storage path
///
/// Root path for Meta storage.
storage_path: String,
storage_path: PathBuf,

service_client: ServiceClientOptions,
}

impl Default for Options {
fn default() -> Self {
Self {
storage_path: "target/meta/".to_string(),
storage_path: Path::new(DEFAULT_STORAGE_DIRECTORY).join("meta"),
service_client: Default::default(),
}
}
}

impl Options {
pub fn storage_path(&self) -> &str {
&self.storage_path
pub fn storage_path(&self) -> &Path {
self.storage_path.as_path()
}

pub fn build<SV: SubscriptionValidator>(
Expand All @@ -76,7 +78,7 @@ impl Options {
let client = self.service_client.build(AssumeRoleCacheMode::None);
Ok(MetaService::new(
schemas.clone(),
FileMetaStorage::new(self.storage_path.into())?,
FileMetaStorage::new(self.storage_path)?,
subscription_validator,
// Total duration roughly 66 seconds
RetryPolicy::exponential(
Expand Down
13 changes: 5 additions & 8 deletions crates/storage-rocksdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use crate::TableKind::{
use bytes::BytesMut;
use codederror::CodedError;
use restate_storage_api::{Storage, StorageError, Transaction};
use restate_types::DEFAULT_STORAGE_DIRECTORY;
use rocksdb::Cache;
use rocksdb::ColumnFamily;
use rocksdb::DBCompressionType;
Expand All @@ -44,7 +45,7 @@ use rocksdb::PrefixRange;
use rocksdb::ReadOptions;
use rocksdb::SingleThreaded;
use rocksdb::{BlockBasedOptions, WriteOptions};
use std::path::Path;
use std::path::{Path, PathBuf};
use std::sync::Arc;

pub use writer::JoinHandle as RocksDBWriterJoinHandle;
Expand Down Expand Up @@ -148,7 +149,7 @@ pub struct Options {
/// # Storage path
///
/// The root path to use for the Rocksdb storage.
pub path: String,
pub path: PathBuf,

/// # Threads
///
Expand Down Expand Up @@ -180,7 +181,7 @@ pub struct Options {
impl Default for Options {
fn default() -> Self {
Self {
path: "target/db/".to_string(),
path: Path::new(DEFAULT_STORAGE_DIRECTORY).join("db"),
threads: 10,
write_buffer_size: 0,
max_total_wal_size: 2 * (1 << 30), // 2 GiB
Expand Down Expand Up @@ -888,11 +889,7 @@ mod tests {
// create a rocksdb storage from options
//
let temp_dir = tempdir().unwrap();
let path = temp_dir
.path()
.to_str()
.expect("can not convert a path to string")
.to_string();
let path = temp_dir.into_path();

let opts = crate::Options {
path,
Expand Down
6 changes: 1 addition & 5 deletions crates/storage-rocksdb/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ fn storage_test_environment() -> (RocksDBStorage, impl Future<Output = ()>) {
// create a rocksdb storage from options
//
let temp_dir = tempdir().unwrap();
let path = temp_dir
.path()
.to_str()
.expect("can not convert a path to string")
.to_string();
let path = temp_dir.into_path();

let opts = restate_storage_rocksdb::Options {
path,
Expand Down
2 changes: 2 additions & 0 deletions crates/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ pub mod timer;
pub use id_util::{IdDecoder, IdEncoder, IdResourceType, IdStrCursor};
pub use node_id::*;
pub use version::*;

pub const DEFAULT_STORAGE_DIRECTORY: &str = "./restate-data";
5 changes: 3 additions & 2 deletions crates/worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use restate_storage_query_postgres::service::PostgresQueryService;
use restate_storage_rocksdb::{RocksDBStorage, RocksDBWriter};
use restate_types::identifiers::{LeaderEpoch, PartitionId, PartitionKey};
use std::ops::RangeInclusive;
use std::path::Path;
use tracing::debug;

mod invoker_integration;
Expand Down Expand Up @@ -143,8 +144,8 @@ pub enum BuildError {
}

impl Options {
pub fn storage_path(&self) -> &str {
&self.storage_rocksdb.path
pub fn storage_path(&self) -> &Path {
self.storage_rocksdb.path.as_path()
}

pub fn build(
Expand Down
2 changes: 1 addition & 1 deletion crates/worker/src/partition/state_machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ mod tests {
let temp_dir = tempdir().unwrap();
info!("Using RocksDB temp directory {}", temp_dir.path().display());
let (rocksdb_storage, writer) = restate_storage_rocksdb::OptionsBuilder::default()
.path(temp_dir.into_path().to_str().unwrap().to_string())
.path(temp_dir.into_path())
.build()
.unwrap()
.build()
Expand Down
Loading