-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/14-add-custom-params-for-topics-cr…
…eation
- Loading branch information
Showing
29 changed files
with
447 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
kafka-ui-api/src/main/java/com/provectus/kafka/ui/cluster/util/ClusterUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.provectus.kafka.ui.cluster.util; | ||
|
||
import com.provectus.kafka.ui.cluster.model.KafkaCluster; | ||
import com.provectus.kafka.ui.model.ConsumerGroup; | ||
import org.apache.kafka.clients.admin.ConsumerGroupDescription; | ||
import org.apache.kafka.common.KafkaFuture; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class ClusterUtil { | ||
|
||
public static <T> Mono<T> toMono(KafkaFuture<T> future){ | ||
return Mono.create(sink -> future.whenComplete((res, ex)->{ | ||
if (ex!=null) { | ||
sink.error(ex); | ||
} else { | ||
sink.success(res); | ||
} | ||
})); | ||
} | ||
|
||
public static ConsumerGroup convertToConsumerGroup(ConsumerGroupDescription c, KafkaCluster cluster) { | ||
ConsumerGroup consumerGroup = new ConsumerGroup(); | ||
consumerGroup.setClusterId(cluster.getCluster().getId()); | ||
consumerGroup.setConsumerGroupId(c.groupId()); | ||
consumerGroup.setNumConsumers(c.members().size()); | ||
Set<String> topics = new HashSet<>(); | ||
c.members().forEach(s1 -> s1.assignment().topicPartitions().forEach(s2 -> topics.add(s2.topic()))); | ||
consumerGroup.setNumTopics(topics.size()); | ||
return consumerGroup; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[ | ||
{ | ||
"clusterId": "fake.cluster", | ||
"consumerGroupId": "_fake.cluster.consumer_1", | ||
"numConsumers": 1, | ||
"numTopics": 11 | ||
}, | ||
{ | ||
"clusterId": "fake.cluster", | ||
"consumerGroupId": "_fake.cluster.consumer_2", | ||
"numConsumers": 2, | ||
"numTopics": 22 | ||
}, | ||
{ | ||
"clusterId": "fake.cluster", | ||
"consumerGroupId": "_fake.cluster.consumer_3", | ||
"numConsumers": 3, | ||
"numTopics": 33 | ||
}, | ||
|
||
{ | ||
"clusterId": "kafka-ui.cluster", | ||
"consumerGroupId": "_kafka-ui.cluster.consumer_1", | ||
"numConsumers": 4, | ||
"numTopics": 44 | ||
}, | ||
{ | ||
"clusterId": "kafka-ui.cluster", | ||
"consumerGroupId": "_kafka-ui.cluster.consumer_2", | ||
"numConsumers": 5, | ||
"numTopics": 55 | ||
}, | ||
{ | ||
"clusterId": "kafka-ui.cluster", | ||
"consumerGroupId": "_kafka-ui.cluster.consumer_3", | ||
"numConsumers": 6, | ||
"numTopics": 66 | ||
} | ||
] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
kafka-ui-react-app/src/components/ConsumerGroups/ConsumerGroups.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import { ClusterName } from 'redux/interfaces'; | ||
import { | ||
Switch, | ||
Route, | ||
} from 'react-router-dom'; | ||
import ListContainer from './List/ListContainer'; | ||
import PageLoader from 'components/common/PageLoader/PageLoader'; | ||
|
||
interface Props { | ||
clusterName: ClusterName; | ||
isFetched: boolean; | ||
fetchConsumerGroupsList: (clusterName: ClusterName) => void; | ||
} | ||
|
||
const ConsumerGroups: React.FC<Props> = ({ | ||
clusterName, | ||
isFetched, | ||
fetchConsumerGroupsList, | ||
}) => { | ||
React.useEffect(() => { fetchConsumerGroupsList(clusterName); }, [fetchConsumerGroupsList, clusterName]); | ||
|
||
if (isFetched) { | ||
return ( | ||
<Switch> | ||
<Route exact path="/clusters/:clusterName/consumer-groups" component={ListContainer} /> | ||
</Switch> | ||
); | ||
} | ||
|
||
return (<PageLoader />); | ||
}; | ||
|
||
export default ConsumerGroups; |
24 changes: 24 additions & 0 deletions
24
kafka-ui-react-app/src/components/ConsumerGroups/ConsumersGroupsContainer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { connect } from 'react-redux'; | ||
import { fetchConsumerGroupsList } from 'redux/actions'; | ||
import { RootState, ClusterName } from 'redux/interfaces'; | ||
import { RouteComponentProps } from 'react-router-dom'; | ||
import ConsumerGroups from './ConsumerGroups'; | ||
import { getIsConsumerGroupsListFetched } from '../../redux/reducers/consumerGroups/selectors'; | ||
|
||
|
||
interface RouteProps { | ||
clusterName: ClusterName; | ||
} | ||
|
||
interface OwnProps extends RouteComponentProps<RouteProps> { } | ||
|
||
const mapStateToProps = (state: RootState, { match: { params: { clusterName } }}: OwnProps) => ({ | ||
isFetched: getIsConsumerGroupsListFetched(state), | ||
clusterName, | ||
}); | ||
|
||
const mapDispatchToProps = { | ||
fetchConsumerGroupsList: (clusterName: ClusterName) => fetchConsumerGroupsList(clusterName), | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(ConsumerGroups); |
64 changes: 64 additions & 0 deletions
64
kafka-ui-react-app/src/components/ConsumerGroups/List/List.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, { ChangeEvent } from 'react'; | ||
import { ConsumerGroup, ClusterName } from 'redux/interfaces'; | ||
import ListItem from './ListItem'; | ||
import Breadcrumb from 'components/common/Breadcrumb/Breadcrumb'; | ||
|
||
interface Props { | ||
clusterName: ClusterName; | ||
consumerGroups: (ConsumerGroup)[]; | ||
} | ||
|
||
const List: React.FC<Props> = ({ | ||
consumerGroups, | ||
}) => { | ||
|
||
const [searchText, setSearchText] = React.useState<string>(''); | ||
|
||
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setSearchText(event.target.value); | ||
}; | ||
|
||
const items = consumerGroups; | ||
|
||
return ( | ||
<div className="section"> | ||
<Breadcrumb>All Consumer Groups</Breadcrumb> | ||
|
||
<div className="box"> | ||
<div className="columns"> | ||
<div className="column is-half is-offset-half"> | ||
<input id="searchText" | ||
type="text" | ||
name="searchText" | ||
className="input" | ||
placeholder="Search" | ||
value={searchText} | ||
onChange={handleInputChange} | ||
/> | ||
</div> | ||
</div> | ||
<table className="table is-striped is-fullwidth"> | ||
<thead> | ||
<tr> | ||
<th>Consumer group ID</th> | ||
<th>Num of consumers</th> | ||
<th>Num of topics</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{items | ||
.filter( (consumerGroup) => !searchText || consumerGroup?.consumerGroupId?.indexOf(searchText) >= 0) | ||
.map((consumerGroup, index) => ( | ||
<ListItem | ||
key={`consumer-group-list-item-key-${index}`} | ||
{...consumerGroup} | ||
/> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default List; |
20 changes: 20 additions & 0 deletions
20
kafka-ui-react-app/src/components/ConsumerGroups/List/ListContainer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { connect } from 'react-redux'; | ||
import {ClusterName, RootState} from 'redux/interfaces'; | ||
import { getConsumerGroupsList } from 'redux/reducers/consumerGroups/selectors'; | ||
import List from './List'; | ||
import { withRouter, RouteComponentProps } from 'react-router-dom'; | ||
|
||
interface RouteProps { | ||
clusterName: ClusterName; | ||
} | ||
|
||
interface OwnProps extends RouteComponentProps<RouteProps> { } | ||
|
||
const mapStateToProps = (state: RootState, { match: { params: { clusterName } } }: OwnProps) => ({ | ||
clusterName, | ||
consumerGroups: getConsumerGroupsList(state) | ||
}); | ||
|
||
export default withRouter( | ||
connect(mapStateToProps)(List) | ||
); |
Oops, something went wrong.