org.apache.helix.PropertyType Java Examples
The following examples show how to use
org.apache.helix.PropertyType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestInstanceValidationUtil.java From helix with Apache License 2.0 | 6 votes |
@Test public void TestIsInstanceStable_true() { String resource = "db"; Mock mock = new Mock(); ClusterConfig clusterConfig = new ClusterConfig(TEST_CLUSTER); clusterConfig.setPersistIntermediateAssignment(true); doReturn(clusterConfig).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.CONFIGS))); doReturn(ImmutableList.of(resource)).when(mock.dataAccessor) .getChildNames(argThat(new PropertyKeyArgument(PropertyType.IDEALSTATES))); IdealState idealState = mock(IdealState.class); when(idealState.isEnabled()).thenReturn(Boolean.TRUE); when(idealState.getPartitionSet()).thenReturn(ImmutableSet.of("db0")); when(idealState.getInstanceStateMap("db0")) .thenReturn(ImmutableMap.of(TEST_INSTANCE, "Master")); idealState.setInstanceStateMap("db0", ImmutableMap.of(TEST_INSTANCE, "Master")); doReturn(idealState).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.IDEALSTATES))); ExternalView externalView = new ExternalView(resource); externalView.setStateMap("db0", ImmutableMap.of(TEST_INSTANCE, "Master")); doReturn(externalView).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.EXTERNALVIEW))); boolean result = InstanceValidationUtil.isInstanceStable(mock.dataAccessor, TEST_INSTANCE); Assert.assertTrue(result); }
Example #2
Source File: TestInstanceValidationUtil.java From helix with Apache License 2.0 | 6 votes |
@Test public void TestHasResourceAssigned_success() { String sessionId = "sessionId"; String resource = "db"; Mock mock = new Mock(); LiveInstance liveInstance = new LiveInstance(TEST_INSTANCE); liveInstance.setSessionId(sessionId); doReturn(liveInstance).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.LIVEINSTANCES))); doReturn(ImmutableList.of(resource)).when(mock.dataAccessor) .getChildNames(argThat(new PropertyKeyArgument(PropertyType.CURRENTSTATES))); CurrentState currentState = mock(CurrentState.class); when(currentState.getPartitionStateMap()).thenReturn(ImmutableMap.of("db0", "master")); doReturn(currentState).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.CURRENTSTATES))); Assert.assertTrue( InstanceValidationUtil.hasResourceAssigned(mock.dataAccessor, TEST_CLUSTER, TEST_INSTANCE)); }
Example #3
Source File: ValidateConfigCommand.java From incubator-pinot with Apache License 2.0 | 6 votes |
@Override public boolean execute() throws Exception { if (!_validateTableConfig && !_validateSchema) { throw new RuntimeException("Need to specify at least one of -schema and -tableConfig"); } LOGGER.info("Connecting to Zookeeper: {}, cluster: ", _zkAddress, _clusterName); ZNRecordSerializer serializer = new ZNRecordSerializer(); String path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, _clusterName); _helixPropertyStore = new ZkHelixPropertyStore<>(_zkAddress, serializer, path); LOGGER.info("\n\n-------------------- Starting Validation --------------------"); if (_validateTableConfig) { validateTableConfig(); } if (_validateSchema) { validateSchema(); } return true; }
Example #4
Source File: TestInstanceValidationUtil.java From helix with Apache License 2.0 | 6 votes |
@Test public void TestHasErrorPartitions_false() { String sessionId = "sessionId"; String resource = "db"; Mock mock = new Mock(); LiveInstance liveInstance = new LiveInstance(TEST_INSTANCE); liveInstance.setSessionId(sessionId); doReturn(liveInstance).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.LIVEINSTANCES))); doReturn(ImmutableList.of(resource)).when(mock.dataAccessor) .getChildNames(argThat(new PropertyKeyArgument(PropertyType.CURRENTSTATES))); CurrentState currentState = mock(CurrentState.class); when(currentState.getPartitionStateMap()).thenReturn(ImmutableMap.of("db0", "Master")); doReturn(currentState).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.CURRENTSTATES))); Assert.assertFalse( InstanceValidationUtil.hasErrorPartitions(mock.dataAccessor, TEST_CLUSTER, TEST_INSTANCE)); }
Example #5
Source File: TestRoutingTableProvider.java From helix with Apache License 2.0 | 6 votes |
@Test(dependsOnMethods = "testCustomizedViewWithoutType") public void testCustomizedViewCorrectConstructor() throws Exception { Map<PropertyType, List<String>> sourceDataTypes = new HashMap<>(); sourceDataTypes.put(PropertyType.CUSTOMIZEDVIEW, Arrays.asList("typeA")); MockRoutingTableProvider routingTableProvider = new MockRoutingTableProvider(_spectator, sourceDataTypes); CustomizedView customizedView = new CustomizedView(TEST_DB); customizedView.setState("p1", "h1", "testState"); // Clear the flag before writing to the Customized View Path customizedViewChangeCalled.getAndSet(false); String customizedViewPath = PropertyPathBuilder.customizedView(CLUSTER_NAME, "typeA", TEST_DB); _spectator.getHelixDataAccessor().getBaseDataAccessor().set(customizedViewPath, customizedView.getRecord(), AccessOption.PERSISTENT); boolean onCustomizedViewChangeCalled = TestHelper.verify(() -> customizedViewChangeCalled.get(), WAIT_DURATION); Assert.assertTrue(onCustomizedViewChangeCalled); _spectator.getHelixDataAccessor().getBaseDataAccessor().remove(customizedViewPath, AccessOption.PERSISTENT); routingTableProvider.shutdown(); }
Example #6
Source File: StatusUpdatesResource.java From helix with Apache License 2.0 | 6 votes |
StringRepresentation getInstanceErrorsRepresentation(String clusterName, String instanceName) throws JsonGenerationException, JsonMappingException, IOException { ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT); String instanceSessionId = ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName); String message = ClusterRepresentationUtil .getInstancePropertyNameListAsString(zkClient, clusterName, instanceName, PropertyType.CURRENTSTATES, instanceSessionId, MediaType.APPLICATION_JSON); StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON); return representation; }
Example #7
Source File: TestInstanceValidationUtil.java From helix with Apache License 2.0 | 6 votes |
@Test public void TestSiblingNodesActiveReplicaCheck_whenNoMinActiveReplica() { String resource = "resource"; Mock mock = new Mock(); doReturn(ImmutableList.of(resource)).when(mock.dataAccessor) .getChildNames(argThat(new PropertyKeyArgument(PropertyType.IDEALSTATES))); // set ideal state IdealState idealState = mock(IdealState.class); when(idealState.isEnabled()).thenReturn(true); when(idealState.isValid()).thenReturn(true); when(idealState.getStateModelDefRef()).thenReturn("MasterSlave"); doReturn(idealState).when(mock.dataAccessor).getProperty(argThat(new PropertyKeyArgument(PropertyType.IDEALSTATES))); //set externalView ExternalView externalView = mock(ExternalView.class); // the resource sibling check will be skipped by design when(externalView.getMinActiveReplicas()).thenReturn(-1); doReturn(externalView).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.EXTERNALVIEW))); boolean result = InstanceValidationUtil.siblingNodesActiveReplicaCheck(mock.dataAccessor, TEST_INSTANCE); Assert.assertTrue(result); }
Example #8
Source File: TestRoutingTableProviderMonitor.java From helix with Apache License 2.0 | 6 votes |
public void testCurrentStateMetrics() throws JMException, InterruptedException { PropertyType type = PropertyType.CURRENTSTATES; RoutingTableProviderMonitor monitor = new RoutingTableProviderMonitor(type, TEST_CLUSTER); monitor.register(); ObjectName name = buildObjectName(type, TEST_CLUSTER); monitor.increaseCallbackCounters(10); Assert.assertEquals((long) _beanServer.getAttribute(name, "StatePropagationLatencyGauge.Max"), 0); monitor.recordStatePropagationLatency(5); long statelatency = (long) _beanServer.getAttribute(name, "StatePropagationLatencyGauge.Max"); Assert.assertEquals(statelatency, 5); monitor.recordStatePropagationLatency(10); statelatency = (long) _beanServer.getAttribute(name, "StatePropagationLatencyGauge.Max"); Assert.assertEquals(statelatency, 10); monitor.unregister(); }
Example #9
Source File: RoutingTableProvider.java From helix with Apache License 2.0 | 6 votes |
/** * Check and validate the input of the sourceDataTypeMap parameter * @param sourceDataTypeMap */ private void validateSourceDataTypeMap(Map<PropertyType, List<String>> sourceDataTypeMap) { for (PropertyType propertyType : sourceDataTypeMap.keySet()) { if (propertyType.equals(PropertyType.CUSTOMIZEDVIEW) && sourceDataTypeMap.get(propertyType).size() == 0) { logger.error("CustomizedView has been used without any aggregation type!"); throw new HelixException("CustomizedView has been used without any aggregation type!"); } if (!propertyType.equals(PropertyType.CUSTOMIZEDVIEW) && sourceDataTypeMap.get(propertyType).size() != 0) { logger.error("Type has been used in addition to the propertyType {} !", propertyType.name()); throw new HelixException( String.format("Type %s has been used in addition to the propertyType %s !", sourceDataTypeMap.get(propertyType), propertyType.name())); } } }
Example #10
Source File: ErrorsResource.java From helix with Apache License 2.0 | 6 votes |
StringRepresentation getInstanceErrorsRepresentation(String clusterName, String instanceName) throws JsonGenerationException, JsonMappingException, IOException { ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT); ; String instanceSessionId = ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName); String message = ClusterRepresentationUtil .getInstancePropertyNameListAsString(zkClient, clusterName, instanceName, PropertyType.CURRENTSTATES, instanceSessionId, MediaType.APPLICATION_JSON); StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON); return representation; }
Example #11
Source File: DistributedLeaderElection.java From helix with Apache License 2.0 | 6 votes |
private void updateHistory(HelixManager manager) { HelixDataAccessor accessor = manager.getHelixDataAccessor(); Builder keyBuilder = accessor.keyBuilder(); final String clusterName = manager.getClusterName(); final String instanceName = manager.getInstanceName(); final String version = manager.getVersion(); // Record a MaintenanceSignal history if (!accessor.getBaseDataAccessor().update(keyBuilder.controllerLeaderHistory().getPath(), oldRecord -> { if (oldRecord == null) { oldRecord = new ZNRecord(PropertyType.HISTORY.toString()); } return new ControllerHistory(oldRecord).updateHistory(clusterName, instanceName, version); }, AccessOption.PERSISTENT)) { LOG.error("Failed to persist leader history to ZK!"); } }
Example #12
Source File: RoutingTableProvider.java From helix with Apache License 2.0 | 6 votes |
@Override @PreFetch(enabled = false) public void onCustomizedViewRootChange(List<String> customizedViewTypes, NotificationContext changeContext) { logger.info( "Registering the CustomizedView listeners again due to the CustomizedView root change."); List<String> userRequestedTypes = _sourceDataTypeMap.getOrDefault(PropertyType.CUSTOMIZEDVIEW, Collections.emptyList()); for (String customizedStateType : userRequestedTypes) { try { _helixManager.addCustomizedViewChangeListener(this, customizedStateType); } catch (Exception e) { shutdown(); throw new HelixException( String.format("Failed to attach CustomizedView Listener to HelixManager for type %s!", customizedStateType), e); } } }
Example #13
Source File: TestInstanceValidationUtil.java From helix with Apache License 2.0 | 6 votes |
@Test public void TestHasErrorPartitions_true() { String sessionId = "sessionId"; String resource = "db"; Mock mock = new Mock(); LiveInstance liveInstance = new LiveInstance(TEST_INSTANCE); liveInstance.setSessionId(sessionId); doReturn(liveInstance).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.LIVEINSTANCES))); doReturn(ImmutableList.of(resource)).when(mock.dataAccessor) .getChildNames(argThat(new PropertyKeyArgument(PropertyType.CURRENTSTATES))); CurrentState currentState = mock(CurrentState.class); when(currentState.getPartitionStateMap()).thenReturn(ImmutableMap.of("db0", "ERROR")); doReturn(currentState).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.CURRENTSTATES))); Assert.assertTrue( InstanceValidationUtil.hasErrorPartitions(mock.dataAccessor, TEST_CLUSTER, TEST_INSTANCE)); }
Example #14
Source File: TestInstanceValidationUtil.java From helix with Apache License 2.0 | 6 votes |
@Test(expectedExceptions = HelixException.class) public void TestSiblingNodesActiveReplicaCheck_exception_whenExternalViewUnavailable() { String resource = "resource"; Mock mock = new Mock(); doReturn(ImmutableList.of(resource)).when(mock.dataAccessor) .getChildNames(argThat(new PropertyKeyArgument(PropertyType.IDEALSTATES))); // set ideal state IdealState idealState = mock(IdealState.class); when(idealState.isEnabled()).thenReturn(true); when(idealState.isValid()).thenReturn(true); when(idealState.getStateModelDefRef()).thenReturn("MasterSlave"); doReturn(idealState).when(mock.dataAccessor).getProperty(argThat(new PropertyKeyArgument(PropertyType.IDEALSTATES))); doReturn(null).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.EXTERNALVIEW))); InstanceValidationUtil.siblingNodesActiveReplicaCheck(mock.dataAccessor, TEST_INSTANCE); }
Example #15
Source File: TestRoutingDataCache.java From helix with Apache License 2.0 | 6 votes |
@Test() public void testUpdateOnNotification() throws Exception { MockZkHelixDataAccessor accessor = new MockZkHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor<ZNRecord>(_gZkClient)); RoutingDataCache cache = new RoutingDataCache("CLUSTER_" + TestHelper.getTestClassName(), PropertyType.EXTERNALVIEW); cache.refresh(accessor); Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW), 1); accessor.clearReadCounters(); // refresh again should read nothing cache.refresh(accessor); Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW), 0); accessor.clearReadCounters(); // refresh again should read nothing as ideal state is same cache.notifyDataChange(HelixConstants.ChangeType.EXTERNAL_VIEW); cache.refresh(accessor); Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW), 0); }
Example #16
Source File: ZKHelixDataAccessor.java From helix with Apache License 2.0 | 6 votes |
@Override public HelixProperty.Stat getPropertyStat(PropertyKey key) { PropertyType type = key.getType(); String path = key.getPath(); int options = constructOptions(type); try { Stat stat = _baseDataAccessor.getStat(path, options); if (stat != null) { return new HelixProperty.Stat(stat.getVersion(), stat.getCtime(), stat.getMtime(), stat.getEphemeralOwner()); } } catch (ZkNoNodeException e) { } return null; }
Example #17
Source File: RoutingTableProviderMonitor.java From helix with Apache License 2.0 | 6 votes |
public RoutingTableProviderMonitor(final PropertyType propertyType, String clusterName) { _propertyType = propertyType; _clusterName = clusterName == null ? DEFAULT : clusterName; // Don't put instanceName into sensor name. This detail information is in the MBean name already. _sensorName = String .format("%s.%s.%s", MonitorDomainNames.RoutingTableProvider.name(), _clusterName, _propertyType.name()); _dataRefreshLatencyGauge = new HistogramDynamicMetric("DataRefreshLatencyGauge", new Histogram( new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _callbackCounter = new SimpleDynamicMetric("CallbackCounter", 0l); _eventQueueSizeGauge = new SimpleDynamicMetric("EventQueueSizeGauge", 0l); _dataRefreshCounter = new SimpleDynamicMetric("DataRefreshCounter", 0l); if (propertyType.equals(PropertyType.CURRENTSTATES)) { _statePropLatencyGauge = new HistogramDynamicMetric("StatePropagationLatencyGauge", new Histogram( new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); } }
Example #18
Source File: TestInstanceValidationUtil.java From helix with Apache License 2.0 | 5 votes |
@Test(expectedExceptions = HelixException.class) public void TestIsInstanceEnabled_whenClusterConfigNull() { Mock mock = new Mock(); doReturn(new InstanceConfig(TEST_INSTANCE)).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.CONFIGS))); doReturn(null).when(mock.dataAccessor) .getProperty(BUILDER.clusterConfig()); InstanceValidationUtil.isEnabled(mock.dataAccessor, TEST_INSTANCE); }
Example #19
Source File: TestInstanceValidationUtil.java From helix with Apache License 2.0 | 5 votes |
@Test(expectedExceptions = HelixException.class) public void TestIsInstanceEnabled_whenInstanceConfigNull() { Mock mock = new Mock(); doReturn(null).when(mock.dataAccessor) .getProperty(argThat(new PropertyKeyArgument(PropertyType.CONFIGS))); InstanceValidationUtil.isEnabled(mock.dataAccessor, TEST_INSTANCE); }
Example #20
Source File: MoveReplicaGroup.java From incubator-pinot with Apache License 2.0 | 5 votes |
private TableConfig getTableConfig(String tableName) throws IOException { ZNRecordSerializer serializer = new ZNRecordSerializer(); String path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, zkPath); ZkHelixPropertyStore<ZNRecord> propertyStore = new ZkHelixPropertyStore<>(zkHost, serializer, path); ZNRecord tcZnRecord = propertyStore.get("/CONFIGS/TABLE/" + tableName, null, 0); TableConfig tableConfig = TableConfigUtils.fromZNRecord(tcZnRecord); LOGGER.debug("Loaded table config"); return tableConfig; }
Example #21
Source File: MockZkHelixDataAccessor.java From helix with Apache License 2.0 | 5 votes |
public int getReadCount(PropertyType type) { if (_readPathCounters.containsKey(type)) { return _readPathCounters.get(type); } return 0; }
Example #22
Source File: TestRoutingTableProviderFromCurrentStates.java From helix with Apache License 2.0 | 5 votes |
private void validatePropagationLatency(PropertyType type, final long upperBound) throws Exception { final ObjectName name = buildObjectName(type); Assert.assertTrue(TestHelper.verify(() -> { long stateLatency = (long) _beanServer.getAttribute(name, "StatePropagationLatencyGauge.Max"); return stateLatency > 0 && stateLatency <= upperBound; }, 1000)); }
Example #23
Source File: ZKHelixDataAccessor.java From helix with Apache License 2.0 | 5 votes |
@Override public <T extends HelixProperty> Map<String, T> getChildValuesMap(PropertyKey key, boolean throwException) { PropertyType type = key.getType(); String parentPath = key.getPath(); int options = constructOptions(type); List<T> children = getChildValues(key, throwException); Map<String, T> childValuesMap = new HashMap<String, T>(); for (T t : children) { childValuesMap.put(t.getRecord().getId(), t); } return childValuesMap; }
Example #24
Source File: TestRoutingTableProviderMonitor.java From helix with Apache License 2.0 | 5 votes |
private ObjectName buildObjectName(PropertyType type, String cluster, int num) throws MalformedObjectNameException { ObjectName objectName = buildObjectName(type, cluster); if (num > 0) { return new ObjectName(String .format("%s,%s=%s", objectName.toString(), MBeanRegistrar.DUPLICATE, String.valueOf(num))); } else { return objectName; } }
Example #25
Source File: ZKHelixDataAccessor.java From helix with Apache License 2.0 | 5 votes |
@Override public List<String> getChildNames(PropertyKey key) { PropertyType type = key.getType(); String parentPath = key.getPath(); int options = constructOptions(type); List<String> childNames = _baseDataAccessor.getChildNames(parentPath, options); if (childNames == null) { childNames = Collections.emptyList(); } return childNames; }
Example #26
Source File: HelixUtils.java From uReplicator with Apache License 2.0 | 5 votes |
public static ZkHelixPropertyStore<ZNRecord> getZkPropertyStore(HelixManager helixManager, String clusterName) { ZkBaseDataAccessor<ZNRecord> baseAccessor = (ZkBaseDataAccessor<ZNRecord>) helixManager.getHelixDataAccessor().getBaseDataAccessor(); String propertyStorePath = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, clusterName); ZkHelixPropertyStore<ZNRecord> propertyStore = new ZkHelixPropertyStore<ZNRecord>(baseAccessor, propertyStorePath, Arrays.asList(propertyStorePath)); return propertyStore; }
Example #27
Source File: TestRoutingTableProviderMonitor.java From helix with Apache License 2.0 | 5 votes |
@Test public void testMetrics() throws JMException, InterruptedException { PropertyType type = PropertyType.EXTERNALVIEW; RoutingTableProviderMonitor monitor = new RoutingTableProviderMonitor(type, TEST_CLUSTER); monitor.register(); ObjectName name = buildObjectName(type, TEST_CLUSTER); monitor.increaseCallbackCounters(10); Assert.assertEquals((long) _beanServer.getAttribute(name, "CallbackCounter"), 1); Assert.assertEquals((long) _beanServer.getAttribute(name, "EventQueueSizeGauge"), 10); monitor.increaseCallbackCounters(15); Assert.assertEquals((long) _beanServer.getAttribute(name, "CallbackCounter"), 2); Assert.assertEquals((long) _beanServer.getAttribute(name, "EventQueueSizeGauge"), 15); Assert.assertEquals((long) _beanServer.getAttribute(name, "DataRefreshLatencyGauge.Max"), 0); Assert.assertEquals((long) _beanServer.getAttribute(name, "DataRefreshCounter"), 0); // StatePropagationLatencyGauge only apply for current state try { _beanServer.getAttribute(name, "StatePropagationLatencyGauge.Max"); Assert.fail(); } catch (AttributeNotFoundException ex) { // Expected AttributeNotFoundException because the metric does not exist in // MBean server. } long startTime = System.currentTimeMillis(); Thread.sleep(5); monitor.increaseDataRefreshCounters(startTime); long latency = (long) _beanServer.getAttribute(name, "DataRefreshLatencyGauge.Max"); Assert.assertTrue(latency >= 5 && latency <= System.currentTimeMillis() - startTime); Assert.assertEquals((long) _beanServer.getAttribute(name, "DataRefreshCounter"), 1); monitor.increaseDataRefreshCounters(startTime); long newLatency = (long) _beanServer.getAttribute(name, "DataRefreshLatencyGauge.Max"); Assert.assertTrue(newLatency >= latency); Assert.assertEquals((long) _beanServer.getAttribute(name, "DataRefreshCounter"), 2); monitor.unregister(); }
Example #28
Source File: ZKHelixDataAccessor.java From helix with Apache License 2.0 | 5 votes |
@Override public boolean removeProperty(PropertyKey key) { PropertyType type = key.getType(); String path = key.getPath(); int options = constructOptions(type); return _baseDataAccessor.remove(path, options); }
Example #29
Source File: ZKHelixAdmin.java From helix with Apache License 2.0 | 5 votes |
@Override public boolean setInstanceConfig(String clusterName, String instanceName, InstanceConfig newInstanceConfig) { logger.info("Set instance config for instance {} to cluster {} with new InstanceConfig {}.", instanceName, clusterName, newInstanceConfig == null ? "NULL" : newInstanceConfig.toString()); String instanceConfigPath = PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName, HelixConfigScope.ConfigScopeProperty.PARTICIPANT.toString(), instanceName); if (!_zkClient.exists(instanceConfigPath)) { throw new HelixException( "instance" + instanceName + " does not exist in cluster " + clusterName); } HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient)); PropertyKey instanceConfigPropertyKey = accessor.keyBuilder().instanceConfig(instanceName); InstanceConfig currentInstanceConfig = accessor.getProperty(instanceConfigPropertyKey); if (!newInstanceConfig.getHostName().equals(currentInstanceConfig.getHostName()) || !newInstanceConfig.getPort().equals(currentInstanceConfig.getPort())) { throw new HelixException( "Hostname and port cannot be changed, current hostname: " + currentInstanceConfig .getHostName() + " and port: " + currentInstanceConfig.getPort() + " is different from new hostname: " + newInstanceConfig.getHostName() + "and new port: " + newInstanceConfig.getPort()); } return accessor.setProperty(instanceConfigPropertyKey, newInstanceConfig); }
Example #30
Source File: TestDefaultMessagingService.java From helix with Apache License 2.0 | 5 votes |
@Override public <T extends HelixProperty> T getProperty(PropertyKey key) { PropertyType type = key.getType(); if (type == PropertyType.EXTERNALVIEW || type == PropertyType.IDEALSTATES) { return (T) new ExternalView(_externalView); } return null; }