-
Notifications
You must be signed in to change notification settings - Fork 254
SUBMARINE-1349. Fix the syntax error reported in sonarcloud and add init value for apiversion in XGboostjobList.java #1020
Conversation
Hi @cdmikechen , Please take a look at this PR, thanks. |
Codecov Report
@@ Coverage Diff @@
## master #1020 +/- ##
=======================================
Coverage 75.98% 75.98%
=======================================
Files 119 119
Lines 5000 5000
=======================================
Hits 3799 3799
Misses 1201 1201
Flags with carried forward coverage won't be shown. Click here to find out more. 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
...erver/server-core/src/main/java/org/apache/submarine/server/manager/ModelVersionManager.java
Outdated
Show resolved
Hide resolved
@@ -54,14 +54,10 @@ public class RegisteredModelManager { | |||
* | |||
* @return object | |||
*/ | |||
public static RegisteredModelManager getInstance() { | |||
public static synchronized RegisteredModelManager getInstance() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
@@ -27,7 +27,7 @@ | |||
|
|||
public class XGBoostJobList implements KubernetesListObject { | |||
@SerializedName("apiVersion") | |||
private String apiVersion; | |||
private String apiVersion = XGBoostJob.CRD_XGBOOST_API_VERSION_V1; | |||
|
|||
@SerializedName("kind") | |||
private String kind; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does kind
have the same problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cdmikechen kind doesn't show the problem in sonarcloud.
f940d14
to
b26c930
Compare
@cdmikechen just updated with some modifications, please take a look. (singleton, and their reference) |
@hhcs9527 |
public static Map<String,MinioClient> minioClientFactory = new HashMap<String, MinioClient>(); | ||
public static Map<String,Client> clientFactory = new HashMap<String, Client>(); | ||
|
||
public static Client getClient(String endpoint) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can use a enum
class to replace inner factory class to avoid client double checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cdmikechen , I agree with you.
But the enum type is more suitable for the predefined class (no argument to init). In our case, we need to init different users in testing, which cannot be predefined; that's why I use double-check locking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Java enum class can be used inside itself to create a constructor with parameters and as a singleton. Variables are only one of its basic uses.
8aa449e
to
85908b1
Compare
Hi @cdmikechen just updated Java enum class, please take a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
codecov currently finds that the current changes do not have some test cases, please add some test cases for the minio client section. The other sections can be left alone for now.
@@ -50,16 +50,14 @@ public class ModelVersionManager { | |||
* | |||
* @return object | |||
*/ | |||
private static class ModelVersionManagerHolder { | |||
private static ModelVersionManager manager = new ModelVersionManager(ModelVersionService.getInstance(), | |||
new ModelVersionTagService(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new class param should also be avoided here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cdmikechen ,
Not sure what you mean by adding some test cases for the minio client section here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New code changes need to be supported by test cases, otherwise they will reduce code coverage and fail to prove code robustness.
@@ -45,30 +47,57 @@ | |||
/** | |||
* S3(Minio) default client | |||
*/ | |||
public class Client { | |||
public enum Client { | |||
DEFAULT(SubmarineConfiguration.getInstance().getString(SubmarineConfVars.ConfVars.SUBMARINE_S3_ENDPOINT)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's necessary to add an endpoint attribute to the enum, which can't declare a variable number of endpoints and has to use the internal map to handle it.
public enum Client {
INSTANCE;
public static Client getInstance(String endpoint) {
// ....
}
}
Client.INSTANCE.getInstance("http://localhost:9000");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cdmikechen ,
Not sure what you mean here as well. Are you suggesting not initiating the enum variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using an enum as a factory to get a single instance object, using a limited number of enum definitions does not achieve the final effect of a dynamic factory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi~ There are still some test case failed and we can merge when you have resolved this issue.
76e816b
to
86cc8cf
Compare
@cdmikechen we still facing the same error for being unable to connect to the local host. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I will merge this pr after python cicd fixed
815c0a4
to
9e05aa1
Compare
9e05aa1
to
3fcabd6
Compare
…nit value for apiversion in XGboostjobList.java
… value for kind in XGboostjobList.java and make some class to be singleton.
…ubmarineConfiguration conf.
…usage of conf may be used in both staitc and non-static.
3fcabd6
to
54dda15
Compare
d53a3ef
to
fad6b5a
Compare
What is this PR for?
What type of PR is it?
Bug Fix
Todos
What is the Jira issue?
SUBMARINE-1349
How should this be tested?
Screenshots (if appropriate)
Questions: