private Map<String, CurrentState> generateCurrentStateMap( Map<String, CurrentStateInfo> currentStateRawData) { Map<String, CurrentState> currentStateMap = new HashMap<String, CurrentState>(); for (String instanceName : currentStateRawData.keySet()) { CurrentStateInfo info = currentStateRawData.get(instanceName); CurrentState currentState = new CurrentState(TEST_RESOURCE); currentState.setSessionId(SESSION_PREFIX + instanceName.split("_")[1]); currentState.setState(PARTITION, info.currentState); currentState.setPreviousState(PARTITION, info.previousState); currentState.setStartTime(PARTITION, info.startTime); currentState.setEndTime(PARTITION, info.endTime); currentStateMap.put(instanceName, currentState); } return currentStateMap; }
private void setCurrentState(String clusterName, String instance, String resourceGroupName, String resourceKey, String sessionId, String state, boolean updateTimestamp) { ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient)); Builder keyBuilder = accessor.keyBuilder(); CurrentState curState = new CurrentState(resourceGroupName); curState.setState(resourceKey, state); curState.setSessionId(sessionId); curState.setStateModelDefRef("MasterSlave"); if (updateTimestamp) { curState.setEndTime(resourceKey, System.currentTimeMillis()); } accessor.setProperty(keyBuilder.currentState(instance, sessionId, resourceGroupName), curState); }
currentStateDelta.setBucketSize(bucketSize); currentStateDelta.setState(partitionKey, (stateModel.getCurrentState() == null) ? initState : stateModel.getCurrentState());
currentStateDelta.setBucketSize(bucketSize); currentStateDelta.setState(partitionKey, (stateModel.getCurrentState() == null) ? initState : stateModel.getCurrentState());
@Override public ZNRecord update(ZNRecord currentData) { CurrentState curState = null; if (currentData == null) { curState = new CurrentState(_lastCurState.getId()); // copy all simple fields settings and overwrite session-id to current session curState.getRecord().setSimpleFields(_lastCurState.getRecord().getSimpleFields()); curState.setSessionId(_curSessionId); } else { curState = new CurrentState(currentData); } for (String partitionName : _lastCurState.getPartitionStateMap().keySet()) { // carry-over only when current-state not exist if (curState.getState(partitionName) == null) { curState.setState(partitionName, _initState); } } return curState.getRecord(); }
stateWithLiveSession.setSessionId("session_3"); stateWithLiveSession.setStateModelDefRef("MasterSlave"); stateWithLiveSession.setState("testResourceName_1", "OFFLINE"); ZNRecord record2 = new ZNRecord("testResourceName"); CurrentState stateWithDeadSession = new CurrentState(record2); stateWithDeadSession.setSessionId("session_dead"); stateWithDeadSession.setStateModelDefRef("MasterSlave"); stateWithDeadSession.setState("testResourceName_1", "MASTER");
@Override public ZNRecord update(ZNRecord currentData) { CurrentState curState = null; if (currentData == null) { curState = new CurrentState(_lastCurState.getId()); // copy all simple fields settings and overwrite session-id to current session curState.getRecord().setSimpleFields(_lastCurState.getRecord().getSimpleFields()); curState.setSessionId(_curSessionId); } else { curState = new CurrentState(currentData); } for (String partitionName : _lastCurState.getPartitionStateMap().keySet()) { // carry-over only when current-state not exist if (curState.getState(partitionName) == null) { curState.setState(partitionName, _initState); } } return curState.getRecord(); }
currentStateDelta.setState(partition, HelixDefinedState.ERROR.toString()); _stateModel.updateState(HelixDefinedState.ERROR.toString());
currentStateDelta.setState(partition, HelixDefinedState.ERROR.toString()); _stateModel.updateState(HelixDefinedState.ERROR.toString());
_currentStateDelta.setState(partitionKey, toState); + partitionKey + ", currentState: " + _stateModel.getCurrentState() + ", message: " + _message); _currentStateDelta.setState(partitionKey, _stateModel.getCurrentState()); } else { StateTransitionError error = _currentStateDelta.setState(partitionKey, HelixDefinedState.ERROR.toString()); _stateModel.updateState(HelixDefinedState.ERROR.toString());
_currentStateDelta.setState(partitionKey, toState); + partitionKey + ", currentState: " + _stateModel.getCurrentState() + ", message: " + _message); _currentStateDelta.setState(partitionKey, _stateModel.getCurrentState()); } else { StateTransitionError error = _currentStateDelta.setState(partitionKey, HelixDefinedState.ERROR.toString()); _stateModel.updateState(HelixDefinedState.ERROR.toString());
currentStateDelta.setState("TestDB_0", "OFFLINE");
currentStateDelta.setState("TestDB_0", "OFFLINE");
currentStateDelta.setState("TestDB_0", "OFFLINE");