id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
400 | WiQuery/wiquery | wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/position/PositionAlignmentOptions.java | PositionAlignmentOptions.setVerticalAlignment | public PositionAlignmentOptions setVerticalAlignment(PositionRelation verticalAlignment, int offsetTop)
{
switch (verticalAlignment)
{
case TOP:
case CENTER:
case BOTTOM:
break;
default:
throw new IllegalArgumentException("Illegal value for the vertical alignment property");
}
this.verticalAlignment = verticalAlignment;
this.offsetTop = offsetTop;
return this;
} | java | public PositionAlignmentOptions setVerticalAlignment(PositionRelation verticalAlignment, int offsetTop)
{
switch (verticalAlignment)
{
case TOP:
case CENTER:
case BOTTOM:
break;
default:
throw new IllegalArgumentException("Illegal value for the vertical alignment property");
}
this.verticalAlignment = verticalAlignment;
this.offsetTop = offsetTop;
return this;
} | [
"public",
"PositionAlignmentOptions",
"setVerticalAlignment",
"(",
"PositionRelation",
"verticalAlignment",
",",
"int",
"offsetTop",
")",
"{",
"switch",
"(",
"verticalAlignment",
")",
"{",
"case",
"TOP",
":",
"case",
"CENTER",
":",
"case",
"BOTTOM",
":",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Illegal value for the vertical alignment property\"",
")",
";",
"}",
"this",
".",
"verticalAlignment",
"=",
"verticalAlignment",
";",
"this",
".",
"offsetTop",
"=",
"offsetTop",
";",
"return",
"this",
";",
"}"
] | Set the verticalAlignment property with an offset. One of TOP, CENTER, BOTTOM.
@param verticalAlignment
@param offsetTop
@return the instance | [
"Set",
"the",
"verticalAlignment",
"property",
"with",
"an",
"offset",
".",
"One",
"of",
"TOP",
"CENTER",
"BOTTOM",
"."
] | 1b8d60c7a3c37b90fd68c9cd0ff97178fcbcbb08 | https://github.com/WiQuery/wiquery/blob/1b8d60c7a3c37b90fd68c9cd0ff97178fcbcbb08/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/position/PositionAlignmentOptions.java#L289-L304 |
401 | Wootric/WootricSDK-Android | androidsdk/src/main/java/com/wootric/androidsdk/objects/Settings.java | Settings.mergeWithSurveyServerSettings | public void mergeWithSurveyServerSettings(Settings settings) {
if(settings == null) {
return;
}
this.adminPanelCustomMessage = settings.adminPanelCustomMessage;
this.adminPanelTimeDelay = settings.adminPanelTimeDelay;
this.localizedTexts = settings.localizedTexts;
this.userID = settings.userID;
this.accountID = settings.accountID;
this.resurveyThrottle = settings.resurveyThrottle;
this.declineResurveyThrottle = settings.declineResurveyThrottle;
this.surveyType = settings.surveyType;
} | java | public void mergeWithSurveyServerSettings(Settings settings) {
if(settings == null) {
return;
}
this.adminPanelCustomMessage = settings.adminPanelCustomMessage;
this.adminPanelTimeDelay = settings.adminPanelTimeDelay;
this.localizedTexts = settings.localizedTexts;
this.userID = settings.userID;
this.accountID = settings.accountID;
this.resurveyThrottle = settings.resurveyThrottle;
this.declineResurveyThrottle = settings.declineResurveyThrottle;
this.surveyType = settings.surveyType;
} | [
"public",
"void",
"mergeWithSurveyServerSettings",
"(",
"Settings",
"settings",
")",
"{",
"if",
"(",
"settings",
"==",
"null",
")",
"{",
"return",
";",
"}",
"this",
".",
"adminPanelCustomMessage",
"=",
"settings",
".",
"adminPanelCustomMessage",
";",
"this",
".",
"adminPanelTimeDelay",
"=",
"settings",
".",
"adminPanelTimeDelay",
";",
"this",
".",
"localizedTexts",
"=",
"settings",
".",
"localizedTexts",
";",
"this",
".",
"userID",
"=",
"settings",
".",
"userID",
";",
"this",
".",
"accountID",
"=",
"settings",
".",
"accountID",
";",
"this",
".",
"resurveyThrottle",
"=",
"settings",
".",
"resurveyThrottle",
";",
"this",
".",
"declineResurveyThrottle",
"=",
"settings",
".",
"declineResurveyThrottle",
";",
"this",
".",
"surveyType",
"=",
"settings",
".",
"surveyType",
";",
"}"
] | Sets values from the argument settings only if they are not provided yet | [
"Sets",
"values",
"from",
"the",
"argument",
"settings",
"only",
"if",
"they",
"are",
"not",
"provided",
"yet"
] | ba584f2317ce99452424b9a78d024e361ad6fec4 | https://github.com/Wootric/WootricSDK-Android/blob/ba584f2317ce99452424b9a78d024e361ad6fec4/androidsdk/src/main/java/com/wootric/androidsdk/objects/Settings.java#L79-L92 |
402 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/tasks/CleanTask.java | CleanTask.setPaths | public void setPaths(String paths) {
if (paths != null && paths.trim().length() > 0) {
String[] pathArray = paths.split(",");
pathList.addAll(Arrays.asList(pathArray));
}
} | java | public void setPaths(String paths) {
if (paths != null && paths.trim().length() > 0) {
String[] pathArray = paths.split(",");
pathList.addAll(Arrays.asList(pathArray));
}
} | [
"public",
"void",
"setPaths",
"(",
"String",
"paths",
")",
"{",
"if",
"(",
"paths",
"!=",
"null",
"&&",
"paths",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"String",
"[",
"]",
"pathArray",
"=",
"paths",
".",
"split",
"(",
"\",\"",
")",
";",
"pathList",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"pathArray",
")",
")",
";",
"}",
"}"
] | If paths are set, only these paths are affected by the cleaning.
@antdoc.notrequired
@param paths the paths to set | [
"If",
"paths",
"are",
"set",
"only",
"these",
"paths",
"are",
"affected",
"by",
"the",
"cleaning",
"."
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/tasks/CleanTask.java#L61-L66 |
403 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/GitSettings.java | GitSettings.setCredentials | public void setCredentials(String username, String password) {
if (GitTaskUtils.isNullOrBlankString(username) || GitTaskUtils.isNullOrBlankString(password)) {
throw new IllegalArgumentException("Credentials must not be empty.");
}
credentials = new UsernamePasswordCredentialsProvider(username, password);
} | java | public void setCredentials(String username, String password) {
if (GitTaskUtils.isNullOrBlankString(username) || GitTaskUtils.isNullOrBlankString(password)) {
throw new IllegalArgumentException("Credentials must not be empty.");
}
credentials = new UsernamePasswordCredentialsProvider(username, password);
} | [
"public",
"void",
"setCredentials",
"(",
"String",
"username",
",",
"String",
"password",
")",
"{",
"if",
"(",
"GitTaskUtils",
".",
"isNullOrBlankString",
"(",
"username",
")",
"||",
"GitTaskUtils",
".",
"isNullOrBlankString",
"(",
"password",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Credentials must not be empty.\"",
")",
";",
"}",
"credentials",
"=",
"new",
"UsernamePasswordCredentialsProvider",
"(",
"username",
",",
"password",
")",
";",
"}"
] | Sets the Git credentials
@param username The username
@param password The password | [
"Sets",
"the",
"Git",
"credentials"
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/GitSettings.java#L38-L44 |
404 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/GitSettings.java | GitSettings.setIdentity | public void setIdentity(String name, String email) {
if (GitTaskUtils.isNullOrBlankString(name) || GitTaskUtils.isNullOrBlankString(email)) {
throw new IllegalArgumentException("Both the username and password must be provided.");
}
identity = new PersonIdent(name, email);
} | java | public void setIdentity(String name, String email) {
if (GitTaskUtils.isNullOrBlankString(name) || GitTaskUtils.isNullOrBlankString(email)) {
throw new IllegalArgumentException("Both the username and password must be provided.");
}
identity = new PersonIdent(name, email);
} | [
"public",
"void",
"setIdentity",
"(",
"String",
"name",
",",
"String",
"email",
")",
"{",
"if",
"(",
"GitTaskUtils",
".",
"isNullOrBlankString",
"(",
"name",
")",
"||",
"GitTaskUtils",
".",
"isNullOrBlankString",
"(",
"email",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Both the username and password must be provided.\"",
")",
";",
"}",
"identity",
"=",
"new",
"PersonIdent",
"(",
"name",
",",
"email",
")",
";",
"}"
] | Sets the name and email for the Git commands user
@param name The Git user's name
@param email The Git user's email | [
"Sets",
"the",
"name",
"and",
"email",
"for",
"the",
"Git",
"commands",
"user"
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/GitSettings.java#L52-L58 |
405 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/AbstractGitRepoAwareTask.java | AbstractGitRepoAwareTask.translateFilePathUsingPrefix | protected String translateFilePathUsingPrefix(String file, String prefix) throws IOException {
if (file.equals(prefix)) {
return ".";
}
String result = new File(file).getCanonicalPath().substring(prefix.length() + 1);
if (File.separatorChar != '/') {
result = result.replace(File.separatorChar, '/');
}
return result;
} | java | protected String translateFilePathUsingPrefix(String file, String prefix) throws IOException {
if (file.equals(prefix)) {
return ".";
}
String result = new File(file).getCanonicalPath().substring(prefix.length() + 1);
if (File.separatorChar != '/') {
result = result.replace(File.separatorChar, '/');
}
return result;
} | [
"protected",
"String",
"translateFilePathUsingPrefix",
"(",
"String",
"file",
",",
"String",
"prefix",
")",
"throws",
"IOException",
"{",
"if",
"(",
"file",
".",
"equals",
"(",
"prefix",
")",
")",
"{",
"return",
"\".\"",
";",
"}",
"String",
"result",
"=",
"new",
"File",
"(",
"file",
")",
".",
"getCanonicalPath",
"(",
")",
".",
"substring",
"(",
"prefix",
".",
"length",
"(",
")",
"+",
"1",
")",
";",
"if",
"(",
"File",
".",
"separatorChar",
"!=",
"'",
"'",
")",
"{",
"result",
"=",
"result",
".",
"replace",
"(",
"File",
".",
"separatorChar",
",",
"'",
"'",
")",
";",
"}",
"return",
"result",
";",
"}"
] | return either a "." if file and prefix have the same value,
or the right part of file - length of prefix plus one removed
@param file file on which a git operation needs to be done
@param prefix folder of the git sandbox
@return path relative to git sandbox folder
@throws IOException the method uses File#getCanonicalPath which can throw IOException | [
"return",
"either",
"a",
".",
"if",
"file",
"and",
"prefix",
"have",
"the",
"same",
"value",
"or",
"the",
"right",
"part",
"of",
"file",
"-",
"length",
"of",
"prefix",
"plus",
"one",
"removed"
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/AbstractGitRepoAwareTask.java#L99-L108 |
406 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/AbstractGitTask.java | AbstractGitTask.setSettingsRef | public void setSettingsRef(String settingsRef) {
if (GitTaskUtils.isNullOrBlankString(settingsRef)) {
throw new BuildException("Can't set blank git settings reference.");
}
// no override
if (this.settingsRef == null) {
this.settingsRef = settingsRef;
}
} | java | public void setSettingsRef(String settingsRef) {
if (GitTaskUtils.isNullOrBlankString(settingsRef)) {
throw new BuildException("Can't set blank git settings reference.");
}
// no override
if (this.settingsRef == null) {
this.settingsRef = settingsRef;
}
} | [
"public",
"void",
"setSettingsRef",
"(",
"String",
"settingsRef",
")",
"{",
"if",
"(",
"GitTaskUtils",
".",
"isNullOrBlankString",
"(",
"settingsRef",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Can't set blank git settings reference.\"",
")",
";",
"}",
"// no override",
"if",
"(",
"this",
".",
"settingsRef",
"==",
"null",
")",
"{",
"this",
".",
"settingsRef",
"=",
"settingsRef",
";",
"}",
"}"
] | Sets a git settings reference
@antdoc.notrequired
@param settingsRef the settingsRef to set | [
"Sets",
"a",
"git",
"settings",
"reference"
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/AbstractGitTask.java#L59-L68 |
407 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/AbstractGitTask.java | AbstractGitTask.setUri | public void setUri(String uri) {
if (GitTaskUtils.isNullOrBlankString(uri)) {
throw new BuildException("Can't set null URI attribute.");
}
if (this.uri == null) {
try {
new URIish(uri);
this.uri = uri;
} catch (URISyntaxException e) {
throw new BuildException(String.format("Invalid URI '%s'.", uri), e);
}
}
} | java | public void setUri(String uri) {
if (GitTaskUtils.isNullOrBlankString(uri)) {
throw new BuildException("Can't set null URI attribute.");
}
if (this.uri == null) {
try {
new URIish(uri);
this.uri = uri;
} catch (URISyntaxException e) {
throw new BuildException(String.format("Invalid URI '%s'.", uri), e);
}
}
} | [
"public",
"void",
"setUri",
"(",
"String",
"uri",
")",
"{",
"if",
"(",
"GitTaskUtils",
".",
"isNullOrBlankString",
"(",
"uri",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Can't set null URI attribute.\"",
")",
";",
"}",
"if",
"(",
"this",
".",
"uri",
"==",
"null",
")",
"{",
"try",
"{",
"new",
"URIish",
"(",
"uri",
")",
";",
"this",
".",
"uri",
"=",
"uri",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"String",
".",
"format",
"(",
"\"Invalid URI '%s'.\"",
",",
"uri",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Sets the git repository uri
@antdoc.notrequired
@param uri The repository uri | [
"Sets",
"the",
"git",
"repository",
"uri"
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/AbstractGitTask.java#L122-L135 |
408 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/AbstractGitTask.java | AbstractGitTask.setDirectory | @Override
public void setDirectory(File dir) {
if (dir == null) {
throw new BuildException("Cannot set null directory attribute.");
}
// no override
if (this.directory == null) {
this.directory = new File(dir.getAbsolutePath());
}
} | java | @Override
public void setDirectory(File dir) {
if (dir == null) {
throw new BuildException("Cannot set null directory attribute.");
}
// no override
if (this.directory == null) {
this.directory = new File(dir.getAbsolutePath());
}
} | [
"@",
"Override",
"public",
"void",
"setDirectory",
"(",
"File",
"dir",
")",
"{",
"if",
"(",
"dir",
"==",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Cannot set null directory attribute.\"",
")",
";",
"}",
"// no override",
"if",
"(",
"this",
".",
"directory",
"==",
"null",
")",
"{",
"this",
".",
"directory",
"=",
"new",
"File",
"(",
"dir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}"
] | Sets the Git repository directory
@antdoc.notrequired
@param dir The repository directory | [
"Sets",
"the",
"Git",
"repository",
"directory"
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/AbstractGitTask.java#L143-L153 |
409 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/AbstractGitTask.java | AbstractGitTask.lookupSettings | protected GitSettings lookupSettings() {
if (getProject() != null && settingsRef != null) {
Reference ref = (Reference) getProject().getReference(settingsRef);
if (ref != null) {
GitSettings settings = (GitSettings) ref.getReferencedObject();
return settings;
}
}
return null;
} | java | protected GitSettings lookupSettings() {
if (getProject() != null && settingsRef != null) {
Reference ref = (Reference) getProject().getReference(settingsRef);
if (ref != null) {
GitSettings settings = (GitSettings) ref.getReferencedObject();
return settings;
}
}
return null;
} | [
"protected",
"GitSettings",
"lookupSettings",
"(",
")",
"{",
"if",
"(",
"getProject",
"(",
")",
"!=",
"null",
"&&",
"settingsRef",
"!=",
"null",
")",
"{",
"Reference",
"ref",
"=",
"(",
"Reference",
")",
"getProject",
"(",
")",
".",
"getReference",
"(",
"settingsRef",
")",
";",
"if",
"(",
"ref",
"!=",
"null",
")",
"{",
"GitSettings",
"settings",
"=",
"(",
"GitSettings",
")",
"ref",
".",
"getReferencedObject",
"(",
")",
";",
"return",
"settings",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Lookup the git settings for this task via a project reference
@return The configured git settings for this task | [
"Lookup",
"the",
"git",
"settings",
"for",
"this",
"task",
"via",
"a",
"project",
"reference"
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/AbstractGitTask.java#L198-L210 |
410 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/AbstractGitTask.java | AbstractGitTask.setupCredentials | @SuppressWarnings("rawtypes")
protected void setupCredentials(GitCommand<?> command) {
GitSettings settings = lookupSettings();
if (settings != null && command instanceof TransportCommand) {
TransportCommand cmd = (TransportCommand) command;
cmd.setCredentialsProvider(settings.getCredentials());
}
} | java | @SuppressWarnings("rawtypes")
protected void setupCredentials(GitCommand<?> command) {
GitSettings settings = lookupSettings();
if (settings != null && command instanceof TransportCommand) {
TransportCommand cmd = (TransportCommand) command;
cmd.setCredentialsProvider(settings.getCredentials());
}
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"protected",
"void",
"setupCredentials",
"(",
"GitCommand",
"<",
"?",
">",
"command",
")",
"{",
"GitSettings",
"settings",
"=",
"lookupSettings",
"(",
")",
";",
"if",
"(",
"settings",
"!=",
"null",
"&&",
"command",
"instanceof",
"TransportCommand",
")",
"{",
"TransportCommand",
"cmd",
"=",
"(",
"TransportCommand",
")",
"command",
";",
"cmd",
".",
"setCredentialsProvider",
"(",
"settings",
".",
"getCredentials",
"(",
")",
")",
";",
"}",
"}"
] | Setups the Git credentials if specified and needed
@param command The git command to configure | [
"Setups",
"the",
"Git",
"credentials",
"if",
"specified",
"and",
"needed"
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/AbstractGitTask.java#L217-L225 |
411 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/tasks/BranchListTask.java | BranchListTask.setListMode | public void setListMode(String listMode) {
if (!GitTaskUtils.isNullOrBlankString(listMode)) {
try {
this.listMode = ListBranchCommand.ListMode.valueOf(listMode);
}
catch (IllegalArgumentException e) {
ListBranchCommand.ListMode[] listModes = ListBranchCommand.ListMode.values();
List<String> listModeValidValues = new ArrayList<String>(listModes.length);
for (ListBranchCommand.ListMode aListMode : listModes) {
listModeValidValues.add(aListMode.name());
}
String validModes = listModeValidValues.toString();
throw new BuildException(String.format("Valid listMode options are: %s.", validModes));
}
}
} | java | public void setListMode(String listMode) {
if (!GitTaskUtils.isNullOrBlankString(listMode)) {
try {
this.listMode = ListBranchCommand.ListMode.valueOf(listMode);
}
catch (IllegalArgumentException e) {
ListBranchCommand.ListMode[] listModes = ListBranchCommand.ListMode.values();
List<String> listModeValidValues = new ArrayList<String>(listModes.length);
for (ListBranchCommand.ListMode aListMode : listModes) {
listModeValidValues.add(aListMode.name());
}
String validModes = listModeValidValues.toString();
throw new BuildException(String.format("Valid listMode options are: %s.", validModes));
}
}
} | [
"public",
"void",
"setListMode",
"(",
"String",
"listMode",
")",
"{",
"if",
"(",
"!",
"GitTaskUtils",
".",
"isNullOrBlankString",
"(",
"listMode",
")",
")",
"{",
"try",
"{",
"this",
".",
"listMode",
"=",
"ListBranchCommand",
".",
"ListMode",
".",
"valueOf",
"(",
"listMode",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"ListBranchCommand",
".",
"ListMode",
"[",
"]",
"listModes",
"=",
"ListBranchCommand",
".",
"ListMode",
".",
"values",
"(",
")",
";",
"List",
"<",
"String",
">",
"listModeValidValues",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"listModes",
".",
"length",
")",
";",
"for",
"(",
"ListBranchCommand",
".",
"ListMode",
"aListMode",
":",
"listModes",
")",
"{",
"listModeValidValues",
".",
"add",
"(",
"aListMode",
".",
"name",
"(",
")",
")",
";",
"}",
"String",
"validModes",
"=",
"listModeValidValues",
".",
"toString",
"(",
")",
";",
"throw",
"new",
"BuildException",
"(",
"String",
".",
"format",
"(",
"\"Valid listMode options are: %s.\"",
",",
"validModes",
")",
")",
";",
"}",
"}",
"}"
] | Sets the listing mode
@antdoc.notrequired
@param listMode - optional: corresponds to the -r/-a options; by default, only local branches will be listed | [
"Sets",
"the",
"listing",
"mode"
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/tasks/BranchListTask.java#L59-L78 |
412 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/tasks/ResetTask.java | ResetTask.setMode | public void setMode(String mode) {
if ("soft".equalsIgnoreCase(mode)) {
this.mode = ResetType.SOFT;
} else if ("mixed".equalsIgnoreCase(mode)) {
this.mode = ResetType.MIXED;
} else if ("hard".equalsIgnoreCase(mode)) {
this.mode = ResetType.HARD;
} else if ("merge".equalsIgnoreCase(mode)) {
this.mode = ResetType.MERGE;
} else if ("keep".equalsIgnoreCase(mode)) {
this.mode = ResetType.KEEP;
} else {
this.mode = ResetType.MIXED;
}
} | java | public void setMode(String mode) {
if ("soft".equalsIgnoreCase(mode)) {
this.mode = ResetType.SOFT;
} else if ("mixed".equalsIgnoreCase(mode)) {
this.mode = ResetType.MIXED;
} else if ("hard".equalsIgnoreCase(mode)) {
this.mode = ResetType.HARD;
} else if ("merge".equalsIgnoreCase(mode)) {
this.mode = ResetType.MERGE;
} else if ("keep".equalsIgnoreCase(mode)) {
this.mode = ResetType.KEEP;
} else {
this.mode = ResetType.MIXED;
}
} | [
"public",
"void",
"setMode",
"(",
"String",
"mode",
")",
"{",
"if",
"(",
"\"soft\"",
".",
"equalsIgnoreCase",
"(",
"mode",
")",
")",
"{",
"this",
".",
"mode",
"=",
"ResetType",
".",
"SOFT",
";",
"}",
"else",
"if",
"(",
"\"mixed\"",
".",
"equalsIgnoreCase",
"(",
"mode",
")",
")",
"{",
"this",
".",
"mode",
"=",
"ResetType",
".",
"MIXED",
";",
"}",
"else",
"if",
"(",
"\"hard\"",
".",
"equalsIgnoreCase",
"(",
"mode",
")",
")",
"{",
"this",
".",
"mode",
"=",
"ResetType",
".",
"HARD",
";",
"}",
"else",
"if",
"(",
"\"merge\"",
".",
"equalsIgnoreCase",
"(",
"mode",
")",
")",
"{",
"this",
".",
"mode",
"=",
"ResetType",
".",
"MERGE",
";",
"}",
"else",
"if",
"(",
"\"keep\"",
".",
"equalsIgnoreCase",
"(",
"mode",
")",
")",
"{",
"this",
".",
"mode",
"=",
"ResetType",
".",
"KEEP",
";",
"}",
"else",
"{",
"this",
".",
"mode",
"=",
"ResetType",
".",
"MIXED",
";",
"}",
"}"
] | If mode is set, apply the specified mode according to Git manual.
@antdoc.notrequired
@param mode the mode used to perform git reset. (Default is MIXED) | [
"If",
"mode",
"is",
"set",
"apply",
"the",
"specified",
"mode",
"according",
"to",
"Git",
"manual",
"."
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/tasks/ResetTask.java#L55-L69 |
413 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/tasks/TagListTask.java | TagListTask.setVerifyContainNames | public void setVerifyContainNames(String names) {
if (!GitTaskUtils.isNullOrBlankString(names)) {
namesToCheck.addAll(Arrays.asList(names.split(",")));
}
else {
throw new BuildException("Invalid references names.");
}
} | java | public void setVerifyContainNames(String names) {
if (!GitTaskUtils.isNullOrBlankString(names)) {
namesToCheck.addAll(Arrays.asList(names.split(",")));
}
else {
throw new BuildException("Invalid references names.");
}
} | [
"public",
"void",
"setVerifyContainNames",
"(",
"String",
"names",
")",
"{",
"if",
"(",
"!",
"GitTaskUtils",
".",
"isNullOrBlankString",
"(",
"names",
")",
")",
"{",
"namesToCheck",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"names",
".",
"split",
"(",
"\",\"",
")",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Invalid references names.\"",
")",
";",
"}",
"}"
] | Sets the comma separated list of reference names to check in the list returned by the command
@antdoc.notrequired
@param names The command separated list of references names | [
"Sets",
"the",
"comma",
"separated",
"list",
"of",
"reference",
"names",
"to",
"check",
"in",
"the",
"list",
"returned",
"by",
"the",
"command"
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/tasks/TagListTask.java#L80-L87 |
414 | rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/tasks/TagListTask.java | TagListTask.processReferencesAndOutput | protected void processReferencesAndOutput(List<Ref> refList) {
List<String> refNames = new ArrayList<String>(refList.size());
for (Ref ref : refList) {
refNames.add(GitTaskUtils.sanitizeRefName(ref.getName()));
}
if (!namesToCheck.isEmpty()) {
if (!refNames.containsAll(namesToCheck)) {
List<String> namesCopy = new ArrayList<String>(namesToCheck);
namesCopy.removeAll(refNames);
throw new GitBuildException(String.format(MISSING_REFS_TEMPLATE, namesCopy.toString()));
}
}
if (!GitTaskUtils.isNullOrBlankString(outputFilename)) {
FileUtils fileUtils = FileUtils.getFileUtils();
Echo echo = new Echo();
echo.setProject(getProject());
echo.setFile(fileUtils.resolveFile(getProject().getBaseDir(), outputFilename));
for (int i = 0; i < refNames.size(); i++) {
String refName = refNames.get(i);
echo.addText(String.format(REF_NAME_TEMPLATE, refName));
}
echo.perform();
}
} | java | protected void processReferencesAndOutput(List<Ref> refList) {
List<String> refNames = new ArrayList<String>(refList.size());
for (Ref ref : refList) {
refNames.add(GitTaskUtils.sanitizeRefName(ref.getName()));
}
if (!namesToCheck.isEmpty()) {
if (!refNames.containsAll(namesToCheck)) {
List<String> namesCopy = new ArrayList<String>(namesToCheck);
namesCopy.removeAll(refNames);
throw new GitBuildException(String.format(MISSING_REFS_TEMPLATE, namesCopy.toString()));
}
}
if (!GitTaskUtils.isNullOrBlankString(outputFilename)) {
FileUtils fileUtils = FileUtils.getFileUtils();
Echo echo = new Echo();
echo.setProject(getProject());
echo.setFile(fileUtils.resolveFile(getProject().getBaseDir(), outputFilename));
for (int i = 0; i < refNames.size(); i++) {
String refName = refNames.get(i);
echo.addText(String.format(REF_NAME_TEMPLATE, refName));
}
echo.perform();
}
} | [
"protected",
"void",
"processReferencesAndOutput",
"(",
"List",
"<",
"Ref",
">",
"refList",
")",
"{",
"List",
"<",
"String",
">",
"refNames",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"refList",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Ref",
"ref",
":",
"refList",
")",
"{",
"refNames",
".",
"add",
"(",
"GitTaskUtils",
".",
"sanitizeRefName",
"(",
"ref",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"namesToCheck",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"!",
"refNames",
".",
"containsAll",
"(",
"namesToCheck",
")",
")",
"{",
"List",
"<",
"String",
">",
"namesCopy",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"namesToCheck",
")",
";",
"namesCopy",
".",
"removeAll",
"(",
"refNames",
")",
";",
"throw",
"new",
"GitBuildException",
"(",
"String",
".",
"format",
"(",
"MISSING_REFS_TEMPLATE",
",",
"namesCopy",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"GitTaskUtils",
".",
"isNullOrBlankString",
"(",
"outputFilename",
")",
")",
"{",
"FileUtils",
"fileUtils",
"=",
"FileUtils",
".",
"getFileUtils",
"(",
")",
";",
"Echo",
"echo",
"=",
"new",
"Echo",
"(",
")",
";",
"echo",
".",
"setProject",
"(",
"getProject",
"(",
")",
")",
";",
"echo",
".",
"setFile",
"(",
"fileUtils",
".",
"resolveFile",
"(",
"getProject",
"(",
")",
".",
"getBaseDir",
"(",
")",
",",
"outputFilename",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"refNames",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"String",
"refName",
"=",
"refNames",
".",
"get",
"(",
"i",
")",
";",
"echo",
".",
"addText",
"(",
"String",
".",
"format",
"(",
"REF_NAME_TEMPLATE",
",",
"refName",
")",
")",
";",
"}",
"echo",
".",
"perform",
"(",
")",
";",
"}",
"}"
] | Processes a list of references, check references names and output to a file if requested.
@param refList The list of references to process | [
"Processes",
"a",
"list",
"of",
"references",
"check",
"references",
"names",
"and",
"output",
"to",
"a",
"file",
"if",
"requested",
"."
] | bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/tasks/TagListTask.java#L104-L134 |
415 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/MapReduce.java | MapReduce.build | public static <T, K> MapReduceCommand<T, K> build(String map, String reduce, OutputType outputType, String collection,
Class<T> resultType, Class<K> keyType) {
return new MapReduceCommand<T, K>(map, reduce, outputType, collection, resultType, keyType);
} | java | public static <T, K> MapReduceCommand<T, K> build(String map, String reduce, OutputType outputType, String collection,
Class<T> resultType, Class<K> keyType) {
return new MapReduceCommand<T, K>(map, reduce, outputType, collection, resultType, keyType);
} | [
"public",
"static",
"<",
"T",
",",
"K",
">",
"MapReduceCommand",
"<",
"T",
",",
"K",
">",
"build",
"(",
"String",
"map",
",",
"String",
"reduce",
",",
"OutputType",
"outputType",
",",
"String",
"collection",
",",
"Class",
"<",
"T",
">",
"resultType",
",",
"Class",
"<",
"K",
">",
"keyType",
")",
"{",
"return",
"new",
"MapReduceCommand",
"<",
"T",
",",
"K",
">",
"(",
"map",
",",
"reduce",
",",
"outputType",
",",
"collection",
",",
"resultType",
",",
"keyType",
")",
";",
"}"
] | Build a map reduce command
@param map The map function
@param reduce The reduce function
@param outputType The outputType
@param collection The collection name, may be null if output type is INLINE
@param resultType The type to deserialise the result to
@param keyType The type of the keys that are being reduced on
@return The command | [
"Build",
"a",
"map",
"reduce",
"command"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/MapReduce.java#L72-L75 |
416 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/internal/util/SerializationUtils.java | SerializationUtils.serializeFields | public static DBObject serializeFields(ObjectMapper objectMapper, DBObject object) {
BasicDBObject serialised = null;
for (String field : object.keySet()) {
Object value = object.get(field);
Object serialisedValue = serializeField(objectMapper, value);
if (value != serialisedValue) {
// It's changed
if (serialised == null) {
// Make a shallow copy of the object
serialised = new BasicDBObject();
for (String f : object.keySet()) {
serialised.put(f, object.get(f));
}
}
serialised.put(field, serialisedValue);
}
}
if (serialised != null) {
return serialised;
} else {
return object;
}
} | java | public static DBObject serializeFields(ObjectMapper objectMapper, DBObject object) {
BasicDBObject serialised = null;
for (String field : object.keySet()) {
Object value = object.get(field);
Object serialisedValue = serializeField(objectMapper, value);
if (value != serialisedValue) {
// It's changed
if (serialised == null) {
// Make a shallow copy of the object
serialised = new BasicDBObject();
for (String f : object.keySet()) {
serialised.put(f, object.get(f));
}
}
serialised.put(field, serialisedValue);
}
}
if (serialised != null) {
return serialised;
} else {
return object;
}
} | [
"public",
"static",
"DBObject",
"serializeFields",
"(",
"ObjectMapper",
"objectMapper",
",",
"DBObject",
"object",
")",
"{",
"BasicDBObject",
"serialised",
"=",
"null",
";",
"for",
"(",
"String",
"field",
":",
"object",
".",
"keySet",
"(",
")",
")",
"{",
"Object",
"value",
"=",
"object",
".",
"get",
"(",
"field",
")",
";",
"Object",
"serialisedValue",
"=",
"serializeField",
"(",
"objectMapper",
",",
"value",
")",
";",
"if",
"(",
"value",
"!=",
"serialisedValue",
")",
"{",
"// It's changed",
"if",
"(",
"serialised",
"==",
"null",
")",
"{",
"// Make a shallow copy of the object",
"serialised",
"=",
"new",
"BasicDBObject",
"(",
")",
";",
"for",
"(",
"String",
"f",
":",
"object",
".",
"keySet",
"(",
")",
")",
"{",
"serialised",
".",
"put",
"(",
"f",
",",
"object",
".",
"get",
"(",
"f",
")",
")",
";",
"}",
"}",
"serialised",
".",
"put",
"(",
"field",
",",
"serialisedValue",
")",
";",
"}",
"}",
"if",
"(",
"serialised",
"!=",
"null",
")",
"{",
"return",
"serialised",
";",
"}",
"else",
"{",
"return",
"object",
";",
"}",
"}"
] | Serialize the fields of the given object using the given object mapper. This will convert POJOs to DBObjects
where necessary.
@param objectMapper The object mapper to use to do the serialization
@param object The object to serialize the fields of
@return The DBObject, safe for serialization to MongoDB | [
"Serialize",
"the",
"fields",
"of",
"the",
"given",
"object",
"using",
"the",
"given",
"object",
"mapper",
".",
"This",
"will",
"convert",
"POJOs",
"to",
"DBObjects",
"where",
"necessary",
"."
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/internal/util/SerializationUtils.java#L77-L99 |
417 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/internal/util/SerializationUtils.java | SerializationUtils.serializeField | public static Object serializeField(ObjectMapper objectMapper, Object value) {
if (value == null || BASIC_TYPES.contains(value.getClass())) {
// Return as is
return value;
} else if (value instanceof DBObject) {
return serializeFields(objectMapper, (DBObject) value);
} else if (value instanceof Collection) {
Collection<?> coll = (Collection<?>) value;
List<Object> copy = null;
int position = 0;
for (Object item : coll) {
Object returned = serializeField(objectMapper, item);
if (returned != item) {
if (copy == null) {
copy = new ArrayList<Object>(coll);
}
copy.set(position, returned);
}
position++;
}
if (copy != null) {
return copy;
} else {
return coll;
}
} else if (value.getClass().isArray()) {
if (BASIC_TYPES.contains(value.getClass().getComponentType())) {
return value;
}
Object[] array = (Object[]) value;
Object[] copy = null;
for (int i = 0; i < array.length; i++) {
Object returned = serializeField(objectMapper, array[i]);
if (returned != array[i]) {
if (copy == null) {
copy = new Object[array.length];
System.arraycopy(array, 0, copy, 0, array.length);
}
copy[i] = returned;
}
}
if (copy != null) {
return copy;
} else {
return array;
}
} else {
// We don't know what it is, serialise it
BsonObjectGenerator generator = new BsonObjectGenerator();
try {
objectMapper.writeValue(generator, value);
} catch (JsonMappingException e) {
throw new MongoJsonMappingException(e);
} catch (IOException e) {
throw new RuntimeException("Somehow got an IOException writing to memory", e);
}
return generator.getValue();
}
} | java | public static Object serializeField(ObjectMapper objectMapper, Object value) {
if (value == null || BASIC_TYPES.contains(value.getClass())) {
// Return as is
return value;
} else if (value instanceof DBObject) {
return serializeFields(objectMapper, (DBObject) value);
} else if (value instanceof Collection) {
Collection<?> coll = (Collection<?>) value;
List<Object> copy = null;
int position = 0;
for (Object item : coll) {
Object returned = serializeField(objectMapper, item);
if (returned != item) {
if (copy == null) {
copy = new ArrayList<Object>(coll);
}
copy.set(position, returned);
}
position++;
}
if (copy != null) {
return copy;
} else {
return coll;
}
} else if (value.getClass().isArray()) {
if (BASIC_TYPES.contains(value.getClass().getComponentType())) {
return value;
}
Object[] array = (Object[]) value;
Object[] copy = null;
for (int i = 0; i < array.length; i++) {
Object returned = serializeField(objectMapper, array[i]);
if (returned != array[i]) {
if (copy == null) {
copy = new Object[array.length];
System.arraycopy(array, 0, copy, 0, array.length);
}
copy[i] = returned;
}
}
if (copy != null) {
return copy;
} else {
return array;
}
} else {
// We don't know what it is, serialise it
BsonObjectGenerator generator = new BsonObjectGenerator();
try {
objectMapper.writeValue(generator, value);
} catch (JsonMappingException e) {
throw new MongoJsonMappingException(e);
} catch (IOException e) {
throw new RuntimeException("Somehow got an IOException writing to memory", e);
}
return generator.getValue();
}
} | [
"public",
"static",
"Object",
"serializeField",
"(",
"ObjectMapper",
"objectMapper",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
"||",
"BASIC_TYPES",
".",
"contains",
"(",
"value",
".",
"getClass",
"(",
")",
")",
")",
"{",
"// Return as is",
"return",
"value",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"DBObject",
")",
"{",
"return",
"serializeFields",
"(",
"objectMapper",
",",
"(",
"DBObject",
")",
"value",
")",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Collection",
")",
"{",
"Collection",
"<",
"?",
">",
"coll",
"=",
"(",
"Collection",
"<",
"?",
">",
")",
"value",
";",
"List",
"<",
"Object",
">",
"copy",
"=",
"null",
";",
"int",
"position",
"=",
"0",
";",
"for",
"(",
"Object",
"item",
":",
"coll",
")",
"{",
"Object",
"returned",
"=",
"serializeField",
"(",
"objectMapper",
",",
"item",
")",
";",
"if",
"(",
"returned",
"!=",
"item",
")",
"{",
"if",
"(",
"copy",
"==",
"null",
")",
"{",
"copy",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
"coll",
")",
";",
"}",
"copy",
".",
"set",
"(",
"position",
",",
"returned",
")",
";",
"}",
"position",
"++",
";",
"}",
"if",
"(",
"copy",
"!=",
"null",
")",
"{",
"return",
"copy",
";",
"}",
"else",
"{",
"return",
"coll",
";",
"}",
"}",
"else",
"if",
"(",
"value",
".",
"getClass",
"(",
")",
".",
"isArray",
"(",
")",
")",
"{",
"if",
"(",
"BASIC_TYPES",
".",
"contains",
"(",
"value",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
")",
")",
")",
"{",
"return",
"value",
";",
"}",
"Object",
"[",
"]",
"array",
"=",
"(",
"Object",
"[",
"]",
")",
"value",
";",
"Object",
"[",
"]",
"copy",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"Object",
"returned",
"=",
"serializeField",
"(",
"objectMapper",
",",
"array",
"[",
"i",
"]",
")",
";",
"if",
"(",
"returned",
"!=",
"array",
"[",
"i",
"]",
")",
"{",
"if",
"(",
"copy",
"==",
"null",
")",
"{",
"copy",
"=",
"new",
"Object",
"[",
"array",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"array",
",",
"0",
",",
"copy",
",",
"0",
",",
"array",
".",
"length",
")",
";",
"}",
"copy",
"[",
"i",
"]",
"=",
"returned",
";",
"}",
"}",
"if",
"(",
"copy",
"!=",
"null",
")",
"{",
"return",
"copy",
";",
"}",
"else",
"{",
"return",
"array",
";",
"}",
"}",
"else",
"{",
"// We don't know what it is, serialise it",
"BsonObjectGenerator",
"generator",
"=",
"new",
"BsonObjectGenerator",
"(",
")",
";",
"try",
"{",
"objectMapper",
".",
"writeValue",
"(",
"generator",
",",
"value",
")",
";",
"}",
"catch",
"(",
"JsonMappingException",
"e",
")",
"{",
"throw",
"new",
"MongoJsonMappingException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Somehow got an IOException writing to memory\"",
",",
"e",
")",
";",
"}",
"return",
"generator",
".",
"getValue",
"(",
")",
";",
"}",
"}"
] | Serialize the given field
@param objectMapper The object mapper to serialize it with
@param value The value to serialize
@return The serialized field. May return the same object if no serialization was necessary. | [
"Serialize",
"the",
"given",
"field"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/internal/util/SerializationUtils.java#L108-L166 |
418 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBCursor.java | DBCursor.next | public T next() throws MongoException {
executed();
current = jacksonDBCollection.convertFromDbObject(cursor.next());
return current;
} | java | public T next() throws MongoException {
executed();
current = jacksonDBCollection.convertFromDbObject(cursor.next());
return current;
} | [
"public",
"T",
"next",
"(",
")",
"throws",
"MongoException",
"{",
"executed",
"(",
")",
";",
"current",
"=",
"jacksonDBCollection",
".",
"convertFromDbObject",
"(",
"cursor",
".",
"next",
"(",
")",
")",
";",
"return",
"current",
";",
"}"
] | Returns the object the cursor is at and moves the cursor ahead by one.
@return the next element
@throws MongoException | [
"Returns",
"the",
"object",
"the",
"cursor",
"is",
"at",
"and",
"moves",
"the",
"cursor",
"ahead",
"by",
"one",
"."
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBCursor.java#L324-L328 |
419 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBCursor.java | DBCursor.toArray | public List<T> toArray(int max) throws MongoException {
executed();
if (max > all.size()) {
List<DBObject> objects = cursor.toArray(max);
for (int i = all.size(); i < objects.size(); i++) {
all.add(jacksonDBCollection.convertFromDbObject(objects.get(i)));
}
}
return all;
} | java | public List<T> toArray(int max) throws MongoException {
executed();
if (max > all.size()) {
List<DBObject> objects = cursor.toArray(max);
for (int i = all.size(); i < objects.size(); i++) {
all.add(jacksonDBCollection.convertFromDbObject(objects.get(i)));
}
}
return all;
} | [
"public",
"List",
"<",
"T",
">",
"toArray",
"(",
"int",
"max",
")",
"throws",
"MongoException",
"{",
"executed",
"(",
")",
";",
"if",
"(",
"max",
">",
"all",
".",
"size",
"(",
")",
")",
"{",
"List",
"<",
"DBObject",
">",
"objects",
"=",
"cursor",
".",
"toArray",
"(",
"max",
")",
";",
"for",
"(",
"int",
"i",
"=",
"all",
".",
"size",
"(",
")",
";",
"i",
"<",
"objects",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"all",
".",
"add",
"(",
"jacksonDBCollection",
".",
"convertFromDbObject",
"(",
"objects",
".",
"get",
"(",
"i",
")",
")",
")",
";",
"}",
"}",
"return",
"all",
";",
"}"
] | Converts this cursor to an array.
@param max the maximum number of objects to return
@return an array of objects
@throws MongoException If an error occurred | [
"Converts",
"this",
"cursor",
"to",
"an",
"array",
"."
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBCursor.java#L380-L389 |
420 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/internal/MongoAnnotationIntrospector.java | MongoAnnotationIntrospector.findSerializer | @Override
public Object findSerializer(Annotated am) {
if (am.hasAnnotation(ObjectId.class)) {
return ObjectIdSerializer.class;
}
return null;
} | java | @Override
public Object findSerializer(Annotated am) {
if (am.hasAnnotation(ObjectId.class)) {
return ObjectIdSerializer.class;
}
return null;
} | [
"@",
"Override",
"public",
"Object",
"findSerializer",
"(",
"Annotated",
"am",
")",
"{",
"if",
"(",
"am",
".",
"hasAnnotation",
"(",
"ObjectId",
".",
"class",
")",
")",
"{",
"return",
"ObjectIdSerializer",
".",
"class",
";",
"}",
"return",
"null",
";",
"}"
] | Handling of ObjectId annotated properties | [
"Handling",
"of",
"ObjectId",
"annotated",
"properties"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/internal/MongoAnnotationIntrospector.java#L83-L89 |
421 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.wrap | public static <T, K> JacksonDBCollection<T, K> wrap(DBCollection dbCollection, Class<T> type, Class<K> keyType, ObjectMapper objectMapper) {
return new JacksonDBCollection<T, K>(dbCollection, objectMapper.constructType(type),
objectMapper.constructType(keyType), objectMapper, null);
} | java | public static <T, K> JacksonDBCollection<T, K> wrap(DBCollection dbCollection, Class<T> type, Class<K> keyType, ObjectMapper objectMapper) {
return new JacksonDBCollection<T, K>(dbCollection, objectMapper.constructType(type),
objectMapper.constructType(keyType), objectMapper, null);
} | [
"public",
"static",
"<",
"T",
",",
"K",
">",
"JacksonDBCollection",
"<",
"T",
",",
"K",
">",
"wrap",
"(",
"DBCollection",
"dbCollection",
",",
"Class",
"<",
"T",
">",
"type",
",",
"Class",
"<",
"K",
">",
"keyType",
",",
"ObjectMapper",
"objectMapper",
")",
"{",
"return",
"new",
"JacksonDBCollection",
"<",
"T",
",",
"K",
">",
"(",
"dbCollection",
",",
"objectMapper",
".",
"constructType",
"(",
"type",
")",
",",
"objectMapper",
".",
"constructType",
"(",
"keyType",
")",
",",
"objectMapper",
",",
"null",
")",
";",
"}"
] | Wraps a DB collection in a JacksonDBCollection, using the given object mapper.
JacksonDBCollection requires a specially configured object mapper to work. It does not automatically configure
the object mapper passed into this method, because the same object mapper might be passed into multiple calls to
this method. Consequently, it is up to the caller to ensure that the object mapper has been configured for use
by JacksonDBCollection. This can be done by passing the object mapper to
{@link MongoJacksonMapperModule#configure(org.codehaus.jackson.map.ObjectMapper)}.
@param dbCollection The DB collection to wrap
@param type The type of objects to deserialise to
@param objectMapper The ObjectMapper to configure.
@return The wrapped collection | [
"Wraps",
"a",
"DB",
"collection",
"in",
"a",
"JacksonDBCollection",
"using",
"the",
"given",
"object",
"mapper",
"."
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L175-L178 |
422 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.enable | public JacksonDBCollection<T, K> enable(Feature feature) {
features.put(feature, true);
return this;
} | java | public JacksonDBCollection<T, K> enable(Feature feature) {
features.put(feature, true);
return this;
} | [
"public",
"JacksonDBCollection",
"<",
"T",
",",
"K",
">",
"enable",
"(",
"Feature",
"feature",
")",
"{",
"features",
".",
"put",
"(",
"feature",
",",
"true",
")",
";",
"return",
"this",
";",
"}"
] | Enable the given feature
@param feature The feature to enable
@return this object | [
"Enable",
"the",
"given",
"feature"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L186-L189 |
423 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.disable | public JacksonDBCollection<T, K> disable(Feature feature) {
features.put(feature, false);
return this;
} | java | public JacksonDBCollection<T, K> disable(Feature feature) {
features.put(feature, false);
return this;
} | [
"public",
"JacksonDBCollection",
"<",
"T",
",",
"K",
">",
"disable",
"(",
"Feature",
"feature",
")",
"{",
"features",
".",
"put",
"(",
"feature",
",",
"false",
")",
";",
"return",
"this",
";",
"}"
] | Disable the given feature
@param feature The feature to disable
@return this object | [
"Disable",
"the",
"given",
"feature"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L197-L200 |
424 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.isEnabled | public boolean isEnabled(Feature feature) {
Boolean enabled = features.get(feature);
if (enabled == null) {
return feature.isEnabledByDefault();
} else {
return enabled;
}
} | java | public boolean isEnabled(Feature feature) {
Boolean enabled = features.get(feature);
if (enabled == null) {
return feature.isEnabledByDefault();
} else {
return enabled;
}
} | [
"public",
"boolean",
"isEnabled",
"(",
"Feature",
"feature",
")",
"{",
"Boolean",
"enabled",
"=",
"features",
".",
"get",
"(",
"feature",
")",
";",
"if",
"(",
"enabled",
"==",
"null",
")",
"{",
"return",
"feature",
".",
"isEnabledByDefault",
"(",
")",
";",
"}",
"else",
"{",
"return",
"enabled",
";",
"}",
"}"
] | Whether the given feature is enabled
@param feature The feature to check
@return whether it is enabled | [
"Whether",
"the",
"given",
"feature",
"is",
"enabled"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L208-L215 |
425 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.createIndex | public void createIndex(DBObject keys, DBObject options) throws MongoException {
dbCollection.createIndex(keys, options);
} | java | public void createIndex(DBObject keys, DBObject options) throws MongoException {
dbCollection.createIndex(keys, options);
} | [
"public",
"void",
"createIndex",
"(",
"DBObject",
"keys",
",",
"DBObject",
"options",
")",
"throws",
"MongoException",
"{",
"dbCollection",
".",
"createIndex",
"(",
"keys",
",",
"options",
")",
";",
"}"
] | Forces creation of an index on a set of fields, if one does not already exist.
@param keys The keys to index
@param options The options
@throws MongoException If an error occurred | [
"Forces",
"creation",
"of",
"an",
"index",
"on",
"a",
"set",
"of",
"fields",
"if",
"one",
"does",
"not",
"already",
"exist",
"."
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L680-L682 |
426 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.ensureIndex | public void ensureIndex(final DBObject keys, final DBObject optionsIN) throws MongoException {
dbCollection.ensureIndex(keys, optionsIN);
} | java | public void ensureIndex(final DBObject keys, final DBObject optionsIN) throws MongoException {
dbCollection.ensureIndex(keys, optionsIN);
} | [
"public",
"void",
"ensureIndex",
"(",
"final",
"DBObject",
"keys",
",",
"final",
"DBObject",
"optionsIN",
")",
"throws",
"MongoException",
"{",
"dbCollection",
".",
"ensureIndex",
"(",
"keys",
",",
"optionsIN",
")",
";",
"}"
] | Creates an index on a set of fields, if one does not already exist.
@param keys an object with a key set of the fields desired for the index
@param optionsIN options for the index (name, unique, etc)
@throws MongoException If an error occurred | [
"Creates",
"an",
"index",
"on",
"a",
"set",
"of",
"fields",
"if",
"one",
"does",
"not",
"already",
"exist",
"."
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L733-L735 |
427 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.rename | public JacksonDBCollection<T, K> rename(String newName, boolean dropTarget) throws MongoException {
return new JacksonDBCollection<T, K>(dbCollection.rename(newName, dropTarget), type, keyType, objectMapper, features);
} | java | public JacksonDBCollection<T, K> rename(String newName, boolean dropTarget) throws MongoException {
return new JacksonDBCollection<T, K>(dbCollection.rename(newName, dropTarget), type, keyType, objectMapper, features);
} | [
"public",
"JacksonDBCollection",
"<",
"T",
",",
"K",
">",
"rename",
"(",
"String",
"newName",
",",
"boolean",
"dropTarget",
")",
"throws",
"MongoException",
"{",
"return",
"new",
"JacksonDBCollection",
"<",
"T",
",",
"K",
">",
"(",
"dbCollection",
".",
"rename",
"(",
"newName",
",",
"dropTarget",
")",
",",
"type",
",",
"keyType",
",",
"objectMapper",
",",
"features",
")",
";",
"}"
] | renames of this collection to newName
@param newName new collection name (not a full namespace)
@param dropTarget if a collection with the new name exists, whether or not to drop it
@return the new collection
@throws MongoException If an error occurred | [
"renames",
"of",
"this",
"collection",
"to",
"newName"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L1173-L1175 |
428 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.group | public DBObject group(DBObject key, DBObject cond, DBObject initial, String reduce, String finalize)
throws MongoException {
GroupCommand cmd = new GroupCommand(dbCollection, key, cond, initial, reduce, finalize);
return group(cmd);
} | java | public DBObject group(DBObject key, DBObject cond, DBObject initial, String reduce, String finalize)
throws MongoException {
GroupCommand cmd = new GroupCommand(dbCollection, key, cond, initial, reduce, finalize);
return group(cmd);
} | [
"public",
"DBObject",
"group",
"(",
"DBObject",
"key",
",",
"DBObject",
"cond",
",",
"DBObject",
"initial",
",",
"String",
"reduce",
",",
"String",
"finalize",
")",
"throws",
"MongoException",
"{",
"GroupCommand",
"cmd",
"=",
"new",
"GroupCommand",
"(",
"dbCollection",
",",
"key",
",",
"cond",
",",
"initial",
",",
"reduce",
",",
"finalize",
")",
";",
"return",
"group",
"(",
"cmd",
")",
";",
"}"
] | Applies a group operation
@param key - { a : true }
@param cond - optional condition on query
@param reduce javascript reduce function
@param initial initial value for first match on a key
@param finalize An optional function that can operate on the result(s) of the reduce function.
@return The results
@throws MongoException If an error occurred
@see <a href="http://www.mongodb.org/display/DOCS/Aggregation">http://www.mongodb.org/display/DOCS/Aggregation</a> | [
"Applies",
"a",
"group",
"operation"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L1204-L1208 |
429 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.distinct | public List distinct(String key, DBObject query) {
return dbCollection.distinct(key, serializeFields(query));
} | java | public List distinct(String key, DBObject query) {
return dbCollection.distinct(key, serializeFields(query));
} | [
"public",
"List",
"distinct",
"(",
"String",
"key",
",",
"DBObject",
"query",
")",
"{",
"return",
"dbCollection",
".",
"distinct",
"(",
"key",
",",
"serializeFields",
"(",
"query",
")",
")",
";",
"}"
] | find distinct values for a key
@param key The key
@param query query to match
@return The results | [
"find",
"distinct",
"values",
"for",
"a",
"key"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L1239-L1241 |
430 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.mapReduce | @Deprecated
public com.mongodb.MapReduceOutput mapReduce(MapReduceCommand command) throws MongoException {
return dbCollection.mapReduce(command);
} | java | @Deprecated
public com.mongodb.MapReduceOutput mapReduce(MapReduceCommand command) throws MongoException {
return dbCollection.mapReduce(command);
} | [
"@",
"Deprecated",
"public",
"com",
".",
"mongodb",
".",
"MapReduceOutput",
"mapReduce",
"(",
"MapReduceCommand",
"command",
")",
"throws",
"MongoException",
"{",
"return",
"dbCollection",
".",
"mapReduce",
"(",
"command",
")",
";",
"}"
] | performs a map reduce operation
@param command object representing the parameters
@return The results
@throws MongoException If an error occurred | [
"performs",
"a",
"map",
"reduce",
"operation"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L1289-L1292 |
431 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.mapReduce | public <S, L> MapReduceOutput<S, L> mapReduce(MapReduce.MapReduceCommand<S, L> command) throws MongoException {
return new MapReduceOutput<S, L>(this, dbCollection.mapReduce(command.build(this)), command.getResultType(),
command.getKeyType());
} | java | public <S, L> MapReduceOutput<S, L> mapReduce(MapReduce.MapReduceCommand<S, L> command) throws MongoException {
return new MapReduceOutput<S, L>(this, dbCollection.mapReduce(command.build(this)), command.getResultType(),
command.getKeyType());
} | [
"public",
"<",
"S",
",",
"L",
">",
"MapReduceOutput",
"<",
"S",
",",
"L",
">",
"mapReduce",
"(",
"MapReduce",
".",
"MapReduceCommand",
"<",
"S",
",",
"L",
">",
"command",
")",
"throws",
"MongoException",
"{",
"return",
"new",
"MapReduceOutput",
"<",
"S",
",",
"L",
">",
"(",
"this",
",",
"dbCollection",
".",
"mapReduce",
"(",
"command",
".",
"build",
"(",
"this",
")",
")",
",",
"command",
".",
"getResultType",
"(",
")",
",",
"command",
".",
"getKeyType",
"(",
")",
")",
";",
"}"
] | Performs a map reduce operation
@param command The command to execute
@return The output
@throws MongoException If an error occurred | [
"Performs",
"a",
"map",
"reduce",
"operation"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L1313-L1316 |
432 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBUpdate.java | DBUpdate.push | public static Builder push(String field, Object value) {
return new Builder().push(field, value);
} | java | public static Builder push(String field, Object value) {
return new Builder().push(field, value);
} | [
"public",
"static",
"Builder",
"push",
"(",
"String",
"field",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
".",
"push",
"(",
"field",
",",
"value",
")",
";",
"}"
] | Add the given value to the array value at the specified field atomically
@param field The field to add the value to
@param value The value to add
@return this object | [
"Add",
"the",
"given",
"value",
"to",
"the",
"array",
"value",
"at",
"the",
"specified",
"field",
"atomically"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBUpdate.java#L90-L92 |
433 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBUpdate.java | DBUpdate.addToSet | public static Builder addToSet(String field, Object value) {
return new Builder().addToSet(field, value);
} | java | public static Builder addToSet(String field, Object value) {
return new Builder().addToSet(field, value);
} | [
"public",
"static",
"Builder",
"addToSet",
"(",
"String",
"field",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
".",
"addToSet",
"(",
"field",
",",
"value",
")",
";",
"}"
] | Add the given value to the array value if it doesn't already exist in the specified field atomically
@param field The field to add the value to
@param value The value to add
@return this object | [
"Add",
"the",
"given",
"value",
"to",
"the",
"array",
"value",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"in",
"the",
"specified",
"field",
"atomically"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBUpdate.java#L123-L125 |
434 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBUpdate.java | DBUpdate.pull | public static Builder pull(String field, Object value) {
return new Builder().pull(field, value);
} | java | public static Builder pull(String field, Object value) {
return new Builder().pull(field, value);
} | [
"public",
"static",
"Builder",
"pull",
"(",
"String",
"field",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
".",
"pull",
"(",
"field",
",",
"value",
")",
";",
"}"
] | Remove all occurances of value from the array at field
@param field The field to remove the value from
@param value The value to remove. This may be another query.
@return this object | [
"Remove",
"all",
"occurances",
"of",
"value",
"from",
"the",
"array",
"at",
"field"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBUpdate.java#L176-L178 |
435 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBUpdate.java | DBUpdate.rename | public static Builder rename(String oldFieldName, String newFieldName) {
return new Builder().rename(oldFieldName, newFieldName);
} | java | public static Builder rename(String oldFieldName, String newFieldName) {
return new Builder().rename(oldFieldName, newFieldName);
} | [
"public",
"static",
"Builder",
"rename",
"(",
"String",
"oldFieldName",
",",
"String",
"newFieldName",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
".",
"rename",
"(",
"oldFieldName",
",",
"newFieldName",
")",
";",
"}"
] | Rename the given field to the new field name
@param oldFieldName The old field name
@param newFieldName The new field name
@return this object | [
"Rename",
"the",
"given",
"field",
"to",
"the",
"new",
"field",
"name"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBUpdate.java#L209-L211 |
436 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBUpdate.java | DBUpdate.bit | public static Builder bit(String field, String operation, int value) {
return new Builder().bit(field, operation, value);
} | java | public static Builder bit(String field, String operation, int value) {
return new Builder().bit(field, operation, value);
} | [
"public",
"static",
"Builder",
"bit",
"(",
"String",
"field",
",",
"String",
"operation",
",",
"int",
"value",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
".",
"bit",
"(",
"field",
",",
"operation",
",",
"value",
")",
";",
"}"
] | Perform a bit operation on the given field
@param field The field to perform the operation on
@param operation The operation to perform
@param value The value
@return this object | [
"Perform",
"a",
"bit",
"operation",
"on",
"the",
"given",
"field"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBUpdate.java#L221-L223 |
437 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBUpdate.java | DBUpdate.bit | public static Builder bit(String field, String operation1, int value1, String operation2, int value2) {
return new Builder().bit(field, operation1, value1, operation2, value2);
} | java | public static Builder bit(String field, String operation1, int value1, String operation2, int value2) {
return new Builder().bit(field, operation1, value1, operation2, value2);
} | [
"public",
"static",
"Builder",
"bit",
"(",
"String",
"field",
",",
"String",
"operation1",
",",
"int",
"value1",
",",
"String",
"operation2",
",",
"int",
"value2",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
".",
"bit",
"(",
"field",
",",
"operation1",
",",
"value1",
",",
"operation2",
",",
"value2",
")",
";",
"}"
] | Perform two bit operations on the given field
@param field The field to perform the operations on
@param operation1 The first operation to perform
@param value1 The first value
@param operation2 The second operation to perform
@param value2 The second value
@return this object | [
"Perform",
"two",
"bit",
"operations",
"on",
"the",
"given",
"field"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBUpdate.java#L235-L237 |
438 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/WriteResult.java | WriteResult.getSavedId | public K getSavedId() {
if (dbObjects.length == 0) {
throw new MongoException("No objects to return");
}
if (dbObjects[0] instanceof JacksonDBObject) {
throw new UnsupportedOperationException("Generated _id retrieval not supported when using stream serialization");
}
return jacksonDBCollection.convertFromDbId(dbObjects[0].get("_id"));
} | java | public K getSavedId() {
if (dbObjects.length == 0) {
throw new MongoException("No objects to return");
}
if (dbObjects[0] instanceof JacksonDBObject) {
throw new UnsupportedOperationException("Generated _id retrieval not supported when using stream serialization");
}
return jacksonDBCollection.convertFromDbId(dbObjects[0].get("_id"));
} | [
"public",
"K",
"getSavedId",
"(",
")",
"{",
"if",
"(",
"dbObjects",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"MongoException",
"(",
"\"No objects to return\"",
")",
";",
"}",
"if",
"(",
"dbObjects",
"[",
"0",
"]",
"instanceof",
"JacksonDBObject",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Generated _id retrieval not supported when using stream serialization\"",
")",
";",
"}",
"return",
"jacksonDBCollection",
".",
"convertFromDbId",
"(",
"dbObjects",
"[",
"0",
"]",
".",
"get",
"(",
"\"_id\"",
")",
")",
";",
"}"
] | Get the saved ID. This may be useful for finding out the ID that was generated by MongoDB if no ID was supplied.
@return The saved ID
@throws MongoException If no objects were saved | [
"Get",
"the",
"saved",
"ID",
".",
"This",
"may",
"be",
"useful",
"for",
"finding",
"out",
"the",
"ID",
"that",
"was",
"generated",
"by",
"MongoDB",
"if",
"no",
"ID",
"was",
"supplied",
"."
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/WriteResult.java#L98-L106 |
439 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/WriteResult.java | WriteResult.getSavedIds | public List<K> getSavedIds() {
if (dbObjects.length > 0 && dbObjects[0] instanceof JacksonDBObject) {
throw new UnsupportedOperationException("Generated _id retrieval not supported when using stream serialization");
}
List<K> ids = new ArrayList<K>();
for (int i = 0; i < dbObjects.length; i++) {
ids.add((K) jacksonDBCollection.convertFromDbId(dbObjects[i].get("_id")));
}
return ids;
} | java | public List<K> getSavedIds() {
if (dbObjects.length > 0 && dbObjects[0] instanceof JacksonDBObject) {
throw new UnsupportedOperationException("Generated _id retrieval not supported when using stream serialization");
}
List<K> ids = new ArrayList<K>();
for (int i = 0; i < dbObjects.length; i++) {
ids.add((K) jacksonDBCollection.convertFromDbId(dbObjects[i].get("_id")));
}
return ids;
} | [
"public",
"List",
"<",
"K",
">",
"getSavedIds",
"(",
")",
"{",
"if",
"(",
"dbObjects",
".",
"length",
">",
"0",
"&&",
"dbObjects",
"[",
"0",
"]",
"instanceof",
"JacksonDBObject",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Generated _id retrieval not supported when using stream serialization\"",
")",
";",
"}",
"List",
"<",
"K",
">",
"ids",
"=",
"new",
"ArrayList",
"<",
"K",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"dbObjects",
".",
"length",
";",
"i",
"++",
")",
"{",
"ids",
".",
"add",
"(",
"(",
"K",
")",
"jacksonDBCollection",
".",
"convertFromDbId",
"(",
"dbObjects",
"[",
"i",
"]",
".",
"get",
"(",
"\"_id\"",
")",
")",
")",
";",
"}",
"return",
"ids",
";",
"}"
] | Get the saved IDs. This may be useful for finding out the IDs that were generated by MongoDB if no IDs were
supplied.
@return The saved IDs | [
"Get",
"the",
"saved",
"IDs",
".",
"This",
"may",
"be",
"useful",
"for",
"finding",
"out",
"the",
"IDs",
"that",
"were",
"generated",
"by",
"MongoDB",
"if",
"no",
"IDs",
"were",
"supplied",
"."
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/WriteResult.java#L115-L126 |
440 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBQuery.java | DBQuery.is | public static Query is(String field, Object value) {
return new Query().is(field, value);
} | java | public static Query is(String field, Object value) {
return new Query().is(field, value);
} | [
"public",
"static",
"Query",
"is",
"(",
"String",
"field",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Query",
"(",
")",
".",
"is",
"(",
"field",
",",
"value",
")",
";",
"}"
] | The field is equal to the given value
@param field The field to compare
@param value The value to compare to
@return the query | [
"The",
"field",
"is",
"equal",
"to",
"the",
"given",
"value"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBQuery.java#L51-L53 |
441 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBQuery.java | DBQuery.lessThan | public static Query lessThan(String field, Object value) {
return new Query().lessThan(field, value);
} | java | public static Query lessThan(String field, Object value) {
return new Query().lessThan(field, value);
} | [
"public",
"static",
"Query",
"lessThan",
"(",
"String",
"field",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Query",
"(",
")",
".",
"lessThan",
"(",
"field",
",",
"value",
")",
";",
"}"
] | The field is less than the given value
@param field The field to compare
@param value The value to compare to
@return the query | [
"The",
"field",
"is",
"less",
"than",
"the",
"given",
"value"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBQuery.java#L62-L64 |
442 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBQuery.java | DBQuery.lessThanEquals | public static Query lessThanEquals(String field, Object value) {
return new Query().lessThanEquals(field, value);
} | java | public static Query lessThanEquals(String field, Object value) {
return new Query().lessThanEquals(field, value);
} | [
"public",
"static",
"Query",
"lessThanEquals",
"(",
"String",
"field",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Query",
"(",
")",
".",
"lessThanEquals",
"(",
"field",
",",
"value",
")",
";",
"}"
] | The field is less than or equal to the given value
@param field The field to compare
@param value The value to compare to
@return the query | [
"The",
"field",
"is",
"less",
"than",
"or",
"equal",
"to",
"the",
"given",
"value"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBQuery.java#L73-L75 |
443 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBQuery.java | DBQuery.greaterThan | public static Query greaterThan(String field, Object value) {
return new Query().greaterThan(field, value);
} | java | public static Query greaterThan(String field, Object value) {
return new Query().greaterThan(field, value);
} | [
"public",
"static",
"Query",
"greaterThan",
"(",
"String",
"field",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Query",
"(",
")",
".",
"greaterThan",
"(",
"field",
",",
"value",
")",
";",
"}"
] | The field is greater than the given value
@param field The field to compare
@param value The value to compare to
@return the query | [
"The",
"field",
"is",
"greater",
"than",
"the",
"given",
"value"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBQuery.java#L84-L86 |
444 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBQuery.java | DBQuery.greaterThanEquals | public static Query greaterThanEquals(String field, Object value) {
return new Query().greaterThanEquals(field, value);
} | java | public static Query greaterThanEquals(String field, Object value) {
return new Query().greaterThanEquals(field, value);
} | [
"public",
"static",
"Query",
"greaterThanEquals",
"(",
"String",
"field",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Query",
"(",
")",
".",
"greaterThanEquals",
"(",
"field",
",",
"value",
")",
";",
"}"
] | The field is greater than or equal to the given value
@param field The field to compare
@param value The value to compare to
@return the query | [
"The",
"field",
"is",
"greater",
"than",
"or",
"equal",
"to",
"the",
"given",
"value"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBQuery.java#L95-L97 |
445 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBQuery.java | DBQuery.notEquals | public static Query notEquals(String field, Object value) {
return new Query().notEquals(field, value);
} | java | public static Query notEquals(String field, Object value) {
return new Query().notEquals(field, value);
} | [
"public",
"static",
"Query",
"notEquals",
"(",
"String",
"field",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Query",
"(",
")",
".",
"notEquals",
"(",
"field",
",",
"value",
")",
";",
"}"
] | The field is not equal to the given value
@param field The field to compare
@param value The value to compare to
@return the query | [
"The",
"field",
"is",
"not",
"equal",
"to",
"the",
"given",
"value"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBQuery.java#L106-L108 |
446 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBQuery.java | DBQuery.mod | public static Query mod(String field, Number mod, Number value) {
return new Query().mod(field, mod, value);
} | java | public static Query mod(String field, Number mod, Number value) {
return new Query().mod(field, mod, value);
} | [
"public",
"static",
"Query",
"mod",
"(",
"String",
"field",
",",
"Number",
"mod",
",",
"Number",
"value",
")",
"{",
"return",
"new",
"Query",
"(",
")",
".",
"mod",
"(",
"field",
",",
"mod",
",",
"value",
")",
";",
"}"
] | The field, modulo the given mod argument, is equal to the value
@param field The field to compare
@param mod The modulo
@param value The value to compare to
@return the query | [
"The",
"field",
"modulo",
"the",
"given",
"mod",
"argument",
"is",
"equal",
"to",
"the",
"value"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBQuery.java#L162-L164 |
447 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBQuery.java | DBQuery.regex | public static Query regex(String field, Pattern regex) {
return new Query().regex(field, regex);
} | java | public static Query regex(String field, Pattern regex) {
return new Query().regex(field, regex);
} | [
"public",
"static",
"Query",
"regex",
"(",
"String",
"field",
",",
"Pattern",
"regex",
")",
"{",
"return",
"new",
"Query",
"(",
")",
".",
"regex",
"(",
"field",
",",
"regex",
")",
";",
"}"
] | The given field matches the regular expression
@param field The field to comare
@param regex The regular expression to match with
@return the query | [
"The",
"given",
"field",
"matches",
"the",
"regular",
"expression"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBQuery.java#L256-L258 |
448 | vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/DBQuery.java | DBQuery.elemMatch | public static Query elemMatch(String field, Query query) {
return new Query().elemMatch(field, query);
} | java | public static Query elemMatch(String field, Query query) {
return new Query().elemMatch(field, query);
} | [
"public",
"static",
"Query",
"elemMatch",
"(",
"String",
"field",
",",
"Query",
"query",
")",
"{",
"return",
"new",
"Query",
"(",
")",
".",
"elemMatch",
"(",
"field",
",",
"query",
")",
";",
"}"
] | An element in the given array field matches the given query
@param field the array field
@param query The query to attempt to match against the elements of the array field
@return the query | [
"An",
"element",
"in",
"the",
"given",
"array",
"field",
"matches",
"the",
"given",
"query"
] | ecd189aefa89636cddf70fb383f5d676be347976 | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/DBQuery.java#L267-L269 |
449 | duracloud/mill | common-dup/src/main/java/org/duracloud/mill/dup/DuplicationPolicyManager.java | DuplicationPolicyManager.readDupAccounts | private List<String> readDupAccounts(InputStream dupAccountsStream)
throws IOException {
ObjectMapper objMapper = new ObjectMapper();
return objMapper.readValue(
dupAccountsStream,
new TypeReference<List<String>>() {
});
} | java | private List<String> readDupAccounts(InputStream dupAccountsStream)
throws IOException {
ObjectMapper objMapper = new ObjectMapper();
return objMapper.readValue(
dupAccountsStream,
new TypeReference<List<String>>() {
});
} | [
"private",
"List",
"<",
"String",
">",
"readDupAccounts",
"(",
"InputStream",
"dupAccountsStream",
")",
"throws",
"IOException",
"{",
"ObjectMapper",
"objMapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"return",
"objMapper",
".",
"readValue",
"(",
"dupAccountsStream",
",",
"new",
"TypeReference",
"<",
"List",
"<",
"String",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}"
] | Reads duplication account listing. File is expected to be a JSON
formatted list of String values.
@param dupAccountsStream stream
@return list of duplication accounts
@throws IOException | [
"Reads",
"duplication",
"account",
"listing",
".",
"File",
"is",
"expected",
"to",
"be",
"a",
"JSON",
"formatted",
"list",
"of",
"String",
"values",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/common-dup/src/main/java/org/duracloud/mill/dup/DuplicationPolicyManager.java#L62-L69 |
450 | duracloud/mill | workman/src/main/java/org/duracloud/mill/workman/TaskWorkerImpl.java | TaskWorkerImpl.init | protected void init() {
log.debug("taskworker {} initializing...", this);
scheduleVisibilityTimeoutExtender(task, new Date(), task.getVisibilityTimeout());
log.debug("taskworker {} initialized", this);
initialized = true;
} | java | protected void init() {
log.debug("taskworker {} initializing...", this);
scheduleVisibilityTimeoutExtender(task, new Date(), task.getVisibilityTimeout());
log.debug("taskworker {} initialized", this);
initialized = true;
} | [
"protected",
"void",
"init",
"(",
")",
"{",
"log",
".",
"debug",
"(",
"\"taskworker {} initializing...\"",
",",
"this",
")",
";",
"scheduleVisibilityTimeoutExtender",
"(",
"task",
",",
"new",
"Date",
"(",
")",
",",
"task",
".",
"getVisibilityTimeout",
"(",
")",
")",
";",
"log",
".",
"debug",
"(",
"\"taskworker {} initialized\"",
",",
"this",
")",
";",
"initialized",
"=",
"true",
";",
"}"
] | This method be called before run since it is possible that there may be significant
delay between when the TaskWorker is initialized and when it is executed. | [
"This",
"method",
"be",
"called",
"before",
"run",
"since",
"it",
"is",
"possible",
"that",
"there",
"may",
"be",
"significant",
"delay",
"between",
"when",
"the",
"TaskWorker",
"is",
"initialized",
"and",
"when",
"it",
"is",
"executed",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/workman/src/main/java/org/duracloud/mill/workman/TaskWorkerImpl.java#L109-L117 |
451 | inaiat/jqplot4java | src/main/java/br/com/digilabs/jqplot/ChartConfiguration.java | ChartConfiguration.setSimpleTitle | public ChartConfiguration<T> setSimpleTitle(String title) {
if (title == null) {
this.title = new Title(title);
} else {
this.title.setText(title);
}
return this;
} | java | public ChartConfiguration<T> setSimpleTitle(String title) {
if (title == null) {
this.title = new Title(title);
} else {
this.title.setText(title);
}
return this;
} | [
"public",
"ChartConfiguration",
"<",
"T",
">",
"setSimpleTitle",
"(",
"String",
"title",
")",
"{",
"if",
"(",
"title",
"==",
"null",
")",
"{",
"this",
".",
"title",
"=",
"new",
"Title",
"(",
"title",
")",
";",
"}",
"else",
"{",
"this",
".",
"title",
".",
"setText",
"(",
"title",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the simple title.
@param title
the new simple title
@return ChartConfiguration | [
"Sets",
"the",
"simple",
"title",
"."
] | 35bcd17749442e88695df0438c8330a65a3977cc | https://github.com/inaiat/jqplot4java/blob/35bcd17749442e88695df0438c8330a65a3977cc/src/main/java/br/com/digilabs/jqplot/ChartConfiguration.java#L149-L156 |
452 | inaiat/jqplot4java | src/main/java/br/com/digilabs/jqplot/ChartConfiguration.java | ChartConfiguration.setLabelX | public ChartConfiguration<T> setLabelX(String label) {
if (label != null) {
axesInstance().xAxisInstance().setLabel(label);
}
return this;
} | java | public ChartConfiguration<T> setLabelX(String label) {
if (label != null) {
axesInstance().xAxisInstance().setLabel(label);
}
return this;
} | [
"public",
"ChartConfiguration",
"<",
"T",
">",
"setLabelX",
"(",
"String",
"label",
")",
"{",
"if",
"(",
"label",
"!=",
"null",
")",
"{",
"axesInstance",
"(",
")",
".",
"xAxisInstance",
"(",
")",
".",
"setLabel",
"(",
"label",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the label x.
@param label
the new label x
@return ChartConfiguration | [
"Sets",
"the",
"label",
"x",
"."
] | 35bcd17749442e88695df0438c8330a65a3977cc | https://github.com/inaiat/jqplot4java/blob/35bcd17749442e88695df0438c8330a65a3977cc/src/main/java/br/com/digilabs/jqplot/ChartConfiguration.java#L314-L319 |
453 | inaiat/jqplot4java | src/main/java/br/com/digilabs/jqplot/ChartConfiguration.java | ChartConfiguration.setLabelY | public ChartConfiguration<T> setLabelY(String label) {
if (label != null) {
axesInstance().yAxisInstance().setLabel(label);
}
return this;
} | java | public ChartConfiguration<T> setLabelY(String label) {
if (label != null) {
axesInstance().yAxisInstance().setLabel(label);
}
return this;
} | [
"public",
"ChartConfiguration",
"<",
"T",
">",
"setLabelY",
"(",
"String",
"label",
")",
"{",
"if",
"(",
"label",
"!=",
"null",
")",
"{",
"axesInstance",
"(",
")",
".",
"yAxisInstance",
"(",
")",
".",
"setLabel",
"(",
"label",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the label y.
@param label
the new label y
@return ChartConfiguration | [
"Sets",
"the",
"label",
"y",
"."
] | 35bcd17749442e88695df0438c8330a65a3977cc | https://github.com/inaiat/jqplot4java/blob/35bcd17749442e88695df0438c8330a65a3977cc/src/main/java/br/com/digilabs/jqplot/ChartConfiguration.java#L328-L333 |
454 | bingoohuang/westcache | src/main/java/com/github/bingoohuang/westcache/WestCacheFactory.java | WestCacheFactory.create | @SuppressWarnings("unchecked")
public static <T> T create(T target) {
if (target instanceof WestCacheCglib) return target;
val in = new CglibCacheMethodInterceptor(target);
return (T) Cglibs.proxy(target.getClass(), in, WestCacheCglib.class);
} | java | @SuppressWarnings("unchecked")
public static <T> T create(T target) {
if (target instanceof WestCacheCglib) return target;
val in = new CglibCacheMethodInterceptor(target);
return (T) Cglibs.proxy(target.getClass(), in, WestCacheCglib.class);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"create",
"(",
"T",
"target",
")",
"{",
"if",
"(",
"target",
"instanceof",
"WestCacheCglib",
")",
"return",
"target",
";",
"val",
"in",
"=",
"new",
"CglibCacheMethodInterceptor",
"(",
"target",
")",
";",
"return",
"(",
"T",
")",
"Cglibs",
".",
"proxy",
"(",
"target",
".",
"getClass",
"(",
")",
",",
"in",
",",
"WestCacheCglib",
".",
"class",
")",
";",
"}"
] | Create a proxied object of target object.
@param target target object.
@param <T> target class.
@return proxied object. | [
"Create",
"a",
"proxied",
"object",
"of",
"target",
"object",
"."
] | 09842bf0b9299abe75551c4b51d326fcc96da42d | https://github.com/bingoohuang/westcache/blob/09842bf0b9299abe75551c4b51d326fcc96da42d/src/main/java/com/github/bingoohuang/westcache/WestCacheFactory.java#L53-L59 |
455 | duracloud/mill | workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java | DuplicationTaskProcessor.spaceExists | private boolean spaceExists(final StorageProvider store,
final String spaceId)
throws TaskExecutionFailedException {
try {
return new Retrier().execute(new Retriable() {
@Override
public Boolean retry() throws Exception {
// The actual method being executed
store.getSpaceProperties(spaceId);
return true;
}
});
} catch (NotFoundException nfe) {
return false;
} catch (Exception e) {
String msg = "Error attempting to check if space exists: " +
e.getMessage();
throw new DuplicationTaskExecutionFailedException(
buildFailureMessage(msg), e);
}
} | java | private boolean spaceExists(final StorageProvider store,
final String spaceId)
throws TaskExecutionFailedException {
try {
return new Retrier().execute(new Retriable() {
@Override
public Boolean retry() throws Exception {
// The actual method being executed
store.getSpaceProperties(spaceId);
return true;
}
});
} catch (NotFoundException nfe) {
return false;
} catch (Exception e) {
String msg = "Error attempting to check if space exists: " +
e.getMessage();
throw new DuplicationTaskExecutionFailedException(
buildFailureMessage(msg), e);
}
} | [
"private",
"boolean",
"spaceExists",
"(",
"final",
"StorageProvider",
"store",
",",
"final",
"String",
"spaceId",
")",
"throws",
"TaskExecutionFailedException",
"{",
"try",
"{",
"return",
"new",
"Retrier",
"(",
")",
".",
"execute",
"(",
"new",
"Retriable",
"(",
")",
"{",
"@",
"Override",
"public",
"Boolean",
"retry",
"(",
")",
"throws",
"Exception",
"{",
"// The actual method being executed",
"store",
".",
"getSpaceProperties",
"(",
"spaceId",
")",
";",
"return",
"true",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"nfe",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"msg",
"=",
"\"Error attempting to check if space exists: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"DuplicationTaskExecutionFailedException",
"(",
"buildFailureMessage",
"(",
"msg",
")",
",",
"e",
")",
";",
"}",
"}"
] | Determines if a space in the given store exists.
@param store the storage provider in which to check the space
@param spaceId space to check
@return true if space exists, false otherwise | [
"Determines",
"if",
"a",
"space",
"in",
"the",
"given",
"store",
"exists",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java#L167-L187 |
456 | duracloud/mill | workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java | DuplicationTaskProcessor.getSpaceListing | private Iterator<String> getSpaceListing(final StorageProvider store,
final String spaceId)
throws TaskExecutionFailedException {
try {
return new Retrier().execute(new Retriable() {
@Override
public Iterator<String> retry() throws Exception {
// The actual method being executed
return store.getSpaceContents(spaceId, null);
}
});
} catch (Exception e) {
String msg = "Error attempting to retrieve space listing: " +
e.getMessage();
throw new DuplicationTaskExecutionFailedException(
buildFailureMessage(msg), e);
}
} | java | private Iterator<String> getSpaceListing(final StorageProvider store,
final String spaceId)
throws TaskExecutionFailedException {
try {
return new Retrier().execute(new Retriable() {
@Override
public Iterator<String> retry() throws Exception {
// The actual method being executed
return store.getSpaceContents(spaceId, null);
}
});
} catch (Exception e) {
String msg = "Error attempting to retrieve space listing: " +
e.getMessage();
throw new DuplicationTaskExecutionFailedException(
buildFailureMessage(msg), e);
}
} | [
"private",
"Iterator",
"<",
"String",
">",
"getSpaceListing",
"(",
"final",
"StorageProvider",
"store",
",",
"final",
"String",
"spaceId",
")",
"throws",
"TaskExecutionFailedException",
"{",
"try",
"{",
"return",
"new",
"Retrier",
"(",
")",
".",
"execute",
"(",
"new",
"Retriable",
"(",
")",
"{",
"@",
"Override",
"public",
"Iterator",
"<",
"String",
">",
"retry",
"(",
")",
"throws",
"Exception",
"{",
"// The actual method being executed",
"return",
"store",
".",
"getSpaceContents",
"(",
"spaceId",
",",
"null",
")",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"msg",
"=",
"\"Error attempting to retrieve space listing: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"DuplicationTaskExecutionFailedException",
"(",
"buildFailureMessage",
"(",
"msg",
")",
",",
"e",
")",
";",
"}",
"}"
] | Retrieve the content listing for a space
@param store the storage provider in which the space exists
@param spaceId space from which to retrieve listing
@return | [
"Retrieve",
"the",
"content",
"listing",
"for",
"a",
"space"
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java#L209-L226 |
457 | duracloud/mill | workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java | DuplicationTaskProcessor.deleteDestSpace | private void deleteDestSpace(final String spaceId)
throws TaskExecutionFailedException {
log.info("Deleting space " + spaceId +
" from dest provider in account " + dupTask.getAccount());
try {
new Retrier().execute(new Retriable() {
@Override
public String retry() throws Exception {
// The actual method being executed
destStore.deleteSpace(spaceId);
return "success";
}
});
} catch (Exception e) {
String msg = "Error attempting to delete the destination space: " +
e.getMessage();
throw new DuplicationTaskExecutionFailedException(
buildFailureMessage(msg), e);
}
log.info("Successfully deleted space " + spaceId +
" from dest provider in account " + dupTask.getAccount());
} | java | private void deleteDestSpace(final String spaceId)
throws TaskExecutionFailedException {
log.info("Deleting space " + spaceId +
" from dest provider in account " + dupTask.getAccount());
try {
new Retrier().execute(new Retriable() {
@Override
public String retry() throws Exception {
// The actual method being executed
destStore.deleteSpace(spaceId);
return "success";
}
});
} catch (Exception e) {
String msg = "Error attempting to delete the destination space: " +
e.getMessage();
throw new DuplicationTaskExecutionFailedException(
buildFailureMessage(msg), e);
}
log.info("Successfully deleted space " + spaceId +
" from dest provider in account " + dupTask.getAccount());
} | [
"private",
"void",
"deleteDestSpace",
"(",
"final",
"String",
"spaceId",
")",
"throws",
"TaskExecutionFailedException",
"{",
"log",
".",
"info",
"(",
"\"Deleting space \"",
"+",
"spaceId",
"+",
"\" from dest provider in account \"",
"+",
"dupTask",
".",
"getAccount",
"(",
")",
")",
";",
"try",
"{",
"new",
"Retrier",
"(",
")",
".",
"execute",
"(",
"new",
"Retriable",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"retry",
"(",
")",
"throws",
"Exception",
"{",
"// The actual method being executed",
"destStore",
".",
"deleteSpace",
"(",
"spaceId",
")",
";",
"return",
"\"success\"",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"msg",
"=",
"\"Error attempting to delete the destination space: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"DuplicationTaskExecutionFailedException",
"(",
"buildFailureMessage",
"(",
"msg",
")",
",",
"e",
")",
";",
"}",
"log",
".",
"info",
"(",
"\"Successfully deleted space \"",
"+",
"spaceId",
"+",
"\" from dest provider in account \"",
"+",
"dupTask",
".",
"getAccount",
"(",
")",
")",
";",
"}"
] | Deletes a space from the destination store
@param spaceId space to delete
@return | [
"Deletes",
"a",
"space",
"from",
"the",
"destination",
"store"
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java#L234-L255 |
458 | duracloud/mill | workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java | DuplicationTaskProcessor.getContentProperties | private Map<String, String> getContentProperties(final StorageProvider store,
final String spaceId,
final String contentId)
throws TaskExecutionFailedException {
try {
return new Retrier().execute(new Retriable() {
@Override
public Map<String, String> retry() throws Exception {
// The actual method being executed
return store.getContentProperties(spaceId, contentId);
}
}, new ExceptionHandler() {
@Override
public void handle(Exception ex) {
if (!(ex instanceof NotFoundException)) {
log.debug(ex.getMessage(), ex);
} else {
log.debug("retry attempt failed but probably not an issue: {}", ex.getMessage());
}
}
});
} catch (NotFoundException nfe) {
return null;
} catch (Exception e) {
String msg = "Error attempting to retrieve content properties: " + e.getMessage();
throw new DuplicationTaskExecutionFailedException(buildFailureMessage(msg), e);
}
} | java | private Map<String, String> getContentProperties(final StorageProvider store,
final String spaceId,
final String contentId)
throws TaskExecutionFailedException {
try {
return new Retrier().execute(new Retriable() {
@Override
public Map<String, String> retry() throws Exception {
// The actual method being executed
return store.getContentProperties(spaceId, contentId);
}
}, new ExceptionHandler() {
@Override
public void handle(Exception ex) {
if (!(ex instanceof NotFoundException)) {
log.debug(ex.getMessage(), ex);
} else {
log.debug("retry attempt failed but probably not an issue: {}", ex.getMessage());
}
}
});
} catch (NotFoundException nfe) {
return null;
} catch (Exception e) {
String msg = "Error attempting to retrieve content properties: " + e.getMessage();
throw new DuplicationTaskExecutionFailedException(buildFailureMessage(msg), e);
}
} | [
"private",
"Map",
"<",
"String",
",",
"String",
">",
"getContentProperties",
"(",
"final",
"StorageProvider",
"store",
",",
"final",
"String",
"spaceId",
",",
"final",
"String",
"contentId",
")",
"throws",
"TaskExecutionFailedException",
"{",
"try",
"{",
"return",
"new",
"Retrier",
"(",
")",
".",
"execute",
"(",
"new",
"Retriable",
"(",
")",
"{",
"@",
"Override",
"public",
"Map",
"<",
"String",
",",
"String",
">",
"retry",
"(",
")",
"throws",
"Exception",
"{",
"// The actual method being executed",
"return",
"store",
".",
"getContentProperties",
"(",
"spaceId",
",",
"contentId",
")",
";",
"}",
"}",
",",
"new",
"ExceptionHandler",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"handle",
"(",
"Exception",
"ex",
")",
"{",
"if",
"(",
"!",
"(",
"ex",
"instanceof",
"NotFoundException",
")",
")",
"{",
"log",
".",
"debug",
"(",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
")",
";",
"}",
"else",
"{",
"log",
".",
"debug",
"(",
"\"retry attempt failed but probably not an issue: {}\"",
",",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"nfe",
")",
"{",
"return",
"null",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"msg",
"=",
"\"Error attempting to retrieve content properties: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"DuplicationTaskExecutionFailedException",
"(",
"buildFailureMessage",
"(",
"msg",
")",
",",
"e",
")",
";",
"}",
"}"
] | Retrieves the properties for the given content item
@param store
@param spaceId
@param contentId
@return
@throws TaskExecutionFailedException | [
"Retrieves",
"the",
"properties",
"for",
"the",
"given",
"content",
"item"
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java#L266-L293 |
459 | duracloud/mill | workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java | DuplicationTaskProcessor.compareProperties | protected boolean compareProperties(Map<String, String> sourceProps,
Map<String, String> destProps) {
return sourceProps.equals(destProps);
} | java | protected boolean compareProperties(Map<String, String> sourceProps,
Map<String, String> destProps) {
return sourceProps.equals(destProps);
} | [
"protected",
"boolean",
"compareProperties",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"sourceProps",
",",
"Map",
"<",
"String",
",",
"String",
">",
"destProps",
")",
"{",
"return",
"sourceProps",
".",
"equals",
"(",
"destProps",
")",
";",
"}"
] | Determines if source and destination properties are equal.
@param sourceProps properties from the source content item
@param destProps properties from the destination content item
@return true if all properties match | [
"Determines",
"if",
"source",
"and",
"destination",
"properties",
"are",
"equal",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java#L302-L305 |
460 | duracloud/mill | workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java | DuplicationTaskProcessor.duplicateProperties | private void duplicateProperties(final String spaceId,
final String contentId, final Map<String, String> sourceProperties)
throws TaskExecutionFailedException {
log.info("Duplicating properties for " + contentId + " in space "
+ spaceId + " in account " + dupTask.getAccount());
try {
new Retrier().execute(new Retriable() {
@Override
public String retry() throws Exception {
// Set properties
try {
destStore.setContentProperties(spaceId, contentId, sourceProperties);
} catch (StorageStateException ex) {
String message = "Unable to set content properties" +
" on destination store ({0}) for " +
"{1} (content) in {2} (space)";
log.warn(MessageFormat.format(message, destStore, contentId, spaceId));
}
return "success";
}
});
log.info("Successfully duplicated properties for " + contentId
+ " in space " + spaceId + " in account "
+ dupTask.getAccount());
} catch (Exception e) {
String msg = "Error attempting to duplicate content properties: " + e.getMessage();
throw new DuplicationTaskExecutionFailedException(
buildFailureMessage(msg), e);
}
} | java | private void duplicateProperties(final String spaceId,
final String contentId, final Map<String, String> sourceProperties)
throws TaskExecutionFailedException {
log.info("Duplicating properties for " + contentId + " in space "
+ spaceId + " in account " + dupTask.getAccount());
try {
new Retrier().execute(new Retriable() {
@Override
public String retry() throws Exception {
// Set properties
try {
destStore.setContentProperties(spaceId, contentId, sourceProperties);
} catch (StorageStateException ex) {
String message = "Unable to set content properties" +
" on destination store ({0}) for " +
"{1} (content) in {2} (space)";
log.warn(MessageFormat.format(message, destStore, contentId, spaceId));
}
return "success";
}
});
log.info("Successfully duplicated properties for " + contentId
+ " in space " + spaceId + " in account "
+ dupTask.getAccount());
} catch (Exception e) {
String msg = "Error attempting to duplicate content properties: " + e.getMessage();
throw new DuplicationTaskExecutionFailedException(
buildFailureMessage(msg), e);
}
} | [
"private",
"void",
"duplicateProperties",
"(",
"final",
"String",
"spaceId",
",",
"final",
"String",
"contentId",
",",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"sourceProperties",
")",
"throws",
"TaskExecutionFailedException",
"{",
"log",
".",
"info",
"(",
"\"Duplicating properties for \"",
"+",
"contentId",
"+",
"\" in space \"",
"+",
"spaceId",
"+",
"\" in account \"",
"+",
"dupTask",
".",
"getAccount",
"(",
")",
")",
";",
"try",
"{",
"new",
"Retrier",
"(",
")",
".",
"execute",
"(",
"new",
"Retriable",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"retry",
"(",
")",
"throws",
"Exception",
"{",
"// Set properties",
"try",
"{",
"destStore",
".",
"setContentProperties",
"(",
"spaceId",
",",
"contentId",
",",
"sourceProperties",
")",
";",
"}",
"catch",
"(",
"StorageStateException",
"ex",
")",
"{",
"String",
"message",
"=",
"\"Unable to set content properties\"",
"+",
"\" on destination store ({0}) for \"",
"+",
"\"{1} (content) in {2} (space)\"",
";",
"log",
".",
"warn",
"(",
"MessageFormat",
".",
"format",
"(",
"message",
",",
"destStore",
",",
"contentId",
",",
"spaceId",
")",
")",
";",
"}",
"return",
"\"success\"",
";",
"}",
"}",
")",
";",
"log",
".",
"info",
"(",
"\"Successfully duplicated properties for \"",
"+",
"contentId",
"+",
"\" in space \"",
"+",
"spaceId",
"+",
"\" in account \"",
"+",
"dupTask",
".",
"getAccount",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"msg",
"=",
"\"Error attempting to duplicate content properties: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"DuplicationTaskExecutionFailedException",
"(",
"buildFailureMessage",
"(",
"msg",
")",
",",
"e",
")",
";",
"}",
"}"
] | Copies the properties from the source item to the destination item.
@param spaceId
@param contentId
@param sourceProperties | [
"Copies",
"the",
"properties",
"from",
"the",
"source",
"item",
"to",
"the",
"destination",
"item",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java#L314-L348 |
461 | duracloud/mill | workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java | DuplicationTaskProcessor.cleanProperties | private void cleanProperties(Map<String, String> props) {
if (props != null) {
props.remove(StorageProvider.PROPERTIES_CONTENT_MD5);
props.remove(StorageProvider.PROPERTIES_CONTENT_CHECKSUM);
props.remove(StorageProvider.PROPERTIES_CONTENT_MODIFIED);
props.remove(StorageProvider.PROPERTIES_CONTENT_SIZE);
props.remove(HttpHeaders.CONTENT_LENGTH);
props.remove(HttpHeaders.CONTENT_TYPE);
props.remove(HttpHeaders.LAST_MODIFIED);
props.remove(HttpHeaders.DATE);
props.remove(HttpHeaders.ETAG);
props.remove(HttpHeaders.CONTENT_LENGTH.toLowerCase());
props.remove(HttpHeaders.CONTENT_TYPE.toLowerCase());
props.remove(HttpHeaders.LAST_MODIFIED.toLowerCase());
props.remove(HttpHeaders.DATE.toLowerCase());
props.remove(HttpHeaders.ETAG.toLowerCase());
}
} | java | private void cleanProperties(Map<String, String> props) {
if (props != null) {
props.remove(StorageProvider.PROPERTIES_CONTENT_MD5);
props.remove(StorageProvider.PROPERTIES_CONTENT_CHECKSUM);
props.remove(StorageProvider.PROPERTIES_CONTENT_MODIFIED);
props.remove(StorageProvider.PROPERTIES_CONTENT_SIZE);
props.remove(HttpHeaders.CONTENT_LENGTH);
props.remove(HttpHeaders.CONTENT_TYPE);
props.remove(HttpHeaders.LAST_MODIFIED);
props.remove(HttpHeaders.DATE);
props.remove(HttpHeaders.ETAG);
props.remove(HttpHeaders.CONTENT_LENGTH.toLowerCase());
props.remove(HttpHeaders.CONTENT_TYPE.toLowerCase());
props.remove(HttpHeaders.LAST_MODIFIED.toLowerCase());
props.remove(HttpHeaders.DATE.toLowerCase());
props.remove(HttpHeaders.ETAG.toLowerCase());
}
} | [
"private",
"void",
"cleanProperties",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"props",
")",
"{",
"if",
"(",
"props",
"!=",
"null",
")",
"{",
"props",
".",
"remove",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_MD5",
")",
";",
"props",
".",
"remove",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_CHECKSUM",
")",
";",
"props",
".",
"remove",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_MODIFIED",
")",
";",
"props",
".",
"remove",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_SIZE",
")",
";",
"props",
".",
"remove",
"(",
"HttpHeaders",
".",
"CONTENT_LENGTH",
")",
";",
"props",
".",
"remove",
"(",
"HttpHeaders",
".",
"CONTENT_TYPE",
")",
";",
"props",
".",
"remove",
"(",
"HttpHeaders",
".",
"LAST_MODIFIED",
")",
";",
"props",
".",
"remove",
"(",
"HttpHeaders",
".",
"DATE",
")",
";",
"props",
".",
"remove",
"(",
"HttpHeaders",
".",
"ETAG",
")",
";",
"props",
".",
"remove",
"(",
"HttpHeaders",
".",
"CONTENT_LENGTH",
".",
"toLowerCase",
"(",
")",
")",
";",
"props",
".",
"remove",
"(",
"HttpHeaders",
".",
"CONTENT_TYPE",
".",
"toLowerCase",
"(",
")",
")",
";",
"props",
".",
"remove",
"(",
"HttpHeaders",
".",
"LAST_MODIFIED",
".",
"toLowerCase",
"(",
")",
")",
";",
"props",
".",
"remove",
"(",
"HttpHeaders",
".",
"DATE",
".",
"toLowerCase",
"(",
")",
")",
";",
"props",
".",
"remove",
"(",
"HttpHeaders",
".",
"ETAG",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"}"
] | Pull out the system-generated properties, to allow the properties that
are added to the duplicated item to be only the user-defined properties.
@param props | [
"Pull",
"out",
"the",
"system",
"-",
"generated",
"properties",
"to",
"allow",
"the",
"properties",
"that",
"are",
"added",
"to",
"the",
"duplicated",
"item",
"to",
"be",
"only",
"the",
"user",
"-",
"defined",
"properties",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java#L356-L373 |
462 | duracloud/mill | workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java | DuplicationTaskProcessor.duplicateContent | private void duplicateContent(final String spaceId,
final String contentId,
final String sourceChecksum,
final Map<String, String> sourceProperties)
throws TaskExecutionFailedException {
log.info("Duplicating " + contentId + " in space " + spaceId +
" in account " + dupTask.getAccount());
ChecksumUtil checksumUtil = new ChecksumUtil(MD5);
boolean localChecksumMatch = false;
int attempt = 0;
File localFile = null;
while (!localChecksumMatch && attempt < 3) {
// Get content stream
try (InputStream sourceStream = getSourceContent(spaceId, contentId)) {
// Cache content locally
localFile = cacheContent(sourceStream);
// Check content
String localChecksum = checksumUtil.generateChecksum(localFile);
if (sourceChecksum.equals(localChecksum)) {
localChecksumMatch = true;
} else {
cleanup(localFile);
}
} catch (Exception e) {
log.warn("Error generating checksum for source content: " + e.getMessage(), e);
}
attempt++;
}
// Put content
if (localChecksumMatch) {
putDestinationContent(spaceId,
contentId,
sourceChecksum,
sourceProperties,
localFile);
log.info(
"Successfully duplicated id={} dup_size={} space={} account={}",
contentId,
localFile.length(),
spaceId, dupTask.getAccount());
} else {
cleanup(localFile);
String msg = "Unable to retrieve content which matches the" +
" expected source checksum of: " + sourceChecksum;
throw new DuplicationTaskExecutionFailedException(buildFailureMessage(msg));
}
cleanup(localFile);
} | java | private void duplicateContent(final String spaceId,
final String contentId,
final String sourceChecksum,
final Map<String, String> sourceProperties)
throws TaskExecutionFailedException {
log.info("Duplicating " + contentId + " in space " + spaceId +
" in account " + dupTask.getAccount());
ChecksumUtil checksumUtil = new ChecksumUtil(MD5);
boolean localChecksumMatch = false;
int attempt = 0;
File localFile = null;
while (!localChecksumMatch && attempt < 3) {
// Get content stream
try (InputStream sourceStream = getSourceContent(spaceId, contentId)) {
// Cache content locally
localFile = cacheContent(sourceStream);
// Check content
String localChecksum = checksumUtil.generateChecksum(localFile);
if (sourceChecksum.equals(localChecksum)) {
localChecksumMatch = true;
} else {
cleanup(localFile);
}
} catch (Exception e) {
log.warn("Error generating checksum for source content: " + e.getMessage(), e);
}
attempt++;
}
// Put content
if (localChecksumMatch) {
putDestinationContent(spaceId,
contentId,
sourceChecksum,
sourceProperties,
localFile);
log.info(
"Successfully duplicated id={} dup_size={} space={} account={}",
contentId,
localFile.length(),
spaceId, dupTask.getAccount());
} else {
cleanup(localFile);
String msg = "Unable to retrieve content which matches the" +
" expected source checksum of: " + sourceChecksum;
throw new DuplicationTaskExecutionFailedException(buildFailureMessage(msg));
}
cleanup(localFile);
} | [
"private",
"void",
"duplicateContent",
"(",
"final",
"String",
"spaceId",
",",
"final",
"String",
"contentId",
",",
"final",
"String",
"sourceChecksum",
",",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"sourceProperties",
")",
"throws",
"TaskExecutionFailedException",
"{",
"log",
".",
"info",
"(",
"\"Duplicating \"",
"+",
"contentId",
"+",
"\" in space \"",
"+",
"spaceId",
"+",
"\" in account \"",
"+",
"dupTask",
".",
"getAccount",
"(",
")",
")",
";",
"ChecksumUtil",
"checksumUtil",
"=",
"new",
"ChecksumUtil",
"(",
"MD5",
")",
";",
"boolean",
"localChecksumMatch",
"=",
"false",
";",
"int",
"attempt",
"=",
"0",
";",
"File",
"localFile",
"=",
"null",
";",
"while",
"(",
"!",
"localChecksumMatch",
"&&",
"attempt",
"<",
"3",
")",
"{",
"// Get content stream",
"try",
"(",
"InputStream",
"sourceStream",
"=",
"getSourceContent",
"(",
"spaceId",
",",
"contentId",
")",
")",
"{",
"// Cache content locally",
"localFile",
"=",
"cacheContent",
"(",
"sourceStream",
")",
";",
"// Check content",
"String",
"localChecksum",
"=",
"checksumUtil",
".",
"generateChecksum",
"(",
"localFile",
")",
";",
"if",
"(",
"sourceChecksum",
".",
"equals",
"(",
"localChecksum",
")",
")",
"{",
"localChecksumMatch",
"=",
"true",
";",
"}",
"else",
"{",
"cleanup",
"(",
"localFile",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"\"Error generating checksum for source content: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"attempt",
"++",
";",
"}",
"// Put content",
"if",
"(",
"localChecksumMatch",
")",
"{",
"putDestinationContent",
"(",
"spaceId",
",",
"contentId",
",",
"sourceChecksum",
",",
"sourceProperties",
",",
"localFile",
")",
";",
"log",
".",
"info",
"(",
"\"Successfully duplicated id={} dup_size={} space={} account={}\"",
",",
"contentId",
",",
"localFile",
".",
"length",
"(",
")",
",",
"spaceId",
",",
"dupTask",
".",
"getAccount",
"(",
")",
")",
";",
"}",
"else",
"{",
"cleanup",
"(",
"localFile",
")",
";",
"String",
"msg",
"=",
"\"Unable to retrieve content which matches the\"",
"+",
"\" expected source checksum of: \"",
"+",
"sourceChecksum",
";",
"throw",
"new",
"DuplicationTaskExecutionFailedException",
"(",
"buildFailureMessage",
"(",
"msg",
")",
")",
";",
"}",
"cleanup",
"(",
"localFile",
")",
";",
"}"
] | Copies a content item from the source store to the destination store
@param spaceId
@param contentId | [
"Copies",
"a",
"content",
"item",
"from",
"the",
"source",
"store",
"to",
"the",
"destination",
"store"
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java#L381-L431 |
463 | duracloud/mill | workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java | DuplicationTaskProcessor.duplicateDeletion | private void duplicateDeletion(final String spaceId,
final String contentId)
throws TaskExecutionFailedException {
if (existsInSourceManifest(spaceId, contentId)) {
throw new TaskExecutionFailedException(
MessageFormat.format("item exists in source manifest and thus appears to be " +
"missing content. account={0}, storeId={1}, spaceId={2}, contentId={3}",
this.dupTask.getAccount(),
this.dupTask.getSourceStoreId(),
spaceId,
contentId));
}
log.info("Duplicating deletion of " + contentId + " in dest space " +
spaceId + " in account " + dupTask.getAccount());
try {
new Retrier().execute(new Retriable() {
@Override
public String retry() throws Exception {
// Delete content
destStore.deleteContent(spaceId, contentId);
return "success";
}
});
} catch (Exception e) {
String msg = "Error attempting to delete content : " + e.getMessage();
throw new DuplicationTaskExecutionFailedException(buildFailureMessage(msg), e);
}
log.info("Successfully deleted content item (content_id=" + contentId +
") in dest space (space_id=" + spaceId + ") where account_id=" +
dupTask.getAccount());
} | java | private void duplicateDeletion(final String spaceId,
final String contentId)
throws TaskExecutionFailedException {
if (existsInSourceManifest(spaceId, contentId)) {
throw new TaskExecutionFailedException(
MessageFormat.format("item exists in source manifest and thus appears to be " +
"missing content. account={0}, storeId={1}, spaceId={2}, contentId={3}",
this.dupTask.getAccount(),
this.dupTask.getSourceStoreId(),
spaceId,
contentId));
}
log.info("Duplicating deletion of " + contentId + " in dest space " +
spaceId + " in account " + dupTask.getAccount());
try {
new Retrier().execute(new Retriable() {
@Override
public String retry() throws Exception {
// Delete content
destStore.deleteContent(spaceId, contentId);
return "success";
}
});
} catch (Exception e) {
String msg = "Error attempting to delete content : " + e.getMessage();
throw new DuplicationTaskExecutionFailedException(buildFailureMessage(msg), e);
}
log.info("Successfully deleted content item (content_id=" + contentId +
") in dest space (space_id=" + spaceId + ") where account_id=" +
dupTask.getAccount());
} | [
"private",
"void",
"duplicateDeletion",
"(",
"final",
"String",
"spaceId",
",",
"final",
"String",
"contentId",
")",
"throws",
"TaskExecutionFailedException",
"{",
"if",
"(",
"existsInSourceManifest",
"(",
"spaceId",
",",
"contentId",
")",
")",
"{",
"throw",
"new",
"TaskExecutionFailedException",
"(",
"MessageFormat",
".",
"format",
"(",
"\"item exists in source manifest and thus appears to be \"",
"+",
"\"missing content. account={0}, storeId={1}, spaceId={2}, contentId={3}\"",
",",
"this",
".",
"dupTask",
".",
"getAccount",
"(",
")",
",",
"this",
".",
"dupTask",
".",
"getSourceStoreId",
"(",
")",
",",
"spaceId",
",",
"contentId",
")",
")",
";",
"}",
"log",
".",
"info",
"(",
"\"Duplicating deletion of \"",
"+",
"contentId",
"+",
"\" in dest space \"",
"+",
"spaceId",
"+",
"\" in account \"",
"+",
"dupTask",
".",
"getAccount",
"(",
")",
")",
";",
"try",
"{",
"new",
"Retrier",
"(",
")",
".",
"execute",
"(",
"new",
"Retriable",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"retry",
"(",
")",
"throws",
"Exception",
"{",
"// Delete content",
"destStore",
".",
"deleteContent",
"(",
"spaceId",
",",
"contentId",
")",
";",
"return",
"\"success\"",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"msg",
"=",
"\"Error attempting to delete content : \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"DuplicationTaskExecutionFailedException",
"(",
"buildFailureMessage",
"(",
"msg",
")",
",",
"e",
")",
";",
"}",
"log",
".",
"info",
"(",
"\"Successfully deleted content item (content_id=\"",
"+",
"contentId",
"+",
"\") in dest space (space_id=\"",
"+",
"spaceId",
"+",
"\") where account_id=\"",
"+",
"dupTask",
".",
"getAccount",
"(",
")",
")",
";",
"}"
] | Deletes a content item in the destination space, but only if it does not exists in the
source manifest.
@param spaceId
@param contentId | [
"Deletes",
"a",
"content",
"item",
"in",
"the",
"destination",
"space",
"but",
"only",
"if",
"it",
"does",
"not",
"exists",
"in",
"the",
"source",
"manifest",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/workman/src/main/java/org/duracloud/mill/dup/DuplicationTaskProcessor.java#L532-L565 |
464 | duracloud/mill | common-dup/src/main/java/org/duracloud/mill/dup/DuplicationPolicy.java | DuplicationPolicy.addDuplicationStorePolicy | public boolean addDuplicationStorePolicy(String spaceId,
DuplicationStorePolicy dupStore) {
LinkedHashSet<DuplicationStorePolicy> dupStores =
spaceDuplicationStorePolicies.get(spaceId);
if (dupStores == null) {
dupStores = new LinkedHashSet<>();
spaceDuplicationStorePolicies.put(spaceId, dupStores);
}
return dupStores.add(dupStore);
} | java | public boolean addDuplicationStorePolicy(String spaceId,
DuplicationStorePolicy dupStore) {
LinkedHashSet<DuplicationStorePolicy> dupStores =
spaceDuplicationStorePolicies.get(spaceId);
if (dupStores == null) {
dupStores = new LinkedHashSet<>();
spaceDuplicationStorePolicies.put(spaceId, dupStores);
}
return dupStores.add(dupStore);
} | [
"public",
"boolean",
"addDuplicationStorePolicy",
"(",
"String",
"spaceId",
",",
"DuplicationStorePolicy",
"dupStore",
")",
"{",
"LinkedHashSet",
"<",
"DuplicationStorePolicy",
">",
"dupStores",
"=",
"spaceDuplicationStorePolicies",
".",
"get",
"(",
"spaceId",
")",
";",
"if",
"(",
"dupStores",
"==",
"null",
")",
"{",
"dupStores",
"=",
"new",
"LinkedHashSet",
"<>",
"(",
")",
";",
"spaceDuplicationStorePolicies",
".",
"put",
"(",
"spaceId",
",",
"dupStores",
")",
";",
"}",
"return",
"dupStores",
".",
"add",
"(",
"dupStore",
")",
";",
"}"
] | Adds a DuplicationStorePolicy for the specified space ID.
@param spaceId the space ID to add the DuplicationStorePolicy for
@param dupStore the DuplicationStorePolicy
@return true if added, false otherwise. False will be returned if the
Set<DuplicationStorePolicy> for the specified space already contains the
dupStore. | [
"Adds",
"a",
"DuplicationStorePolicy",
"for",
"the",
"specified",
"space",
"ID",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/common-dup/src/main/java/org/duracloud/mill/dup/DuplicationPolicy.java#L109-L118 |
465 | duracloud/mill | workman/src/main/java/org/duracloud/mill/storagestats/aws/CloudWatchStorageStatsGatherer.java | CloudWatchStorageStatsGatherer.getTotalBytes | private long getTotalBytes(String bucketName,
AmazonCloudWatch client) {
long totalBytes = 0;
totalBytes += getMetricData(bucketName,
"BucketSizeBytes",
"StandardStorage",
client);
totalBytes += getMetricData(bucketName,
"BucketSizeBytes",
"StandardIAStorage",
client);
totalBytes += getMetricData(bucketName,
"BucketSizeBytes",
"ReducedRedundancyStorage",
client);
return totalBytes;
} | java | private long getTotalBytes(String bucketName,
AmazonCloudWatch client) {
long totalBytes = 0;
totalBytes += getMetricData(bucketName,
"BucketSizeBytes",
"StandardStorage",
client);
totalBytes += getMetricData(bucketName,
"BucketSizeBytes",
"StandardIAStorage",
client);
totalBytes += getMetricData(bucketName,
"BucketSizeBytes",
"ReducedRedundancyStorage",
client);
return totalBytes;
} | [
"private",
"long",
"getTotalBytes",
"(",
"String",
"bucketName",
",",
"AmazonCloudWatch",
"client",
")",
"{",
"long",
"totalBytes",
"=",
"0",
";",
"totalBytes",
"+=",
"getMetricData",
"(",
"bucketName",
",",
"\"BucketSizeBytes\"",
",",
"\"StandardStorage\"",
",",
"client",
")",
";",
"totalBytes",
"+=",
"getMetricData",
"(",
"bucketName",
",",
"\"BucketSizeBytes\"",
",",
"\"StandardIAStorage\"",
",",
"client",
")",
";",
"totalBytes",
"+=",
"getMetricData",
"(",
"bucketName",
",",
"\"BucketSizeBytes\"",
",",
"\"ReducedRedundancyStorage\"",
",",
"client",
")",
";",
"return",
"totalBytes",
";",
"}"
] | Gets the total byte count for all storage types and combines them to
produce a single stored bytes value
@param bucketName
@return | [
"Gets",
"the",
"total",
"byte",
"count",
"for",
"all",
"storage",
"types",
"and",
"combines",
"them",
"to",
"produce",
"a",
"single",
"stored",
"bytes",
"value"
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/workman/src/main/java/org/duracloud/mill/storagestats/aws/CloudWatchStorageStatsGatherer.java#L72-L88 |
466 | duracloud/mill | workman/src/main/java/org/duracloud/mill/storagestats/aws/CloudWatchStorageStatsGatherer.java | CloudWatchStorageStatsGatherer.buildRequest | private GetMetricStatisticsRequest buildRequest(String bucketName,
String metricName,
String storageType) {
GetMetricStatisticsRequest request = new GetMetricStatisticsRequest();
request.setMetricName(metricName);
request.setNamespace("AWS/S3");
request.setPeriod(360);
request.setStatistics(Collections.singletonList("Maximum"));
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
Date currentTime = cal.getTime();
cal.add(Calendar.DATE, -1);
request.setStartTime(cal.getTime());
request.setEndTime(currentTime);
List<Dimension> dimensions = new ArrayList<>();
dimensions.add(new Dimension().withName("BucketName")
.withValue(bucketName));
dimensions.add(new Dimension().withName("StorageType")
.withValue(storageType));
request.setDimensions(dimensions);
return request;
} | java | private GetMetricStatisticsRequest buildRequest(String bucketName,
String metricName,
String storageType) {
GetMetricStatisticsRequest request = new GetMetricStatisticsRequest();
request.setMetricName(metricName);
request.setNamespace("AWS/S3");
request.setPeriod(360);
request.setStatistics(Collections.singletonList("Maximum"));
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
Date currentTime = cal.getTime();
cal.add(Calendar.DATE, -1);
request.setStartTime(cal.getTime());
request.setEndTime(currentTime);
List<Dimension> dimensions = new ArrayList<>();
dimensions.add(new Dimension().withName("BucketName")
.withValue(bucketName));
dimensions.add(new Dimension().withName("StorageType")
.withValue(storageType));
request.setDimensions(dimensions);
return request;
} | [
"private",
"GetMetricStatisticsRequest",
"buildRequest",
"(",
"String",
"bucketName",
",",
"String",
"metricName",
",",
"String",
"storageType",
")",
"{",
"GetMetricStatisticsRequest",
"request",
"=",
"new",
"GetMetricStatisticsRequest",
"(",
")",
";",
"request",
".",
"setMetricName",
"(",
"metricName",
")",
";",
"request",
".",
"setNamespace",
"(",
"\"AWS/S3\"",
")",
";",
"request",
".",
"setPeriod",
"(",
"360",
")",
";",
"request",
".",
"setStatistics",
"(",
"Collections",
".",
"singletonList",
"(",
"\"Maximum\"",
")",
")",
";",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
"TimeZone",
".",
"getTimeZone",
"(",
"\"UTC\"",
")",
")",
";",
"Date",
"currentTime",
"=",
"cal",
".",
"getTime",
"(",
")",
";",
"cal",
".",
"add",
"(",
"Calendar",
".",
"DATE",
",",
"-",
"1",
")",
";",
"request",
".",
"setStartTime",
"(",
"cal",
".",
"getTime",
"(",
")",
")",
";",
"request",
".",
"setEndTime",
"(",
"currentTime",
")",
";",
"List",
"<",
"Dimension",
">",
"dimensions",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"dimensions",
".",
"add",
"(",
"new",
"Dimension",
"(",
")",
".",
"withName",
"(",
"\"BucketName\"",
")",
".",
"withValue",
"(",
"bucketName",
")",
")",
";",
"dimensions",
".",
"add",
"(",
"new",
"Dimension",
"(",
")",
".",
"withName",
"(",
"\"StorageType\"",
")",
".",
"withValue",
"(",
"storageType",
")",
")",
";",
"request",
".",
"setDimensions",
"(",
"dimensions",
")",
";",
"return",
"request",
";",
"}"
] | Create the request to ask for bucket metrics
@param bucketName
@param metricName
@param storageType
@return | [
"Create",
"the",
"request",
"to",
"ask",
"for",
"bucket",
"metrics"
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/workman/src/main/java/org/duracloud/mill/storagestats/aws/CloudWatchStorageStatsGatherer.java#L118-L141 |
467 | duracloud/mill | loopingtaskproducer/src/main/java/org/duracloud/mill/ltp/LoopingTaskProducer.java | LoopingTaskProducer.writeCompletionFile | private void writeCompletionFile() {
File completionFile = getCompletionFile();
try {
if (completionFile.createNewFile()) {
log.info("successfully created completion marker file: {}",
completionFile.getAbsolutePath());
} else {
log.warn("completion marker file unexpectably exists already " +
"- something may be amiss: {}",
completionFile.getAbsolutePath());
}
} catch (IOException e) {
log.error("Unable to create the completion file {}: {}",
completionFile.getAbsolutePath(),
e.getMessage());
}
} | java | private void writeCompletionFile() {
File completionFile = getCompletionFile();
try {
if (completionFile.createNewFile()) {
log.info("successfully created completion marker file: {}",
completionFile.getAbsolutePath());
} else {
log.warn("completion marker file unexpectably exists already " +
"- something may be amiss: {}",
completionFile.getAbsolutePath());
}
} catch (IOException e) {
log.error("Unable to create the completion file {}: {}",
completionFile.getAbsolutePath(),
e.getMessage());
}
} | [
"private",
"void",
"writeCompletionFile",
"(",
")",
"{",
"File",
"completionFile",
"=",
"getCompletionFile",
"(",
")",
";",
"try",
"{",
"if",
"(",
"completionFile",
".",
"createNewFile",
"(",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"successfully created completion marker file: {}\"",
",",
"completionFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"\"completion marker file unexpectably exists already \"",
"+",
"\"- something may be amiss: {}\"",
",",
"completionFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to create the completion file {}: {}\"",
",",
"completionFile",
".",
"getAbsolutePath",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Writes zero length file to the work directory to mark the completion of a run. | [
"Writes",
"zero",
"length",
"file",
"to",
"the",
"work",
"directory",
"to",
"mark",
"the",
"completion",
"of",
"a",
"run",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/loopingtaskproducer/src/main/java/org/duracloud/mill/ltp/LoopingTaskProducer.java#L211-L228 |
468 | duracloud/mill | loopingtaskproducer/src/main/java/org/duracloud/mill/ltp/LoopingTaskProducer.java | LoopingTaskProducer.loadMorselQueue | private Queue<T> loadMorselQueue() {
Queue<T> morselQueue = createQueue();
//load morsels from state;
Set<T> morsels = new LinkedHashSet<>(this.stateManager.getMorsels());
morselQueue.addAll(morsels);
if (morselQueue.isEmpty()) {
loadMorselQueueFromSource(morselQueue);
}
return morselQueue;
} | java | private Queue<T> loadMorselQueue() {
Queue<T> morselQueue = createQueue();
//load morsels from state;
Set<T> morsels = new LinkedHashSet<>(this.stateManager.getMorsels());
morselQueue.addAll(morsels);
if (morselQueue.isEmpty()) {
loadMorselQueueFromSource(morselQueue);
}
return morselQueue;
} | [
"private",
"Queue",
"<",
"T",
">",
"loadMorselQueue",
"(",
")",
"{",
"Queue",
"<",
"T",
">",
"morselQueue",
"=",
"createQueue",
"(",
")",
";",
"//load morsels from state;",
"Set",
"<",
"T",
">",
"morsels",
"=",
"new",
"LinkedHashSet",
"<>",
"(",
"this",
".",
"stateManager",
".",
"getMorsels",
"(",
")",
")",
";",
"morselQueue",
".",
"addAll",
"(",
"morsels",
")",
";",
"if",
"(",
"morselQueue",
".",
"isEmpty",
"(",
")",
")",
"{",
"loadMorselQueueFromSource",
"(",
"morselQueue",
")",
";",
"}",
"return",
"morselQueue",
";",
"}"
] | Loads the morsels from the persistent state if there are any; otherwise it loads all other morsels based on
on duplication policy manager.
@return | [
"Loads",
"the",
"morsels",
"from",
"the",
"persistent",
"state",
"if",
"there",
"are",
"any",
";",
"otherwise",
"it",
"loads",
"all",
"other",
"morsels",
"based",
"on",
"on",
"duplication",
"policy",
"manager",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/loopingtaskproducer/src/main/java/org/duracloud/mill/ltp/LoopingTaskProducer.java#L435-L448 |
469 | duracloud/mill | loopingtaskproducer/src/main/java/org/duracloud/mill/ltp/PathFilterManager.java | PathFilterManager.isExcluded | public boolean isExcluded(String path) {
if (inclusions != null && !inclusions.isEmpty()) {
if (!matchesList(path, inclusions, false)) {
log.debug("{} does not match an inclusion: skipping...", path);
return true;
}
}
if (exclusions == null) {
return false;
}
if (matchesList(path, exclusions, true)) {
log.debug("{} matches exclusions: skipping...", path);
return true;
}
return false;
} | java | public boolean isExcluded(String path) {
if (inclusions != null && !inclusions.isEmpty()) {
if (!matchesList(path, inclusions, false)) {
log.debug("{} does not match an inclusion: skipping...", path);
return true;
}
}
if (exclusions == null) {
return false;
}
if (matchesList(path, exclusions, true)) {
log.debug("{} matches exclusions: skipping...", path);
return true;
}
return false;
} | [
"public",
"boolean",
"isExcluded",
"(",
"String",
"path",
")",
"{",
"if",
"(",
"inclusions",
"!=",
"null",
"&&",
"!",
"inclusions",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"!",
"matchesList",
"(",
"path",
",",
"inclusions",
",",
"false",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"{} does not match an inclusion: skipping...\"",
",",
"path",
")",
";",
"return",
"true",
";",
"}",
"}",
"if",
"(",
"exclusions",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"matchesList",
"(",
"path",
",",
"exclusions",
",",
"true",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"{} matches exclusions: skipping...\"",
",",
"path",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Returns true if the path is included and not excluded. A path is included
if the inclusions list is null or empty or the path matches an item in
the list.
@param path
@return | [
"Returns",
"true",
"if",
"the",
"path",
"is",
"included",
"and",
"not",
"excluded",
".",
"A",
"path",
"is",
"included",
"if",
"the",
"inclusions",
"list",
"is",
"null",
"or",
"empty",
"or",
"the",
"path",
"matches",
"an",
"item",
"in",
"the",
"list",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/loopingtaskproducer/src/main/java/org/duracloud/mill/ltp/PathFilterManager.java#L116-L133 |
470 | duracloud/mill | common/src/main/java/org/duracloud/mill/util/Iterators.java | Iterators.difference | public static Iterator<String> difference(Iterator<String> iterA, Iterator<String> iterB)
throws IOException {
String cacheName = "compare-" + System.currentTimeMillis();
cacheManager.addCache(cacheName);
Cache cache = cacheManager.getCache(cacheName);
while (iterB.hasNext()) {
String item = iterB.next();
cache.put(new Element(item, null));
}
int diffCnt = 0;
File diffFile = new File(System.getProperty("java.io.tmpdir") +
File.separator + "diff-" +
System.currentTimeMillis() + ".txt");
FileWriter fileWriter = new FileWriter(diffFile);
while (iterA.hasNext()) {
String item = iterA.next();
if (!cache.isKeyInCache(item)) {
// write item to file
fileWriter.write(item + "\n");
diffCnt++;
if (diffCnt % 100 == 0) {
fileWriter.flush();
}
}
}
fileWriter.close();
// All done with the cache, clean it up
cache.removeAll();
cacheManager.removeCache(cache.getName());
if (diffCnt > 0) {
return new FileLineIterator(diffFile);
} else {
// nothing written to the file so not needed, delete it
diffFile.delete();
return new ArrayList<String>(0).iterator();
}
} | java | public static Iterator<String> difference(Iterator<String> iterA, Iterator<String> iterB)
throws IOException {
String cacheName = "compare-" + System.currentTimeMillis();
cacheManager.addCache(cacheName);
Cache cache = cacheManager.getCache(cacheName);
while (iterB.hasNext()) {
String item = iterB.next();
cache.put(new Element(item, null));
}
int diffCnt = 0;
File diffFile = new File(System.getProperty("java.io.tmpdir") +
File.separator + "diff-" +
System.currentTimeMillis() + ".txt");
FileWriter fileWriter = new FileWriter(diffFile);
while (iterA.hasNext()) {
String item = iterA.next();
if (!cache.isKeyInCache(item)) {
// write item to file
fileWriter.write(item + "\n");
diffCnt++;
if (diffCnt % 100 == 0) {
fileWriter.flush();
}
}
}
fileWriter.close();
// All done with the cache, clean it up
cache.removeAll();
cacheManager.removeCache(cache.getName());
if (diffCnt > 0) {
return new FileLineIterator(diffFile);
} else {
// nothing written to the file so not needed, delete it
diffFile.delete();
return new ArrayList<String>(0).iterator();
}
} | [
"public",
"static",
"Iterator",
"<",
"String",
">",
"difference",
"(",
"Iterator",
"<",
"String",
">",
"iterA",
",",
"Iterator",
"<",
"String",
">",
"iterB",
")",
"throws",
"IOException",
"{",
"String",
"cacheName",
"=",
"\"compare-\"",
"+",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"cacheManager",
".",
"addCache",
"(",
"cacheName",
")",
";",
"Cache",
"cache",
"=",
"cacheManager",
".",
"getCache",
"(",
"cacheName",
")",
";",
"while",
"(",
"iterB",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"item",
"=",
"iterB",
".",
"next",
"(",
")",
";",
"cache",
".",
"put",
"(",
"new",
"Element",
"(",
"item",
",",
"null",
")",
")",
";",
"}",
"int",
"diffCnt",
"=",
"0",
";",
"File",
"diffFile",
"=",
"new",
"File",
"(",
"System",
".",
"getProperty",
"(",
"\"java.io.tmpdir\"",
")",
"+",
"File",
".",
"separator",
"+",
"\"diff-\"",
"+",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"\".txt\"",
")",
";",
"FileWriter",
"fileWriter",
"=",
"new",
"FileWriter",
"(",
"diffFile",
")",
";",
"while",
"(",
"iterA",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"item",
"=",
"iterA",
".",
"next",
"(",
")",
";",
"if",
"(",
"!",
"cache",
".",
"isKeyInCache",
"(",
"item",
")",
")",
"{",
"// write item to file",
"fileWriter",
".",
"write",
"(",
"item",
"+",
"\"\\n\"",
")",
";",
"diffCnt",
"++",
";",
"if",
"(",
"diffCnt",
"%",
"100",
"==",
"0",
")",
"{",
"fileWriter",
".",
"flush",
"(",
")",
";",
"}",
"}",
"}",
"fileWriter",
".",
"close",
"(",
")",
";",
"// All done with the cache, clean it up",
"cache",
".",
"removeAll",
"(",
")",
";",
"cacheManager",
".",
"removeCache",
"(",
"cache",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"diffCnt",
">",
"0",
")",
"{",
"return",
"new",
"FileLineIterator",
"(",
"diffFile",
")",
";",
"}",
"else",
"{",
"// nothing written to the file so not needed, delete it",
"diffFile",
".",
"delete",
"(",
")",
";",
"return",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"0",
")",
".",
"iterator",
"(",
")",
";",
"}",
"}"
] | Returns an Iterator contain the difference of elements contained in the
provided Iterators. The returned Iterator contains all elements that are
contained by iterA and not contained by iterB. iterB may also contain
elements not present in iterA; these are simply ignored.
@param iterA
@param iterB
@return an Iterator containing elements in iterA but not in iterB | [
"Returns",
"an",
"Iterator",
"contain",
"the",
"difference",
"of",
"elements",
"contained",
"in",
"the",
"provided",
"Iterators",
".",
"The",
"returned",
"Iterator",
"contains",
"all",
"elements",
"that",
"are",
"contained",
"by",
"iterA",
"and",
"not",
"contained",
"by",
"iterB",
".",
"iterB",
"may",
"also",
"contain",
"elements",
"not",
"present",
"in",
"iterA",
";",
"these",
"are",
"simply",
"ignored",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/common/src/main/java/org/duracloud/mill/util/Iterators.java#L45-L85 |
471 | inaiat/jqplot4java | src/main/java/br/com/digilabs/jqplot/JqPlotUtils.java | JqPlotUtils.retriveJavaScriptResources | public static List<String> retriveJavaScriptResources(Chart<?> chart) {
List<String> resources = new ArrayList<String>();
Class<?> clazz = chart.getClass();
if (clazz.isAnnotationPresent(JqPlotPlugin.class)) {
JqPlotResources[] jqPlotResourceses = clazz.getAnnotation(
JqPlotPlugin.class).values();
for (JqPlotResources jqPlotResources : jqPlotResourceses) {
resources.add(jqPlotResources.getResource());
}
}
//can it/should we make this more generic?
if(chart.getChartConfiguration().getHighlighter() != null) {
resources.add(JqPlotResources.Highlighter.getResource());
}
return resources;
} | java | public static List<String> retriveJavaScriptResources(Chart<?> chart) {
List<String> resources = new ArrayList<String>();
Class<?> clazz = chart.getClass();
if (clazz.isAnnotationPresent(JqPlotPlugin.class)) {
JqPlotResources[] jqPlotResourceses = clazz.getAnnotation(
JqPlotPlugin.class).values();
for (JqPlotResources jqPlotResources : jqPlotResourceses) {
resources.add(jqPlotResources.getResource());
}
}
//can it/should we make this more generic?
if(chart.getChartConfiguration().getHighlighter() != null) {
resources.add(JqPlotResources.Highlighter.getResource());
}
return resources;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"retriveJavaScriptResources",
"(",
"Chart",
"<",
"?",
">",
"chart",
")",
"{",
"List",
"<",
"String",
">",
"resources",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"Class",
"<",
"?",
">",
"clazz",
"=",
"chart",
".",
"getClass",
"(",
")",
";",
"if",
"(",
"clazz",
".",
"isAnnotationPresent",
"(",
"JqPlotPlugin",
".",
"class",
")",
")",
"{",
"JqPlotResources",
"[",
"]",
"jqPlotResourceses",
"=",
"clazz",
".",
"getAnnotation",
"(",
"JqPlotPlugin",
".",
"class",
")",
".",
"values",
"(",
")",
";",
"for",
"(",
"JqPlotResources",
"jqPlotResources",
":",
"jqPlotResourceses",
")",
"{",
"resources",
".",
"add",
"(",
"jqPlotResources",
".",
"getResource",
"(",
")",
")",
";",
"}",
"}",
"//can it/should we make this more generic?",
"if",
"(",
"chart",
".",
"getChartConfiguration",
"(",
")",
".",
"getHighlighter",
"(",
")",
"!=",
"null",
")",
"{",
"resources",
".",
"add",
"(",
"JqPlotResources",
".",
"Highlighter",
".",
"getResource",
"(",
")",
")",
";",
"}",
"return",
"resources",
";",
"}"
] | Retorna os recursos de javascript
@param chart Chart
@return lista de com os javascripts dos gráficos | [
"Retorna",
"os",
"recursos",
"de",
"javascript"
] | 35bcd17749442e88695df0438c8330a65a3977cc | https://github.com/inaiat/jqplot4java/blob/35bcd17749442e88695df0438c8330a65a3977cc/src/main/java/br/com/digilabs/jqplot/JqPlotUtils.java#L44-L62 |
472 | inaiat/jqplot4java | src/main/java/br/com/digilabs/jqplot/chart/AbstractChart.java | AbstractChart.addSerie | public AbstractChart<T, S> addSerie(Serie serie) {
Collection<Serie> series = getSeries();
if (series == null) {
series = new ArrayList<Serie>();
}
series.add(serie);
return this;
} | java | public AbstractChart<T, S> addSerie(Serie serie) {
Collection<Serie> series = getSeries();
if (series == null) {
series = new ArrayList<Serie>();
}
series.add(serie);
return this;
} | [
"public",
"AbstractChart",
"<",
"T",
",",
"S",
">",
"addSerie",
"(",
"Serie",
"serie",
")",
"{",
"Collection",
"<",
"Serie",
">",
"series",
"=",
"getSeries",
"(",
")",
";",
"if",
"(",
"series",
"==",
"null",
")",
"{",
"series",
"=",
"new",
"ArrayList",
"<",
"Serie",
">",
"(",
")",
";",
"}",
"series",
".",
"add",
"(",
"serie",
")",
";",
"return",
"this",
";",
"}"
] | Adiciona uma serie
@param serie Add serie of chart
@return AbstractChart | [
"Adiciona",
"uma",
"serie"
] | 35bcd17749442e88695df0438c8330a65a3977cc | https://github.com/inaiat/jqplot4java/blob/35bcd17749442e88695df0438c8330a65a3977cc/src/main/java/br/com/digilabs/jqplot/chart/AbstractChart.java#L79-L86 |
473 | inaiat/jqplot4java | src/main/java/br/com/digilabs/jqplot/chart/AbstractChart.java | AbstractChart.addSeries | public AbstractChart<T, S> addSeries(Serie... series) {
Collection<Serie> chartSeries = getSeries();
if (chartSeries == null) {
chartSeries = new ArrayList<Serie>();
}
for (int i = series.length - 1; i >= 0; i--) {
chartSeries.add(series[i]);
}
return this;
} | java | public AbstractChart<T, S> addSeries(Serie... series) {
Collection<Serie> chartSeries = getSeries();
if (chartSeries == null) {
chartSeries = new ArrayList<Serie>();
}
for (int i = series.length - 1; i >= 0; i--) {
chartSeries.add(series[i]);
}
return this;
} | [
"public",
"AbstractChart",
"<",
"T",
",",
"S",
">",
"addSeries",
"(",
"Serie",
"...",
"series",
")",
"{",
"Collection",
"<",
"Serie",
">",
"chartSeries",
"=",
"getSeries",
"(",
")",
";",
"if",
"(",
"chartSeries",
"==",
"null",
")",
"{",
"chartSeries",
"=",
"new",
"ArrayList",
"<",
"Serie",
">",
"(",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"series",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"chartSeries",
".",
"add",
"(",
"series",
"[",
"i",
"]",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Add a collection of series
@param series Add series of chart
@return AbstractChart | [
"Add",
"a",
"collection",
"of",
"series"
] | 35bcd17749442e88695df0438c8330a65a3977cc | https://github.com/inaiat/jqplot4java/blob/35bcd17749442e88695df0438c8330a65a3977cc/src/main/java/br/com/digilabs/jqplot/chart/AbstractChart.java#L94-L104 |
474 | duracloud/mill | common/src/main/java/org/duracloud/mill/util/PropertyFileHelper.java | PropertyFileHelper.loadFromSystemProperty | public static void loadFromSystemProperty(String propertyFileSystemProperty, String defaultPropertyFilePath) {
String path = System.getProperty(propertyFileSystemProperty);
if (path == null) {
path = defaultPropertyFilePath;
System.setProperty(propertyFileSystemProperty, path);
log.info("Using default " + propertyFileSystemProperty + " value: "
+ path + ". To override default specify java commandline param -D"
+ propertyFileSystemProperty + "=/your/prop/file/path/here");
} else {
log.info("Using user-defined " + propertyFileSystemProperty + " property: " + path);
}
if (!new File(path).exists()) {
log.error(path + " does not exist. It is required to run this application. Exiting...");
System.exit(1);
} else {
try {
SystemPropertyLoader.load(path);
} catch (IOException e) {
e.printStackTrace();
}
}
} | java | public static void loadFromSystemProperty(String propertyFileSystemProperty, String defaultPropertyFilePath) {
String path = System.getProperty(propertyFileSystemProperty);
if (path == null) {
path = defaultPropertyFilePath;
System.setProperty(propertyFileSystemProperty, path);
log.info("Using default " + propertyFileSystemProperty + " value: "
+ path + ". To override default specify java commandline param -D"
+ propertyFileSystemProperty + "=/your/prop/file/path/here");
} else {
log.info("Using user-defined " + propertyFileSystemProperty + " property: " + path);
}
if (!new File(path).exists()) {
log.error(path + " does not exist. It is required to run this application. Exiting...");
System.exit(1);
} else {
try {
SystemPropertyLoader.load(path);
} catch (IOException e) {
e.printStackTrace();
}
}
} | [
"public",
"static",
"void",
"loadFromSystemProperty",
"(",
"String",
"propertyFileSystemProperty",
",",
"String",
"defaultPropertyFilePath",
")",
"{",
"String",
"path",
"=",
"System",
".",
"getProperty",
"(",
"propertyFileSystemProperty",
")",
";",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"path",
"=",
"defaultPropertyFilePath",
";",
"System",
".",
"setProperty",
"(",
"propertyFileSystemProperty",
",",
"path",
")",
";",
"log",
".",
"info",
"(",
"\"Using default \"",
"+",
"propertyFileSystemProperty",
"+",
"\" value: \"",
"+",
"path",
"+",
"\". To override default specify java commandline param -D\"",
"+",
"propertyFileSystemProperty",
"+",
"\"=/your/prop/file/path/here\"",
")",
";",
"}",
"else",
"{",
"log",
".",
"info",
"(",
"\"Using user-defined \"",
"+",
"propertyFileSystemProperty",
"+",
"\" property: \"",
"+",
"path",
")",
";",
"}",
"if",
"(",
"!",
"new",
"File",
"(",
"path",
")",
".",
"exists",
"(",
")",
")",
"{",
"log",
".",
"error",
"(",
"path",
"+",
"\" does not exist. It is required to run this application. Exiting...\"",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"else",
"{",
"try",
"{",
"SystemPropertyLoader",
".",
"load",
"(",
"path",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}"
] | Ensures that a specified system property is set with a valid file path.
If the system property is not set, the specified default value will set instead.
If the resulting system property value does not resolve to an existing file,
The system will exit after logging the error.
@param profileFileSystemProperty The system property to check
@param defaultFilePath The default property file path | [
"Ensures",
"that",
"a",
"specified",
"system",
"property",
"is",
"set",
"with",
"a",
"valid",
"file",
"path",
".",
"If",
"the",
"system",
"property",
"is",
"not",
"set",
"the",
"specified",
"default",
"value",
"will",
"set",
"instead",
".",
"If",
"the",
"resulting",
"system",
"property",
"value",
"does",
"not",
"resolve",
"to",
"an",
"existing",
"file",
"The",
"system",
"will",
"exit",
"after",
"logging",
"the",
"error",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/common/src/main/java/org/duracloud/mill/util/PropertyFileHelper.java#L35-L58 |
475 | duracloud/mill | common-storageprovider/src/main/java/org/duracloud/mill/common/storageprovider/StorageProviderFactory.java | StorageProviderFactory.createWithAudit | public StorageProvider createWithAudit(StorageProviderCredentials credentials,
String accountSubdomain,
TaskQueue auditQueue) {
UserUtil userUtil = new SimpleUserUtil();
StorageProvider storageprovider = create(credentials);
StorageProvider auditProvider =
new AuditStorageProvider(storageprovider,
accountSubdomain,
credentials.getProviderId(),
credentials.getProviderType().getName(),
userUtil,
auditQueue);
return auditProvider;
} | java | public StorageProvider createWithAudit(StorageProviderCredentials credentials,
String accountSubdomain,
TaskQueue auditQueue) {
UserUtil userUtil = new SimpleUserUtil();
StorageProvider storageprovider = create(credentials);
StorageProvider auditProvider =
new AuditStorageProvider(storageprovider,
accountSubdomain,
credentials.getProviderId(),
credentials.getProviderType().getName(),
userUtil,
auditQueue);
return auditProvider;
} | [
"public",
"StorageProvider",
"createWithAudit",
"(",
"StorageProviderCredentials",
"credentials",
",",
"String",
"accountSubdomain",
",",
"TaskQueue",
"auditQueue",
")",
"{",
"UserUtil",
"userUtil",
"=",
"new",
"SimpleUserUtil",
"(",
")",
";",
"StorageProvider",
"storageprovider",
"=",
"create",
"(",
"credentials",
")",
";",
"StorageProvider",
"auditProvider",
"=",
"new",
"AuditStorageProvider",
"(",
"storageprovider",
",",
"accountSubdomain",
",",
"credentials",
".",
"getProviderId",
"(",
")",
",",
"credentials",
".",
"getProviderType",
"(",
")",
".",
"getName",
"(",
")",
",",
"userUtil",
",",
"auditQueue",
")",
";",
"return",
"auditProvider",
";",
"}"
] | Creates a StorageProvider which captures events and passes them to the
audit queue.
@param credentials needed to connect to storage provider
@param accountSubdomain subdomain of the storage provider account
@param auditQueue used to capture changes to stored content
@return | [
"Creates",
"a",
"StorageProvider",
"which",
"captures",
"events",
"and",
"passes",
"them",
"to",
"the",
"audit",
"queue",
"."
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/common-storageprovider/src/main/java/org/duracloud/mill/common/storageprovider/StorageProviderFactory.java#L38-L51 |
476 | duracloud/mill | common-storageprovider/src/main/java/org/duracloud/mill/common/storageprovider/StorageProviderFactory.java | StorageProviderFactory.create | public StorageProvider create(StorageProviderCredentials credentials) {
StorageProviderType storageProviderType = credentials.getProviderType();
if (storageProviderType.equals(StorageProviderType.AMAZON_S3)) {
return new S3StorageProvider(credentials.getAccessKey(),
credentials.getSecretKey(),
credentials.getOptions());
} else if (storageProviderType.equals(StorageProviderType.AMAZON_GLACIER)) {
return new GlacierStorageProvider(credentials.getAccessKey(),
credentials.getSecretKey(),
credentials.getOptions());
} else if (storageProviderType.equals(StorageProviderType.CHRONOPOLIS)) {
return new ChronopolisStorageProvider(credentials.getAccessKey(),
credentials.getSecretKey());
}
throw new RuntimeException(storageProviderType
+ " is not a supported storage provider type");
} | java | public StorageProvider create(StorageProviderCredentials credentials) {
StorageProviderType storageProviderType = credentials.getProviderType();
if (storageProviderType.equals(StorageProviderType.AMAZON_S3)) {
return new S3StorageProvider(credentials.getAccessKey(),
credentials.getSecretKey(),
credentials.getOptions());
} else if (storageProviderType.equals(StorageProviderType.AMAZON_GLACIER)) {
return new GlacierStorageProvider(credentials.getAccessKey(),
credentials.getSecretKey(),
credentials.getOptions());
} else if (storageProviderType.equals(StorageProviderType.CHRONOPOLIS)) {
return new ChronopolisStorageProvider(credentials.getAccessKey(),
credentials.getSecretKey());
}
throw new RuntimeException(storageProviderType
+ " is not a supported storage provider type");
} | [
"public",
"StorageProvider",
"create",
"(",
"StorageProviderCredentials",
"credentials",
")",
"{",
"StorageProviderType",
"storageProviderType",
"=",
"credentials",
".",
"getProviderType",
"(",
")",
";",
"if",
"(",
"storageProviderType",
".",
"equals",
"(",
"StorageProviderType",
".",
"AMAZON_S3",
")",
")",
"{",
"return",
"new",
"S3StorageProvider",
"(",
"credentials",
".",
"getAccessKey",
"(",
")",
",",
"credentials",
".",
"getSecretKey",
"(",
")",
",",
"credentials",
".",
"getOptions",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"storageProviderType",
".",
"equals",
"(",
"StorageProviderType",
".",
"AMAZON_GLACIER",
")",
")",
"{",
"return",
"new",
"GlacierStorageProvider",
"(",
"credentials",
".",
"getAccessKey",
"(",
")",
",",
"credentials",
".",
"getSecretKey",
"(",
")",
",",
"credentials",
".",
"getOptions",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"storageProviderType",
".",
"equals",
"(",
"StorageProviderType",
".",
"CHRONOPOLIS",
")",
")",
"{",
"return",
"new",
"ChronopolisStorageProvider",
"(",
"credentials",
".",
"getAccessKey",
"(",
")",
",",
"credentials",
".",
"getSecretKey",
"(",
")",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"storageProviderType",
"+",
"\" is not a supported storage provider type\"",
")",
";",
"}"
] | Creates a StorageProvider
@param credentials
@return | [
"Creates",
"a",
"StorageProvider"
] | 854ac6edcba7fa2cab60993f172e82c2d1dad4bd | https://github.com/duracloud/mill/blob/854ac6edcba7fa2cab60993f172e82c2d1dad4bd/common-storageprovider/src/main/java/org/duracloud/mill/common/storageprovider/StorageProviderFactory.java#L59-L77 |
477 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/zookeeper/TephraZKClientService.java | TephraZKClientService.wrapWatcher | private Watcher wrapWatcher(final Watcher watcher) {
if (watcher == null) {
return null;
}
return new Watcher() {
@Override
public void process(final WatchedEvent event) {
if (eventExecutor.isShutdown()) {
LOG.debug("Already shutdown. Discarding event: {}", event);
return;
}
eventExecutor.execute(new Runnable() {
@Override
public void run() {
try {
watcher.process(event);
} catch (Throwable t) {
LOG.error("Watcher throws exception.", t);
}
}
});
}
};
} | java | private Watcher wrapWatcher(final Watcher watcher) {
if (watcher == null) {
return null;
}
return new Watcher() {
@Override
public void process(final WatchedEvent event) {
if (eventExecutor.isShutdown()) {
LOG.debug("Already shutdown. Discarding event: {}", event);
return;
}
eventExecutor.execute(new Runnable() {
@Override
public void run() {
try {
watcher.process(event);
} catch (Throwable t) {
LOG.error("Watcher throws exception.", t);
}
}
});
}
};
} | [
"private",
"Watcher",
"wrapWatcher",
"(",
"final",
"Watcher",
"watcher",
")",
"{",
"if",
"(",
"watcher",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"Watcher",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"process",
"(",
"final",
"WatchedEvent",
"event",
")",
"{",
"if",
"(",
"eventExecutor",
".",
"isShutdown",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Already shutdown. Discarding event: {}\"",
",",
"event",
")",
";",
"return",
";",
"}",
"eventExecutor",
".",
"execute",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"watcher",
".",
"process",
"(",
"event",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Watcher throws exception.\"",
",",
"t",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
"}",
";",
"}"
] | Wraps the given watcher to be called from the event executor.
@param watcher Watcher to be wrapped
@return The wrapped Watcher | [
"Wraps",
"the",
"given",
"watcher",
"to",
"be",
"called",
"from",
"the",
"event",
"executor",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/zookeeper/TephraZKClientService.java#L383-L406 |
478 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/zookeeper/TephraZKClientService.java | TephraZKClientService.copyAuthInfo | private Multimap<String, byte[]> copyAuthInfo(Multimap<String, byte[]> authInfos) {
Multimap<String, byte[]> result = ArrayListMultimap.create();
for (Map.Entry<String, byte[]> entry : authInfos.entries()) {
byte[] info = entry.getValue();
result.put(entry.getKey(), info == null ? null : Arrays.copyOf(info, info.length));
}
return result;
} | java | private Multimap<String, byte[]> copyAuthInfo(Multimap<String, byte[]> authInfos) {
Multimap<String, byte[]> result = ArrayListMultimap.create();
for (Map.Entry<String, byte[]> entry : authInfos.entries()) {
byte[] info = entry.getValue();
result.put(entry.getKey(), info == null ? null : Arrays.copyOf(info, info.length));
}
return result;
} | [
"private",
"Multimap",
"<",
"String",
",",
"byte",
"[",
"]",
">",
"copyAuthInfo",
"(",
"Multimap",
"<",
"String",
",",
"byte",
"[",
"]",
">",
"authInfos",
")",
"{",
"Multimap",
"<",
"String",
",",
"byte",
"[",
"]",
">",
"result",
"=",
"ArrayListMultimap",
".",
"create",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"byte",
"[",
"]",
">",
"entry",
":",
"authInfos",
".",
"entries",
"(",
")",
")",
"{",
"byte",
"[",
"]",
"info",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"result",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"info",
"==",
"null",
"?",
"null",
":",
"Arrays",
".",
"copyOf",
"(",
"info",
",",
"info",
".",
"length",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Creates a deep copy of the given authInfos multimap. | [
"Creates",
"a",
"deep",
"copy",
"of",
"the",
"given",
"authInfos",
"multimap",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/zookeeper/TephraZKClientService.java#L411-L420 |
479 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/zookeeper/TephraZKClientService.java | TephraZKClientService.createZooKeeper | private ZooKeeper createZooKeeper() throws IOException {
ZooKeeper zk = new ZooKeeper(zkStr, sessionTimeout, wrapWatcher(this));
for (Map.Entry<String, byte[]> authInfo : authInfos.entries()) {
zk.addAuthInfo(authInfo.getKey(), authInfo.getValue());
}
return zk;
} | java | private ZooKeeper createZooKeeper() throws IOException {
ZooKeeper zk = new ZooKeeper(zkStr, sessionTimeout, wrapWatcher(this));
for (Map.Entry<String, byte[]> authInfo : authInfos.entries()) {
zk.addAuthInfo(authInfo.getKey(), authInfo.getValue());
}
return zk;
} | [
"private",
"ZooKeeper",
"createZooKeeper",
"(",
")",
"throws",
"IOException",
"{",
"ZooKeeper",
"zk",
"=",
"new",
"ZooKeeper",
"(",
"zkStr",
",",
"sessionTimeout",
",",
"wrapWatcher",
"(",
"this",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"byte",
"[",
"]",
">",
"authInfo",
":",
"authInfos",
".",
"entries",
"(",
")",
")",
"{",
"zk",
".",
"addAuthInfo",
"(",
"authInfo",
".",
"getKey",
"(",
")",
",",
"authInfo",
".",
"getValue",
"(",
")",
")",
";",
"}",
"return",
"zk",
";",
"}"
] | Creates a new ZooKeeper connection. | [
"Creates",
"a",
"new",
"ZooKeeper",
"connection",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/zookeeper/TephraZKClientService.java#L470-L476 |
480 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/persist/HDFSUtil.java | HDFSUtil.recoverFileLease | public void recoverFileLease(final FileSystem fs, final Path p,
Configuration conf)
throws IOException {
// lease recovery not needed for local file system case.
if (!(fs instanceof DistributedFileSystem)) {
return;
}
recoverDFSFileLease((DistributedFileSystem) fs, p, conf);
} | java | public void recoverFileLease(final FileSystem fs, final Path p,
Configuration conf)
throws IOException {
// lease recovery not needed for local file system case.
if (!(fs instanceof DistributedFileSystem)) {
return;
}
recoverDFSFileLease((DistributedFileSystem) fs, p, conf);
} | [
"public",
"void",
"recoverFileLease",
"(",
"final",
"FileSystem",
"fs",
",",
"final",
"Path",
"p",
",",
"Configuration",
"conf",
")",
"throws",
"IOException",
"{",
"// lease recovery not needed for local file system case.",
"if",
"(",
"!",
"(",
"fs",
"instanceof",
"DistributedFileSystem",
")",
")",
"{",
"return",
";",
"}",
"recoverDFSFileLease",
"(",
"(",
"DistributedFileSystem",
")",
"fs",
",",
"p",
",",
"conf",
")",
";",
"}"
] | Recover the lease from HDFS, retrying multiple times. | [
"Recover",
"the",
"lease",
"from",
"HDFS",
"retrying",
"multiple",
"times",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/persist/HDFSUtil.java#L45-L53 |
481 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/persist/HDFSUtil.java | HDFSUtil.recoverLease | boolean recoverLease(final DistributedFileSystem dfs, final int nbAttempt, final Path p,
final long startWaiting)
throws FileNotFoundException {
boolean recovered = false;
try {
recovered = dfs.recoverLease(p);
LOG.info("recoverLease=" + recovered + ", " +
getLogMessageDetail(nbAttempt, p, startWaiting));
} catch (IOException e) {
if (e instanceof LeaseExpiredException && e.getMessage().contains("File does not exist")) {
// This exception comes out instead of FNFE, fix it
throw new FileNotFoundException("The given file wasn't found at " + p);
} else if (e instanceof FileNotFoundException) {
throw (FileNotFoundException) e;
}
LOG.warn(getLogMessageDetail(nbAttempt, p, startWaiting), e);
}
return recovered;
} | java | boolean recoverLease(final DistributedFileSystem dfs, final int nbAttempt, final Path p,
final long startWaiting)
throws FileNotFoundException {
boolean recovered = false;
try {
recovered = dfs.recoverLease(p);
LOG.info("recoverLease=" + recovered + ", " +
getLogMessageDetail(nbAttempt, p, startWaiting));
} catch (IOException e) {
if (e instanceof LeaseExpiredException && e.getMessage().contains("File does not exist")) {
// This exception comes out instead of FNFE, fix it
throw new FileNotFoundException("The given file wasn't found at " + p);
} else if (e instanceof FileNotFoundException) {
throw (FileNotFoundException) e;
}
LOG.warn(getLogMessageDetail(nbAttempt, p, startWaiting), e);
}
return recovered;
} | [
"boolean",
"recoverLease",
"(",
"final",
"DistributedFileSystem",
"dfs",
",",
"final",
"int",
"nbAttempt",
",",
"final",
"Path",
"p",
",",
"final",
"long",
"startWaiting",
")",
"throws",
"FileNotFoundException",
"{",
"boolean",
"recovered",
"=",
"false",
";",
"try",
"{",
"recovered",
"=",
"dfs",
".",
"recoverLease",
"(",
"p",
")",
";",
"LOG",
".",
"info",
"(",
"\"recoverLease=\"",
"+",
"recovered",
"+",
"\", \"",
"+",
"getLogMessageDetail",
"(",
"nbAttempt",
",",
"p",
",",
"startWaiting",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"if",
"(",
"e",
"instanceof",
"LeaseExpiredException",
"&&",
"e",
".",
"getMessage",
"(",
")",
".",
"contains",
"(",
"\"File does not exist\"",
")",
")",
"{",
"// This exception comes out instead of FNFE, fix it",
"throw",
"new",
"FileNotFoundException",
"(",
"\"The given file wasn't found at \"",
"+",
"p",
")",
";",
"}",
"else",
"if",
"(",
"e",
"instanceof",
"FileNotFoundException",
")",
"{",
"throw",
"(",
"FileNotFoundException",
")",
"e",
";",
"}",
"LOG",
".",
"warn",
"(",
"getLogMessageDetail",
"(",
"nbAttempt",
",",
"p",
",",
"startWaiting",
")",
",",
"e",
")",
";",
"}",
"return",
"recovered",
";",
"}"
] | Try to recover the lease.
@param dfs The filesystem instance.
@param nbAttempt Count number of this attempt.
@param p Path of the file to recover.
@param startWaiting Timestamp of when we started attempting to recover the file lease.
@return True if dfs#recoverLease came by true.
@throws java.io.FileNotFoundException | [
"Try",
"to",
"recover",
"the",
"lease",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/persist/HDFSUtil.java#L164-L182 |
482 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/persist/HDFSUtil.java | HDFSUtil.isFileClosed | private boolean isFileClosed(final DistributedFileSystem dfs, final Method m, final Path p) {
try {
return (Boolean) m.invoke(dfs, p);
} catch (SecurityException e) {
LOG.warn("No access", e);
} catch (Exception e) {
LOG.warn("Failed invocation for " + p.toString(), e);
}
return false;
} | java | private boolean isFileClosed(final DistributedFileSystem dfs, final Method m, final Path p) {
try {
return (Boolean) m.invoke(dfs, p);
} catch (SecurityException e) {
LOG.warn("No access", e);
} catch (Exception e) {
LOG.warn("Failed invocation for " + p.toString(), e);
}
return false;
} | [
"private",
"boolean",
"isFileClosed",
"(",
"final",
"DistributedFileSystem",
"dfs",
",",
"final",
"Method",
"m",
",",
"final",
"Path",
"p",
")",
"{",
"try",
"{",
"return",
"(",
"Boolean",
")",
"m",
".",
"invoke",
"(",
"dfs",
",",
"p",
")",
";",
"}",
"catch",
"(",
"SecurityException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"No access\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed invocation for \"",
"+",
"p",
".",
"toString",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Call HDFS-4525 isFileClosed if it is available.
@param dfs Filesystem instance to use.
@param m Method instance to call.
@param p Path of the file to check is closed.
@return True if file is closed. | [
"Call",
"HDFS",
"-",
"4525",
"isFileClosed",
"if",
"it",
"is",
"available",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/persist/HDFSUtil.java#L202-L211 |
483 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/distributed/TransactionServiceClient.java | TransactionServiceClient.main | public static void main(String[] args) throws Exception {
if (args.length > 1 || (args.length == 1 && !"-v".equals(args[0]))) {
System.out.println("USAGE: TransactionServiceClient [-v]");
}
boolean verbose = false;
if (args.length == 1 && "-v".equals(args[0])) {
verbose = true;
}
doMain(verbose, new ConfigurationFactory().get());
} | java | public static void main(String[] args) throws Exception {
if (args.length > 1 || (args.length == 1 && !"-v".equals(args[0]))) {
System.out.println("USAGE: TransactionServiceClient [-v]");
}
boolean verbose = false;
if (args.length == 1 && "-v".equals(args[0])) {
verbose = true;
}
doMain(verbose, new ConfigurationFactory().get());
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"if",
"(",
"args",
".",
"length",
">",
"1",
"||",
"(",
"args",
".",
"length",
"==",
"1",
"&&",
"!",
"\"-v\"",
".",
"equals",
"(",
"args",
"[",
"0",
"]",
")",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"USAGE: TransactionServiceClient [-v]\"",
")",
";",
"}",
"boolean",
"verbose",
"=",
"false",
";",
"if",
"(",
"args",
".",
"length",
"==",
"1",
"&&",
"\"-v\"",
".",
"equals",
"(",
"args",
"[",
"0",
"]",
")",
")",
"{",
"verbose",
"=",
"true",
";",
"}",
"doMain",
"(",
"verbose",
",",
"new",
"ConfigurationFactory",
"(",
")",
".",
"get",
"(",
")",
")",
";",
"}"
] | Utility to be used for basic verification of transaction system availability and functioning
@param args arguments list, accepts single option "-v" that makes it to print out more details about started tx
@throws Exception | [
"Utility",
"to",
"be",
"used",
"for",
"basic",
"verification",
"of",
"transaction",
"system",
"availability",
"and",
"functioning"
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/distributed/TransactionServiceClient.java#L69-L79 |
484 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/distributed/TransactionServiceClient.java | TransactionServiceClient.execute | private <T> T execute(Operation<T> operation, ThriftClientProvider provider) throws Exception {
RetryStrategy retryStrategy = retryStrategyProvider.newRetryStrategy();
while (true) {
// did we get a custom client provider or do we use the default?
if (provider == null) {
provider = this.clientProvider;
}
// this will throw a TException if it cannot get a client
try (CloseableThriftClient closeable = provider.getCloseableClient()) {
// note that this can throw exceptions other than TException
return operation.execute(closeable.getThriftClient());
} catch (TException te) {
// determine whether we should retry
boolean retry = retryStrategy.failOnce();
if (!retry) {
// retry strategy is exceeded, throw an operation exception
String message =
"Thrift error for " + operation + ": " + te.getMessage();
LOG.error(message);
LOG.debug(message, te);
throw new Exception(message, te);
} else {
// call retry strategy before retrying
retryStrategy.beforeRetry();
String msg = "Retrying " + operation.getName() + " after Thrift error: " + te.getMessage();
LOG.info(msg);
LOG.debug(msg, te);
}
}
}
} | java | private <T> T execute(Operation<T> operation, ThriftClientProvider provider) throws Exception {
RetryStrategy retryStrategy = retryStrategyProvider.newRetryStrategy();
while (true) {
// did we get a custom client provider or do we use the default?
if (provider == null) {
provider = this.clientProvider;
}
// this will throw a TException if it cannot get a client
try (CloseableThriftClient closeable = provider.getCloseableClient()) {
// note that this can throw exceptions other than TException
return operation.execute(closeable.getThriftClient());
} catch (TException te) {
// determine whether we should retry
boolean retry = retryStrategy.failOnce();
if (!retry) {
// retry strategy is exceeded, throw an operation exception
String message =
"Thrift error for " + operation + ": " + te.getMessage();
LOG.error(message);
LOG.debug(message, te);
throw new Exception(message, te);
} else {
// call retry strategy before retrying
retryStrategy.beforeRetry();
String msg = "Retrying " + operation.getName() + " after Thrift error: " + te.getMessage();
LOG.info(msg);
LOG.debug(msg, te);
}
}
}
} | [
"private",
"<",
"T",
">",
"T",
"execute",
"(",
"Operation",
"<",
"T",
">",
"operation",
",",
"ThriftClientProvider",
"provider",
")",
"throws",
"Exception",
"{",
"RetryStrategy",
"retryStrategy",
"=",
"retryStrategyProvider",
".",
"newRetryStrategy",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"// did we get a custom client provider or do we use the default?",
"if",
"(",
"provider",
"==",
"null",
")",
"{",
"provider",
"=",
"this",
".",
"clientProvider",
";",
"}",
"// this will throw a TException if it cannot get a client",
"try",
"(",
"CloseableThriftClient",
"closeable",
"=",
"provider",
".",
"getCloseableClient",
"(",
")",
")",
"{",
"// note that this can throw exceptions other than TException",
"return",
"operation",
".",
"execute",
"(",
"closeable",
".",
"getThriftClient",
"(",
")",
")",
";",
"}",
"catch",
"(",
"TException",
"te",
")",
"{",
"// determine whether we should retry",
"boolean",
"retry",
"=",
"retryStrategy",
".",
"failOnce",
"(",
")",
";",
"if",
"(",
"!",
"retry",
")",
"{",
"// retry strategy is exceeded, throw an operation exception",
"String",
"message",
"=",
"\"Thrift error for \"",
"+",
"operation",
"+",
"\": \"",
"+",
"te",
".",
"getMessage",
"(",
")",
";",
"LOG",
".",
"error",
"(",
"message",
")",
";",
"LOG",
".",
"debug",
"(",
"message",
",",
"te",
")",
";",
"throw",
"new",
"Exception",
"(",
"message",
",",
"te",
")",
";",
"}",
"else",
"{",
"// call retry strategy before retrying",
"retryStrategy",
".",
"beforeRetry",
"(",
")",
";",
"String",
"msg",
"=",
"\"Retrying \"",
"+",
"operation",
".",
"getName",
"(",
")",
"+",
"\" after Thrift error: \"",
"+",
"te",
".",
"getMessage",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"msg",
")",
";",
"LOG",
".",
"debug",
"(",
"msg",
",",
"te",
")",
";",
"}",
"}",
"}",
"}"
] | This is a generic method implementing the somewhat complex execution
and retry logic for operations, to avoid repetitive code.
Attempts to execute one operation, by obtaining an tx client from
the client provider and passing the operation to the client. If the
call fails with a Thrift exception, apply the retry strategy. If no
more retries are to be made according to the strategy, call the
operation's error method to obtain a value to return. Note that error()
may also throw an exception. Note also that the retry logic is only
applied for thrift exceptions.
@param operation The operation to be executed
@param provider An tx client provider. If null, then a client will be
obtained using the client provider
@param <T> The return type of the operation
@return the result of the operation, or a value returned by error() | [
"This",
"is",
"a",
"generic",
"method",
"implementing",
"the",
"somewhat",
"complex",
"execution",
"and",
"retry",
"logic",
"for",
"operations",
"to",
"avoid",
"repetitive",
"code",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/distributed/TransactionServiceClient.java#L207-L239 |
485 | cdapio/tephra | tephra-hbase-compat-1.1/src/main/java/co/cask/tephra/hbase11/coprocessor/TransactionVisibilityFilter.java | TransactionVisibilityFilter.determineReturnCode | protected ReturnCode determineReturnCode(ReturnCode txFilterCode, ReturnCode subFilterCode) {
// Return the more restrictive of the two filter responses
switch (subFilterCode) {
case INCLUDE:
return txFilterCode;
case INCLUDE_AND_NEXT_COL:
return ReturnCode.INCLUDE_AND_NEXT_COL;
case SKIP:
return txFilterCode == ReturnCode.INCLUDE ? ReturnCode.SKIP : ReturnCode.NEXT_COL;
default:
return subFilterCode;
}
} | java | protected ReturnCode determineReturnCode(ReturnCode txFilterCode, ReturnCode subFilterCode) {
// Return the more restrictive of the two filter responses
switch (subFilterCode) {
case INCLUDE:
return txFilterCode;
case INCLUDE_AND_NEXT_COL:
return ReturnCode.INCLUDE_AND_NEXT_COL;
case SKIP:
return txFilterCode == ReturnCode.INCLUDE ? ReturnCode.SKIP : ReturnCode.NEXT_COL;
default:
return subFilterCode;
}
} | [
"protected",
"ReturnCode",
"determineReturnCode",
"(",
"ReturnCode",
"txFilterCode",
",",
"ReturnCode",
"subFilterCode",
")",
"{",
"// Return the more restrictive of the two filter responses",
"switch",
"(",
"subFilterCode",
")",
"{",
"case",
"INCLUDE",
":",
"return",
"txFilterCode",
";",
"case",
"INCLUDE_AND_NEXT_COL",
":",
"return",
"ReturnCode",
".",
"INCLUDE_AND_NEXT_COL",
";",
"case",
"SKIP",
":",
"return",
"txFilterCode",
"==",
"ReturnCode",
".",
"INCLUDE",
"?",
"ReturnCode",
".",
"SKIP",
":",
"ReturnCode",
".",
"NEXT_COL",
";",
"default",
":",
"return",
"subFilterCode",
";",
"}",
"}"
] | Determines the return code of TransactionVisibilityFilter based on sub-filter's return code.
Sub-filter can only exclude cells included by TransactionVisibilityFilter, i.e., sub-filter's
INCLUDE will be ignored. This behavior makes sure that sub-filter only sees cell versions valid for the
given transaction. If sub-filter needs to see older versions of cell, then this method can be overridden.
@param txFilterCode return code from TransactionVisibilityFilter
@param subFilterCode return code from sub-filter
@return final return code | [
"Determines",
"the",
"return",
"code",
"of",
"TransactionVisibilityFilter",
"based",
"on",
"sub",
"-",
"filter",
"s",
"return",
"code",
".",
"Sub",
"-",
"filter",
"can",
"only",
"exclude",
"cells",
"included",
"by",
"TransactionVisibilityFilter",
"i",
".",
"e",
".",
"sub",
"-",
"filter",
"s",
"INCLUDE",
"will",
"be",
"ignored",
".",
"This",
"behavior",
"makes",
"sure",
"that",
"sub",
"-",
"filter",
"only",
"sees",
"cell",
"versions",
"valid",
"for",
"the",
"given",
"transaction",
".",
"If",
"sub",
"-",
"filter",
"needs",
"to",
"see",
"older",
"versions",
"of",
"cell",
"then",
"this",
"method",
"can",
"be",
"overridden",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-hbase-compat-1.1/src/main/java/co/cask/tephra/hbase11/coprocessor/TransactionVisibilityFilter.java#L173-L185 |
486 | cdapio/tephra | tephra-hbase-compat-1.1/src/main/java/co/cask/tephra/hbase11/coprocessor/TransactionProcessor.java | TransactionProcessor.projectFamilyDeletes | private Scan projectFamilyDeletes(Scan scan) {
for (Map.Entry<byte[], NavigableSet<byte[]>> entry : scan.getFamilyMap().entrySet()) {
NavigableSet<byte[]> columns = entry.getValue();
// wildcard scans will automatically include the delete marker, so only need to add it when we have
// explicit columns listed
if (columns != null && !columns.isEmpty()) {
scan.addColumn(entry.getKey(), TxConstants.FAMILY_DELETE_QUALIFIER);
}
}
return scan;
} | java | private Scan projectFamilyDeletes(Scan scan) {
for (Map.Entry<byte[], NavigableSet<byte[]>> entry : scan.getFamilyMap().entrySet()) {
NavigableSet<byte[]> columns = entry.getValue();
// wildcard scans will automatically include the delete marker, so only need to add it when we have
// explicit columns listed
if (columns != null && !columns.isEmpty()) {
scan.addColumn(entry.getKey(), TxConstants.FAMILY_DELETE_QUALIFIER);
}
}
return scan;
} | [
"private",
"Scan",
"projectFamilyDeletes",
"(",
"Scan",
"scan",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"byte",
"[",
"]",
",",
"NavigableSet",
"<",
"byte",
"[",
"]",
">",
">",
"entry",
":",
"scan",
".",
"getFamilyMap",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"NavigableSet",
"<",
"byte",
"[",
"]",
">",
"columns",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"// wildcard scans will automatically include the delete marker, so only need to add it when we have",
"// explicit columns listed",
"if",
"(",
"columns",
"!=",
"null",
"&&",
"!",
"columns",
".",
"isEmpty",
"(",
")",
")",
"{",
"scan",
".",
"addColumn",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"TxConstants",
".",
"FAMILY_DELETE_QUALIFIER",
")",
";",
"}",
"}",
"return",
"scan",
";",
"}"
] | Ensures that family delete markers are present in the columns requested for any scan operation.
@param scan The original scan request
@return The modified scan request with the family delete qualifiers represented | [
"Ensures",
"that",
"family",
"delete",
"markers",
"are",
"present",
"in",
"the",
"columns",
"requested",
"for",
"any",
"scan",
"operation",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-hbase-compat-1.1/src/main/java/co/cask/tephra/hbase11/coprocessor/TransactionProcessor.java#L226-L236 |
487 | cdapio/tephra | tephra-hbase-compat-1.1/src/main/java/co/cask/tephra/hbase11/coprocessor/TransactionProcessor.java | TransactionProcessor.projectFamilyDeletes | private Get projectFamilyDeletes(Get get) {
for (Map.Entry<byte[], NavigableSet<byte[]>> entry : get.getFamilyMap().entrySet()) {
NavigableSet<byte[]> columns = entry.getValue();
// wildcard scans will automatically include the delete marker, so only need to add it when we have
// explicit columns listed
if (columns != null && !columns.isEmpty()) {
get.addColumn(entry.getKey(), TxConstants.FAMILY_DELETE_QUALIFIER);
}
}
return get;
} | java | private Get projectFamilyDeletes(Get get) {
for (Map.Entry<byte[], NavigableSet<byte[]>> entry : get.getFamilyMap().entrySet()) {
NavigableSet<byte[]> columns = entry.getValue();
// wildcard scans will automatically include the delete marker, so only need to add it when we have
// explicit columns listed
if (columns != null && !columns.isEmpty()) {
get.addColumn(entry.getKey(), TxConstants.FAMILY_DELETE_QUALIFIER);
}
}
return get;
} | [
"private",
"Get",
"projectFamilyDeletes",
"(",
"Get",
"get",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"byte",
"[",
"]",
",",
"NavigableSet",
"<",
"byte",
"[",
"]",
">",
">",
"entry",
":",
"get",
".",
"getFamilyMap",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"NavigableSet",
"<",
"byte",
"[",
"]",
">",
"columns",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"// wildcard scans will automatically include the delete marker, so only need to add it when we have",
"// explicit columns listed",
"if",
"(",
"columns",
"!=",
"null",
"&&",
"!",
"columns",
".",
"isEmpty",
"(",
")",
")",
"{",
"get",
".",
"addColumn",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"TxConstants",
".",
"FAMILY_DELETE_QUALIFIER",
")",
";",
"}",
"}",
"return",
"get",
";",
"}"
] | Ensures that family delete markers are present in the columns requested for any get operation.
@param get The original get request
@return The modified get request with the family delete qualifiers represented | [
"Ensures",
"that",
"family",
"delete",
"markers",
"are",
"present",
"in",
"the",
"columns",
"requested",
"for",
"any",
"get",
"operation",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-hbase-compat-1.1/src/main/java/co/cask/tephra/hbase11/coprocessor/TransactionProcessor.java#L243-L253 |
488 | cdapio/tephra | tephra-hbase-compat-1.1/src/main/java/co/cask/tephra/hbase11/coprocessor/TransactionProcessor.java | TransactionProcessor.getTransactionFilter | protected Filter getTransactionFilter(Transaction tx, ScanType type, Filter filter) {
return TransactionFilters.getVisibilityFilter(tx, ttlByFamily, allowEmptyValues, type, filter);
} | java | protected Filter getTransactionFilter(Transaction tx, ScanType type, Filter filter) {
return TransactionFilters.getVisibilityFilter(tx, ttlByFamily, allowEmptyValues, type, filter);
} | [
"protected",
"Filter",
"getTransactionFilter",
"(",
"Transaction",
"tx",
",",
"ScanType",
"type",
",",
"Filter",
"filter",
")",
"{",
"return",
"TransactionFilters",
".",
"getVisibilityFilter",
"(",
"tx",
",",
"ttlByFamily",
",",
"allowEmptyValues",
",",
"type",
",",
"filter",
")",
";",
"}"
] | Derived classes can override this method to customize the filter used to return data visible for the current
transaction.
@param tx the current transaction to apply
@param type the type of scan being performed | [
"Derived",
"classes",
"can",
"override",
"this",
"method",
"to",
"customize",
"the",
"filter",
"used",
"to",
"return",
"data",
"visible",
"for",
"the",
"current",
"transaction",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-hbase-compat-1.1/src/main/java/co/cask/tephra/hbase11/coprocessor/TransactionProcessor.java#L314-L316 |
489 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/TransactionContext.java | TransactionContext.addTransactionAware | public boolean addTransactionAware(TransactionAware txAware) {
// If the txAware is newly added, call startTx as well if there is an active transaction
boolean added = txAwares.add(txAware);
if (added && currentTx != null) {
txAware.startTx(currentTx);
}
return added;
} | java | public boolean addTransactionAware(TransactionAware txAware) {
// If the txAware is newly added, call startTx as well if there is an active transaction
boolean added = txAwares.add(txAware);
if (added && currentTx != null) {
txAware.startTx(currentTx);
}
return added;
} | [
"public",
"boolean",
"addTransactionAware",
"(",
"TransactionAware",
"txAware",
")",
"{",
"// If the txAware is newly added, call startTx as well if there is an active transaction",
"boolean",
"added",
"=",
"txAwares",
".",
"add",
"(",
"txAware",
")",
";",
"if",
"(",
"added",
"&&",
"currentTx",
"!=",
"null",
")",
"{",
"txAware",
".",
"startTx",
"(",
"currentTx",
")",
";",
"}",
"return",
"added",
";",
"}"
] | Adds a new transaction-aware to participate in the transaction.
@param txAware the new transaction-aware | [
"Adds",
"a",
"new",
"transaction",
"-",
"aware",
"to",
"participate",
"in",
"the",
"transaction",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/TransactionContext.java#L57-L64 |
490 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/TransactionContext.java | TransactionContext.abort | public void abort(TransactionFailureException cause) throws TransactionFailureException {
if (currentTx == null) {
// might be called by some generic exception handler even though already aborted/finished - we allow that
return;
}
try {
boolean success = true;
for (TransactionAware txAware : txAwares) {
try {
if (!txAware.rollbackTx()) {
success = false;
}
} catch (Throwable e) {
String message = String.format("Unable to roll back changes in transaction-aware '%s' for transaction %d. ",
txAware.getTransactionAwareName(), currentTx.getTransactionId());
LOG.warn(message, e);
if (cause == null) {
cause = new TransactionFailureException(message, e);
}
success = false;
}
}
if (success) {
txClient.abort(currentTx);
} else {
txClient.invalidate(currentTx.getTransactionId());
}
if (cause != null) {
throw cause;
}
} finally {
currentTx = null;
}
} | java | public void abort(TransactionFailureException cause) throws TransactionFailureException {
if (currentTx == null) {
// might be called by some generic exception handler even though already aborted/finished - we allow that
return;
}
try {
boolean success = true;
for (TransactionAware txAware : txAwares) {
try {
if (!txAware.rollbackTx()) {
success = false;
}
} catch (Throwable e) {
String message = String.format("Unable to roll back changes in transaction-aware '%s' for transaction %d. ",
txAware.getTransactionAwareName(), currentTx.getTransactionId());
LOG.warn(message, e);
if (cause == null) {
cause = new TransactionFailureException(message, e);
}
success = false;
}
}
if (success) {
txClient.abort(currentTx);
} else {
txClient.invalidate(currentTx.getTransactionId());
}
if (cause != null) {
throw cause;
}
} finally {
currentTx = null;
}
} | [
"public",
"void",
"abort",
"(",
"TransactionFailureException",
"cause",
")",
"throws",
"TransactionFailureException",
"{",
"if",
"(",
"currentTx",
"==",
"null",
")",
"{",
"// might be called by some generic exception handler even though already aborted/finished - we allow that",
"return",
";",
"}",
"try",
"{",
"boolean",
"success",
"=",
"true",
";",
"for",
"(",
"TransactionAware",
"txAware",
":",
"txAwares",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"txAware",
".",
"rollbackTx",
"(",
")",
")",
"{",
"success",
"=",
"false",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Unable to roll back changes in transaction-aware '%s' for transaction %d. \"",
",",
"txAware",
".",
"getTransactionAwareName",
"(",
")",
",",
"currentTx",
".",
"getTransactionId",
"(",
")",
")",
";",
"LOG",
".",
"warn",
"(",
"message",
",",
"e",
")",
";",
"if",
"(",
"cause",
"==",
"null",
")",
"{",
"cause",
"=",
"new",
"TransactionFailureException",
"(",
"message",
",",
"e",
")",
";",
"}",
"success",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"success",
")",
"{",
"txClient",
".",
"abort",
"(",
"currentTx",
")",
";",
"}",
"else",
"{",
"txClient",
".",
"invalidate",
"(",
"currentTx",
".",
"getTransactionId",
"(",
")",
")",
";",
"}",
"if",
"(",
"cause",
"!=",
"null",
")",
"{",
"throw",
"cause",
";",
"}",
"}",
"finally",
"{",
"currentTx",
"=",
"null",
";",
"}",
"}"
] | Aborts the given transaction, and rolls back all data set changes. If rollback fails,
the transaction is invalidated. If an exception is caught during rollback, the exception
is rethrown wrapped into a TransactionFailureException, after all remaining TransactionAwares have
completed rollback. If an existing exception is passed in, that exception is thrown in either
case, whether the rollback is successful or not. In other words, this method always throws the
first exception that it encounters.
@param cause the original exception that caused the abort
@throws TransactionFailureException for any exception that is encountered. | [
"Aborts",
"the",
"given",
"transaction",
"and",
"rolls",
"back",
"all",
"data",
"set",
"changes",
".",
"If",
"rollback",
"fails",
"the",
"transaction",
"is",
"invalidated",
".",
"If",
"an",
"exception",
"is",
"caught",
"during",
"rollback",
"the",
"exception",
"is",
"rethrown",
"wrapped",
"into",
"a",
"TransactionFailureException",
"after",
"all",
"remaining",
"TransactionAwares",
"have",
"completed",
"rollback",
".",
"If",
"an",
"existing",
"exception",
"is",
"passed",
"in",
"that",
"exception",
"is",
"thrown",
"in",
"either",
"case",
"whether",
"the",
"rollback",
"is",
"successful",
"or",
"not",
".",
"In",
"other",
"words",
"this",
"method",
"always",
"throws",
"the",
"first",
"exception",
"that",
"it",
"encounters",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/TransactionContext.java#L189-L222 |
491 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/distributed/AbstractClientProvider.java | AbstractClientProvider.initDiscovery | private void initDiscovery() {
if (discoveryServiceClient == null) {
LOG.info("No DiscoveryServiceClient provided. Skipping service discovery.");
return;
}
endpointStrategy = new TimeLimitEndpointStrategy(
new RandomEndpointStrategy(
discoveryServiceClient.discover(
configuration.get(TxConstants.Service.CFG_DATA_TX_DISCOVERY_SERVICE_NAME,
TxConstants.Service.DEFAULT_DATA_TX_DISCOVERY_SERVICE_NAME))),
2, TimeUnit.SECONDS);
} | java | private void initDiscovery() {
if (discoveryServiceClient == null) {
LOG.info("No DiscoveryServiceClient provided. Skipping service discovery.");
return;
}
endpointStrategy = new TimeLimitEndpointStrategy(
new RandomEndpointStrategy(
discoveryServiceClient.discover(
configuration.get(TxConstants.Service.CFG_DATA_TX_DISCOVERY_SERVICE_NAME,
TxConstants.Service.DEFAULT_DATA_TX_DISCOVERY_SERVICE_NAME))),
2, TimeUnit.SECONDS);
} | [
"private",
"void",
"initDiscovery",
"(",
")",
"{",
"if",
"(",
"discoveryServiceClient",
"==",
"null",
")",
"{",
"LOG",
".",
"info",
"(",
"\"No DiscoveryServiceClient provided. Skipping service discovery.\"",
")",
";",
"return",
";",
"}",
"endpointStrategy",
"=",
"new",
"TimeLimitEndpointStrategy",
"(",
"new",
"RandomEndpointStrategy",
"(",
"discoveryServiceClient",
".",
"discover",
"(",
"configuration",
".",
"get",
"(",
"TxConstants",
".",
"Service",
".",
"CFG_DATA_TX_DISCOVERY_SERVICE_NAME",
",",
"TxConstants",
".",
"Service",
".",
"DEFAULT_DATA_TX_DISCOVERY_SERVICE_NAME",
")",
")",
")",
",",
"2",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}"
] | Initialize the service discovery client, we will reuse that
every time we need to create a new client. | [
"Initialize",
"the",
"service",
"discovery",
"client",
"we",
"will",
"reuse",
"that",
"every",
"time",
"we",
"need",
"to",
"create",
"a",
"new",
"client",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/distributed/AbstractClientProvider.java#L68-L80 |
492 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/visibility/VisibilityFence.java | VisibilityFence.prepareWait | public static FenceWait prepareWait(byte[] fenceId, TransactionSystemClient txClient)
throws TransactionFailureException, InterruptedException, TimeoutException {
return new DefaultFenceWait(new TransactionContext(txClient, new WriteFence(fenceId)));
} | java | public static FenceWait prepareWait(byte[] fenceId, TransactionSystemClient txClient)
throws TransactionFailureException, InterruptedException, TimeoutException {
return new DefaultFenceWait(new TransactionContext(txClient, new WriteFence(fenceId)));
} | [
"public",
"static",
"FenceWait",
"prepareWait",
"(",
"byte",
"[",
"]",
"fenceId",
",",
"TransactionSystemClient",
"txClient",
")",
"throws",
"TransactionFailureException",
",",
"InterruptedException",
",",
"TimeoutException",
"{",
"return",
"new",
"DefaultFenceWait",
"(",
"new",
"TransactionContext",
"(",
"txClient",
",",
"new",
"WriteFence",
"(",
"fenceId",
")",
")",
")",
";",
"}"
] | Used by a writer to wait on a fence so that changes are visible to all readers with in-progress transactions.
@param fenceId uniquely identifies the data that this fence is used to synchronize.
If the data is a table cell then this id can be composed of the table name, row key
and column key for the data.
@return {@link FenceWait} object | [
"Used",
"by",
"a",
"writer",
"to",
"wait",
"on",
"a",
"fence",
"so",
"that",
"changes",
"are",
"visible",
"to",
"all",
"readers",
"with",
"in",
"-",
"progress",
"transactions",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/visibility/VisibilityFence.java#L134-L137 |
493 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/persist/TransactionEditCodecs.java | TransactionEditCodecs.encode | @VisibleForTesting
static void encode(TransactionEdit src, DataOutput out, TransactionEditCodec codec) throws IOException {
out.writeByte(codec.getVersion());
codec.encode(src, out);
} | java | @VisibleForTesting
static void encode(TransactionEdit src, DataOutput out, TransactionEditCodec codec) throws IOException {
out.writeByte(codec.getVersion());
codec.encode(src, out);
} | [
"@",
"VisibleForTesting",
"static",
"void",
"encode",
"(",
"TransactionEdit",
"src",
",",
"DataOutput",
"out",
",",
"TransactionEditCodec",
"codec",
")",
"throws",
"IOException",
"{",
"out",
".",
"writeByte",
"(",
"codec",
".",
"getVersion",
"(",
")",
")",
";",
"codec",
".",
"encode",
"(",
"src",
",",
"out",
")",
";",
"}"
] | Encodes the given transaction edit using a specific codec. Note that this is only exposed
for use by tests. | [
"Encodes",
"the",
"given",
"transaction",
"edit",
"using",
"a",
"specific",
"codec",
".",
"Note",
"that",
"this",
"is",
"only",
"exposed",
"for",
"use",
"by",
"tests",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/persist/TransactionEditCodecs.java#L89-L93 |
494 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/snapshot/SnapshotCodecProvider.java | SnapshotCodecProvider.initialize | private void initialize(Configuration configuration) {
String[] codecClassNames = configuration.getTrimmedStrings(TxConstants.Persist.CFG_TX_SNAPHOT_CODEC_CLASSES);
List<Class> codecClasses = Lists.newArrayList();
if (codecClassNames != null) {
for (String clsName : codecClassNames) {
try {
codecClasses.add(Class.forName(clsName));
} catch (ClassNotFoundException cnfe) {
LOG.warn("Unable to load class configured for " + TxConstants.Persist.CFG_TX_SNAPHOT_CODEC_CLASSES
+ ": " + clsName, cnfe);
}
}
}
if (codecClasses.size() == 0) {
codecClasses.addAll(Arrays.asList(TxConstants.Persist.DEFAULT_TX_SNAPHOT_CODEC_CLASSES));
}
for (Class<?> codecClass : codecClasses) {
try {
SnapshotCodec codec = (SnapshotCodec) (codecClass.newInstance());
codecs.put(codec.getVersion(), codec);
LOG.debug("Using snapshot codec {} for snapshots of version {}", codecClass.getName(), codec.getVersion());
} catch (Exception e) {
LOG.warn("Error instantiating snapshot codec {}. Skipping.", codecClass.getName(), e);
}
}
} | java | private void initialize(Configuration configuration) {
String[] codecClassNames = configuration.getTrimmedStrings(TxConstants.Persist.CFG_TX_SNAPHOT_CODEC_CLASSES);
List<Class> codecClasses = Lists.newArrayList();
if (codecClassNames != null) {
for (String clsName : codecClassNames) {
try {
codecClasses.add(Class.forName(clsName));
} catch (ClassNotFoundException cnfe) {
LOG.warn("Unable to load class configured for " + TxConstants.Persist.CFG_TX_SNAPHOT_CODEC_CLASSES
+ ": " + clsName, cnfe);
}
}
}
if (codecClasses.size() == 0) {
codecClasses.addAll(Arrays.asList(TxConstants.Persist.DEFAULT_TX_SNAPHOT_CODEC_CLASSES));
}
for (Class<?> codecClass : codecClasses) {
try {
SnapshotCodec codec = (SnapshotCodec) (codecClass.newInstance());
codecs.put(codec.getVersion(), codec);
LOG.debug("Using snapshot codec {} for snapshots of version {}", codecClass.getName(), codec.getVersion());
} catch (Exception e) {
LOG.warn("Error instantiating snapshot codec {}. Skipping.", codecClass.getName(), e);
}
}
} | [
"private",
"void",
"initialize",
"(",
"Configuration",
"configuration",
")",
"{",
"String",
"[",
"]",
"codecClassNames",
"=",
"configuration",
".",
"getTrimmedStrings",
"(",
"TxConstants",
".",
"Persist",
".",
"CFG_TX_SNAPHOT_CODEC_CLASSES",
")",
";",
"List",
"<",
"Class",
">",
"codecClasses",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"if",
"(",
"codecClassNames",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"clsName",
":",
"codecClassNames",
")",
"{",
"try",
"{",
"codecClasses",
".",
"add",
"(",
"Class",
".",
"forName",
"(",
"clsName",
")",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"cnfe",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Unable to load class configured for \"",
"+",
"TxConstants",
".",
"Persist",
".",
"CFG_TX_SNAPHOT_CODEC_CLASSES",
"+",
"\": \"",
"+",
"clsName",
",",
"cnfe",
")",
";",
"}",
"}",
"}",
"if",
"(",
"codecClasses",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"codecClasses",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"TxConstants",
".",
"Persist",
".",
"DEFAULT_TX_SNAPHOT_CODEC_CLASSES",
")",
")",
";",
"}",
"for",
"(",
"Class",
"<",
"?",
">",
"codecClass",
":",
"codecClasses",
")",
"{",
"try",
"{",
"SnapshotCodec",
"codec",
"=",
"(",
"SnapshotCodec",
")",
"(",
"codecClass",
".",
"newInstance",
"(",
")",
")",
";",
"codecs",
".",
"put",
"(",
"codec",
".",
"getVersion",
"(",
")",
",",
"codec",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Using snapshot codec {} for snapshots of version {}\"",
",",
"codecClass",
".",
"getName",
"(",
")",
",",
"codec",
".",
"getVersion",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Error instantiating snapshot codec {}. Skipping.\"",
",",
"codecClass",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Register all codec specified in the configuration with this provider.
There can only be one codec for a given version. | [
"Register",
"all",
"codec",
"specified",
"in",
"the",
"configuration",
"with",
"this",
"provider",
".",
"There",
"can",
"only",
"be",
"one",
"codec",
"for",
"a",
"given",
"version",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/snapshot/SnapshotCodecProvider.java#L57-L83 |
495 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/snapshot/SnapshotCodecProvider.java | SnapshotCodecProvider.getCurrentCodec | private SnapshotCodec getCurrentCodec() {
if (codecs.isEmpty()) {
throw new IllegalStateException(String.format("No codecs are registered."));
}
return codecs.get(codecs.lastKey());
} | java | private SnapshotCodec getCurrentCodec() {
if (codecs.isEmpty()) {
throw new IllegalStateException(String.format("No codecs are registered."));
}
return codecs.get(codecs.lastKey());
} | [
"private",
"SnapshotCodec",
"getCurrentCodec",
"(",
")",
"{",
"if",
"(",
"codecs",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"format",
"(",
"\"No codecs are registered.\"",
")",
")",
";",
"}",
"return",
"codecs",
".",
"get",
"(",
"codecs",
".",
"lastKey",
"(",
")",
")",
";",
"}"
] | Retrieve the current snapshot codec, that is, the codec with the highest known version.
@return the current codec
@throws java.lang.IllegalStateException if no codecs are registered | [
"Retrieve",
"the",
"current",
"snapshot",
"codec",
"that",
"is",
"the",
"codec",
"with",
"the",
"highest",
"known",
"version",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/snapshot/SnapshotCodecProvider.java#L106-L111 |
496 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/snapshot/SnapshotCodecProvider.java | SnapshotCodecProvider.getCodec | private SnapshotCodec getCodec(InputStream in) {
BinaryDecoder decoder = new BinaryDecoder(in);
int persistedVersion;
try {
persistedVersion = decoder.readInt();
} catch (IOException e) {
LOG.error("Unable to read transaction state version: ", e);
throw Throwables.propagate(e);
}
return getCodecForVersion(persistedVersion);
} | java | private SnapshotCodec getCodec(InputStream in) {
BinaryDecoder decoder = new BinaryDecoder(in);
int persistedVersion;
try {
persistedVersion = decoder.readInt();
} catch (IOException e) {
LOG.error("Unable to read transaction state version: ", e);
throw Throwables.propagate(e);
}
return getCodecForVersion(persistedVersion);
} | [
"private",
"SnapshotCodec",
"getCodec",
"(",
"InputStream",
"in",
")",
"{",
"BinaryDecoder",
"decoder",
"=",
"new",
"BinaryDecoder",
"(",
"in",
")",
";",
"int",
"persistedVersion",
";",
"try",
"{",
"persistedVersion",
"=",
"decoder",
".",
"readInt",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Unable to read transaction state version: \"",
",",
"e",
")",
";",
"throw",
"Throwables",
".",
"propagate",
"(",
"e",
")",
";",
"}",
"return",
"getCodecForVersion",
"(",
"persistedVersion",
")",
";",
"}"
] | Return the appropriate codec for the version in InputStream | [
"Return",
"the",
"appropriate",
"codec",
"for",
"the",
"version",
"in",
"InputStream"
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/snapshot/SnapshotCodecProvider.java#L114-L124 |
497 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/persist/AbstractTransactionLog.java | AbstractTransactionLog.getPendingWrites | private List<Entry> getPendingWrites() {
synchronized (this) {
List<Entry> save = this.pendingWrites;
this.pendingWrites = new LinkedList<>();
return save;
}
} | java | private List<Entry> getPendingWrites() {
synchronized (this) {
List<Entry> save = this.pendingWrites;
this.pendingWrites = new LinkedList<>();
return save;
}
} | [
"private",
"List",
"<",
"Entry",
">",
"getPendingWrites",
"(",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"List",
"<",
"Entry",
">",
"save",
"=",
"this",
".",
"pendingWrites",
";",
"this",
".",
"pendingWrites",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"return",
"save",
";",
"}",
"}"
] | will accumulate in a new list. | [
"will",
"accumulate",
"in",
"a",
"new",
"list",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/persist/AbstractTransactionLog.java#L145-L151 |
498 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/util/TxUtils.java | TxUtils.getMaxVisibleTimestamp | public static long getMaxVisibleTimestamp(Transaction tx) {
// NOTE: +1 here because we want read up to writepointer inclusive, but timerange's end is exclusive
// however, we also need to guard against overflow in the case write pointer is set to MAX_VALUE
return tx.getWritePointer() < Long.MAX_VALUE ?
tx.getWritePointer() + 1 : tx.getWritePointer();
} | java | public static long getMaxVisibleTimestamp(Transaction tx) {
// NOTE: +1 here because we want read up to writepointer inclusive, but timerange's end is exclusive
// however, we also need to guard against overflow in the case write pointer is set to MAX_VALUE
return tx.getWritePointer() < Long.MAX_VALUE ?
tx.getWritePointer() + 1 : tx.getWritePointer();
} | [
"public",
"static",
"long",
"getMaxVisibleTimestamp",
"(",
"Transaction",
"tx",
")",
"{",
"// NOTE: +1 here because we want read up to writepointer inclusive, but timerange's end is exclusive",
"// however, we also need to guard against overflow in the case write pointer is set to MAX_VALUE",
"return",
"tx",
".",
"getWritePointer",
"(",
")",
"<",
"Long",
".",
"MAX_VALUE",
"?",
"tx",
".",
"getWritePointer",
"(",
")",
"+",
"1",
":",
"tx",
".",
"getWritePointer",
"(",
")",
";",
"}"
] | Returns the maximum timestamp to use for time-range operations, based on the given transaction.
@param tx The current transaction
@return The maximum timestamp (exclusive) to use for time-range operations | [
"Returns",
"the",
"maximum",
"timestamp",
"to",
"use",
"for",
"time",
"-",
"range",
"operations",
"based",
"on",
"the",
"given",
"transaction",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/util/TxUtils.java#L89-L94 |
499 | cdapio/tephra | tephra-core/src/main/java/co/cask/tephra/util/TxUtils.java | TxUtils.getMaxTTL | private static long getMaxTTL(Map<byte[], Long> ttlByFamily) {
long maxTTL = 0;
for (Long familyTTL : ttlByFamily.values()) {
maxTTL = Math.max(familyTTL <= 0 ? Long.MAX_VALUE : familyTTL, maxTTL);
}
return maxTTL == 0 ? Long.MAX_VALUE : maxTTL;
} | java | private static long getMaxTTL(Map<byte[], Long> ttlByFamily) {
long maxTTL = 0;
for (Long familyTTL : ttlByFamily.values()) {
maxTTL = Math.max(familyTTL <= 0 ? Long.MAX_VALUE : familyTTL, maxTTL);
}
return maxTTL == 0 ? Long.MAX_VALUE : maxTTL;
} | [
"private",
"static",
"long",
"getMaxTTL",
"(",
"Map",
"<",
"byte",
"[",
"]",
",",
"Long",
">",
"ttlByFamily",
")",
"{",
"long",
"maxTTL",
"=",
"0",
";",
"for",
"(",
"Long",
"familyTTL",
":",
"ttlByFamily",
".",
"values",
"(",
")",
")",
"{",
"maxTTL",
"=",
"Math",
".",
"max",
"(",
"familyTTL",
"<=",
"0",
"?",
"Long",
".",
"MAX_VALUE",
":",
"familyTTL",
",",
"maxTTL",
")",
";",
"}",
"return",
"maxTTL",
"==",
"0",
"?",
"Long",
".",
"MAX_VALUE",
":",
"maxTTL",
";",
"}"
] | Returns the max TTL for the given TTL values. Returns Long.MAX_VALUE if any of the column families has no TTL set. | [
"Returns",
"the",
"max",
"TTL",
"for",
"the",
"given",
"TTL",
"values",
".",
"Returns",
"Long",
".",
"MAX_VALUE",
"if",
"any",
"of",
"the",
"column",
"families",
"has",
"no",
"TTL",
"set",
"."
] | 082c56c15c6ece15002631ff6f89206a00d8915c | https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/util/TxUtils.java#L136-L142 |