Update deps, status and hashmap

This commit is contained in:
Dominik Werder
2024-02-07 11:48:40 +01:00
parent f5ca38caaf
commit 3c4970aa2c
9 changed files with 956 additions and 444 deletions

View File

@@ -15,6 +15,8 @@ use futures_util::Future;
use futures_util::FutureExt;
use futures_util::Stream;
use futures_util::StreamExt;
use hashbrown::HashMap;
use hashbrown::HashSet;
use log::*;
use netpod::timeunits::*;
use netpod::ScalarType;
@@ -53,8 +55,6 @@ use stats::CaConnStats;
use stats::CaProtoStats;
use stats::IntervalEma;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::net::SocketAddrV4;
use std::ops::ControlFlow;
@@ -1531,7 +1531,7 @@ impl CaConn {
let sid_ev = Sid(ev.sid);
let ioid = Ioid(ev.ioid);
if let Some(cid) = self.read_ioids.get(&ioid) {
let ch_s = if let Some(x) = self.channels.get_mut(&cid) {
let ch_s = if let Some(x) = self.channels.get_mut(cid) {
x
} else {
warn!("handle_read_notify_res can not find channel for {cid:?} {ioid:?}");

View File

@@ -30,6 +30,7 @@ use err::Error;
use futures_util::FutureExt;
use futures_util::Stream;
use futures_util::StreamExt;
use hashbrown::HashMap;
use log::*;
use scywr::iteminsertqueue::ChannelInfoItem;
use scywr::iteminsertqueue::ChannelStatusItem;
@@ -54,7 +55,6 @@ use stats::CaConnStats;
use stats::CaProtoStats;
use stats::IocFinderStats;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::net::SocketAddr;
use std::net::SocketAddrV4;
@@ -346,7 +346,7 @@ pub struct CaConnSet {
ticker: Pin<Box<tokio::time::Sleep>>,
backend: String,
local_epics_hostname: String,
ca_conn_ress: BTreeMap<SocketAddr, CaConnRes>,
ca_conn_ress: HashMap<SocketAddr, CaConnRes>,
channel_states: ChannelStateMap,
channel_by_cssid: HashMap<ChannelStatusSeriesId, Channel>,
connset_inp_rx: Pin<Box<Receiver<CaConnSetEvent>>>,
@@ -413,7 +413,7 @@ impl CaConnSet {
ticker: Self::new_self_ticker(),
backend,
local_epics_hostname,
ca_conn_ress: BTreeMap::new(),
ca_conn_ress: HashMap::new(),
channel_states: ChannelStateMap::new(),
channel_by_cssid: HashMap::new(),
connset_inp_rx: Box::pin(connset_inp_rx),

View File

@@ -11,10 +11,10 @@ use dbpg::iocindex::IocItem;
use dbpg::iocindex::IocSearchIndexWorker;
use dbpg::postgres::Row as PgRow;
use err::Error;
use hashbrown::HashMap;
use log::*;
use netpod::Database;
use stats::IocFinderStats;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::sync::Arc;
use std::time::Duration;
@@ -188,17 +188,19 @@ async fn finder_worker_single(
let nbatch = batch.len();
trace_batch!("received results {} resdiff {}", rows.len(), resdiff);
let items = transform_pgres(rows);
let names: HashMap<_, _> = items.iter().map(|x| (&x.channel, true)).collect();
let mut to_add = Vec::new();
for e in batch {
if !names.contains_key(e.name_string()) {
let item = FindIocRes {
channel: e.name().into(),
response_addr: None,
addr: None,
dt: Duration::from_millis(0),
};
to_add.push(item);
{
let names: HashMap<_, _> = items.iter().map(|x| (&x.channel, true)).collect();
for e in batch {
if !names.contains_key(e.name_string()) {
let item = FindIocRes {
channel: e.name().into(),
response_addr: None,
addr: None,
dt: Duration::from_millis(0),
};
to_add.push(item);
}
}
}
let mut items = items;

View File

@@ -67,10 +67,6 @@ pub struct UnassignedState {
#[derive(Debug, Clone, Serialize)]
pub enum WithStatusSeriesIdStateInner {
UnknownAddress {
#[serde(with = "humantime_serde")]
since: SystemTime,
},
AddrSearchPending {
#[serde(with = "humantime_serde")]
since: SystemTime,
@@ -79,6 +75,10 @@ pub enum WithStatusSeriesIdStateInner {
addr: SocketAddrV4,
state: WithAddressState,
},
UnknownAddress {
#[serde(with = "humantime_serde")]
since: SystemTime,
},
NoAddress {
#[serde(with = "humantime_serde")]
since: SystemTime,