use of alluxio.grpc.ConfigProperty in project alluxio by Alluxio.
the class ConfigurationUtils method getConfiguration.
/**
* 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);
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(String.valueOf(conf.get(key, useRawDisplayValue)));
}
configs.add(configProp.build());
}
return configs;
}
use of alluxio.grpc.ConfigProperty in project alluxio by Alluxio.
the class AlluxioMasterRestServiceHandler method getWebUIConfiguration.
/**
* Gets Web UI ServerConfiguration page data.
*
* @return the response object
*/
@GET
@Path(WEBUI_CONFIG)
public Response getWebUIConfiguration() {
return RestUtils.call(() -> {
MasterWebUIConfiguration response = new MasterWebUIConfiguration();
response.setWhitelist(mFileSystemMaster.getWhiteList());
TreeSet<Triple<String, String, String>> sortedProperties = new TreeSet<>();
Set<String> alluxioConfExcludes = Sets.newHashSet(PropertyKey.MASTER_WHITELIST.toString());
for (ConfigProperty configProperty : mMetaMaster.getConfiguration(GetConfigurationPOptions.newBuilder().setRawValue(true).build()).toProto().getClusterConfigsList()) {
String confName = configProperty.getName();
if (!alluxioConfExcludes.contains(confName)) {
sortedProperties.add(new ImmutableTriple<>(confName, ConfigurationUtils.valueAsString(configProperty.getValue()), configProperty.getSource()));
}
}
response.setConfiguration(sortedProperties);
return response;
}, ServerConfiguration.global());
}
use of alluxio.grpc.ConfigProperty in project alluxio by Alluxio.
the class AlluxioWorkerRestServiceHandler method getWebUIConfiguration.
/**
* Gets Web UI ServerConfiguration page data.
*
* @return the response object
*/
@GET
@Path(WEBUI_CONFIG)
public Response getWebUIConfiguration() {
return RestUtils.call(() -> {
WorkerWebUIConfiguration response = new WorkerWebUIConfiguration();
response.setWhitelist(mBlockWorker.getWhiteList());
TreeSet<Triple<String, String, String>> sortedProperties = new TreeSet<>();
Set<String> alluxioConfExcludes = Sets.newHashSet(PropertyKey.WORKER_WHITELIST.toString());
for (ConfigProperty configProperty : mBlockWorker.getConfiguration(GetConfigurationPOptions.newBuilder().setRawValue(true).build()).toProto().getClusterConfigsList()) {
String confName = configProperty.getName();
if (!alluxioConfExcludes.contains(confName)) {
sortedProperties.add(new ImmutableTriple<>(confName, ConfigurationUtils.valueAsString(configProperty.getValue()), configProperty.getSource()));
}
}
response.setConfiguration(sortedProperties);
return response;
}, ServerConfiguration.global());
}
use of alluxio.grpc.ConfigProperty in project alluxio by Alluxio.
the class BlockMasterSync method registerWithMaster.
/**
* Registers with the Alluxio master. This should be called before the
* continuous heartbeat thread begins.
*/
private void registerWithMaster() throws IOException {
BlockStoreMeta storeMeta = mBlockWorker.getStoreMetaFull();
StorageTierAssoc storageTierAssoc = new WorkerStorageTierAssoc();
List<ConfigProperty> configList = ConfigurationUtils.getConfiguration(ServerConfiguration.global(), Scope.WORKER);
if (ACQUIRE_LEASE) {
LOG.info("Acquiring a RegisterLease from the master before registering");
try {
mMasterClient.acquireRegisterLeaseWithBackoff(mWorkerId.get(), storeMeta.getNumberOfBlocks(), getDefaultAcquireLeaseRetryPolicy());
LOG.info("Lease acquired");
} catch (FailedToAcquireRegisterLeaseException e) {
mMasterClient.disconnect();
if (ServerConfiguration.getBoolean(PropertyKey.TEST_MODE)) {
throw new RuntimeException(String.format("Master register lease timeout exceeded: %dms", ACQUIRE_LEASE_WAIT_MAX_DURATION));
}
ProcessUtils.fatalError(LOG, "Master register lease timeout exceeded: %dms", ACQUIRE_LEASE_WAIT_MAX_DURATION);
}
}
if (mUseStreaming) {
mMasterClient.registerWithStream(mWorkerId.get(), storageTierAssoc.getOrderedStorageAliases(), storeMeta.getCapacityBytesOnTiers(), storeMeta.getUsedBytesOnTiers(), storeMeta.getBlockListByStorageLocation(), storeMeta.getLostStorage(), configList);
} else {
mMasterClient.register(mWorkerId.get(), storageTierAssoc.getOrderedStorageAliases(), storeMeta.getCapacityBytesOnTiers(), storeMeta.getUsedBytesOnTiers(), storeMeta.getBlockListByStorageLocation(), storeMeta.getLostStorage(), configList);
}
// If the worker registers with master successfully, the lease will be recycled on the
// master side. No need to manually request for recycle on the worker side.
}
use of alluxio.grpc.ConfigProperty in project alluxio by Alluxio.
the class ServerConfigurationCheckerTest method checkConf.
@Test
public void checkConf() {
// Prepare data
PropertyKey keyMasterEnforce = new PropertyKey.Builder("TestKey1").setConsistencyCheckLevel(PropertyKey.ConsistencyCheckLevel.ENFORCE).setScope(Scope.MASTER).build();
ConfigProperty masterEnforceProp = ConfigProperty.newBuilder().setName(keyMasterEnforce.getName()).setSource("Test").setValue("Value").build();
PropertyKey keyWorkerWarn = new PropertyKey.Builder("TestKey2").setConsistencyCheckLevel(PropertyKey.ConsistencyCheckLevel.WARN).setScope(Scope.WORKER).build();
ConfigProperty workerWarnProp = ConfigProperty.newBuilder().setName(keyWorkerWarn.getName()).setSource("Test").setValue("Value").build();
PropertyKey keyServerEnforce = new PropertyKey.Builder("TestKey3").setConsistencyCheckLevel(PropertyKey.ConsistencyCheckLevel.ENFORCE).setScope(Scope.SERVER).build();
ConfigProperty serverEnforceProp = ConfigProperty.newBuilder().setName(keyServerEnforce.getName()).setSource("Test").setValue("Value").build();
Random random = new Random();
Address addressOne = new Address(RandomStringUtils.randomAlphanumeric(10), random.nextInt());
Address addressTwo = new Address(RandomStringUtils.randomAlphanumeric(10), random.nextInt());
// When records have nothing different, no errors or warns will be found
mRecordOne.registerNewConf(addressOne, Arrays.asList(masterEnforceProp, workerWarnProp));
mRecordTwo.registerNewConf(addressTwo, Arrays.asList(masterEnforceProp, workerWarnProp));
checkResults(0, 0, ConfigStatus.PASSED);
// When records have a wrong warn property, checker should be able to find config warns
ConfigProperty wrongWorkerWarnProp = ConfigProperty.newBuilder().setName(workerWarnProp.getName()).setSource(workerWarnProp.getSource()).setValue("WrongValue").build();
mRecordOne.registerNewConf(addressOne, Arrays.asList(masterEnforceProp, wrongWorkerWarnProp));
checkResults(0, 1, ConfigStatus.WARN);
// When records have a wrong enforce property, checker should be able to find config errors
ConfigProperty wrongMasterEnforceProp = ConfigProperty.newBuilder().setName(masterEnforceProp.getName()).setSource(masterEnforceProp.getSource()).setValue("WrongValue").build();
mRecordTwo.registerNewConf(addressTwo, Arrays.asList(wrongMasterEnforceProp, workerWarnProp));
checkResults(1, 1, ConfigStatus.FAILED);
ConfigProperty wrongServerEnforceProp = ConfigProperty.newBuilder().setName(serverEnforceProp.getName()).setSource(serverEnforceProp.getSource()).setValue("WrongValue").build();
mRecordOne.registerNewConf(addressOne, Arrays.asList(masterEnforceProp, workerWarnProp, serverEnforceProp));
mRecordTwo.registerNewConf(addressTwo, Arrays.asList(masterEnforceProp, workerWarnProp, wrongServerEnforceProp));
checkResults(1, 0, ConfigStatus.FAILED);
}
Aggregations