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
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
161,000 |
voldemort/voldemort
|
src/java/voldemort/utils/JmxUtils.java
|
JmxUtils.createObjectName
|
public static ObjectName createObjectName(String domain, String type) {
try {
return new ObjectName(domain + ":type=" + type);
} catch(MalformedObjectNameException e) {
throw new VoldemortException(e);
}
}
|
java
|
public static ObjectName createObjectName(String domain, String type) {
try {
return new ObjectName(domain + ":type=" + type);
} catch(MalformedObjectNameException e) {
throw new VoldemortException(e);
}
}
|
[
"public",
"static",
"ObjectName",
"createObjectName",
"(",
"String",
"domain",
",",
"String",
"type",
")",
"{",
"try",
"{",
"return",
"new",
"ObjectName",
"(",
"domain",
"+",
"\":type=\"",
"+",
"type",
")",
";",
"}",
"catch",
"(",
"MalformedObjectNameException",
"e",
")",
"{",
"throw",
"new",
"VoldemortException",
"(",
"e",
")",
";",
"}",
"}"
] |
Create a JMX ObjectName
@param domain The domain of the object
@param type The type of the object
@return An ObjectName representing the name
|
[
"Create",
"a",
"JMX",
"ObjectName"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/JmxUtils.java#L238-L244
|
161,001 |
voldemort/voldemort
|
src/java/voldemort/utils/JmxUtils.java
|
JmxUtils.getClassName
|
public static String getClassName(Class<?> c) {
String name = c.getName();
return name.substring(name.lastIndexOf('.') + 1, name.length());
}
|
java
|
public static String getClassName(Class<?> c) {
String name = c.getName();
return name.substring(name.lastIndexOf('.') + 1, name.length());
}
|
[
"public",
"static",
"String",
"getClassName",
"(",
"Class",
"<",
"?",
">",
"c",
")",
"{",
"String",
"name",
"=",
"c",
".",
"getName",
"(",
")",
";",
"return",
"name",
".",
"substring",
"(",
"name",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
",",
"name",
".",
"length",
"(",
")",
")",
";",
"}"
] |
Get the class name without the package
@param c The class name with package
@return the class name without the package
|
[
"Get",
"the",
"class",
"name",
"without",
"the",
"package"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/JmxUtils.java#L273-L276
|
161,002 |
voldemort/voldemort
|
src/java/voldemort/utils/JmxUtils.java
|
JmxUtils.registerMbean
|
public static void registerMbean(Object mbean, ObjectName name) {
registerMbean(ManagementFactory.getPlatformMBeanServer(),
JmxUtils.createModelMBean(mbean),
name);
}
|
java
|
public static void registerMbean(Object mbean, ObjectName name) {
registerMbean(ManagementFactory.getPlatformMBeanServer(),
JmxUtils.createModelMBean(mbean),
name);
}
|
[
"public",
"static",
"void",
"registerMbean",
"(",
"Object",
"mbean",
",",
"ObjectName",
"name",
")",
"{",
"registerMbean",
"(",
"ManagementFactory",
".",
"getPlatformMBeanServer",
"(",
")",
",",
"JmxUtils",
".",
"createModelMBean",
"(",
"mbean",
")",
",",
"name",
")",
";",
"}"
] |
Register the given mbean with the platform mbean server
@param mbean The mbean to register
@param name The name to register under
|
[
"Register",
"the",
"given",
"mbean",
"with",
"the",
"platform",
"mbean",
"server"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/JmxUtils.java#L284-L288
|
161,003 |
voldemort/voldemort
|
src/java/voldemort/utils/JmxUtils.java
|
JmxUtils.registerMbean
|
public static ObjectName registerMbean(String typeName, Object obj) {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName name = JmxUtils.createObjectName(JmxUtils.getPackageName(obj.getClass()),
typeName);
registerMbean(server, JmxUtils.createModelMBean(obj), name);
return name;
}
|
java
|
public static ObjectName registerMbean(String typeName, Object obj) {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName name = JmxUtils.createObjectName(JmxUtils.getPackageName(obj.getClass()),
typeName);
registerMbean(server, JmxUtils.createModelMBean(obj), name);
return name;
}
|
[
"public",
"static",
"ObjectName",
"registerMbean",
"(",
"String",
"typeName",
",",
"Object",
"obj",
")",
"{",
"MBeanServer",
"server",
"=",
"ManagementFactory",
".",
"getPlatformMBeanServer",
"(",
")",
";",
"ObjectName",
"name",
"=",
"JmxUtils",
".",
"createObjectName",
"(",
"JmxUtils",
".",
"getPackageName",
"(",
"obj",
".",
"getClass",
"(",
")",
")",
",",
"typeName",
")",
";",
"registerMbean",
"(",
"server",
",",
"JmxUtils",
".",
"createModelMBean",
"(",
"obj",
")",
",",
"name",
")",
";",
"return",
"name",
";",
"}"
] |
Register the given object under the package name of the object's class
with the given type name.
this method using the platform mbean server as returned by
ManagementFactory.getPlatformMBeanServer()
@param typeName The name of the type to register
@param obj The object to register as an mbean
|
[
"Register",
"the",
"given",
"object",
"under",
"the",
"package",
"name",
"of",
"the",
"object",
"s",
"class",
"with",
"the",
"given",
"type",
"name",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/JmxUtils.java#L300-L306
|
161,004 |
voldemort/voldemort
|
src/java/voldemort/utils/JmxUtils.java
|
JmxUtils.registerMbean
|
public static void registerMbean(MBeanServer server, ModelMBean mbean, ObjectName name) {
try {
synchronized(LOCK) {
if(server.isRegistered(name))
JmxUtils.unregisterMbean(server, name);
server.registerMBean(mbean, name);
}
} catch(Exception e) {
logger.error("Error registering mbean:", e);
}
}
|
java
|
public static void registerMbean(MBeanServer server, ModelMBean mbean, ObjectName name) {
try {
synchronized(LOCK) {
if(server.isRegistered(name))
JmxUtils.unregisterMbean(server, name);
server.registerMBean(mbean, name);
}
} catch(Exception e) {
logger.error("Error registering mbean:", e);
}
}
|
[
"public",
"static",
"void",
"registerMbean",
"(",
"MBeanServer",
"server",
",",
"ModelMBean",
"mbean",
",",
"ObjectName",
"name",
")",
"{",
"try",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"if",
"(",
"server",
".",
"isRegistered",
"(",
"name",
")",
")",
"JmxUtils",
".",
"unregisterMbean",
"(",
"server",
",",
"name",
")",
";",
"server",
".",
"registerMBean",
"(",
"mbean",
",",
"name",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error registering mbean:\"",
",",
"e",
")",
";",
"}",
"}"
] |
Register the given mbean with the server
@param server The server to register with
@param mbean The mbean to register
@param name The name to register under
|
[
"Register",
"the",
"given",
"mbean",
"with",
"the",
"server"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/JmxUtils.java#L315-L325
|
161,005 |
voldemort/voldemort
|
src/java/voldemort/utils/JmxUtils.java
|
JmxUtils.unregisterMbean
|
public static void unregisterMbean(MBeanServer server, ObjectName name) {
try {
server.unregisterMBean(name);
} catch(Exception e) {
logger.error("Error unregistering mbean", e);
}
}
|
java
|
public static void unregisterMbean(MBeanServer server, ObjectName name) {
try {
server.unregisterMBean(name);
} catch(Exception e) {
logger.error("Error unregistering mbean", e);
}
}
|
[
"public",
"static",
"void",
"unregisterMbean",
"(",
"MBeanServer",
"server",
",",
"ObjectName",
"name",
")",
"{",
"try",
"{",
"server",
".",
"unregisterMBean",
"(",
"name",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error unregistering mbean\"",
",",
"e",
")",
";",
"}",
"}"
] |
Unregister the mbean with the given name
@param server The server to unregister from
@param name The name of the mbean to unregister
|
[
"Unregister",
"the",
"mbean",
"with",
"the",
"given",
"name"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/JmxUtils.java#L333-L339
|
161,006 |
voldemort/voldemort
|
src/java/voldemort/utils/JmxUtils.java
|
JmxUtils.unregisterMbean
|
public static void unregisterMbean(ObjectName name) {
try {
ManagementFactory.getPlatformMBeanServer().unregisterMBean(name);
} catch(Exception e) {
logger.error("Error unregistering mbean", e);
}
}
|
java
|
public static void unregisterMbean(ObjectName name) {
try {
ManagementFactory.getPlatformMBeanServer().unregisterMBean(name);
} catch(Exception e) {
logger.error("Error unregistering mbean", e);
}
}
|
[
"public",
"static",
"void",
"unregisterMbean",
"(",
"ObjectName",
"name",
")",
"{",
"try",
"{",
"ManagementFactory",
".",
"getPlatformMBeanServer",
"(",
")",
".",
"unregisterMBean",
"(",
"name",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error unregistering mbean\"",
",",
"e",
")",
";",
"}",
"}"
] |
Unregister the mbean with the given name from the platform mbean server
@param name The name of the mbean to unregister
|
[
"Unregister",
"the",
"mbean",
"with",
"the",
"given",
"name",
"from",
"the",
"platform",
"mbean",
"server"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/JmxUtils.java#L346-L352
|
161,007 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyUtils.java
|
ReadOnlyUtils.isFormatCorrect
|
public static boolean isFormatCorrect(String fileName, ReadOnlyStorageFormat format) {
switch(format) {
case READONLY_V0:
case READONLY_V1:
if(fileName.matches("^[\\d]+_[\\d]+\\.(data|index)")) {
return true;
} else {
return false;
}
case READONLY_V2:
if(fileName.matches("^[\\d]+_[\\d]+_[\\d]+\\.(data|index)")) {
return true;
} else {
return false;
}
default:
throw new VoldemortException("Format type not supported");
}
}
|
java
|
public static boolean isFormatCorrect(String fileName, ReadOnlyStorageFormat format) {
switch(format) {
case READONLY_V0:
case READONLY_V1:
if(fileName.matches("^[\\d]+_[\\d]+\\.(data|index)")) {
return true;
} else {
return false;
}
case READONLY_V2:
if(fileName.matches("^[\\d]+_[\\d]+_[\\d]+\\.(data|index)")) {
return true;
} else {
return false;
}
default:
throw new VoldemortException("Format type not supported");
}
}
|
[
"public",
"static",
"boolean",
"isFormatCorrect",
"(",
"String",
"fileName",
",",
"ReadOnlyStorageFormat",
"format",
")",
"{",
"switch",
"(",
"format",
")",
"{",
"case",
"READONLY_V0",
":",
"case",
"READONLY_V1",
":",
"if",
"(",
"fileName",
".",
"matches",
"(",
"\"^[\\\\d]+_[\\\\d]+\\\\.(data|index)\"",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"case",
"READONLY_V2",
":",
"if",
"(",
"fileName",
".",
"matches",
"(",
"\"^[\\\\d]+_[\\\\d]+_[\\\\d]+\\\\.(data|index)\"",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"default",
":",
"throw",
"new",
"VoldemortException",
"(",
"\"Format type not supported\"",
")",
";",
"}",
"}"
] |
Given a file name and read-only storage format, tells whether the file
name format is correct
@param fileName The name of the file
@param format The RO format
@return true if file format is correct, else false
|
[
"Given",
"a",
"file",
"name",
"and",
"read",
"-",
"only",
"storage",
"format",
"tells",
"whether",
"the",
"file",
"name",
"format",
"is",
"correct"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyUtils.java#L53-L73
|
161,008 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyUtils.java
|
ReadOnlyUtils.getChunkId
|
public static int getChunkId(String fileName) {
Pattern pattern = Pattern.compile("_[\\d]+\\.");
Matcher matcher = pattern.matcher(fileName);
if(matcher.find()) {
return new Integer(fileName.substring(matcher.start() + 1, matcher.end() - 1));
} else {
throw new VoldemortException("Could not extract out chunk id from " + fileName);
}
}
|
java
|
public static int getChunkId(String fileName) {
Pattern pattern = Pattern.compile("_[\\d]+\\.");
Matcher matcher = pattern.matcher(fileName);
if(matcher.find()) {
return new Integer(fileName.substring(matcher.start() + 1, matcher.end() - 1));
} else {
throw new VoldemortException("Could not extract out chunk id from " + fileName);
}
}
|
[
"public",
"static",
"int",
"getChunkId",
"(",
"String",
"fileName",
")",
"{",
"Pattern",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"\"_[\\\\d]+\\\\.\"",
")",
";",
"Matcher",
"matcher",
"=",
"pattern",
".",
"matcher",
"(",
"fileName",
")",
";",
"if",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"return",
"new",
"Integer",
"(",
"fileName",
".",
"substring",
"(",
"matcher",
".",
"start",
"(",
")",
"+",
"1",
",",
"matcher",
".",
"end",
"(",
")",
"-",
"1",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"VoldemortException",
"(",
"\"Could not extract out chunk id from \"",
"+",
"fileName",
")",
";",
"}",
"}"
] |
Returns the chunk id for the file name
@param fileName The file name
@return Chunk id
|
[
"Returns",
"the",
"chunk",
"id",
"for",
"the",
"file",
"name"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyUtils.java#L103-L112
|
161,009 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyUtils.java
|
ReadOnlyUtils.getCurrentVersion
|
public static File getCurrentVersion(File storeDirectory) {
File latestDir = getLatestDir(storeDirectory);
if(latestDir != null)
return latestDir;
File[] versionDirs = getVersionDirs(storeDirectory);
if(versionDirs == null || versionDirs.length == 0) {
return null;
} else {
return findKthVersionedDir(versionDirs, versionDirs.length - 1, versionDirs.length - 1)[0];
}
}
|
java
|
public static File getCurrentVersion(File storeDirectory) {
File latestDir = getLatestDir(storeDirectory);
if(latestDir != null)
return latestDir;
File[] versionDirs = getVersionDirs(storeDirectory);
if(versionDirs == null || versionDirs.length == 0) {
return null;
} else {
return findKthVersionedDir(versionDirs, versionDirs.length - 1, versionDirs.length - 1)[0];
}
}
|
[
"public",
"static",
"File",
"getCurrentVersion",
"(",
"File",
"storeDirectory",
")",
"{",
"File",
"latestDir",
"=",
"getLatestDir",
"(",
"storeDirectory",
")",
";",
"if",
"(",
"latestDir",
"!=",
"null",
")",
"return",
"latestDir",
";",
"File",
"[",
"]",
"versionDirs",
"=",
"getVersionDirs",
"(",
"storeDirectory",
")",
";",
"if",
"(",
"versionDirs",
"==",
"null",
"||",
"versionDirs",
".",
"length",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"findKthVersionedDir",
"(",
"versionDirs",
",",
"versionDirs",
".",
"length",
"-",
"1",
",",
"versionDirs",
".",
"length",
"-",
"1",
")",
"[",
"0",
"]",
";",
"}",
"}"
] |
Retrieve the dir pointed to by 'latest' symbolic-link or the current
version dir
@return Current version directory, else null
|
[
"Retrieve",
"the",
"dir",
"pointed",
"to",
"by",
"latest",
"symbolic",
"-",
"link",
"or",
"the",
"current",
"version",
"dir"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyUtils.java#L120-L131
|
161,010 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyUtils.java
|
ReadOnlyUtils.checkVersionDirName
|
public static boolean checkVersionDirName(File versionDir) {
return (versionDir.isDirectory() && versionDir.getName().contains("version-") && !versionDir.getName()
.endsWith(".bak"));
}
|
java
|
public static boolean checkVersionDirName(File versionDir) {
return (versionDir.isDirectory() && versionDir.getName().contains("version-") && !versionDir.getName()
.endsWith(".bak"));
}
|
[
"public",
"static",
"boolean",
"checkVersionDirName",
"(",
"File",
"versionDir",
")",
"{",
"return",
"(",
"versionDir",
".",
"isDirectory",
"(",
")",
"&&",
"versionDir",
".",
"getName",
"(",
")",
".",
"contains",
"(",
"\"version-\"",
")",
"&&",
"!",
"versionDir",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"\".bak\"",
")",
")",
";",
"}"
] |
Checks if the name of the file follows the version-n format
@param versionDir The directory
@return Returns true if the name is correct, else false
|
[
"Checks",
"if",
"the",
"name",
"of",
"the",
"file",
"follows",
"the",
"version",
"-",
"n",
"format"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyUtils.java#L162-L165
|
161,011 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyUtils.java
|
ReadOnlyUtils.getVersionId
|
private static long getVersionId(String versionDir) {
try {
return Long.parseLong(versionDir.replace("version-", ""));
} catch(NumberFormatException e) {
logger.trace("Cannot parse version directory to obtain id " + versionDir);
return -1;
}
}
|
java
|
private static long getVersionId(String versionDir) {
try {
return Long.parseLong(versionDir.replace("version-", ""));
} catch(NumberFormatException e) {
logger.trace("Cannot parse version directory to obtain id " + versionDir);
return -1;
}
}
|
[
"private",
"static",
"long",
"getVersionId",
"(",
"String",
"versionDir",
")",
"{",
"try",
"{",
"return",
"Long",
".",
"parseLong",
"(",
"versionDir",
".",
"replace",
"(",
"\"version-\"",
",",
"\"\"",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"logger",
".",
"trace",
"(",
"\"Cannot parse version directory to obtain id \"",
"+",
"versionDir",
")",
";",
"return",
"-",
"1",
";",
"}",
"}"
] |
Extracts the version id from a string
@param versionDir The string
@return Returns the version id of the directory, else -1
|
[
"Extracts",
"the",
"version",
"id",
"from",
"a",
"string"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyUtils.java#L183-L190
|
161,012 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyUtils.java
|
ReadOnlyUtils.getVersionDirs
|
public static File[] getVersionDirs(File rootDir, final long minId, final long maxId) {
return rootDir.listFiles(new FileFilter() {
public boolean accept(File pathName) {
if(checkVersionDirName(pathName)) {
long versionId = getVersionId(pathName);
if(versionId != -1 && versionId <= maxId && versionId >= minId) {
return true;
}
}
return false;
}
});
}
|
java
|
public static File[] getVersionDirs(File rootDir, final long minId, final long maxId) {
return rootDir.listFiles(new FileFilter() {
public boolean accept(File pathName) {
if(checkVersionDirName(pathName)) {
long versionId = getVersionId(pathName);
if(versionId != -1 && versionId <= maxId && versionId >= minId) {
return true;
}
}
return false;
}
});
}
|
[
"public",
"static",
"File",
"[",
"]",
"getVersionDirs",
"(",
"File",
"rootDir",
",",
"final",
"long",
"minId",
",",
"final",
"long",
"maxId",
")",
"{",
"return",
"rootDir",
".",
"listFiles",
"(",
"new",
"FileFilter",
"(",
")",
"{",
"public",
"boolean",
"accept",
"(",
"File",
"pathName",
")",
"{",
"if",
"(",
"checkVersionDirName",
"(",
"pathName",
")",
")",
"{",
"long",
"versionId",
"=",
"getVersionId",
"(",
"pathName",
")",
";",
"if",
"(",
"versionId",
"!=",
"-",
"1",
"&&",
"versionId",
"<=",
"maxId",
"&&",
"versionId",
">=",
"minId",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"}",
")",
";",
"}"
] |
Returns all the version directories present in the root directory
specified
@param rootDir The parent directory
@param maxId The
@return An array of version directories
|
[
"Returns",
"all",
"the",
"version",
"directories",
"present",
"in",
"the",
"root",
"directory",
"specified"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyUtils.java#L211-L224
|
161,013 |
voldemort/voldemort
|
src/java/voldemort/server/VoldemortServer.java
|
VoldemortServer.stopInner
|
@Override
protected void stopInner() throws VoldemortException {
List<VoldemortException> exceptions = new ArrayList<VoldemortException>();
logger.info("Stopping services:" + getIdentityNode().getId());
/* Stop in reverse order */
exceptions.addAll(stopOnlineServices());
for(VoldemortService service: Utils.reversed(basicServices)) {
try {
service.stop();
} catch(VoldemortException e) {
exceptions.add(e);
logger.error(e);
}
}
logger.info("All services stopped for Node:" + getIdentityNode().getId());
if(exceptions.size() > 0)
throw exceptions.get(0);
// release lock of jvm heap
JNAUtils.tryMunlockall();
}
|
java
|
@Override
protected void stopInner() throws VoldemortException {
List<VoldemortException> exceptions = new ArrayList<VoldemortException>();
logger.info("Stopping services:" + getIdentityNode().getId());
/* Stop in reverse order */
exceptions.addAll(stopOnlineServices());
for(VoldemortService service: Utils.reversed(basicServices)) {
try {
service.stop();
} catch(VoldemortException e) {
exceptions.add(e);
logger.error(e);
}
}
logger.info("All services stopped for Node:" + getIdentityNode().getId());
if(exceptions.size() > 0)
throw exceptions.get(0);
// release lock of jvm heap
JNAUtils.tryMunlockall();
}
|
[
"@",
"Override",
"protected",
"void",
"stopInner",
"(",
")",
"throws",
"VoldemortException",
"{",
"List",
"<",
"VoldemortException",
">",
"exceptions",
"=",
"new",
"ArrayList",
"<",
"VoldemortException",
">",
"(",
")",
";",
"logger",
".",
"info",
"(",
"\"Stopping services:\"",
"+",
"getIdentityNode",
"(",
")",
".",
"getId",
"(",
")",
")",
";",
"/* Stop in reverse order */",
"exceptions",
".",
"addAll",
"(",
"stopOnlineServices",
"(",
")",
")",
";",
"for",
"(",
"VoldemortService",
"service",
":",
"Utils",
".",
"reversed",
"(",
"basicServices",
")",
")",
"{",
"try",
"{",
"service",
".",
"stop",
"(",
")",
";",
"}",
"catch",
"(",
"VoldemortException",
"e",
")",
"{",
"exceptions",
".",
"add",
"(",
"e",
")",
";",
"logger",
".",
"error",
"(",
"e",
")",
";",
"}",
"}",
"logger",
".",
"info",
"(",
"\"All services stopped for Node:\"",
"+",
"getIdentityNode",
"(",
")",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"exceptions",
".",
"size",
"(",
")",
">",
"0",
")",
"throw",
"exceptions",
".",
"get",
"(",
"0",
")",
";",
"// release lock of jvm heap",
"JNAUtils",
".",
"tryMunlockall",
"(",
")",
";",
"}"
] |
Attempt to shutdown the server. As much shutdown as possible will be
completed, even if intermediate errors are encountered.
@throws VoldemortException
|
[
"Attempt",
"to",
"shutdown",
"the",
"server",
".",
"As",
"much",
"shutdown",
"as",
"possible",
"will",
"be",
"completed",
"even",
"if",
"intermediate",
"errors",
"are",
"encountered",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/VoldemortServer.java#L502-L523
|
161,014 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/chunk/ChunkedFileSet.java
|
ChunkedFileSet.getReplicaTypeForPartition
|
private int getReplicaTypeForPartition(int partitionId) {
List<Integer> routingPartitionList = routingStrategy.getReplicatingPartitionList(partitionId);
// Determine if we should host this partition, and if so, whether we are a primary,
// secondary or n-ary replica for it
int correctReplicaType = -1;
for (int replica = 0; replica < routingPartitionList.size(); replica++) {
if(nodePartitionIds.contains(routingPartitionList.get(replica))) {
// This means the partitionId currently being iterated on should be hosted
// by this node. Let's remember its replica type in order to make sure the
// files we have are properly named.
correctReplicaType = replica;
break;
}
}
return correctReplicaType;
}
|
java
|
private int getReplicaTypeForPartition(int partitionId) {
List<Integer> routingPartitionList = routingStrategy.getReplicatingPartitionList(partitionId);
// Determine if we should host this partition, and if so, whether we are a primary,
// secondary or n-ary replica for it
int correctReplicaType = -1;
for (int replica = 0; replica < routingPartitionList.size(); replica++) {
if(nodePartitionIds.contains(routingPartitionList.get(replica))) {
// This means the partitionId currently being iterated on should be hosted
// by this node. Let's remember its replica type in order to make sure the
// files we have are properly named.
correctReplicaType = replica;
break;
}
}
return correctReplicaType;
}
|
[
"private",
"int",
"getReplicaTypeForPartition",
"(",
"int",
"partitionId",
")",
"{",
"List",
"<",
"Integer",
">",
"routingPartitionList",
"=",
"routingStrategy",
".",
"getReplicatingPartitionList",
"(",
"partitionId",
")",
";",
"// Determine if we should host this partition, and if so, whether we are a primary,",
"// secondary or n-ary replica for it",
"int",
"correctReplicaType",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"replica",
"=",
"0",
";",
"replica",
"<",
"routingPartitionList",
".",
"size",
"(",
")",
";",
"replica",
"++",
")",
"{",
"if",
"(",
"nodePartitionIds",
".",
"contains",
"(",
"routingPartitionList",
".",
"get",
"(",
"replica",
")",
")",
")",
"{",
"// This means the partitionId currently being iterated on should be hosted",
"// by this node. Let's remember its replica type in order to make sure the",
"// files we have are properly named.",
"correctReplicaType",
"=",
"replica",
";",
"break",
";",
"}",
"}",
"return",
"correctReplicaType",
";",
"}"
] |
Given a partition ID, determine which replica of this partition is hosted by the
current node, if any.
Note: This is an implementation detail of the READONLY_V2 naming scheme, and should
not be used outside of that scope.
@param partitionId for which we want to know the replica type
@return the requested partition's replica type (which ranges from 0 to replication
factor -1) if the partition is hosted on the current node, or -1 if the
requested partition is not hosted on this node.
|
[
"Given",
"a",
"partition",
"ID",
"determine",
"which",
"replica",
"of",
"this",
"partition",
"is",
"hosted",
"by",
"the",
"current",
"node",
"if",
"any",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/chunk/ChunkedFileSet.java#L261-L278
|
161,015 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/chunk/ChunkedFileSet.java
|
ChunkedFileSet.renameReadOnlyV2Files
|
private void renameReadOnlyV2Files(int masterPartitionId, int correctReplicaType) {
for (int replica = 0; replica < routingStrategy.getNumReplicas(); replica++) {
if (replica != correctReplicaType) {
int chunkId = 0;
while (true) {
String fileName = Integer.toString(masterPartitionId) + "_"
+ Integer.toString(replica) + "_"
+ Integer.toString(chunkId);
File index = getIndexFile(fileName);
File data = getDataFile(fileName);
if(index.exists() && data.exists()) {
// We found files with the "wrong" replica type, so let's rename them
String correctFileName = Integer.toString(masterPartitionId) + "_"
+ Integer.toString(correctReplicaType) + "_"
+ Integer.toString(chunkId);
File indexWithCorrectReplicaType = getIndexFile(correctFileName);
File dataWithCorrectReplicaType = getDataFile(correctFileName);
Utils.move(index, indexWithCorrectReplicaType);
Utils.move(data, dataWithCorrectReplicaType);
// Maybe change this to DEBUG?
logger.info("Renamed files with wrong replica type: "
+ index.getAbsolutePath() + "|data -> "
+ indexWithCorrectReplicaType.getName() + "|data");
} else if(index.exists() ^ data.exists()) {
throw new VoldemortException("One of the following does not exist: "
+ index.toString()
+ " or "
+ data.toString() + ".");
} else {
// The files don't exist, or we've gone over all available chunks,
// so let's move on.
break;
}
chunkId++;
}
}
}
}
|
java
|
private void renameReadOnlyV2Files(int masterPartitionId, int correctReplicaType) {
for (int replica = 0; replica < routingStrategy.getNumReplicas(); replica++) {
if (replica != correctReplicaType) {
int chunkId = 0;
while (true) {
String fileName = Integer.toString(masterPartitionId) + "_"
+ Integer.toString(replica) + "_"
+ Integer.toString(chunkId);
File index = getIndexFile(fileName);
File data = getDataFile(fileName);
if(index.exists() && data.exists()) {
// We found files with the "wrong" replica type, so let's rename them
String correctFileName = Integer.toString(masterPartitionId) + "_"
+ Integer.toString(correctReplicaType) + "_"
+ Integer.toString(chunkId);
File indexWithCorrectReplicaType = getIndexFile(correctFileName);
File dataWithCorrectReplicaType = getDataFile(correctFileName);
Utils.move(index, indexWithCorrectReplicaType);
Utils.move(data, dataWithCorrectReplicaType);
// Maybe change this to DEBUG?
logger.info("Renamed files with wrong replica type: "
+ index.getAbsolutePath() + "|data -> "
+ indexWithCorrectReplicaType.getName() + "|data");
} else if(index.exists() ^ data.exists()) {
throw new VoldemortException("One of the following does not exist: "
+ index.toString()
+ " or "
+ data.toString() + ".");
} else {
// The files don't exist, or we've gone over all available chunks,
// so let's move on.
break;
}
chunkId++;
}
}
}
}
|
[
"private",
"void",
"renameReadOnlyV2Files",
"(",
"int",
"masterPartitionId",
",",
"int",
"correctReplicaType",
")",
"{",
"for",
"(",
"int",
"replica",
"=",
"0",
";",
"replica",
"<",
"routingStrategy",
".",
"getNumReplicas",
"(",
")",
";",
"replica",
"++",
")",
"{",
"if",
"(",
"replica",
"!=",
"correctReplicaType",
")",
"{",
"int",
"chunkId",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"String",
"fileName",
"=",
"Integer",
".",
"toString",
"(",
"masterPartitionId",
")",
"+",
"\"_\"",
"+",
"Integer",
".",
"toString",
"(",
"replica",
")",
"+",
"\"_\"",
"+",
"Integer",
".",
"toString",
"(",
"chunkId",
")",
";",
"File",
"index",
"=",
"getIndexFile",
"(",
"fileName",
")",
";",
"File",
"data",
"=",
"getDataFile",
"(",
"fileName",
")",
";",
"if",
"(",
"index",
".",
"exists",
"(",
")",
"&&",
"data",
".",
"exists",
"(",
")",
")",
"{",
"// We found files with the \"wrong\" replica type, so let's rename them",
"String",
"correctFileName",
"=",
"Integer",
".",
"toString",
"(",
"masterPartitionId",
")",
"+",
"\"_\"",
"+",
"Integer",
".",
"toString",
"(",
"correctReplicaType",
")",
"+",
"\"_\"",
"+",
"Integer",
".",
"toString",
"(",
"chunkId",
")",
";",
"File",
"indexWithCorrectReplicaType",
"=",
"getIndexFile",
"(",
"correctFileName",
")",
";",
"File",
"dataWithCorrectReplicaType",
"=",
"getDataFile",
"(",
"correctFileName",
")",
";",
"Utils",
".",
"move",
"(",
"index",
",",
"indexWithCorrectReplicaType",
")",
";",
"Utils",
".",
"move",
"(",
"data",
",",
"dataWithCorrectReplicaType",
")",
";",
"// Maybe change this to DEBUG?",
"logger",
".",
"info",
"(",
"\"Renamed files with wrong replica type: \"",
"+",
"index",
".",
"getAbsolutePath",
"(",
")",
"+",
"\"|data -> \"",
"+",
"indexWithCorrectReplicaType",
".",
"getName",
"(",
")",
"+",
"\"|data\"",
")",
";",
"}",
"else",
"if",
"(",
"index",
".",
"exists",
"(",
")",
"^",
"data",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"VoldemortException",
"(",
"\"One of the following does not exist: \"",
"+",
"index",
".",
"toString",
"(",
")",
"+",
"\" or \"",
"+",
"data",
".",
"toString",
"(",
")",
"+",
"\".\"",
")",
";",
"}",
"else",
"{",
"// The files don't exist, or we've gone over all available chunks,",
"// so let's move on.",
"break",
";",
"}",
"chunkId",
"++",
";",
"}",
"}",
"}",
"}"
] |
This function looks for files with the "wrong" replica type in their name, and
if it finds any, renames them.
Those files may have ended up on this server either because:
- 1. We restored them from another server, where they were named according to
another replica type. Or,
- 2. The {@link voldemort.store.readonly.mr.azkaban.VoldemortBuildAndPushJob}
and the {@link voldemort.store.readonly.fetcher.HdfsFetcher} are
operating in 'build.primary.replicas.only' mode, so they only ever built
and fetched replica 0 of any given file.
Note: This is an implementation detail of the READONLY_V2 naming scheme, and should
not be used outside of that scope.
@param masterPartitionId partition ID of the "primary replica"
@param correctReplicaType replica number which should be found on the current
node for the provided masterPartitionId.
|
[
"This",
"function",
"looks",
"for",
"files",
"with",
"the",
"wrong",
"replica",
"type",
"in",
"their",
"name",
"and",
"if",
"it",
"finds",
"any",
"renames",
"them",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/chunk/ChunkedFileSet.java#L299-L340
|
161,016 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/chunk/ChunkedFileSet.java
|
ChunkedFileSet.keyToStorageFormat
|
public byte[] keyToStorageFormat(byte[] key) {
switch(getReadOnlyStorageFormat()) {
case READONLY_V0:
case READONLY_V1:
return ByteUtils.md5(key);
case READONLY_V2:
return ByteUtils.copy(ByteUtils.md5(key), 0, 2 * ByteUtils.SIZE_OF_INT);
default:
throw new VoldemortException("Unknown read-only storage format");
}
}
|
java
|
public byte[] keyToStorageFormat(byte[] key) {
switch(getReadOnlyStorageFormat()) {
case READONLY_V0:
case READONLY_V1:
return ByteUtils.md5(key);
case READONLY_V2:
return ByteUtils.copy(ByteUtils.md5(key), 0, 2 * ByteUtils.SIZE_OF_INT);
default:
throw new VoldemortException("Unknown read-only storage format");
}
}
|
[
"public",
"byte",
"[",
"]",
"keyToStorageFormat",
"(",
"byte",
"[",
"]",
"key",
")",
"{",
"switch",
"(",
"getReadOnlyStorageFormat",
"(",
")",
")",
"{",
"case",
"READONLY_V0",
":",
"case",
"READONLY_V1",
":",
"return",
"ByteUtils",
".",
"md5",
"(",
"key",
")",
";",
"case",
"READONLY_V2",
":",
"return",
"ByteUtils",
".",
"copy",
"(",
"ByteUtils",
".",
"md5",
"(",
"key",
")",
",",
"0",
",",
"2",
"*",
"ByteUtils",
".",
"SIZE_OF_INT",
")",
";",
"default",
":",
"throw",
"new",
"VoldemortException",
"(",
"\"Unknown read-only storage format\"",
")",
";",
"}",
"}"
] |
Converts the key to the format in which it is stored for searching
@param key Byte array of the key
@return The format stored in the index file
|
[
"Converts",
"the",
"key",
"to",
"the",
"format",
"in",
"which",
"it",
"is",
"stored",
"for",
"searching"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/chunk/ChunkedFileSet.java#L529-L540
|
161,017 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/chunk/ChunkedFileSet.java
|
ChunkedFileSet.getChunkForKey
|
public int getChunkForKey(byte[] key) throws IllegalStateException {
if(numChunks == 0) {
throw new IllegalStateException("The ChunkedFileSet is closed.");
}
switch(storageFormat) {
case READONLY_V0: {
return ReadOnlyUtils.chunk(ByteUtils.md5(key), numChunks);
}
case READONLY_V1: {
if(nodePartitionIds == null) {
throw new IllegalStateException("nodePartitionIds is null.");
}
List<Integer> routingPartitionList = routingStrategy.getPartitionList(key);
routingPartitionList.retainAll(nodePartitionIds);
if(routingPartitionList.size() != 1) {
throw new IllegalStateException("The key does not belong on this node.");
}
return chunkIdToChunkStart.get(routingPartitionList.get(0))
+ ReadOnlyUtils.chunk(ByteUtils.md5(key),
chunkIdToNumChunks.get(routingPartitionList.get(0)));
}
case READONLY_V2: {
List<Integer> routingPartitionList = routingStrategy.getPartitionList(key);
Pair<Integer, Integer> bucket = null;
for(int replicaType = 0; replicaType < routingPartitionList.size(); replicaType++) {
if(nodePartitionIds == null) {
throw new IllegalStateException("nodePartitionIds is null.");
}
if(nodePartitionIds.contains(routingPartitionList.get(replicaType))) {
if(bucket == null) {
bucket = Pair.create(routingPartitionList.get(0), replicaType);
} else {
throw new IllegalStateException("Found more than one replica for a given partition on the current node!");
}
}
}
if(bucket == null) {
throw new IllegalStateException("The key does not belong on this node.");
}
Integer chunkStart = chunkIdToChunkStart.get(bucket);
if (chunkStart == null) {
throw new IllegalStateException("chunkStart is null.");
}
return chunkStart + ReadOnlyUtils.chunk(ByteUtils.md5(key), chunkIdToNumChunks.get(bucket));
}
default: {
throw new IllegalStateException("Unsupported storageFormat: " + storageFormat);
}
}
}
|
java
|
public int getChunkForKey(byte[] key) throws IllegalStateException {
if(numChunks == 0) {
throw new IllegalStateException("The ChunkedFileSet is closed.");
}
switch(storageFormat) {
case READONLY_V0: {
return ReadOnlyUtils.chunk(ByteUtils.md5(key), numChunks);
}
case READONLY_V1: {
if(nodePartitionIds == null) {
throw new IllegalStateException("nodePartitionIds is null.");
}
List<Integer> routingPartitionList = routingStrategy.getPartitionList(key);
routingPartitionList.retainAll(nodePartitionIds);
if(routingPartitionList.size() != 1) {
throw new IllegalStateException("The key does not belong on this node.");
}
return chunkIdToChunkStart.get(routingPartitionList.get(0))
+ ReadOnlyUtils.chunk(ByteUtils.md5(key),
chunkIdToNumChunks.get(routingPartitionList.get(0)));
}
case READONLY_V2: {
List<Integer> routingPartitionList = routingStrategy.getPartitionList(key);
Pair<Integer, Integer> bucket = null;
for(int replicaType = 0; replicaType < routingPartitionList.size(); replicaType++) {
if(nodePartitionIds == null) {
throw new IllegalStateException("nodePartitionIds is null.");
}
if(nodePartitionIds.contains(routingPartitionList.get(replicaType))) {
if(bucket == null) {
bucket = Pair.create(routingPartitionList.get(0), replicaType);
} else {
throw new IllegalStateException("Found more than one replica for a given partition on the current node!");
}
}
}
if(bucket == null) {
throw new IllegalStateException("The key does not belong on this node.");
}
Integer chunkStart = chunkIdToChunkStart.get(bucket);
if (chunkStart == null) {
throw new IllegalStateException("chunkStart is null.");
}
return chunkStart + ReadOnlyUtils.chunk(ByteUtils.md5(key), chunkIdToNumChunks.get(bucket));
}
default: {
throw new IllegalStateException("Unsupported storageFormat: " + storageFormat);
}
}
}
|
[
"public",
"int",
"getChunkForKey",
"(",
"byte",
"[",
"]",
"key",
")",
"throws",
"IllegalStateException",
"{",
"if",
"(",
"numChunks",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The ChunkedFileSet is closed.\"",
")",
";",
"}",
"switch",
"(",
"storageFormat",
")",
"{",
"case",
"READONLY_V0",
":",
"{",
"return",
"ReadOnlyUtils",
".",
"chunk",
"(",
"ByteUtils",
".",
"md5",
"(",
"key",
")",
",",
"numChunks",
")",
";",
"}",
"case",
"READONLY_V1",
":",
"{",
"if",
"(",
"nodePartitionIds",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"nodePartitionIds is null.\"",
")",
";",
"}",
"List",
"<",
"Integer",
">",
"routingPartitionList",
"=",
"routingStrategy",
".",
"getPartitionList",
"(",
"key",
")",
";",
"routingPartitionList",
".",
"retainAll",
"(",
"nodePartitionIds",
")",
";",
"if",
"(",
"routingPartitionList",
".",
"size",
"(",
")",
"!=",
"1",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The key does not belong on this node.\"",
")",
";",
"}",
"return",
"chunkIdToChunkStart",
".",
"get",
"(",
"routingPartitionList",
".",
"get",
"(",
"0",
")",
")",
"+",
"ReadOnlyUtils",
".",
"chunk",
"(",
"ByteUtils",
".",
"md5",
"(",
"key",
")",
",",
"chunkIdToNumChunks",
".",
"get",
"(",
"routingPartitionList",
".",
"get",
"(",
"0",
")",
")",
")",
";",
"}",
"case",
"READONLY_V2",
":",
"{",
"List",
"<",
"Integer",
">",
"routingPartitionList",
"=",
"routingStrategy",
".",
"getPartitionList",
"(",
"key",
")",
";",
"Pair",
"<",
"Integer",
",",
"Integer",
">",
"bucket",
"=",
"null",
";",
"for",
"(",
"int",
"replicaType",
"=",
"0",
";",
"replicaType",
"<",
"routingPartitionList",
".",
"size",
"(",
")",
";",
"replicaType",
"++",
")",
"{",
"if",
"(",
"nodePartitionIds",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"nodePartitionIds is null.\"",
")",
";",
"}",
"if",
"(",
"nodePartitionIds",
".",
"contains",
"(",
"routingPartitionList",
".",
"get",
"(",
"replicaType",
")",
")",
")",
"{",
"if",
"(",
"bucket",
"==",
"null",
")",
"{",
"bucket",
"=",
"Pair",
".",
"create",
"(",
"routingPartitionList",
".",
"get",
"(",
"0",
")",
",",
"replicaType",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Found more than one replica for a given partition on the current node!\"",
")",
";",
"}",
"}",
"}",
"if",
"(",
"bucket",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The key does not belong on this node.\"",
")",
";",
"}",
"Integer",
"chunkStart",
"=",
"chunkIdToChunkStart",
".",
"get",
"(",
"bucket",
")",
";",
"if",
"(",
"chunkStart",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"chunkStart is null.\"",
")",
";",
"}",
"return",
"chunkStart",
"+",
"ReadOnlyUtils",
".",
"chunk",
"(",
"ByteUtils",
".",
"md5",
"(",
"key",
")",
",",
"chunkIdToNumChunks",
".",
"get",
"(",
"bucket",
")",
")",
";",
"}",
"default",
":",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unsupported storageFormat: \"",
"+",
"storageFormat",
")",
";",
"}",
"}",
"}"
] |
Given a particular key, first converts its to the storage format and then
determines which chunk it belongs to
@param key Byte array of keys
@return Chunk id
@throws IllegalStateException if unable to find the chunk id for the given key
|
[
"Given",
"a",
"particular",
"key",
"first",
"converts",
"its",
"to",
"the",
"storage",
"format",
"and",
"then",
"determines",
"which",
"chunk",
"it",
"belongs",
"to"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/chunk/ChunkedFileSet.java#L568-L626
|
161,018 |
voldemort/voldemort
|
src/java/voldemort/tools/ReadOnlyReplicationHelperCLI.java
|
ReadOnlyReplicationHelperCLI.parseAndCompare
|
private static List<String> parseAndCompare(List<String> fileNames, int masterPartitionId) {
List<String> sourceFileNames = new ArrayList<String>();
for(String fileName: fileNames) {
String[] partitionIdReplicaChunk = fileName.split(SPLIT_LITERAL);
if(Integer.parseInt(partitionIdReplicaChunk[0]) == masterPartitionId) {
sourceFileNames.add(fileName);
}
}
return sourceFileNames;
}
|
java
|
private static List<String> parseAndCompare(List<String> fileNames, int masterPartitionId) {
List<String> sourceFileNames = new ArrayList<String>();
for(String fileName: fileNames) {
String[] partitionIdReplicaChunk = fileName.split(SPLIT_LITERAL);
if(Integer.parseInt(partitionIdReplicaChunk[0]) == masterPartitionId) {
sourceFileNames.add(fileName);
}
}
return sourceFileNames;
}
|
[
"private",
"static",
"List",
"<",
"String",
">",
"parseAndCompare",
"(",
"List",
"<",
"String",
">",
"fileNames",
",",
"int",
"masterPartitionId",
")",
"{",
"List",
"<",
"String",
">",
"sourceFileNames",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"fileName",
":",
"fileNames",
")",
"{",
"String",
"[",
"]",
"partitionIdReplicaChunk",
"=",
"fileName",
".",
"split",
"(",
"SPLIT_LITERAL",
")",
";",
"if",
"(",
"Integer",
".",
"parseInt",
"(",
"partitionIdReplicaChunk",
"[",
"0",
"]",
")",
"==",
"masterPartitionId",
")",
"{",
"sourceFileNames",
".",
"add",
"(",
"fileName",
")",
";",
"}",
"}",
"return",
"sourceFileNames",
";",
"}"
] |
This method take a list of fileName of the type partitionId_Replica_Chunk
and returns file names that match the regular expression
masterPartitionId_
|
[
"This",
"method",
"take",
"a",
"list",
"of",
"fileName",
"of",
"the",
"type",
"partitionId_Replica_Chunk",
"and",
"returns",
"file",
"names",
"that",
"match",
"the",
"regular",
"expression",
"masterPartitionId_"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/ReadOnlyReplicationHelperCLI.java#L151-L160
|
161,019 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java
|
ReadOnlyStorageEngine.getChunkIdToNumChunks
|
@JmxGetter(name = "getChunkIdToNumChunks", description = "Returns a string representation of the map of chunk id to number of chunks")
public String getChunkIdToNumChunks() {
StringBuilder builder = new StringBuilder();
for(Entry<Object, Integer> entry: fileSet.getChunkIdToNumChunks().entrySet()) {
builder.append(entry.getKey().toString() + " - " + entry.getValue().toString() + ", ");
}
return builder.toString();
}
|
java
|
@JmxGetter(name = "getChunkIdToNumChunks", description = "Returns a string representation of the map of chunk id to number of chunks")
public String getChunkIdToNumChunks() {
StringBuilder builder = new StringBuilder();
for(Entry<Object, Integer> entry: fileSet.getChunkIdToNumChunks().entrySet()) {
builder.append(entry.getKey().toString() + " - " + entry.getValue().toString() + ", ");
}
return builder.toString();
}
|
[
"@",
"JmxGetter",
"(",
"name",
"=",
"\"getChunkIdToNumChunks\"",
",",
"description",
"=",
"\"Returns a string representation of the map of chunk id to number of chunks\"",
")",
"public",
"String",
"getChunkIdToNumChunks",
"(",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"Object",
",",
"Integer",
">",
"entry",
":",
"fileSet",
".",
"getChunkIdToNumChunks",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"builder",
".",
"append",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"toString",
"(",
")",
"+",
"\" - \"",
"+",
"entry",
".",
"getValue",
"(",
")",
".",
"toString",
"(",
")",
"+",
"\", \"",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] |
Returns a string representation of map of chunk id to number of chunks
@return String of map of chunk id to number of chunks
|
[
"Returns",
"a",
"string",
"representation",
"of",
"map",
"of",
"chunk",
"id",
"to",
"number",
"of",
"chunks"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java#L171-L178
|
161,020 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java
|
ReadOnlyStorageEngine.open
|
public void open(File versionDir) {
/* acquire modification lock */
fileModificationLock.writeLock().lock();
try {
/* check that the store is currently closed */
if(isOpen)
throw new IllegalStateException("Attempt to open already open store.");
// Find version directory from symbolic link or max version id
if(versionDir == null) {
versionDir = ReadOnlyUtils.getCurrentVersion(storeDir);
if(versionDir == null)
versionDir = new File(storeDir, "version-0");
}
// Set the max version id
long versionId = ReadOnlyUtils.getVersionId(versionDir);
if(versionId == -1) {
throw new VoldemortException("Unable to parse id from version directory "
+ versionDir.getAbsolutePath());
}
Utils.mkdirs(versionDir);
// Validate symbolic link, and create it if it doesn't already exist
Utils.symlink(versionDir.getAbsolutePath(), storeDir.getAbsolutePath() + File.separator + "latest");
this.fileSet = new ChunkedFileSet(versionDir, routingStrategy, nodeId, maxValueBufferAllocationSize);
storeVersionManager.syncInternalStateFromFileSystem(false);
this.lastSwapped = System.currentTimeMillis();
this.isOpen = true;
} catch(IOException e) {
logger.error("Error in opening store", e);
} finally {
fileModificationLock.writeLock().unlock();
}
}
|
java
|
public void open(File versionDir) {
/* acquire modification lock */
fileModificationLock.writeLock().lock();
try {
/* check that the store is currently closed */
if(isOpen)
throw new IllegalStateException("Attempt to open already open store.");
// Find version directory from symbolic link or max version id
if(versionDir == null) {
versionDir = ReadOnlyUtils.getCurrentVersion(storeDir);
if(versionDir == null)
versionDir = new File(storeDir, "version-0");
}
// Set the max version id
long versionId = ReadOnlyUtils.getVersionId(versionDir);
if(versionId == -1) {
throw new VoldemortException("Unable to parse id from version directory "
+ versionDir.getAbsolutePath());
}
Utils.mkdirs(versionDir);
// Validate symbolic link, and create it if it doesn't already exist
Utils.symlink(versionDir.getAbsolutePath(), storeDir.getAbsolutePath() + File.separator + "latest");
this.fileSet = new ChunkedFileSet(versionDir, routingStrategy, nodeId, maxValueBufferAllocationSize);
storeVersionManager.syncInternalStateFromFileSystem(false);
this.lastSwapped = System.currentTimeMillis();
this.isOpen = true;
} catch(IOException e) {
logger.error("Error in opening store", e);
} finally {
fileModificationLock.writeLock().unlock();
}
}
|
[
"public",
"void",
"open",
"(",
"File",
"versionDir",
")",
"{",
"/* acquire modification lock */",
"fileModificationLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"/* check that the store is currently closed */",
"if",
"(",
"isOpen",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Attempt to open already open store.\"",
")",
";",
"// Find version directory from symbolic link or max version id",
"if",
"(",
"versionDir",
"==",
"null",
")",
"{",
"versionDir",
"=",
"ReadOnlyUtils",
".",
"getCurrentVersion",
"(",
"storeDir",
")",
";",
"if",
"(",
"versionDir",
"==",
"null",
")",
"versionDir",
"=",
"new",
"File",
"(",
"storeDir",
",",
"\"version-0\"",
")",
";",
"}",
"// Set the max version id",
"long",
"versionId",
"=",
"ReadOnlyUtils",
".",
"getVersionId",
"(",
"versionDir",
")",
";",
"if",
"(",
"versionId",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"VoldemortException",
"(",
"\"Unable to parse id from version directory \"",
"+",
"versionDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"Utils",
".",
"mkdirs",
"(",
"versionDir",
")",
";",
"// Validate symbolic link, and create it if it doesn't already exist",
"Utils",
".",
"symlink",
"(",
"versionDir",
".",
"getAbsolutePath",
"(",
")",
",",
"storeDir",
".",
"getAbsolutePath",
"(",
")",
"+",
"File",
".",
"separator",
"+",
"\"latest\"",
")",
";",
"this",
".",
"fileSet",
"=",
"new",
"ChunkedFileSet",
"(",
"versionDir",
",",
"routingStrategy",
",",
"nodeId",
",",
"maxValueBufferAllocationSize",
")",
";",
"storeVersionManager",
".",
"syncInternalStateFromFileSystem",
"(",
"false",
")",
";",
"this",
".",
"lastSwapped",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"this",
".",
"isOpen",
"=",
"true",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error in opening store\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"fileModificationLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Open the store with the version directory specified. If null is specified
we open the directory with the maximum version
@param versionDir Version Directory to open. If null, we open the max
versioned / latest directory
|
[
"Open",
"the",
"store",
"with",
"the",
"version",
"directory",
"specified",
".",
"If",
"null",
"is",
"specified",
"we",
"open",
"the",
"directory",
"with",
"the",
"maximum",
"version"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java#L187-L222
|
161,021 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java
|
ReadOnlyStorageEngine.getLastSwapped
|
@JmxGetter(name = "lastSwapped", description = "Time in milliseconds since the store was swapped")
public long getLastSwapped() {
long timeSinceLastSwap = System.currentTimeMillis() - lastSwapped;
return timeSinceLastSwap > 0 ? timeSinceLastSwap : 0;
}
|
java
|
@JmxGetter(name = "lastSwapped", description = "Time in milliseconds since the store was swapped")
public long getLastSwapped() {
long timeSinceLastSwap = System.currentTimeMillis() - lastSwapped;
return timeSinceLastSwap > 0 ? timeSinceLastSwap : 0;
}
|
[
"@",
"JmxGetter",
"(",
"name",
"=",
"\"lastSwapped\"",
",",
"description",
"=",
"\"Time in milliseconds since the store was swapped\"",
")",
"public",
"long",
"getLastSwapped",
"(",
")",
"{",
"long",
"timeSinceLastSwap",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"lastSwapped",
";",
"return",
"timeSinceLastSwap",
">",
"0",
"?",
"timeSinceLastSwap",
":",
"0",
";",
"}"
] |
Time since last time the store was swapped
@return Time in milliseconds since the store was swapped
|
[
"Time",
"since",
"last",
"time",
"the",
"store",
"was",
"swapped"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java#L277-L281
|
161,022 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java
|
ReadOnlyStorageEngine.close
|
@Override
public void close() throws VoldemortException {
logger.debug("Close called for read-only store.");
this.fileModificationLock.writeLock().lock();
try {
if(isOpen) {
this.isOpen = false;
fileSet.close();
} else {
logger.debug("Attempt to close already closed store " + getName());
}
} finally {
this.fileModificationLock.writeLock().unlock();
}
}
|
java
|
@Override
public void close() throws VoldemortException {
logger.debug("Close called for read-only store.");
this.fileModificationLock.writeLock().lock();
try {
if(isOpen) {
this.isOpen = false;
fileSet.close();
} else {
logger.debug("Attempt to close already closed store " + getName());
}
} finally {
this.fileModificationLock.writeLock().unlock();
}
}
|
[
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"VoldemortException",
"{",
"logger",
".",
"debug",
"(",
"\"Close called for read-only store.\"",
")",
";",
"this",
".",
"fileModificationLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"isOpen",
")",
"{",
"this",
".",
"isOpen",
"=",
"false",
";",
"fileSet",
".",
"close",
"(",
")",
";",
"}",
"else",
"{",
"logger",
".",
"debug",
"(",
"\"Attempt to close already closed store \"",
"+",
"getName",
"(",
")",
")",
";",
"}",
"}",
"finally",
"{",
"this",
".",
"fileModificationLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Close the store.
|
[
"Close",
"the",
"store",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java#L286-L301
|
161,023 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java
|
ReadOnlyStorageEngine.swapFiles
|
@JmxOperation(description = "swapFiles changes this store to use the new data directory")
public void swapFiles(String newStoreDirectory) {
logger.info("Swapping files for store '" + getName() + "' to " + newStoreDirectory);
File newVersionDir = new File(newStoreDirectory);
if(!newVersionDir.exists())
throw new VoldemortException("File " + newVersionDir.getAbsolutePath()
+ " does not exist.");
if(!(newVersionDir.getParentFile().compareTo(storeDir.getAbsoluteFile()) == 0 && ReadOnlyUtils.checkVersionDirName(newVersionDir)))
throw new VoldemortException("Invalid version folder name '"
+ newVersionDir
+ "'. Either parent directory is incorrect or format(version-n) is incorrect");
// retrieve previous version for (a) check if last write is winning
// (b) if failure, rollback use
File previousVersionDir = ReadOnlyUtils.getCurrentVersion(storeDir);
if(previousVersionDir == null)
throw new VoldemortException("Could not find any latest directory to swap with in store '"
+ getName() + "'");
long newVersionId = ReadOnlyUtils.getVersionId(newVersionDir);
long previousVersionId = ReadOnlyUtils.getVersionId(previousVersionDir);
if(newVersionId == -1 || previousVersionId == -1)
throw new VoldemortException("Unable to parse folder names (" + newVersionDir.getName()
+ "," + previousVersionDir.getName()
+ ") since format(version-n) is incorrect");
// check if we're greater than latest since we want last write to win
if(previousVersionId > newVersionId) {
logger.info("No swap required since current latest version " + previousVersionId
+ " is greater than swap version " + newVersionId);
deleteBackups();
return;
}
logger.info("Acquiring write lock on '" + getName() + "':");
fileModificationLock.writeLock().lock();
boolean success = false;
try {
close();
logger.info("Opening primary files for store '" + getName() + "' at "
+ newStoreDirectory);
// open the latest store
open(newVersionDir);
success = true;
} finally {
try {
// we failed to do the swap, attempt a rollback to last version
if(!success)
rollback(previousVersionDir);
} finally {
fileModificationLock.writeLock().unlock();
if(success)
logger.info("Swap operation completed successfully on store " + getName()
+ ", releasing lock.");
else
logger.error("Swap operation failed.");
}
}
// okay we have released the lock and the store is now open again, it is
// safe to do a potentially slow delete if we have one too many backups
deleteBackups();
}
|
java
|
@JmxOperation(description = "swapFiles changes this store to use the new data directory")
public void swapFiles(String newStoreDirectory) {
logger.info("Swapping files for store '" + getName() + "' to " + newStoreDirectory);
File newVersionDir = new File(newStoreDirectory);
if(!newVersionDir.exists())
throw new VoldemortException("File " + newVersionDir.getAbsolutePath()
+ " does not exist.");
if(!(newVersionDir.getParentFile().compareTo(storeDir.getAbsoluteFile()) == 0 && ReadOnlyUtils.checkVersionDirName(newVersionDir)))
throw new VoldemortException("Invalid version folder name '"
+ newVersionDir
+ "'. Either parent directory is incorrect or format(version-n) is incorrect");
// retrieve previous version for (a) check if last write is winning
// (b) if failure, rollback use
File previousVersionDir = ReadOnlyUtils.getCurrentVersion(storeDir);
if(previousVersionDir == null)
throw new VoldemortException("Could not find any latest directory to swap with in store '"
+ getName() + "'");
long newVersionId = ReadOnlyUtils.getVersionId(newVersionDir);
long previousVersionId = ReadOnlyUtils.getVersionId(previousVersionDir);
if(newVersionId == -1 || previousVersionId == -1)
throw new VoldemortException("Unable to parse folder names (" + newVersionDir.getName()
+ "," + previousVersionDir.getName()
+ ") since format(version-n) is incorrect");
// check if we're greater than latest since we want last write to win
if(previousVersionId > newVersionId) {
logger.info("No swap required since current latest version " + previousVersionId
+ " is greater than swap version " + newVersionId);
deleteBackups();
return;
}
logger.info("Acquiring write lock on '" + getName() + "':");
fileModificationLock.writeLock().lock();
boolean success = false;
try {
close();
logger.info("Opening primary files for store '" + getName() + "' at "
+ newStoreDirectory);
// open the latest store
open(newVersionDir);
success = true;
} finally {
try {
// we failed to do the swap, attempt a rollback to last version
if(!success)
rollback(previousVersionDir);
} finally {
fileModificationLock.writeLock().unlock();
if(success)
logger.info("Swap operation completed successfully on store " + getName()
+ ", releasing lock.");
else
logger.error("Swap operation failed.");
}
}
// okay we have released the lock and the store is now open again, it is
// safe to do a potentially slow delete if we have one too many backups
deleteBackups();
}
|
[
"@",
"JmxOperation",
"(",
"description",
"=",
"\"swapFiles changes this store to use the new data directory\"",
")",
"public",
"void",
"swapFiles",
"(",
"String",
"newStoreDirectory",
")",
"{",
"logger",
".",
"info",
"(",
"\"Swapping files for store '\"",
"+",
"getName",
"(",
")",
"+",
"\"' to \"",
"+",
"newStoreDirectory",
")",
";",
"File",
"newVersionDir",
"=",
"new",
"File",
"(",
"newStoreDirectory",
")",
";",
"if",
"(",
"!",
"newVersionDir",
".",
"exists",
"(",
")",
")",
"throw",
"new",
"VoldemortException",
"(",
"\"File \"",
"+",
"newVersionDir",
".",
"getAbsolutePath",
"(",
")",
"+",
"\" does not exist.\"",
")",
";",
"if",
"(",
"!",
"(",
"newVersionDir",
".",
"getParentFile",
"(",
")",
".",
"compareTo",
"(",
"storeDir",
".",
"getAbsoluteFile",
"(",
")",
")",
"==",
"0",
"&&",
"ReadOnlyUtils",
".",
"checkVersionDirName",
"(",
"newVersionDir",
")",
")",
")",
"throw",
"new",
"VoldemortException",
"(",
"\"Invalid version folder name '\"",
"+",
"newVersionDir",
"+",
"\"'. Either parent directory is incorrect or format(version-n) is incorrect\"",
")",
";",
"// retrieve previous version for (a) check if last write is winning",
"// (b) if failure, rollback use",
"File",
"previousVersionDir",
"=",
"ReadOnlyUtils",
".",
"getCurrentVersion",
"(",
"storeDir",
")",
";",
"if",
"(",
"previousVersionDir",
"==",
"null",
")",
"throw",
"new",
"VoldemortException",
"(",
"\"Could not find any latest directory to swap with in store '\"",
"+",
"getName",
"(",
")",
"+",
"\"'\"",
")",
";",
"long",
"newVersionId",
"=",
"ReadOnlyUtils",
".",
"getVersionId",
"(",
"newVersionDir",
")",
";",
"long",
"previousVersionId",
"=",
"ReadOnlyUtils",
".",
"getVersionId",
"(",
"previousVersionDir",
")",
";",
"if",
"(",
"newVersionId",
"==",
"-",
"1",
"||",
"previousVersionId",
"==",
"-",
"1",
")",
"throw",
"new",
"VoldemortException",
"(",
"\"Unable to parse folder names (\"",
"+",
"newVersionDir",
".",
"getName",
"(",
")",
"+",
"\",\"",
"+",
"previousVersionDir",
".",
"getName",
"(",
")",
"+",
"\") since format(version-n) is incorrect\"",
")",
";",
"// check if we're greater than latest since we want last write to win",
"if",
"(",
"previousVersionId",
">",
"newVersionId",
")",
"{",
"logger",
".",
"info",
"(",
"\"No swap required since current latest version \"",
"+",
"previousVersionId",
"+",
"\" is greater than swap version \"",
"+",
"newVersionId",
")",
";",
"deleteBackups",
"(",
")",
";",
"return",
";",
"}",
"logger",
".",
"info",
"(",
"\"Acquiring write lock on '\"",
"+",
"getName",
"(",
")",
"+",
"\"':\"",
")",
";",
"fileModificationLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"boolean",
"success",
"=",
"false",
";",
"try",
"{",
"close",
"(",
")",
";",
"logger",
".",
"info",
"(",
"\"Opening primary files for store '\"",
"+",
"getName",
"(",
")",
"+",
"\"' at \"",
"+",
"newStoreDirectory",
")",
";",
"// open the latest store",
"open",
"(",
"newVersionDir",
")",
";",
"success",
"=",
"true",
";",
"}",
"finally",
"{",
"try",
"{",
"// we failed to do the swap, attempt a rollback to last version",
"if",
"(",
"!",
"success",
")",
"rollback",
"(",
"previousVersionDir",
")",
";",
"}",
"finally",
"{",
"fileModificationLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"if",
"(",
"success",
")",
"logger",
".",
"info",
"(",
"\"Swap operation completed successfully on store \"",
"+",
"getName",
"(",
")",
"+",
"\", releasing lock.\"",
")",
";",
"else",
"logger",
".",
"error",
"(",
"\"Swap operation failed.\"",
")",
";",
"}",
"}",
"// okay we have released the lock and the store is now open again, it is",
"// safe to do a potentially slow delete if we have one too many backups",
"deleteBackups",
"(",
")",
";",
"}"
] |
Swap the current version folder for a new one
@param newStoreDirectory The path to the new version directory
|
[
"Swap",
"the",
"current",
"version",
"folder",
"for",
"a",
"new",
"one"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java#L308-L374
|
161,024 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java
|
ReadOnlyStorageEngine.deleteBackups
|
private void deleteBackups() {
File[] storeDirList = ReadOnlyUtils.getVersionDirs(storeDir, 0L, getCurrentVersionId());
if(storeDirList != null && storeDirList.length > (numBackups + 1)) {
// delete ALL old directories asynchronously
File[] extraBackups = ReadOnlyUtils.findKthVersionedDir(storeDirList,
0,
storeDirList.length
- (numBackups + 1) - 1);
if(extraBackups != null) {
for(File backUpFile: extraBackups) {
deleteAsync(backUpFile);
}
}
}
}
|
java
|
private void deleteBackups() {
File[] storeDirList = ReadOnlyUtils.getVersionDirs(storeDir, 0L, getCurrentVersionId());
if(storeDirList != null && storeDirList.length > (numBackups + 1)) {
// delete ALL old directories asynchronously
File[] extraBackups = ReadOnlyUtils.findKthVersionedDir(storeDirList,
0,
storeDirList.length
- (numBackups + 1) - 1);
if(extraBackups != null) {
for(File backUpFile: extraBackups) {
deleteAsync(backUpFile);
}
}
}
}
|
[
"private",
"void",
"deleteBackups",
"(",
")",
"{",
"File",
"[",
"]",
"storeDirList",
"=",
"ReadOnlyUtils",
".",
"getVersionDirs",
"(",
"storeDir",
",",
"0L",
",",
"getCurrentVersionId",
"(",
")",
")",
";",
"if",
"(",
"storeDirList",
"!=",
"null",
"&&",
"storeDirList",
".",
"length",
">",
"(",
"numBackups",
"+",
"1",
")",
")",
"{",
"// delete ALL old directories asynchronously",
"File",
"[",
"]",
"extraBackups",
"=",
"ReadOnlyUtils",
".",
"findKthVersionedDir",
"(",
"storeDirList",
",",
"0",
",",
"storeDirList",
".",
"length",
"-",
"(",
"numBackups",
"+",
"1",
")",
"-",
"1",
")",
";",
"if",
"(",
"extraBackups",
"!=",
"null",
")",
"{",
"for",
"(",
"File",
"backUpFile",
":",
"extraBackups",
")",
"{",
"deleteAsync",
"(",
"backUpFile",
")",
";",
"}",
"}",
"}",
"}"
] |
Delete all backups asynchronously
|
[
"Delete",
"all",
"backups",
"asynchronously"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java#L379-L393
|
161,025 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java
|
ReadOnlyStorageEngine.deleteAsync
|
private void deleteAsync(final File file) {
new Thread(new Runnable() {
@Override
public void run() {
try {
try {
logger.info("Waiting for " + deleteBackupMs
+ " milliseconds before deleting " + file.getAbsolutePath());
Thread.sleep(deleteBackupMs);
} catch(InterruptedException e) {
logger.warn("Did not sleep enough before deleting backups");
}
logger.info("Deleting file " + file.getAbsolutePath());
Utils.rm(file);
logger.info("Deleting of " + file.getAbsolutePath()
+ " completed successfully.");
storeVersionManager.syncInternalStateFromFileSystem(true);
} catch(Exception e) {
logger.error("Exception during deleteAsync for path: " + file, e);
}
}
}, "background-file-delete").start();
}
|
java
|
private void deleteAsync(final File file) {
new Thread(new Runnable() {
@Override
public void run() {
try {
try {
logger.info("Waiting for " + deleteBackupMs
+ " milliseconds before deleting " + file.getAbsolutePath());
Thread.sleep(deleteBackupMs);
} catch(InterruptedException e) {
logger.warn("Did not sleep enough before deleting backups");
}
logger.info("Deleting file " + file.getAbsolutePath());
Utils.rm(file);
logger.info("Deleting of " + file.getAbsolutePath()
+ " completed successfully.");
storeVersionManager.syncInternalStateFromFileSystem(true);
} catch(Exception e) {
logger.error("Exception during deleteAsync for path: " + file, e);
}
}
}, "background-file-delete").start();
}
|
[
"private",
"void",
"deleteAsync",
"(",
"final",
"File",
"file",
")",
"{",
"new",
"Thread",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"try",
"{",
"logger",
".",
"info",
"(",
"\"Waiting for \"",
"+",
"deleteBackupMs",
"+",
"\" milliseconds before deleting \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"Thread",
".",
"sleep",
"(",
"deleteBackupMs",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Did not sleep enough before deleting backups\"",
")",
";",
"}",
"logger",
".",
"info",
"(",
"\"Deleting file \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"Utils",
".",
"rm",
"(",
"file",
")",
";",
"logger",
".",
"info",
"(",
"\"Deleting of \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
"+",
"\" completed successfully.\"",
")",
";",
"storeVersionManager",
".",
"syncInternalStateFromFileSystem",
"(",
"true",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Exception during deleteAsync for path: \"",
"+",
"file",
",",
"e",
")",
";",
"}",
"}",
"}",
",",
"\"background-file-delete\"",
")",
".",
"start",
"(",
")",
";",
"}"
] |
Delete the given file in a separate thread
@param file The file to delete
|
[
"Delete",
"the",
"given",
"file",
"in",
"a",
"separate",
"thread"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java#L400-L423
|
161,026 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java
|
ReadOnlyStorageEngine.rollback
|
public void rollback(File rollbackToDir) {
logger.info("Rolling back store '" + getName() + "'");
fileModificationLock.writeLock().lock();
try {
if(rollbackToDir == null)
throw new VoldemortException("Version directory specified to rollback is null");
if(!rollbackToDir.exists())
throw new VoldemortException("Version directory " + rollbackToDir.getAbsolutePath()
+ " specified to rollback does not exist");
long versionId = ReadOnlyUtils.getVersionId(rollbackToDir);
if(versionId == -1)
throw new VoldemortException("Cannot parse version id");
File[] backUpDirs = ReadOnlyUtils.getVersionDirs(storeDir, versionId, Long.MAX_VALUE);
if(backUpDirs == null || backUpDirs.length <= 1) {
logger.warn("No rollback performed since there are no back-up directories");
return;
}
backUpDirs = ReadOnlyUtils.findKthVersionedDir(backUpDirs, 0, backUpDirs.length - 1);
if(isOpen)
close();
// open the rollback directory
open(rollbackToDir);
// back-up all other directories
DateFormat df = new SimpleDateFormat("MM-dd-yyyy");
for(int index = 1; index < backUpDirs.length; index++) {
Utils.move(backUpDirs[index], new File(storeDir, backUpDirs[index].getName() + "."
+ df.format(new Date()) + ".bak"));
}
} finally {
fileModificationLock.writeLock().unlock();
logger.info("Rollback operation completed on '" + getName() + "', releasing lock.");
}
}
|
java
|
public void rollback(File rollbackToDir) {
logger.info("Rolling back store '" + getName() + "'");
fileModificationLock.writeLock().lock();
try {
if(rollbackToDir == null)
throw new VoldemortException("Version directory specified to rollback is null");
if(!rollbackToDir.exists())
throw new VoldemortException("Version directory " + rollbackToDir.getAbsolutePath()
+ " specified to rollback does not exist");
long versionId = ReadOnlyUtils.getVersionId(rollbackToDir);
if(versionId == -1)
throw new VoldemortException("Cannot parse version id");
File[] backUpDirs = ReadOnlyUtils.getVersionDirs(storeDir, versionId, Long.MAX_VALUE);
if(backUpDirs == null || backUpDirs.length <= 1) {
logger.warn("No rollback performed since there are no back-up directories");
return;
}
backUpDirs = ReadOnlyUtils.findKthVersionedDir(backUpDirs, 0, backUpDirs.length - 1);
if(isOpen)
close();
// open the rollback directory
open(rollbackToDir);
// back-up all other directories
DateFormat df = new SimpleDateFormat("MM-dd-yyyy");
for(int index = 1; index < backUpDirs.length; index++) {
Utils.move(backUpDirs[index], new File(storeDir, backUpDirs[index].getName() + "."
+ df.format(new Date()) + ".bak"));
}
} finally {
fileModificationLock.writeLock().unlock();
logger.info("Rollback operation completed on '" + getName() + "', releasing lock.");
}
}
|
[
"public",
"void",
"rollback",
"(",
"File",
"rollbackToDir",
")",
"{",
"logger",
".",
"info",
"(",
"\"Rolling back store '\"",
"+",
"getName",
"(",
")",
"+",
"\"'\"",
")",
";",
"fileModificationLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"rollbackToDir",
"==",
"null",
")",
"throw",
"new",
"VoldemortException",
"(",
"\"Version directory specified to rollback is null\"",
")",
";",
"if",
"(",
"!",
"rollbackToDir",
".",
"exists",
"(",
")",
")",
"throw",
"new",
"VoldemortException",
"(",
"\"Version directory \"",
"+",
"rollbackToDir",
".",
"getAbsolutePath",
"(",
")",
"+",
"\" specified to rollback does not exist\"",
")",
";",
"long",
"versionId",
"=",
"ReadOnlyUtils",
".",
"getVersionId",
"(",
"rollbackToDir",
")",
";",
"if",
"(",
"versionId",
"==",
"-",
"1",
")",
"throw",
"new",
"VoldemortException",
"(",
"\"Cannot parse version id\"",
")",
";",
"File",
"[",
"]",
"backUpDirs",
"=",
"ReadOnlyUtils",
".",
"getVersionDirs",
"(",
"storeDir",
",",
"versionId",
",",
"Long",
".",
"MAX_VALUE",
")",
";",
"if",
"(",
"backUpDirs",
"==",
"null",
"||",
"backUpDirs",
".",
"length",
"<=",
"1",
")",
"{",
"logger",
".",
"warn",
"(",
"\"No rollback performed since there are no back-up directories\"",
")",
";",
"return",
";",
"}",
"backUpDirs",
"=",
"ReadOnlyUtils",
".",
"findKthVersionedDir",
"(",
"backUpDirs",
",",
"0",
",",
"backUpDirs",
".",
"length",
"-",
"1",
")",
";",
"if",
"(",
"isOpen",
")",
"close",
"(",
")",
";",
"// open the rollback directory",
"open",
"(",
"rollbackToDir",
")",
";",
"// back-up all other directories",
"DateFormat",
"df",
"=",
"new",
"SimpleDateFormat",
"(",
"\"MM-dd-yyyy\"",
")",
";",
"for",
"(",
"int",
"index",
"=",
"1",
";",
"index",
"<",
"backUpDirs",
".",
"length",
";",
"index",
"++",
")",
"{",
"Utils",
".",
"move",
"(",
"backUpDirs",
"[",
"index",
"]",
",",
"new",
"File",
"(",
"storeDir",
",",
"backUpDirs",
"[",
"index",
"]",
".",
"getName",
"(",
")",
"+",
"\".\"",
"+",
"df",
".",
"format",
"(",
"new",
"Date",
"(",
")",
")",
"+",
"\".bak\"",
")",
")",
";",
"}",
"}",
"finally",
"{",
"fileModificationLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"logger",
".",
"info",
"(",
"\"Rollback operation completed on '\"",
"+",
"getName",
"(",
")",
"+",
"\"', releasing lock.\"",
")",
";",
"}",
"}"
] |
Rollback to the specified push version
@param rollbackToDir The version directory to rollback to
|
[
"Rollback",
"to",
"the",
"specified",
"push",
"version"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java#L441-L480
|
161,027 |
voldemort/voldemort
|
src/java/voldemort/rest/RestRequestValidator.java
|
RestRequestValidator.hasTimeOutHeader
|
protected boolean hasTimeOutHeader() {
boolean result = false;
String timeoutValStr = this.request.getHeader(RestMessageHeaders.X_VOLD_REQUEST_TIMEOUT_MS);
if(timeoutValStr != null) {
try {
this.parsedTimeoutInMs = Long.parseLong(timeoutValStr);
if(this.parsedTimeoutInMs < 0) {
RestErrorHandler.writeErrorResponse(messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Time out cannot be negative ");
} else {
result = true;
}
} catch(NumberFormatException nfe) {
logger.error("Exception when validating request. Incorrect timeout parameter. Cannot parse this to long: "
+ timeoutValStr,
nfe);
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Incorrect timeout parameter. Cannot parse this to long: "
+ timeoutValStr);
}
} else {
logger.error("Error when validating request. Missing timeout parameter.");
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Missing timeout parameter.");
}
return result;
}
|
java
|
protected boolean hasTimeOutHeader() {
boolean result = false;
String timeoutValStr = this.request.getHeader(RestMessageHeaders.X_VOLD_REQUEST_TIMEOUT_MS);
if(timeoutValStr != null) {
try {
this.parsedTimeoutInMs = Long.parseLong(timeoutValStr);
if(this.parsedTimeoutInMs < 0) {
RestErrorHandler.writeErrorResponse(messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Time out cannot be negative ");
} else {
result = true;
}
} catch(NumberFormatException nfe) {
logger.error("Exception when validating request. Incorrect timeout parameter. Cannot parse this to long: "
+ timeoutValStr,
nfe);
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Incorrect timeout parameter. Cannot parse this to long: "
+ timeoutValStr);
}
} else {
logger.error("Error when validating request. Missing timeout parameter.");
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Missing timeout parameter.");
}
return result;
}
|
[
"protected",
"boolean",
"hasTimeOutHeader",
"(",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"String",
"timeoutValStr",
"=",
"this",
".",
"request",
".",
"getHeader",
"(",
"RestMessageHeaders",
".",
"X_VOLD_REQUEST_TIMEOUT_MS",
")",
";",
"if",
"(",
"timeoutValStr",
"!=",
"null",
")",
"{",
"try",
"{",
"this",
".",
"parsedTimeoutInMs",
"=",
"Long",
".",
"parseLong",
"(",
"timeoutValStr",
")",
";",
"if",
"(",
"this",
".",
"parsedTimeoutInMs",
"<",
"0",
")",
"{",
"RestErrorHandler",
".",
"writeErrorResponse",
"(",
"messageEvent",
",",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Time out cannot be negative \"",
")",
";",
"}",
"else",
"{",
"result",
"=",
"true",
";",
"}",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"logger",
".",
"error",
"(",
"\"Exception when validating request. Incorrect timeout parameter. Cannot parse this to long: \"",
"+",
"timeoutValStr",
",",
"nfe",
")",
";",
"RestErrorHandler",
".",
"writeErrorResponse",
"(",
"this",
".",
"messageEvent",
",",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Incorrect timeout parameter. Cannot parse this to long: \"",
"+",
"timeoutValStr",
")",
";",
"}",
"}",
"else",
"{",
"logger",
".",
"error",
"(",
"\"Error when validating request. Missing timeout parameter.\"",
")",
";",
"RestErrorHandler",
".",
"writeErrorResponse",
"(",
"this",
".",
"messageEvent",
",",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing timeout parameter.\"",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieve and validate the timeout value from the REST request.
"X_VOLD_REQUEST_TIMEOUT_MS" is the timeout header.
@return true if present, false if missing
|
[
"Retrieve",
"and",
"validate",
"the",
"timeout",
"value",
"from",
"the",
"REST",
"request",
".",
"X_VOLD_REQUEST_TIMEOUT_MS",
"is",
"the",
"timeout",
"header",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestRequestValidator.java#L67-L98
|
161,028 |
voldemort/voldemort
|
src/java/voldemort/rest/RestRequestValidator.java
|
RestRequestValidator.parseRoutingCodeHeader
|
protected void parseRoutingCodeHeader() {
String rtCode = this.request.getHeader(RestMessageHeaders.X_VOLD_ROUTING_TYPE_CODE);
if(rtCode != null) {
try {
int routingTypeCode = Integer.parseInt(rtCode);
this.parsedRoutingType = RequestRoutingType.getRequestRoutingType(routingTypeCode);
} catch(NumberFormatException nfe) {
logger.error("Exception when validating request. Incorrect routing type parameter. Cannot parse this to long: "
+ rtCode,
nfe);
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Incorrect routing type parameter. Cannot parse this to long: "
+ rtCode);
} catch(VoldemortException ve) {
logger.error("Exception when validating request. Incorrect routing type code: "
+ rtCode, ve);
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Incorrect routing type code: " + rtCode);
}
}
}
|
java
|
protected void parseRoutingCodeHeader() {
String rtCode = this.request.getHeader(RestMessageHeaders.X_VOLD_ROUTING_TYPE_CODE);
if(rtCode != null) {
try {
int routingTypeCode = Integer.parseInt(rtCode);
this.parsedRoutingType = RequestRoutingType.getRequestRoutingType(routingTypeCode);
} catch(NumberFormatException nfe) {
logger.error("Exception when validating request. Incorrect routing type parameter. Cannot parse this to long: "
+ rtCode,
nfe);
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Incorrect routing type parameter. Cannot parse this to long: "
+ rtCode);
} catch(VoldemortException ve) {
logger.error("Exception when validating request. Incorrect routing type code: "
+ rtCode, ve);
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Incorrect routing type code: " + rtCode);
}
}
}
|
[
"protected",
"void",
"parseRoutingCodeHeader",
"(",
")",
"{",
"String",
"rtCode",
"=",
"this",
".",
"request",
".",
"getHeader",
"(",
"RestMessageHeaders",
".",
"X_VOLD_ROUTING_TYPE_CODE",
")",
";",
"if",
"(",
"rtCode",
"!=",
"null",
")",
"{",
"try",
"{",
"int",
"routingTypeCode",
"=",
"Integer",
".",
"parseInt",
"(",
"rtCode",
")",
";",
"this",
".",
"parsedRoutingType",
"=",
"RequestRoutingType",
".",
"getRequestRoutingType",
"(",
"routingTypeCode",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"logger",
".",
"error",
"(",
"\"Exception when validating request. Incorrect routing type parameter. Cannot parse this to long: \"",
"+",
"rtCode",
",",
"nfe",
")",
";",
"RestErrorHandler",
".",
"writeErrorResponse",
"(",
"this",
".",
"messageEvent",
",",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Incorrect routing type parameter. Cannot parse this to long: \"",
"+",
"rtCode",
")",
";",
"}",
"catch",
"(",
"VoldemortException",
"ve",
")",
"{",
"logger",
".",
"error",
"(",
"\"Exception when validating request. Incorrect routing type code: \"",
"+",
"rtCode",
",",
"ve",
")",
";",
"RestErrorHandler",
".",
"writeErrorResponse",
"(",
"this",
".",
"messageEvent",
",",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Incorrect routing type code: \"",
"+",
"rtCode",
")",
";",
"}",
"}",
"}"
] |
Retrieve the routing type value from the REST request.
"X_VOLD_ROUTING_TYPE_CODE" is the routing type header.
By default, the routing code is set to NORMAL
TODO REST-Server 1. Change the header name to a better name. 2. Assumes
that integer is passed in the header
|
[
"Retrieve",
"the",
"routing",
"type",
"value",
"from",
"the",
"REST",
"request",
".",
"X_VOLD_ROUTING_TYPE_CODE",
"is",
"the",
"routing",
"type",
"header",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestRequestValidator.java#L110-L133
|
161,029 |
voldemort/voldemort
|
src/java/voldemort/rest/RestRequestValidator.java
|
RestRequestValidator.hasTimeStampHeader
|
protected boolean hasTimeStampHeader() {
String originTime = request.getHeader(RestMessageHeaders.X_VOLD_REQUEST_ORIGIN_TIME_MS);
boolean result = false;
if(originTime != null) {
try {
// TODO: remove the originTime field from request header,
// because coordinator should not accept the request origin time
// from the client.. In this commit, we only changed
// "this.parsedRequestOriginTimeInMs" from
// "Long.parseLong(originTime)" to current system time,
// The reason that we did not remove the field from request
// header right now, is because this commit is a quick fix for
// internal performance test to be available as soon as
// possible.
this.parsedRequestOriginTimeInMs = System.currentTimeMillis();
if(this.parsedRequestOriginTimeInMs < 0) {
RestErrorHandler.writeErrorResponse(messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Origin time cannot be negative ");
} else {
result = true;
}
} catch(NumberFormatException nfe) {
logger.error("Exception when validating request. Incorrect origin time parameter. Cannot parse this to long: "
+ originTime,
nfe);
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Incorrect origin time parameter. Cannot parse this to long: "
+ originTime);
}
} else {
logger.error("Error when validating request. Missing origin time parameter.");
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Missing origin time parameter.");
}
return result;
}
|
java
|
protected boolean hasTimeStampHeader() {
String originTime = request.getHeader(RestMessageHeaders.X_VOLD_REQUEST_ORIGIN_TIME_MS);
boolean result = false;
if(originTime != null) {
try {
// TODO: remove the originTime field from request header,
// because coordinator should not accept the request origin time
// from the client.. In this commit, we only changed
// "this.parsedRequestOriginTimeInMs" from
// "Long.parseLong(originTime)" to current system time,
// The reason that we did not remove the field from request
// header right now, is because this commit is a quick fix for
// internal performance test to be available as soon as
// possible.
this.parsedRequestOriginTimeInMs = System.currentTimeMillis();
if(this.parsedRequestOriginTimeInMs < 0) {
RestErrorHandler.writeErrorResponse(messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Origin time cannot be negative ");
} else {
result = true;
}
} catch(NumberFormatException nfe) {
logger.error("Exception when validating request. Incorrect origin time parameter. Cannot parse this to long: "
+ originTime,
nfe);
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Incorrect origin time parameter. Cannot parse this to long: "
+ originTime);
}
} else {
logger.error("Error when validating request. Missing origin time parameter.");
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Missing origin time parameter.");
}
return result;
}
|
[
"protected",
"boolean",
"hasTimeStampHeader",
"(",
")",
"{",
"String",
"originTime",
"=",
"request",
".",
"getHeader",
"(",
"RestMessageHeaders",
".",
"X_VOLD_REQUEST_ORIGIN_TIME_MS",
")",
";",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"originTime",
"!=",
"null",
")",
"{",
"try",
"{",
"// TODO: remove the originTime field from request header,",
"// because coordinator should not accept the request origin time",
"// from the client.. In this commit, we only changed",
"// \"this.parsedRequestOriginTimeInMs\" from",
"// \"Long.parseLong(originTime)\" to current system time,",
"// The reason that we did not remove the field from request",
"// header right now, is because this commit is a quick fix for",
"// internal performance test to be available as soon as",
"// possible.",
"this",
".",
"parsedRequestOriginTimeInMs",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"this",
".",
"parsedRequestOriginTimeInMs",
"<",
"0",
")",
"{",
"RestErrorHandler",
".",
"writeErrorResponse",
"(",
"messageEvent",
",",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Origin time cannot be negative \"",
")",
";",
"}",
"else",
"{",
"result",
"=",
"true",
";",
"}",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"logger",
".",
"error",
"(",
"\"Exception when validating request. Incorrect origin time parameter. Cannot parse this to long: \"",
"+",
"originTime",
",",
"nfe",
")",
";",
"RestErrorHandler",
".",
"writeErrorResponse",
"(",
"this",
".",
"messageEvent",
",",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Incorrect origin time parameter. Cannot parse this to long: \"",
"+",
"originTime",
")",
";",
"}",
"}",
"else",
"{",
"logger",
".",
"error",
"(",
"\"Error when validating request. Missing origin time parameter.\"",
")",
";",
"RestErrorHandler",
".",
"writeErrorResponse",
"(",
"this",
".",
"messageEvent",
",",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing origin time parameter.\"",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieve and validate the timestamp value from the REST request.
"X_VOLD_REQUEST_ORIGIN_TIME_MS" is timestamp header
TODO REST-Server 1. Change Time stamp header to a better name.
@return true if present, false if missing
|
[
"Retrieve",
"and",
"validate",
"the",
"timestamp",
"value",
"from",
"the",
"REST",
"request",
".",
"X_VOLD_REQUEST_ORIGIN_TIME_MS",
"is",
"timestamp",
"header"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestRequestValidator.java#L143-L183
|
161,030 |
voldemort/voldemort
|
src/java/voldemort/rest/RestRequestValidator.java
|
RestRequestValidator.hasVectorClock
|
protected boolean hasVectorClock(boolean isVectorClockOptional) {
boolean result = false;
String vectorClockHeader = this.request.getHeader(RestMessageHeaders.X_VOLD_VECTOR_CLOCK);
if(vectorClockHeader != null) {
ObjectMapper mapper = new ObjectMapper();
try {
VectorClockWrapper vcWrapper = mapper.readValue(vectorClockHeader,
VectorClockWrapper.class);
this.parsedVectorClock = new VectorClock(vcWrapper.getVersions(),
vcWrapper.getTimestamp());
result = true;
} catch(Exception e) {
logger.error("Exception while parsing and constructing vector clock", e);
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Invalid Vector Clock");
}
} else if(!isVectorClockOptional) {
logger.error("Error when validating request. Missing Vector Clock");
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Missing Vector Clock");
} else {
result = true;
}
return result;
}
|
java
|
protected boolean hasVectorClock(boolean isVectorClockOptional) {
boolean result = false;
String vectorClockHeader = this.request.getHeader(RestMessageHeaders.X_VOLD_VECTOR_CLOCK);
if(vectorClockHeader != null) {
ObjectMapper mapper = new ObjectMapper();
try {
VectorClockWrapper vcWrapper = mapper.readValue(vectorClockHeader,
VectorClockWrapper.class);
this.parsedVectorClock = new VectorClock(vcWrapper.getVersions(),
vcWrapper.getTimestamp());
result = true;
} catch(Exception e) {
logger.error("Exception while parsing and constructing vector clock", e);
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Invalid Vector Clock");
}
} else if(!isVectorClockOptional) {
logger.error("Error when validating request. Missing Vector Clock");
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Missing Vector Clock");
} else {
result = true;
}
return result;
}
|
[
"protected",
"boolean",
"hasVectorClock",
"(",
"boolean",
"isVectorClockOptional",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"String",
"vectorClockHeader",
"=",
"this",
".",
"request",
".",
"getHeader",
"(",
"RestMessageHeaders",
".",
"X_VOLD_VECTOR_CLOCK",
")",
";",
"if",
"(",
"vectorClockHeader",
"!=",
"null",
")",
"{",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"try",
"{",
"VectorClockWrapper",
"vcWrapper",
"=",
"mapper",
".",
"readValue",
"(",
"vectorClockHeader",
",",
"VectorClockWrapper",
".",
"class",
")",
";",
"this",
".",
"parsedVectorClock",
"=",
"new",
"VectorClock",
"(",
"vcWrapper",
".",
"getVersions",
"(",
")",
",",
"vcWrapper",
".",
"getTimestamp",
"(",
")",
")",
";",
"result",
"=",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Exception while parsing and constructing vector clock\"",
",",
"e",
")",
";",
"RestErrorHandler",
".",
"writeErrorResponse",
"(",
"this",
".",
"messageEvent",
",",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Invalid Vector Clock\"",
")",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"isVectorClockOptional",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error when validating request. Missing Vector Clock\"",
")",
";",
"RestErrorHandler",
".",
"writeErrorResponse",
"(",
"this",
".",
"messageEvent",
",",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing Vector Clock\"",
")",
";",
"}",
"else",
"{",
"result",
"=",
"true",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieve and validate vector clock value from the REST request.
"X_VOLD_VECTOR_CLOCK" is the vector clock header.
@return true if present, false if missing
|
[
"Retrieve",
"and",
"validate",
"vector",
"clock",
"value",
"from",
"the",
"REST",
"request",
".",
"X_VOLD_VECTOR_CLOCK",
"is",
"the",
"vector",
"clock",
"header",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestRequestValidator.java#L191-L219
|
161,031 |
voldemort/voldemort
|
src/java/voldemort/rest/RestRequestValidator.java
|
RestRequestValidator.hasKey
|
protected boolean hasKey() {
boolean result = false;
String requestURI = this.request.getUri();
parseKeys(requestURI);
if(this.parsedKeys != null) {
result = true;
} else {
logger.error("Error when validating request. No key specified.");
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Error: No key specified !");
}
return result;
}
|
java
|
protected boolean hasKey() {
boolean result = false;
String requestURI = this.request.getUri();
parseKeys(requestURI);
if(this.parsedKeys != null) {
result = true;
} else {
logger.error("Error when validating request. No key specified.");
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Error: No key specified !");
}
return result;
}
|
[
"protected",
"boolean",
"hasKey",
"(",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"String",
"requestURI",
"=",
"this",
".",
"request",
".",
"getUri",
"(",
")",
";",
"parseKeys",
"(",
"requestURI",
")",
";",
"if",
"(",
"this",
".",
"parsedKeys",
"!=",
"null",
")",
"{",
"result",
"=",
"true",
";",
"}",
"else",
"{",
"logger",
".",
"error",
"(",
"\"Error when validating request. No key specified.\"",
")",
";",
"RestErrorHandler",
".",
"writeErrorResponse",
"(",
"this",
".",
"messageEvent",
",",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Error: No key specified !\"",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieve and validate the key from the REST request.
@return true if present, false if missing
|
[
"Retrieve",
"and",
"validate",
"the",
"key",
"from",
"the",
"REST",
"request",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestRequestValidator.java#L226-L240
|
161,032 |
voldemort/voldemort
|
src/java/voldemort/rest/RestRequestValidator.java
|
RestRequestValidator.isStoreValid
|
protected boolean isStoreValid() {
boolean result = false;
String requestURI = this.request.getUri();
this.storeName = parseStoreName(requestURI);
if(storeName != null) {
result = true;
} else {
logger.error("Error when validating request. Missing store name.");
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Missing store name. Critical error.");
}
return result;
}
|
java
|
protected boolean isStoreValid() {
boolean result = false;
String requestURI = this.request.getUri();
this.storeName = parseStoreName(requestURI);
if(storeName != null) {
result = true;
} else {
logger.error("Error when validating request. Missing store name.");
RestErrorHandler.writeErrorResponse(this.messageEvent,
HttpResponseStatus.BAD_REQUEST,
"Missing store name. Critical error.");
}
return result;
}
|
[
"protected",
"boolean",
"isStoreValid",
"(",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"String",
"requestURI",
"=",
"this",
".",
"request",
".",
"getUri",
"(",
")",
";",
"this",
".",
"storeName",
"=",
"parseStoreName",
"(",
"requestURI",
")",
";",
"if",
"(",
"storeName",
"!=",
"null",
")",
"{",
"result",
"=",
"true",
";",
"}",
"else",
"{",
"logger",
".",
"error",
"(",
"\"Error when validating request. Missing store name.\"",
")",
";",
"RestErrorHandler",
".",
"writeErrorResponse",
"(",
"this",
".",
"messageEvent",
",",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing store name. Critical error.\"",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieve and validate store name from the REST request.
@return true if valid, false otherwise
|
[
"Retrieve",
"and",
"validate",
"store",
"name",
"from",
"the",
"REST",
"request",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestRequestValidator.java#L275-L288
|
161,033 |
voldemort/voldemort
|
src/java/voldemort/rest/RestRequestValidator.java
|
RestRequestValidator.debugLog
|
protected void debugLog(String operationType, Long receivedTimeInMs) {
long durationInMs = receivedTimeInMs - (this.parsedRequestOriginTimeInMs);
int numVectorClockEntries = (this.parsedVectorClock == null ? 0
: this.parsedVectorClock.getVersionMap()
.size());
logger.debug("Received a new request. Operation type: " + operationType + " , Key(s): "
+ keysHexString(this.parsedKeys) + " , Store: " + this.storeName
+ " , Origin time (in ms): " + (this.parsedRequestOriginTimeInMs)
+ " , Request received at time(in ms): " + receivedTimeInMs
+ " , Num vector clock entries: " + numVectorClockEntries
+ " , Duration from RESTClient to CoordinatorRestRequestValidator(in ms): "
+ durationInMs);
}
|
java
|
protected void debugLog(String operationType, Long receivedTimeInMs) {
long durationInMs = receivedTimeInMs - (this.parsedRequestOriginTimeInMs);
int numVectorClockEntries = (this.parsedVectorClock == null ? 0
: this.parsedVectorClock.getVersionMap()
.size());
logger.debug("Received a new request. Operation type: " + operationType + " , Key(s): "
+ keysHexString(this.parsedKeys) + " , Store: " + this.storeName
+ " , Origin time (in ms): " + (this.parsedRequestOriginTimeInMs)
+ " , Request received at time(in ms): " + receivedTimeInMs
+ " , Num vector clock entries: " + numVectorClockEntries
+ " , Duration from RESTClient to CoordinatorRestRequestValidator(in ms): "
+ durationInMs);
}
|
[
"protected",
"void",
"debugLog",
"(",
"String",
"operationType",
",",
"Long",
"receivedTimeInMs",
")",
"{",
"long",
"durationInMs",
"=",
"receivedTimeInMs",
"-",
"(",
"this",
".",
"parsedRequestOriginTimeInMs",
")",
";",
"int",
"numVectorClockEntries",
"=",
"(",
"this",
".",
"parsedVectorClock",
"==",
"null",
"?",
"0",
":",
"this",
".",
"parsedVectorClock",
".",
"getVersionMap",
"(",
")",
".",
"size",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Received a new request. Operation type: \"",
"+",
"operationType",
"+",
"\" , Key(s): \"",
"+",
"keysHexString",
"(",
"this",
".",
"parsedKeys",
")",
"+",
"\" , Store: \"",
"+",
"this",
".",
"storeName",
"+",
"\" , Origin time (in ms): \"",
"+",
"(",
"this",
".",
"parsedRequestOriginTimeInMs",
")",
"+",
"\" , Request received at time(in ms): \"",
"+",
"receivedTimeInMs",
"+",
"\" , Num vector clock entries: \"",
"+",
"numVectorClockEntries",
"+",
"\" , Duration from RESTClient to CoordinatorRestRequestValidator(in ms): \"",
"+",
"durationInMs",
")",
";",
"}"
] |
Prints a debug log message that details the time taken for the Http
request to be parsed by the coordinator
@param operationType
@param receivedTimeInMs
|
[
"Prints",
"a",
"debug",
"log",
"message",
"that",
"details",
"the",
"time",
"taken",
"for",
"the",
"Http",
"request",
"to",
"be",
"parsed",
"by",
"the",
"coordinator"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestRequestValidator.java#L321-L334
|
161,034 |
voldemort/voldemort
|
contrib/hadoop-store-builder/src/java/voldemort/store/readonly/fetcher/HdfsFetcher.java
|
HdfsFetcher.fetch
|
@Deprecated
@Override
public File fetch(String source, String dest, long diskQuotaSizeInKB) throws Exception {
return fetchFromSource(source, dest, null, null, -1, diskQuotaSizeInKB, null);
}
|
java
|
@Deprecated
@Override
public File fetch(String source, String dest, long diskQuotaSizeInKB) throws Exception {
return fetchFromSource(source, dest, null, null, -1, diskQuotaSizeInKB, null);
}
|
[
"@",
"Deprecated",
"@",
"Override",
"public",
"File",
"fetch",
"(",
"String",
"source",
",",
"String",
"dest",
",",
"long",
"diskQuotaSizeInKB",
")",
"throws",
"Exception",
"{",
"return",
"fetchFromSource",
"(",
"source",
",",
"dest",
",",
"null",
",",
"null",
",",
"-",
"1",
",",
"diskQuotaSizeInKB",
",",
"null",
")",
";",
"}"
] |
Used for unit tests only.
FIXME: Refactor test code with dependency injection or scope restrictions so this function is not public.
@deprecated Do not use for production code, use {@link #fetch(String, String, voldemort.server.protocol.admin.AsyncOperationStatus, String, long, voldemort.store.metadata.MetadataStore, Long diskQuotaSizeInKB)} instead.
|
[
"Used",
"for",
"unit",
"tests",
"only",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/contrib/hadoop-store-builder/src/java/voldemort/store/readonly/fetcher/HdfsFetcher.java#L178-L182
|
161,035 |
voldemort/voldemort
|
contrib/hadoop-store-builder/src/java/voldemort/store/readonly/fetcher/HdfsFetcher.java
|
HdfsFetcher.main
|
public static void main(String[] args) throws Exception {
if(args.length < 1)
Utils.croak("USAGE: java " + HdfsFetcher.class.getName()
+ " url [keytab-location kerberos-username hadoop-config-path [destDir]]");
String url = args[0];
VoldemortConfig config = new VoldemortConfig(-1, "");
HdfsFetcher fetcher = new HdfsFetcher(config);
String destDir = null;
Long diskQuotaSizeInKB;
if(args.length >= 4) {
fetcher.voldemortConfig.setReadOnlyKeytabPath(args[1]);
fetcher.voldemortConfig.setReadOnlyKerberosUser(args[2]);
fetcher.voldemortConfig.setHadoopConfigPath(args[3]);
}
if(args.length >= 5)
destDir = args[4];
if(args.length >= 6)
diskQuotaSizeInKB = Long.parseLong(args[5]);
else
diskQuotaSizeInKB = null;
// for testing we want to be able to download a single file
allowFetchingOfSingleFile = true;
FileSystem fs = HadoopUtils.getHadoopFileSystem(fetcher.voldemortConfig, url);
Path p = new Path(url);
FileStatus status = fs.listStatus(p)[0];
long size = status.getLen();
long start = System.currentTimeMillis();
if(destDir == null)
destDir = System.getProperty("java.io.tmpdir") + File.separator + start;
File location = fetcher.fetch(url, destDir, null, null, -1, null, diskQuotaSizeInKB);
double rate = size * Time.MS_PER_SECOND / (double) (System.currentTimeMillis() - start);
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(2);
System.out.println("Fetch to " + location + " completed: "
+ nf.format(rate / (1024.0 * 1024.0)) + " MB/sec.");
fs.close();
}
|
java
|
public static void main(String[] args) throws Exception {
if(args.length < 1)
Utils.croak("USAGE: java " + HdfsFetcher.class.getName()
+ " url [keytab-location kerberos-username hadoop-config-path [destDir]]");
String url = args[0];
VoldemortConfig config = new VoldemortConfig(-1, "");
HdfsFetcher fetcher = new HdfsFetcher(config);
String destDir = null;
Long diskQuotaSizeInKB;
if(args.length >= 4) {
fetcher.voldemortConfig.setReadOnlyKeytabPath(args[1]);
fetcher.voldemortConfig.setReadOnlyKerberosUser(args[2]);
fetcher.voldemortConfig.setHadoopConfigPath(args[3]);
}
if(args.length >= 5)
destDir = args[4];
if(args.length >= 6)
diskQuotaSizeInKB = Long.parseLong(args[5]);
else
diskQuotaSizeInKB = null;
// for testing we want to be able to download a single file
allowFetchingOfSingleFile = true;
FileSystem fs = HadoopUtils.getHadoopFileSystem(fetcher.voldemortConfig, url);
Path p = new Path(url);
FileStatus status = fs.listStatus(p)[0];
long size = status.getLen();
long start = System.currentTimeMillis();
if(destDir == null)
destDir = System.getProperty("java.io.tmpdir") + File.separator + start;
File location = fetcher.fetch(url, destDir, null, null, -1, null, diskQuotaSizeInKB);
double rate = size * Time.MS_PER_SECOND / (double) (System.currentTimeMillis() - start);
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(2);
System.out.println("Fetch to " + location + " completed: "
+ nf.format(rate / (1024.0 * 1024.0)) + " MB/sec.");
fs.close();
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"if",
"(",
"args",
".",
"length",
"<",
"1",
")",
"Utils",
".",
"croak",
"(",
"\"USAGE: java \"",
"+",
"HdfsFetcher",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\" url [keytab-location kerberos-username hadoop-config-path [destDir]]\"",
")",
";",
"String",
"url",
"=",
"args",
"[",
"0",
"]",
";",
"VoldemortConfig",
"config",
"=",
"new",
"VoldemortConfig",
"(",
"-",
"1",
",",
"\"\"",
")",
";",
"HdfsFetcher",
"fetcher",
"=",
"new",
"HdfsFetcher",
"(",
"config",
")",
";",
"String",
"destDir",
"=",
"null",
";",
"Long",
"diskQuotaSizeInKB",
";",
"if",
"(",
"args",
".",
"length",
">=",
"4",
")",
"{",
"fetcher",
".",
"voldemortConfig",
".",
"setReadOnlyKeytabPath",
"(",
"args",
"[",
"1",
"]",
")",
";",
"fetcher",
".",
"voldemortConfig",
".",
"setReadOnlyKerberosUser",
"(",
"args",
"[",
"2",
"]",
")",
";",
"fetcher",
".",
"voldemortConfig",
".",
"setHadoopConfigPath",
"(",
"args",
"[",
"3",
"]",
")",
";",
"}",
"if",
"(",
"args",
".",
"length",
">=",
"5",
")",
"destDir",
"=",
"args",
"[",
"4",
"]",
";",
"if",
"(",
"args",
".",
"length",
">=",
"6",
")",
"diskQuotaSizeInKB",
"=",
"Long",
".",
"parseLong",
"(",
"args",
"[",
"5",
"]",
")",
";",
"else",
"diskQuotaSizeInKB",
"=",
"null",
";",
"// for testing we want to be able to download a single file",
"allowFetchingOfSingleFile",
"=",
"true",
";",
"FileSystem",
"fs",
"=",
"HadoopUtils",
".",
"getHadoopFileSystem",
"(",
"fetcher",
".",
"voldemortConfig",
",",
"url",
")",
";",
"Path",
"p",
"=",
"new",
"Path",
"(",
"url",
")",
";",
"FileStatus",
"status",
"=",
"fs",
".",
"listStatus",
"(",
"p",
")",
"[",
"0",
"]",
";",
"long",
"size",
"=",
"status",
".",
"getLen",
"(",
")",
";",
"long",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"destDir",
"==",
"null",
")",
"destDir",
"=",
"System",
".",
"getProperty",
"(",
"\"java.io.tmpdir\"",
")",
"+",
"File",
".",
"separator",
"+",
"start",
";",
"File",
"location",
"=",
"fetcher",
".",
"fetch",
"(",
"url",
",",
"destDir",
",",
"null",
",",
"null",
",",
"-",
"1",
",",
"null",
",",
"diskQuotaSizeInKB",
")",
";",
"double",
"rate",
"=",
"size",
"*",
"Time",
".",
"MS_PER_SECOND",
"/",
"(",
"double",
")",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
")",
";",
"NumberFormat",
"nf",
"=",
"NumberFormat",
".",
"getInstance",
"(",
")",
";",
"nf",
".",
"setMaximumFractionDigits",
"(",
"2",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Fetch to \"",
"+",
"location",
"+",
"\" completed: \"",
"+",
"nf",
".",
"format",
"(",
"rate",
"/",
"(",
"1024.0",
"*",
"1024.0",
")",
")",
"+",
"\" MB/sec.\"",
")",
";",
"fs",
".",
"close",
"(",
")",
";",
"}"
] |
Main method for testing fetching
|
[
"Main",
"method",
"for",
"testing",
"fetching"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/contrib/hadoop-store-builder/src/java/voldemort/store/readonly/fetcher/HdfsFetcher.java#L487-L532
|
161,036 |
voldemort/voldemort
|
src/java/voldemort/client/rebalance/RebalanceTaskInfo.java
|
RebalanceTaskInfo.getPartitionStoreMoves
|
public synchronized int getPartitionStoreMoves() {
int count = 0;
for (List<Integer> entry : storeToPartitionIds.values())
count += entry.size();
return count;
}
|
java
|
public synchronized int getPartitionStoreMoves() {
int count = 0;
for (List<Integer> entry : storeToPartitionIds.values())
count += entry.size();
return count;
}
|
[
"public",
"synchronized",
"int",
"getPartitionStoreMoves",
"(",
")",
"{",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"List",
"<",
"Integer",
">",
"entry",
":",
"storeToPartitionIds",
".",
"values",
"(",
")",
")",
"count",
"+=",
"entry",
".",
"size",
"(",
")",
";",
"return",
"count",
";",
"}"
] |
Total count of partition-stores moved in this task.
@return number of partition stores moved in this task.
|
[
"Total",
"count",
"of",
"partition",
"-",
"stores",
"moved",
"in",
"this",
"task",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/client/rebalance/RebalanceTaskInfo.java#L156-L161
|
161,037 |
voldemort/voldemort
|
src/java/voldemort/client/rebalance/RebalanceTaskInfo.java
|
RebalanceTaskInfo.getPartitionStoreCount
|
public synchronized int getPartitionStoreCount() {
int count = 0;
for (String store : storeToPartitionIds.keySet()) {
count += storeToPartitionIds.get(store).size();
}
return count;
}
|
java
|
public synchronized int getPartitionStoreCount() {
int count = 0;
for (String store : storeToPartitionIds.keySet()) {
count += storeToPartitionIds.get(store).size();
}
return count;
}
|
[
"public",
"synchronized",
"int",
"getPartitionStoreCount",
"(",
")",
"{",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"String",
"store",
":",
"storeToPartitionIds",
".",
"keySet",
"(",
")",
")",
"{",
"count",
"+=",
"storeToPartitionIds",
".",
"get",
"(",
"store",
")",
".",
"size",
"(",
")",
";",
"}",
"return",
"count",
";",
"}"
] |
Returns the total count of partitions across all stores.
@return returns the total count of partitions across all stores.
|
[
"Returns",
"the",
"total",
"count",
"of",
"partitions",
"across",
"all",
"stores",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/client/rebalance/RebalanceTaskInfo.java#L196-L202
|
161,038 |
voldemort/voldemort
|
src/java/voldemort/client/rebalance/RebalanceTaskInfo.java
|
RebalanceTaskInfo.taskListToString
|
public static String taskListToString(List<RebalanceTaskInfo> infos) {
StringBuffer sb = new StringBuffer();
for (RebalanceTaskInfo info : infos) {
sb.append("\t").append(info.getDonorId()).append(" -> ").append(info.getStealerId()).append(" : [");
for (String storeName : info.getPartitionStores()) {
sb.append("{").append(storeName).append(" : ").append(info.getPartitionIds(storeName)).append("}");
}
sb.append("]").append(Utils.NEWLINE);
}
return sb.toString();
}
|
java
|
public static String taskListToString(List<RebalanceTaskInfo> infos) {
StringBuffer sb = new StringBuffer();
for (RebalanceTaskInfo info : infos) {
sb.append("\t").append(info.getDonorId()).append(" -> ").append(info.getStealerId()).append(" : [");
for (String storeName : info.getPartitionStores()) {
sb.append("{").append(storeName).append(" : ").append(info.getPartitionIds(storeName)).append("}");
}
sb.append("]").append(Utils.NEWLINE);
}
return sb.toString();
}
|
[
"public",
"static",
"String",
"taskListToString",
"(",
"List",
"<",
"RebalanceTaskInfo",
">",
"infos",
")",
"{",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"RebalanceTaskInfo",
"info",
":",
"infos",
")",
"{",
"sb",
".",
"append",
"(",
"\"\\t\"",
")",
".",
"append",
"(",
"info",
".",
"getDonorId",
"(",
")",
")",
".",
"append",
"(",
"\" -> \"",
")",
".",
"append",
"(",
"info",
".",
"getStealerId",
"(",
")",
")",
".",
"append",
"(",
"\" : [\"",
")",
";",
"for",
"(",
"String",
"storeName",
":",
"info",
".",
"getPartitionStores",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"{\"",
")",
".",
"append",
"(",
"storeName",
")",
".",
"append",
"(",
"\" : \"",
")",
".",
"append",
"(",
"info",
".",
"getPartitionIds",
"(",
"storeName",
")",
")",
".",
"append",
"(",
"\"}\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"]\"",
")",
".",
"append",
"(",
"Utils",
".",
"NEWLINE",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Pretty prints a task list of rebalancing tasks.
@param infos list of rebalancing tasks (RebalancePartitionsInfo)
@return pretty-printed string
|
[
"Pretty",
"prints",
"a",
"task",
"list",
"of",
"rebalancing",
"tasks",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/client/rebalance/RebalanceTaskInfo.java#L231-L241
|
161,039 |
voldemort/voldemort
|
contrib/hadoop-store-builder/src/java/voldemort/store/readonly/mr/AvroStoreBuilderMapper.java
|
AvroStoreBuilderMapper.map
|
@Override
public void map(GenericData.Record record,
AvroCollector<Pair<ByteBuffer, ByteBuffer>> collector,
Reporter reporter) throws IOException {
byte[] keyBytes = null;
byte[] valBytes = null;
Object keyRecord = null;
Object valRecord = null;
try {
keyRecord = record.get(keyField);
valRecord = record.get(valField);
keyBytes = keySerializer.toBytes(keyRecord);
valBytes = valueSerializer.toBytes(valRecord);
this.collectorWrapper.setCollector(collector);
this.mapper.map(keyBytes, valBytes, this.collectorWrapper);
recordCounter++;
} catch (OutOfMemoryError oom) {
logger.error(oomErrorMessage(reporter));
if (keyBytes == null) {
logger.error("keyRecord caused OOM!");
} else {
logger.error("keyRecord: " + keyRecord);
logger.error("valRecord: " + (valBytes == null ? "caused OOM" : valRecord));
}
throw new VoldemortException(oomErrorMessage(reporter), oom);
}
}
|
java
|
@Override
public void map(GenericData.Record record,
AvroCollector<Pair<ByteBuffer, ByteBuffer>> collector,
Reporter reporter) throws IOException {
byte[] keyBytes = null;
byte[] valBytes = null;
Object keyRecord = null;
Object valRecord = null;
try {
keyRecord = record.get(keyField);
valRecord = record.get(valField);
keyBytes = keySerializer.toBytes(keyRecord);
valBytes = valueSerializer.toBytes(valRecord);
this.collectorWrapper.setCollector(collector);
this.mapper.map(keyBytes, valBytes, this.collectorWrapper);
recordCounter++;
} catch (OutOfMemoryError oom) {
logger.error(oomErrorMessage(reporter));
if (keyBytes == null) {
logger.error("keyRecord caused OOM!");
} else {
logger.error("keyRecord: " + keyRecord);
logger.error("valRecord: " + (valBytes == null ? "caused OOM" : valRecord));
}
throw new VoldemortException(oomErrorMessage(reporter), oom);
}
}
|
[
"@",
"Override",
"public",
"void",
"map",
"(",
"GenericData",
".",
"Record",
"record",
",",
"AvroCollector",
"<",
"Pair",
"<",
"ByteBuffer",
",",
"ByteBuffer",
">",
">",
"collector",
",",
"Reporter",
"reporter",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"keyBytes",
"=",
"null",
";",
"byte",
"[",
"]",
"valBytes",
"=",
"null",
";",
"Object",
"keyRecord",
"=",
"null",
";",
"Object",
"valRecord",
"=",
"null",
";",
"try",
"{",
"keyRecord",
"=",
"record",
".",
"get",
"(",
"keyField",
")",
";",
"valRecord",
"=",
"record",
".",
"get",
"(",
"valField",
")",
";",
"keyBytes",
"=",
"keySerializer",
".",
"toBytes",
"(",
"keyRecord",
")",
";",
"valBytes",
"=",
"valueSerializer",
".",
"toBytes",
"(",
"valRecord",
")",
";",
"this",
".",
"collectorWrapper",
".",
"setCollector",
"(",
"collector",
")",
";",
"this",
".",
"mapper",
".",
"map",
"(",
"keyBytes",
",",
"valBytes",
",",
"this",
".",
"collectorWrapper",
")",
";",
"recordCounter",
"++",
";",
"}",
"catch",
"(",
"OutOfMemoryError",
"oom",
")",
"{",
"logger",
".",
"error",
"(",
"oomErrorMessage",
"(",
"reporter",
")",
")",
";",
"if",
"(",
"keyBytes",
"==",
"null",
")",
"{",
"logger",
".",
"error",
"(",
"\"keyRecord caused OOM!\"",
")",
";",
"}",
"else",
"{",
"logger",
".",
"error",
"(",
"\"keyRecord: \"",
"+",
"keyRecord",
")",
";",
"logger",
".",
"error",
"(",
"\"valRecord: \"",
"+",
"(",
"valBytes",
"==",
"null",
"?",
"\"caused OOM\"",
":",
"valRecord",
")",
")",
";",
"}",
"throw",
"new",
"VoldemortException",
"(",
"oomErrorMessage",
"(",
"reporter",
")",
",",
"oom",
")",
";",
"}",
"}"
] |
Create the voldemort key and value from the input Avro record by
extracting the key and value and map it out for each of the responsible
voldemort nodes
The output value is the node_id & partition_id of the responsible node
followed by serialized value
|
[
"Create",
"the",
"voldemort",
"key",
"and",
"value",
"from",
"the",
"input",
"Avro",
"record",
"by",
"extracting",
"the",
"key",
"and",
"value",
"and",
"map",
"it",
"out",
"for",
"each",
"of",
"the",
"responsible",
"voldemort",
"nodes"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/contrib/hadoop-store-builder/src/java/voldemort/store/readonly/mr/AvroStoreBuilderMapper.java#L113-L142
|
161,040 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/io/jna/mman.java
|
mman.mmap
|
public static Pointer mmap(long len, int prot, int flags, int fildes, long off)
throws IOException {
// we don't really have a need to change the recommended pointer.
Pointer addr = new Pointer(0);
Pointer result = Delegate.mmap(addr,
new NativeLong(len),
prot,
flags,
fildes,
new NativeLong(off));
if(Pointer.nativeValue(result) == -1) {
if(logger.isDebugEnabled())
logger.debug(errno.strerror());
throw new IOException("mmap failed: " + errno.strerror());
}
return result;
}
|
java
|
public static Pointer mmap(long len, int prot, int flags, int fildes, long off)
throws IOException {
// we don't really have a need to change the recommended pointer.
Pointer addr = new Pointer(0);
Pointer result = Delegate.mmap(addr,
new NativeLong(len),
prot,
flags,
fildes,
new NativeLong(off));
if(Pointer.nativeValue(result) == -1) {
if(logger.isDebugEnabled())
logger.debug(errno.strerror());
throw new IOException("mmap failed: " + errno.strerror());
}
return result;
}
|
[
"public",
"static",
"Pointer",
"mmap",
"(",
"long",
"len",
",",
"int",
"prot",
",",
"int",
"flags",
",",
"int",
"fildes",
",",
"long",
"off",
")",
"throws",
"IOException",
"{",
"// we don't really have a need to change the recommended pointer.",
"Pointer",
"addr",
"=",
"new",
"Pointer",
"(",
"0",
")",
";",
"Pointer",
"result",
"=",
"Delegate",
".",
"mmap",
"(",
"addr",
",",
"new",
"NativeLong",
"(",
"len",
")",
",",
"prot",
",",
"flags",
",",
"fildes",
",",
"new",
"NativeLong",
"(",
"off",
")",
")",
";",
"if",
"(",
"Pointer",
".",
"nativeValue",
"(",
"result",
")",
"==",
"-",
"1",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"errno",
".",
"strerror",
"(",
")",
")",
";",
"throw",
"new",
"IOException",
"(",
"\"mmap failed: \"",
"+",
"errno",
".",
"strerror",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Map the given region of the given file descriptor into memory.
Returns a Pointer to the newly mapped memory throws an
IOException on error.
|
[
"Map",
"the",
"given",
"region",
"of",
"the",
"given",
"file",
"descriptor",
"into",
"memory",
".",
"Returns",
"a",
"Pointer",
"to",
"the",
"newly",
"mapped",
"memory",
"throws",
"an",
"IOException",
"on",
"error",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/io/jna/mman.java#L36-L57
|
161,041 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/io/jna/mman.java
|
mman.mlock
|
public static void mlock(Pointer addr, long len) {
int res = Delegate.mlock(addr, new NativeLong(len));
if(res != 0) {
if(logger.isDebugEnabled()) {
logger.debug("Mlock failed probably because of insufficient privileges, errno:"
+ errno.strerror() + ", return value:" + res);
}
} else {
if(logger.isDebugEnabled())
logger.debug("Mlock successfull");
}
}
|
java
|
public static void mlock(Pointer addr, long len) {
int res = Delegate.mlock(addr, new NativeLong(len));
if(res != 0) {
if(logger.isDebugEnabled()) {
logger.debug("Mlock failed probably because of insufficient privileges, errno:"
+ errno.strerror() + ", return value:" + res);
}
} else {
if(logger.isDebugEnabled())
logger.debug("Mlock successfull");
}
}
|
[
"public",
"static",
"void",
"mlock",
"(",
"Pointer",
"addr",
",",
"long",
"len",
")",
"{",
"int",
"res",
"=",
"Delegate",
".",
"mlock",
"(",
"addr",
",",
"new",
"NativeLong",
"(",
"len",
")",
")",
";",
"if",
"(",
"res",
"!=",
"0",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Mlock failed probably because of insufficient privileges, errno:\"",
"+",
"errno",
".",
"strerror",
"(",
")",
"+",
"\", return value:\"",
"+",
"res",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"Mlock successfull\"",
")",
";",
"}",
"}"
] |
Lock the given region. Does not report failures.
|
[
"Lock",
"the",
"given",
"region",
".",
"Does",
"not",
"report",
"failures",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/io/jna/mman.java#L80-L94
|
161,042 |
voldemort/voldemort
|
src/java/voldemort/store/readonly/io/jna/mman.java
|
mman.munlock
|
public static void munlock(Pointer addr, long len) {
if(Delegate.munlock(addr, new NativeLong(len)) != 0) {
if(logger.isDebugEnabled())
logger.debug("munlocking failed with errno:" + errno.strerror());
} else {
if(logger.isDebugEnabled())
logger.debug("munlocking region");
}
}
|
java
|
public static void munlock(Pointer addr, long len) {
if(Delegate.munlock(addr, new NativeLong(len)) != 0) {
if(logger.isDebugEnabled())
logger.debug("munlocking failed with errno:" + errno.strerror());
} else {
if(logger.isDebugEnabled())
logger.debug("munlocking region");
}
}
|
[
"public",
"static",
"void",
"munlock",
"(",
"Pointer",
"addr",
",",
"long",
"len",
")",
"{",
"if",
"(",
"Delegate",
".",
"munlock",
"(",
"addr",
",",
"new",
"NativeLong",
"(",
"len",
")",
")",
"!=",
"0",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"munlocking failed with errno:\"",
"+",
"errno",
".",
"strerror",
"(",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"munlocking region\"",
")",
";",
"}",
"}"
] |
Unlock the given region. Does not report failures.
|
[
"Unlock",
"the",
"given",
"region",
".",
"Does",
"not",
"report",
"failures",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/io/jna/mman.java#L99-L108
|
161,043 |
voldemort/voldemort
|
src/java/voldemort/serialization/json/JsonTypeDefinition.java
|
JsonTypeDefinition.projectionType
|
public JsonTypeDefinition projectionType(String... properties) {
if(this.getType() instanceof Map<?, ?>) {
Map<?, ?> type = (Map<?, ?>) getType();
Arrays.sort(properties);
Map<String, Object> newType = new LinkedHashMap<String, Object>();
for(String prop: properties)
newType.put(prop, type.get(prop));
return new JsonTypeDefinition(newType);
} else {
throw new IllegalArgumentException("Cannot take the projection of a type that is not a Map.");
}
}
|
java
|
public JsonTypeDefinition projectionType(String... properties) {
if(this.getType() instanceof Map<?, ?>) {
Map<?, ?> type = (Map<?, ?>) getType();
Arrays.sort(properties);
Map<String, Object> newType = new LinkedHashMap<String, Object>();
for(String prop: properties)
newType.put(prop, type.get(prop));
return new JsonTypeDefinition(newType);
} else {
throw new IllegalArgumentException("Cannot take the projection of a type that is not a Map.");
}
}
|
[
"public",
"JsonTypeDefinition",
"projectionType",
"(",
"String",
"...",
"properties",
")",
"{",
"if",
"(",
"this",
".",
"getType",
"(",
")",
"instanceof",
"Map",
"<",
"?",
",",
"?",
">",
")",
"{",
"Map",
"<",
"?",
",",
"?",
">",
"type",
"=",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"getType",
"(",
")",
";",
"Arrays",
".",
"sort",
"(",
"properties",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"newType",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"for",
"(",
"String",
"prop",
":",
"properties",
")",
"newType",
".",
"put",
"(",
"prop",
",",
"type",
".",
"get",
"(",
"prop",
")",
")",
";",
"return",
"new",
"JsonTypeDefinition",
"(",
"newType",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot take the projection of a type that is not a Map.\"",
")",
";",
"}",
"}"
] |
Get the type created by selecting only a subset of properties from this
type. The type must be a map for this to work
@param properties The properties to select
@return The new type definition
|
[
"Get",
"the",
"type",
"created",
"by",
"selecting",
"only",
"a",
"subset",
"of",
"properties",
"from",
"this",
"type",
".",
"The",
"type",
"must",
"be",
"a",
"map",
"for",
"this",
"to",
"work"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/serialization/json/JsonTypeDefinition.java#L96-L107
|
161,044 |
voldemort/voldemort
|
src/java/voldemort/server/protocol/admin/BufferedUpdatePartitionEntriesStreamRequestHandler.java
|
BufferedUpdatePartitionEntriesStreamRequestHandler.writeBufferedValsToStorage
|
private void writeBufferedValsToStorage() {
List<Versioned<byte[]>> obsoleteVals = storageEngine.multiVersionPut(currBufferedKey,
currBufferedVals);
// log Obsolete versions in debug mode
if(logger.isDebugEnabled() && obsoleteVals.size() > 0) {
logger.debug("updateEntries (Streaming multi-version-put) rejected these versions as obsolete : "
+ StoreUtils.getVersions(obsoleteVals) + " for key " + currBufferedKey);
}
currBufferedVals = new ArrayList<Versioned<byte[]>>(VALS_BUFFER_EXPECTED_SIZE);
}
|
java
|
private void writeBufferedValsToStorage() {
List<Versioned<byte[]>> obsoleteVals = storageEngine.multiVersionPut(currBufferedKey,
currBufferedVals);
// log Obsolete versions in debug mode
if(logger.isDebugEnabled() && obsoleteVals.size() > 0) {
logger.debug("updateEntries (Streaming multi-version-put) rejected these versions as obsolete : "
+ StoreUtils.getVersions(obsoleteVals) + " for key " + currBufferedKey);
}
currBufferedVals = new ArrayList<Versioned<byte[]>>(VALS_BUFFER_EXPECTED_SIZE);
}
|
[
"private",
"void",
"writeBufferedValsToStorage",
"(",
")",
"{",
"List",
"<",
"Versioned",
"<",
"byte",
"[",
"]",
">",
">",
"obsoleteVals",
"=",
"storageEngine",
".",
"multiVersionPut",
"(",
"currBufferedKey",
",",
"currBufferedVals",
")",
";",
"// log Obsolete versions in debug mode",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
"&&",
"obsoleteVals",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"logger",
".",
"debug",
"(",
"\"updateEntries (Streaming multi-version-put) rejected these versions as obsolete : \"",
"+",
"StoreUtils",
".",
"getVersions",
"(",
"obsoleteVals",
")",
"+",
"\" for key \"",
"+",
"currBufferedKey",
")",
";",
"}",
"currBufferedVals",
"=",
"new",
"ArrayList",
"<",
"Versioned",
"<",
"byte",
"[",
"]",
">",
">",
"(",
"VALS_BUFFER_EXPECTED_SIZE",
")",
";",
"}"
] |
Persists the current set of versions buffered for the current key into
storage, using the multiVersionPut api
NOTE: Now, it could be that the stream broke off and has more pending
versions. For now, we simply commit what we have to disk. A better design
would rely on in-stream markers to do the flushing to storage.
|
[
"Persists",
"the",
"current",
"set",
"of",
"versions",
"buffered",
"for",
"the",
"current",
"key",
"into",
"storage",
"using",
"the",
"multiVersionPut",
"api"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/protocol/admin/BufferedUpdatePartitionEntriesStreamRequestHandler.java#L66-L75
|
161,045 |
voldemort/voldemort
|
src/java/voldemort/server/rebalance/Rebalancer.java
|
Rebalancer.acquireRebalancingPermit
|
public synchronized boolean acquireRebalancingPermit(int nodeId) {
boolean added = rebalancePermits.add(nodeId);
logger.info("Acquiring rebalancing permit for node id " + nodeId + ", returned: " + added);
return added;
}
|
java
|
public synchronized boolean acquireRebalancingPermit(int nodeId) {
boolean added = rebalancePermits.add(nodeId);
logger.info("Acquiring rebalancing permit for node id " + nodeId + ", returned: " + added);
return added;
}
|
[
"public",
"synchronized",
"boolean",
"acquireRebalancingPermit",
"(",
"int",
"nodeId",
")",
"{",
"boolean",
"added",
"=",
"rebalancePermits",
".",
"add",
"(",
"nodeId",
")",
";",
"logger",
".",
"info",
"(",
"\"Acquiring rebalancing permit for node id \"",
"+",
"nodeId",
"+",
"\", returned: \"",
"+",
"added",
")",
";",
"return",
"added",
";",
"}"
] |
Acquire a permit for a particular node id so as to allow rebalancing
@param nodeId The id of the node for which we are acquiring a permit
@return Returns true if permit acquired, false if the permit is already
held by someone
|
[
"Acquire",
"a",
"permit",
"for",
"a",
"particular",
"node",
"id",
"so",
"as",
"to",
"allow",
"rebalancing"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/rebalance/Rebalancer.java#L91-L96
|
161,046 |
voldemort/voldemort
|
src/java/voldemort/server/rebalance/Rebalancer.java
|
Rebalancer.releaseRebalancingPermit
|
public synchronized void releaseRebalancingPermit(int nodeId) {
boolean removed = rebalancePermits.remove(nodeId);
logger.info("Releasing rebalancing permit for node id " + nodeId + ", returned: " + removed);
if(!removed)
throw new VoldemortException(new IllegalStateException("Invalid state, must hold a "
+ "permit to release"));
}
|
java
|
public synchronized void releaseRebalancingPermit(int nodeId) {
boolean removed = rebalancePermits.remove(nodeId);
logger.info("Releasing rebalancing permit for node id " + nodeId + ", returned: " + removed);
if(!removed)
throw new VoldemortException(new IllegalStateException("Invalid state, must hold a "
+ "permit to release"));
}
|
[
"public",
"synchronized",
"void",
"releaseRebalancingPermit",
"(",
"int",
"nodeId",
")",
"{",
"boolean",
"removed",
"=",
"rebalancePermits",
".",
"remove",
"(",
"nodeId",
")",
";",
"logger",
".",
"info",
"(",
"\"Releasing rebalancing permit for node id \"",
"+",
"nodeId",
"+",
"\", returned: \"",
"+",
"removed",
")",
";",
"if",
"(",
"!",
"removed",
")",
"throw",
"new",
"VoldemortException",
"(",
"new",
"IllegalStateException",
"(",
"\"Invalid state, must hold a \"",
"+",
"\"permit to release\"",
")",
")",
";",
"}"
] |
Release the rebalancing permit for a particular node id
@param nodeId The node id whose permit we want to release
|
[
"Release",
"the",
"rebalancing",
"permit",
"for",
"a",
"particular",
"node",
"id"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/rebalance/Rebalancer.java#L103-L109
|
161,047 |
voldemort/voldemort
|
src/java/voldemort/server/rebalance/Rebalancer.java
|
Rebalancer.swapROStores
|
private void swapROStores(List<String> swappedStoreNames, boolean useSwappedStoreNames) {
try {
for(StoreDefinition storeDef: metadataStore.getStoreDefList()) {
// Only pick up the RO stores
if(storeDef.getType().compareTo(ReadOnlyStorageConfiguration.TYPE_NAME) == 0) {
if(useSwappedStoreNames && !swappedStoreNames.contains(storeDef.getName())) {
continue;
}
ReadOnlyStorageEngine engine = (ReadOnlyStorageEngine) storeRepository.getStorageEngine(storeDef.getName());
if(engine == null) {
throw new VoldemortException("Could not find storage engine for "
+ storeDef.getName() + " to swap ");
}
logger.info("Swapping RO store " + storeDef.getName());
// Time to swap this store - Could have used admin client,
// but why incur the overhead?
engine.swapFiles(engine.getCurrentDirPath());
// Add to list of stores already swapped
if(!useSwappedStoreNames)
swappedStoreNames.add(storeDef.getName());
}
}
} catch(Exception e) {
logger.error("Error while swapping RO store");
throw new VoldemortException(e);
}
}
|
java
|
private void swapROStores(List<String> swappedStoreNames, boolean useSwappedStoreNames) {
try {
for(StoreDefinition storeDef: metadataStore.getStoreDefList()) {
// Only pick up the RO stores
if(storeDef.getType().compareTo(ReadOnlyStorageConfiguration.TYPE_NAME) == 0) {
if(useSwappedStoreNames && !swappedStoreNames.contains(storeDef.getName())) {
continue;
}
ReadOnlyStorageEngine engine = (ReadOnlyStorageEngine) storeRepository.getStorageEngine(storeDef.getName());
if(engine == null) {
throw new VoldemortException("Could not find storage engine for "
+ storeDef.getName() + " to swap ");
}
logger.info("Swapping RO store " + storeDef.getName());
// Time to swap this store - Could have used admin client,
// but why incur the overhead?
engine.swapFiles(engine.getCurrentDirPath());
// Add to list of stores already swapped
if(!useSwappedStoreNames)
swappedStoreNames.add(storeDef.getName());
}
}
} catch(Exception e) {
logger.error("Error while swapping RO store");
throw new VoldemortException(e);
}
}
|
[
"private",
"void",
"swapROStores",
"(",
"List",
"<",
"String",
">",
"swappedStoreNames",
",",
"boolean",
"useSwappedStoreNames",
")",
"{",
"try",
"{",
"for",
"(",
"StoreDefinition",
"storeDef",
":",
"metadataStore",
".",
"getStoreDefList",
"(",
")",
")",
"{",
"// Only pick up the RO stores",
"if",
"(",
"storeDef",
".",
"getType",
"(",
")",
".",
"compareTo",
"(",
"ReadOnlyStorageConfiguration",
".",
"TYPE_NAME",
")",
"==",
"0",
")",
"{",
"if",
"(",
"useSwappedStoreNames",
"&&",
"!",
"swappedStoreNames",
".",
"contains",
"(",
"storeDef",
".",
"getName",
"(",
")",
")",
")",
"{",
"continue",
";",
"}",
"ReadOnlyStorageEngine",
"engine",
"=",
"(",
"ReadOnlyStorageEngine",
")",
"storeRepository",
".",
"getStorageEngine",
"(",
"storeDef",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"engine",
"==",
"null",
")",
"{",
"throw",
"new",
"VoldemortException",
"(",
"\"Could not find storage engine for \"",
"+",
"storeDef",
".",
"getName",
"(",
")",
"+",
"\" to swap \"",
")",
";",
"}",
"logger",
".",
"info",
"(",
"\"Swapping RO store \"",
"+",
"storeDef",
".",
"getName",
"(",
")",
")",
";",
"// Time to swap this store - Could have used admin client,",
"// but why incur the overhead?",
"engine",
".",
"swapFiles",
"(",
"engine",
".",
"getCurrentDirPath",
"(",
")",
")",
";",
"// Add to list of stores already swapped",
"if",
"(",
"!",
"useSwappedStoreNames",
")",
"swappedStoreNames",
".",
"add",
"(",
"storeDef",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error while swapping RO store\"",
")",
";",
"throw",
"new",
"VoldemortException",
"(",
"e",
")",
";",
"}",
"}"
] |
Goes through all the RO Stores in the plan and swaps it
@param swappedStoreNames Names of stores already swapped
@param useSwappedStoreNames Swap only the previously swapped stores (
Happens during error )
|
[
"Goes",
"through",
"all",
"the",
"RO",
"Stores",
"in",
"the",
"plan",
"and",
"swaps",
"it"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/rebalance/Rebalancer.java#L336-L370
|
161,048 |
voldemort/voldemort
|
src/java/voldemort/server/rebalance/Rebalancer.java
|
Rebalancer.changeClusterAndStores
|
private void changeClusterAndStores(String clusterKey,
final Cluster cluster,
String storesKey,
final List<StoreDefinition> storeDefs) {
metadataStore.writeLock.lock();
try {
VectorClock updatedVectorClock = ((VectorClock) metadataStore.get(clusterKey, null)
.get(0)
.getVersion()).incremented(metadataStore.getNodeId(),
System.currentTimeMillis());
metadataStore.put(clusterKey, Versioned.value((Object) cluster, updatedVectorClock));
// now put new stores
updatedVectorClock = ((VectorClock) metadataStore.get(storesKey, null)
.get(0)
.getVersion()).incremented(metadataStore.getNodeId(),
System.currentTimeMillis());
metadataStore.put(storesKey, Versioned.value((Object) storeDefs, updatedVectorClock));
} catch(Exception e) {
logger.info("Error while changing cluster to " + cluster + "for key " + clusterKey);
throw new VoldemortException(e);
} finally {
metadataStore.writeLock.unlock();
}
}
|
java
|
private void changeClusterAndStores(String clusterKey,
final Cluster cluster,
String storesKey,
final List<StoreDefinition> storeDefs) {
metadataStore.writeLock.lock();
try {
VectorClock updatedVectorClock = ((VectorClock) metadataStore.get(clusterKey, null)
.get(0)
.getVersion()).incremented(metadataStore.getNodeId(),
System.currentTimeMillis());
metadataStore.put(clusterKey, Versioned.value((Object) cluster, updatedVectorClock));
// now put new stores
updatedVectorClock = ((VectorClock) metadataStore.get(storesKey, null)
.get(0)
.getVersion()).incremented(metadataStore.getNodeId(),
System.currentTimeMillis());
metadataStore.put(storesKey, Versioned.value((Object) storeDefs, updatedVectorClock));
} catch(Exception e) {
logger.info("Error while changing cluster to " + cluster + "for key " + clusterKey);
throw new VoldemortException(e);
} finally {
metadataStore.writeLock.unlock();
}
}
|
[
"private",
"void",
"changeClusterAndStores",
"(",
"String",
"clusterKey",
",",
"final",
"Cluster",
"cluster",
",",
"String",
"storesKey",
",",
"final",
"List",
"<",
"StoreDefinition",
">",
"storeDefs",
")",
"{",
"metadataStore",
".",
"writeLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"VectorClock",
"updatedVectorClock",
"=",
"(",
"(",
"VectorClock",
")",
"metadataStore",
".",
"get",
"(",
"clusterKey",
",",
"null",
")",
".",
"get",
"(",
"0",
")",
".",
"getVersion",
"(",
")",
")",
".",
"incremented",
"(",
"metadataStore",
".",
"getNodeId",
"(",
")",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"metadataStore",
".",
"put",
"(",
"clusterKey",
",",
"Versioned",
".",
"value",
"(",
"(",
"Object",
")",
"cluster",
",",
"updatedVectorClock",
")",
")",
";",
"// now put new stores",
"updatedVectorClock",
"=",
"(",
"(",
"VectorClock",
")",
"metadataStore",
".",
"get",
"(",
"storesKey",
",",
"null",
")",
".",
"get",
"(",
"0",
")",
".",
"getVersion",
"(",
")",
")",
".",
"incremented",
"(",
"metadataStore",
".",
"getNodeId",
"(",
")",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"metadataStore",
".",
"put",
"(",
"storesKey",
",",
"Versioned",
".",
"value",
"(",
"(",
"Object",
")",
"storeDefs",
",",
"updatedVectorClock",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"info",
"(",
"\"Error while changing cluster to \"",
"+",
"cluster",
"+",
"\"for key \"",
"+",
"clusterKey",
")",
";",
"throw",
"new",
"VoldemortException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"metadataStore",
".",
"writeLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Updates the cluster and store metadata atomically
This is required during rebalance and expansion into a new zone since we
have to update the store def along with the cluster def.
@param cluster The cluster metadata information
@param storeDefs The stores metadata information
|
[
"Updates",
"the",
"cluster",
"and",
"store",
"metadata",
"atomically"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/rebalance/Rebalancer.java#L381-L406
|
161,049 |
voldemort/voldemort
|
src/java/voldemort/server/rebalance/Rebalancer.java
|
Rebalancer.rebalanceNode
|
public int rebalanceNode(final RebalanceTaskInfo stealInfo) {
final RebalanceTaskInfo info = metadataStore.getRebalancerState()
.find(stealInfo.getDonorId());
// Do we have the plan in the state?
if(info == null) {
throw new VoldemortException("Could not find plan " + stealInfo
+ " in the server state on " + metadataStore.getNodeId());
} else if(!info.equals(stealInfo)) {
// If we do have the plan, is it the same
throw new VoldemortException("The plan in server state " + info
+ " is not the same as the process passed " + stealInfo);
} else if(!acquireRebalancingPermit(stealInfo.getDonorId())) {
// Both are same, now try to acquire a lock for the donor node
throw new AlreadyRebalancingException("Node " + metadataStore.getNodeId()
+ " is already rebalancing from donor "
+ info.getDonorId() + " with info " + info);
}
// Acquired lock successfully, start rebalancing...
int requestId = asyncService.getUniqueRequestId();
// Why do we pass 'info' instead of 'stealInfo'? So that we can change
// the state as the stores finish rebalance
asyncService.submitOperation(requestId,
new StealerBasedRebalanceAsyncOperation(this,
voldemortConfig,
metadataStore,
requestId,
info));
return requestId;
}
|
java
|
public int rebalanceNode(final RebalanceTaskInfo stealInfo) {
final RebalanceTaskInfo info = metadataStore.getRebalancerState()
.find(stealInfo.getDonorId());
// Do we have the plan in the state?
if(info == null) {
throw new VoldemortException("Could not find plan " + stealInfo
+ " in the server state on " + metadataStore.getNodeId());
} else if(!info.equals(stealInfo)) {
// If we do have the plan, is it the same
throw new VoldemortException("The plan in server state " + info
+ " is not the same as the process passed " + stealInfo);
} else if(!acquireRebalancingPermit(stealInfo.getDonorId())) {
// Both are same, now try to acquire a lock for the donor node
throw new AlreadyRebalancingException("Node " + metadataStore.getNodeId()
+ " is already rebalancing from donor "
+ info.getDonorId() + " with info " + info);
}
// Acquired lock successfully, start rebalancing...
int requestId = asyncService.getUniqueRequestId();
// Why do we pass 'info' instead of 'stealInfo'? So that we can change
// the state as the stores finish rebalance
asyncService.submitOperation(requestId,
new StealerBasedRebalanceAsyncOperation(this,
voldemortConfig,
metadataStore,
requestId,
info));
return requestId;
}
|
[
"public",
"int",
"rebalanceNode",
"(",
"final",
"RebalanceTaskInfo",
"stealInfo",
")",
"{",
"final",
"RebalanceTaskInfo",
"info",
"=",
"metadataStore",
".",
"getRebalancerState",
"(",
")",
".",
"find",
"(",
"stealInfo",
".",
"getDonorId",
"(",
")",
")",
";",
"// Do we have the plan in the state?",
"if",
"(",
"info",
"==",
"null",
")",
"{",
"throw",
"new",
"VoldemortException",
"(",
"\"Could not find plan \"",
"+",
"stealInfo",
"+",
"\" in the server state on \"",
"+",
"metadataStore",
".",
"getNodeId",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"!",
"info",
".",
"equals",
"(",
"stealInfo",
")",
")",
"{",
"// If we do have the plan, is it the same",
"throw",
"new",
"VoldemortException",
"(",
"\"The plan in server state \"",
"+",
"info",
"+",
"\" is not the same as the process passed \"",
"+",
"stealInfo",
")",
";",
"}",
"else",
"if",
"(",
"!",
"acquireRebalancingPermit",
"(",
"stealInfo",
".",
"getDonorId",
"(",
")",
")",
")",
"{",
"// Both are same, now try to acquire a lock for the donor node",
"throw",
"new",
"AlreadyRebalancingException",
"(",
"\"Node \"",
"+",
"metadataStore",
".",
"getNodeId",
"(",
")",
"+",
"\" is already rebalancing from donor \"",
"+",
"info",
".",
"getDonorId",
"(",
")",
"+",
"\" with info \"",
"+",
"info",
")",
";",
"}",
"// Acquired lock successfully, start rebalancing...",
"int",
"requestId",
"=",
"asyncService",
".",
"getUniqueRequestId",
"(",
")",
";",
"// Why do we pass 'info' instead of 'stealInfo'? So that we can change",
"// the state as the stores finish rebalance",
"asyncService",
".",
"submitOperation",
"(",
"requestId",
",",
"new",
"StealerBasedRebalanceAsyncOperation",
"(",
"this",
",",
"voldemortConfig",
",",
"metadataStore",
",",
"requestId",
",",
"info",
")",
")",
";",
"return",
"requestId",
";",
"}"
] |
This function is responsible for starting the actual async rebalance
operation. This is run if this node is the stealer node
<br>
We also assume that the check that this server is in rebalancing state
has been done at a higher level
@param stealInfo Partition info to steal
@return Returns a id identifying the async operation
|
[
"This",
"function",
"is",
"responsible",
"for",
"starting",
"the",
"actual",
"async",
"rebalance",
"operation",
".",
"This",
"is",
"run",
"if",
"this",
"node",
"is",
"the",
"stealer",
"node"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/rebalance/Rebalancer.java#L420-L453
|
161,050 |
voldemort/voldemort
|
src/java/voldemort/server/niosocket/AsyncRequestHandler.java
|
AsyncRequestHandler.prepForWrite
|
protected void prepForWrite(SelectionKey selectionKey) {
if(logger.isTraceEnabled())
traceInputBufferState("About to clear read buffer");
if(requestHandlerFactory.shareReadWriteBuffer() == false) {
inputStream.clear();
}
if(logger.isTraceEnabled())
traceInputBufferState("Cleared read buffer");
outputStream.getBuffer().flip();
selectionKey.interestOps(SelectionKey.OP_WRITE);
}
|
java
|
protected void prepForWrite(SelectionKey selectionKey) {
if(logger.isTraceEnabled())
traceInputBufferState("About to clear read buffer");
if(requestHandlerFactory.shareReadWriteBuffer() == false) {
inputStream.clear();
}
if(logger.isTraceEnabled())
traceInputBufferState("Cleared read buffer");
outputStream.getBuffer().flip();
selectionKey.interestOps(SelectionKey.OP_WRITE);
}
|
[
"protected",
"void",
"prepForWrite",
"(",
"SelectionKey",
"selectionKey",
")",
"{",
"if",
"(",
"logger",
".",
"isTraceEnabled",
"(",
")",
")",
"traceInputBufferState",
"(",
"\"About to clear read buffer\"",
")",
";",
"if",
"(",
"requestHandlerFactory",
".",
"shareReadWriteBuffer",
"(",
")",
"==",
"false",
")",
"{",
"inputStream",
".",
"clear",
"(",
")",
";",
"}",
"if",
"(",
"logger",
".",
"isTraceEnabled",
"(",
")",
")",
"traceInputBufferState",
"(",
"\"Cleared read buffer\"",
")",
";",
"outputStream",
".",
"getBuffer",
"(",
")",
".",
"flip",
"(",
")",
";",
"selectionKey",
".",
"interestOps",
"(",
"SelectionKey",
".",
"OP_WRITE",
")",
";",
"}"
] |
Flips the output buffer, and lets the Selector know we're ready to write.
@param selectionKey
|
[
"Flips",
"the",
"output",
"buffer",
"and",
"lets",
"the",
"Selector",
"know",
"we",
"re",
"ready",
"to",
"write",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/niosocket/AsyncRequestHandler.java#L92-L105
|
161,051 |
voldemort/voldemort
|
src/java/voldemort/server/niosocket/AsyncRequestHandler.java
|
AsyncRequestHandler.initRequestHandler
|
private boolean initRequestHandler(SelectionKey selectionKey) {
ByteBuffer inputBuffer = inputStream.getBuffer();
int remaining = inputBuffer.remaining();
// Don't have enough bytes to determine the protocol yet...
if(remaining < 3)
return true;
byte[] protoBytes = { inputBuffer.get(0), inputBuffer.get(1), inputBuffer.get(2) };
try {
String proto = ByteUtils.getString(protoBytes, "UTF-8");
inputBuffer.clear();
RequestFormatType requestFormatType = RequestFormatType.fromCode(proto);
requestHandler = requestHandlerFactory.getRequestHandler(requestFormatType);
if(logger.isInfoEnabled())
logger.info("Protocol negotiated for " + socketChannel.socket() + ": "
+ requestFormatType.getDisplayName());
// The protocol negotiation is the first request, so respond by
// sticking the bytes in the output buffer, signaling the Selector,
// and returning false to denote no further processing is needed.
outputStream.getBuffer().put(ByteUtils.getBytes("ok", "UTF-8"));
prepForWrite(selectionKey);
return false;
} catch(IllegalArgumentException e) {
// okay we got some nonsense. For backwards compatibility,
// assume this is an old client who does not know how to negotiate
RequestFormatType requestFormatType = RequestFormatType.VOLDEMORT_V0;
requestHandler = requestHandlerFactory.getRequestHandler(requestFormatType);
if(logger.isInfoEnabled())
logger.info("No protocol proposal given for " + socketChannel.socket()
+ ", assuming " + requestFormatType.getDisplayName());
return true;
}
}
|
java
|
private boolean initRequestHandler(SelectionKey selectionKey) {
ByteBuffer inputBuffer = inputStream.getBuffer();
int remaining = inputBuffer.remaining();
// Don't have enough bytes to determine the protocol yet...
if(remaining < 3)
return true;
byte[] protoBytes = { inputBuffer.get(0), inputBuffer.get(1), inputBuffer.get(2) };
try {
String proto = ByteUtils.getString(protoBytes, "UTF-8");
inputBuffer.clear();
RequestFormatType requestFormatType = RequestFormatType.fromCode(proto);
requestHandler = requestHandlerFactory.getRequestHandler(requestFormatType);
if(logger.isInfoEnabled())
logger.info("Protocol negotiated for " + socketChannel.socket() + ": "
+ requestFormatType.getDisplayName());
// The protocol negotiation is the first request, so respond by
// sticking the bytes in the output buffer, signaling the Selector,
// and returning false to denote no further processing is needed.
outputStream.getBuffer().put(ByteUtils.getBytes("ok", "UTF-8"));
prepForWrite(selectionKey);
return false;
} catch(IllegalArgumentException e) {
// okay we got some nonsense. For backwards compatibility,
// assume this is an old client who does not know how to negotiate
RequestFormatType requestFormatType = RequestFormatType.VOLDEMORT_V0;
requestHandler = requestHandlerFactory.getRequestHandler(requestFormatType);
if(logger.isInfoEnabled())
logger.info("No protocol proposal given for " + socketChannel.socket()
+ ", assuming " + requestFormatType.getDisplayName());
return true;
}
}
|
[
"private",
"boolean",
"initRequestHandler",
"(",
"SelectionKey",
"selectionKey",
")",
"{",
"ByteBuffer",
"inputBuffer",
"=",
"inputStream",
".",
"getBuffer",
"(",
")",
";",
"int",
"remaining",
"=",
"inputBuffer",
".",
"remaining",
"(",
")",
";",
"// Don't have enough bytes to determine the protocol yet...",
"if",
"(",
"remaining",
"<",
"3",
")",
"return",
"true",
";",
"byte",
"[",
"]",
"protoBytes",
"=",
"{",
"inputBuffer",
".",
"get",
"(",
"0",
")",
",",
"inputBuffer",
".",
"get",
"(",
"1",
")",
",",
"inputBuffer",
".",
"get",
"(",
"2",
")",
"}",
";",
"try",
"{",
"String",
"proto",
"=",
"ByteUtils",
".",
"getString",
"(",
"protoBytes",
",",
"\"UTF-8\"",
")",
";",
"inputBuffer",
".",
"clear",
"(",
")",
";",
"RequestFormatType",
"requestFormatType",
"=",
"RequestFormatType",
".",
"fromCode",
"(",
"proto",
")",
";",
"requestHandler",
"=",
"requestHandlerFactory",
".",
"getRequestHandler",
"(",
"requestFormatType",
")",
";",
"if",
"(",
"logger",
".",
"isInfoEnabled",
"(",
")",
")",
"logger",
".",
"info",
"(",
"\"Protocol negotiated for \"",
"+",
"socketChannel",
".",
"socket",
"(",
")",
"+",
"\": \"",
"+",
"requestFormatType",
".",
"getDisplayName",
"(",
")",
")",
";",
"// The protocol negotiation is the first request, so respond by",
"// sticking the bytes in the output buffer, signaling the Selector,",
"// and returning false to denote no further processing is needed.",
"outputStream",
".",
"getBuffer",
"(",
")",
".",
"put",
"(",
"ByteUtils",
".",
"getBytes",
"(",
"\"ok\"",
",",
"\"UTF-8\"",
")",
")",
";",
"prepForWrite",
"(",
"selectionKey",
")",
";",
"return",
"false",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"// okay we got some nonsense. For backwards compatibility,",
"// assume this is an old client who does not know how to negotiate",
"RequestFormatType",
"requestFormatType",
"=",
"RequestFormatType",
".",
"VOLDEMORT_V0",
";",
"requestHandler",
"=",
"requestHandlerFactory",
".",
"getRequestHandler",
"(",
"requestFormatType",
")",
";",
"if",
"(",
"logger",
".",
"isInfoEnabled",
"(",
")",
")",
"logger",
".",
"info",
"(",
"\"No protocol proposal given for \"",
"+",
"socketChannel",
".",
"socket",
"(",
")",
"+",
"\", assuming \"",
"+",
"requestFormatType",
".",
"getDisplayName",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"}"
] |
Returns true if the request should continue.
@return
|
[
"Returns",
"true",
"if",
"the",
"request",
"should",
"continue",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/niosocket/AsyncRequestHandler.java#L401-L440
|
161,052 |
voldemort/voldemort
|
src/java/voldemort/client/rebalance/QuotaResetter.java
|
QuotaResetter.rememberAndDisableQuota
|
public void rememberAndDisableQuota() {
for(Integer nodeId: nodeIds) {
boolean quotaEnforcement = Boolean.parseBoolean(adminClient.metadataMgmtOps.getRemoteMetadata(nodeId,
MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY)
.getValue());
mapNodeToQuotaEnforcingEnabled.put(nodeId, quotaEnforcement);
}
adminClient.metadataMgmtOps.updateRemoteMetadata(nodeIds,
MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY,
Boolean.toString(false));
}
|
java
|
public void rememberAndDisableQuota() {
for(Integer nodeId: nodeIds) {
boolean quotaEnforcement = Boolean.parseBoolean(adminClient.metadataMgmtOps.getRemoteMetadata(nodeId,
MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY)
.getValue());
mapNodeToQuotaEnforcingEnabled.put(nodeId, quotaEnforcement);
}
adminClient.metadataMgmtOps.updateRemoteMetadata(nodeIds,
MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY,
Boolean.toString(false));
}
|
[
"public",
"void",
"rememberAndDisableQuota",
"(",
")",
"{",
"for",
"(",
"Integer",
"nodeId",
":",
"nodeIds",
")",
"{",
"boolean",
"quotaEnforcement",
"=",
"Boolean",
".",
"parseBoolean",
"(",
"adminClient",
".",
"metadataMgmtOps",
".",
"getRemoteMetadata",
"(",
"nodeId",
",",
"MetadataStore",
".",
"QUOTA_ENFORCEMENT_ENABLED_KEY",
")",
".",
"getValue",
"(",
")",
")",
";",
"mapNodeToQuotaEnforcingEnabled",
".",
"put",
"(",
"nodeId",
",",
"quotaEnforcement",
")",
";",
"}",
"adminClient",
".",
"metadataMgmtOps",
".",
"updateRemoteMetadata",
"(",
"nodeIds",
",",
"MetadataStore",
".",
"QUOTA_ENFORCEMENT_ENABLED_KEY",
",",
"Boolean",
".",
"toString",
"(",
"false",
")",
")",
";",
"}"
] |
Before cluster management operations, i.e. remember and disable quota
enforcement settings
|
[
"Before",
"cluster",
"management",
"operations",
"i",
".",
"e",
".",
"remember",
"and",
"disable",
"quota",
"enforcement",
"settings"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/client/rebalance/QuotaResetter.java#L37-L47
|
161,053 |
voldemort/voldemort
|
src/java/voldemort/client/rebalance/QuotaResetter.java
|
QuotaResetter.resetQuotaAndRecoverEnforcement
|
public void resetQuotaAndRecoverEnforcement() {
for(Integer nodeId: nodeIds) {
boolean quotaEnforcement = mapNodeToQuotaEnforcingEnabled.get(nodeId);
adminClient.metadataMgmtOps.updateRemoteMetadata(Arrays.asList(nodeId),
MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY,
Boolean.toString(quotaEnforcement));
}
for(String storeName: storeNames) {
adminClient.quotaMgmtOps.rebalanceQuota(storeName);
}
}
|
java
|
public void resetQuotaAndRecoverEnforcement() {
for(Integer nodeId: nodeIds) {
boolean quotaEnforcement = mapNodeToQuotaEnforcingEnabled.get(nodeId);
adminClient.metadataMgmtOps.updateRemoteMetadata(Arrays.asList(nodeId),
MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY,
Boolean.toString(quotaEnforcement));
}
for(String storeName: storeNames) {
adminClient.quotaMgmtOps.rebalanceQuota(storeName);
}
}
|
[
"public",
"void",
"resetQuotaAndRecoverEnforcement",
"(",
")",
"{",
"for",
"(",
"Integer",
"nodeId",
":",
"nodeIds",
")",
"{",
"boolean",
"quotaEnforcement",
"=",
"mapNodeToQuotaEnforcingEnabled",
".",
"get",
"(",
"nodeId",
")",
";",
"adminClient",
".",
"metadataMgmtOps",
".",
"updateRemoteMetadata",
"(",
"Arrays",
".",
"asList",
"(",
"nodeId",
")",
",",
"MetadataStore",
".",
"QUOTA_ENFORCEMENT_ENABLED_KEY",
",",
"Boolean",
".",
"toString",
"(",
"quotaEnforcement",
")",
")",
";",
"}",
"for",
"(",
"String",
"storeName",
":",
"storeNames",
")",
"{",
"adminClient",
".",
"quotaMgmtOps",
".",
"rebalanceQuota",
"(",
"storeName",
")",
";",
"}",
"}"
] |
After cluster management operations, i.e. reset quota and recover quota
enforcement settings
|
[
"After",
"cluster",
"management",
"operations",
"i",
".",
"e",
".",
"reset",
"quota",
"and",
"recover",
"quota",
"enforcement",
"settings"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/client/rebalance/QuotaResetter.java#L53-L63
|
161,054 |
voldemort/voldemort
|
src/java/voldemort/versioning/VectorClock.java
|
VectorClock.incrementVersion
|
public void incrementVersion(int node, long time) {
if(node < 0 || node > Short.MAX_VALUE)
throw new IllegalArgumentException(node
+ " is outside the acceptable range of node ids.");
this.timestamp = time;
Long version = versionMap.get((short) node);
if(version == null) {
version = 1L;
} else {
version = version + 1L;
}
versionMap.put((short) node, version);
if(versionMap.size() >= MAX_NUMBER_OF_VERSIONS) {
throw new IllegalStateException("Vector clock is full!");
}
}
|
java
|
public void incrementVersion(int node, long time) {
if(node < 0 || node > Short.MAX_VALUE)
throw new IllegalArgumentException(node
+ " is outside the acceptable range of node ids.");
this.timestamp = time;
Long version = versionMap.get((short) node);
if(version == null) {
version = 1L;
} else {
version = version + 1L;
}
versionMap.put((short) node, version);
if(versionMap.size() >= MAX_NUMBER_OF_VERSIONS) {
throw new IllegalStateException("Vector clock is full!");
}
}
|
[
"public",
"void",
"incrementVersion",
"(",
"int",
"node",
",",
"long",
"time",
")",
"{",
"if",
"(",
"node",
"<",
"0",
"||",
"node",
">",
"Short",
".",
"MAX_VALUE",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"node",
"+",
"\" is outside the acceptable range of node ids.\"",
")",
";",
"this",
".",
"timestamp",
"=",
"time",
";",
"Long",
"version",
"=",
"versionMap",
".",
"get",
"(",
"(",
"short",
")",
"node",
")",
";",
"if",
"(",
"version",
"==",
"null",
")",
"{",
"version",
"=",
"1L",
";",
"}",
"else",
"{",
"version",
"=",
"version",
"+",
"1L",
";",
"}",
"versionMap",
".",
"put",
"(",
"(",
"short",
")",
"node",
",",
"version",
")",
";",
"if",
"(",
"versionMap",
".",
"size",
"(",
")",
">=",
"MAX_NUMBER_OF_VERSIONS",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Vector clock is full!\"",
")",
";",
"}",
"}"
] |
Increment the version info associated with the given node
@param node The node
|
[
"Increment",
"the",
"version",
"info",
"associated",
"with",
"the",
"given",
"node"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/versioning/VectorClock.java#L205-L224
|
161,055 |
voldemort/voldemort
|
src/java/voldemort/versioning/VectorClock.java
|
VectorClock.incremented
|
public VectorClock incremented(int nodeId, long time) {
VectorClock copyClock = this.clone();
copyClock.incrementVersion(nodeId, time);
return copyClock;
}
|
java
|
public VectorClock incremented(int nodeId, long time) {
VectorClock copyClock = this.clone();
copyClock.incrementVersion(nodeId, time);
return copyClock;
}
|
[
"public",
"VectorClock",
"incremented",
"(",
"int",
"nodeId",
",",
"long",
"time",
")",
"{",
"VectorClock",
"copyClock",
"=",
"this",
".",
"clone",
"(",
")",
";",
"copyClock",
".",
"incrementVersion",
"(",
"nodeId",
",",
"time",
")",
";",
"return",
"copyClock",
";",
"}"
] |
Get new vector clock based on this clock but incremented on index nodeId
@param nodeId The id of the node to increment
@return A vector clock equal on each element execept that indexed by
nodeId
|
[
"Get",
"new",
"vector",
"clock",
"based",
"on",
"this",
"clock",
"but",
"incremented",
"on",
"index",
"nodeId"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/versioning/VectorClock.java#L233-L237
|
161,056 |
voldemort/voldemort
|
src/java/voldemort/tools/PartitionBalance.java
|
PartitionBalance.getNodeIdToPrimaryCount
|
private Map<Integer, Integer> getNodeIdToPrimaryCount(Cluster cluster) {
Map<Integer, Integer> nodeIdToPrimaryCount = Maps.newHashMap();
for(Node node: cluster.getNodes()) {
nodeIdToPrimaryCount.put(node.getId(), node.getPartitionIds().size());
}
return nodeIdToPrimaryCount;
}
|
java
|
private Map<Integer, Integer> getNodeIdToPrimaryCount(Cluster cluster) {
Map<Integer, Integer> nodeIdToPrimaryCount = Maps.newHashMap();
for(Node node: cluster.getNodes()) {
nodeIdToPrimaryCount.put(node.getId(), node.getPartitionIds().size());
}
return nodeIdToPrimaryCount;
}
|
[
"private",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"getNodeIdToPrimaryCount",
"(",
"Cluster",
"cluster",
")",
"{",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"nodeIdToPrimaryCount",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"for",
"(",
"Node",
"node",
":",
"cluster",
".",
"getNodes",
"(",
")",
")",
"{",
"nodeIdToPrimaryCount",
".",
"put",
"(",
"node",
".",
"getId",
"(",
")",
",",
"node",
".",
"getPartitionIds",
"(",
")",
".",
"size",
"(",
")",
")",
";",
"}",
"return",
"nodeIdToPrimaryCount",
";",
"}"
] |
Go through all nodes and determine how many partition Ids each node
hosts.
@param cluster
@return map of nodeId to number of primary partitions hosted on node.
|
[
"Go",
"through",
"all",
"nodes",
"and",
"determine",
"how",
"many",
"partition",
"Ids",
"each",
"node",
"hosts",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/PartitionBalance.java#L180-L187
|
161,057 |
voldemort/voldemort
|
src/java/voldemort/tools/PartitionBalance.java
|
PartitionBalance.getNodeIdToZonePrimaryCount
|
private Map<Integer, Integer> getNodeIdToZonePrimaryCount(Cluster cluster,
StoreRoutingPlan storeRoutingPlan) {
Map<Integer, Integer> nodeIdToZonePrimaryCount = Maps.newHashMap();
for(Integer nodeId: cluster.getNodeIds()) {
nodeIdToZonePrimaryCount.put(nodeId,
storeRoutingPlan.getZonePrimaryPartitionIds(nodeId).size());
}
return nodeIdToZonePrimaryCount;
}
|
java
|
private Map<Integer, Integer> getNodeIdToZonePrimaryCount(Cluster cluster,
StoreRoutingPlan storeRoutingPlan) {
Map<Integer, Integer> nodeIdToZonePrimaryCount = Maps.newHashMap();
for(Integer nodeId: cluster.getNodeIds()) {
nodeIdToZonePrimaryCount.put(nodeId,
storeRoutingPlan.getZonePrimaryPartitionIds(nodeId).size());
}
return nodeIdToZonePrimaryCount;
}
|
[
"private",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"getNodeIdToZonePrimaryCount",
"(",
"Cluster",
"cluster",
",",
"StoreRoutingPlan",
"storeRoutingPlan",
")",
"{",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"nodeIdToZonePrimaryCount",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"for",
"(",
"Integer",
"nodeId",
":",
"cluster",
".",
"getNodeIds",
"(",
")",
")",
"{",
"nodeIdToZonePrimaryCount",
".",
"put",
"(",
"nodeId",
",",
"storeRoutingPlan",
".",
"getZonePrimaryPartitionIds",
"(",
"nodeId",
")",
".",
"size",
"(",
")",
")",
";",
"}",
"return",
"nodeIdToZonePrimaryCount",
";",
"}"
] |
Go through all partition IDs and determine which node is "first" in the
replicating node list for every zone. This determines the number of
"zone primaries" each node hosts.
@return map of nodeId to number of zone-primaries hosted on node.
|
[
"Go",
"through",
"all",
"partition",
"IDs",
"and",
"determine",
"which",
"node",
"is",
"first",
"in",
"the",
"replicating",
"node",
"list",
"for",
"every",
"zone",
".",
"This",
"determines",
"the",
"number",
"of",
"zone",
"primaries",
"each",
"node",
"hosts",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/PartitionBalance.java#L196-L205
|
161,058 |
voldemort/voldemort
|
src/java/voldemort/tools/PartitionBalance.java
|
PartitionBalance.getNodeIdToNaryCount
|
private Map<Integer, Integer> getNodeIdToNaryCount(Cluster cluster,
StoreRoutingPlan storeRoutingPlan) {
Map<Integer, Integer> nodeIdToNaryCount = Maps.newHashMap();
for(int nodeId: cluster.getNodeIds()) {
nodeIdToNaryCount.put(nodeId, storeRoutingPlan.getZoneNAryPartitionIds(nodeId).size());
}
return nodeIdToNaryCount;
}
|
java
|
private Map<Integer, Integer> getNodeIdToNaryCount(Cluster cluster,
StoreRoutingPlan storeRoutingPlan) {
Map<Integer, Integer> nodeIdToNaryCount = Maps.newHashMap();
for(int nodeId: cluster.getNodeIds()) {
nodeIdToNaryCount.put(nodeId, storeRoutingPlan.getZoneNAryPartitionIds(nodeId).size());
}
return nodeIdToNaryCount;
}
|
[
"private",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"getNodeIdToNaryCount",
"(",
"Cluster",
"cluster",
",",
"StoreRoutingPlan",
"storeRoutingPlan",
")",
"{",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"nodeIdToNaryCount",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"for",
"(",
"int",
"nodeId",
":",
"cluster",
".",
"getNodeIds",
"(",
")",
")",
"{",
"nodeIdToNaryCount",
".",
"put",
"(",
"nodeId",
",",
"storeRoutingPlan",
".",
"getZoneNAryPartitionIds",
"(",
"nodeId",
")",
".",
"size",
"(",
")",
")",
";",
"}",
"return",
"nodeIdToNaryCount",
";",
"}"
] |
Go through all node IDs and determine which node
@param cluster
@param storeRoutingPlan
@return
|
[
"Go",
"through",
"all",
"node",
"IDs",
"and",
"determine",
"which",
"node"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/PartitionBalance.java#L214-L223
|
161,059 |
voldemort/voldemort
|
src/java/voldemort/tools/PartitionBalance.java
|
PartitionBalance.dumpZoneNAryDetails
|
private String dumpZoneNAryDetails(StoreRoutingPlan storeRoutingPlan) {
StringBuilder sb = new StringBuilder();
sb.append("\tDetailed Dump (Zone N-Aries):").append(Utils.NEWLINE);
for(Node node: storeRoutingPlan.getCluster().getNodes()) {
int zoneId = node.getZoneId();
int nodeId = node.getId();
sb.append("\tNode ID: " + nodeId + " in zone " + zoneId).append(Utils.NEWLINE);
List<Integer> naries = storeRoutingPlan.getZoneNAryPartitionIds(nodeId);
Map<Integer, List<Integer>> zoneNaryTypeToPartitionIds = new HashMap<Integer, List<Integer>>();
for(int nary: naries) {
int zoneReplicaType = storeRoutingPlan.getZoneNaryForNodesPartition(zoneId,
nodeId,
nary);
if(!zoneNaryTypeToPartitionIds.containsKey(zoneReplicaType)) {
zoneNaryTypeToPartitionIds.put(zoneReplicaType, new ArrayList<Integer>());
}
zoneNaryTypeToPartitionIds.get(zoneReplicaType).add(nary);
}
for(int replicaType: new TreeSet<Integer>(zoneNaryTypeToPartitionIds.keySet())) {
sb.append("\t\t" + replicaType + " : ");
sb.append(zoneNaryTypeToPartitionIds.get(replicaType).toString());
sb.append(Utils.NEWLINE);
}
}
return sb.toString();
}
|
java
|
private String dumpZoneNAryDetails(StoreRoutingPlan storeRoutingPlan) {
StringBuilder sb = new StringBuilder();
sb.append("\tDetailed Dump (Zone N-Aries):").append(Utils.NEWLINE);
for(Node node: storeRoutingPlan.getCluster().getNodes()) {
int zoneId = node.getZoneId();
int nodeId = node.getId();
sb.append("\tNode ID: " + nodeId + " in zone " + zoneId).append(Utils.NEWLINE);
List<Integer> naries = storeRoutingPlan.getZoneNAryPartitionIds(nodeId);
Map<Integer, List<Integer>> zoneNaryTypeToPartitionIds = new HashMap<Integer, List<Integer>>();
for(int nary: naries) {
int zoneReplicaType = storeRoutingPlan.getZoneNaryForNodesPartition(zoneId,
nodeId,
nary);
if(!zoneNaryTypeToPartitionIds.containsKey(zoneReplicaType)) {
zoneNaryTypeToPartitionIds.put(zoneReplicaType, new ArrayList<Integer>());
}
zoneNaryTypeToPartitionIds.get(zoneReplicaType).add(nary);
}
for(int replicaType: new TreeSet<Integer>(zoneNaryTypeToPartitionIds.keySet())) {
sb.append("\t\t" + replicaType + " : ");
sb.append(zoneNaryTypeToPartitionIds.get(replicaType).toString());
sb.append(Utils.NEWLINE);
}
}
return sb.toString();
}
|
[
"private",
"String",
"dumpZoneNAryDetails",
"(",
"StoreRoutingPlan",
"storeRoutingPlan",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"\\tDetailed Dump (Zone N-Aries):\"",
")",
".",
"append",
"(",
"Utils",
".",
"NEWLINE",
")",
";",
"for",
"(",
"Node",
"node",
":",
"storeRoutingPlan",
".",
"getCluster",
"(",
")",
".",
"getNodes",
"(",
")",
")",
"{",
"int",
"zoneId",
"=",
"node",
".",
"getZoneId",
"(",
")",
";",
"int",
"nodeId",
"=",
"node",
".",
"getId",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"\\tNode ID: \"",
"+",
"nodeId",
"+",
"\" in zone \"",
"+",
"zoneId",
")",
".",
"append",
"(",
"Utils",
".",
"NEWLINE",
")",
";",
"List",
"<",
"Integer",
">",
"naries",
"=",
"storeRoutingPlan",
".",
"getZoneNAryPartitionIds",
"(",
"nodeId",
")",
";",
"Map",
"<",
"Integer",
",",
"List",
"<",
"Integer",
">",
">",
"zoneNaryTypeToPartitionIds",
"=",
"new",
"HashMap",
"<",
"Integer",
",",
"List",
"<",
"Integer",
">",
">",
"(",
")",
";",
"for",
"(",
"int",
"nary",
":",
"naries",
")",
"{",
"int",
"zoneReplicaType",
"=",
"storeRoutingPlan",
".",
"getZoneNaryForNodesPartition",
"(",
"zoneId",
",",
"nodeId",
",",
"nary",
")",
";",
"if",
"(",
"!",
"zoneNaryTypeToPartitionIds",
".",
"containsKey",
"(",
"zoneReplicaType",
")",
")",
"{",
"zoneNaryTypeToPartitionIds",
".",
"put",
"(",
"zoneReplicaType",
",",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
")",
")",
";",
"}",
"zoneNaryTypeToPartitionIds",
".",
"get",
"(",
"zoneReplicaType",
")",
".",
"add",
"(",
"nary",
")",
";",
"}",
"for",
"(",
"int",
"replicaType",
":",
"new",
"TreeSet",
"<",
"Integer",
">",
"(",
"zoneNaryTypeToPartitionIds",
".",
"keySet",
"(",
")",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"\\t\\t\"",
"+",
"replicaType",
"+",
"\" : \"",
")",
";",
"sb",
".",
"append",
"(",
"zoneNaryTypeToPartitionIds",
".",
"get",
"(",
"replicaType",
")",
".",
"toString",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"Utils",
".",
"NEWLINE",
")",
";",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Dumps the partition IDs per node in terms of zone n-ary type.
@param cluster
@param storeRoutingPlan
@return pretty printed string of detailed zone n-ary type.
|
[
"Dumps",
"the",
"partition",
"IDs",
"per",
"node",
"in",
"terms",
"of",
"zone",
"n",
"-",
"ary",
"type",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/PartitionBalance.java#L232-L260
|
161,060 |
voldemort/voldemort
|
src/java/voldemort/tools/PartitionBalance.java
|
PartitionBalance.summarizeBalance
|
private Pair<Double, String>
summarizeBalance(final Map<Integer, Integer> nodeIdToPartitionCount, String title) {
StringBuilder builder = new StringBuilder();
builder.append("\n" + title + "\n");
Map<Integer, ZoneBalanceStats> zoneToBalanceStats = new HashMap<Integer, ZoneBalanceStats>();
for(Integer zoneId: cluster.getZoneIds()) {
zoneToBalanceStats.put(zoneId, new ZoneBalanceStats());
}
for(Node node: cluster.getNodes()) {
int curCount = nodeIdToPartitionCount.get(node.getId());
builder.append("\tNode ID: " + node.getId() + " : " + curCount + " (" + node.getHost()
+ ")\n");
zoneToBalanceStats.get(node.getZoneId()).addPartitions(curCount);
}
// double utilityToBeMinimized = Double.MIN_VALUE;
double utilityToBeMinimized = 0;
for(Integer zoneId: cluster.getZoneIds()) {
builder.append("Zone " + zoneId + "\n");
builder.append(zoneToBalanceStats.get(zoneId).dumpStats());
utilityToBeMinimized += zoneToBalanceStats.get(zoneId).getUtility();
/*-
* Another utility function to consider
if(zoneToBalanceStats.get(zoneId).getMaxMinRatio() > utilityToBeMinimized) {
utilityToBeMinimized = zoneToBalanceStats.get(zoneId).getUtility();
}
*/
}
return Pair.create(utilityToBeMinimized, builder.toString());
}
|
java
|
private Pair<Double, String>
summarizeBalance(final Map<Integer, Integer> nodeIdToPartitionCount, String title) {
StringBuilder builder = new StringBuilder();
builder.append("\n" + title + "\n");
Map<Integer, ZoneBalanceStats> zoneToBalanceStats = new HashMap<Integer, ZoneBalanceStats>();
for(Integer zoneId: cluster.getZoneIds()) {
zoneToBalanceStats.put(zoneId, new ZoneBalanceStats());
}
for(Node node: cluster.getNodes()) {
int curCount = nodeIdToPartitionCount.get(node.getId());
builder.append("\tNode ID: " + node.getId() + " : " + curCount + " (" + node.getHost()
+ ")\n");
zoneToBalanceStats.get(node.getZoneId()).addPartitions(curCount);
}
// double utilityToBeMinimized = Double.MIN_VALUE;
double utilityToBeMinimized = 0;
for(Integer zoneId: cluster.getZoneIds()) {
builder.append("Zone " + zoneId + "\n");
builder.append(zoneToBalanceStats.get(zoneId).dumpStats());
utilityToBeMinimized += zoneToBalanceStats.get(zoneId).getUtility();
/*-
* Another utility function to consider
if(zoneToBalanceStats.get(zoneId).getMaxMinRatio() > utilityToBeMinimized) {
utilityToBeMinimized = zoneToBalanceStats.get(zoneId).getUtility();
}
*/
}
return Pair.create(utilityToBeMinimized, builder.toString());
}
|
[
"private",
"Pair",
"<",
"Double",
",",
"String",
">",
"summarizeBalance",
"(",
"final",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"nodeIdToPartitionCount",
",",
"String",
"title",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"\"\\n\"",
"+",
"title",
"+",
"\"\\n\"",
")",
";",
"Map",
"<",
"Integer",
",",
"ZoneBalanceStats",
">",
"zoneToBalanceStats",
"=",
"new",
"HashMap",
"<",
"Integer",
",",
"ZoneBalanceStats",
">",
"(",
")",
";",
"for",
"(",
"Integer",
"zoneId",
":",
"cluster",
".",
"getZoneIds",
"(",
")",
")",
"{",
"zoneToBalanceStats",
".",
"put",
"(",
"zoneId",
",",
"new",
"ZoneBalanceStats",
"(",
")",
")",
";",
"}",
"for",
"(",
"Node",
"node",
":",
"cluster",
".",
"getNodes",
"(",
")",
")",
"{",
"int",
"curCount",
"=",
"nodeIdToPartitionCount",
".",
"get",
"(",
"node",
".",
"getId",
"(",
")",
")",
";",
"builder",
".",
"append",
"(",
"\"\\tNode ID: \"",
"+",
"node",
".",
"getId",
"(",
")",
"+",
"\" : \"",
"+",
"curCount",
"+",
"\" (\"",
"+",
"node",
".",
"getHost",
"(",
")",
"+",
"\")\\n\"",
")",
";",
"zoneToBalanceStats",
".",
"get",
"(",
"node",
".",
"getZoneId",
"(",
")",
")",
".",
"addPartitions",
"(",
"curCount",
")",
";",
"}",
"// double utilityToBeMinimized = Double.MIN_VALUE;",
"double",
"utilityToBeMinimized",
"=",
"0",
";",
"for",
"(",
"Integer",
"zoneId",
":",
"cluster",
".",
"getZoneIds",
"(",
")",
")",
"{",
"builder",
".",
"append",
"(",
"\"Zone \"",
"+",
"zoneId",
"+",
"\"\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"zoneToBalanceStats",
".",
"get",
"(",
"zoneId",
")",
".",
"dumpStats",
"(",
")",
")",
";",
"utilityToBeMinimized",
"+=",
"zoneToBalanceStats",
".",
"get",
"(",
"zoneId",
")",
".",
"getUtility",
"(",
")",
";",
"/*- \n * Another utility function to consider \n if(zoneToBalanceStats.get(zoneId).getMaxMinRatio() > utilityToBeMinimized) {\n utilityToBeMinimized = zoneToBalanceStats.get(zoneId).getUtility();\n }\n */",
"}",
"return",
"Pair",
".",
"create",
"(",
"utilityToBeMinimized",
",",
"builder",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Summarizes balance for the given nodeId to PartitionCount.
@param nodeIdToPartitionCount
@param title for use in pretty string
@return Pair: getFirst() is utility value to be minimized, getSecond() is
pretty summary string of balance
|
[
"Summarizes",
"balance",
"for",
"the",
"given",
"nodeId",
"to",
"PartitionCount",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/PartitionBalance.java#L398-L430
|
161,061 |
voldemort/voldemort
|
src/java/voldemort/server/rebalance/async/StealerBasedRebalanceAsyncOperation.java
|
StealerBasedRebalanceAsyncOperation.rebalanceStore
|
private void rebalanceStore(String storeName,
final AdminClient adminClient,
RebalanceTaskInfo stealInfo,
boolean isReadOnlyStore) {
// Move partitions
if (stealInfo.getPartitionIds(storeName) != null && stealInfo.getPartitionIds(storeName).size() > 0) {
logger.info(getHeader(stealInfo) + "Starting partitions migration for store "
+ storeName + " from donor node " + stealInfo.getDonorId());
int asyncId = adminClient.storeMntOps.migratePartitions(stealInfo.getDonorId(),
metadataStore.getNodeId(),
storeName,
stealInfo.getPartitionIds(storeName),
null,
stealInfo.getInitialCluster());
rebalanceStatusList.add(asyncId);
if(logger.isDebugEnabled()) {
logger.debug(getHeader(stealInfo) + "Waiting for completion for " + storeName
+ " with async id " + asyncId);
}
adminClient.rpcOps.waitForCompletion(metadataStore.getNodeId(),
asyncId,
voldemortConfig.getRebalancingTimeoutSec(),
TimeUnit.SECONDS,
getStatus());
rebalanceStatusList.remove((Object) asyncId);
logger.info(getHeader(stealInfo) + "Completed partition migration for store "
+ storeName + " from donor node " + stealInfo.getDonorId());
}
logger.info(getHeader(stealInfo) + "Finished all migration for store " + storeName);
}
|
java
|
private void rebalanceStore(String storeName,
final AdminClient adminClient,
RebalanceTaskInfo stealInfo,
boolean isReadOnlyStore) {
// Move partitions
if (stealInfo.getPartitionIds(storeName) != null && stealInfo.getPartitionIds(storeName).size() > 0) {
logger.info(getHeader(stealInfo) + "Starting partitions migration for store "
+ storeName + " from donor node " + stealInfo.getDonorId());
int asyncId = adminClient.storeMntOps.migratePartitions(stealInfo.getDonorId(),
metadataStore.getNodeId(),
storeName,
stealInfo.getPartitionIds(storeName),
null,
stealInfo.getInitialCluster());
rebalanceStatusList.add(asyncId);
if(logger.isDebugEnabled()) {
logger.debug(getHeader(stealInfo) + "Waiting for completion for " + storeName
+ " with async id " + asyncId);
}
adminClient.rpcOps.waitForCompletion(metadataStore.getNodeId(),
asyncId,
voldemortConfig.getRebalancingTimeoutSec(),
TimeUnit.SECONDS,
getStatus());
rebalanceStatusList.remove((Object) asyncId);
logger.info(getHeader(stealInfo) + "Completed partition migration for store "
+ storeName + " from donor node " + stealInfo.getDonorId());
}
logger.info(getHeader(stealInfo) + "Finished all migration for store " + storeName);
}
|
[
"private",
"void",
"rebalanceStore",
"(",
"String",
"storeName",
",",
"final",
"AdminClient",
"adminClient",
",",
"RebalanceTaskInfo",
"stealInfo",
",",
"boolean",
"isReadOnlyStore",
")",
"{",
"// Move partitions",
"if",
"(",
"stealInfo",
".",
"getPartitionIds",
"(",
"storeName",
")",
"!=",
"null",
"&&",
"stealInfo",
".",
"getPartitionIds",
"(",
"storeName",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"logger",
".",
"info",
"(",
"getHeader",
"(",
"stealInfo",
")",
"+",
"\"Starting partitions migration for store \"",
"+",
"storeName",
"+",
"\" from donor node \"",
"+",
"stealInfo",
".",
"getDonorId",
"(",
")",
")",
";",
"int",
"asyncId",
"=",
"adminClient",
".",
"storeMntOps",
".",
"migratePartitions",
"(",
"stealInfo",
".",
"getDonorId",
"(",
")",
",",
"metadataStore",
".",
"getNodeId",
"(",
")",
",",
"storeName",
",",
"stealInfo",
".",
"getPartitionIds",
"(",
"storeName",
")",
",",
"null",
",",
"stealInfo",
".",
"getInitialCluster",
"(",
")",
")",
";",
"rebalanceStatusList",
".",
"add",
"(",
"asyncId",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"getHeader",
"(",
"stealInfo",
")",
"+",
"\"Waiting for completion for \"",
"+",
"storeName",
"+",
"\" with async id \"",
"+",
"asyncId",
")",
";",
"}",
"adminClient",
".",
"rpcOps",
".",
"waitForCompletion",
"(",
"metadataStore",
".",
"getNodeId",
"(",
")",
",",
"asyncId",
",",
"voldemortConfig",
".",
"getRebalancingTimeoutSec",
"(",
")",
",",
"TimeUnit",
".",
"SECONDS",
",",
"getStatus",
"(",
")",
")",
";",
"rebalanceStatusList",
".",
"remove",
"(",
"(",
"Object",
")",
"asyncId",
")",
";",
"logger",
".",
"info",
"(",
"getHeader",
"(",
"stealInfo",
")",
"+",
"\"Completed partition migration for store \"",
"+",
"storeName",
"+",
"\" from donor node \"",
"+",
"stealInfo",
".",
"getDonorId",
"(",
")",
")",
";",
"}",
"logger",
".",
"info",
"(",
"getHeader",
"(",
"stealInfo",
")",
"+",
"\"Finished all migration for store \"",
"+",
"storeName",
")",
";",
"}"
] |
Blocking function which completes the migration of one store
@param storeName The name of the store
@param adminClient Admin client used to initiate the copying of data
@param stealInfo The steal information
@param isReadOnlyStore Boolean indicating that this is a read-only store
|
[
"Blocking",
"function",
"which",
"completes",
"the",
"migration",
"of",
"one",
"store"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/rebalance/async/StealerBasedRebalanceAsyncOperation.java#L174-L209
|
161,062 |
voldemort/voldemort
|
src/java/voldemort/store/stats/ClientSocketStats.java
|
ClientSocketStats.recordSyncOpTimeNs
|
public void recordSyncOpTimeNs(SocketDestination dest, long opTimeNs) {
if(dest != null) {
getOrCreateNodeStats(dest).recordSyncOpTimeNs(null, opTimeNs);
recordSyncOpTimeNs(null, opTimeNs);
} else {
this.syncOpTimeRequestCounter.addRequest(opTimeNs);
}
}
|
java
|
public void recordSyncOpTimeNs(SocketDestination dest, long opTimeNs) {
if(dest != null) {
getOrCreateNodeStats(dest).recordSyncOpTimeNs(null, opTimeNs);
recordSyncOpTimeNs(null, opTimeNs);
} else {
this.syncOpTimeRequestCounter.addRequest(opTimeNs);
}
}
|
[
"public",
"void",
"recordSyncOpTimeNs",
"(",
"SocketDestination",
"dest",
",",
"long",
"opTimeNs",
")",
"{",
"if",
"(",
"dest",
"!=",
"null",
")",
"{",
"getOrCreateNodeStats",
"(",
"dest",
")",
".",
"recordSyncOpTimeNs",
"(",
"null",
",",
"opTimeNs",
")",
";",
"recordSyncOpTimeNs",
"(",
"null",
",",
"opTimeNs",
")",
";",
"}",
"else",
"{",
"this",
".",
"syncOpTimeRequestCounter",
".",
"addRequest",
"(",
"opTimeNs",
")",
";",
"}",
"}"
] |
Record operation for sync ops time
@param dest Destination of the socket to connect to. Will actually record
if null. Otherwise will call this on self and corresponding child
with this param null.
@param opTimeUs The number of us for the op to finish
|
[
"Record",
"operation",
"for",
"sync",
"ops",
"time"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/ClientSocketStats.java#L213-L220
|
161,063 |
voldemort/voldemort
|
src/java/voldemort/store/stats/ClientSocketStats.java
|
ClientSocketStats.recordAsyncOpTimeNs
|
public void recordAsyncOpTimeNs(SocketDestination dest, long opTimeNs) {
if(dest != null) {
getOrCreateNodeStats(dest).recordAsyncOpTimeNs(null, opTimeNs);
recordAsyncOpTimeNs(null, opTimeNs);
} else {
this.asynOpTimeRequestCounter.addRequest(opTimeNs);
}
}
|
java
|
public void recordAsyncOpTimeNs(SocketDestination dest, long opTimeNs) {
if(dest != null) {
getOrCreateNodeStats(dest).recordAsyncOpTimeNs(null, opTimeNs);
recordAsyncOpTimeNs(null, opTimeNs);
} else {
this.asynOpTimeRequestCounter.addRequest(opTimeNs);
}
}
|
[
"public",
"void",
"recordAsyncOpTimeNs",
"(",
"SocketDestination",
"dest",
",",
"long",
"opTimeNs",
")",
"{",
"if",
"(",
"dest",
"!=",
"null",
")",
"{",
"getOrCreateNodeStats",
"(",
"dest",
")",
".",
"recordAsyncOpTimeNs",
"(",
"null",
",",
"opTimeNs",
")",
";",
"recordAsyncOpTimeNs",
"(",
"null",
",",
"opTimeNs",
")",
";",
"}",
"else",
"{",
"this",
".",
"asynOpTimeRequestCounter",
".",
"addRequest",
"(",
"opTimeNs",
")",
";",
"}",
"}"
] |
Record operation for async ops time
@param dest Destination of the socket to connect to. Will actually record
if null. Otherwise will call this on self and corresponding child
with this param null.
@param opTimeUs The number of us for the op to finish
|
[
"Record",
"operation",
"for",
"async",
"ops",
"time"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/ClientSocketStats.java#L230-L237
|
161,064 |
voldemort/voldemort
|
src/java/voldemort/store/stats/ClientSocketStats.java
|
ClientSocketStats.recordConnectionEstablishmentTimeUs
|
public void recordConnectionEstablishmentTimeUs(SocketDestination dest, long connEstTimeUs) {
if(dest != null) {
getOrCreateNodeStats(dest).recordConnectionEstablishmentTimeUs(null, connEstTimeUs);
recordConnectionEstablishmentTimeUs(null, connEstTimeUs);
} else {
this.connectionEstablishmentRequestCounter.addRequest(connEstTimeUs * Time.NS_PER_US);
}
}
|
java
|
public void recordConnectionEstablishmentTimeUs(SocketDestination dest, long connEstTimeUs) {
if(dest != null) {
getOrCreateNodeStats(dest).recordConnectionEstablishmentTimeUs(null, connEstTimeUs);
recordConnectionEstablishmentTimeUs(null, connEstTimeUs);
} else {
this.connectionEstablishmentRequestCounter.addRequest(connEstTimeUs * Time.NS_PER_US);
}
}
|
[
"public",
"void",
"recordConnectionEstablishmentTimeUs",
"(",
"SocketDestination",
"dest",
",",
"long",
"connEstTimeUs",
")",
"{",
"if",
"(",
"dest",
"!=",
"null",
")",
"{",
"getOrCreateNodeStats",
"(",
"dest",
")",
".",
"recordConnectionEstablishmentTimeUs",
"(",
"null",
",",
"connEstTimeUs",
")",
";",
"recordConnectionEstablishmentTimeUs",
"(",
"null",
",",
"connEstTimeUs",
")",
";",
"}",
"else",
"{",
"this",
".",
"connectionEstablishmentRequestCounter",
".",
"addRequest",
"(",
"connEstTimeUs",
"*",
"Time",
".",
"NS_PER_US",
")",
";",
"}",
"}"
] |
Record the connection establishment time
@param dest Destination of the socket to connect to. Will actually record
if null. Otherwise will call this on self and corresponding child
with this param null.
@param connEstTimeUs The number of us to wait before establishing a
connection
|
[
"Record",
"the",
"connection",
"establishment",
"time"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/ClientSocketStats.java#L248-L255
|
161,065 |
voldemort/voldemort
|
src/java/voldemort/store/stats/ClientSocketStats.java
|
ClientSocketStats.recordCheckoutTimeUs
|
public void recordCheckoutTimeUs(SocketDestination dest, long checkoutTimeUs) {
if(dest != null) {
getOrCreateNodeStats(dest).recordCheckoutTimeUs(null, checkoutTimeUs);
recordCheckoutTimeUs(null, checkoutTimeUs);
} else {
this.checkoutTimeRequestCounter.addRequest(checkoutTimeUs * Time.NS_PER_US);
}
}
|
java
|
public void recordCheckoutTimeUs(SocketDestination dest, long checkoutTimeUs) {
if(dest != null) {
getOrCreateNodeStats(dest).recordCheckoutTimeUs(null, checkoutTimeUs);
recordCheckoutTimeUs(null, checkoutTimeUs);
} else {
this.checkoutTimeRequestCounter.addRequest(checkoutTimeUs * Time.NS_PER_US);
}
}
|
[
"public",
"void",
"recordCheckoutTimeUs",
"(",
"SocketDestination",
"dest",
",",
"long",
"checkoutTimeUs",
")",
"{",
"if",
"(",
"dest",
"!=",
"null",
")",
"{",
"getOrCreateNodeStats",
"(",
"dest",
")",
".",
"recordCheckoutTimeUs",
"(",
"null",
",",
"checkoutTimeUs",
")",
";",
"recordCheckoutTimeUs",
"(",
"null",
",",
"checkoutTimeUs",
")",
";",
"}",
"else",
"{",
"this",
".",
"checkoutTimeRequestCounter",
".",
"addRequest",
"(",
"checkoutTimeUs",
"*",
"Time",
".",
"NS_PER_US",
")",
";",
"}",
"}"
] |
Record the checkout wait time in us
@param dest Destination of the socket to checkout. Will actually record
if null. Otherwise will call this on self and corresponding child
with this param null.
@param checkoutTimeUs The number of us to wait before getting a socket
|
[
"Record",
"the",
"checkout",
"wait",
"time",
"in",
"us"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/ClientSocketStats.java#L265-L272
|
161,066 |
voldemort/voldemort
|
src/java/voldemort/store/stats/ClientSocketStats.java
|
ClientSocketStats.recordCheckoutQueueLength
|
public void recordCheckoutQueueLength(SocketDestination dest, int queueLength) {
if(dest != null) {
getOrCreateNodeStats(dest).recordCheckoutQueueLength(null, queueLength);
recordCheckoutQueueLength(null, queueLength);
} else {
this.checkoutQueueLengthHistogram.insert(queueLength);
checkMonitoringInterval();
}
}
|
java
|
public void recordCheckoutQueueLength(SocketDestination dest, int queueLength) {
if(dest != null) {
getOrCreateNodeStats(dest).recordCheckoutQueueLength(null, queueLength);
recordCheckoutQueueLength(null, queueLength);
} else {
this.checkoutQueueLengthHistogram.insert(queueLength);
checkMonitoringInterval();
}
}
|
[
"public",
"void",
"recordCheckoutQueueLength",
"(",
"SocketDestination",
"dest",
",",
"int",
"queueLength",
")",
"{",
"if",
"(",
"dest",
"!=",
"null",
")",
"{",
"getOrCreateNodeStats",
"(",
"dest",
")",
".",
"recordCheckoutQueueLength",
"(",
"null",
",",
"queueLength",
")",
";",
"recordCheckoutQueueLength",
"(",
"null",
",",
"queueLength",
")",
";",
"}",
"else",
"{",
"this",
".",
"checkoutQueueLengthHistogram",
".",
"insert",
"(",
"queueLength",
")",
";",
"checkMonitoringInterval",
"(",
")",
";",
"}",
"}"
] |
Record the checkout queue length
@param dest Destination of the socket to checkout. Will actually record
if null. Otherwise will call this on self and corresponding child
with this param null.
@param queueLength The number of entries in the "synchronous" checkout
queue.
|
[
"Record",
"the",
"checkout",
"queue",
"length"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/ClientSocketStats.java#L283-L291
|
161,067 |
voldemort/voldemort
|
src/java/voldemort/store/stats/ClientSocketStats.java
|
ClientSocketStats.recordResourceRequestTimeUs
|
public void recordResourceRequestTimeUs(SocketDestination dest, long resourceRequestTimeUs) {
if(dest != null) {
getOrCreateNodeStats(dest).recordResourceRequestTimeUs(null, resourceRequestTimeUs);
recordResourceRequestTimeUs(null, resourceRequestTimeUs);
} else {
this.resourceRequestTimeRequestCounter.addRequest(resourceRequestTimeUs
* Time.NS_PER_US);
}
}
|
java
|
public void recordResourceRequestTimeUs(SocketDestination dest, long resourceRequestTimeUs) {
if(dest != null) {
getOrCreateNodeStats(dest).recordResourceRequestTimeUs(null, resourceRequestTimeUs);
recordResourceRequestTimeUs(null, resourceRequestTimeUs);
} else {
this.resourceRequestTimeRequestCounter.addRequest(resourceRequestTimeUs
* Time.NS_PER_US);
}
}
|
[
"public",
"void",
"recordResourceRequestTimeUs",
"(",
"SocketDestination",
"dest",
",",
"long",
"resourceRequestTimeUs",
")",
"{",
"if",
"(",
"dest",
"!=",
"null",
")",
"{",
"getOrCreateNodeStats",
"(",
"dest",
")",
".",
"recordResourceRequestTimeUs",
"(",
"null",
",",
"resourceRequestTimeUs",
")",
";",
"recordResourceRequestTimeUs",
"(",
"null",
",",
"resourceRequestTimeUs",
")",
";",
"}",
"else",
"{",
"this",
".",
"resourceRequestTimeRequestCounter",
".",
"addRequest",
"(",
"resourceRequestTimeUs",
"*",
"Time",
".",
"NS_PER_US",
")",
";",
"}",
"}"
] |
Record the resource request wait time in us
@param dest Destination of the socket for which the resource was
requested. Will actually record if null. Otherwise will call this
on self and corresponding child with this param null.
@param resourceRequestTimeUs The number of us to wait before getting a
socket
|
[
"Record",
"the",
"resource",
"request",
"wait",
"time",
"in",
"us"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/ClientSocketStats.java#L302-L310
|
161,068 |
voldemort/voldemort
|
src/java/voldemort/store/stats/ClientSocketStats.java
|
ClientSocketStats.recordResourceRequestQueueLength
|
public void recordResourceRequestQueueLength(SocketDestination dest, int queueLength) {
if(dest != null) {
getOrCreateNodeStats(dest).recordResourceRequestQueueLength(null, queueLength);
recordResourceRequestQueueLength(null, queueLength);
} else {
this.resourceRequestQueueLengthHistogram.insert(queueLength);
checkMonitoringInterval();
}
}
|
java
|
public void recordResourceRequestQueueLength(SocketDestination dest, int queueLength) {
if(dest != null) {
getOrCreateNodeStats(dest).recordResourceRequestQueueLength(null, queueLength);
recordResourceRequestQueueLength(null, queueLength);
} else {
this.resourceRequestQueueLengthHistogram.insert(queueLength);
checkMonitoringInterval();
}
}
|
[
"public",
"void",
"recordResourceRequestQueueLength",
"(",
"SocketDestination",
"dest",
",",
"int",
"queueLength",
")",
"{",
"if",
"(",
"dest",
"!=",
"null",
")",
"{",
"getOrCreateNodeStats",
"(",
"dest",
")",
".",
"recordResourceRequestQueueLength",
"(",
"null",
",",
"queueLength",
")",
";",
"recordResourceRequestQueueLength",
"(",
"null",
",",
"queueLength",
")",
";",
"}",
"else",
"{",
"this",
".",
"resourceRequestQueueLengthHistogram",
".",
"insert",
"(",
"queueLength",
")",
";",
"checkMonitoringInterval",
"(",
")",
";",
"}",
"}"
] |
Record the resource request queue length
@param dest Destination of the socket for which resource request is
enqueued. Will actually record if null. Otherwise will call this
on self and corresponding child with this param null.
@param queueLength The number of entries in the "asynchronous" resource
request queue.
|
[
"Record",
"the",
"resource",
"request",
"queue",
"length"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/ClientSocketStats.java#L321-L329
|
161,069 |
voldemort/voldemort
|
src/java/voldemort/store/stats/ClientSocketStats.java
|
ClientSocketStats.close
|
public void close() {
Iterator<SocketDestination> it = getStatsMap().keySet().iterator();
while(it.hasNext()) {
try {
SocketDestination destination = it.next();
JmxUtils.unregisterMbean(JmxUtils.createObjectName(JmxUtils.getPackageName(ClientRequestExecutor.class),
"stats_"
+ destination.toString()
.replace(':',
'_')
+ identifierString));
} catch(Exception e) {}
}
}
|
java
|
public void close() {
Iterator<SocketDestination> it = getStatsMap().keySet().iterator();
while(it.hasNext()) {
try {
SocketDestination destination = it.next();
JmxUtils.unregisterMbean(JmxUtils.createObjectName(JmxUtils.getPackageName(ClientRequestExecutor.class),
"stats_"
+ destination.toString()
.replace(':',
'_')
+ identifierString));
} catch(Exception e) {}
}
}
|
[
"public",
"void",
"close",
"(",
")",
"{",
"Iterator",
"<",
"SocketDestination",
">",
"it",
"=",
"getStatsMap",
"(",
")",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"try",
"{",
"SocketDestination",
"destination",
"=",
"it",
".",
"next",
"(",
")",
";",
"JmxUtils",
".",
"unregisterMbean",
"(",
"JmxUtils",
".",
"createObjectName",
"(",
"JmxUtils",
".",
"getPackageName",
"(",
"ClientRequestExecutor",
".",
"class",
")",
",",
"\"stats_\"",
"+",
"destination",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
"+",
"identifierString",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"}"
] |
Unregister all MBeans
|
[
"Unregister",
"all",
"MBeans"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/ClientSocketStats.java#L504-L517
|
161,070 |
voldemort/voldemort
|
src/java/voldemort/store/socket/SocketStore.java
|
SocketStore.request
|
private <T> T request(ClientRequest<T> delegate, String operationName) {
long startTimeMs = -1;
long startTimeNs = -1;
if(logger.isDebugEnabled()) {
startTimeMs = System.currentTimeMillis();
}
ClientRequestExecutor clientRequestExecutor = pool.checkout(destination);
String debugMsgStr = "";
startTimeNs = System.nanoTime();
BlockingClientRequest<T> blockingClientRequest = null;
try {
blockingClientRequest = new BlockingClientRequest<T>(delegate, timeoutMs);
clientRequestExecutor.addClientRequest(blockingClientRequest,
timeoutMs,
System.nanoTime() - startTimeNs);
boolean awaitResult = blockingClientRequest.await();
if(awaitResult == false) {
blockingClientRequest.timeOut();
}
if(logger.isDebugEnabled())
debugMsgStr += "success";
return blockingClientRequest.getResult();
} catch(InterruptedException e) {
if(logger.isDebugEnabled())
debugMsgStr += "unreachable: " + e.getMessage();
throw new UnreachableStoreException("Failure in " + operationName + " on "
+ destination + ": " + e.getMessage(), e);
} catch(UnreachableStoreException e) {
clientRequestExecutor.close();
if(logger.isDebugEnabled())
debugMsgStr += "failure: " + e.getMessage();
throw new UnreachableStoreException("Failure in " + operationName + " on "
+ destination + ": " + e.getMessage(), e.getCause());
} finally {
if(blockingClientRequest != null && !blockingClientRequest.isComplete()) {
// close the executor if we timed out
clientRequestExecutor.close();
}
// Record operation time
long opTimeNs = Utils.elapsedTimeNs(startTimeNs, System.nanoTime());
if(stats != null) {
stats.recordSyncOpTimeNs(destination, opTimeNs);
}
if(logger.isDebugEnabled()) {
logger.debug("Sync request end, type: "
+ operationName
+ " requestRef: "
+ System.identityHashCode(delegate)
+ " totalTimeNs: "
+ opTimeNs
+ " start time: "
+ startTimeMs
+ " end time: "
+ System.currentTimeMillis()
+ " client:"
+ clientRequestExecutor.getSocketChannel().socket().getLocalAddress()
+ ":"
+ clientRequestExecutor.getSocketChannel().socket().getLocalPort()
+ " server: "
+ clientRequestExecutor.getSocketChannel()
.socket()
.getRemoteSocketAddress() + " outcome: "
+ debugMsgStr);
}
pool.checkin(destination, clientRequestExecutor);
}
}
|
java
|
private <T> T request(ClientRequest<T> delegate, String operationName) {
long startTimeMs = -1;
long startTimeNs = -1;
if(logger.isDebugEnabled()) {
startTimeMs = System.currentTimeMillis();
}
ClientRequestExecutor clientRequestExecutor = pool.checkout(destination);
String debugMsgStr = "";
startTimeNs = System.nanoTime();
BlockingClientRequest<T> blockingClientRequest = null;
try {
blockingClientRequest = new BlockingClientRequest<T>(delegate, timeoutMs);
clientRequestExecutor.addClientRequest(blockingClientRequest,
timeoutMs,
System.nanoTime() - startTimeNs);
boolean awaitResult = blockingClientRequest.await();
if(awaitResult == false) {
blockingClientRequest.timeOut();
}
if(logger.isDebugEnabled())
debugMsgStr += "success";
return blockingClientRequest.getResult();
} catch(InterruptedException e) {
if(logger.isDebugEnabled())
debugMsgStr += "unreachable: " + e.getMessage();
throw new UnreachableStoreException("Failure in " + operationName + " on "
+ destination + ": " + e.getMessage(), e);
} catch(UnreachableStoreException e) {
clientRequestExecutor.close();
if(logger.isDebugEnabled())
debugMsgStr += "failure: " + e.getMessage();
throw new UnreachableStoreException("Failure in " + operationName + " on "
+ destination + ": " + e.getMessage(), e.getCause());
} finally {
if(blockingClientRequest != null && !blockingClientRequest.isComplete()) {
// close the executor if we timed out
clientRequestExecutor.close();
}
// Record operation time
long opTimeNs = Utils.elapsedTimeNs(startTimeNs, System.nanoTime());
if(stats != null) {
stats.recordSyncOpTimeNs(destination, opTimeNs);
}
if(logger.isDebugEnabled()) {
logger.debug("Sync request end, type: "
+ operationName
+ " requestRef: "
+ System.identityHashCode(delegate)
+ " totalTimeNs: "
+ opTimeNs
+ " start time: "
+ startTimeMs
+ " end time: "
+ System.currentTimeMillis()
+ " client:"
+ clientRequestExecutor.getSocketChannel().socket().getLocalAddress()
+ ":"
+ clientRequestExecutor.getSocketChannel().socket().getLocalPort()
+ " server: "
+ clientRequestExecutor.getSocketChannel()
.socket()
.getRemoteSocketAddress() + " outcome: "
+ debugMsgStr);
}
pool.checkin(destination, clientRequestExecutor);
}
}
|
[
"private",
"<",
"T",
">",
"T",
"request",
"(",
"ClientRequest",
"<",
"T",
">",
"delegate",
",",
"String",
"operationName",
")",
"{",
"long",
"startTimeMs",
"=",
"-",
"1",
";",
"long",
"startTimeNs",
"=",
"-",
"1",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"startTimeMs",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"}",
"ClientRequestExecutor",
"clientRequestExecutor",
"=",
"pool",
".",
"checkout",
"(",
"destination",
")",
";",
"String",
"debugMsgStr",
"=",
"\"\"",
";",
"startTimeNs",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"BlockingClientRequest",
"<",
"T",
">",
"blockingClientRequest",
"=",
"null",
";",
"try",
"{",
"blockingClientRequest",
"=",
"new",
"BlockingClientRequest",
"<",
"T",
">",
"(",
"delegate",
",",
"timeoutMs",
")",
";",
"clientRequestExecutor",
".",
"addClientRequest",
"(",
"blockingClientRequest",
",",
"timeoutMs",
",",
"System",
".",
"nanoTime",
"(",
")",
"-",
"startTimeNs",
")",
";",
"boolean",
"awaitResult",
"=",
"blockingClientRequest",
".",
"await",
"(",
")",
";",
"if",
"(",
"awaitResult",
"==",
"false",
")",
"{",
"blockingClientRequest",
".",
"timeOut",
"(",
")",
";",
"}",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"debugMsgStr",
"+=",
"\"success\"",
";",
"return",
"blockingClientRequest",
".",
"getResult",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"debugMsgStr",
"+=",
"\"unreachable: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"UnreachableStoreException",
"(",
"\"Failure in \"",
"+",
"operationName",
"+",
"\" on \"",
"+",
"destination",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"UnreachableStoreException",
"e",
")",
"{",
"clientRequestExecutor",
".",
"close",
"(",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"debugMsgStr",
"+=",
"\"failure: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"UnreachableStoreException",
"(",
"\"Failure in \"",
"+",
"operationName",
"+",
"\" on \"",
"+",
"destination",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
".",
"getCause",
"(",
")",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"blockingClientRequest",
"!=",
"null",
"&&",
"!",
"blockingClientRequest",
".",
"isComplete",
"(",
")",
")",
"{",
"// close the executor if we timed out",
"clientRequestExecutor",
".",
"close",
"(",
")",
";",
"}",
"// Record operation time",
"long",
"opTimeNs",
"=",
"Utils",
".",
"elapsedTimeNs",
"(",
"startTimeNs",
",",
"System",
".",
"nanoTime",
"(",
")",
")",
";",
"if",
"(",
"stats",
"!=",
"null",
")",
"{",
"stats",
".",
"recordSyncOpTimeNs",
"(",
"destination",
",",
"opTimeNs",
")",
";",
"}",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Sync request end, type: \"",
"+",
"operationName",
"+",
"\" requestRef: \"",
"+",
"System",
".",
"identityHashCode",
"(",
"delegate",
")",
"+",
"\" totalTimeNs: \"",
"+",
"opTimeNs",
"+",
"\" start time: \"",
"+",
"startTimeMs",
"+",
"\" end time: \"",
"+",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"\" client:\"",
"+",
"clientRequestExecutor",
".",
"getSocketChannel",
"(",
")",
".",
"socket",
"(",
")",
".",
"getLocalAddress",
"(",
")",
"+",
"\":\"",
"+",
"clientRequestExecutor",
".",
"getSocketChannel",
"(",
")",
".",
"socket",
"(",
")",
".",
"getLocalPort",
"(",
")",
"+",
"\" server: \"",
"+",
"clientRequestExecutor",
".",
"getSocketChannel",
"(",
")",
".",
"socket",
"(",
")",
".",
"getRemoteSocketAddress",
"(",
")",
"+",
"\" outcome: \"",
"+",
"debugMsgStr",
")",
";",
"}",
"pool",
".",
"checkin",
"(",
"destination",
",",
"clientRequestExecutor",
")",
";",
"}",
"}"
] |
This method handles submitting and then waiting for the request from the
server. It uses the ClientRequest API to actually write the request and
then read back the response. This implementation will block for a
response from the server.
@param <T> Return type
@param clientRequest ClientRequest implementation used to write the
request and read the response
@param operationName Simple string representing the type of request
@return Data returned by the individual requests
|
[
"This",
"method",
"handles",
"submitting",
"and",
"then",
"waiting",
"for",
"the",
"request",
"from",
"the",
"server",
".",
"It",
"uses",
"the",
"ClientRequest",
"API",
"to",
"actually",
"write",
"the",
"request",
"and",
"then",
"read",
"back",
"the",
"response",
".",
"This",
"implementation",
"will",
"block",
"for",
"a",
"response",
"from",
"the",
"server",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/socket/SocketStore.java#L271-L349
|
161,071 |
voldemort/voldemort
|
src/java/voldemort/store/socket/SocketStore.java
|
SocketStore.requestAsync
|
private <T> void requestAsync(ClientRequest<T> delegate,
NonblockingStoreCallback callback,
long timeoutMs,
String operationName) {
pool.submitAsync(this.destination, delegate, callback, timeoutMs, operationName);
}
|
java
|
private <T> void requestAsync(ClientRequest<T> delegate,
NonblockingStoreCallback callback,
long timeoutMs,
String operationName) {
pool.submitAsync(this.destination, delegate, callback, timeoutMs, operationName);
}
|
[
"private",
"<",
"T",
">",
"void",
"requestAsync",
"(",
"ClientRequest",
"<",
"T",
">",
"delegate",
",",
"NonblockingStoreCallback",
"callback",
",",
"long",
"timeoutMs",
",",
"String",
"operationName",
")",
"{",
"pool",
".",
"submitAsync",
"(",
"this",
".",
"destination",
",",
"delegate",
",",
"callback",
",",
"timeoutMs",
",",
"operationName",
")",
";",
"}"
] |
This method handles submitting and then waiting for the request from the
server. It uses the ClientRequest API to actually write the request and
then read back the response. This implementation will not block for a
response from the server.
@param <T> Return type
@param clientRequest ClientRequest implementation used to write the
request and read the response
@param operationName Simple string representing the type of request
@return Data returned by the individual requests
|
[
"This",
"method",
"handles",
"submitting",
"and",
"then",
"waiting",
"for",
"the",
"request",
"from",
"the",
"server",
".",
"It",
"uses",
"the",
"ClientRequest",
"API",
"to",
"actually",
"write",
"the",
"request",
"and",
"then",
"read",
"back",
"the",
"response",
".",
"This",
"implementation",
"will",
"not",
"block",
"for",
"a",
"response",
"from",
"the",
"server",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/socket/SocketStore.java#L366-L371
|
161,072 |
voldemort/voldemort
|
src/java/voldemort/store/stats/StreamingStats.java
|
StreamingStats.getAvgFetchKeysNetworkTimeMs
|
@JmxGetter(name = "avgFetchKeysNetworkTimeMs", description = "average time spent on network, for fetch keys")
public double getAvgFetchKeysNetworkTimeMs() {
return networkTimeCounterMap.get(Operation.FETCH_KEYS).getAvgEventValue() / Time.NS_PER_MS;
}
|
java
|
@JmxGetter(name = "avgFetchKeysNetworkTimeMs", description = "average time spent on network, for fetch keys")
public double getAvgFetchKeysNetworkTimeMs() {
return networkTimeCounterMap.get(Operation.FETCH_KEYS).getAvgEventValue() / Time.NS_PER_MS;
}
|
[
"@",
"JmxGetter",
"(",
"name",
"=",
"\"avgFetchKeysNetworkTimeMs\"",
",",
"description",
"=",
"\"average time spent on network, for fetch keys\"",
")",
"public",
"double",
"getAvgFetchKeysNetworkTimeMs",
"(",
")",
"{",
"return",
"networkTimeCounterMap",
".",
"get",
"(",
"Operation",
".",
"FETCH_KEYS",
")",
".",
"getAvgEventValue",
"(",
")",
"/",
"Time",
".",
"NS_PER_MS",
";",
"}"
] |
Mbeans for FETCH_KEYS
|
[
"Mbeans",
"for",
"FETCH_KEYS"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/StreamingStats.java#L118-L121
|
161,073 |
voldemort/voldemort
|
src/java/voldemort/store/stats/StreamingStats.java
|
StreamingStats.getAvgFetchEntriesNetworkTimeMs
|
@JmxGetter(name = "avgFetchEntriesNetworkTimeMs", description = "average time spent on network, for streaming operations")
public double getAvgFetchEntriesNetworkTimeMs() {
return networkTimeCounterMap.get(Operation.FETCH_ENTRIES).getAvgEventValue()
/ Time.NS_PER_MS;
}
|
java
|
@JmxGetter(name = "avgFetchEntriesNetworkTimeMs", description = "average time spent on network, for streaming operations")
public double getAvgFetchEntriesNetworkTimeMs() {
return networkTimeCounterMap.get(Operation.FETCH_ENTRIES).getAvgEventValue()
/ Time.NS_PER_MS;
}
|
[
"@",
"JmxGetter",
"(",
"name",
"=",
"\"avgFetchEntriesNetworkTimeMs\"",
",",
"description",
"=",
"\"average time spent on network, for streaming operations\"",
")",
"public",
"double",
"getAvgFetchEntriesNetworkTimeMs",
"(",
")",
"{",
"return",
"networkTimeCounterMap",
".",
"get",
"(",
"Operation",
".",
"FETCH_ENTRIES",
")",
".",
"getAvgEventValue",
"(",
")",
"/",
"Time",
".",
"NS_PER_MS",
";",
"}"
] |
Mbeans for FETCH_ENTRIES
|
[
"Mbeans",
"for",
"FETCH_ENTRIES"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/StreamingStats.java#L139-L143
|
161,074 |
voldemort/voldemort
|
src/java/voldemort/store/stats/StreamingStats.java
|
StreamingStats.getAvgUpdateEntriesNetworkTimeMs
|
@JmxGetter(name = "avgUpdateEntriesNetworkTimeMs", description = "average time spent on network, for streaming operations")
public double getAvgUpdateEntriesNetworkTimeMs() {
return networkTimeCounterMap.get(Operation.UPDATE_ENTRIES).getAvgEventValue()
/ Time.NS_PER_MS;
}
|
java
|
@JmxGetter(name = "avgUpdateEntriesNetworkTimeMs", description = "average time spent on network, for streaming operations")
public double getAvgUpdateEntriesNetworkTimeMs() {
return networkTimeCounterMap.get(Operation.UPDATE_ENTRIES).getAvgEventValue()
/ Time.NS_PER_MS;
}
|
[
"@",
"JmxGetter",
"(",
"name",
"=",
"\"avgUpdateEntriesNetworkTimeMs\"",
",",
"description",
"=",
"\"average time spent on network, for streaming operations\"",
")",
"public",
"double",
"getAvgUpdateEntriesNetworkTimeMs",
"(",
")",
"{",
"return",
"networkTimeCounterMap",
".",
"get",
"(",
"Operation",
".",
"UPDATE_ENTRIES",
")",
".",
"getAvgEventValue",
"(",
")",
"/",
"Time",
".",
"NS_PER_MS",
";",
"}"
] |
Mbeans for UPDATE_ENTRIES
|
[
"Mbeans",
"for",
"UPDATE_ENTRIES"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/StreamingStats.java#L168-L172
|
161,075 |
voldemort/voldemort
|
src/java/voldemort/store/stats/StreamingStats.java
|
StreamingStats.getAvgSlopUpdateNetworkTimeMs
|
@JmxGetter(name = "avgSlopUpdateNetworkTimeMs", description = "average time spent on network, for streaming operations")
public double getAvgSlopUpdateNetworkTimeMs() {
return networkTimeCounterMap.get(Operation.SLOP_UPDATE).getAvgEventValue() / Time.NS_PER_MS;
}
|
java
|
@JmxGetter(name = "avgSlopUpdateNetworkTimeMs", description = "average time spent on network, for streaming operations")
public double getAvgSlopUpdateNetworkTimeMs() {
return networkTimeCounterMap.get(Operation.SLOP_UPDATE).getAvgEventValue() / Time.NS_PER_MS;
}
|
[
"@",
"JmxGetter",
"(",
"name",
"=",
"\"avgSlopUpdateNetworkTimeMs\"",
",",
"description",
"=",
"\"average time spent on network, for streaming operations\"",
")",
"public",
"double",
"getAvgSlopUpdateNetworkTimeMs",
"(",
")",
"{",
"return",
"networkTimeCounterMap",
".",
"get",
"(",
"Operation",
".",
"SLOP_UPDATE",
")",
".",
"getAvgEventValue",
"(",
")",
"/",
"Time",
".",
"NS_PER_MS",
";",
"}"
] |
Mbeans for SLOP_UPDATE
|
[
"Mbeans",
"for",
"SLOP_UPDATE"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/StreamingStats.java#L186-L189
|
161,076 |
voldemort/voldemort
|
src/java/voldemort/serialization/SerializationUtils.java
|
SerializationUtils.getJavaClassFromSchemaInfo
|
public static String getJavaClassFromSchemaInfo(String schemaInfo) {
final String ONLY_JAVA_CLIENTS_SUPPORTED = "Only Java clients are supported currently, so the format of the schema-info should be: <schema-info>java=foo.Bar</schema-info> where foo.Bar is the fully qualified name of the message.";
if(StringUtils.isEmpty(schemaInfo))
throw new IllegalArgumentException("This serializer requires a non-empty schema-info.");
String[] languagePairs = StringUtils.split(schemaInfo, ',');
if(languagePairs.length > 1)
throw new IllegalArgumentException(ONLY_JAVA_CLIENTS_SUPPORTED);
String[] javaPair = StringUtils.split(languagePairs[0], '=');
if(javaPair.length != 2 || !javaPair[0].trim().equals("java"))
throw new IllegalArgumentException(ONLY_JAVA_CLIENTS_SUPPORTED);
return javaPair[1].trim();
}
|
java
|
public static String getJavaClassFromSchemaInfo(String schemaInfo) {
final String ONLY_JAVA_CLIENTS_SUPPORTED = "Only Java clients are supported currently, so the format of the schema-info should be: <schema-info>java=foo.Bar</schema-info> where foo.Bar is the fully qualified name of the message.";
if(StringUtils.isEmpty(schemaInfo))
throw new IllegalArgumentException("This serializer requires a non-empty schema-info.");
String[] languagePairs = StringUtils.split(schemaInfo, ',');
if(languagePairs.length > 1)
throw new IllegalArgumentException(ONLY_JAVA_CLIENTS_SUPPORTED);
String[] javaPair = StringUtils.split(languagePairs[0], '=');
if(javaPair.length != 2 || !javaPair[0].trim().equals("java"))
throw new IllegalArgumentException(ONLY_JAVA_CLIENTS_SUPPORTED);
return javaPair[1].trim();
}
|
[
"public",
"static",
"String",
"getJavaClassFromSchemaInfo",
"(",
"String",
"schemaInfo",
")",
"{",
"final",
"String",
"ONLY_JAVA_CLIENTS_SUPPORTED",
"=",
"\"Only Java clients are supported currently, so the format of the schema-info should be: <schema-info>java=foo.Bar</schema-info> where foo.Bar is the fully qualified name of the message.\"",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"schemaInfo",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"This serializer requires a non-empty schema-info.\"",
")",
";",
"String",
"[",
"]",
"languagePairs",
"=",
"StringUtils",
".",
"split",
"(",
"schemaInfo",
",",
"'",
"'",
")",
";",
"if",
"(",
"languagePairs",
".",
"length",
">",
"1",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"ONLY_JAVA_CLIENTS_SUPPORTED",
")",
";",
"String",
"[",
"]",
"javaPair",
"=",
"StringUtils",
".",
"split",
"(",
"languagePairs",
"[",
"0",
"]",
",",
"'",
"'",
")",
";",
"if",
"(",
"javaPair",
".",
"length",
"!=",
"2",
"||",
"!",
"javaPair",
"[",
"0",
"]",
".",
"trim",
"(",
")",
".",
"equals",
"(",
"\"java\"",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"ONLY_JAVA_CLIENTS_SUPPORTED",
")",
";",
"return",
"javaPair",
"[",
"1",
"]",
".",
"trim",
"(",
")",
";",
"}"
] |
Extracts the java class name from the schema info
@param schemaInfo the schema info, a string like: java=java.lang.String
@return the name of the class extracted from the schema info
|
[
"Extracts",
"the",
"java",
"class",
"name",
"from",
"the",
"schema",
"info"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/serialization/SerializationUtils.java#L35-L50
|
161,077 |
voldemort/voldemort
|
src/java/voldemort/utils/StoreDefinitionUtils.java
|
StoreDefinitionUtils.filterStores
|
public static List<StoreDefinition> filterStores(List<StoreDefinition> storeDefs,
final boolean isReadOnly) {
List<StoreDefinition> filteredStores = Lists.newArrayList();
for(StoreDefinition storeDef: storeDefs) {
if(storeDef.getType().equals(ReadOnlyStorageConfiguration.TYPE_NAME) == isReadOnly) {
filteredStores.add(storeDef);
}
}
return filteredStores;
}
|
java
|
public static List<StoreDefinition> filterStores(List<StoreDefinition> storeDefs,
final boolean isReadOnly) {
List<StoreDefinition> filteredStores = Lists.newArrayList();
for(StoreDefinition storeDef: storeDefs) {
if(storeDef.getType().equals(ReadOnlyStorageConfiguration.TYPE_NAME) == isReadOnly) {
filteredStores.add(storeDef);
}
}
return filteredStores;
}
|
[
"public",
"static",
"List",
"<",
"StoreDefinition",
">",
"filterStores",
"(",
"List",
"<",
"StoreDefinition",
">",
"storeDefs",
",",
"final",
"boolean",
"isReadOnly",
")",
"{",
"List",
"<",
"StoreDefinition",
">",
"filteredStores",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"for",
"(",
"StoreDefinition",
"storeDef",
":",
"storeDefs",
")",
"{",
"if",
"(",
"storeDef",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"ReadOnlyStorageConfiguration",
".",
"TYPE_NAME",
")",
"==",
"isReadOnly",
")",
"{",
"filteredStores",
".",
"add",
"(",
"storeDef",
")",
";",
"}",
"}",
"return",
"filteredStores",
";",
"}"
] |
Given a list of store definitions, filters the list depending on the
boolean
@param storeDefs Complete list of store definitions
@param isReadOnly Boolean indicating whether filter on read-only or not?
@return List of filtered store definition
|
[
"Given",
"a",
"list",
"of",
"store",
"definitions",
"filters",
"the",
"list",
"depending",
"on",
"the",
"boolean"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/StoreDefinitionUtils.java#L57-L66
|
161,078 |
voldemort/voldemort
|
src/java/voldemort/utils/StoreDefinitionUtils.java
|
StoreDefinitionUtils.getStoreNames
|
public static List<String> getStoreNames(List<StoreDefinition> storeDefList) {
List<String> storeList = new ArrayList<String>();
for(StoreDefinition def: storeDefList) {
storeList.add(def.getName());
}
return storeList;
}
|
java
|
public static List<String> getStoreNames(List<StoreDefinition> storeDefList) {
List<String> storeList = new ArrayList<String>();
for(StoreDefinition def: storeDefList) {
storeList.add(def.getName());
}
return storeList;
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"getStoreNames",
"(",
"List",
"<",
"StoreDefinition",
">",
"storeDefList",
")",
"{",
"List",
"<",
"String",
">",
"storeList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"StoreDefinition",
"def",
":",
"storeDefList",
")",
"{",
"storeList",
".",
"add",
"(",
"def",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"storeList",
";",
"}"
] |
Given a list of store definitions return a list of store names
@param storeDefList The list of store definitions
@return Returns a list of store names
|
[
"Given",
"a",
"list",
"of",
"store",
"definitions",
"return",
"a",
"list",
"of",
"store",
"names"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/StoreDefinitionUtils.java#L74-L80
|
161,079 |
voldemort/voldemort
|
src/java/voldemort/utils/StoreDefinitionUtils.java
|
StoreDefinitionUtils.getStoreNamesSet
|
public static Set<String> getStoreNamesSet(List<StoreDefinition> storeDefList) {
HashSet<String> storeSet = new HashSet<String>();
for(StoreDefinition def: storeDefList) {
storeSet.add(def.getName());
}
return storeSet;
}
|
java
|
public static Set<String> getStoreNamesSet(List<StoreDefinition> storeDefList) {
HashSet<String> storeSet = new HashSet<String>();
for(StoreDefinition def: storeDefList) {
storeSet.add(def.getName());
}
return storeSet;
}
|
[
"public",
"static",
"Set",
"<",
"String",
">",
"getStoreNamesSet",
"(",
"List",
"<",
"StoreDefinition",
">",
"storeDefList",
")",
"{",
"HashSet",
"<",
"String",
">",
"storeSet",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"StoreDefinition",
"def",
":",
"storeDefList",
")",
"{",
"storeSet",
".",
"add",
"(",
"def",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"storeSet",
";",
"}"
] |
Given a list of store definitions return a set of store names
@param storeDefList The list of store definitions
@return Returns a set of store names
|
[
"Given",
"a",
"list",
"of",
"store",
"definitions",
"return",
"a",
"set",
"of",
"store",
"names"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/StoreDefinitionUtils.java#L88-L94
|
161,080 |
voldemort/voldemort
|
src/java/voldemort/utils/StoreDefinitionUtils.java
|
StoreDefinitionUtils.getUniqueStoreDefinitionsWithCounts
|
public static HashMap<StoreDefinition, Integer> getUniqueStoreDefinitionsWithCounts(List<StoreDefinition> storeDefs) {
HashMap<StoreDefinition, Integer> uniqueStoreDefs = Maps.newHashMap();
for(StoreDefinition storeDef: storeDefs) {
if(uniqueStoreDefs.isEmpty()) {
uniqueStoreDefs.put(storeDef, 1);
} else {
StoreDefinition sameStore = null;
// Go over all the other stores to find if this is unique
for(StoreDefinition uniqueStoreDef: uniqueStoreDefs.keySet()) {
if(uniqueStoreDef.getReplicationFactor() == storeDef.getReplicationFactor()
&& uniqueStoreDef.getRoutingStrategyType()
.compareTo(storeDef.getRoutingStrategyType()) == 0) {
// Further check for the zone routing case
if(uniqueStoreDef.getRoutingStrategyType()
.compareTo(RoutingStrategyType.ZONE_STRATEGY) == 0) {
boolean zonesSame = true;
for(int zoneId: uniqueStoreDef.getZoneReplicationFactor().keySet()) {
if(storeDef.getZoneReplicationFactor().get(zoneId) == null
|| storeDef.getZoneReplicationFactor().get(zoneId) != uniqueStoreDef.getZoneReplicationFactor()
.get(zoneId)) {
zonesSame = false;
break;
}
}
if(zonesSame) {
sameStore = uniqueStoreDef;
}
} else {
sameStore = uniqueStoreDef;
}
if(sameStore != null) {
// Bump up the count
int currentCount = uniqueStoreDefs.get(sameStore);
uniqueStoreDefs.put(sameStore, currentCount + 1);
break;
}
}
}
if(sameStore == null) {
// New store
uniqueStoreDefs.put(storeDef, 1);
}
}
}
return uniqueStoreDefs;
}
|
java
|
public static HashMap<StoreDefinition, Integer> getUniqueStoreDefinitionsWithCounts(List<StoreDefinition> storeDefs) {
HashMap<StoreDefinition, Integer> uniqueStoreDefs = Maps.newHashMap();
for(StoreDefinition storeDef: storeDefs) {
if(uniqueStoreDefs.isEmpty()) {
uniqueStoreDefs.put(storeDef, 1);
} else {
StoreDefinition sameStore = null;
// Go over all the other stores to find if this is unique
for(StoreDefinition uniqueStoreDef: uniqueStoreDefs.keySet()) {
if(uniqueStoreDef.getReplicationFactor() == storeDef.getReplicationFactor()
&& uniqueStoreDef.getRoutingStrategyType()
.compareTo(storeDef.getRoutingStrategyType()) == 0) {
// Further check for the zone routing case
if(uniqueStoreDef.getRoutingStrategyType()
.compareTo(RoutingStrategyType.ZONE_STRATEGY) == 0) {
boolean zonesSame = true;
for(int zoneId: uniqueStoreDef.getZoneReplicationFactor().keySet()) {
if(storeDef.getZoneReplicationFactor().get(zoneId) == null
|| storeDef.getZoneReplicationFactor().get(zoneId) != uniqueStoreDef.getZoneReplicationFactor()
.get(zoneId)) {
zonesSame = false;
break;
}
}
if(zonesSame) {
sameStore = uniqueStoreDef;
}
} else {
sameStore = uniqueStoreDef;
}
if(sameStore != null) {
// Bump up the count
int currentCount = uniqueStoreDefs.get(sameStore);
uniqueStoreDefs.put(sameStore, currentCount + 1);
break;
}
}
}
if(sameStore == null) {
// New store
uniqueStoreDefs.put(storeDef, 1);
}
}
}
return uniqueStoreDefs;
}
|
[
"public",
"static",
"HashMap",
"<",
"StoreDefinition",
",",
"Integer",
">",
"getUniqueStoreDefinitionsWithCounts",
"(",
"List",
"<",
"StoreDefinition",
">",
"storeDefs",
")",
"{",
"HashMap",
"<",
"StoreDefinition",
",",
"Integer",
">",
"uniqueStoreDefs",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"for",
"(",
"StoreDefinition",
"storeDef",
":",
"storeDefs",
")",
"{",
"if",
"(",
"uniqueStoreDefs",
".",
"isEmpty",
"(",
")",
")",
"{",
"uniqueStoreDefs",
".",
"put",
"(",
"storeDef",
",",
"1",
")",
";",
"}",
"else",
"{",
"StoreDefinition",
"sameStore",
"=",
"null",
";",
"// Go over all the other stores to find if this is unique",
"for",
"(",
"StoreDefinition",
"uniqueStoreDef",
":",
"uniqueStoreDefs",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"uniqueStoreDef",
".",
"getReplicationFactor",
"(",
")",
"==",
"storeDef",
".",
"getReplicationFactor",
"(",
")",
"&&",
"uniqueStoreDef",
".",
"getRoutingStrategyType",
"(",
")",
".",
"compareTo",
"(",
"storeDef",
".",
"getRoutingStrategyType",
"(",
")",
")",
"==",
"0",
")",
"{",
"// Further check for the zone routing case",
"if",
"(",
"uniqueStoreDef",
".",
"getRoutingStrategyType",
"(",
")",
".",
"compareTo",
"(",
"RoutingStrategyType",
".",
"ZONE_STRATEGY",
")",
"==",
"0",
")",
"{",
"boolean",
"zonesSame",
"=",
"true",
";",
"for",
"(",
"int",
"zoneId",
":",
"uniqueStoreDef",
".",
"getZoneReplicationFactor",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"storeDef",
".",
"getZoneReplicationFactor",
"(",
")",
".",
"get",
"(",
"zoneId",
")",
"==",
"null",
"||",
"storeDef",
".",
"getZoneReplicationFactor",
"(",
")",
".",
"get",
"(",
"zoneId",
")",
"!=",
"uniqueStoreDef",
".",
"getZoneReplicationFactor",
"(",
")",
".",
"get",
"(",
"zoneId",
")",
")",
"{",
"zonesSame",
"=",
"false",
";",
"break",
";",
"}",
"}",
"if",
"(",
"zonesSame",
")",
"{",
"sameStore",
"=",
"uniqueStoreDef",
";",
"}",
"}",
"else",
"{",
"sameStore",
"=",
"uniqueStoreDef",
";",
"}",
"if",
"(",
"sameStore",
"!=",
"null",
")",
"{",
"// Bump up the count",
"int",
"currentCount",
"=",
"uniqueStoreDefs",
".",
"get",
"(",
"sameStore",
")",
";",
"uniqueStoreDefs",
".",
"put",
"(",
"sameStore",
",",
"currentCount",
"+",
"1",
")",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"sameStore",
"==",
"null",
")",
"{",
"// New store",
"uniqueStoreDefs",
".",
"put",
"(",
"storeDef",
",",
"1",
")",
";",
"}",
"}",
"}",
"return",
"uniqueStoreDefs",
";",
"}"
] |
Given a list of store definitions, find out and return a map of similar
store definitions + count of them
@param storeDefs All store definitions
@return Map of a unique store definition + counts
|
[
"Given",
"a",
"list",
"of",
"store",
"definitions",
"find",
"out",
"and",
"return",
"a",
"map",
"of",
"similar",
"store",
"definitions",
"+",
"count",
"of",
"them"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/StoreDefinitionUtils.java#L127-L178
|
161,081 |
voldemort/voldemort
|
src/java/voldemort/utils/StoreDefinitionUtils.java
|
StoreDefinitionUtils.isAvroSchema
|
public static boolean isAvroSchema(String serializerName) {
if(serializerName.equals(AVRO_GENERIC_VERSIONED_TYPE_NAME)
|| serializerName.equals(AVRO_GENERIC_TYPE_NAME)
|| serializerName.equals(AVRO_REFLECTIVE_TYPE_NAME)
|| serializerName.equals(AVRO_SPECIFIC_TYPE_NAME)) {
return true;
} else {
return false;
}
}
|
java
|
public static boolean isAvroSchema(String serializerName) {
if(serializerName.equals(AVRO_GENERIC_VERSIONED_TYPE_NAME)
|| serializerName.equals(AVRO_GENERIC_TYPE_NAME)
|| serializerName.equals(AVRO_REFLECTIVE_TYPE_NAME)
|| serializerName.equals(AVRO_SPECIFIC_TYPE_NAME)) {
return true;
} else {
return false;
}
}
|
[
"public",
"static",
"boolean",
"isAvroSchema",
"(",
"String",
"serializerName",
")",
"{",
"if",
"(",
"serializerName",
".",
"equals",
"(",
"AVRO_GENERIC_VERSIONED_TYPE_NAME",
")",
"||",
"serializerName",
".",
"equals",
"(",
"AVRO_GENERIC_TYPE_NAME",
")",
"||",
"serializerName",
".",
"equals",
"(",
"AVRO_REFLECTIVE_TYPE_NAME",
")",
"||",
"serializerName",
".",
"equals",
"(",
"AVRO_SPECIFIC_TYPE_NAME",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Determine whether or not a given serializedr is "AVRO" based
@param serializerName
@return
|
[
"Determine",
"whether",
"or",
"not",
"a",
"given",
"serializedr",
"is",
"AVRO",
"based"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/StoreDefinitionUtils.java#L186-L195
|
161,082 |
voldemort/voldemort
|
src/java/voldemort/utils/StoreDefinitionUtils.java
|
StoreDefinitionUtils.validateIfAvroSchema
|
private static void validateIfAvroSchema(SerializerDefinition serializerDef) {
if(serializerDef.getName().equals(AVRO_GENERIC_VERSIONED_TYPE_NAME)
|| serializerDef.getName().equals(AVRO_GENERIC_TYPE_NAME)) {
SchemaEvolutionValidator.validateAllAvroSchemas(serializerDef);
// check backwards compatibility if needed
if(serializerDef.getName().equals(AVRO_GENERIC_VERSIONED_TYPE_NAME)) {
SchemaEvolutionValidator.checkSchemaCompatibility(serializerDef);
}
}
}
|
java
|
private static void validateIfAvroSchema(SerializerDefinition serializerDef) {
if(serializerDef.getName().equals(AVRO_GENERIC_VERSIONED_TYPE_NAME)
|| serializerDef.getName().equals(AVRO_GENERIC_TYPE_NAME)) {
SchemaEvolutionValidator.validateAllAvroSchemas(serializerDef);
// check backwards compatibility if needed
if(serializerDef.getName().equals(AVRO_GENERIC_VERSIONED_TYPE_NAME)) {
SchemaEvolutionValidator.checkSchemaCompatibility(serializerDef);
}
}
}
|
[
"private",
"static",
"void",
"validateIfAvroSchema",
"(",
"SerializerDefinition",
"serializerDef",
")",
"{",
"if",
"(",
"serializerDef",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"AVRO_GENERIC_VERSIONED_TYPE_NAME",
")",
"||",
"serializerDef",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"AVRO_GENERIC_TYPE_NAME",
")",
")",
"{",
"SchemaEvolutionValidator",
".",
"validateAllAvroSchemas",
"(",
"serializerDef",
")",
";",
"// check backwards compatibility if needed",
"if",
"(",
"serializerDef",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"AVRO_GENERIC_VERSIONED_TYPE_NAME",
")",
")",
"{",
"SchemaEvolutionValidator",
".",
"checkSchemaCompatibility",
"(",
"serializerDef",
")",
";",
"}",
"}",
"}"
] |
If provided with an AVRO schema, validates it and checks if there are
backwards compatible.
TODO should probably place some similar checks for other serializer types
as well?
@param serializerDef
|
[
"If",
"provided",
"with",
"an",
"AVRO",
"schema",
"validates",
"it",
"and",
"checks",
"if",
"there",
"are",
"backwards",
"compatible",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/StoreDefinitionUtils.java#L206-L215
|
161,083 |
voldemort/voldemort
|
src/java/voldemort/store/stats/Histogram.java
|
Histogram.insert
|
public synchronized void insert(long data) {
resetIfNeeded();
long index = 0;
if(data >= this.upperBound) {
index = nBuckets - 1;
} else if(data < 0) {
logger.error(data + " can't be bucketed because it is negative!");
return;
} else {
index = data / step;
}
if(index < 0 || index >= nBuckets) {
// This should be dead code. Defending against code changes in
// future.
logger.error(data + " can't be bucketed because index is not in range [0,nBuckets).");
return;
}
buckets[(int) index]++;
sum += data;
size++;
}
|
java
|
public synchronized void insert(long data) {
resetIfNeeded();
long index = 0;
if(data >= this.upperBound) {
index = nBuckets - 1;
} else if(data < 0) {
logger.error(data + " can't be bucketed because it is negative!");
return;
} else {
index = data / step;
}
if(index < 0 || index >= nBuckets) {
// This should be dead code. Defending against code changes in
// future.
logger.error(data + " can't be bucketed because index is not in range [0,nBuckets).");
return;
}
buckets[(int) index]++;
sum += data;
size++;
}
|
[
"public",
"synchronized",
"void",
"insert",
"(",
"long",
"data",
")",
"{",
"resetIfNeeded",
"(",
")",
";",
"long",
"index",
"=",
"0",
";",
"if",
"(",
"data",
">=",
"this",
".",
"upperBound",
")",
"{",
"index",
"=",
"nBuckets",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"data",
"<",
"0",
")",
"{",
"logger",
".",
"error",
"(",
"data",
"+",
"\" can't be bucketed because it is negative!\"",
")",
";",
"return",
";",
"}",
"else",
"{",
"index",
"=",
"data",
"/",
"step",
";",
"}",
"if",
"(",
"index",
"<",
"0",
"||",
"index",
">=",
"nBuckets",
")",
"{",
"// This should be dead code. Defending against code changes in",
"// future.",
"logger",
".",
"error",
"(",
"data",
"+",
"\" can't be bucketed because index is not in range [0,nBuckets).\"",
")",
";",
"return",
";",
"}",
"buckets",
"[",
"(",
"int",
")",
"index",
"]",
"++",
";",
"sum",
"+=",
"data",
";",
"size",
"++",
";",
"}"
] |
Insert a value into the right bucket of the histogram. If the value is
larger than any bound, insert into the last bucket. If the value is less
than zero, then ignore it.
@param data The value to insert into the histogram
|
[
"Insert",
"a",
"value",
"into",
"the",
"right",
"bucket",
"of",
"the",
"histogram",
".",
"If",
"the",
"value",
"is",
"larger",
"than",
"any",
"bound",
"insert",
"into",
"the",
"last",
"bucket",
".",
"If",
"the",
"value",
"is",
"less",
"than",
"zero",
"then",
"ignore",
"it",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/stats/Histogram.java#L101-L121
|
161,084 |
voldemort/voldemort
|
src/java/voldemort/store/rebalancing/RebootstrappingStore.java
|
RebootstrappingStore.checkAndAddNodeStore
|
private void checkAndAddNodeStore() {
for(Node node: metadata.getCluster().getNodes()) {
if(!routedStore.getInnerStores().containsKey(node.getId())) {
if(!storeRepository.hasNodeStore(getName(), node.getId())) {
storeRepository.addNodeStore(node.getId(), createNodeStore(node));
}
routedStore.getInnerStores().put(node.getId(),
storeRepository.getNodeStore(getName(),
node.getId()));
}
}
}
|
java
|
private void checkAndAddNodeStore() {
for(Node node: metadata.getCluster().getNodes()) {
if(!routedStore.getInnerStores().containsKey(node.getId())) {
if(!storeRepository.hasNodeStore(getName(), node.getId())) {
storeRepository.addNodeStore(node.getId(), createNodeStore(node));
}
routedStore.getInnerStores().put(node.getId(),
storeRepository.getNodeStore(getName(),
node.getId()));
}
}
}
|
[
"private",
"void",
"checkAndAddNodeStore",
"(",
")",
"{",
"for",
"(",
"Node",
"node",
":",
"metadata",
".",
"getCluster",
"(",
")",
".",
"getNodes",
"(",
")",
")",
"{",
"if",
"(",
"!",
"routedStore",
".",
"getInnerStores",
"(",
")",
".",
"containsKey",
"(",
"node",
".",
"getId",
"(",
")",
")",
")",
"{",
"if",
"(",
"!",
"storeRepository",
".",
"hasNodeStore",
"(",
"getName",
"(",
")",
",",
"node",
".",
"getId",
"(",
")",
")",
")",
"{",
"storeRepository",
".",
"addNodeStore",
"(",
"node",
".",
"getId",
"(",
")",
",",
"createNodeStore",
"(",
"node",
")",
")",
";",
"}",
"routedStore",
".",
"getInnerStores",
"(",
")",
".",
"put",
"(",
"node",
".",
"getId",
"(",
")",
",",
"storeRepository",
".",
"getNodeStore",
"(",
"getName",
"(",
")",
",",
"node",
".",
"getId",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] |
Check that all nodes in the new cluster have a corresponding entry in
storeRepository and innerStores. add a NodeStore if not present, is
needed as with rebalancing we can add new nodes on the fly.
|
[
"Check",
"that",
"all",
"nodes",
"in",
"the",
"new",
"cluster",
"have",
"a",
"corresponding",
"entry",
"in",
"storeRepository",
"and",
"innerStores",
".",
"add",
"a",
"NodeStore",
"if",
"not",
"present",
"is",
"needed",
"as",
"with",
"rebalancing",
"we",
"can",
"add",
"new",
"nodes",
"on",
"the",
"fly",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/rebalancing/RebootstrappingStore.java#L93-L104
|
161,085 |
voldemort/voldemort
|
src/java/voldemort/utils/pool/ResourcePoolConfig.java
|
ResourcePoolConfig.setTimeout
|
public ResourcePoolConfig setTimeout(long timeout, TimeUnit unit) {
if(timeout < 0)
throw new IllegalArgumentException("The timeout must be a non-negative number.");
this.timeoutNs = TimeUnit.NANOSECONDS.convert(timeout, unit);
return this;
}
|
java
|
public ResourcePoolConfig setTimeout(long timeout, TimeUnit unit) {
if(timeout < 0)
throw new IllegalArgumentException("The timeout must be a non-negative number.");
this.timeoutNs = TimeUnit.NANOSECONDS.convert(timeout, unit);
return this;
}
|
[
"public",
"ResourcePoolConfig",
"setTimeout",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"if",
"(",
"timeout",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The timeout must be a non-negative number.\"",
")",
";",
"this",
".",
"timeoutNs",
"=",
"TimeUnit",
".",
"NANOSECONDS",
".",
"convert",
"(",
"timeout",
",",
"unit",
")",
";",
"return",
"this",
";",
"}"
] |
The timeout which we block for when a resource is not available
@param timeout The timeout
@param unit The units of the timeout
|
[
"The",
"timeout",
"which",
"we",
"block",
"for",
"when",
"a",
"resource",
"is",
"not",
"available"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/pool/ResourcePoolConfig.java#L59-L64
|
161,086 |
voldemort/voldemort
|
contrib/krati/src/java/voldemort/store/krati/KratiStorageEngine.java
|
KratiStorageEngine.assembleValues
|
private byte[] assembleValues(List<Versioned<byte[]>> values) throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream dataStream = new DataOutputStream(stream);
for(Versioned<byte[]> value: values) {
byte[] object = value.getValue();
dataStream.writeInt(object.length);
dataStream.write(object);
VectorClock clock = (VectorClock) value.getVersion();
dataStream.writeInt(clock.sizeInBytes());
dataStream.write(clock.toBytes());
}
return stream.toByteArray();
}
|
java
|
private byte[] assembleValues(List<Versioned<byte[]>> values) throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream dataStream = new DataOutputStream(stream);
for(Versioned<byte[]> value: values) {
byte[] object = value.getValue();
dataStream.writeInt(object.length);
dataStream.write(object);
VectorClock clock = (VectorClock) value.getVersion();
dataStream.writeInt(clock.sizeInBytes());
dataStream.write(clock.toBytes());
}
return stream.toByteArray();
}
|
[
"private",
"byte",
"[",
"]",
"assembleValues",
"(",
"List",
"<",
"Versioned",
"<",
"byte",
"[",
"]",
">",
">",
"values",
")",
"throws",
"IOException",
"{",
"ByteArrayOutputStream",
"stream",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"DataOutputStream",
"dataStream",
"=",
"new",
"DataOutputStream",
"(",
"stream",
")",
";",
"for",
"(",
"Versioned",
"<",
"byte",
"[",
"]",
">",
"value",
":",
"values",
")",
"{",
"byte",
"[",
"]",
"object",
"=",
"value",
".",
"getValue",
"(",
")",
";",
"dataStream",
".",
"writeInt",
"(",
"object",
".",
"length",
")",
";",
"dataStream",
".",
"write",
"(",
"object",
")",
";",
"VectorClock",
"clock",
"=",
"(",
"VectorClock",
")",
"value",
".",
"getVersion",
"(",
")",
";",
"dataStream",
".",
"writeInt",
"(",
"clock",
".",
"sizeInBytes",
"(",
")",
")",
";",
"dataStream",
".",
"write",
"(",
"clock",
".",
"toBytes",
"(",
")",
")",
";",
"}",
"return",
"stream",
".",
"toByteArray",
"(",
")",
";",
"}"
] |
Store the versioned values
@param values list of versioned bytes
@return the list of versioned values rolled into an array of bytes
|
[
"Store",
"the",
"versioned",
"values"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/contrib/krati/src/java/voldemort/store/krati/KratiStorageEngine.java#L266-L282
|
161,087 |
voldemort/voldemort
|
contrib/krati/src/java/voldemort/store/krati/KratiStorageEngine.java
|
KratiStorageEngine.disassembleValues
|
private List<Versioned<byte[]>> disassembleValues(byte[] values) throws IOException {
if(values == null)
return new ArrayList<Versioned<byte[]>>(0);
List<Versioned<byte[]>> returnList = new ArrayList<Versioned<byte[]>>();
ByteArrayInputStream stream = new ByteArrayInputStream(values);
DataInputStream dataStream = new DataInputStream(stream);
while(dataStream.available() > 0) {
byte[] object = new byte[dataStream.readInt()];
dataStream.read(object);
byte[] clockBytes = new byte[dataStream.readInt()];
dataStream.read(clockBytes);
VectorClock clock = new VectorClock(clockBytes);
returnList.add(new Versioned<byte[]>(object, clock));
}
return returnList;
}
|
java
|
private List<Versioned<byte[]>> disassembleValues(byte[] values) throws IOException {
if(values == null)
return new ArrayList<Versioned<byte[]>>(0);
List<Versioned<byte[]>> returnList = new ArrayList<Versioned<byte[]>>();
ByteArrayInputStream stream = new ByteArrayInputStream(values);
DataInputStream dataStream = new DataInputStream(stream);
while(dataStream.available() > 0) {
byte[] object = new byte[dataStream.readInt()];
dataStream.read(object);
byte[] clockBytes = new byte[dataStream.readInt()];
dataStream.read(clockBytes);
VectorClock clock = new VectorClock(clockBytes);
returnList.add(new Versioned<byte[]>(object, clock));
}
return returnList;
}
|
[
"private",
"List",
"<",
"Versioned",
"<",
"byte",
"[",
"]",
">",
">",
"disassembleValues",
"(",
"byte",
"[",
"]",
"values",
")",
"throws",
"IOException",
"{",
"if",
"(",
"values",
"==",
"null",
")",
"return",
"new",
"ArrayList",
"<",
"Versioned",
"<",
"byte",
"[",
"]",
">",
">",
"(",
"0",
")",
";",
"List",
"<",
"Versioned",
"<",
"byte",
"[",
"]",
">",
">",
"returnList",
"=",
"new",
"ArrayList",
"<",
"Versioned",
"<",
"byte",
"[",
"]",
">",
">",
"(",
")",
";",
"ByteArrayInputStream",
"stream",
"=",
"new",
"ByteArrayInputStream",
"(",
"values",
")",
";",
"DataInputStream",
"dataStream",
"=",
"new",
"DataInputStream",
"(",
"stream",
")",
";",
"while",
"(",
"dataStream",
".",
"available",
"(",
")",
">",
"0",
")",
"{",
"byte",
"[",
"]",
"object",
"=",
"new",
"byte",
"[",
"dataStream",
".",
"readInt",
"(",
")",
"]",
";",
"dataStream",
".",
"read",
"(",
"object",
")",
";",
"byte",
"[",
"]",
"clockBytes",
"=",
"new",
"byte",
"[",
"dataStream",
".",
"readInt",
"(",
")",
"]",
";",
"dataStream",
".",
"read",
"(",
"clockBytes",
")",
";",
"VectorClock",
"clock",
"=",
"new",
"VectorClock",
"(",
"clockBytes",
")",
";",
"returnList",
".",
"add",
"(",
"new",
"Versioned",
"<",
"byte",
"[",
"]",
">",
"(",
"object",
",",
"clock",
")",
")",
";",
"}",
"return",
"returnList",
";",
"}"
] |
Splits up value into multiple versioned values
@param value
@return
@throws IOException
|
[
"Splits",
"up",
"value",
"into",
"multiple",
"versioned",
"values"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/contrib/krati/src/java/voldemort/store/krati/KratiStorageEngine.java#L291-L312
|
161,088 |
voldemort/voldemort
|
src/java/voldemort/server/protocol/admin/PartitionScanFetchStreamRequestHandler.java
|
PartitionScanFetchStreamRequestHandler.statusInfoMessage
|
protected void statusInfoMessage(final String tag) {
if(logger.isInfoEnabled()) {
logger.info(tag + " : [partition: " + currentPartition + ", partitionFetched: "
+ currentPartitionFetched
+ "] for store " + storageEngine.getName());
}
}
|
java
|
protected void statusInfoMessage(final String tag) {
if(logger.isInfoEnabled()) {
logger.info(tag + " : [partition: " + currentPartition + ", partitionFetched: "
+ currentPartitionFetched
+ "] for store " + storageEngine.getName());
}
}
|
[
"protected",
"void",
"statusInfoMessage",
"(",
"final",
"String",
"tag",
")",
"{",
"if",
"(",
"logger",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"tag",
"+",
"\" : [partition: \"",
"+",
"currentPartition",
"+",
"\", partitionFetched: \"",
"+",
"currentPartitionFetched",
"+",
"\"] for store \"",
"+",
"storageEngine",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] |
Simple info message for status
@param tag Message to print out at start of info message
|
[
"Simple",
"info",
"message",
"for",
"status"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/protocol/admin/PartitionScanFetchStreamRequestHandler.java#L75-L81
|
161,089 |
voldemort/voldemort
|
src/java/voldemort/server/scheduler/slop/StreamingSlopPusherJob.java
|
StreamingSlopPusherJob.slopSize
|
private int slopSize(Versioned<Slop> slopVersioned) {
int nBytes = 0;
Slop slop = slopVersioned.getValue();
nBytes += slop.getKey().length();
nBytes += ((VectorClock) slopVersioned.getVersion()).sizeInBytes();
switch(slop.getOperation()) {
case PUT: {
nBytes += slop.getValue().length;
break;
}
case DELETE: {
break;
}
default:
logger.error("Unknown slop operation: " + slop.getOperation());
}
return nBytes;
}
|
java
|
private int slopSize(Versioned<Slop> slopVersioned) {
int nBytes = 0;
Slop slop = slopVersioned.getValue();
nBytes += slop.getKey().length();
nBytes += ((VectorClock) slopVersioned.getVersion()).sizeInBytes();
switch(slop.getOperation()) {
case PUT: {
nBytes += slop.getValue().length;
break;
}
case DELETE: {
break;
}
default:
logger.error("Unknown slop operation: " + slop.getOperation());
}
return nBytes;
}
|
[
"private",
"int",
"slopSize",
"(",
"Versioned",
"<",
"Slop",
">",
"slopVersioned",
")",
"{",
"int",
"nBytes",
"=",
"0",
";",
"Slop",
"slop",
"=",
"slopVersioned",
".",
"getValue",
"(",
")",
";",
"nBytes",
"+=",
"slop",
".",
"getKey",
"(",
")",
".",
"length",
"(",
")",
";",
"nBytes",
"+=",
"(",
"(",
"VectorClock",
")",
"slopVersioned",
".",
"getVersion",
"(",
")",
")",
".",
"sizeInBytes",
"(",
")",
";",
"switch",
"(",
"slop",
".",
"getOperation",
"(",
")",
")",
"{",
"case",
"PUT",
":",
"{",
"nBytes",
"+=",
"slop",
".",
"getValue",
"(",
")",
".",
"length",
";",
"break",
";",
"}",
"case",
"DELETE",
":",
"{",
"break",
";",
"}",
"default",
":",
"logger",
".",
"error",
"(",
"\"Unknown slop operation: \"",
"+",
"slop",
".",
"getOperation",
"(",
")",
")",
";",
"}",
"return",
"nBytes",
";",
"}"
] |
Returns the approximate size of slop to help in throttling
@param slopVersioned The versioned slop whose size we want
@return Size in bytes
|
[
"Returns",
"the",
"approximate",
"size",
"of",
"slop",
"to",
"help",
"in",
"throttling"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/scheduler/slop/StreamingSlopPusherJob.java#L328-L345
|
161,090 |
voldemort/voldemort
|
contrib/restclient/src/java/voldemort/restclient/RESTClientFactory.java
|
RESTClientFactory.getStoreClient
|
@Override
public <K, V> StoreClient<K, V> getStoreClient(final String storeName,
final InconsistencyResolver<Versioned<V>> resolver) {
// wrap it in LazyStoreClient here so any direct calls to this method
// returns a lazy client
return new LazyStoreClient<K, V>(new Callable<StoreClient<K, V>>() {
@Override
public StoreClient<K, V> call() throws Exception {
Store<K, V, Object> clientStore = getRawStore(storeName, resolver);
return new RESTClient<K, V>(storeName, clientStore);
}
}, true);
}
|
java
|
@Override
public <K, V> StoreClient<K, V> getStoreClient(final String storeName,
final InconsistencyResolver<Versioned<V>> resolver) {
// wrap it in LazyStoreClient here so any direct calls to this method
// returns a lazy client
return new LazyStoreClient<K, V>(new Callable<StoreClient<K, V>>() {
@Override
public StoreClient<K, V> call() throws Exception {
Store<K, V, Object> clientStore = getRawStore(storeName, resolver);
return new RESTClient<K, V>(storeName, clientStore);
}
}, true);
}
|
[
"@",
"Override",
"public",
"<",
"K",
",",
"V",
">",
"StoreClient",
"<",
"K",
",",
"V",
">",
"getStoreClient",
"(",
"final",
"String",
"storeName",
",",
"final",
"InconsistencyResolver",
"<",
"Versioned",
"<",
"V",
">",
">",
"resolver",
")",
"{",
"// wrap it in LazyStoreClient here so any direct calls to this method",
"// returns a lazy client",
"return",
"new",
"LazyStoreClient",
"<",
"K",
",",
"V",
">",
"(",
"new",
"Callable",
"<",
"StoreClient",
"<",
"K",
",",
"V",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"StoreClient",
"<",
"K",
",",
"V",
">",
"call",
"(",
")",
"throws",
"Exception",
"{",
"Store",
"<",
"K",
",",
"V",
",",
"Object",
">",
"clientStore",
"=",
"getRawStore",
"(",
"storeName",
",",
"resolver",
")",
";",
"return",
"new",
"RESTClient",
"<",
"K",
",",
"V",
">",
"(",
"storeName",
",",
"clientStore",
")",
";",
"}",
"}",
",",
"true",
")",
";",
"}"
] |
Creates a REST client used to perform Voldemort operations against the
Coordinator
@param storeName Name of the store to perform the operations on
@param resolver Custom resolver as specified by the application
@return
|
[
"Creates",
"a",
"REST",
"client",
"used",
"to",
"perform",
"Voldemort",
"operations",
"against",
"the",
"Coordinator"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/contrib/restclient/src/java/voldemort/restclient/RESTClientFactory.java#L105-L118
|
161,091 |
voldemort/voldemort
|
src/java/voldemort/routing/ConsistentRoutingStrategy.java
|
ConsistentRoutingStrategy.abs
|
private static int abs(int a) {
if(a >= 0)
return a;
else if(a != Integer.MIN_VALUE)
return -a;
return Integer.MAX_VALUE;
}
|
java
|
private static int abs(int a) {
if(a >= 0)
return a;
else if(a != Integer.MIN_VALUE)
return -a;
return Integer.MAX_VALUE;
}
|
[
"private",
"static",
"int",
"abs",
"(",
"int",
"a",
")",
"{",
"if",
"(",
"a",
">=",
"0",
")",
"return",
"a",
";",
"else",
"if",
"(",
"a",
"!=",
"Integer",
".",
"MIN_VALUE",
")",
"return",
"-",
"a",
";",
"return",
"Integer",
".",
"MAX_VALUE",
";",
"}"
] |
A modified version of abs that always returns a non-negative value.
Math.abs returns Integer.MIN_VALUE if a == Integer.MIN_VALUE and this
method returns Integer.MAX_VALUE in that case.
|
[
"A",
"modified",
"version",
"of",
"abs",
"that",
"always",
"returns",
"a",
"non",
"-",
"negative",
"value",
".",
"Math",
".",
"abs",
"returns",
"Integer",
".",
"MIN_VALUE",
"if",
"a",
"==",
"Integer",
".",
"MIN_VALUE",
"and",
"this",
"method",
"returns",
"Integer",
".",
"MAX_VALUE",
"in",
"that",
"case",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/routing/ConsistentRoutingStrategy.java#L106-L112
|
161,092 |
voldemort/voldemort
|
src/java/voldemort/routing/ConsistentRoutingStrategy.java
|
ConsistentRoutingStrategy.getMasterPartition
|
@Override
public Integer getMasterPartition(byte[] key) {
return abs(hash.hash(key)) % (Math.max(1, this.partitionToNode.length));
}
|
java
|
@Override
public Integer getMasterPartition(byte[] key) {
return abs(hash.hash(key)) % (Math.max(1, this.partitionToNode.length));
}
|
[
"@",
"Override",
"public",
"Integer",
"getMasterPartition",
"(",
"byte",
"[",
"]",
"key",
")",
"{",
"return",
"abs",
"(",
"hash",
".",
"hash",
"(",
"key",
")",
")",
"%",
"(",
"Math",
".",
"max",
"(",
"1",
",",
"this",
".",
"partitionToNode",
".",
"length",
")",
")",
";",
"}"
] |
Obtain the master partition for a given key
@param key
@return master partition id
|
[
"Obtain",
"the",
"master",
"partition",
"for",
"a",
"given",
"key"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/routing/ConsistentRoutingStrategy.java#L170-L173
|
161,093 |
voldemort/voldemort
|
src/java/voldemort/server/scheduler/slop/SlopPusherJob.java
|
SlopPusherJob.isSlopDead
|
protected boolean isSlopDead(Cluster cluster, Set<String> storeNames, Slop slop) {
// destination node , no longer exists
if(!cluster.getNodeIds().contains(slop.getNodeId())) {
return true;
}
// destination store, no longer exists
if(!storeNames.contains(slop.getStoreName())) {
return true;
}
// else. slop is alive
return false;
}
|
java
|
protected boolean isSlopDead(Cluster cluster, Set<String> storeNames, Slop slop) {
// destination node , no longer exists
if(!cluster.getNodeIds().contains(slop.getNodeId())) {
return true;
}
// destination store, no longer exists
if(!storeNames.contains(slop.getStoreName())) {
return true;
}
// else. slop is alive
return false;
}
|
[
"protected",
"boolean",
"isSlopDead",
"(",
"Cluster",
"cluster",
",",
"Set",
"<",
"String",
">",
"storeNames",
",",
"Slop",
"slop",
")",
"{",
"// destination node , no longer exists",
"if",
"(",
"!",
"cluster",
".",
"getNodeIds",
"(",
")",
".",
"contains",
"(",
"slop",
".",
"getNodeId",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"// destination store, no longer exists",
"if",
"(",
"!",
"storeNames",
".",
"contains",
"(",
"slop",
".",
"getStoreName",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"// else. slop is alive",
"return",
"false",
";",
"}"
] |
A slop is dead if the destination node or the store does not exist
anymore on the cluster.
@param slop
@return
|
[
"A",
"slop",
"is",
"dead",
"if",
"the",
"destination",
"node",
"or",
"the",
"store",
"does",
"not",
"exist",
"anymore",
"on",
"the",
"cluster",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/scheduler/slop/SlopPusherJob.java#L52-L65
|
161,094 |
voldemort/voldemort
|
src/java/voldemort/server/scheduler/slop/SlopPusherJob.java
|
SlopPusherJob.handleDeadSlop
|
protected void handleDeadSlop(SlopStorageEngine slopStorageEngine,
Pair<ByteArray, Versioned<Slop>> keyAndVal) {
Versioned<Slop> versioned = keyAndVal.getSecond();
// If configured to delete the dead slop
if(voldemortConfig.getAutoPurgeDeadSlops()) {
slopStorageEngine.delete(keyAndVal.getFirst(), versioned.getVersion());
if(getLogger().isDebugEnabled()) {
getLogger().debug("Auto purging dead slop :" + versioned.getValue());
}
} else {
// Keep ignoring the dead slops
if(getLogger().isDebugEnabled()) {
getLogger().debug("Ignoring dead slop :" + versioned.getValue());
}
}
}
|
java
|
protected void handleDeadSlop(SlopStorageEngine slopStorageEngine,
Pair<ByteArray, Versioned<Slop>> keyAndVal) {
Versioned<Slop> versioned = keyAndVal.getSecond();
// If configured to delete the dead slop
if(voldemortConfig.getAutoPurgeDeadSlops()) {
slopStorageEngine.delete(keyAndVal.getFirst(), versioned.getVersion());
if(getLogger().isDebugEnabled()) {
getLogger().debug("Auto purging dead slop :" + versioned.getValue());
}
} else {
// Keep ignoring the dead slops
if(getLogger().isDebugEnabled()) {
getLogger().debug("Ignoring dead slop :" + versioned.getValue());
}
}
}
|
[
"protected",
"void",
"handleDeadSlop",
"(",
"SlopStorageEngine",
"slopStorageEngine",
",",
"Pair",
"<",
"ByteArray",
",",
"Versioned",
"<",
"Slop",
">",
">",
"keyAndVal",
")",
"{",
"Versioned",
"<",
"Slop",
">",
"versioned",
"=",
"keyAndVal",
".",
"getSecond",
"(",
")",
";",
"// If configured to delete the dead slop",
"if",
"(",
"voldemortConfig",
".",
"getAutoPurgeDeadSlops",
"(",
")",
")",
"{",
"slopStorageEngine",
".",
"delete",
"(",
"keyAndVal",
".",
"getFirst",
"(",
")",
",",
"versioned",
".",
"getVersion",
"(",
")",
")",
";",
"if",
"(",
"getLogger",
"(",
")",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"getLogger",
"(",
")",
".",
"debug",
"(",
"\"Auto purging dead slop :\"",
"+",
"versioned",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"// Keep ignoring the dead slops",
"if",
"(",
"getLogger",
"(",
")",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"getLogger",
"(",
")",
".",
"debug",
"(",
"\"Ignoring dead slop :\"",
"+",
"versioned",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Handle slop for nodes that are no longer part of the cluster. It may not
always be the case. For example, shrinking a zone or deleting a store.
|
[
"Handle",
"slop",
"for",
"nodes",
"that",
"are",
"no",
"longer",
"part",
"of",
"the",
"cluster",
".",
"It",
"may",
"not",
"always",
"be",
"the",
"case",
".",
"For",
"example",
"shrinking",
"a",
"zone",
"or",
"deleting",
"a",
"store",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/scheduler/slop/SlopPusherJob.java#L71-L87
|
161,095 |
voldemort/voldemort
|
src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorFactory.java
|
ClientRequestExecutorFactory.destroy
|
@Override
public void destroy(SocketDestination dest, ClientRequestExecutor clientRequestExecutor)
throws Exception {
clientRequestExecutor.close();
int numDestroyed = destroyed.incrementAndGet();
if(stats != null) {
stats.incrementCount(dest, ClientSocketStats.Tracked.CONNECTION_DESTROYED_EVENT);
}
if(logger.isDebugEnabled())
logger.debug("Destroyed socket " + numDestroyed + " connection to " + dest.getHost()
+ ":" + dest.getPort());
}
|
java
|
@Override
public void destroy(SocketDestination dest, ClientRequestExecutor clientRequestExecutor)
throws Exception {
clientRequestExecutor.close();
int numDestroyed = destroyed.incrementAndGet();
if(stats != null) {
stats.incrementCount(dest, ClientSocketStats.Tracked.CONNECTION_DESTROYED_EVENT);
}
if(logger.isDebugEnabled())
logger.debug("Destroyed socket " + numDestroyed + " connection to " + dest.getHost()
+ ":" + dest.getPort());
}
|
[
"@",
"Override",
"public",
"void",
"destroy",
"(",
"SocketDestination",
"dest",
",",
"ClientRequestExecutor",
"clientRequestExecutor",
")",
"throws",
"Exception",
"{",
"clientRequestExecutor",
".",
"close",
"(",
")",
";",
"int",
"numDestroyed",
"=",
"destroyed",
".",
"incrementAndGet",
"(",
")",
";",
"if",
"(",
"stats",
"!=",
"null",
")",
"{",
"stats",
".",
"incrementCount",
"(",
"dest",
",",
"ClientSocketStats",
".",
"Tracked",
".",
"CONNECTION_DESTROYED_EVENT",
")",
";",
"}",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"Destroyed socket \"",
"+",
"numDestroyed",
"+",
"\" connection to \"",
"+",
"dest",
".",
"getHost",
"(",
")",
"+",
"\":\"",
"+",
"dest",
".",
"getPort",
"(",
")",
")",
";",
"}"
] |
Close the ClientRequestExecutor.
|
[
"Close",
"the",
"ClientRequestExecutor",
"."
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorFactory.java#L120-L132
|
161,096 |
voldemort/voldemort
|
src/java/voldemort/rest/coordinator/config/ClientConfigUtil.java
|
ClientConfigUtil.readSingleClientConfigAvro
|
@SuppressWarnings("unchecked")
public static Properties readSingleClientConfigAvro(String configAvro) {
Properties props = new Properties();
try {
JsonDecoder decoder = new JsonDecoder(CLIENT_CONFIG_AVRO_SCHEMA, configAvro);
GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(CLIENT_CONFIG_AVRO_SCHEMA);
Map<Utf8, Utf8> flowMap = (Map<Utf8, Utf8>) datumReader.read(null, decoder);
for(Utf8 key: flowMap.keySet()) {
props.put(key.toString(), flowMap.get(key).toString());
}
} catch(Exception e) {
e.printStackTrace();
}
return props;
}
|
java
|
@SuppressWarnings("unchecked")
public static Properties readSingleClientConfigAvro(String configAvro) {
Properties props = new Properties();
try {
JsonDecoder decoder = new JsonDecoder(CLIENT_CONFIG_AVRO_SCHEMA, configAvro);
GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(CLIENT_CONFIG_AVRO_SCHEMA);
Map<Utf8, Utf8> flowMap = (Map<Utf8, Utf8>) datumReader.read(null, decoder);
for(Utf8 key: flowMap.keySet()) {
props.put(key.toString(), flowMap.get(key).toString());
}
} catch(Exception e) {
e.printStackTrace();
}
return props;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Properties",
"readSingleClientConfigAvro",
"(",
"String",
"configAvro",
")",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"try",
"{",
"JsonDecoder",
"decoder",
"=",
"new",
"JsonDecoder",
"(",
"CLIENT_CONFIG_AVRO_SCHEMA",
",",
"configAvro",
")",
";",
"GenericDatumReader",
"<",
"Object",
">",
"datumReader",
"=",
"new",
"GenericDatumReader",
"<",
"Object",
">",
"(",
"CLIENT_CONFIG_AVRO_SCHEMA",
")",
";",
"Map",
"<",
"Utf8",
",",
"Utf8",
">",
"flowMap",
"=",
"(",
"Map",
"<",
"Utf8",
",",
"Utf8",
">",
")",
"datumReader",
".",
"read",
"(",
"null",
",",
"decoder",
")",
";",
"for",
"(",
"Utf8",
"key",
":",
"flowMap",
".",
"keySet",
"(",
")",
")",
"{",
"props",
".",
"put",
"(",
"key",
".",
"toString",
"(",
")",
",",
"flowMap",
".",
"get",
"(",
"key",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"props",
";",
"}"
] |
Parses a string that contains single fat client config string in avro
format
@param configAvro Input string of avro format, that contains config for
multiple stores
@return Properties of single fat client config
|
[
"Parses",
"a",
"string",
"that",
"contains",
"single",
"fat",
"client",
"config",
"string",
"in",
"avro",
"format"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/coordinator/config/ClientConfigUtil.java#L34-L48
|
161,097 |
voldemort/voldemort
|
src/java/voldemort/rest/coordinator/config/ClientConfigUtil.java
|
ClientConfigUtil.readMultipleClientConfigAvro
|
@SuppressWarnings("unchecked")
public static Map<String, Properties> readMultipleClientConfigAvro(String configAvro) {
Map<String, Properties> mapStoreToProps = Maps.newHashMap();
try {
JsonDecoder decoder = new JsonDecoder(CLIENT_CONFIGS_AVRO_SCHEMA, configAvro);
GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(CLIENT_CONFIGS_AVRO_SCHEMA);
Map<Utf8, Map<Utf8, Utf8>> storeConfigs = (Map<Utf8, Map<Utf8, Utf8>>) datumReader.read(null,
decoder);
// Store config props to return back
for(Utf8 storeName: storeConfigs.keySet()) {
Properties props = new Properties();
Map<Utf8, Utf8> singleConfig = storeConfigs.get(storeName);
for(Utf8 key: singleConfig.keySet()) {
props.put(key.toString(), singleConfig.get(key).toString());
}
if(storeName == null || storeName.length() == 0) {
throw new Exception("Invalid store name found!");
}
mapStoreToProps.put(storeName.toString(), props);
}
} catch(Exception e) {
e.printStackTrace();
}
return mapStoreToProps;
}
|
java
|
@SuppressWarnings("unchecked")
public static Map<String, Properties> readMultipleClientConfigAvro(String configAvro) {
Map<String, Properties> mapStoreToProps = Maps.newHashMap();
try {
JsonDecoder decoder = new JsonDecoder(CLIENT_CONFIGS_AVRO_SCHEMA, configAvro);
GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(CLIENT_CONFIGS_AVRO_SCHEMA);
Map<Utf8, Map<Utf8, Utf8>> storeConfigs = (Map<Utf8, Map<Utf8, Utf8>>) datumReader.read(null,
decoder);
// Store config props to return back
for(Utf8 storeName: storeConfigs.keySet()) {
Properties props = new Properties();
Map<Utf8, Utf8> singleConfig = storeConfigs.get(storeName);
for(Utf8 key: singleConfig.keySet()) {
props.put(key.toString(), singleConfig.get(key).toString());
}
if(storeName == null || storeName.length() == 0) {
throw new Exception("Invalid store name found!");
}
mapStoreToProps.put(storeName.toString(), props);
}
} catch(Exception e) {
e.printStackTrace();
}
return mapStoreToProps;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Map",
"<",
"String",
",",
"Properties",
">",
"readMultipleClientConfigAvro",
"(",
"String",
"configAvro",
")",
"{",
"Map",
"<",
"String",
",",
"Properties",
">",
"mapStoreToProps",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"try",
"{",
"JsonDecoder",
"decoder",
"=",
"new",
"JsonDecoder",
"(",
"CLIENT_CONFIGS_AVRO_SCHEMA",
",",
"configAvro",
")",
";",
"GenericDatumReader",
"<",
"Object",
">",
"datumReader",
"=",
"new",
"GenericDatumReader",
"<",
"Object",
">",
"(",
"CLIENT_CONFIGS_AVRO_SCHEMA",
")",
";",
"Map",
"<",
"Utf8",
",",
"Map",
"<",
"Utf8",
",",
"Utf8",
">",
">",
"storeConfigs",
"=",
"(",
"Map",
"<",
"Utf8",
",",
"Map",
"<",
"Utf8",
",",
"Utf8",
">",
">",
")",
"datumReader",
".",
"read",
"(",
"null",
",",
"decoder",
")",
";",
"// Store config props to return back",
"for",
"(",
"Utf8",
"storeName",
":",
"storeConfigs",
".",
"keySet",
"(",
")",
")",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"Map",
"<",
"Utf8",
",",
"Utf8",
">",
"singleConfig",
"=",
"storeConfigs",
".",
"get",
"(",
"storeName",
")",
";",
"for",
"(",
"Utf8",
"key",
":",
"singleConfig",
".",
"keySet",
"(",
")",
")",
"{",
"props",
".",
"put",
"(",
"key",
".",
"toString",
"(",
")",
",",
"singleConfig",
".",
"get",
"(",
"key",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"if",
"(",
"storeName",
"==",
"null",
"||",
"storeName",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Invalid store name found!\"",
")",
";",
"}",
"mapStoreToProps",
".",
"put",
"(",
"storeName",
".",
"toString",
"(",
")",
",",
"props",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"mapStoreToProps",
";",
"}"
] |
Parses a string that contains multiple fat client configs in avro format
@param configAvro Input string of avro format, that contains config for
multiple stores
@return Map of store names to store config properties
|
[
"Parses",
"a",
"string",
"that",
"contains",
"multiple",
"fat",
"client",
"configs",
"in",
"avro",
"format"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/coordinator/config/ClientConfigUtil.java#L57-L85
|
161,098 |
voldemort/voldemort
|
src/java/voldemort/rest/coordinator/config/ClientConfigUtil.java
|
ClientConfigUtil.writeSingleClientConfigAvro
|
public static String writeSingleClientConfigAvro(Properties props) {
// TODO: Use a dedicated json lib. We shouldn't be manually manipulating json...
String avroConfig = "";
Boolean firstProp = true;
for(String key: props.stringPropertyNames()) {
if(firstProp) {
firstProp = false;
} else {
avroConfig = avroConfig + ",\n";
}
avroConfig = avroConfig + "\t\t\"" + key + "\": \"" + props.getProperty(key) + "\"";
}
if(avroConfig.isEmpty()) {
return "{}";
} else {
return "{\n" + avroConfig + "\n\t}";
}
}
|
java
|
public static String writeSingleClientConfigAvro(Properties props) {
// TODO: Use a dedicated json lib. We shouldn't be manually manipulating json...
String avroConfig = "";
Boolean firstProp = true;
for(String key: props.stringPropertyNames()) {
if(firstProp) {
firstProp = false;
} else {
avroConfig = avroConfig + ",\n";
}
avroConfig = avroConfig + "\t\t\"" + key + "\": \"" + props.getProperty(key) + "\"";
}
if(avroConfig.isEmpty()) {
return "{}";
} else {
return "{\n" + avroConfig + "\n\t}";
}
}
|
[
"public",
"static",
"String",
"writeSingleClientConfigAvro",
"(",
"Properties",
"props",
")",
"{",
"// TODO: Use a dedicated json lib. We shouldn't be manually manipulating json...",
"String",
"avroConfig",
"=",
"\"\"",
";",
"Boolean",
"firstProp",
"=",
"true",
";",
"for",
"(",
"String",
"key",
":",
"props",
".",
"stringPropertyNames",
"(",
")",
")",
"{",
"if",
"(",
"firstProp",
")",
"{",
"firstProp",
"=",
"false",
";",
"}",
"else",
"{",
"avroConfig",
"=",
"avroConfig",
"+",
"\",\\n\"",
";",
"}",
"avroConfig",
"=",
"avroConfig",
"+",
"\"\\t\\t\\\"\"",
"+",
"key",
"+",
"\"\\\": \\\"\"",
"+",
"props",
".",
"getProperty",
"(",
"key",
")",
"+",
"\"\\\"\"",
";",
"}",
"if",
"(",
"avroConfig",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"\"{}\"",
";",
"}",
"else",
"{",
"return",
"\"{\\n\"",
"+",
"avroConfig",
"+",
"\"\\n\\t}\"",
";",
"}",
"}"
] |
Assembles an avro format string of single store config from store
properties
@param props Store properties
@return String in avro format that contains single store configs
|
[
"Assembles",
"an",
"avro",
"format",
"string",
"of",
"single",
"store",
"config",
"from",
"store",
"properties"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/coordinator/config/ClientConfigUtil.java#L94-L111
|
161,099 |
voldemort/voldemort
|
src/java/voldemort/rest/coordinator/config/ClientConfigUtil.java
|
ClientConfigUtil.writeMultipleClientConfigAvro
|
public static String writeMultipleClientConfigAvro(Map<String, Properties> mapStoreToProps) {
// TODO: Use a dedicated json lib. We shouldn't be manually manipulating json...
String avroConfig = "";
Boolean firstStore = true;
for(String storeName: mapStoreToProps.keySet()) {
if(firstStore) {
firstStore = false;
} else {
avroConfig = avroConfig + ",\n";
}
Properties props = mapStoreToProps.get(storeName);
avroConfig = avroConfig + "\t\"" + storeName + "\": "
+ writeSingleClientConfigAvro(props);
}
return "{\n" + avroConfig + "\n}";
}
|
java
|
public static String writeMultipleClientConfigAvro(Map<String, Properties> mapStoreToProps) {
// TODO: Use a dedicated json lib. We shouldn't be manually manipulating json...
String avroConfig = "";
Boolean firstStore = true;
for(String storeName: mapStoreToProps.keySet()) {
if(firstStore) {
firstStore = false;
} else {
avroConfig = avroConfig + ",\n";
}
Properties props = mapStoreToProps.get(storeName);
avroConfig = avroConfig + "\t\"" + storeName + "\": "
+ writeSingleClientConfigAvro(props);
}
return "{\n" + avroConfig + "\n}";
}
|
[
"public",
"static",
"String",
"writeMultipleClientConfigAvro",
"(",
"Map",
"<",
"String",
",",
"Properties",
">",
"mapStoreToProps",
")",
"{",
"// TODO: Use a dedicated json lib. We shouldn't be manually manipulating json...",
"String",
"avroConfig",
"=",
"\"\"",
";",
"Boolean",
"firstStore",
"=",
"true",
";",
"for",
"(",
"String",
"storeName",
":",
"mapStoreToProps",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"firstStore",
")",
"{",
"firstStore",
"=",
"false",
";",
"}",
"else",
"{",
"avroConfig",
"=",
"avroConfig",
"+",
"\",\\n\"",
";",
"}",
"Properties",
"props",
"=",
"mapStoreToProps",
".",
"get",
"(",
"storeName",
")",
";",
"avroConfig",
"=",
"avroConfig",
"+",
"\"\\t\\\"\"",
"+",
"storeName",
"+",
"\"\\\": \"",
"+",
"writeSingleClientConfigAvro",
"(",
"props",
")",
";",
"}",
"return",
"\"{\\n\"",
"+",
"avroConfig",
"+",
"\"\\n}\"",
";",
"}"
] |
Assembles an avro format string that contains multiple fat client configs
from map of store to properties
@param mapStoreToProps A map of store names to their properties
@return Avro string that contains multiple store configs
|
[
"Assembles",
"an",
"avro",
"format",
"string",
"that",
"contains",
"multiple",
"fat",
"client",
"configs",
"from",
"map",
"of",
"store",
"to",
"properties"
] |
a7dbdea58032021361680faacf2782cf981c5332
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/coordinator/config/ClientConfigUtil.java#L120-L136
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.