use of io.cdap.cdap.runtime.spi.provisioner.ProvisionerSystemContext in project cdap by caskdata.
the class AbstractDataprocProvisioner method getSystemContext.
/**
* Returns the {@link ProvisionerSystemContext} that was passed to the {@link #initialize(ProvisionerSystemContext)}
* method. The system properties will be reloaded via the {@link ProvisionerSystemContext#reloadProperties()}
* method upon every time when this method is called.
*/
protected ProvisionerSystemContext getSystemContext() {
ProvisionerSystemContext context = Objects.requireNonNull(systemContext, "System context is not available. Please make sure the initialize method has been called.");
context.reloadProperties();
return context;
}
use of io.cdap.cdap.runtime.spi.provisioner.ProvisionerSystemContext in project cdap by caskdata.
the class AbstractDataprocProvisioner method getSystemLabels.
/**
* Returns a set of system labels that should be applied to all Dataproc entities.
*/
protected final Map<String, String> getSystemLabels() {
Map<String, String> labels = new HashMap<>();
ProvisionerSystemContext systemContext = getSystemContext();
// dataproc only allows label values to be lowercase letters, numbers, or dashes
labels.put(LABEL_VERSON, getVersionLabel());
String extraLabelsStr = systemContext.getProperties().get(LABELS_PROPERTY);
// name1=val1,name2=val2
if (extraLabelsStr != null) {
labels.putAll(DataprocUtils.parseLabels(extraLabelsStr));
}
return Collections.unmodifiableMap(labels);
}
use of io.cdap.cdap.runtime.spi.provisioner.ProvisionerSystemContext in project cdap by caskdata.
the class ProvisioningService method initializeProvisioners.
/**
* Reloads provisioners in the extension directory. Any new provisioners will be added and any deleted provisioners
* will be removed. Loaded provisioners will be initialized.
*/
private void initializeProvisioners() {
Map<String, Provisioner> provisioners = provisionerProvider.loadProvisioners();
Map<String, ProvisionerConfig> provisionerConfigs = provisionerConfigProvider.loadProvisionerConfigs(provisioners.values());
LOG.debug("Provisioners = {}", provisioners);
Map<String, ProvisionerDetail> details = new HashMap<>(provisioners.size());
for (Map.Entry<String, Provisioner> provisionerEntry : provisioners.entrySet()) {
String provisionerName = provisionerEntry.getKey();
Provisioner provisioner = provisionerEntry.getValue();
ProvisionerSystemContext provisionerSystemContext = new DefaultSystemProvisionerContext(cConf, provisionerName);
try {
provisioner.initialize(provisionerSystemContext);
} catch (RuntimeException e) {
LOG.warn("Error initializing the {} provisioner. It will not be available for use.", provisionerName, e);
provisioners.remove(provisionerName);
continue;
}
ProvisionerSpecification spec = provisioner.getSpec();
ProvisionerConfig config = provisionerConfigs.getOrDefault(provisionerName, new ProvisionerConfig(new ArrayList<>(), null, null, false));
details.put(provisionerName, new ProvisionerDetail(spec.getName(), spec.getLabel(), spec.getDescription(), config.getConfigurationGroups(), config.getFilters(), config.getIcon(), config.isBeta()));
}
provisionerInfo.set(new ProvisionerInfo(provisioners, details));
}
Aggregations