You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/08/04 17:28:55 UTC
[GitHub] [helix] mgao0 commented on a change in pull request #1187: Add latency metric support for customized view aggregation
mgao0 commented on a change in pull request #1187:
URL: https://github.com/apache/helix/pull/1187#discussion_r465212964
##########
File path: helix-core/src/main/java/org/apache/helix/controller/stages/CustomizedStateOutput.java
##########
@@ -24,32 +24,63 @@
import java.util.Map;
import java.util.Set;
+import org.apache.helix.model.CustomizedState;
import org.apache.helix.model.Partition;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class CustomizedStateOutput {
+ private static Logger LOG = LoggerFactory.getLogger(CustomizedStateOutput.class);
+
// stateType -> (resourceName -> (Partition -> (instanceName -> customizedState)))
private final Map<String, Map<String, Map<Partition, Map<String, String>>>> _customizedStateMap;
+ // stateType -> (resourceName -> (Partition -> (instanceName -> startTime)))
+ private final Map<String, Map<String, Map<Partition, Map<String, String>>>> _startTimeMap;
public CustomizedStateOutput() {
_customizedStateMap = new HashMap<>();
+ _startTimeMap = new HashMap<>();
}
public void setCustomizedState(String stateType, String resourceName, Partition partition,
String instanceName, String state) {
- if (!_customizedStateMap.containsKey(stateType)) {
- _customizedStateMap
- .put(stateType, new HashMap<String, Map<Partition, Map<String, String>>>());
+ setCustomizedStateProperty(CustomizedState.CustomizedStateProperty.CURRENT_STATE, stateType,
+ resourceName, partition, instanceName, state);
+ }
+
+ public void setStartTime(String stateType, String resourceName, Partition partition,
+ String instanceName, String state) {
+ setCustomizedStateProperty(CustomizedState.CustomizedStateProperty.START_TIME, stateType,
+ resourceName, partition, instanceName, state);
+ }
+
+ private void setCustomizedStateProperty(CustomizedState.CustomizedStateProperty propertyName,
+ String stateType, String resourceName, Partition partition, String instanceName,
+ String state) {
+ Map<String, Map<String, Map<Partition, Map<String, String>>>> mapToUpdate;
+ switch (propertyName) {
+ case CURRENT_STATE:
+ mapToUpdate = _customizedStateMap;
+ break;
+ case START_TIME:
+ mapToUpdate = _startTimeMap;
+ break;
+ default:
+ LOG.error(
Review comment:
Good to know. Thanks! I changed all the ERROR level to warning since it's not significant issue
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org