use of com.dtstack.taier.dao.domain.Component in project Taier by DTStack.
the class ClusterService method buildClusterConfig.
public JSONObject buildClusterConfig(Long clusterId, String componentVersion, EComponentType computeComponentType) {
Cluster cluster = clusterMapper.getOne(clusterId);
if (null == cluster) {
throw new RdosDefineException(ErrorCode.CANT_NOT_FIND_CLUSTER);
}
JSONObject config = new JSONObject();
List<Component> components = componentService.listAllComponents(clusterId);
for (Component component : components) {
EComponentType componentType = EComponentType.getByCode(component.getComponentTypeCode());
if (!EComponentScheduleType.COMPUTE.equals(EComponentType.getScheduleTypeByComponent(component.getComponentTypeCode()))) {
JSONObject componentConfig = componentService.getComponentByClusterId(clusterId, componentType.getTypeCode(), false, JSONObject.class, null);
config.put(componentType.getConfName(), componentConfig);
} else if (componentType.equals(computeComponentType)) {
JSONObject componentConfig = componentService.getComponentByClusterId(clusterId, componentType.getTypeCode(), false, JSONObject.class, componentVersion);
config.put(componentType.getConfName(), componentConfig);
}
// ignore other compute component
}
config.put(CLUSTER, cluster.getClusterName());
return config;
}
use of com.dtstack.taier.dao.domain.Component in project Taier by DTStack.
the class ComponentService method buildHdfsTypeName.
public String buildHdfsTypeName(Long tenantId, Long clusterId) {
if (null == clusterId) {
clusterId = clusterTenantMapper.getClusterIdByTenantId(tenantId);
}
Component component = getComponentByClusterId(clusterId, EComponentType.HDFS.getTypeCode(), null);
if (null == component || StringUtils.isBlank(component.getVersionName())) {
return "hdfs2";
}
String versionName = component.getVersionName();
List<Dict> dicts = scheduleDictService.listByDictType(DictType.HDFS_TYPE_NAME);
Optional<Dict> dbTypeNames = dicts.stream().filter(dict -> dict.getDictName().equals(versionName.trim())).findFirst();
if (dbTypeNames.isPresent()) {
return dbTypeNames.get().getDictValue();
}
String hadoopVersion = component.getVersionValue();
if (StringUtils.isBlank(hadoopVersion)) {
return "hdfs2";
}
return EComponentType.HDFS.name().toLowerCase() + hadoopVersion.charAt(0);
}
use of com.dtstack.taier.dao.domain.Component in project Taier by DTStack.
the class SyncOperatorPipeline method queryLastLocation.
public String queryLastLocation(Long tenantId, String engineJobId, long startTime, long endTime, EDeployMode deployMode, String jobId, String componentVersion) {
endTime = endTime + 1000 * 60;
List<Component> components = componentService.listComponentsByComponentType(tenantId, EComponentType.FLINK.getTypeCode());
if (CollectionUtils.isEmpty(components)) {
return null;
}
Optional<Component> componentOptional = components.stream().filter(c -> c.getVersionValue().equals(componentVersion)).findFirst();
if (!componentOptional.isPresent()) {
return null;
}
Map<String, Object> componentConfigToMap = componentConfigService.convertComponentConfigToMap(componentOptional.get().getId(), true);
Map<String, Object> flinkConfig = (Map<String, Object>) componentConfigToMap.get(deployMode.getMode());
String prometheusHost = (String) flinkConfig.get("prometheusHost");
String prometheusPort = (String) flinkConfig.get("prometheusPort");
LOGGER.info("last job {} deployMode {} prometheus host {} port {}", jobId, deployMode.getType(), prometheusHost, prometheusPort);
// prometheus的配置信息 从控制台获取
PrometheusMetricQuery prometheusMetricQuery = new PrometheusMetricQuery(String.format("%s:%s", prometheusHost, prometheusPort));
IMetric numReadMetric = MetricBuilder.buildMetric("endLocation", engineJobId, startTime, endTime, prometheusMetricQuery);
if (numReadMetric != null) {
String startLocation = String.valueOf(numReadMetric.getMetric());
LOGGER.info("job {} deployMode {} startLocation [{}]", jobId, deployMode.getType(), startLocation);
if (StringUtils.isEmpty(startLocation) || "0".equalsIgnoreCase(startLocation)) {
return null;
}
return String.valueOf(numReadMetric.getMetric());
}
return null;
}
use of com.dtstack.taier.dao.domain.Component in project Taier by DTStack.
the class StoragePart method getVersionValue.
@Override
public String getVersionValue() {
// special hdfs same as yarn
if (StringUtils.isBlank(versionName) && EComponentType.HDFS.equals(type)) {
Component resourceComponent = componentScheduleGroup.get(EComponentScheduleType.RESOURCE).get(0);
versionName = resourceComponent.getVersionName();
}
return context.getComponentModel(type).getVersionValue(versionName);
}
use of com.dtstack.taier.dao.domain.Component in project Taier by DTStack.
the class StoragePart method getExtraVersionParameters.
@Override
public Long getExtraVersionParameters() {
Component resourceComponent = componentScheduleGroup.get(EComponentScheduleType.RESOURCE).get(0);
String resourceVersion = resourceComponent.getVersionName();
EComponentType resourceType = EComponentType.getByCode(resourceComponent.getComponentTypeCode());
Optional<JSONObject> resourceModelExtraVersionParameters = context.getModelExtraVersionParameters(resourceType, resourceVersion);
if (resourceModelExtraVersionParameters.isPresent()) {
return resourceModelExtraVersionParameters.map(res -> res.getJSONObject(type.name())).orElse(new JSONObject()).getLong(type.name());
}
return null;
}
Aggregations