mgao0 commented on a change in pull request #1187:
URL: https://github.com/apache/helix/pull/1187#discussion_r466646627
##########
File path:
helix-core/src/main/java/org/apache/helix/controller/stages/CustomizedStateOutput.java
##########
@@ -24,32 +24,58 @@
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 final 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>>>());
- }
- if (!_customizedStateMap.get(stateType).containsKey(resourceName)) {
- _customizedStateMap.get(stateType)
- .put(resourceName, new HashMap<Partition, Map<String, String>>());
- }
- if
(!_customizedStateMap.get(stateType).get(resourceName).containsKey(partition)) {
- _customizedStateMap.get(stateType).get(resourceName)
- .put(partition, new HashMap<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;
Review comment:
I updated this part. I was trying to simplify the code but found it
makes things more complicated. Now I just separate the two methods, as they do
not really cause a lot duplicated code.
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]