-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change serviceResName to domain format
- Loading branch information
1 parent
a083d78
commit 98fb0b9
Showing
2 changed files
with
36 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 35 additions & 36 deletions
71
tis-plugin/src/main/java/com/qlangtech/tis/datax/job/ServiceResName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,57 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* <p> | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.qlangtech.tis.datax.job; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
|
||
import java.util.Objects; | ||
import com.qlangtech.tis.plugin.k8s.K8sImage; | ||
|
||
/** | ||
* @author: 百岁([email protected]) | ||
* @create: 2024-03-11 13:33 | ||
**/ | ||
public class ServiceResName<T> extends SubJobResName<T> { | ||
private static final String HOST_SUFFIX = "_SERVICE_HOST"; | ||
private static final String PORT_SUFFIX = "_SERVICE_PORT"; | ||
// private static final String HOST_SUFFIX = "_SERVICE_HOST"; | ||
// private static final String PORT_SUFFIX = "_SERVICE_PORT"; | ||
|
||
public ServiceResName(String name, SubJobExec<T> subJobExec) { | ||
super(name, subJobExec); | ||
} | ||
|
||
public String getHostEvnName() { | ||
return replaceAndUpperCase(getName()) + HOST_SUFFIX; | ||
} | ||
|
||
public String getPortEvnName() { | ||
return replaceAndUpperCase(getName()) + PORT_SUFFIX; | ||
// public String getHostEvnName() { | ||
// return replaceAndUpperCase(getName()) + HOST_SUFFIX; | ||
// } | ||
// | ||
// public String getPortEvnName() { | ||
// return replaceAndUpperCase(getName()) + PORT_SUFFIX; | ||
// } | ||
// | ||
public String getHostPortReplacement(K8sImage image) { | ||
return getName() + "." + image.getNamespace(); | ||
// return toVarReplacement(getHostEvnName()) + ":" + toVarReplacement(getPortEvnName()); | ||
} | ||
|
||
public String getHostPortReplacement() { | ||
return toVarReplacement(getHostEvnName()) + ":" + toVarReplacement(getPortEvnName()); | ||
} | ||
// private String toVarReplacement(String val) { | ||
// return "$(" + Objects.requireNonNull(val, "val can not be null") + ")"; | ||
// } | ||
|
||
private String toVarReplacement(String val) { | ||
return "$(" + Objects.requireNonNull(val, "val can not be null") + ")"; | ||
} | ||
|
||
private String replaceAndUpperCase(String val) { | ||
return StringUtils.upperCase(StringUtils.replace(val, "-", "_")); | ||
} | ||
// private String replaceAndUpperCase(String val) { | ||
// return StringUtils.upperCase(StringUtils.replace(val, "-", "_")); | ||
// } | ||
|
||
@Override | ||
protected String getResourceType() { | ||
|