Skip to content

Commit d66ae6e

Browse files
author
Stephen Powis
committed
Cleanup
1 parent fe66dc6 commit d66ae6e

File tree

8 files changed

+229
-12
lines changed

8 files changed

+229
-12
lines changed
Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/**
2+
* Copyright 2018, 2019 SourceLab.org https://github.com/SourceLabOrg/kafka-connect-client
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
7+
* persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10+
* Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13+
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
*/
17+
118
package org.sourcelab.kafka.connect.apiclient.request.dto;
219

320
/**
@@ -8,24 +25,36 @@ public class ConnectServerVersion {
825
private String commit;
926
private String kafkaClusterId;
1027

28+
/**
29+
* Version of running Kafka-Connect server.
30+
* @return Version of running Kafka-Connect server.
31+
*/
1132
public String getVersion() {
1233
return version;
1334
}
1435

36+
/**
37+
* Commit hash of running Kafka-Connect server.
38+
* @return Commit hash of running Kafka-Connect server.
39+
*/
1540
public String getCommit() {
1641
return commit;
1742
}
1843

44+
/**
45+
* Kafka Cluster Identifier.
46+
* @return Kafka Cluster Identifier.
47+
*/
1948
public String getKafkaClusterId() {
2049
return kafkaClusterId;
2150
}
2251

2352
@Override
2453
public String toString() {
25-
return "ConnectServerVersion{" +
26-
"version='" + version + '\'' +
27-
", commit='" + commit + '\'' +
28-
", kafkaClusterId='" + kafkaClusterId + '\'' +
29-
'}';
54+
return "ConnectServerVersion{"
55+
+ "version='" + version + '\''
56+
+ ", commit='" + commit + '\''
57+
+ ", kafkaClusterId='" + kafkaClusterId + '\''
58+
+ '}';
3059
}
3160
}
Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,55 @@
1-
package org.sourcelab.kafka.connect.apiclient.request.dto;
1+
/**
2+
* Copyright 2018, 2019 SourceLab.org https://github.com/SourceLabOrg/kafka-connect-client
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
7+
* persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10+
* Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13+
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
*/
217

18+
package org.sourcelab.kafka.connect.apiclient.request.dto;
319

420
import java.util.Collection;
521
import java.util.Map;
622

23+
/**
24+
* Deployed Connectors extended with their associated ConnectorDefinitions.
25+
*
26+
* Requires Kafka-Connect server 2.3.0+
27+
*/
728
public interface ConnectorsWithExpandedInfo {
829

30+
/**
31+
* Names for all deployed connectors.
32+
* @return Names of all deployed connectors.
33+
*/
934
Collection<String> getConnectorNames();
1035

11-
ConnectorDefinition getDefinitionForConnector(final String connectorName);
36+
/**
37+
* Given a connector name, return the definition for the connector.
38+
* @param connectorName name of connector to return definition for.
39+
* @return ConnectorDefinition for the given connector name.
40+
* @throws IllegalArgumentException if passed a connector name not included in the results.
41+
*/
42+
ConnectorDefinition getDefinitionForConnector(final String connectorName) throws IllegalArgumentException;
1243

44+
/**
45+
* All ConnectorDefinitions.
46+
* @return all ConnectorDefinitions.
47+
*/
1348
Collection<ConnectorDefinition> getAllDefinitions();
1449

50+
/**
51+
* Map of ConnectorName to its respective ConnectorDefinition.
52+
* @return Map of ConnectorName to its respective ConnectorDefinition.
53+
*/
1554
Map<String, ConnectorDefinition> getMappedDefinitions();
1655
}

src/main/java/org/sourcelab/kafka/connect/apiclient/request/dto/ConnectorsWithExpandedMetadata.java

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/**
2+
* Copyright 2018, 2019 SourceLab.org https://github.com/SourceLabOrg/kafka-connect-client
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
7+
* persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10+
* Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13+
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
*/
17+
118
package org.sourcelab.kafka.connect.apiclient.request.dto;
219

