This commit is contained in:
Dominik Werder
2021-05-06 17:53:45 +02:00
parent f391eca970
commit af9c11bdd8
16 changed files with 246 additions and 270 deletions

View File

@@ -36,7 +36,8 @@ async fn go() -> Result<(), Error> {
ClientType::Binned(opts) => {
let beg = opts.beg.parse()?;
let end = opts.end.parse()?;
retrieval::client::get_binned(opts.host, opts.port, opts.channel, beg, end, opts.bins).await?;
retrieval::client::get_binned(opts.host, opts.port, opts.backend, opts.channel, beg, end, opts.bins)
.await?;
}
},
SubCmd::GenerateTestData => {

View File

@@ -40,6 +40,8 @@ pub struct BinnedClient {
#[clap(long)]
pub port: u16,
#[clap(long)]
pub backend: String,
#[clap(long)]
pub channel: String,
#[clap(long)]
pub beg: String,

View File

@@ -9,13 +9,14 @@ use netpod::log::*;
pub async fn get_binned(
host: String,
port: u16,
channel_backend: String,
channel_name: String,
beg_date: DateTime<Utc>,
end_date: DateTime<Utc>,
bin_count: u32,
) -> Result<(), Error> {
info!("------- get_binned client");
let t1 = Utc::now();
let channel_backend = "NOBACKEND";
let date_fmt = "%Y-%m-%dT%H:%M:%S.%3fZ";
let uri = format!(
"http://{}:{}/api/1/binned?channel_backend={}&channel_name={}&beg_date={}&end_date={}&bin_count={}",
@@ -27,27 +28,24 @@ pub async fn get_binned(
end_date.format(date_fmt),
bin_count,
);
info!("URI {:?}", uri);
info!("get_binned uri {:?}", uri);
let req = hyper::Request::builder()
.method(http::Method::GET)
.uri(uri)
.body(Body::empty())?;
info!("Request for {:?}", req);
let client = hyper::Client::new();
let res = client.request(req).await?;
info!("client response {:?}", res);
if res.status() != StatusCode::OK {
error!("Server error");
return Err(Error::with_msg(format!("Server error")));
error!("Server error {:?}", res);
return Err(Error::with_msg(format!("Server error {:?}", res)));
}
//let (res_head, mut res_body) = res.into_parts();
let s1 = disk::cache::HttpBodyAsAsyncRead::new(res);
let s2 = InMemoryFrameAsyncReadStream::new(s1);
use futures_util::StreamExt;
use std::future::ready;
let mut bin_count = 0;
let s3 = s2
.map_err(|e| error!("{:?}", e))
.map_err(|e| error!("get_binned {:?}", e))
.filter_map(|item| {
let g = match item {
Ok(frame) => {

View File

@@ -55,6 +55,9 @@ async fn get_binned_0_inner() -> Result<(), Error> {
&cluster,
)
.await?;
if true {
return Ok(());
}
get_binned_channel(
"wave-u16-le-n77",
"1970-01-01T01:11:00.000Z",
@@ -71,9 +74,6 @@ async fn get_binned_0_inner() -> Result<(), Error> {
&cluster,
)
.await?;
if true {
return Ok(());
}
Ok(())
}
@@ -94,7 +94,7 @@ where
let channel_backend = "testbackend";
let date_fmt = "%Y-%m-%dT%H:%M:%S.%3fZ";
let uri = format!(
"http://{}:{}/api/1/binned?channel_backend={}&channel_name={}&bin_count={}&beg_date={}&end_date={}",
"http://{}:{}/api/1/binned?cache_usage=ignore&channel_backend={}&channel_name={}&bin_count={}&beg_date={}&end_date={}",
node0.host,
node0.port,
channel_backend,
@@ -125,11 +125,15 @@ where
#[derive(Debug)]
pub struct BinnedResponse {
bin_count: usize,
bytes_read: u64,
}
impl BinnedResponse {
pub fn new() -> Self {
Self { bin_count: 0 }
Self {
bin_count: 0,
bytes_read: 0,
}
}
}
@@ -178,6 +182,10 @@ where
a.bin_count += k.ts1s.len();
Ok(a)
}
Ok(MinMaxAvgScalarBinBatchStreamItem::EventDataReadStats(stats)) => {
a.bytes_read += stats.parsed_bytes;
Ok(a)
}
Ok(_) => Ok(a),
Err(e) => Err(e),
},
@@ -186,6 +194,7 @@ where
ready(g)
});
let ret = s1.await;
info!("BinnedResponse: {:?}", ret);
ret
}