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

fix(RouteDiagram): Show total exchanges instead of completed #1181

Merged
merged 2 commits into from
Oct 23, 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
11 changes: 9 additions & 2 deletions packages/hawtio/src/plugins/camel/route-diagram/RouteDiagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ const CamelNode: React.FunctionComponent<NodeProps<CamelNodeData>> = ({
return newLabel.substring(0, 17) + '...'
}

const totalExchanges: number =
parseInt(data.stats?.exchangesCompleted ?? '0') + parseInt(data.stats?.exchangesInflight ?? '0')

return (
<div
className={'camel-node-content' + (selected ? ' highlighted' : '')}
Expand All @@ -163,7 +166,7 @@ const CamelNode: React.FunctionComponent<NodeProps<CamelNodeData>> = ({
<div className='annotation'>{annotation?.element}</div>
<div className='icon'>{data.imageUrl}</div>
<div className='inflights'>{showInflightCounter && data.stats?.exchangesInflight}</div>
<div className='number'>{data.stats?.exchangesCompleted}</div>
<div className='number'>{totalExchanges}</div>
<div className='camel-node-label'>{truncate(data.label)}</div>
{data.cid && <div className='camel-node-id'> (ID: {data.cid})</div>}
{showStatistics && (
Expand All @@ -177,6 +180,10 @@ const CamelNode: React.FunctionComponent<NodeProps<CamelNodeData>> = ({
<Td>ID</Td>
<Td>{data.stats.id}</Td>
</Tr>
<Tr>
<Td>Total</Td>
<Td>{totalExchanges}</Td>
</Tr>
<Tr>
<Td>Completed</Td>
<Td>{data.stats?.exchangesCompleted}</Td>
Expand All @@ -194,7 +201,7 @@ const CamelNode: React.FunctionComponent<NodeProps<CamelNodeData>> = ({
<Td>{data.stats?.meanProcessingTime} (ms)</Td>
</Tr>
<Tr>
<Td>Mix</Td>
<Td>Min</Td>
<Td>{data.stats?.minProcessingTime} (ms)</Td>
</Tr>
<Tr>
Expand Down
9 changes: 3 additions & 6 deletions packages/hawtio/src/plugins/camel/routes-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type RouteStats = Statistics & {

export const ROUTE_OPERATIONS = {
dumpRoutesAsXml: 'dumpRoutesAsXml()',
dumpRoutesStatsAsXml: 'dumpRoutesStatsAsXml',
} as const

// TODO: This service should be named more properly like RoutesXmlService, RouteStatisticsService, etc.
Expand Down Expand Up @@ -212,15 +213,11 @@ class RoutesService {

async dumpRoutesStatsXML(routesNode: MBeanNode): Promise<string | null> {
let xml = null
const routeNodeOperation = 'dumpRouteStatsAsXml'
const routesFolderOperation = 'dumpRoutesStatsAsXml'

const mbeanName = routesNode.getMetadata(contextNodeType)
const operationForMBean = mbeanName ? routesFolderOperation : routeNodeOperation
const mbeanToQuery = mbeanName ? mbeanName : (routesNode.objectName ?? '')
const mbeanToQuery = mbeanName ? mbeanName : (routesNode.parent?.getMetadata(contextNodeType) ?? '')

try {
xml = await jolokiaService.execute(mbeanToQuery, operationForMBean, [true, true])
xml = await jolokiaService.execute(mbeanToQuery, ROUTE_OPERATIONS.dumpRoutesStatsAsXml, [true, true])
} catch (error) {
throw new Error('Failed to dump routes stats from mbean ' + mbeanName + ': ' + error)
}
Expand Down
Loading