if (currentState != null && targetState.equals(currentState.getState(partitionName))) { LOG.info("CurrentState " + currentState + " match the target state of the relay message, remove it from committed message cache."
if (partition != null) { currentStateOutput.setCurrentState(resourceName, partition, instanceName, currentState.getState(partitionName)); currentStateOutput.setRequestedState(resourceName, partition, instanceName, currentState.getRequestedState(partitionName));
cache.getCurrentState(instanceName, liveInstances.get(instanceName).getSessionId()) .get(resourceName); if (currentState.getState(partition.getPartitionName()).equalsIgnoreCase(topState)) { handOffEndTime = Math.min(handOffEndTime, currentState.getEndTime(partition.getPartitionName()));
if (partition != null) { currentStateOutput.setCurrentState(resourceName, partition, instanceName, currentState.getState(partitionName)); currentStateOutput.setRequestedState(resourceName, partition, instanceName, currentState.getRequestedState(partitionName));
if (currentState == null || !targetState.equals(currentState.getState(partitionName))) { LOG.info("CurrentState " + currentState + " do not match the target state of the message, ignore relay messages attached to message "
private void callParticipantCode(NotificationContext context) { // since ZkClient.unsubscribe() does not immediately remove listeners // from zk, it is possible that two listeners exist when leadership transfers // therefore, double check to make sure only one participant invokes the code if (context.getType() == Type.CALLBACK) { HelixManager manager = context.getManager(); // DataAccessor accessor = manager.getDataAccessor(); HelixDataAccessor accessor = manager.getHelixDataAccessor(); Builder keyBuilder = accessor.keyBuilder(); String instance = manager.getInstanceName(); String sessionId = manager.getSessionId(); // get resource name from partition key: "PARTICIPANT_LEADER_XXX_0" String resourceName = _partitionKey.substring(0, _partitionKey.lastIndexOf('_')); CurrentState curState = accessor.getProperty(keyBuilder.currentState(instance, sessionId, resourceName)); if (curState == null) { return; } String state = curState.getState(_partitionKey); if (state == null || !state.equalsIgnoreCase("LEADER")) { return; } } try { _callback.onCallback(context); } catch (Exception e) { LOG.error("Error invoking callback:" + _callback, e); } }
private void callParticipantCode(NotificationContext context) { // since ZkClient.unsubscribe() does not immediately remove listeners // from zk, it is possible that two listeners exist when leadership transfers // therefore, double check to make sure only one participant invokes the code if (context.getType() == Type.CALLBACK) { HelixManager manager = context.getManager(); // DataAccessor accessor = manager.getDataAccessor(); HelixDataAccessor accessor = manager.getHelixDataAccessor(); Builder keyBuilder = accessor.keyBuilder(); String instance = manager.getInstanceName(); String sessionId = manager.getSessionId(); // get resource name from partition key: "PARTICIPANT_LEADER_XXX_0" String resourceName = _partitionKey.substring(0, _partitionKey.lastIndexOf('_')); CurrentState curState = accessor.getProperty(keyBuilder.currentState(instance, sessionId, resourceName)); if (curState == null) { return; } String state = curState.getState(_partitionKey); if (state == null || !state.equalsIgnoreCase("LEADER")) { return; } } try { _callback.onCallback(context); } catch (Exception e) { LOG.error("Error invoking callback:" + _callback, e); } }
if (currentState == null || !targetState.equals(currentState.getState(partitionName))) { LOG.info("CurrentState " + currentState + " do not match the target state of the message, ignore relay messages attached to message " if (currentState != null && targetState.equals(currentState.getState(partitionName))) { LOG.info("CurrentState " + currentState + " match the target state of the relay message, remove relay from cache." + message
int expectedHost = 0; for (String partition : currentState.getPartitionStateMap().keySet()) { String state = currentState.getState(partition); Assert.assertEquals(state, expectedState, dbName + " Partition " + partition + "'s state is different as expected!");
private void verifyP2PDisabled() { ClusterDataCache dataCache = new ClusterDataCache(CLUSTER_NAME); dataCache.refresh(_accessor); Map<String, LiveInstance> liveInstanceMap = dataCache.getLiveInstances(); for (LiveInstance instance : liveInstanceMap.values()) { Map<String, CurrentState> currentStateMap = dataCache.getCurrentState(instance.getInstanceName(), instance.getSessionId()); Assert.assertNotNull(currentStateMap); for (CurrentState currentState : currentStateMap.values()) { for (String partition : currentState.getPartitionStateMap().keySet()) { String state = currentState.getState(partition); if (state.equalsIgnoreCase("MASTER")) { String triggerHost = currentState.getTriggerHost(partition); Assert.assertEquals(triggerHost, _controllerName, state + " of " + partition + " on " + instance.getInstanceName() + " was triggered by " + triggerHost); } } } } }
cache.getCurrentState(instanceName, liveInstances.get(instanceName).getSessionId()) .get(resourceName); if (currentState.getState(partition.getPartitionName()).equalsIgnoreCase(topState)) { if (currentState.getEndTime(partition.getPartitionName()) <= handOffEndTime) { handOffEndTime = currentState.getEndTime(partition.getPartitionName());
@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(); }
@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(); }
private void verifyP2PEnabled(long startTime) { ClusterDataCache dataCache = new ClusterDataCache(CLUSTER_NAME); dataCache.refresh(_accessor); Map<String, LiveInstance> liveInstanceMap = dataCache.getLiveInstances(); for (LiveInstance instance : liveInstanceMap.values()) { Map<String, CurrentState> currentStateMap = dataCache.getCurrentState(instance.getInstanceName(), instance.getSessionId()); Assert.assertNotNull(currentStateMap); for (CurrentState currentState : currentStateMap.values()) { for (String partition : currentState.getPartitionStateMap().keySet()) { String state = currentState.getState(partition); long start = currentState.getStartTime(partition); if (state.equalsIgnoreCase("MASTER") && start > startTime) { String triggerHost = currentState.getTriggerHost(partition); if (!triggerHost.equals(_controllerName)) { p2pTrigged ++; } total ++; } } } } }
: _currentStateDelta.getState(partitionName);
: _currentStateDelta.getState(partitionName);
accessor.getProperty(keyBuilder.currentState(instanceName, sessionId, resourceName)); for (String partitionName : resetPartitionNames) { if (!curState.getState(partitionName).equals(HelixDefinedState.ERROR.toString())) { throw new HelixException( "Can't reset state for " + resourceName + "/" + partitionNames + " on " + instanceName
accessor.getProperty(keyBuilder.currentState(instanceName, sessionId, resourceName)); for (String partitionName : resetPartitionNames) { if (!curState.getState(partitionName).equals(HelixDefinedState.ERROR.toString())) { throw new HelixException( "Can't reset state for " + resourceName + "/" + partitionNames + " on " + instanceName
if (currentStateMap.containsKey(resource)) { CurrentState currentState = currentStateMap.get(resource); state = currentState.getState(partition);