Skip to content
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

Merged
merged 20 commits into from
Jul 27, 2017
Merged

Conversation

kidsbear
Copy link
Contributor

For issue #236

@kidsbear kidsbear requested a review from dhalperi July 20, 2017 21:20
@ratulm
Copy link
Member

ratulm commented Jul 20, 2017

Hey, Wei - I am curious if this functionality is not something that you could have provided through the existing listContainers() API call?

@kidsbear
Copy link
Contributor Author

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(
Copy link
Member

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.)

Copy link
Member

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.

Copy link
Contributor Author

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

@ratulm
Copy link
Member

ratulm commented Jul 21, 2017

Sorry, I may have been unclear, but this behavior is unclear and not intuitive.

Suggestions:

  • instead of existContainer, call things checkContainerExists
  • return just true or false accordingly

Makes sense?

@kidsbear
Copy link
Contributor Author

Sure, will fix it later:)

@dhalperi
Copy link
Member

dhalperi commented Jul 21, 2017 via email

SortedSet<String> testrigs = new TreeSet<>(
CommonUtil.getSubdirectories(containerDir).stream()
.map(dir -> dir.getFileName().toString())
.collect(Collectors.toSet()));
Copy link
Member

@ratulm ratulm Jul 25, 2017

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;
Copy link
Member

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,
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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();
Copy link
Member

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);
Copy link
Member

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(
Copy link
Member

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?

Copy link
Member

@dhalperi dhalperi left a 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() {
Copy link
Member

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants