-
Notifications
You must be signed in to change notification settings - Fork 447
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
Low friction cleanups (suggested by IntelliJ) #361
base: master
Are you sure you want to change the base?
Conversation
@@ -94,15 +93,6 @@ public XinfraMonitor(Map<String, Map> allClusterProps) throws Exception { | |||
(config, now) -> _offlineRunnables.size()); | |||
} | |||
|
|||
private boolean constructorContainsClass(Constructor<?>[] constructors, Class<?> classObject) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was never called
/* Delay 2 second to reduce the chance that produce and consumer thread has race condition | ||
with TopicManagementService and MultiClusterTopicManagementService */ | ||
long threadSleepMs = TimeUnit.SECONDS.toMillis(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to concisely use the Utils.delay(...)
method. Here, I additionally had to import delay
statically since a Kafka Utils
class is already used. (avoiding fully qualified import)
@@ -55,8 +55,6 @@ | |||
*/ | |||
public class Utils { | |||
private static final Logger LOG = LoggerFactory.getLogger(Utils.class); | |||
public static final int ZK_CONNECTION_TIMEOUT_MS = 30_000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
@@ -117,9 +115,7 @@ public static List<Integer> replicaIdentifiers(Set<BrokerMetadata> brokers) { | |||
Collections.shuffle(brokerMetadataList); | |||
|
|||
// Get broker ids for replica list | |||
List<Integer> replicaList = brokerMetadataList.stream().map(m -> m.id()).collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline
for (Map.Entry<String, String> entry : customProps.entrySet()) { | ||
consumerProps.put(entry.getKey(), entry.getValue()); | ||
} | ||
consumerProps.putAll(customProps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never would have spotted this myself - putAll is a convenient shortcut + also more performant (I know, not relevant here)
_metricMap = new HashMap<>(); | ||
_dimensionsMap = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was redundant
|
||
return offsetCommitSuccessRate + offsetCommitFailureRate > 0 ? offsetCommitSuccessRate / ( | ||
offsetCommitSuccessRate + offsetCommitFailureRate) : 0; | ||
Measurable measurable = (config, now) -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using lambda
|
||
consumeService.stop(); | ||
thread.join(500); | ||
|
||
Assert.assertFalse(thread.isAlive()); | ||
Assert.assertEquals(error.get(), null); | ||
Assert.assertNull(error.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simplify
@@ -207,8 +200,7 @@ public void run() { | |||
*/ | |||
private Metrics consumeServiceMetrics(ConsumeService consumeService) { | |||
setup(); | |||
Metrics metrics = consumeService.metrics(); | |||
return metrics; | |||
return consumeService.metrics(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline
public XinfraMonitorConstants() { | ||
|
||
} | ||
private XinfraMonitorConstants() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utility class
To familiarize with the code base I tried to perform a "random act of kindness" (Uncle Bob) 😊 by applying some of the suggested IntelliJ refactorings/ cleanups.