-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add get-container functionality #241
Conversation
Hey, Wei - I am curious if this functionality is not something that you could have provided through the existing listContainers() API call? |
Actually, I am not sure about this. The existing listContainers() API call requires the api key has the authority to list all containers under the folder, I am not sure if we also need the authority for get-container call. Also, if we only want to see if the container exist, we can check if the container is in the return list, I am not sure whether we need more information(testrig, etc). |
@POST | ||
@Path(CoordConsts.SVC_RSC_GET_CONTAINER) | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public JSONArray getContainer( |
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.
getContainer() is perhaps not the right name for this function. Perhaps:
- getContainerInfo() if the plan down the line is to provide more information about the container (e.g., time of creation)
- doesContainerExists() is the intent is to simply let the clients check if the container with the provided name exists. (that is the purpose this function is currently serving, as no other information is provided.)
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.
getting back to your response, @kidsbear, i see the difference between the two functions. yes, being able to check if a containerName exists without having access to it is useful (and not supported by listContainers).
and by that token, the purpose of this function should stay as something close to doesContainerExist() as no other info should be provided with clients with API keys that don't have access to the container.
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.
Now the command used is 'exist-container', will output a string whether indicates the container does not exist, or the creation time of the container
… issue236-container merge branch
… issue236-container merge branch
Sorry, I may have been unclear, but this behavior is unclear and not intuitive. Suggestions:
Makes sense? |
Sure, will fix it later:) |
I don't buy it.i think getContainer is the right RESTful name for the
function. -- GET on a particular container to get its information.
Let's discuss tomorrow
…On Thu, Jul 20, 2017 at 18:43 kidsbear ***@***.***> wrote:
Sure, will fix it later:)
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#241 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAgIT6nXKlo09ot0ZH0F-N8lJ8wm__bWks5sQAJGgaJpZM4Oerx1>
.
|
SortedSet<String> testrigs = new TreeSet<>( | ||
CommonUtil.getSubdirectories(containerDir).stream() | ||
.map(dir -> dir.getFileName().toString()) | ||
.collect(Collectors.toSet())); |
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.
Technically, testrigs do not sit directly under the container directory. They sit under /BfConsts.RELPATH_TESTRIGS_DIR. (The constant is "" right now for backward compatibility but we'll make it something else at some point.)
Or, perhaps, your intent was to show all subdirectories under containerDir, and I am confused by the variable names saying 'testrigs' in some places.
} | ||
|
||
String testrigs = response.readEntity(String.class) + "\n"; | ||
return testrigs; |
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.
Consistent with server-side code, use 'containerInfo' as variable name instead of 'testrigs'?
@@ -385,6 +385,52 @@ private ClientBuilder getClientBuilder() throws Exception { | |||
.register(MultiPartFeature.class); | |||
} | |||
|
|||
/** | |||
* Return true if successfully get the information of the container, |
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.
This does not seem up to date.
@@ -1322,6 +1322,23 @@ private boolean getAnswer( | |||
return parameters; | |||
} | |||
|
|||
/** | |||
* Get information of the container(first element in {@code parameters}) return true if |
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.
Please clean up this javadoc. Space before (
and I can't tell if this is 1 or 2 sentences, etc. Use punctuation.
@@ -531,6 +531,20 @@ public String getAnswer( | |||
return answer; | |||
} | |||
|
|||
/** | |||
* Return a {@link SortedSet SortedSet} contains all subdirectories under the path {@code |
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.
A Container is not a sorted set -- it should be a Container
. Please make a proper java object that represents a container. One field it may have is testrigs
, which could be an ordered list or set of testrigs.
checkContainerAccessibility(apiKey, containerName); | ||
|
||
SortedSet<String> containerInfo = Main.getWorkMgr().getContainer(containerDir); | ||
return Response.ok(containerInfo.toString(), MediaType.TEXT_PLAIN).build(); |
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.
This should be a JSON response of a container.
_folder.newFolder(containerName); | ||
Main.mainInit(new String[] {"-containerslocation", _folder.getRoot().toString()}); | ||
Path containerDir = Paths.get(_folder.getRoot().toPath().resolve(containerName).toString()); | ||
SortedSet<String> containerInfo = _manager.getContainer(containerDir); |
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.
Most of the lines in these tests are identical. Can you pull all the setup of the Main and the containers to a helper function and simplify the tests dramatically?
@POST | ||
@Path(CoordConsts.SVC_RSC_GET_CONTAINER) | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Response getContainer( |
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.
Where is the test of this function?
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.
Minor changes requested, but looks great!
_analysis = analysis; | ||
} | ||
|
||
public String listTestrigs() { |
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.
drop this function – it's just a thin wrapper around getTestrigs
, isn't it?
/** | ||
* Get information of the container(first element in {@code parameters}). | ||
* <p> </p> | ||
* Returns true if successfully get container information, false otherwise |
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.
Get information of the container (first element in {@code parameters}).
<p>Returns {@code true} if successfully get container information, {@code false} otherwise.
… issue236-container merge
For issue #236