Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vernedeng committed Jun 30, 2024
1 parent de52c9b commit 73bb519
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public static String getSortClusterConfigUrl() {
return get().acquireSortClusterConfigUrl();
}

public static String getSortConfigUrl() {
return get().acquireSortConfigUrl();
}

private static ManagerUrlLoader get() {
if (instance != null) {
return instance;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.apache.inlong.common.pojo.sort.TaskConfig;
import org.apache.inlong.common.pojo.sort.dataflow.DataFlowConfig;
import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
import org.apache.inlong.sort.standalone.config.loader.v2.ClassResourceSortClusterConfigLoader;
import org.apache.inlong.sort.standalone.config.loader.v2.ManagerSortClusterConfigLoader;
import org.apache.inlong.sort.standalone.config.loader.v2.ClassResourceSortConfigLoader;
import org.apache.inlong.sort.standalone.config.loader.v2.ManagerSortConfigLoader;
import org.apache.inlong.sort.standalone.config.loader.v2.SortConfigLoader;
import org.apache.inlong.sort.standalone.config.pojo.InlongId;

Expand Down Expand Up @@ -73,9 +73,9 @@ private static SortConfigHolder get() {
.getString(SortConfigType.KEY_TYPE, SortConfigType.MANAGER.name());

if (SortConfigType.FILE.name().equalsIgnoreCase(loaderType)) {
instance.loader = new ClassResourceSortClusterConfigLoader();
instance.loader = new ClassResourceSortConfigLoader();
} else if (SortConfigType.MANAGER.name().equalsIgnoreCase(loaderType)) {
instance.loader = new ManagerSortClusterConfigLoader();
instance.loader = new ManagerSortConfigLoader();
} else {
// user-defined
try {
Expand All @@ -89,7 +89,7 @@ private static SortConfigHolder get() {
}
}
if (instance.loader == null) {
instance.loader = new ClassResourceSortClusterConfigLoader();
instance.loader = new ClassResourceSortConfigLoader();
}
try {
instance.loader.configure(new Context(CommonPropertiesHolder.get()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ public class CommonPropertiesManagerUrlLoader implements ManagerUrlLoader {
private static final Logger LOG = InlongLoggerFactory.getLogger(CommonPropertiesManagerUrlLoader.class);
private static final String KEY_SORT_CLUSTER_CONFIG_MANAGER_URL = "sortClusterConfig.managerUrl";
private static final String KEY_SORT_SOURCE_CONFIG_MANAGER_URL = "sortSourceConfig.managerUrl";
private static final String KEY_SORT_CONFIG_MANAGER_URL = "sortConfig.managerUrl";

private String sortSourceConfigUrl;
private String sortClusterConfigUrl;
private String sortConfigUrl;
public Context context;

@Override
Expand Down Expand Up @@ -70,6 +72,22 @@ public String acquireSortClusterConfigUrl() {
return sortClusterConfigUrl;
}

@Override
public String acquireSortConfigUrl() {
if (sortConfigUrl != null) {
return sortConfigUrl;
}
sortConfigUrl = context.getString(KEY_SORT_CONFIG_MANAGER_URL);
if (StringUtils.isBlank(sortConfigUrl)) {
String warnMsg = "Get key" + KEY_SORT_CONFIG_MANAGER_URL
+ " from CommonPropertiesHolder failed, it's a optional property use to specify "
+ "the url where Sort-Standalone request SortSourceConfig.";
LOG.warn(warnMsg);
sortConfigUrl = warnMsg;
}
return sortConfigUrl;
}

@Override
public void configure(Context context) {
Optional.ofNullable(context).ifPresent(c -> this.context = c);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public interface ManagerUrlLoader extends Configurable {
* @return SortClusterConfigUrl
*/
String acquireSortClusterConfigUrl();

String acquireSortConfigUrl();
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

import java.nio.charset.Charset;

public class ClassResourceSortClusterConfigLoader implements SortConfigLoader {
public class ClassResourceSortConfigLoader implements SortConfigLoader {

public static final Logger LOG = InlongLoggerFactory.getLogger(ClassResourceSortClusterConfigLoader.class);
public static final Logger LOG = InlongLoggerFactory.getLogger(ClassResourceSortConfigLoader.class);
private Context context;
private ObjectMapper objectMapper = new ObjectMapper();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.concurrent.TimeUnit;

@Slf4j
public class ManagerSortClusterConfigLoader implements SortConfigLoader {
public class ManagerSortConfigLoader implements SortConfigLoader {

private Context context;
private CloseableHttpClient httpClient;
Expand Down Expand Up @@ -66,7 +66,7 @@ public SortConfig load() {
HttpGet httpGet = null;
try {
String clusterName = this.context.getString(CommonPropertiesHolder.KEY_CLUSTER_ID);
String url = ManagerUrlHandler.getSortClusterConfigUrl() + "?clusterName="
String url = ManagerUrlHandler.getSortConfigUrl() + "?clusterName="
+ clusterName + "&md5=";
if (StringUtils.isNotBlank(this.md5)) {
url += this.md5;
Expand Down

0 comments on commit 73bb519

Please sign in to comment.