ConfigProperty.Builder config = ConfigProperty.newBuilder().setName(key.getName()) .setSource(alluxioConf.getSource(key).toString()); String val = alluxioConf.getOrDefault(key, null, ConfigurationValueOptions.defaults().useDisplayValue(true)); if (val != null) { config.setValue(val); confMap.put(key.getName(), config.build());
.setScope(Scope.MASTER).build(); ConfigProperty masterEnforceProp = ConfigProperty.newBuilder() .setName(keyMasterEnforce.getName()).setSource("Test").setValue("Value").build(); .setScope(Scope.WORKER).build(); ConfigProperty workerWarnProp = ConfigProperty.newBuilder() .setName(keyWorkerWarn.getName()).setSource("Test").setValue("Value").build(); .setScope(Scope.SERVER).build(); ConfigProperty serverEnforceProp = ConfigProperty.newBuilder() .setName(keyServerEnforce.getName()).setSource("Test").setValue("Value").build(); ConfigProperty.newBuilder().setName(workerWarnProp.getName()) .setSource(workerWarnProp.getSource()).setValue("WrongValue").build(); mRecordOne.registerNewConf(addressOne, Arrays.asList(masterEnforceProp, wrongWorkerWarnProp)); checkResults(0, 1, ConfigStatus.WARN); .setName(masterEnforceProp.getName()) .setSource(masterEnforceProp.getSource()).setValue("WrongValue").build(); mRecordTwo.registerNewConf(addressTwo, Arrays.asList(wrongMasterEnforceProp, workerWarnProp)); checkResults(1, 1, ConfigStatus.FAILED); .setName(serverEnforceProp.getName()) .setSource(serverEnforceProp.getSource()).setValue("WrongValue").build(); mRecordOne.registerNewConf(addressOne, Arrays.asList(masterEnforceProp, workerWarnProp, serverEnforceProp));
/** * Gets all configuration properties filtered by the specified scope. * * @param conf the configuration to use * @param scope the scope to filter by * @return the properties */ public static List<ConfigProperty> getConfiguration(AlluxioConfiguration conf, Scope scope) { ConfigurationValueOptions useRawDisplayValue = ConfigurationValueOptions.defaults().useDisplayValue(true).useRawValue(true); List<ConfigProperty> configs = new ArrayList<>(); List<PropertyKey> selectedKeys = conf.keySet().stream() .filter(key -> GrpcUtils.contains(key.getScope(), scope)) .filter(key -> key.isValid(key.getName())) .collect(toList()); for (PropertyKey key : selectedKeys) { ConfigProperty.Builder configProp = ConfigProperty.newBuilder().setName(key.getName()) .setSource(conf.getSource(key).toString()); if (conf.isSet(key)) { configProp.setValue(conf.get(key, useRawDisplayValue)); } configs.add(configProp.build()); } return configs; }
@Override public List<ConfigProperty> getConfiguration(GetConfigurationPOptions options) { List<ConfigProperty> configInfoList = new ArrayList<>(); for (PropertyKey key : ServerConfiguration.keySet()) { if (key.isBuiltIn()) { String source = ServerConfiguration.getSource(key).toString(); String value = ServerConfiguration.getOrDefault(key, null, ConfigurationValueOptions.defaults().useDisplayValue(true) .useRawValue(options.getRawValue())); ConfigProperty.Builder config = ConfigProperty.newBuilder().setName(key.getName()).setSource(source); if (value != null) { config.setValue(value); } configInfoList.add(config.build()); } } return configInfoList; }
@Before public void before() { PropertyKey keyEnforce = PropertyKey.ZOOKEEPER_ELECTION_PATH; PropertyKey keyWarn = PropertyKey.WORKER_FREE_SPACE_TIMEOUT; mConfigListOne = Arrays.asList( ConfigProperty.newBuilder().setName(keyEnforce.getName()).setSource("Test") .setValue("Value").build(), ConfigProperty.newBuilder().setName(keyWarn.getName()).setSource("Test").setValue("Value2") .build()); mConfigListTwo = Arrays.asList( ConfigProperty.newBuilder().setName(keyEnforce.getName()).setSource("Test") .setValue("Value3").build(), ConfigProperty.newBuilder().setName(keyWarn.getName()).setSource("Test").setValue("Value4") .build()); Random random = new Random(); mAddressOne = new Address(RandomStringUtils.randomAlphanumeric(10), random.nextInt()); mAddressTwo = new Address(RandomStringUtils.randomAlphanumeric(10), random.nextInt()); }
/** * <code>repeated .alluxio.grpc.ConfigProperty configs = 1;</code> */ public Builder addConfigs( alluxio.grpc.ConfigProperty.Builder builderForValue) { if (configsBuilder_ == null) { ensureConfigsIsMutable(); configs_.add(builderForValue.build()); onChanged(); } else { configsBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * <code>repeated .alluxio.grpc.ConfigProperty configs = 1;</code> */ public Builder addConfigs( int index, alluxio.grpc.ConfigProperty.Builder builderForValue) { if (configsBuilder_ == null) { ensureConfigsIsMutable(); configs_.add(index, builderForValue.build()); onChanged(); } else { configsBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * <code>repeated .alluxio.grpc.ConfigProperty configs = 1;</code> */ public Builder setConfigs( int index, alluxio.grpc.ConfigProperty.Builder builderForValue) { if (configsBuilder_ == null) { ensureConfigsIsMutable(); configs_.set(index, builderForValue.build()); onChanged(); } else { configsBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * <code>repeated .alluxio.grpc.ConfigProperty configs = 1;</code> */ public Builder addConfigs( alluxio.grpc.ConfigProperty.Builder builderForValue) { if (configsBuilder_ == null) { ensureConfigsIsMutable(); configs_.add(builderForValue.build()); onChanged(); } else { configsBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * <code>repeated .alluxio.grpc.ConfigProperty configs = 1;</code> */ public Builder addConfigs( alluxio.grpc.ConfigProperty.Builder builderForValue) { if (configsBuilder_ == null) { ensureConfigsIsMutable(); configs_.add(builderForValue.build()); onChanged(); } else { configsBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * <code>repeated .alluxio.grpc.ConfigProperty configs = 1;</code> */ public Builder setConfigs( int index, alluxio.grpc.ConfigProperty.Builder builderForValue) { if (configsBuilder_ == null) { ensureConfigsIsMutable(); configs_.set(index, builderForValue.build()); onChanged(); } else { configsBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * <code>repeated .alluxio.grpc.ConfigProperty configs = 1;</code> */ public Builder addConfigs( int index, alluxio.grpc.ConfigProperty.Builder builderForValue) { if (configsBuilder_ == null) { ensureConfigsIsMutable(); configs_.add(index, builderForValue.build()); onChanged(); } else { configsBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * <code>repeated .alluxio.grpc.ConfigProperty configs = 1;</code> */ public Builder setConfigs( int index, alluxio.grpc.ConfigProperty.Builder builderForValue) { if (configsBuilder_ == null) { ensureConfigsIsMutable(); configs_.set(index, builderForValue.build()); onChanged(); } else { configsBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * <code>repeated .alluxio.grpc.ConfigProperty configs = 1;</code> */ public Builder addConfigs( int index, alluxio.grpc.ConfigProperty.Builder builderForValue) { if (configsBuilder_ == null) { ensureConfigsIsMutable(); configs_.add(index, builderForValue.build()); onChanged(); } else { configsBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
public alluxio.grpc.ConfigProperty build() { alluxio.grpc.ConfigProperty result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
@java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } /**
@Test public void registerNewConfUnknownProperty() { Address testAddress = new Address("test", 0); ServerConfigurationStore configStore = new ServerConfigurationStore(); configStore.registerNewConf(testAddress, Arrays.asList(ConfigProperty.newBuilder().setName("unknown.property").build() )); Map<Address, List<ConfigRecord>> confMap = configStore.getConfMap(); assertTrue(confMap.containsKey(testAddress)); assertEquals("unknown.property", confMap.get(testAddress).get(0).getKey().getName()); }