ControllerLeaderLocator(HelixManager helixManager) { _helixManager = helixManager; _clusterName = helixManager.getClusterName(); }
public ReplicaGroupRebalanceSegmentStrategy(HelixManager helixManager) { _helixManager = helixManager; _helixAdmin = helixManager.getClusterManagmentTool(); _helixClusterName = helixManager.getClusterName(); _propertyStore = helixManager.getHelixPropertyStore(); }
public DefaultRebalanceSegmentStrategy(HelixManager helixManager) { _helixManager = helixManager; _helixAdmin = helixManager.getClusterManagmentTool(); _helixClusterName = helixManager.getClusterName(); _propertyStore = helixManager.getHelixPropertyStore(); }
protected ExternalView fetchExternalView(String table) { return HelixHelper .getExternalViewForResource(_helixManager.getClusterManagmentTool(), _helixManager.getClusterName(), table); }
.getExternalViewForResource(_helixManager.getClusterManagmentTool(), _helixManager.getClusterName(), BROKER_RESOURCE_INSTANCE); if (currentBrokerResource == null) {
@Transition(from = "OFFLINE", to = "ONLINE") public void onBecomeOnlineFromOffline(Message message, NotificationContext context) { try { LOGGER.info("BrokerResourceOnlineOfflineStateModel.onBecomeOnlineFromOffline() : " + message); Builder keyBuilder = _helixManager.getHelixDataAccessor().keyBuilder(); String tableName = message.getPartitionName(); HelixDataAccessor helixDataAccessor = _helixManager.getHelixDataAccessor(); List<InstanceConfig> instanceConfigList = helixDataAccessor.getChildValues(keyBuilder.instanceConfigs()); TableConfig tableConfig = ZKMetadataProvider.getTableConfig(_propertyStore, tableName); _helixExternalViewBasedRouting.markDataResourceOnline(tableConfig, HelixHelper.getExternalViewForResource(_helixAdmin, _helixManager.getClusterName(), tableName), instanceConfigList); _tableQueryQuotaManager.initTableQueryQuota(tableConfig, HelixHelper .getExternalViewForResource(_helixAdmin, _helixManager.getClusterName(), BROKER_RESOURCE_INSTANCE)); } catch (Exception e) { LOGGER.error("Caught exception during OFFLINE -> ONLINE transition", e); Utils.rethrowException(e); throw new AssertionError("Should not reach this"); } }
@Test public void testControllerLeaderExists() { HelixManager helixManager = mock(HelixManager.class); HelixDataAccessor helixDataAccessor = mock(HelixDataAccessor.class); BaseDataAccessor<ZNRecord> baseDataAccessor = mock(BaseDataAccessor.class); ZNRecord znRecord = mock(ZNRecord.class); final String leaderHost = "host"; final int leaderPort = 12345; when(helixManager.getHelixDataAccessor()).thenReturn(helixDataAccessor); when(helixDataAccessor.getBaseDataAccessor()).thenReturn(baseDataAccessor); when(znRecord.getId()).thenReturn(leaderHost + "_" + leaderPort); when(baseDataAccessor.get(anyString(), (Stat) any(), anyInt())).thenReturn(znRecord); when(helixManager.getClusterName()).thenReturn("myCluster"); // Create Controller Leader Locator FakeControllerLeaderLocator.create(helixManager); ControllerLeaderLocator controllerLeaderLocator = FakeControllerLeaderLocator.getInstance(); Pair<String, Integer> expectedLeaderLocation = new Pair<>(leaderHost, leaderPort); Assert.assertEquals(controllerLeaderLocator.getControllerLeader().getFirst(), expectedLeaderLocation.getFirst()); Assert.assertEquals(controllerLeaderLocator.getControllerLeader().getSecond(), expectedLeaderLocation.getSecond()); }
when(znRecord.getId()).thenReturn(leaderHost + "_" + leaderPort); when(baseDataAccessor.get(anyString(), any(), anyInt())).thenReturn(znRecord); when(helixManager.getClusterName()).thenReturn("testCluster");
private static void assignIdealStates(HelixManager helixManager, Map<String, IdealState> idealStatesFromAssignment) { HelixAdmin helixAdmin = helixManager.getClusterManagmentTool(); String helixClusterName = helixManager.getClusterName(); for (String topic : idealStatesFromAssignment.keySet()) { IdealState idealState = idealStatesFromAssignment.get(topic); helixAdmin.setResourceIdealState(helixClusterName, topic, idealState); } }
public static Set<TopicPartition> getUnassignedPartitions(HelixManager helixManager) { Set<TopicPartition> unassignedPartitions = new HashSet<TopicPartition>(); HelixAdmin helixAdmin = helixManager.getClusterManagmentTool(); String helixClusterName = helixManager.getClusterName(); for (String topic : helixAdmin.getResourcesInCluster(helixClusterName)) { IdealState is = helixAdmin.getResourceIdealState(helixClusterName, topic); int numPartitions = is.getNumPartitions(); for (int partition = 0; partition < numPartitions; ++partition) { if (is.getInstanceSet(Integer.toString(partition)).isEmpty()) { TopicPartition tpi = new TopicPartition(topic, partition); unassignedPartitions.add(tpi); } } } return unassignedPartitions; }
/** * From IdealStates. * @param helixManager * @return InstanceToNumTopicPartitionMap */ public static Map<String, Set<TopicPartition>> getInstanceToTopicPartitionsMap( HelixManager helixManager) { Map<String, Set<TopicPartition>> instanceToNumTopicPartitionMap = new HashMap<String, Set<TopicPartition>>(); HelixAdmin helixAdmin = helixManager.getClusterManagmentTool(); String helixClusterName = helixManager.getClusterName(); for (String topic : helixAdmin.getResourcesInCluster(helixClusterName)) { IdealState is = helixAdmin.getResourceIdealState(helixClusterName, topic); for (String partition : is.getPartitionSet()) { TopicPartition tpi = new TopicPartition(topic, Integer.parseInt(partition)); for (String instance : is.getInstanceSet(partition)) { if (!instanceToNumTopicPartitionMap.containsKey(instance)) { instanceToNumTopicPartitionMap.put(instance, new HashSet<TopicPartition>()); } instanceToNumTopicPartitionMap.get(instance).add(tpi); } } } return instanceToNumTopicPartitionMap; }
public ZKPathDataDumpTask(HelixManager manager, long thresholdNoChangeMsForStatusUpdates, long thresholdNoChangeMsForErrors, int maxLeafCount) { LOG.info("Init ZKPathDataDumpTask for cluster: " + manager.getClusterName() + ", thresholdNoChangeMsForStatusUpdates: " + thresholdNoChangeMsForStatusUpdates + ", thresholdNoChangeMsForErrors: " + thresholdNoChangeMsForErrors + ", maxLeafCount: " + maxLeafCount); _manager = manager; _jsonSerializer = new ZNRecordSerializer(); _thresholdNoChangeMsForStatusUpdates = thresholdNoChangeMsForStatusUpdates; _thresholdNoChangeMsForErrors = thresholdNoChangeMsForErrors; _maxLeafCount = maxLeafCount; }
private void resetRoutingTableAndNotify(long startTime, RoutingTable newRoutingTable) { _routingTableRef.set(newRoutingTable); logger.info("Refresh the RoutingTable for cluster {}, takes {} ms.", (_helixManager != null ? _helixManager.getClusterName() : null), (System.currentTimeMillis() - startTime)); notifyRoutingTableChange(); // Update timestamp for last refresh if (_isPeriodicRefreshEnabled) { _lastRefreshTimestamp = System.currentTimeMillis(); } }
private void assignIdealStates(HelixManager helixManager, Map<String, IdealState> idealStatesFromAssignment) { HelixAdmin helixAdmin = helixManager.getClusterManagmentTool(); String helixClusterName = helixManager.getClusterName(); for (String topic : idealStatesFromAssignment.keySet()) { IdealState idealState = idealStatesFromAssignment.get(topic); helixAdmin.setResourceIdealState(helixClusterName, topic, idealState); } }
@Override public void run() { LOG.info("HelixControllerMainShutdownHook invoked on manager: " + _manager.getClusterName() + ", " + _manager.getInstanceName()); _manager.disconnect(); } }
@Override public void run() { LOG.info("HelixControllerMainShutdownHook invoked on manager: " + _manager.getClusterName() + ", " + _manager.getInstanceName()); _manager.disconnect(); } }
@Override public void onDisconnected(HelixManager helixManager, Throwable error) throws Exception { Assert.assertEquals(helixManager.getClusterName(), clusterName); onDisconnectedFlag.getAndSet(true); } });
void disablePartition() { String instanceName = _manager.getInstanceName(); String resourceName = _message.getResourceName(); String partitionName = _message.getPartitionName(); String clusterName = _manager.getClusterName(); HelixAdmin admin = _manager.getClusterManagmentTool(); admin.enablePartition(false, clusterName, instanceName, resourceName, Arrays.asList(partitionName)); logger.info("error in transit from ERROR to " + _message.getToState() + " for partition: " + partitionName + ". disable it on " + instanceName); }
private static void markForDeletion(HelixManager mgr, String resourceName) { mgr.getConfigAccessor().set( TaskUtil.getResourceConfigScope(mgr.getClusterName(), resourceName), WorkflowConfig.WorkflowConfigProperty.TargetState.name(), TargetState.DELETE.name()); }
public MockMessagingService(HelixManager manager) { super(manager); _manager = manager; boolean isParticipant = false; if (manager.getInstanceType() == InstanceType.PARTICIPANT || manager.getInstanceType() == InstanceType.CONTROLLER_PARTICIPANT) { isParticipant = true; } _taskExecutor = new MockHelixTaskExecutor( new ParticipantStatusMonitor(isParticipant, manager.getInstanceName()), new MessageQueueMonitor(manager.getClusterName(), manager.getInstanceName())); }