320
import com.fasterxml.jackson.annotation.JsonAnySetter;
@@ -9,21 +26,31 @@
926
import java.util.Map;
1027
import java.util.stream.Collectors;
1128

29+
/**
30+
* Deployed Connectors extended with all available associated Metadata.
31+
*
32+
* Currently this includes both 'info' and 'status' metadata.
33+
*
34+
* Requires Kafka-Connect server 2.3.0+
35+
*/
1236
public class ConnectorsWithExpandedMetadata implements ConnectorsWithExpandedInfo, ConnectorsWithExpandedStatus {
1337
@JsonAnySetter
1438
private Map<String, ConnectorsWithExpandedMetadata.ConnectorWithExpandedMetadata> results = new HashMap<>();
1539

40+
@Override
1641
public Collection<String> getConnectorNames() {
1742
return results.keySet();
1843
}
1944

45+
@Override
2046
public ConnectorDefinition getDefinitionForConnector(final String connectorName) {
2147
if (!results.containsKey(connectorName)) {
2248
throw new IllegalArgumentException("Results do not contain connector: " + connectorName);
2349
}
2450
return results.get(connectorName).getInfo();
2551
}
2652

53+
@Override
2754
public Collection<ConnectorDefinition> getAllDefinitions() {
2855
return results
2956
.values()
@@ -32,6 +59,7 @@ public Collection<ConnectorDefinition> getAllDefinitions() {
3259
.collect(Collectors.toList());
3360
}
3461

62+
@Override
3563
public Map<String, ConnectorDefinition> getMappedDefinitions() {
3664
return Collections.unmodifiableMap(
3765
results
@@ -41,13 +69,15 @@ public Map<String, ConnectorDefinition> getMappedDefinitions() {
4169
);
4270
}
4371

72+
@Override
4473
public ConnectorStatus getStatusForConnector(final String connectorName) {
4574
if (!results.containsKey(connectorName)) {
4675
throw new IllegalArgumentException("Results do not contain connector: " + connectorName);
4776
}
4877
return results.get(connectorName).getStatus();
4978
}
5079

80+
@Override
5181
public Collection<ConnectorStatus> getAllStatuses() {
5282
return results
5383
.values()
@@ -56,6 +86,7 @@ public Collection<ConnectorStatus> getAllStatuses() {
5686
.collect(Collectors.toList());
5787
}
5888

89+
@Override
5990
public Map<String, ConnectorStatus> getMappedStatuses() {
6091
return Collections.unmodifiableMap(
6192
results
@@ -72,6 +103,9 @@ public String toString() {
72103
+ '}';
73104
}
74105

106+
/**
107+
* Expanded metadata included with the connector response.
108+
*/
75109
public static class ConnectorWithExpandedMetadata {
76110

77111
@JsonProperty("info")
@@ -90,10 +124,18 @@ public ConnectorDefinition getInfo() {
90124

91125
@Override
92126
public String toString() {
93-
return "Connector{" +
94-
"info=" + info +
95-
", status=" + status +
96-
'}';
127+
String value = "ConnectorMetadata{";
128+
if (info != null) {
129+
value += "info=" + info;
130+
if (status != null) {
131+
value += ", ";
132+
}
133+
}
134+
if (status != null) {
135+
value += "status=" + status;
136+
}
137+
value += '}';
138+
return value;
97139
}
98140
}
99141
}

src/main/java/org/sourcelab/kafka/connect/apiclient/request/dto/ConnectorsWithExpandedStatus.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,36 @@
33
import java.util.Collection;
44
import java.util.Map;
55

6+
/**
7+
* Deployed Connectors extended with their associated ConnectorDefinitions.
8+
*
9+
* Requires Kafka-Connect server 2.3.0+
10+
*/
611
public interface ConnectorsWithExpandedStatus {
712

13+
/**
14+
* Names for all deployed connectors.
15+
* @return Names of all deployed connectors.
16+
*/
817
Collection<String> getConnectorNames();
918

19+
/**
20+
* Given a connector name, return the status for the connector.
21+
* @param connectorName name of connector to return status for.
22+
* @return ConnectorStatus for the given connector name.
23+
* @throws IllegalArgumentException if passed a connector name not included in the results.
24+
*/
1025
ConnectorStatus getStatusForConnector(final String connectorName);
1126

27+
/**
28+
* All connector statuses.
29+
* @return All connector statuses.
30+
*/
1231
Collection<ConnectorStatus> getAllStatuses();
1332

33+
/**
34+
* Map of ConnectorName to its respective Status.
35+
* @return Map of ConnectorName to its respective Status.
36+
*/
1437
Map<String, ConnectorStatus> getMappedStatuses();
1538
}

src/main/java/org/sourcelab/kafka/connect/apiclient/request/get/GetConnectorsExpandAllDetails.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
1+
/**
2+
* Copyright 2018, 2019 SourceLab.org https://github.com/SourceLabOrg/kafka-connect-client
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
7+
* persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10+
* Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13+
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
*/
17+
118
package org.sourcelab.kafka.connect.apiclient.request.get;
219

320
import org.sourcelab.kafka.connect.apiclient.request.JacksonFactory;
421
import org.sourcelab.kafka.connect.apiclient.request.dto.ConnectorsWithExpandedMetadata;
522

623
import java.io.IOException;
724

25+
/**
26+
* Defines a request to retrieve all deployed Connectors extended with all available associated metadata.
27+
*
28+
* Currently this includes both 'info' and 'status' metadata.
29+
*
30+
* Requires Kafka-Connect server 2.3.0+
31+
*/
832
public class GetConnectorsExpandAllDetails implements GetRequest<ConnectorsWithExpandedMetadata> {
933

1034
@Override

src/main/java/org/sourcelab/kafka/connect/apiclient/request/get/GetConnectorsExpandInfo.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/**
2+
* Copyright 2018, 2019 SourceLab.org https://github.com/SourceLabOrg/kafka-connect-client
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
7+
* persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10+
* Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13+
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
*/
17+
118
package org.sourcelab.kafka.connect.apiclient.request.get;
219

320
import org.sourcelab.kafka.connect.apiclient.request.JacksonFactory;
@@ -6,6 +23,11 @@
623

724
import java.io.IOException;
825

26+
/**
27+
* Defines a request to retrieve all deployed Connectors extended with 'info' metadata.
28+
*
29+
* Requires Kafka-Connect server 2.3.0+
30+
*/
931
public class GetConnectorsExpandInfo implements GetRequest<ConnectorsWithExpandedInfo> {
1032

1133
@Override

src/main/java/org/sourcelab/kafka/connect/apiclient/request/get/GetConnectorsExpandStatus.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
1-
package org.sourcelab.kafka.connect.apiclient.request.get;
1+
/**
2+
* Copyright 2018, 2019 SourceLab.org https://github.com/SourceLabOrg/kafka-connect-client
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
7+
* persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10+
* Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13+
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
*/
217

18+
package org.sourcelab.kafka.connect.apiclient.request.get;
319

420
import org.sourcelab.kafka.connect.apiclient.request.JacksonFactory;
521
import org.sourcelab.kafka.connect.apiclient.request.dto.ConnectorsWithExpandedMetadata;
622
import org.sourcelab.kafka.connect.apiclient.request.dto.ConnectorsWithExpandedStatus;
723

824
import java.io.IOException;
925

26+
/**
27+
* Defines a request to retrieve all deployed Connectors extended 'status' metadata.
28+
*
29+
* Requires Kafka-Connect server 2.3.0+
30+
*/
1031
public class GetConnectorsExpandStatus implements GetRequest<ConnectorsWithExpandedStatus> {
1132

1233
@Override

src/test/java/org/sourcelab/kafka/connect/apiclient/request/get/connector/GetConnectServerVersionTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/**
2+
* Copyright 2018, 2019 SourceLab.org https://github.com/SourceLabOrg/kafka-connect-client
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
7+
* persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10+
* Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13+
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
*/
17+
118
package org.sourcelab.kafka.connect.apiclient.request.get.connector;
219

320
import org.junit.Test;

0 commit comments

Comments
 (0)