-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade Helix lib to 0.9.1 and add metrics for state transition (#1374)
1. Upgrade Helix lib which should fix missing ZK callback issues 2. Introduce participant metrics to track partitions in each state
- Loading branch information
Showing
13 changed files
with
245 additions
and
22 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
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
64 changes: 64 additions & 0 deletions
64
ambry-clustermap/src/main/java/com.github.ambry.clustermap/HelixParticipantMetrics.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,64 @@ | ||
/* | ||
* Copyright 2020 LinkedIn Corp. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
package com.github.ambry.clustermap; | ||
|
||
import com.codahale.metrics.Counter; | ||
import com.codahale.metrics.Gauge; | ||
import com.codahale.metrics.MetricRegistry; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
|
||
/** | ||
* Metrics for {@link HelixParticipant} to monitor partition state transitions. | ||
*/ | ||
class HelixParticipantMetrics { | ||
final AtomicInteger bootstrapCount = new AtomicInteger(); | ||
final AtomicInteger standbyCount = new AtomicInteger(); | ||
final AtomicInteger leaderCount = new AtomicInteger(); | ||
final AtomicInteger inactiveCount = new AtomicInteger(); | ||
final AtomicInteger offlineCount = new AtomicInteger(); | ||
// no need to record exact number of "dropped" partition, a counter to track partition-dropped events would suffice | ||
final Counter partitionDroppedCount; | ||
|
||
HelixParticipantMetrics(MetricRegistry metricRegistry) { | ||
Gauge<Integer> bootstrapPartitionCount = bootstrapCount::get; | ||
metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "bootstrapPartitionCount"), | ||
bootstrapPartitionCount); | ||
Gauge<Integer> standbyPartitionCount = standbyCount::get; | ||
metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "standbyPartitionCount"), | ||
standbyPartitionCount); | ||
Gauge<Integer> leaderPartitionCount = leaderCount::get; | ||
metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "leaderPartitionCount"), leaderPartitionCount); | ||
Gauge<Integer> inactivePartitionCount = inactiveCount::get; | ||
metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "inactivePartitionCount"), | ||
inactivePartitionCount); | ||
Gauge<Integer> offlinePartitionCount = offlineCount::get; | ||
metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "offlinePartitionCount"), | ||
offlinePartitionCount); | ||
partitionDroppedCount = | ||
metricRegistry.counter(MetricRegistry.name(HelixParticipant.class, "partitionDroppedCount")); | ||
} | ||
|
||
/** | ||
* Set number of partitions on current node. This is invoked during startup. | ||
* @param partitionCount number of partitions on current node | ||
*/ | ||
void setLocalPartitionCount(int partitionCount) { | ||
// this method should be invoked before participation, so the initial value is expected to be 0. | ||
if (!offlineCount.compareAndSet(0, partitionCount)) { | ||
throw new IllegalStateException( | ||
"Number of OFFLINE partitions has changed before initializing participant metrics"); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.