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

Failed to read or write on Windows with Pravega 0.10.2+ #373

Open
thekingofcity opened this issue May 8, 2022 · 1 comment
Open

Failed to read or write on Windows with Pravega 0.10.2+ #373

thekingofcity opened this issue May 8, 2022 · 1 comment

Comments

@thekingofcity
Copy link
Collaborator

Problem description
The windows build of the rust client failed to read or write Pravega 0.10.2+. This can be verified by downloading the latest pravegactl from the release page and execute write. Or by calling the rust api in a new project. Sample code are shown in the details.

use std::env; use std::time::Instant;

use pravega_client::client_factory::ClientFactory;
use pravega_client_config::ClientConfigBuilder;
use pravega_client_shared::{Scope, Stream, StreamConfiguration, ScopedStream, Scaling, ScaleType};
use futures::stream::FuturesUnordered;
use futures::stream::StreamExt;

fn main() {
let args: Vec = env::args().collect();
let host = if args.len() > 1 {
args[1].clone()
} else {
"localhost:9090".to_string()
};
let scope = if args.len() > 2 {
args[2].clone()
} else {
"hello".to_string()
};
let stream = if args.len() > 3 {
args[3].clone()
} else {
"world".to_string()
};
let client_config = ClientConfigBuilder::default()
.controller_uri(host)
.build()
.expect("creating config");
let client_factory = ClientFactory::new(client_config);
let runtime = client_factory.runtime();
let scope = Scope::from(scope);
let stream = Stream::from(stream);
let controller_client = client_factory.controller_client();
let scoped_stream = ScopedStream {
scope: scope.clone(),
stream: stream.clone(),
};
let stream_config = StreamConfiguration {
scoped_stream: ScopedStream {
scope: scope.clone(),
stream: stream.clone(),
},
scaling: Scaling {
scale_type: ScaleType::FixedNumSegments,
min_num_segments: 1,
..Default::default()
},
retention: Default::default(),
tags: None,
};

runtime.block_on(async move{
    let res = controller_client.create_scope(&scope).await.expect("create scope");
    println!("create scope {}: {}", scope.to_string(), res);
    let res = controller_client.create_stream(&stream_config).await.expect("create stream");
    println!("create stream {}: {}", stream.to_string(), res);
});

let mut writer = client_factory.create_event_writer(scoped_stream.clone());
println!("event writer created");
runtime.block_on(async move {
    for _ in 0..5 {
        let data100: Vec<u8> = vec![0; 100];
        writer.write_event_by_routing_key("hello".to_string(), data100).await;
        println!("event sent");
    }
    writer.flush().await.expect("flush"); // BLOCK HERE!!!
    println!("writer flushed");
});

// Create a reader group to read data from the Pravega stream.
let cf = &client_factory;
runtime.block_on(async move {
    let rg = cf.create_reader_group("rg".to_string(), scoped_stream.clone()).await; // AND HERE!!!
    println!("reader group created");
    // Create a reader under the reader group.
    let mut reader1 = rg.create_reader("r1".to_string()).await;
    if let Some(mut segment_slice) = reader1.acquire_segment().await.unwrap() {
        while let Some(event) = segment_slice.next() {
            println!("Event read is {:?}", event);
        }
    }
});

}

Platform Pravega version Able to read and write
pravegactl Windows 0.10.1
pravegactl Linux 0.10.1
sample code Windows 0.10.1
sample code Linux 0.10.1
pravegactl Windows 0.10.2
pravegactl Linux 0.10.2
sample code Windows 0.10.2
sample code Linux 0.10.2

Problem location

Suggestions for an improvement

@thekingofcity
Copy link
Collaborator Author

After some cross-checking, this problem only happens when you start Pravega standalone locally aka. 127.0.0.1. For a temporary solution, you may set the environment set "JAVA_OPTS=-Dpravegaservice.service.published.host.nameOrIp=127.0.0.1" so that the client can connect to the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant