idealState.setPartitionState(segmentName, instance, "OFFLINE"); updateSuccessful = helixDataAccessor.updateProperty(idealStatePropertyKey, idealState); } while (!updateSuccessful); LOGGER.info("Setting Ideal State for segment '{}' to ONLINE for instance '{}'", segmentName, instance); updateSuccessful = helixDataAccessor.updateProperty(idealStatePropertyKey, idealState); } while (!updateSuccessful);
updateSuccessful = helixDataAccessor.updateProperty(idealStatePropertyKey, idealState); } while (!updateSuccessful && (System.currentTimeMillis() <= deadline));
/** * Trigger the controller to perform rebalance for a given resource. * @param accessor Helix data accessor * @param resource the name of the resource changed to triggering the execution */ public static void invokeRebalance(HelixDataAccessor accessor, String resource) { LOG.info("invoke rebalance for " + resource); PropertyKey key = accessor.keyBuilder().idealStates(resource); IdealState is = accessor.getProperty(key); if (is != null) { if (!accessor.updateProperty(key, is)) { LOG.warn("Failed to invoke rebalance on resource {}", resource); } } else { LOG.warn("Can't find ideal state for {}", resource); } }
/** * Trigger the controller to perform rebalance for a given resource. * @param accessor Helix data accessor * @param resource the name of the resource changed to triggering the execution */ public static void invokeRebalanceForResourceConfig(HelixDataAccessor accessor, String resource) { LOG.info("invoke rebalance for " + resource); PropertyKey key = accessor.keyBuilder().resourceConfig(resource); ResourceConfig cfg = accessor.getProperty(key); if (cfg != null) { if (!accessor.updateProperty(key, cfg)) { LOG.warn("Failed to invoke rebalance on resource config {}", resource); } } else { LOG.warn("Can't find resource config for {}", resource); } } }
/** * Trigger the controller to perform rebalance for a given resource. * @param accessor Helix data accessor * @param resource the name of the resource changed to triggering the execution */ public static void invokeRebalance(HelixDataAccessor accessor, String resource) { LOG.info("invoke rebalance for " + resource); PropertyKey key = accessor.keyBuilder().idealStates(resource); IdealState is = accessor.getProperty(key); if (is != null) { if (!accessor.updateProperty(key, is)) { LOG.warn("Failed to invoke rebalance on resource {}", resource); } } else { LOG.warn("Can't find ideal state for {}", resource); } } }
/** * Request a state change for a specific task. * * @param accessor connected Helix data accessor * @param instance the instance serving the task * @param sessionId the current session of the instance * @param resource the job name * @param partition the task partition name * @param state the requested state * @return true if the request was persisted, false otherwise */ private static boolean setRequestedState(HelixDataAccessor accessor, String instance, String sessionId, String resource, String partition, TaskPartitionState state) { LOG.debug( String.format("Requesting a state transition to %s for partition %s.", state, partition)); try { PropertyKey.Builder keyBuilder = accessor.keyBuilder(); PropertyKey key = keyBuilder.currentState(instance, sessionId, resource); CurrentState currStateDelta = new CurrentState(resource); currStateDelta.setRequestedState(partition, state.name()); return accessor.updateProperty(key, currStateDelta); } catch (Exception e) { LOG.error(String .format("Error when requesting a state transition to %s for partition %s.", state, partition), e); return false; } } }
/** * Request a state change for a specific task. * * @param accessor connected Helix data accessor * @param instance the instance serving the task * @param sessionId the current session of the instance * @param resource the job name * @param partition the task partition name * @param state the requested state * @return true if the request was persisted, false otherwise */ private static boolean setRequestedState(HelixDataAccessor accessor, String instance, String sessionId, String resource, String partition, TaskPartitionState state) { LOG.debug( String.format("Requesting a state transition to %s for partition %s.", state, partition)); try { PropertyKey.Builder keyBuilder = accessor.keyBuilder(); PropertyKey key = keyBuilder.currentState(instance, sessionId, resource); CurrentState currStateDelta = new CurrentState(resource); currStateDelta.setRequestedState(partition, state.name()); return accessor.updateProperty(key, currStateDelta); } catch (Exception e) { LOG.error(String .format("Error when requesting a state transition to %s for partition %s.", state, partition), e); return false; } } }
public void postHandleMessage() { if (_message.getBatchMessageMode() == true && _batchMsgWrapper != null) { _batchMsgWrapper.end(_message, _notificationContext); } // update currentState HelixManager manager = _notificationContext.getManager(); HelixDataAccessor accessor = manager.getHelixDataAccessor(); ConcurrentHashMap<String, CurrentStateUpdate> csUpdateMap = (ConcurrentHashMap<String, CurrentStateUpdate>) _notificationContext .get(MapKey.CURRENT_STATE_UPDATE.toString()); if (csUpdateMap != null) { Map<PropertyKey, CurrentState> csUpdate = mergeCurStateUpdate(csUpdateMap); // TODO: change to use asyncSet for (PropertyKey key : csUpdate.keySet()) { // logger.info("updateCS: " + key); // System.out.println("\tupdateCS: " + key.getPath() + ", " + // curStateMap.get(key)); if(!accessor.updateProperty(key, csUpdate.get(key))) { LOG.error( "Fails to persist current state to ZK for key " + key); } } } }
public void postHandleMessage() { if (_message.getBatchMessageMode() == true && _batchMsgWrapper != null) { _batchMsgWrapper.end(_message, _notificationContext); } // update currentState HelixManager manager = _notificationContext.getManager(); HelixDataAccessor accessor = manager.getHelixDataAccessor(); ConcurrentHashMap<String, CurrentStateUpdate> csUpdateMap = (ConcurrentHashMap<String, CurrentStateUpdate>) _notificationContext .get(MapKey.CURRENT_STATE_UPDATE.toString()); if (csUpdateMap != null) { Map<PropertyKey, CurrentState> csUpdate = mergeCurStateUpdate(csUpdateMap); // TODO: change to use asyncSet for (PropertyKey key : csUpdate.keySet()) { // logger.info("updateCS: " + key); // System.out.println("\tupdateCS: " + key.getPath() + ", " + // curStateMap.get(key)); if(!accessor.updateProperty(key, csUpdate.get(key))) { LOG.error( "Fails to persist current state to ZK for key " + key); } } } }
if (isController) { accessor .updateProperty(keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey), new StatusUpdate(createMessageLogRecord(message))); + statusUpdateRecord); accessor.updateProperty(propertyKey, new StatusUpdate(statusUpdateRecord)); accessor.updateProperty( keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey), new StatusUpdate( record)); _logger.trace("StatusUpdate path:" + propertyKey.getPath() + ", updates:" + record); accessor.updateProperty(propertyKey, new StatusUpdate(record));
if (isController) { accessor .updateProperty(keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey), new StatusUpdate(createMessageLogRecord(message))); + statusUpdateRecord); accessor.updateProperty(propertyKey, new StatusUpdate(statusUpdateRecord)); accessor.updateProperty( keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey), new StatusUpdate( record)); _logger.trace("StatusUpdate path:" + propertyKey.getPath() + ", updates:" + record); accessor.updateProperty(propertyKey, new StatusUpdate(record));
/** * Write an error record to zookeeper to the zookeeper store. * @param record * the status update record * @param instanceName * the instance name * @param updateSubPath * the error update sub path * @param updateKey * the error update key * @param sessionId * the session id * @param accessor * the zookeeper data accessor that writes the status update to zookeeper * @param isController * if the error log is for a controller instance or not */ void publishErrorRecord(ZNRecord record, String instanceName, String updateSubPath, String updateKey, String sessionId, HelixDataAccessor accessor, boolean isController) { Builder keyBuilder = accessor.keyBuilder(); if (isController) { // TODO need to fix: ERRORS_CONTROLLER doesn't have a form of // ../{sessionId}/{subPath} accessor.setProperty(keyBuilder.controllerTaskError(updateSubPath), new Error(record)); } else { accessor.updateProperty(keyBuilder.stateTransitionError(instanceName, sessionId, updateSubPath, updateKey), new Error(record)); } } }
/** * Write an error record to zookeeper to the zookeeper store. * @param record * the status update record * @param instanceName * the instance name * @param updateSubPath * the error update sub path * @param updateKey * the error update key * @param sessionId * the session id * @param accessor * the zookeeper data accessor that writes the status update to zookeeper * @param isController * if the error log is for a controller instance or not */ void publishErrorRecord(ZNRecord record, String instanceName, String updateSubPath, String updateKey, String sessionId, HelixDataAccessor accessor, boolean isController) { Builder keyBuilder = accessor.keyBuilder(); if (isController) { // TODO need to fix: ERRORS_CONTROLLER doesn't have a form of // ../{sessionId}/{subPath} accessor.setProperty(keyBuilder.controllerTaskError(updateSubPath), new Error(record)); } else { accessor.updateProperty(keyBuilder.stateTransitionError(instanceName, sessionId, updateSubPath, updateKey), new Error(record)); } } }
if (!accessor.updateProperty( keyBuilder.currentState(instanceName, _message.getTgtSessionId(), resourceName), currentStateDelta)) {
if (!accessor.updateProperty( keyBuilder.currentState(instanceName, _message.getTgtSessionId(), resourceName), currentStateDelta)) {
map.put("k1", "v1"); instance.getRecord().setMapField("test", map); Assert.assertTrue(helixDataAccessor.updateProperty(propertyKey, instance), "Failed to update live instance node");
_manager.getHelixDataAccessor().updateProperty( accessor.keyBuilder().idealStates(newAddedScheduledTasks.getId()), newAddedScheduledTasks); accessor.updateProperty(keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.name(), _message.getMsgId()), new StatusUpdate(statusUpdate));
_manager.getHelixDataAccessor().updateProperty( accessor.keyBuilder().idealStates(newAddedScheduledTasks.getId()), newAddedScheduledTasks); accessor.updateProperty(keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.name(), _message.getMsgId()), new StatusUpdate(statusUpdate));
accessor.updateProperty(keyBuilder.idealStates(resourceId), new DataUpdater<ZNRecord>() { @Override public ZNRecord update(ZNRecord current) {
accessor.updateProperty(keyBuilder.idealStates(resourceId), new DataUpdater<ZNRecord>() { @Override public ZNRecord update(ZNRecord current) {