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 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
OpenLiberty/open-liberty | dev/com.ibm.jbatch.container/src/com/ibm/jbatch/container/controller/impl/ChunkStepControllerImpl.java | ChunkStepControllerImpl.initStepTransactionTimeout | private int initStepTransactionTimeout() {
logger.entering(sourceClass, "initStepTransactionTimeout");
Properties p = runtimeStepExecution.getProperties();
int timeout = DEFAULT_TRAN_TIMEOUT_SECONDS; // default as per spec.
if (p != null && !p.isEmpty()) {
String propertyTimeOut = p.getProperty("javax.transaction.global.timeout");
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "javax.transaction.global.timeout = {0}", propertyTimeOut == null ? "<null>" : propertyTimeOut);
}
if (propertyTimeOut != null && !propertyTimeOut.isEmpty()) {
timeout = Integer.parseInt(propertyTimeOut, 10);
}
}
logger.exiting(sourceClass, "initStepTransactionTimeout", timeout);
return timeout;
} | java | private int initStepTransactionTimeout() {
logger.entering(sourceClass, "initStepTransactionTimeout");
Properties p = runtimeStepExecution.getProperties();
int timeout = DEFAULT_TRAN_TIMEOUT_SECONDS; // default as per spec.
if (p != null && !p.isEmpty()) {
String propertyTimeOut = p.getProperty("javax.transaction.global.timeout");
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "javax.transaction.global.timeout = {0}", propertyTimeOut == null ? "<null>" : propertyTimeOut);
}
if (propertyTimeOut != null && !propertyTimeOut.isEmpty()) {
timeout = Integer.parseInt(propertyTimeOut, 10);
}
}
logger.exiting(sourceClass, "initStepTransactionTimeout", timeout);
return timeout;
} | [
"private",
"int",
"initStepTransactionTimeout",
"(",
")",
"{",
"logger",
".",
"entering",
"(",
"sourceClass",
",",
"\"initStepTransactionTimeout\"",
")",
";",
"Properties",
"p",
"=",
"runtimeStepExecution",
".",
"getProperties",
"(",
")",
";",
"int",
"timeout",
"=",
"DEFAULT_TRAN_TIMEOUT_SECONDS",
";",
"// default as per spec.",
"if",
"(",
"p",
"!=",
"null",
"&&",
"!",
"p",
".",
"isEmpty",
"(",
")",
")",
"{",
"String",
"propertyTimeOut",
"=",
"p",
".",
"getProperty",
"(",
"\"javax.transaction.global.timeout\"",
")",
";",
"if",
"(",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"javax.transaction.global.timeout = {0}\"",
",",
"propertyTimeOut",
"==",
"null",
"?",
"\"<null>\"",
":",
"propertyTimeOut",
")",
";",
"}",
"if",
"(",
"propertyTimeOut",
"!=",
"null",
"&&",
"!",
"propertyTimeOut",
".",
"isEmpty",
"(",
")",
")",
"{",
"timeout",
"=",
"Integer",
".",
"parseInt",
"(",
"propertyTimeOut",
",",
"10",
")",
";",
"}",
"}",
"logger",
".",
"exiting",
"(",
"sourceClass",
",",
"\"initStepTransactionTimeout\"",
",",
"timeout",
")",
";",
"return",
"timeout",
";",
"}"
] | Note we can rely on the StepContext properties already having been set at this point.
@return global transaction timeout defined in step properties. default
timeout value is 180 | [
"Note",
"we",
"can",
"rely",
"on",
"the",
"StepContext",
"properties",
"already",
"having",
"been",
"set",
"at",
"this",
"point",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.jbatch.container/src/com/ibm/jbatch/container/controller/impl/ChunkStepControllerImpl.java#L1072-L1088 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/AnySimpleType.java | AnySimpleType.replaceWhitespace | @Trivial
private static String replaceWhitespace(String value) {
final int length = value.length();
for (int i = 0; i < length; ++i) {
char c = value.charAt(i);
if (c < 0x20 && (c == 0x9 || c == 0xA || c == 0xD)) {
return replace0(value, i, length);
}
}
return value;
} | java | @Trivial
private static String replaceWhitespace(String value) {
final int length = value.length();
for (int i = 0; i < length; ++i) {
char c = value.charAt(i);
if (c < 0x20 && (c == 0x9 || c == 0xA || c == 0xD)) {
return replace0(value, i, length);
}
}
return value;
} | [
"@",
"Trivial",
"private",
"static",
"String",
"replaceWhitespace",
"(",
"String",
"value",
")",
"{",
"final",
"int",
"length",
"=",
"value",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"++",
"i",
")",
"{",
"char",
"c",
"=",
"value",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"<",
"0x20",
"&&",
"(",
"c",
"==",
"0x9",
"||",
"c",
"==",
"0xA",
"||",
"c",
"==",
"0xD",
")",
")",
"{",
"return",
"replace0",
"(",
"value",
",",
"i",
",",
"length",
")",
";",
"}",
"}",
"return",
"value",
";",
"}"
] | Replaces all occurrences of 0x9, 0xA and 0xD with 0x20. | [
"Replaces",
"all",
"occurrences",
"of",
"0x9",
"0xA",
"and",
"0xD",
"with",
"0x20",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/AnySimpleType.java#L179-L189 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/store/MessageProcessorStore.java | MessageProcessorStore.setMessagingEngineUuid | private void setMessagingEngineUuid(SIBUuid8 uuid)
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "setMessagingEngineUuid", new Object[] { uuid });
messagingEngineUuid = uuid;
if (tc.isEntryEnabled())
SibTr.exit(tc, "setMessagingEngineUuid");
} | java | private void setMessagingEngineUuid(SIBUuid8 uuid)
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "setMessagingEngineUuid", new Object[] { uuid });
messagingEngineUuid = uuid;
if (tc.isEntryEnabled())
SibTr.exit(tc, "setMessagingEngineUuid");
} | [
"private",
"void",
"setMessagingEngineUuid",
"(",
"SIBUuid8",
"uuid",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"setMessagingEngineUuid\"",
",",
"new",
"Object",
"[",
"]",
"{",
"uuid",
"}",
")",
";",
"messagingEngineUuid",
"=",
"uuid",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"setMessagingEngineUuid\"",
")",
";",
"}"
] | Set the messagingEngineUuid.
@param uuid | [
"Set",
"the",
"messagingEngineUuid",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/store/MessageProcessorStore.java#L129-L138 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.config/src/com/ibm/ws/config/xml/internal/nester/Nester.java | Nester.nest | public static Map<String, List<Map<String, Object>>> nest(Map<String, Object> map, String... keys) {
Map<String, List<Map<String, Object>>> result = new HashMap<String, List<Map<String, Object>>>(keys.length);
String keyMatch = "";
for (String key : keys) {
result.put(key, new ArrayList<Map<String, Object>>());
keyMatch = MessageFormat.format("{0}{1}|", keyMatch, Pattern.quote(key));
}
String patternString = MessageFormat.format("^({0})\\.([0-9]*)\\.(.*)", keyMatch.substring(0, keyMatch.length() - 1));
Pattern pattern = Pattern.compile(patternString);
for (Map.Entry<String, Object> entry : map.entrySet()) {
String k = entry.getKey();
Matcher matcher = pattern.matcher(k);
if (matcher.matches()) {
int base = 1;
String key = matcher.group(1);
processMatch(result.get(key), entry.getValue(), matcher, base);
}
}
return result;
} | java | public static Map<String, List<Map<String, Object>>> nest(Map<String, Object> map, String... keys) {
Map<String, List<Map<String, Object>>> result = new HashMap<String, List<Map<String, Object>>>(keys.length);
String keyMatch = "";
for (String key : keys) {
result.put(key, new ArrayList<Map<String, Object>>());
keyMatch = MessageFormat.format("{0}{1}|", keyMatch, Pattern.quote(key));
}
String patternString = MessageFormat.format("^({0})\\.([0-9]*)\\.(.*)", keyMatch.substring(0, keyMatch.length() - 1));
Pattern pattern = Pattern.compile(patternString);
for (Map.Entry<String, Object> entry : map.entrySet()) {
String k = entry.getKey();
Matcher matcher = pattern.matcher(k);
if (matcher.matches()) {
int base = 1;
String key = matcher.group(1);
processMatch(result.get(key), entry.getValue(), matcher, base);
}
}
return result;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
">",
"nest",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
",",
"String",
"...",
"keys",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
">",
"result",
"=",
"new",
"HashMap",
"<",
"String",
",",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
">",
"(",
"keys",
".",
"length",
")",
";",
"String",
"keyMatch",
"=",
"\"\"",
";",
"for",
"(",
"String",
"key",
":",
"keys",
")",
"{",
"result",
".",
"put",
"(",
"key",
",",
"new",
"ArrayList",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
")",
")",
";",
"keyMatch",
"=",
"MessageFormat",
".",
"format",
"(",
"\"{0}{1}|\"",
",",
"keyMatch",
",",
"Pattern",
".",
"quote",
"(",
"key",
")",
")",
";",
"}",
"String",
"patternString",
"=",
"MessageFormat",
".",
"format",
"(",
"\"^({0})\\\\.([0-9]*)\\\\.(.*)\"",
",",
"keyMatch",
".",
"substring",
"(",
"0",
",",
"keyMatch",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
";",
"Pattern",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"patternString",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"k",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"Matcher",
"matcher",
"=",
"pattern",
".",
"matcher",
"(",
"k",
")",
";",
"if",
"(",
"matcher",
".",
"matches",
"(",
")",
")",
"{",
"int",
"base",
"=",
"1",
";",
"String",
"key",
"=",
"matcher",
".",
"group",
"(",
"1",
")",
";",
"processMatch",
"(",
"result",
".",
"get",
"(",
"key",
")",
",",
"entry",
".",
"getValue",
"(",
")",
",",
"matcher",
",",
"base",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Extracts all sub configurations starting with any of the specified keys
@param map flattened properties
@param keys keys of interest
@return map keyed by (supplied) key of lists of extracted nested configurations | [
"Extracts",
"all",
"sub",
"configurations",
"starting",
"with",
"any",
"of",
"the",
"specified",
"keys"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.config/src/com/ibm/ws/config/xml/internal/nester/Nester.java#L90-L109 | train |
OpenLiberty/open-liberty | dev/wlp.lib.extract/src/wlp/lib/extract/SelfExtractRun.java | SelfExtractRun.getUserHome | private static String getUserHome() {
String home;
if (platformType == SelfExtractUtils.PlatformType_CYGWIN) {
home = System.getenv("HOME");
} else {
home = System.getProperty("user.home");
}
return home;
} | java | private static String getUserHome() {
String home;
if (platformType == SelfExtractUtils.PlatformType_CYGWIN) {
home = System.getenv("HOME");
} else {
home = System.getProperty("user.home");
}
return home;
} | [
"private",
"static",
"String",
"getUserHome",
"(",
")",
"{",
"String",
"home",
";",
"if",
"(",
"platformType",
"==",
"SelfExtractUtils",
".",
"PlatformType_CYGWIN",
")",
"{",
"home",
"=",
"System",
".",
"getenv",
"(",
"\"HOME\"",
")",
";",
"}",
"else",
"{",
"home",
"=",
"System",
".",
"getProperty",
"(",
"\"user.home\"",
")",
";",
"}",
"return",
"home",
";",
"}"
] | Determine user home based on platform type.
Java user.home property is correct in all cases except
for cygwin. For cygwin, user.home is Windows home,
so use HOME env var instead.
@return user home directory | [
"Determine",
"user",
"home",
"based",
"on",
"platform",
"type",
".",
"Java",
"user",
".",
"home",
"property",
"is",
"correct",
"in",
"all",
"cases",
"except",
"for",
"cygwin",
".",
"For",
"cygwin",
"user",
".",
"home",
"is",
"Windows",
"home",
"so",
"use",
"HOME",
"env",
"var",
"instead",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/wlp.lib.extract/src/wlp/lib/extract/SelfExtractRun.java#L53-L63 | train |
OpenLiberty/open-liberty | dev/wlp.lib.extract/src/wlp/lib/extract/SelfExtractRun.java | SelfExtractRun.createIfNeeded | private static String createIfNeeded(String dir) {
File f = new File(dir);
if (f.exists()) {
return dir;
} else {
boolean success = f.mkdirs();
if (success)
return dir;
else
return null;
}
} | java | private static String createIfNeeded(String dir) {
File f = new File(dir);
if (f.exists()) {
return dir;
} else {
boolean success = f.mkdirs();
if (success)
return dir;
else
return null;
}
} | [
"private",
"static",
"String",
"createIfNeeded",
"(",
"String",
"dir",
")",
"{",
"File",
"f",
"=",
"new",
"File",
"(",
"dir",
")",
";",
"if",
"(",
"f",
".",
"exists",
"(",
")",
")",
"{",
"return",
"dir",
";",
"}",
"else",
"{",
"boolean",
"success",
"=",
"f",
".",
"mkdirs",
"(",
")",
";",
"if",
"(",
"success",
")",
"return",
"dir",
";",
"else",
"return",
"null",
";",
"}",
"}"
] | Create input directory if it does not exist
@return directory name | [
"Create",
"input",
"directory",
"if",
"it",
"does",
"not",
"exist"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/wlp.lib.extract/src/wlp/lib/extract/SelfExtractRun.java#L80-L91 | train |
OpenLiberty/open-liberty | dev/wlp.lib.extract/src/wlp/lib/extract/SelfExtractRun.java | SelfExtractRun.jarFileName | private static String jarFileName() {
// do this first so we can access extractor, ok to invoke more than once
createExtractor();
// get <name> from path/<name>.jar
String fullyQualifiedFileName = extractor.container.getName();
int lastSeparator = fullyQualifiedFileName.lastIndexOf(File.separatorChar);
String simpleFileName = fullyQualifiedFileName.substring(lastSeparator + 1);
int dotIdx = simpleFileName.lastIndexOf('.');
if (dotIdx != -1) {
return simpleFileName.substring(0, simpleFileName.lastIndexOf('.'));
}
return simpleFileName;
} | java | private static String jarFileName() {
// do this first so we can access extractor, ok to invoke more than once
createExtractor();
// get <name> from path/<name>.jar
String fullyQualifiedFileName = extractor.container.getName();
int lastSeparator = fullyQualifiedFileName.lastIndexOf(File.separatorChar);
String simpleFileName = fullyQualifiedFileName.substring(lastSeparator + 1);
int dotIdx = simpleFileName.lastIndexOf('.');
if (dotIdx != -1) {
return simpleFileName.substring(0, simpleFileName.lastIndexOf('.'));
}
return simpleFileName;
} | [
"private",
"static",
"String",
"jarFileName",
"(",
")",
"{",
"// do this first so we can access extractor, ok to invoke more than once",
"createExtractor",
"(",
")",
";",
"// get <name> from path/<name>.jar",
"String",
"fullyQualifiedFileName",
"=",
"extractor",
".",
"container",
".",
"getName",
"(",
")",
";",
"int",
"lastSeparator",
"=",
"fullyQualifiedFileName",
".",
"lastIndexOf",
"(",
"File",
".",
"separatorChar",
")",
";",
"String",
"simpleFileName",
"=",
"fullyQualifiedFileName",
".",
"substring",
"(",
"lastSeparator",
"+",
"1",
")",
";",
"int",
"dotIdx",
"=",
"simpleFileName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"dotIdx",
"!=",
"-",
"1",
")",
"{",
"return",
"simpleFileName",
".",
"substring",
"(",
"0",
",",
"simpleFileName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
")",
";",
"}",
"return",
"simpleFileName",
";",
"}"
] | Return jar file name from input archive
@return <name> from path/<name>.jar | [
"Return",
"jar",
"file",
"name",
"from",
"input",
"archive"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/wlp.lib.extract/src/wlp/lib/extract/SelfExtractRun.java#L98-L110 | train |
OpenLiberty/open-liberty | dev/wlp.lib.extract/src/wlp/lib/extract/SelfExtractRun.java | SelfExtractRun.disable2PC | private static void disable2PC(String extractDirectory, String serverName) throws IOException {
String fileName = extractDirectory + File.separator + "wlp" + File.separator + "usr" + File.separator + "servers" + File.separator + serverName + File.separator
+ "jvm.options";
BufferedReader br = null;
BufferedWriter bw = null;
StringBuffer sb = new StringBuffer();
try {
String sCurrentLine;
File file = new File(fileName);
// if file doesnt exists, then create it
if (!file.exists()) {
boolean success = file.createNewFile();
if (!success) {
throw new IOException("Failed to create file " + fileName);
}
} else {
// read existing file content
br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8"));
while ((sCurrentLine = br.readLine()) != null) {
sb.append(sCurrentLine + "\n");
}
}
// write property to disable 2PC commit
String content = "-Dcom.ibm.tx.jta.disable2PC=true";
bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file.getAbsoluteFile()), "UTF-8"));
bw.write(sb.toString());
bw.write(content);
} finally {
if (br != null)
br.close();
if (bw != null)
bw.close();
}
} | java | private static void disable2PC(String extractDirectory, String serverName) throws IOException {
String fileName = extractDirectory + File.separator + "wlp" + File.separator + "usr" + File.separator + "servers" + File.separator + serverName + File.separator
+ "jvm.options";
BufferedReader br = null;
BufferedWriter bw = null;
StringBuffer sb = new StringBuffer();
try {
String sCurrentLine;
File file = new File(fileName);
// if file doesnt exists, then create it
if (!file.exists()) {
boolean success = file.createNewFile();
if (!success) {
throw new IOException("Failed to create file " + fileName);
}
} else {
// read existing file content
br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8"));
while ((sCurrentLine = br.readLine()) != null) {
sb.append(sCurrentLine + "\n");
}
}
// write property to disable 2PC commit
String content = "-Dcom.ibm.tx.jta.disable2PC=true";
bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file.getAbsoluteFile()), "UTF-8"));
bw.write(sb.toString());
bw.write(content);
} finally {
if (br != null)
br.close();
if (bw != null)
bw.close();
}
} | [
"private",
"static",
"void",
"disable2PC",
"(",
"String",
"extractDirectory",
",",
"String",
"serverName",
")",
"throws",
"IOException",
"{",
"String",
"fileName",
"=",
"extractDirectory",
"+",
"File",
".",
"separator",
"+",
"\"wlp\"",
"+",
"File",
".",
"separator",
"+",
"\"usr\"",
"+",
"File",
".",
"separator",
"+",
"\"servers\"",
"+",
"File",
".",
"separator",
"+",
"serverName",
"+",
"File",
".",
"separator",
"+",
"\"jvm.options\"",
";",
"BufferedReader",
"br",
"=",
"null",
";",
"BufferedWriter",
"bw",
"=",
"null",
";",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"try",
"{",
"String",
"sCurrentLine",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"fileName",
")",
";",
"// if file doesnt exists, then create it",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"boolean",
"success",
"=",
"file",
".",
"createNewFile",
"(",
")",
";",
"if",
"(",
"!",
"success",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Failed to create file \"",
"+",
"fileName",
")",
";",
"}",
"}",
"else",
"{",
"// read existing file content",
"br",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"new",
"FileInputStream",
"(",
"fileName",
")",
",",
"\"UTF-8\"",
")",
")",
";",
"while",
"(",
"(",
"sCurrentLine",
"=",
"br",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"sb",
".",
"append",
"(",
"sCurrentLine",
"+",
"\"\\n\"",
")",
";",
"}",
"}",
"// write property to disable 2PC commit",
"String",
"content",
"=",
"\"-Dcom.ibm.tx.jta.disable2PC=true\"",
";",
"bw",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"file",
".",
"getAbsoluteFile",
"(",
")",
")",
",",
"\"UTF-8\"",
")",
")",
";",
"bw",
".",
"write",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"bw",
".",
"write",
"(",
"content",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"br",
"!=",
"null",
")",
"br",
".",
"close",
"(",
")",
";",
"if",
"(",
"bw",
"!=",
"null",
")",
"bw",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Write property into jvm.options to disable 2PC transactions.
2PC transactions are disabled by default because default transaction
log is stored in extract directory and therefore foils transaction
recovery if the server terminates unexpectedly.
@param extractDirectory
@param serverName
@throws IOException | [
"Write",
"property",
"into",
"jvm",
".",
"options",
"to",
"disable",
"2PC",
"transactions",
".",
"2PC",
"transactions",
"are",
"disabled",
"by",
"default",
"because",
"default",
"transaction",
"log",
"is",
"stored",
"in",
"extract",
"directory",
"and",
"therefore",
"foils",
"transaction",
"recovery",
"if",
"the",
"server",
"terminates",
"unexpectedly",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/wlp.lib.extract/src/wlp/lib/extract/SelfExtractRun.java#L176-L218 | train |
OpenLiberty/open-liberty | dev/wlp.lib.extract/src/wlp/lib/extract/SelfExtractRun.java | SelfExtractRun.runServer | private static int runServer(String extractDirectory, String serverName, String[] args) throws IOException, InterruptedException {
int rc = 0;
Runtime rt = Runtime.getRuntime();
String action = "run";
if (System.getenv("WLP_JAR_DEBUG") != null)
action = "debug";
// unless user specifies to enable 2PC, disable it
if (System.getenv("WLP_JAR_ENABLE_2PC") == null)
disable2PC(extractDirectory, serverName);
String cmd = extractDirectory + File.separator + "wlp" + File.separator + "bin" + File.separator + "server " + action + " " + serverName;
if (args.length > 0) {
StringBuilder appArgs = new StringBuilder(" --");
for (String arg : args) {
appArgs.append(" ").append(arg);
}
cmd += appArgs.toString();
}
System.out.println(cmd);
if (platformType == SelfExtractUtils.PlatformType_UNIX) {
// cmd ready as-is for Unix
} else if (platformType == SelfExtractUtils.PlatformType_WINDOWS) {
cmd = "cmd /k " + cmd;
} else if (platformType == SelfExtractUtils.PlatformType_CYGWIN) {
cmd = "bash -c " + '"' + cmd.replace('\\', '/') + '"';
}
Process proc = rt.exec(cmd, SelfExtractUtils.runEnv(extractDirectory), null); // run server
// setup and start reader threads for error and output streams
StreamReader errorReader = new StreamReader(proc.getErrorStream(), "ERROR");
errorReader.start();
StreamReader outputReader = new StreamReader(proc.getInputStream(), "OUTPUT");
outputReader.start();
// now setup the shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHook(platformType, extractDirectory, serverName, outputReader, errorReader)));
// wait on server start process to complete, capture and pass on return code
rc = proc.waitFor();
return rc;
} | java | private static int runServer(String extractDirectory, String serverName, String[] args) throws IOException, InterruptedException {
int rc = 0;
Runtime rt = Runtime.getRuntime();
String action = "run";
if (System.getenv("WLP_JAR_DEBUG") != null)
action = "debug";
// unless user specifies to enable 2PC, disable it
if (System.getenv("WLP_JAR_ENABLE_2PC") == null)
disable2PC(extractDirectory, serverName);
String cmd = extractDirectory + File.separator + "wlp" + File.separator + "bin" + File.separator + "server " + action + " " + serverName;
if (args.length > 0) {
StringBuilder appArgs = new StringBuilder(" --");
for (String arg : args) {
appArgs.append(" ").append(arg);
}
cmd += appArgs.toString();
}
System.out.println(cmd);
if (platformType == SelfExtractUtils.PlatformType_UNIX) {
// cmd ready as-is for Unix
} else if (platformType == SelfExtractUtils.PlatformType_WINDOWS) {
cmd = "cmd /k " + cmd;
} else if (platformType == SelfExtractUtils.PlatformType_CYGWIN) {
cmd = "bash -c " + '"' + cmd.replace('\\', '/') + '"';
}
Process proc = rt.exec(cmd, SelfExtractUtils.runEnv(extractDirectory), null); // run server
// setup and start reader threads for error and output streams
StreamReader errorReader = new StreamReader(proc.getErrorStream(), "ERROR");
errorReader.start();
StreamReader outputReader = new StreamReader(proc.getInputStream(), "OUTPUT");
outputReader.start();
// now setup the shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHook(platformType, extractDirectory, serverName, outputReader, errorReader)));
// wait on server start process to complete, capture and pass on return code
rc = proc.waitFor();
return rc;
} | [
"private",
"static",
"int",
"runServer",
"(",
"String",
"extractDirectory",
",",
"String",
"serverName",
",",
"String",
"[",
"]",
"args",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"int",
"rc",
"=",
"0",
";",
"Runtime",
"rt",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
";",
"String",
"action",
"=",
"\"run\"",
";",
"if",
"(",
"System",
".",
"getenv",
"(",
"\"WLP_JAR_DEBUG\"",
")",
"!=",
"null",
")",
"action",
"=",
"\"debug\"",
";",
"// unless user specifies to enable 2PC, disable it",
"if",
"(",
"System",
".",
"getenv",
"(",
"\"WLP_JAR_ENABLE_2PC\"",
")",
"==",
"null",
")",
"disable2PC",
"(",
"extractDirectory",
",",
"serverName",
")",
";",
"String",
"cmd",
"=",
"extractDirectory",
"+",
"File",
".",
"separator",
"+",
"\"wlp\"",
"+",
"File",
".",
"separator",
"+",
"\"bin\"",
"+",
"File",
".",
"separator",
"+",
"\"server \"",
"+",
"action",
"+",
"\" \"",
"+",
"serverName",
";",
"if",
"(",
"args",
".",
"length",
">",
"0",
")",
"{",
"StringBuilder",
"appArgs",
"=",
"new",
"StringBuilder",
"(",
"\" --\"",
")",
";",
"for",
"(",
"String",
"arg",
":",
"args",
")",
"{",
"appArgs",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"arg",
")",
";",
"}",
"cmd",
"+=",
"appArgs",
".",
"toString",
"(",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"cmd",
")",
";",
"if",
"(",
"platformType",
"==",
"SelfExtractUtils",
".",
"PlatformType_UNIX",
")",
"{",
"// cmd ready as-is for Unix",
"}",
"else",
"if",
"(",
"platformType",
"==",
"SelfExtractUtils",
".",
"PlatformType_WINDOWS",
")",
"{",
"cmd",
"=",
"\"cmd /k \"",
"+",
"cmd",
";",
"}",
"else",
"if",
"(",
"platformType",
"==",
"SelfExtractUtils",
".",
"PlatformType_CYGWIN",
")",
"{",
"cmd",
"=",
"\"bash -c \"",
"+",
"'",
"'",
"+",
"cmd",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
"+",
"'",
"'",
";",
"}",
"Process",
"proc",
"=",
"rt",
".",
"exec",
"(",
"cmd",
",",
"SelfExtractUtils",
".",
"runEnv",
"(",
"extractDirectory",
")",
",",
"null",
")",
";",
"// run server",
"// setup and start reader threads for error and output streams",
"StreamReader",
"errorReader",
"=",
"new",
"StreamReader",
"(",
"proc",
".",
"getErrorStream",
"(",
")",
",",
"\"ERROR\"",
")",
";",
"errorReader",
".",
"start",
"(",
")",
";",
"StreamReader",
"outputReader",
"=",
"new",
"StreamReader",
"(",
"proc",
".",
"getInputStream",
"(",
")",
",",
"\"OUTPUT\"",
")",
";",
"outputReader",
".",
"start",
"(",
")",
";",
"// now setup the shutdown hook",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"addShutdownHook",
"(",
"new",
"Thread",
"(",
"new",
"ShutdownHook",
"(",
"platformType",
",",
"extractDirectory",
",",
"serverName",
",",
"outputReader",
",",
"errorReader",
")",
")",
")",
";",
"// wait on server start process to complete, capture and pass on return code",
"rc",
"=",
"proc",
".",
"waitFor",
"(",
")",
";",
"return",
"rc",
";",
"}"
] | Run server extracted from jar
If environment variable WLP_JAR_DEBUG is set, use 'server debug' instead
@param extractDirectory
@param serverName
@return server run return code
@throws IOException
@throws InterruptedException | [
"Run",
"server",
"extracted",
"from",
"jar",
"If",
"environment",
"variable",
"WLP_JAR_DEBUG",
"is",
"set",
"use",
"server",
"debug",
"instead"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/wlp.lib.extract/src/wlp/lib/extract/SelfExtractRun.java#L230-L277 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/J2CGlobalConfigProperties.java | J2CGlobalConfigProperties.isInitialized | private void isInitialized(boolean condition, String propName) {
if (condition == true) {
IllegalStateException e = new IllegalStateException("J2CGlobalConfigProperties: internal error. Set once property already set.");
Tr.error(tc, "SET_ONCE_PROP_ALREADY_SET_J2CA0159", (Object) null);
throw e;
}
} | java | private void isInitialized(boolean condition, String propName) {
if (condition == true) {
IllegalStateException e = new IllegalStateException("J2CGlobalConfigProperties: internal error. Set once property already set.");
Tr.error(tc, "SET_ONCE_PROP_ALREADY_SET_J2CA0159", (Object) null);
throw e;
}
} | [
"private",
"void",
"isInitialized",
"(",
"boolean",
"condition",
",",
"String",
"propName",
")",
"{",
"if",
"(",
"condition",
"==",
"true",
")",
"{",
"IllegalStateException",
"e",
"=",
"new",
"IllegalStateException",
"(",
"\"J2CGlobalConfigProperties: internal error. Set once property already set.\"",
")",
";",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"SET_ONCE_PROP_ALREADY_SET_J2CA0159\"",
",",
"(",
"Object",
")",
"null",
")",
";",
"throw",
"e",
";",
"}",
"}"
] | Utility method for set once methods. | [
"Utility",
"method",
"for",
"set",
"once",
"methods",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/J2CGlobalConfigProperties.java#L784-L790 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/J2CGlobalConfigProperties.java | J2CGlobalConfigProperties.applyRequestGroupConfigChanges | public synchronized final void applyRequestGroupConfigChanges() {
// Note: on the following call the "false,true" forces the change notification
// to be sent. The listener will then pick up all property values in the
// group.
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(this, tc, "applyRequestGroupConfigChanges");
changeSupport.firePropertyChange("applyRequestGroupConfigChanges", false, true);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(this, tc, "applyRequestGroupConfigChanges");
} | java | public synchronized final void applyRequestGroupConfigChanges() {
// Note: on the following call the "false,true" forces the change notification
// to be sent. The listener will then pick up all property values in the
// group.
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(this, tc, "applyRequestGroupConfigChanges");
changeSupport.firePropertyChange("applyRequestGroupConfigChanges", false, true);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(this, tc, "applyRequestGroupConfigChanges");
} | [
"public",
"synchronized",
"final",
"void",
"applyRequestGroupConfigChanges",
"(",
")",
"{",
"// Note: on the following call the \"false,true\" forces the change notification",
"// to be sent. The listener will then pick up all property values in the",
"// group.",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"applyRequestGroupConfigChanges\"",
")",
";",
"changeSupport",
".",
"firePropertyChange",
"(",
"\"applyRequestGroupConfigChanges\"",
",",
"false",
",",
"true",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"applyRequestGroupConfigChanges\"",
")",
";",
"}"
] | Request Stat variable group | [
"Request",
"Stat",
"variable",
"group"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/J2CGlobalConfigProperties.java#L895-L906 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.comms.server/src/com/ibm/ws/sib/comms/server/IdToObjectMap.java | IdToObjectMap.get | public Object get(int key) throws SIErrorException // D214655
{
if (tc.isEntryEnabled()) SibTr.entry(tc, "get");
if (tc.isDebugEnabled()) SibTr.debug(tc, "key: "+key); // f174137
captiveComparitorKey.setValue(key);
if (tc.isDebugEnabled()) SibTr.debug(tc, "captiveComparitorKey: "+captiveComparitorKey); // f174317
// Start D214655
Object retObject = map.get(captiveComparitorKey);
if (retObject == null)
{
// If no object existed this is always an error too
throw new SIErrorException(
nls.getFormattedMessage("NO_SUCH_KEY_SICO2059", new Object[] {""+key}, null) // D256974
);
}
if (tc.isEntryEnabled()) SibTr.exit(tc, "get");
return retObject;
// End D214655
} | java | public Object get(int key) throws SIErrorException // D214655
{
if (tc.isEntryEnabled()) SibTr.entry(tc, "get");
if (tc.isDebugEnabled()) SibTr.debug(tc, "key: "+key); // f174137
captiveComparitorKey.setValue(key);
if (tc.isDebugEnabled()) SibTr.debug(tc, "captiveComparitorKey: "+captiveComparitorKey); // f174317
// Start D214655
Object retObject = map.get(captiveComparitorKey);
if (retObject == null)
{
// If no object existed this is always an error too
throw new SIErrorException(
nls.getFormattedMessage("NO_SUCH_KEY_SICO2059", new Object[] {""+key}, null) // D256974
);
}
if (tc.isEntryEnabled()) SibTr.exit(tc, "get");
return retObject;
// End D214655
} | [
"public",
"Object",
"get",
"(",
"int",
"key",
")",
"throws",
"SIErrorException",
"// D214655",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"get\"",
")",
";",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"SibTr",
".",
"debug",
"(",
"tc",
",",
"\"key: \"",
"+",
"key",
")",
";",
"// f174137",
"captiveComparitorKey",
".",
"setValue",
"(",
"key",
")",
";",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"SibTr",
".",
"debug",
"(",
"tc",
",",
"\"captiveComparitorKey: \"",
"+",
"captiveComparitorKey",
")",
";",
"// f174317",
"// Start D214655",
"Object",
"retObject",
"=",
"map",
".",
"get",
"(",
"captiveComparitorKey",
")",
";",
"if",
"(",
"retObject",
"==",
"null",
")",
"{",
"// If no object existed this is always an error too",
"throw",
"new",
"SIErrorException",
"(",
"nls",
".",
"getFormattedMessage",
"(",
"\"NO_SUCH_KEY_SICO2059\"",
",",
"new",
"Object",
"[",
"]",
"{",
"\"\"",
"+",
"key",
"}",
",",
"null",
")",
"// D256974",
")",
";",
"}",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"get\"",
")",
";",
"return",
"retObject",
";",
"// End D214655",
"}"
] | Retrives the object associated with a particular key from the map.
@param key
@return Object
@throws SIErrorException if the element did not exist | [
"Retrives",
"the",
"object",
"associated",
"with",
"a",
"particular",
"key",
"from",
"the",
"map",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.comms.server/src/com/ibm/ws/sib/comms/server/IdToObjectMap.java#L113-L137 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.comms.server/src/com/ibm/ws/sib/comms/server/IdToObjectMap.java | IdToObjectMap.remove | public Object remove(int key) throws SIErrorException // D214655
{
if (tc.isEntryEnabled()) SibTr.entry(tc, "remove", ""+key);
captiveComparitorKey.setValue(key);
// Start D214655
Object retObject = map.remove(captiveComparitorKey);
if (retObject == null)
{
// If no object existed this is always an error too
throw new SIErrorException(
nls.getFormattedMessage("NO_SUCH_KEY_SICO2059", new Object[] {""+key}, null) // D256974
);
}
if (tc.isEntryEnabled()) SibTr.exit(tc, "remove");
return retObject;
// End D214655
} | java | public Object remove(int key) throws SIErrorException // D214655
{
if (tc.isEntryEnabled()) SibTr.entry(tc, "remove", ""+key);
captiveComparitorKey.setValue(key);
// Start D214655
Object retObject = map.remove(captiveComparitorKey);
if (retObject == null)
{
// If no object existed this is always an error too
throw new SIErrorException(
nls.getFormattedMessage("NO_SUCH_KEY_SICO2059", new Object[] {""+key}, null) // D256974
);
}
if (tc.isEntryEnabled()) SibTr.exit(tc, "remove");
return retObject;
// End D214655
} | [
"public",
"Object",
"remove",
"(",
"int",
"key",
")",
"throws",
"SIErrorException",
"// D214655",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"remove\"",
",",
"\"\"",
"+",
"key",
")",
";",
"captiveComparitorKey",
".",
"setValue",
"(",
"key",
")",
";",
"// Start D214655",
"Object",
"retObject",
"=",
"map",
".",
"remove",
"(",
"captiveComparitorKey",
")",
";",
"if",
"(",
"retObject",
"==",
"null",
")",
"{",
"// If no object existed this is always an error too",
"throw",
"new",
"SIErrorException",
"(",
"nls",
".",
"getFormattedMessage",
"(",
"\"NO_SUCH_KEY_SICO2059\"",
",",
"new",
"Object",
"[",
"]",
"{",
"\"\"",
"+",
"key",
"}",
",",
"null",
")",
"// D256974",
")",
";",
"}",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"remove\"",
")",
";",
"return",
"retObject",
";",
"// End D214655",
"}"
] | Removes an object from the map.
@param key
@return Object
@throws SIErrorException if the element did not exist | [
"Removes",
"an",
"object",
"from",
"the",
"map",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.comms.server/src/com/ibm/ws/sib/comms/server/IdToObjectMap.java#L145-L166 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.comms.server/src/com/ibm/ws/sib/comms/server/IdToObjectMap.java | IdToObjectMap.iterator | public Iterator iterator()
{
if (tc.isEntryEnabled()) SibTr.entry(tc, "iterator");
if (tc.isEntryEnabled()) SibTr.exit(tc, "iterator");
return map.values().iterator();
} | java | public Iterator iterator()
{
if (tc.isEntryEnabled()) SibTr.entry(tc, "iterator");
if (tc.isEntryEnabled()) SibTr.exit(tc, "iterator");
return map.values().iterator();
} | [
"public",
"Iterator",
"iterator",
"(",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"iterator\"",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"iterator\"",
")",
";",
"return",
"map",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
";",
"}"
] | Returns an iterator with which to browse the values
@return Iterator | [
"Returns",
"an",
"iterator",
"with",
"which",
"to",
"browse",
"the",
"values"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.comms.server/src/com/ibm/ws/sib/comms/server/IdToObjectMap.java#L174-L180 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.comms.server/src/com/ibm/ws/sib/comms/server/IdToObjectMap.java | IdToObjectMap.containsKey | public boolean containsKey(int id)
{
if (tc.isEntryEnabled()) SibTr.entry(tc, "get", ""+id);
captiveComparitorKey.setValue(id);
final boolean result = map.containsKey(captiveComparitorKey);
if (tc.isEntryEnabled()) SibTr.exit(tc, "get", ""+result);
return result;
} | java | public boolean containsKey(int id)
{
if (tc.isEntryEnabled()) SibTr.entry(tc, "get", ""+id);
captiveComparitorKey.setValue(id);
final boolean result = map.containsKey(captiveComparitorKey);
if (tc.isEntryEnabled()) SibTr.exit(tc, "get", ""+result);
return result;
} | [
"public",
"boolean",
"containsKey",
"(",
"int",
"id",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"get\"",
",",
"\"\"",
"+",
"id",
")",
";",
"captiveComparitorKey",
".",
"setValue",
"(",
"id",
")",
";",
"final",
"boolean",
"result",
"=",
"map",
".",
"containsKey",
"(",
"captiveComparitorKey",
")",
";",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"get\"",
",",
"\"\"",
"+",
"result",
")",
";",
"return",
"result",
";",
"}"
] | Determines if the specified id is present in the IdToObjectMap
@param id the id to check
@return boolean true if (and only if) the id is present in the
map. | [
"Determines",
"if",
"the",
"specified",
"id",
"is",
"present",
"in",
"the",
"IdToObjectMap"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.comms.server/src/com/ibm/ws/sib/comms/server/IdToObjectMap.java#L203-L212 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/JIT_Debug.java | JIT_Debug.checkCast | public static Object checkCast(Object value, Object object, String valueClassName)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{
ClassLoader valueLoader = value == null ? null :
AccessController.doPrivileged(new GetClassLoaderPrivileged(value.getClass()));
ClassLoader contextLoader =
AccessController.doPrivileged(new GetContextClassLoaderPrivileged());
ClassLoader objectLoader =
AccessController.doPrivileged(new GetClassLoaderPrivileged(object.getClass()));
ClassLoader objectValueLoader;
try
{
Class<?> objectValueClass = Class.forName(valueClassName, false, objectLoader);
objectValueLoader = objectValueClass == null ? null :
AccessController.doPrivileged(new GetClassLoaderPrivileged(objectValueClass));
} catch (Throwable t)
{
Tr.debug(tc, "checkCast: failed to load " + valueClassName, t);
objectValueLoader = null;
}
Tr.debug(tc, "checkCast: value=" + Util.identity(value) +
", valueClassName=" + valueClassName,
", valueLoader=" + Util.identity(valueLoader) +
", contextLoader=" + Util.identity(contextLoader) +
", object=" + Util.identity(object) +
", objectLoader=" + Util.identity(objectLoader) +
", objectValueLoader=" + Util.identity(objectValueLoader));
}
return value;
} | java | public static Object checkCast(Object value, Object object, String valueClassName)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{
ClassLoader valueLoader = value == null ? null :
AccessController.doPrivileged(new GetClassLoaderPrivileged(value.getClass()));
ClassLoader contextLoader =
AccessController.doPrivileged(new GetContextClassLoaderPrivileged());
ClassLoader objectLoader =
AccessController.doPrivileged(new GetClassLoaderPrivileged(object.getClass()));
ClassLoader objectValueLoader;
try
{
Class<?> objectValueClass = Class.forName(valueClassName, false, objectLoader);
objectValueLoader = objectValueClass == null ? null :
AccessController.doPrivileged(new GetClassLoaderPrivileged(objectValueClass));
} catch (Throwable t)
{
Tr.debug(tc, "checkCast: failed to load " + valueClassName, t);
objectValueLoader = null;
}
Tr.debug(tc, "checkCast: value=" + Util.identity(value) +
", valueClassName=" + valueClassName,
", valueLoader=" + Util.identity(valueLoader) +
", contextLoader=" + Util.identity(contextLoader) +
", object=" + Util.identity(object) +
", objectLoader=" + Util.identity(objectLoader) +
", objectValueLoader=" + Util.identity(objectValueLoader));
}
return value;
} | [
"public",
"static",
"Object",
"checkCast",
"(",
"Object",
"value",
",",
"Object",
"object",
",",
"String",
"valueClassName",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"ClassLoader",
"valueLoader",
"=",
"value",
"==",
"null",
"?",
"null",
":",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"GetClassLoaderPrivileged",
"(",
"value",
".",
"getClass",
"(",
")",
")",
")",
";",
"ClassLoader",
"contextLoader",
"=",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"GetContextClassLoaderPrivileged",
"(",
")",
")",
";",
"ClassLoader",
"objectLoader",
"=",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"GetClassLoaderPrivileged",
"(",
"object",
".",
"getClass",
"(",
")",
")",
")",
";",
"ClassLoader",
"objectValueLoader",
";",
"try",
"{",
"Class",
"<",
"?",
">",
"objectValueClass",
"=",
"Class",
".",
"forName",
"(",
"valueClassName",
",",
"false",
",",
"objectLoader",
")",
";",
"objectValueLoader",
"=",
"objectValueClass",
"==",
"null",
"?",
"null",
":",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"GetClassLoaderPrivileged",
"(",
"objectValueClass",
")",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"checkCast: failed to load \"",
"+",
"valueClassName",
",",
"t",
")",
";",
"objectValueLoader",
"=",
"null",
";",
"}",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"checkCast: value=\"",
"+",
"Util",
".",
"identity",
"(",
"value",
")",
"+",
"\", valueClassName=\"",
"+",
"valueClassName",
",",
"\", valueLoader=\"",
"+",
"Util",
".",
"identity",
"(",
"valueLoader",
")",
"+",
"\", contextLoader=\"",
"+",
"Util",
".",
"identity",
"(",
"contextLoader",
")",
"+",
"\", object=\"",
"+",
"Util",
".",
"identity",
"(",
"object",
")",
"+",
"\", objectLoader=\"",
"+",
"Util",
".",
"identity",
"(",
"objectLoader",
")",
"+",
"\", objectValueLoader=\"",
"+",
"Util",
".",
"identity",
"(",
"objectValueLoader",
")",
")",
";",
"}",
"return",
"value",
";",
"}"
] | Called by JIT-deployed code that is performing a checkcast. For the
convenience of generated code, the input value is returned directly.
@param value the value being cast
@param object the object performing the cast
@param valueClassName the expected class name
@return value | [
"Called",
"by",
"JIT",
"-",
"deployed",
"code",
"that",
"is",
"performing",
"a",
"checkcast",
".",
"For",
"the",
"convenience",
"of",
"generated",
"code",
"the",
"input",
"value",
"is",
"returned",
"directly",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/JIT_Debug.java#L39-L72 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.getNode | GBSNode getNode(Object newKey)
{
GBSNode p;
if (_nodePool == null)
p = new GBSNode(this, newKey);
else
{
p = _nodePool;
_nodePool = p.rightChild();
p.reset(newKey);
}
return p;
} | java | GBSNode getNode(Object newKey)
{
GBSNode p;
if (_nodePool == null)
p = new GBSNode(this, newKey);
else
{
p = _nodePool;
_nodePool = p.rightChild();
p.reset(newKey);
}
return p;
} | [
"GBSNode",
"getNode",
"(",
"Object",
"newKey",
")",
"{",
"GBSNode",
"p",
";",
"if",
"(",
"_nodePool",
"==",
"null",
")",
"p",
"=",
"new",
"GBSNode",
"(",
"this",
",",
"newKey",
")",
";",
"else",
"{",
"p",
"=",
"_nodePool",
";",
"_nodePool",
"=",
"p",
".",
"rightChild",
"(",
")",
";",
"p",
".",
"reset",
"(",
"newKey",
")",
";",
"}",
"return",
"p",
";",
"}"
] | Allocate a new node for the tree.
@param newKey The initial key for the new node.
@return The new node. | [
"Allocate",
"a",
"new",
"node",
"for",
"the",
"tree",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L344-L356 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.prePopulate | public void prePopulate(int x)
{
for (int i = 0; i < x; i++)
{
GBSNode p = new GBSNode(this);
releaseNode(p);
}
} | java | public void prePopulate(int x)
{
for (int i = 0; i < x; i++)
{
GBSNode p = new GBSNode(this);
releaseNode(p);
}
} | [
"public",
"void",
"prePopulate",
"(",
"int",
"x",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"x",
";",
"i",
"++",
")",
"{",
"GBSNode",
"p",
"=",
"new",
"GBSNode",
"(",
"this",
")",
";",
"releaseNode",
"(",
"p",
")",
";",
"}",
"}"
] | Add some number of free nodes to the node pool for testing.
@param x The number of nodes to add. | [
"Add",
"some",
"number",
"of",
"free",
"nodes",
"to",
"the",
"node",
"pool",
"for",
"testing",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L363-L370 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.maximumFringeImbalance | public int maximumFringeImbalance()
{
int maxBal;
GBSNode q = root();
if (q.leftChild() == null)
{
maxBal = kFactor() - 1;
if (maxBal < 3)
maxBal = 3;
}
else
{
if ((kFactor() % 3) == 0)
maxBal = kFactor() + 2;
else
maxBal = kFactor() + 1;
}
return maxBal;
} | java | public int maximumFringeImbalance()
{
int maxBal;
GBSNode q = root();
if (q.leftChild() == null)
{
maxBal = kFactor() - 1;
if (maxBal < 3)
maxBal = 3;
}
else
{
if ((kFactor() % 3) == 0)
maxBal = kFactor() + 2;
else
maxBal = kFactor() + 1;
}
return maxBal;
} | [
"public",
"int",
"maximumFringeImbalance",
"(",
")",
"{",
"int",
"maxBal",
";",
"GBSNode",
"q",
"=",
"root",
"(",
")",
";",
"if",
"(",
"q",
".",
"leftChild",
"(",
")",
"==",
"null",
")",
"{",
"maxBal",
"=",
"kFactor",
"(",
")",
"-",
"1",
";",
"if",
"(",
"maxBal",
"<",
"3",
")",
"maxBal",
"=",
"3",
";",
"}",
"else",
"{",
"if",
"(",
"(",
"kFactor",
"(",
")",
"%",
"3",
")",
"==",
"0",
")",
"maxBal",
"=",
"kFactor",
"(",
")",
"+",
"2",
";",
"else",
"maxBal",
"=",
"kFactor",
"(",
")",
"+",
"1",
";",
"}",
"return",
"maxBal",
";",
"}"
] | Return the maximum imbalance allowed for a fringe.
<p>This depends on the K Factor and on whether or not the tree is
a special case of a single fringe.</p> | [
"Return",
"the",
"maximum",
"imbalance",
"allowed",
"for",
"a",
"fringe",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L505-L523 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.calcTZeroDepth | private int calcTZeroDepth(int proposedK)
{
int d = -1;
if ( (proposedK >= 0) && (proposedK < _t0_d.length) )
d = _t0_d[proposedK];
if (d < 0)
{
String x =
"K Factor (" + proposedK + ") is invalid.\n" +
"Valid K factors are: " + kFactorString() + ".";
throw new IllegalArgumentException(x);
}
return d;
} | java | private int calcTZeroDepth(int proposedK)
{
int d = -1;
if ( (proposedK >= 0) && (proposedK < _t0_d.length) )
d = _t0_d[proposedK];
if (d < 0)
{
String x =
"K Factor (" + proposedK + ") is invalid.\n" +
"Valid K factors are: " + kFactorString() + ".";
throw new IllegalArgumentException(x);
}
return d;
} | [
"private",
"int",
"calcTZeroDepth",
"(",
"int",
"proposedK",
")",
"{",
"int",
"d",
"=",
"-",
"1",
";",
"if",
"(",
"(",
"proposedK",
">=",
"0",
")",
"&&",
"(",
"proposedK",
"<",
"_t0_d",
".",
"length",
")",
")",
"d",
"=",
"_t0_d",
"[",
"proposedK",
"]",
";",
"if",
"(",
"d",
"<",
"0",
")",
"{",
"String",
"x",
"=",
"\"K Factor (\"",
"+",
"proposedK",
"+",
"\") is invalid.\\n\"",
"+",
"\"Valid K factors are: \"",
"+",
"kFactorString",
"(",
")",
"+",
"\".\"",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"x",
")",
";",
"}",
"return",
"d",
";",
"}"
] | Set the depth of a T0 sub-tree. | [
"Set",
"the",
"depth",
"of",
"a",
"T0",
"sub",
"-",
"tree",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L528-L541 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.checkForPossibleIndexChange | static boolean checkForPossibleIndexChange(
int v1,
int v2,
Throwable exc,
String msg)
{
if (v1 != v2)
return pessimisticNeeded;
else
{
GBSTreeException x = new GBSTreeException(
msg + ", v1 = " + v1, exc);
throw x;
}
} | java | static boolean checkForPossibleIndexChange(
int v1,
int v2,
Throwable exc,
String msg)
{
if (v1 != v2)
return pessimisticNeeded;
else
{
GBSTreeException x = new GBSTreeException(
msg + ", v1 = " + v1, exc);
throw x;
}
} | [
"static",
"boolean",
"checkForPossibleIndexChange",
"(",
"int",
"v1",
",",
"int",
"v2",
",",
"Throwable",
"exc",
",",
"String",
"msg",
")",
"{",
"if",
"(",
"v1",
"!=",
"v2",
")",
"return",
"pessimisticNeeded",
";",
"else",
"{",
"GBSTreeException",
"x",
"=",
"new",
"GBSTreeException",
"(",
"msg",
"+",
"\", v1 = \"",
"+",
"v1",
",",
"exc",
")",
";",
"throw",
"x",
";",
"}",
"}"
] | Process an exception that may have occurred while the index was
changing.
<p>An optimistic search hit an exception that may have been caused by
a change in the index in mid-search. The two parameters v1 and v2
represent the index vno at the time the search started and at the
time the exception was caught. If the two are different then the
index changed in mid-search and we assume that was the reason for the
exception. We return "pessimisticNeeded" which indicates that a
pessimistic search is now required. If the index structure is,
indeed, damaged then the pessimistic search will encounter the same
exception. If the two version numbers are the same then the index
did not change in mid-search and the exception is an indication of
either a programming error or a fatal corruption of the index.</p>
@param v1 The version number at the time the search started.
@param v2 The version number at the time the exception was caught.
@param exc The Exception that was caught.
@param msg A message to store with the new exception.
@return pessimisticNeeded if the version numbers have changed and
a pessimistic search is required. | [
"Process",
"an",
"exception",
"that",
"may",
"have",
"occurred",
"while",
"the",
"index",
"was",
"changing",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L589-L603 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.iterator | public Iterator iterator()
{
GBSIterator x = new GBSIterator(this);
Iterator q = (Iterator) x;
return q;
} | java | public Iterator iterator()
{
GBSIterator x = new GBSIterator(this);
Iterator q = (Iterator) x;
return q;
} | [
"public",
"Iterator",
"iterator",
"(",
")",
"{",
"GBSIterator",
"x",
"=",
"new",
"GBSIterator",
"(",
"this",
")",
";",
"Iterator",
"q",
"=",
"(",
"Iterator",
")",
"x",
";",
"return",
"q",
";",
"}"
] | Create and return an Iterator positioned on the beginning of the tree.
<p>The Iterator is not actually positioned on the beginning of the
tree. It has no position at all. The first time Iterator.next() is
invoked it will position itself on the beginning of the tree.</p> | [
"Create",
"and",
"return",
"an",
"Iterator",
"positioned",
"on",
"the",
"beginning",
"of",
"the",
"tree",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L612-L617 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.searchEqual | public Object searchEqual(
Object searchKey)
{
SearchComparator comp = searchComparator(SearchComparator.EQ);
Object p = find(comp, searchKey);
return p;
} | java | public Object searchEqual(
Object searchKey)
{
SearchComparator comp = searchComparator(SearchComparator.EQ);
Object p = find(comp, searchKey);
return p;
} | [
"public",
"Object",
"searchEqual",
"(",
"Object",
"searchKey",
")",
"{",
"SearchComparator",
"comp",
"=",
"searchComparator",
"(",
"SearchComparator",
".",
"EQ",
")",
";",
"Object",
"p",
"=",
"find",
"(",
"comp",
",",
"searchKey",
")",
";",
"return",
"p",
";",
"}"
] | Find the first key in the index that is equal to the given key.
@param searchKey The key to be found.
@return The first key in the index that is equal to the supplied key
(searchKey). | [
"Find",
"the",
"first",
"key",
"in",
"the",
"index",
"that",
"is",
"equal",
"to",
"the",
"given",
"key",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L627-L633 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.searchGreater | public Object searchGreater(
Object searchKey)
{
SearchComparator comp = searchComparator(SearchComparator.GT);
Object p = find(comp, searchKey);
return p;
} | java | public Object searchGreater(
Object searchKey)
{
SearchComparator comp = searchComparator(SearchComparator.GT);
Object p = find(comp, searchKey);
return p;
} | [
"public",
"Object",
"searchGreater",
"(",
"Object",
"searchKey",
")",
"{",
"SearchComparator",
"comp",
"=",
"searchComparator",
"(",
"SearchComparator",
".",
"GT",
")",
";",
"Object",
"p",
"=",
"find",
"(",
"comp",
",",
"searchKey",
")",
";",
"return",
"p",
";",
"}"
] | Find the first key in the index that is greater than the given key.
@param searchKey The key to be found.
@return The first key in the index that is strictly greater than
the supplied key (searchKey). | [
"Find",
"the",
"first",
"key",
"in",
"the",
"index",
"that",
"is",
"greater",
"than",
"the",
"given",
"key",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L643-L649 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.searchGreaterOrEqual | public Object searchGreaterOrEqual(
Object searchKey)
{
SearchComparator comp = searchComparator(SearchComparator.GE);
Object p = find(comp, searchKey);
return p;
} | java | public Object searchGreaterOrEqual(
Object searchKey)
{
SearchComparator comp = searchComparator(SearchComparator.GE);
Object p = find(comp, searchKey);
return p;
} | [
"public",
"Object",
"searchGreaterOrEqual",
"(",
"Object",
"searchKey",
")",
"{",
"SearchComparator",
"comp",
"=",
"searchComparator",
"(",
"SearchComparator",
".",
"GE",
")",
";",
"Object",
"p",
"=",
"find",
"(",
"comp",
",",
"searchKey",
")",
";",
"return",
"p",
";",
"}"
] | Find the first key in the index that is greater than or equal to
the given key.
@param searchKey The key to be found.
@return The first key in the index that is greater than or equal to
the supplied key (searchKey). | [
"Find",
"the",
"first",
"key",
"in",
"the",
"index",
"that",
"is",
"greater",
"than",
"or",
"equal",
"to",
"the",
"given",
"key",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L660-L666 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.getSearchNode | private SearchNode getSearchNode()
{
Object x = _searchNode.get();
SearchNode g = null;
if (x != null)
{
g = (SearchNode) x;
g.reset();
}
else
{
g = new SearchNode();
x = (Object) g;
_searchNode.set(x);
}
return g;
} | java | private SearchNode getSearchNode()
{
Object x = _searchNode.get();
SearchNode g = null;
if (x != null)
{
g = (SearchNode) x;
g.reset();
}
else
{
g = new SearchNode();
x = (Object) g;
_searchNode.set(x);
}
return g;
} | [
"private",
"SearchNode",
"getSearchNode",
"(",
")",
"{",
"Object",
"x",
"=",
"_searchNode",
".",
"get",
"(",
")",
";",
"SearchNode",
"g",
"=",
"null",
";",
"if",
"(",
"x",
"!=",
"null",
")",
"{",
"g",
"=",
"(",
"SearchNode",
")",
"x",
";",
"g",
".",
"reset",
"(",
")",
";",
"}",
"else",
"{",
"g",
"=",
"new",
"SearchNode",
"(",
")",
";",
"x",
"=",
"(",
"Object",
")",
"g",
";",
"_searchNode",
".",
"set",
"(",
"x",
")",
";",
"}",
"return",
"g",
";",
"}"
] | Find a SearchNode for use by the current thread.
<p>Allocation of a SearchNode is more expensive than serial
reuse. This is a very cheap form of pooling done by attaching a
SearchNode to each thread that calls find.</p> | [
"Find",
"a",
"SearchNode",
"for",
"use",
"by",
"the",
"current",
"thread",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L678-L694 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.optimisticFind | private boolean optimisticFind(
SearchComparator comp,
Object searchKey,
SearchNode point)
{
point.reset();
int v1 = _vno;
if (root() != null)
{
if ((v1&1) != 0)
return pessimisticNeeded;
synchronized(point)
{
}
try
{
internalFind(comp, searchKey, point);
}
catch (NullPointerException npe)
{
//No FFDC Code Needed.
_nullPointerExceptions++;
return checkForPossibleIndexChange(v1, _vno, npe, "optimisticInsert");
}
catch (OptimisticDepthException ode)
{
//No FFDC Code Needed.
_optimisticDepthExceptions++;
return checkForPossibleIndexChange(v1, _vno, ode, "optimisticInsert");
}
if (v1 != _vno)
return pessimisticNeeded;
}
_optimisticFinds++;
return optimisticWorked;
} | java | private boolean optimisticFind(
SearchComparator comp,
Object searchKey,
SearchNode point)
{
point.reset();
int v1 = _vno;
if (root() != null)
{
if ((v1&1) != 0)
return pessimisticNeeded;
synchronized(point)
{
}
try
{
internalFind(comp, searchKey, point);
}
catch (NullPointerException npe)
{
//No FFDC Code Needed.
_nullPointerExceptions++;
return checkForPossibleIndexChange(v1, _vno, npe, "optimisticInsert");
}
catch (OptimisticDepthException ode)
{
//No FFDC Code Needed.
_optimisticDepthExceptions++;
return checkForPossibleIndexChange(v1, _vno, ode, "optimisticInsert");
}
if (v1 != _vno)
return pessimisticNeeded;
}
_optimisticFinds++;
return optimisticWorked;
} | [
"private",
"boolean",
"optimisticFind",
"(",
"SearchComparator",
"comp",
",",
"Object",
"searchKey",
",",
"SearchNode",
"point",
")",
"{",
"point",
".",
"reset",
"(",
")",
";",
"int",
"v1",
"=",
"_vno",
";",
"if",
"(",
"root",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"(",
"v1",
"&",
"1",
")",
"!=",
"0",
")",
"return",
"pessimisticNeeded",
";",
"synchronized",
"(",
"point",
")",
"{",
"}",
"try",
"{",
"internalFind",
"(",
"comp",
",",
"searchKey",
",",
"point",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"npe",
")",
"{",
"//No FFDC Code Needed.",
"_nullPointerExceptions",
"++",
";",
"return",
"checkForPossibleIndexChange",
"(",
"v1",
",",
"_vno",
",",
"npe",
",",
"\"optimisticInsert\"",
")",
";",
"}",
"catch",
"(",
"OptimisticDepthException",
"ode",
")",
"{",
"//No FFDC Code Needed.",
"_optimisticDepthExceptions",
"++",
";",
"return",
"checkForPossibleIndexChange",
"(",
"v1",
",",
"_vno",
",",
"ode",
",",
"\"optimisticInsert\"",
")",
";",
"}",
"if",
"(",
"v1",
"!=",
"_vno",
")",
"return",
"pessimisticNeeded",
";",
"}",
"_optimisticFinds",
"++",
";",
"return",
"optimisticWorked",
";",
"}"
] | Optimistic find in a GBS Tree | [
"Optimistic",
"find",
"in",
"a",
"GBS",
"Tree"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L728-L765 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.pessimisticFind | private void pessimisticFind(
SearchComparator comp,
Object searchKey,
SearchNode point)
{
point.reset();
synchronized(this)
{
internalFind(comp, searchKey, point);
_pessimisticFinds++;
}
} | java | private void pessimisticFind(
SearchComparator comp,
Object searchKey,
SearchNode point)
{
point.reset();
synchronized(this)
{
internalFind(comp, searchKey, point);
_pessimisticFinds++;
}
} | [
"private",
"void",
"pessimisticFind",
"(",
"SearchComparator",
"comp",
",",
"Object",
"searchKey",
",",
"SearchNode",
"point",
")",
"{",
"point",
".",
"reset",
"(",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"internalFind",
"(",
"comp",
",",
"searchKey",
",",
"point",
")",
";",
"_pessimisticFinds",
"++",
";",
"}",
"}"
] | Pessimistic find in a GBS Tree | [
"Pessimistic",
"find",
"in",
"a",
"GBS",
"Tree"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L771-L783 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.iteratorFind | synchronized Object iteratorFind(
DeleteStack stack,
SearchComparator comp,
Object searchKey,
SearchNode point)
{
point.reset();
GBSNode p = root();
GBSNode l = null;
GBSNode r = null;
int lx = 0;
int rx = 0;
Object ret = null;
stack.start(dummyTopNode(), "GBSTree.iteratorFind");
while (p != null)
{
int xcc = comp.compare(searchKey, p.middleKey());
if (xcc == 0)
{
point.setFound(p, p.middleIndex());
p = null;
}
else if (xcc < 0)
{
if (p.leftChild() != null)
{
stack.push(NodeStack.PROCESS_CURRENT, p, "GBSTree.iteratorFind(1)");
l = p;
lx = stack.index();
p = p.leftChild();
}
else
{
leftSearch(comp, p, r, searchKey, point);
if (point.wasFound())
{
if (point.foundNode() == r)
stack.reset(rx - 1);
}
p = null;
}
}
else // (xcc > 0)
{
if (p.rightChild() != null)
{
stack.push(NodeStack.DONE_VISITS, p, "GBSTree.iteratorFind(2)");
r = p;
rx = stack.index();
p = p.rightChild();
}
else
{
rightSearch(comp, p, l, searchKey, point);
if (point.wasFound())
{
if (point.foundNode() == l)
stack.reset(lx - 1);
}
p = null;
}
}
}
if (point.wasFound())
{
ret = point.foundNode().key(point.foundIndex());
point.setLocation(ret);
}
return ret;
} | java | synchronized Object iteratorFind(
DeleteStack stack,
SearchComparator comp,
Object searchKey,
SearchNode point)
{
point.reset();
GBSNode p = root();
GBSNode l = null;
GBSNode r = null;
int lx = 0;
int rx = 0;
Object ret = null;
stack.start(dummyTopNode(), "GBSTree.iteratorFind");
while (p != null)
{
int xcc = comp.compare(searchKey, p.middleKey());
if (xcc == 0)
{
point.setFound(p, p.middleIndex());
p = null;
}
else if (xcc < 0)
{
if (p.leftChild() != null)
{
stack.push(NodeStack.PROCESS_CURRENT, p, "GBSTree.iteratorFind(1)");
l = p;
lx = stack.index();
p = p.leftChild();
}
else
{
leftSearch(comp, p, r, searchKey, point);
if (point.wasFound())
{
if (point.foundNode() == r)
stack.reset(rx - 1);
}
p = null;
}
}
else // (xcc > 0)
{
if (p.rightChild() != null)
{
stack.push(NodeStack.DONE_VISITS, p, "GBSTree.iteratorFind(2)");
r = p;
rx = stack.index();
p = p.rightChild();
}
else
{
rightSearch(comp, p, l, searchKey, point);
if (point.wasFound())
{
if (point.foundNode() == l)
stack.reset(lx - 1);
}
p = null;
}
}
}
if (point.wasFound())
{
ret = point.foundNode().key(point.foundIndex());
point.setLocation(ret);
}
return ret;
} | [
"synchronized",
"Object",
"iteratorFind",
"(",
"DeleteStack",
"stack",
",",
"SearchComparator",
"comp",
",",
"Object",
"searchKey",
",",
"SearchNode",
"point",
")",
"{",
"point",
".",
"reset",
"(",
")",
";",
"GBSNode",
"p",
"=",
"root",
"(",
")",
";",
"GBSNode",
"l",
"=",
"null",
";",
"GBSNode",
"r",
"=",
"null",
";",
"int",
"lx",
"=",
"0",
";",
"int",
"rx",
"=",
"0",
";",
"Object",
"ret",
"=",
"null",
";",
"stack",
".",
"start",
"(",
"dummyTopNode",
"(",
")",
",",
"\"GBSTree.iteratorFind\"",
")",
";",
"while",
"(",
"p",
"!=",
"null",
")",
"{",
"int",
"xcc",
"=",
"comp",
".",
"compare",
"(",
"searchKey",
",",
"p",
".",
"middleKey",
"(",
")",
")",
";",
"if",
"(",
"xcc",
"==",
"0",
")",
"{",
"point",
".",
"setFound",
"(",
"p",
",",
"p",
".",
"middleIndex",
"(",
")",
")",
";",
"p",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"xcc",
"<",
"0",
")",
"{",
"if",
"(",
"p",
".",
"leftChild",
"(",
")",
"!=",
"null",
")",
"{",
"stack",
".",
"push",
"(",
"NodeStack",
".",
"PROCESS_CURRENT",
",",
"p",
",",
"\"GBSTree.iteratorFind(1)\"",
")",
";",
"l",
"=",
"p",
";",
"lx",
"=",
"stack",
".",
"index",
"(",
")",
";",
"p",
"=",
"p",
".",
"leftChild",
"(",
")",
";",
"}",
"else",
"{",
"leftSearch",
"(",
"comp",
",",
"p",
",",
"r",
",",
"searchKey",
",",
"point",
")",
";",
"if",
"(",
"point",
".",
"wasFound",
"(",
")",
")",
"{",
"if",
"(",
"point",
".",
"foundNode",
"(",
")",
"==",
"r",
")",
"stack",
".",
"reset",
"(",
"rx",
"-",
"1",
")",
";",
"}",
"p",
"=",
"null",
";",
"}",
"}",
"else",
"// (xcc > 0)",
"{",
"if",
"(",
"p",
".",
"rightChild",
"(",
")",
"!=",
"null",
")",
"{",
"stack",
".",
"push",
"(",
"NodeStack",
".",
"DONE_VISITS",
",",
"p",
",",
"\"GBSTree.iteratorFind(2)\"",
")",
";",
"r",
"=",
"p",
";",
"rx",
"=",
"stack",
".",
"index",
"(",
")",
";",
"p",
"=",
"p",
".",
"rightChild",
"(",
")",
";",
"}",
"else",
"{",
"rightSearch",
"(",
"comp",
",",
"p",
",",
"l",
",",
"searchKey",
",",
"point",
")",
";",
"if",
"(",
"point",
".",
"wasFound",
"(",
")",
")",
"{",
"if",
"(",
"point",
".",
"foundNode",
"(",
")",
"==",
"l",
")",
"stack",
".",
"reset",
"(",
"lx",
"-",
"1",
")",
";",
"}",
"p",
"=",
"null",
";",
"}",
"}",
"}",
"if",
"(",
"point",
".",
"wasFound",
"(",
")",
")",
"{",
"ret",
"=",
"point",
".",
"foundNode",
"(",
")",
".",
"key",
"(",
"point",
".",
"foundIndex",
"(",
")",
")",
";",
"point",
".",
"setLocation",
"(",
"ret",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Search the index from an Iterator.
<p>Search the index to find one of the following:</p>
<ol>
<li>An index entry that is exactly equal to the supplied key,
<li>An index entry that is strictly greater than the supplied key, or
<li>An index entry that is greater than or equal to the supplied key.
</ol>
<p>This is called by the Iterator when the tree has had structural
modifications between calls to next(). The only safe way to
re-establish the position of the Iterator is to re-search the
tree. If this is a next() operation then the Iterator is searching
for the key that is greater than the last key given out.</p> | [
"Search",
"the",
"index",
"from",
"an",
"Iterator",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L860-L932 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.leftSearch | private void leftSearch(
SearchComparator comp,
GBSNode p,
GBSNode r,
Object searchKey,
SearchNode point)
{
if (r == null) /* There is no upper predecessor */
{
int idx = p.searchLeft(comp, searchKey);
if ( !(idx < 0) )
point.setFound(p, idx);
}
else /* There is an upper predecessor */
{
int xcc = comp.compare(searchKey, r.rightMostKey());
if (xcc == 0) /* Target is right-most in upper pred. */
point.setFound(r, r.rightMostIndex());
else if (xcc > 0) /* Target (if it exists) is in left */
{
/* half of current node */
int idx = p.searchLeft(comp, searchKey);
if ( !(idx < 0) )
point.setFound(p, idx);
}
else /* Target (if it exists) is in right */
{
/* half of predecessor (if it exists) */
int idx = r.searchRight(comp, searchKey);
if ( !(idx < 0) )
point.setFound(r, idx);
}
}
} | java | private void leftSearch(
SearchComparator comp,
GBSNode p,
GBSNode r,
Object searchKey,
SearchNode point)
{
if (r == null) /* There is no upper predecessor */
{
int idx = p.searchLeft(comp, searchKey);
if ( !(idx < 0) )
point.setFound(p, idx);
}
else /* There is an upper predecessor */
{
int xcc = comp.compare(searchKey, r.rightMostKey());
if (xcc == 0) /* Target is right-most in upper pred. */
point.setFound(r, r.rightMostIndex());
else if (xcc > 0) /* Target (if it exists) is in left */
{
/* half of current node */
int idx = p.searchLeft(comp, searchKey);
if ( !(idx < 0) )
point.setFound(p, idx);
}
else /* Target (if it exists) is in right */
{
/* half of predecessor (if it exists) */
int idx = r.searchRight(comp, searchKey);
if ( !(idx < 0) )
point.setFound(r, idx);
}
}
} | [
"private",
"void",
"leftSearch",
"(",
"SearchComparator",
"comp",
",",
"GBSNode",
"p",
",",
"GBSNode",
"r",
",",
"Object",
"searchKey",
",",
"SearchNode",
"point",
")",
"{",
"if",
"(",
"r",
"==",
"null",
")",
"/* There is no upper predecessor */",
"{",
"int",
"idx",
"=",
"p",
".",
"searchLeft",
"(",
"comp",
",",
"searchKey",
")",
";",
"if",
"(",
"!",
"(",
"idx",
"<",
"0",
")",
")",
"point",
".",
"setFound",
"(",
"p",
",",
"idx",
")",
";",
"}",
"else",
"/* There is an upper predecessor */",
"{",
"int",
"xcc",
"=",
"comp",
".",
"compare",
"(",
"searchKey",
",",
"r",
".",
"rightMostKey",
"(",
")",
")",
";",
"if",
"(",
"xcc",
"==",
"0",
")",
"/* Target is right-most in upper pred. */",
"point",
".",
"setFound",
"(",
"r",
",",
"r",
".",
"rightMostIndex",
"(",
")",
")",
";",
"else",
"if",
"(",
"xcc",
">",
"0",
")",
"/* Target (if it exists) is in left */",
"{",
"/* half of current node */",
"int",
"idx",
"=",
"p",
".",
"searchLeft",
"(",
"comp",
",",
"searchKey",
")",
";",
"if",
"(",
"!",
"(",
"idx",
"<",
"0",
")",
")",
"point",
".",
"setFound",
"(",
"p",
",",
"idx",
")",
";",
"}",
"else",
"/* Target (if it exists) is in right */",
"{",
"/* half of predecessor (if it exists) */",
"int",
"idx",
"=",
"r",
".",
"searchRight",
"(",
"comp",
",",
"searchKey",
")",
";",
"if",
"(",
"!",
"(",
"idx",
"<",
"0",
")",
")",
"point",
".",
"setFound",
"(",
"r",
",",
"idx",
")",
";",
"}",
"}",
"}"
] | Search after falling off a left edge.
<p>We have fallen off of the left edge because the search key is
less than the median of the current node. In the example below if
the current node is GHI then the previous node is DEF and the
desired key is greater than E and less than H. If the curent node
is MNO the previous node is JKL and the desired key is greater than
K and less than N. If the current node is ABC there is no previous
node and the desired key is less than B.</p>
<pre>
*------------------J.K.L------------------*
| |
| |
| |
*-------D.E.F-------* *-------P.Q.R-------*
| | | |
| | | |
| | | |
A.B.C G.H.I M.N.O S.T.U
</pre>
<p>We now have two choices:</p>
<ol>
<li>Check to see if the search key is greater than the right-most
key in the predecessor node.
<li>Check to see if the search key is greater than or equal to the
left-most key in the current node.
</ol>
<p>If either of the above is true we need to search the left half
of the current node. Otherwise we need to search the right half of
the predecessor node. But this only is true if we are looking for
an exact match. With an exact match it doesn't matter whether we
select the node to search by checking right-most key in predecessor
or left-most key in current. But if we are looking for the first
index entry that is greater than the given key we must first check
the right-most key in the upper predecessor (if there is one) to
take care of the case that the key value lies between right-most in
upper predecessor and left-most in current. For in this case we
must search left-most of current.</p>
@param comp The index comparator used by the current search.
@param p The current node.
@param r The logical predecessor node, which is the one from which
we last turned right.
@param searchKey The key we are trying to find.
@param point will contain the node and index of the found key
(if any). | [
"Search",
"after",
"falling",
"off",
"a",
"left",
"edge",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L985-L1018 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.rightSearch | private void rightSearch(
SearchComparator comp,
GBSNode p,
GBSNode l,
Object searchKey,
SearchNode point)
{
int xcc = comp.compare(searchKey, p.rightMostKey());
if (xcc == 0) /* Target is right-most key in current */
point.setFound(p, 0);
else if (xcc < 0) /* Target (if it exists) is in right */
{
/* half of current node */
int idx = p.searchRight(comp, searchKey);
if ( !(idx < 0) )
point.setFound(p, idx);
}
else /* Target (if it exists) is in left */
{
/* half of successor (if it exists) */
if (l != null)
{
int idx = l.searchLeft(comp, searchKey);
if ( !(idx < 0) )
point.setFound(l, idx);
}
}
} | java | private void rightSearch(
SearchComparator comp,
GBSNode p,
GBSNode l,
Object searchKey,
SearchNode point)
{
int xcc = comp.compare(searchKey, p.rightMostKey());
if (xcc == 0) /* Target is right-most key in current */
point.setFound(p, 0);
else if (xcc < 0) /* Target (if it exists) is in right */
{
/* half of current node */
int idx = p.searchRight(comp, searchKey);
if ( !(idx < 0) )
point.setFound(p, idx);
}
else /* Target (if it exists) is in left */
{
/* half of successor (if it exists) */
if (l != null)
{
int idx = l.searchLeft(comp, searchKey);
if ( !(idx < 0) )
point.setFound(l, idx);
}
}
} | [
"private",
"void",
"rightSearch",
"(",
"SearchComparator",
"comp",
",",
"GBSNode",
"p",
",",
"GBSNode",
"l",
",",
"Object",
"searchKey",
",",
"SearchNode",
"point",
")",
"{",
"int",
"xcc",
"=",
"comp",
".",
"compare",
"(",
"searchKey",
",",
"p",
".",
"rightMostKey",
"(",
")",
")",
";",
"if",
"(",
"xcc",
"==",
"0",
")",
"/* Target is right-most key in current */",
"point",
".",
"setFound",
"(",
"p",
",",
"0",
")",
";",
"else",
"if",
"(",
"xcc",
"<",
"0",
")",
"/* Target (if it exists) is in right */",
"{",
"/* half of current node */",
"int",
"idx",
"=",
"p",
".",
"searchRight",
"(",
"comp",
",",
"searchKey",
")",
";",
"if",
"(",
"!",
"(",
"idx",
"<",
"0",
")",
")",
"point",
".",
"setFound",
"(",
"p",
",",
"idx",
")",
";",
"}",
"else",
"/* Target (if it exists) is in left */",
"{",
"/* half of successor (if it exists) */",
"if",
"(",
"l",
"!=",
"null",
")",
"{",
"int",
"idx",
"=",
"l",
".",
"searchLeft",
"(",
"comp",
",",
"searchKey",
")",
";",
"if",
"(",
"!",
"(",
"idx",
"<",
"0",
")",
")",
"point",
".",
"setFound",
"(",
"l",
",",
"idx",
")",
";",
"}",
"}",
"}"
] | Search after falling off a right edge.
<p>We have fallen off of the right edge because the search key is
greater than the median of the current node. In the example below
if the current node is GHI then the successor node is JKL and the
desired key is greater than H and less than K. If the curent node
is MNO the successor node is PQR and the desired key is greater
than N and less than Q. If the current node is STU there is no
successor node and the desired key is greater than T.</p>
<pre>
*------------------J.K.L------------------*
| |
| |
| |
*-------D.E.F-------* *-------P.Q.R-------*
| | | |
| | | |
| | | |
A.B.C G.H.I M.N.O S.T.U
</pre>
<p>We now have two choices:
<ol>
<li>Check to see if the search key is less than the left-most
key in the successor node.
<li>Check to see if the search key is less than or equal to the
right-most key in the current node.
</ol>
If either of the above is true we need to search the right half of
the current node. Otherwise we need to search the left half of
the successor node.</p>
@param comp The index comparator used by the current search.
@param p The current node.
@param l The logical successor node, which is the one from which
we last turned left.
@param searchKey The key we are trying to find.
@param point will contain the node and index of the found key
(if any). | [
"Search",
"after",
"falling",
"off",
"a",
"right",
"edge",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1063-L1090 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.getInsertStack | private InsertStack getInsertStack()
{
Object x = _insertStack.get();
InsertStack g = null;
if (x != null)
{
g = (InsertStack) x;
g.reset();
}
else
{
g = new InsertStack(this);
x = (Object) g;
_insertStack.set(x);
}
return g;
} | java | private InsertStack getInsertStack()
{
Object x = _insertStack.get();
InsertStack g = null;
if (x != null)
{
g = (InsertStack) x;
g.reset();
}
else
{
g = new InsertStack(this);
x = (Object) g;
_insertStack.set(x);
}
return g;
} | [
"private",
"InsertStack",
"getInsertStack",
"(",
")",
"{",
"Object",
"x",
"=",
"_insertStack",
".",
"get",
"(",
")",
";",
"InsertStack",
"g",
"=",
"null",
";",
"if",
"(",
"x",
"!=",
"null",
")",
"{",
"g",
"=",
"(",
"InsertStack",
")",
"x",
";",
"g",
".",
"reset",
"(",
")",
";",
"}",
"else",
"{",
"g",
"=",
"new",
"InsertStack",
"(",
"this",
")",
";",
"x",
"=",
"(",
"Object",
")",
"g",
";",
"_insertStack",
".",
"set",
"(",
"x",
")",
";",
"}",
"return",
"g",
";",
"}"
] | Find an InsertStack for use by the current thread.
<p>Allocation of an InsertStack is more expensive than serial
reuse. This is a very cheap form of pooling done by attaching an
InsertStack to each thread that calls insert.</p> | [
"Find",
"an",
"InsertStack",
"for",
"use",
"by",
"the",
"current",
"thread",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1101-L1117 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.insert | public boolean insert(
Object new1)
{
boolean result;
InsertStack stack = getInsertStack();
if (root() == null)
pessimisticInsert(stack, new1);
else
{
boolean didit = optimisticInsert(stack, new1);
if (didit == pessimisticNeeded)
pessimisticInsert(stack, new1);
}
if (stack.isDuplicate())
result = false;
else
result = true;
return result;
} | java | public boolean insert(
Object new1)
{
boolean result;
InsertStack stack = getInsertStack();
if (root() == null)
pessimisticInsert(stack, new1);
else
{
boolean didit = optimisticInsert(stack, new1);
if (didit == pessimisticNeeded)
pessimisticInsert(stack, new1);
}
if (stack.isDuplicate())
result = false;
else
result = true;
return result;
} | [
"public",
"boolean",
"insert",
"(",
"Object",
"new1",
")",
"{",
"boolean",
"result",
";",
"InsertStack",
"stack",
"=",
"getInsertStack",
"(",
")",
";",
"if",
"(",
"root",
"(",
")",
"==",
"null",
")",
"pessimisticInsert",
"(",
"stack",
",",
"new1",
")",
";",
"else",
"{",
"boolean",
"didit",
"=",
"optimisticInsert",
"(",
"stack",
",",
"new1",
")",
";",
"if",
"(",
"didit",
"==",
"pessimisticNeeded",
")",
"pessimisticInsert",
"(",
"stack",
",",
"new1",
")",
";",
"}",
"if",
"(",
"stack",
".",
"isDuplicate",
"(",
")",
")",
"result",
"=",
"false",
";",
"else",
"result",
"=",
"true",
";",
"return",
"result",
";",
"}"
] | Insert into a GBS Tree.
@param new1 The Object to be inserted.
@return true if the Object was inserted, false if the Object was
a duplicate of one already in the tree. | [
"Insert",
"into",
"a",
"GBS",
"Tree",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1127-L1146 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.optimisticInsert | private boolean optimisticInsert(
InsertStack stack,
Object new1)
{
InsertNodes point = stack.insertNodes();
int v1 = _vno;
if (root() == null)
return pessimisticNeeded;
if ((v1&1) != 0)
return pessimisticNeeded;
synchronized(stack)
{
}
try
{
findInsert(
point,
stack,
new1);
}
catch (NullPointerException npe)
{
//No FFDC Code Needed.
_nullPointerExceptions++;
return checkForPossibleIndexChange(v1, _vno, npe, "optimisticInsert");
}
catch (OptimisticDepthException ode)
{
//No FFDC Code Needed.
_optimisticDepthExceptions++;
return checkForPossibleIndexChange(v1, _vno, ode, "optimisticInsert");
}
synchronized(this)
{
if (v1 != _vno)
{
_optimisticInsertSurprises++;
return pessimisticNeeded;
}
_optimisticInserts++;
if (point.isDuplicate())
stack.markDuplicate();
else
{
_vno++;
if ((_vno&1) == 1)
{
finishInsert(point, stack, new1);
_population++;
}
synchronized(stack)
{
}
_vno++;
}
} // synchronized(this)
return optimisticWorked;
} | java | private boolean optimisticInsert(
InsertStack stack,
Object new1)
{
InsertNodes point = stack.insertNodes();
int v1 = _vno;
if (root() == null)
return pessimisticNeeded;
if ((v1&1) != 0)
return pessimisticNeeded;
synchronized(stack)
{
}
try
{
findInsert(
point,
stack,
new1);
}
catch (NullPointerException npe)
{
//No FFDC Code Needed.
_nullPointerExceptions++;
return checkForPossibleIndexChange(v1, _vno, npe, "optimisticInsert");
}
catch (OptimisticDepthException ode)
{
//No FFDC Code Needed.
_optimisticDepthExceptions++;
return checkForPossibleIndexChange(v1, _vno, ode, "optimisticInsert");
}
synchronized(this)
{
if (v1 != _vno)
{
_optimisticInsertSurprises++;
return pessimisticNeeded;
}
_optimisticInserts++;
if (point.isDuplicate())
stack.markDuplicate();
else
{
_vno++;
if ((_vno&1) == 1)
{
finishInsert(point, stack, new1);
_population++;
}
synchronized(stack)
{
}
_vno++;
}
} // synchronized(this)
return optimisticWorked;
} | [
"private",
"boolean",
"optimisticInsert",
"(",
"InsertStack",
"stack",
",",
"Object",
"new1",
")",
"{",
"InsertNodes",
"point",
"=",
"stack",
".",
"insertNodes",
"(",
")",
";",
"int",
"v1",
"=",
"_vno",
";",
"if",
"(",
"root",
"(",
")",
"==",
"null",
")",
"return",
"pessimisticNeeded",
";",
"if",
"(",
"(",
"v1",
"&",
"1",
")",
"!=",
"0",
")",
"return",
"pessimisticNeeded",
";",
"synchronized",
"(",
"stack",
")",
"{",
"}",
"try",
"{",
"findInsert",
"(",
"point",
",",
"stack",
",",
"new1",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"npe",
")",
"{",
"//No FFDC Code Needed.",
"_nullPointerExceptions",
"++",
";",
"return",
"checkForPossibleIndexChange",
"(",
"v1",
",",
"_vno",
",",
"npe",
",",
"\"optimisticInsert\"",
")",
";",
"}",
"catch",
"(",
"OptimisticDepthException",
"ode",
")",
"{",
"//No FFDC Code Needed.",
"_optimisticDepthExceptions",
"++",
";",
"return",
"checkForPossibleIndexChange",
"(",
"v1",
",",
"_vno",
",",
"ode",
",",
"\"optimisticInsert\"",
")",
";",
"}",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"v1",
"!=",
"_vno",
")",
"{",
"_optimisticInsertSurprises",
"++",
";",
"return",
"pessimisticNeeded",
";",
"}",
"_optimisticInserts",
"++",
";",
"if",
"(",
"point",
".",
"isDuplicate",
"(",
")",
")",
"stack",
".",
"markDuplicate",
"(",
")",
";",
"else",
"{",
"_vno",
"++",
";",
"if",
"(",
"(",
"_vno",
"&",
"1",
")",
"==",
"1",
")",
"{",
"finishInsert",
"(",
"point",
",",
"stack",
",",
"new1",
")",
";",
"_population",
"++",
";",
"}",
"synchronized",
"(",
"stack",
")",
"{",
"}",
"_vno",
"++",
";",
"}",
"}",
"// synchronized(this)",
"return",
"optimisticWorked",
";",
"}"
] | Optimistic insert into a GBS Tree.
@param stack The InsertStack used to do the insert.
@param new1 The Object to be inserted.
@return optimisticWorked if the insert worked, pessimisticNeeded if
the insert failed due to interference from another thread. | [
"Optimistic",
"insert",
"into",
"a",
"GBS",
"Tree",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1158-L1219 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.pessimisticInsert | private synchronized boolean pessimisticInsert(
InsertStack stack,
Object new1)
{
_vno++;
if ((_vno&1) == 1)
{
if (root() == null)
{
addFirstNode(new1);
_population++;
}
else
{
InsertNodes point = stack.insertNodes();
findInsert(
point,
stack,
new1);
if (point.isDuplicate())
stack.markDuplicate();
else
{
finishInsert(point, stack, new1);
_population++;
}
}
}
synchronized(stack)
{
}
_vno++;
_pessimisticInserts++;
return optimisticWorked;
} | java | private synchronized boolean pessimisticInsert(
InsertStack stack,
Object new1)
{
_vno++;
if ((_vno&1) == 1)
{
if (root() == null)
{
addFirstNode(new1);
_population++;
}
else
{
InsertNodes point = stack.insertNodes();
findInsert(
point,
stack,
new1);
if (point.isDuplicate())
stack.markDuplicate();
else
{
finishInsert(point, stack, new1);
_population++;
}
}
}
synchronized(stack)
{
}
_vno++;
_pessimisticInserts++;
return optimisticWorked;
} | [
"private",
"synchronized",
"boolean",
"pessimisticInsert",
"(",
"InsertStack",
"stack",
",",
"Object",
"new1",
")",
"{",
"_vno",
"++",
";",
"if",
"(",
"(",
"_vno",
"&",
"1",
")",
"==",
"1",
")",
"{",
"if",
"(",
"root",
"(",
")",
"==",
"null",
")",
"{",
"addFirstNode",
"(",
"new1",
")",
";",
"_population",
"++",
";",
"}",
"else",
"{",
"InsertNodes",
"point",
"=",
"stack",
".",
"insertNodes",
"(",
")",
";",
"findInsert",
"(",
"point",
",",
"stack",
",",
"new1",
")",
";",
"if",
"(",
"point",
".",
"isDuplicate",
"(",
")",
")",
"stack",
".",
"markDuplicate",
"(",
")",
";",
"else",
"{",
"finishInsert",
"(",
"point",
",",
"stack",
",",
"new1",
")",
";",
"_population",
"++",
";",
"}",
"}",
"}",
"synchronized",
"(",
"stack",
")",
"{",
"}",
"_vno",
"++",
";",
"_pessimisticInserts",
"++",
";",
"return",
"optimisticWorked",
";",
"}"
] | Pessimistic insert into a GBS Tree.
@param stack The InsertStack used to do the insert.
@param new1 The Object to be inserted.
@return optimisticWorked as this version always works. | [
"Pessimistic",
"insert",
"into",
"a",
"GBS",
"Tree",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1230-L1265 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.findInsert | private void findInsert(
InsertNodes point,
InsertStack stack,
Object new1)
{
java.util.Comparator comp = insertComparator();
NodeInsertPoint ip = stack.nodeInsertPoint();
GBSNode p; /* P is used to march down the tree */
int xcc; /* Compare result */
GBSNode l_last = null; /* Node from which we last departed by */
/* turning left (logical successor) */
GBSNode r_last = null; /* Node from which we last departed by */
/* turning right (logical predecessor) */
p = root(); /* Root of tree */
/* Remember father of root */
stack.start(dummyTopNode(), "GBSTree.findInsert");
for (;;) /* Through the whole tree */
{
xcc = comp.compare(new1, p.middleKey());
if ( !(xcc > 0) ) /* New key <= node key */
{
GBSNode leftChild = p.leftChild();
if (leftChild != null) /* Have a left child */
{
l_last = p; /* Remember node from which we */
/* last moved left (successor) */
stack.balancedPush(NodeStack.PROCESS_CURRENT, p);
p = leftChild; /* Move left */
}
else /* Have no left child */
{
leftAdd( /* Add a left child */
p, /* Current node */
r_last, /* Node from which we last turned right */
new1, /* Key to add */
ip, /* NodeInsertPoint */
point); /* Returned InsertNodes */
break;
}
}
else /* New key > node key */
{
GBSNode rightChild = p.rightChild();
if (rightChild != null) /* There is a right child */
{
r_last = p; /* Remember node from which we */
/* last moved right (predecessor) */
stack.balancedPush(NodeStack.DONE_VISITS, p);
p = rightChild; /* Move right */
}
else /* There is no right child */
{
rightAdd( /* Add a right child */
p, /* Current node */
l_last, /* Node from which we last turned left */
new1, /* Key to add */
ip, /* NodeInsertPoint */
point); /* Returned InsertNodes */
break;
}
}
} // for
} | java | private void findInsert(
InsertNodes point,
InsertStack stack,
Object new1)
{
java.util.Comparator comp = insertComparator();
NodeInsertPoint ip = stack.nodeInsertPoint();
GBSNode p; /* P is used to march down the tree */
int xcc; /* Compare result */
GBSNode l_last = null; /* Node from which we last departed by */
/* turning left (logical successor) */
GBSNode r_last = null; /* Node from which we last departed by */
/* turning right (logical predecessor) */
p = root(); /* Root of tree */
/* Remember father of root */
stack.start(dummyTopNode(), "GBSTree.findInsert");
for (;;) /* Through the whole tree */
{
xcc = comp.compare(new1, p.middleKey());
if ( !(xcc > 0) ) /* New key <= node key */
{
GBSNode leftChild = p.leftChild();
if (leftChild != null) /* Have a left child */
{
l_last = p; /* Remember node from which we */
/* last moved left (successor) */
stack.balancedPush(NodeStack.PROCESS_CURRENT, p);
p = leftChild; /* Move left */
}
else /* Have no left child */
{
leftAdd( /* Add a left child */
p, /* Current node */
r_last, /* Node from which we last turned right */
new1, /* Key to add */
ip, /* NodeInsertPoint */
point); /* Returned InsertNodes */
break;
}
}
else /* New key > node key */
{
GBSNode rightChild = p.rightChild();
if (rightChild != null) /* There is a right child */
{
r_last = p; /* Remember node from which we */
/* last moved right (predecessor) */
stack.balancedPush(NodeStack.DONE_VISITS, p);
p = rightChild; /* Move right */
}
else /* There is no right child */
{
rightAdd( /* Add a right child */
p, /* Current node */
l_last, /* Node from which we last turned left */
new1, /* Key to add */
ip, /* NodeInsertPoint */
point); /* Returned InsertNodes */
break;
}
}
} // for
} | [
"private",
"void",
"findInsert",
"(",
"InsertNodes",
"point",
",",
"InsertStack",
"stack",
",",
"Object",
"new1",
")",
"{",
"java",
".",
"util",
".",
"Comparator",
"comp",
"=",
"insertComparator",
"(",
")",
";",
"NodeInsertPoint",
"ip",
"=",
"stack",
".",
"nodeInsertPoint",
"(",
")",
";",
"GBSNode",
"p",
";",
"/* P is used to march down the tree */",
"int",
"xcc",
";",
"/* Compare result */",
"GBSNode",
"l_last",
"=",
"null",
";",
"/* Node from which we last departed by */",
"/* turning left (logical successor) */",
"GBSNode",
"r_last",
"=",
"null",
";",
"/* Node from which we last departed by */",
"/* turning right (logical predecessor) */",
"p",
"=",
"root",
"(",
")",
";",
"/* Root of tree */",
"/* Remember father of root */",
"stack",
".",
"start",
"(",
"dummyTopNode",
"(",
")",
",",
"\"GBSTree.findInsert\"",
")",
";",
"for",
"(",
";",
";",
")",
"/* Through the whole tree */",
"{",
"xcc",
"=",
"comp",
".",
"compare",
"(",
"new1",
",",
"p",
".",
"middleKey",
"(",
")",
")",
";",
"if",
"(",
"!",
"(",
"xcc",
">",
"0",
")",
")",
"/* New key <= node key */",
"{",
"GBSNode",
"leftChild",
"=",
"p",
".",
"leftChild",
"(",
")",
";",
"if",
"(",
"leftChild",
"!=",
"null",
")",
"/* Have a left child */",
"{",
"l_last",
"=",
"p",
";",
"/* Remember node from which we */",
"/* last moved left (successor) */",
"stack",
".",
"balancedPush",
"(",
"NodeStack",
".",
"PROCESS_CURRENT",
",",
"p",
")",
";",
"p",
"=",
"leftChild",
";",
"/* Move left */",
"}",
"else",
"/* Have no left child */",
"{",
"leftAdd",
"(",
"/* Add a left child */",
"p",
",",
"/* Current node */",
"r_last",
",",
"/* Node from which we last turned right */",
"new1",
",",
"/* Key to add */",
"ip",
",",
"/* NodeInsertPoint */",
"point",
")",
";",
"/* Returned InsertNodes */",
"break",
";",
"}",
"}",
"else",
"/* New key > node key */",
"{",
"GBSNode",
"rightChild",
"=",
"p",
".",
"rightChild",
"(",
")",
";",
"if",
"(",
"rightChild",
"!=",
"null",
")",
"/* There is a right child */",
"{",
"r_last",
"=",
"p",
";",
"/* Remember node from which we */",
"/* last moved right (predecessor) */",
"stack",
".",
"balancedPush",
"(",
"NodeStack",
".",
"DONE_VISITS",
",",
"p",
")",
";",
"p",
"=",
"rightChild",
";",
"/* Move right */",
"}",
"else",
"/* There is no right child */",
"{",
"rightAdd",
"(",
"/* Add a right child */",
"p",
",",
"/* Current node */",
"l_last",
",",
"/* Node from which we last turned left */",
"new1",
",",
"/* Key to add */",
"ip",
",",
"/* NodeInsertPoint */",
"point",
")",
";",
"/* Returned InsertNodes */",
"break",
";",
"}",
"}",
"}",
"// for",
"}"
] | Find the insert point within the tree.
@param point Returned insert points.
@param stack The InsertStack of nodes traversed.
@param new1 The Object to be inserted. | [
"Find",
"the",
"insert",
"point",
"within",
"the",
"tree",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1274-L1337 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.leftAdd | private void leftAdd(
GBSNode p,
GBSNode r,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
if (r == null) /* There is no upper predecessor */
leftAddNoPredecessor(p, new1, ip, point);
else /* There is an upper predecessor */
leftAddWithPredecessor(p, r, new1, ip, point);
} | java | private void leftAdd(
GBSNode p,
GBSNode r,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
if (r == null) /* There is no upper predecessor */
leftAddNoPredecessor(p, new1, ip, point);
else /* There is an upper predecessor */
leftAddWithPredecessor(p, r, new1, ip, point);
} | [
"private",
"void",
"leftAdd",
"(",
"GBSNode",
"p",
",",
"GBSNode",
"r",
",",
"Object",
"new1",
",",
"NodeInsertPoint",
"ip",
",",
"InsertNodes",
"point",
")",
"{",
"if",
"(",
"r",
"==",
"null",
")",
"/* There is no upper predecessor */",
"leftAddNoPredecessor",
"(",
"p",
",",
"new1",
",",
"ip",
",",
"point",
")",
";",
"else",
"/* There is an upper predecessor */",
"leftAddWithPredecessor",
"(",
"p",
",",
"r",
",",
"new1",
",",
"ip",
",",
"point",
")",
";",
"}"
] | Add to predecssor or current.
<ol>
<li>There is no left child.
<li>There might or might not be a right child
<li>INSERT_KEY < MEDIAN of current node
<li>INSERT_KEY > MEDIAN of predecessor (if there is one)
</ol>
<p>In the example below, if the current node is GHI, then the insert
key is greater than E and less than H. If the current node is MNO,
then the insert key is greater than K and less than N. If the
current node is ABC, the insert key is less than B and there is no
predecessor because there is no node from which we moved right.</p>
<pre>
*------------------J.K.L------------------*
| |
| |
| |
*-------D.E.F-------* *-------P.Q.R-------*
| | | |
| | | |
| | | |
A.B.C G.H.I M.N.O S.T.U
</pre>
<p>We tried to move left and fell off the end. If the key value is
greater than the high key of the predecessor or if there is no
predecessor, the insert point is in the left half of the current
node. Otherwise, the insert point is in the right half of the
predecessor node.</p>
@param p Current node from which we tried to move left
@param r Last node from which we actually moved right (logical predecessor)
@param new1 Key being inserted
@param ip Scratch NodeInsertPoint to avoid allocating a new one
@param point Returned insert points | [
"Add",
"to",
"predecssor",
"or",
"current",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1382-L1393 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.leftAddNoPredecessor | private void leftAddNoPredecessor(
GBSNode p,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
p.findInsertPointInLeft(new1, ip);
point.setInsert(p, ip);
} | java | private void leftAddNoPredecessor(
GBSNode p,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
p.findInsertPointInLeft(new1, ip);
point.setInsert(p, ip);
} | [
"private",
"void",
"leftAddNoPredecessor",
"(",
"GBSNode",
"p",
",",
"Object",
"new1",
",",
"NodeInsertPoint",
"ip",
",",
"InsertNodes",
"point",
")",
"{",
"p",
".",
"findInsertPointInLeft",
"(",
"new1",
",",
"ip",
")",
";",
"point",
".",
"setInsert",
"(",
"p",
",",
"ip",
")",
";",
"}"
] | Add to left side with no predecessor present.
<p>There is no upper predecessor. If key exists it is in left part
of current node.</p>
@param p Current node from which we tried to move left
@param new1 Key being inserted
@param ip Scratch NodeInsertPoint to avoid allocating a new one
@param point Returned insert points | [
"Add",
"to",
"left",
"side",
"with",
"no",
"predecessor",
"present",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1406-L1414 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.leftAddWithPredecessor | private void leftAddWithPredecessor(
GBSNode p,
GBSNode r,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
java.util.Comparator comp = r.insertComparator();
int xcc = comp.compare(new1, r.rightMostKey());
if (xcc > 0) /* If key exists it is in left part */
{
/* of current node */
p.findInsertPointInLeft(new1, ip);
point.setInsert(p, ip);
}
else /* If key exists it is in right part */
{
/* of predecessor node */
r.findInsertPointInRight(new1, ip);
if (ip.isDuplicate()) /* Key is a duplicate */
point.setInsert(r, ip);
else /* Key is not a duplicate */
{
point.setInsertAndPosition(
p,
-1,
r,
ip.insertPoint());
point.setRight();
}
}
} | java | private void leftAddWithPredecessor(
GBSNode p,
GBSNode r,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
java.util.Comparator comp = r.insertComparator();
int xcc = comp.compare(new1, r.rightMostKey());
if (xcc > 0) /* If key exists it is in left part */
{
/* of current node */
p.findInsertPointInLeft(new1, ip);
point.setInsert(p, ip);
}
else /* If key exists it is in right part */
{
/* of predecessor node */
r.findInsertPointInRight(new1, ip);
if (ip.isDuplicate()) /* Key is a duplicate */
point.setInsert(r, ip);
else /* Key is not a duplicate */
{
point.setInsertAndPosition(
p,
-1,
r,
ip.insertPoint());
point.setRight();
}
}
} | [
"private",
"void",
"leftAddWithPredecessor",
"(",
"GBSNode",
"p",
",",
"GBSNode",
"r",
",",
"Object",
"new1",
",",
"NodeInsertPoint",
"ip",
",",
"InsertNodes",
"point",
")",
"{",
"java",
".",
"util",
".",
"Comparator",
"comp",
"=",
"r",
".",
"insertComparator",
"(",
")",
";",
"int",
"xcc",
"=",
"comp",
".",
"compare",
"(",
"new1",
",",
"r",
".",
"rightMostKey",
"(",
")",
")",
";",
"if",
"(",
"xcc",
">",
"0",
")",
"/* If key exists it is in left part */",
"{",
"/* of current node */",
"p",
".",
"findInsertPointInLeft",
"(",
"new1",
",",
"ip",
")",
";",
"point",
".",
"setInsert",
"(",
"p",
",",
"ip",
")",
";",
"}",
"else",
"/* If key exists it is in right part */",
"{",
"/* of predecessor node */",
"r",
".",
"findInsertPointInRight",
"(",
"new1",
",",
"ip",
")",
";",
"if",
"(",
"ip",
".",
"isDuplicate",
"(",
")",
")",
"/* Key is a duplicate */",
"point",
".",
"setInsert",
"(",
"r",
",",
"ip",
")",
";",
"else",
"/* Key is not a duplicate */",
"{",
"point",
".",
"setInsertAndPosition",
"(",
"p",
",",
"-",
"1",
",",
"r",
",",
"ip",
".",
"insertPoint",
"(",
")",
")",
";",
"point",
".",
"setRight",
"(",
")",
";",
"}",
"}",
"}"
] | Add to left side with an upper predecessor present.
<p>There is an upper predecessor. If the current key is greater
than the right-most key of the upper predecessor then the insert
point is in the left half of the current node.</p>
<p>Otherwise it is in the right part of the upper predecessor. If
it is not a duplicate of some key in the upper predecessor we
insert the new key in the upper predecessor and migrate down the
right-most key in the upper predecessor.</p>
@param p Current node from which we tried to move left
@param r Last node from which we actually moved right (logical predecessor)
@param new1 Key being inserted
@param ip Scratch NodeInsertPoint to avoid allocating a new one
@param point Returned insert points | [
"Add",
"to",
"left",
"side",
"with",
"an",
"upper",
"predecessor",
"present",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1434-L1467 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.rightAdd | private void rightAdd(
GBSNode p,
GBSNode l,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
if (l == null) /* There is no upper successor */
rightAddNoSuccessor(p, new1, ip, point);
else /* There is an upper successor */
rightAddWithSuccessor(p, l, new1, ip, point);
} | java | private void rightAdd(
GBSNode p,
GBSNode l,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
if (l == null) /* There is no upper successor */
rightAddNoSuccessor(p, new1, ip, point);
else /* There is an upper successor */
rightAddWithSuccessor(p, l, new1, ip, point);
} | [
"private",
"void",
"rightAdd",
"(",
"GBSNode",
"p",
",",
"GBSNode",
"l",
",",
"Object",
"new1",
",",
"NodeInsertPoint",
"ip",
",",
"InsertNodes",
"point",
")",
"{",
"if",
"(",
"l",
"==",
"null",
")",
"/* There is no upper successor */",
"rightAddNoSuccessor",
"(",
"p",
",",
"new1",
",",
"ip",
",",
"point",
")",
";",
"else",
"/* There is an upper successor */",
"rightAddWithSuccessor",
"(",
"p",
",",
"l",
",",
"new1",
",",
"ip",
",",
"point",
")",
";",
"}"
] | Add to current or successor.
<ol>
<li>There is no right child
<li>There may or may not be a left child.
<li>INSERT_KEY > MEDIAN of current node.
<li>INSERT_KEY < MEDIAN of successor (if there is one)
</ol>
<p>In the example below, if the current node is GHI, then the insert
key is greater than H and less than K. If the current node is
MNO, then the insert key is greater than N and less than Q. If
the current node is STU, the insert key is greater than T and
there is no successor.</p>
<pre>
*------------------J.K.L------------------*
| |
| |
| |
*-------D.E.F-------* *-------P.Q.R-------*
| | | |
| | | |
| | | |
A.B.C G.H.I M.N.O S.T.U
</pre>
<p>We tried to move right and fell off the end. If the key value is
less than the low key of the successor or if there is no
successor, the insert point is in the right half of the current
node. Otherwise, the insert point is in the left half of the
successor node.</p>
@param p Current node from which we tried to move left
@param l Last node from which we actually moved left (logical successor)
@param new1 Key being inserted
@param ip Scratch NodeInsertPoint to avoid allocating a new one
@param point Returned insert points | [
"Add",
"to",
"current",
"or",
"successor",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1511-L1522 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.rightAddNoSuccessor | private void rightAddNoSuccessor(
GBSNode p,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
if (p.lessThanHalfFull()) /* Node not even half full so the insert */
/* point now is high key of current */
point.setInsert(p, p.rightMostIndex());
else /* Keys exist beyond the median */
{
/* Must look for insert point */
p.findInsertPointInRight(new1, ip);
point.setInsert(p, ip);
}
} | java | private void rightAddNoSuccessor(
GBSNode p,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
if (p.lessThanHalfFull()) /* Node not even half full so the insert */
/* point now is high key of current */
point.setInsert(p, p.rightMostIndex());
else /* Keys exist beyond the median */
{
/* Must look for insert point */
p.findInsertPointInRight(new1, ip);
point.setInsert(p, ip);
}
} | [
"private",
"void",
"rightAddNoSuccessor",
"(",
"GBSNode",
"p",
",",
"Object",
"new1",
",",
"NodeInsertPoint",
"ip",
",",
"InsertNodes",
"point",
")",
"{",
"if",
"(",
"p",
".",
"lessThanHalfFull",
"(",
")",
")",
"/* Node not even half full so the insert */",
"/* point now is high key of current */",
"point",
".",
"setInsert",
"(",
"p",
",",
"p",
".",
"rightMostIndex",
"(",
")",
")",
";",
"else",
"/* Keys exist beyond the median */",
"{",
"/* Must look for insert point */",
"p",
".",
"findInsertPointInRight",
"(",
"new1",
",",
"ip",
")",
";",
"point",
".",
"setInsert",
"(",
"p",
",",
"ip",
")",
";",
"}",
"}"
] | Add to right side with no upper successor present.
<p>There is no upper successor. If key exists it is in right part
of current node. If curent node is less than half full there can
be no duplicate because the last compare that got us here was with
the right-most key in the current node.</p>
@param p Current node from which we tried to move left
@param new1 Key being inserted
@param ip Scratch NodeInsertPoint to avoid allocating a new one
@param point Returned insert points | [
"Add",
"to",
"right",
"side",
"with",
"no",
"upper",
"successor",
"present",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1537-L1552 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.rightAddWithSuccessor | private void rightAddWithSuccessor(
GBSNode p,
GBSNode l,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
java.util.Comparator comp = l.insertComparator();
int xcc = comp.compare(new1, l.leftMostKey());
if (xcc < 0) /* If key exists it is in right part */
{
/* of current node */
if (p.lessThanHalfFull()) /* Node not even half full so the insert */
/* point now is high key of current */
point.setInsert(p, p.rightMostIndex());
else /* Keys exist beyond the median */
{
/* Must look for insert point */
p.findInsertPointInRight(new1, ip);
point.setInsert(p, ip);
}
}
else /* If key exists it is in left part */
{
/* of upper successor */
l.findInsertPointInLeft(new1, ip);
if (ip.isDuplicate()) /* Key is a duplicate */
point.setInsert(l, ip);
else /* Key is not a duplicate */
{
point.setInsertAndPosition(
p,
p.rightMostIndex(),
l,
ip.insertPoint());
point.setLeft();
}
}
} | java | private void rightAddWithSuccessor(
GBSNode p,
GBSNode l,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
java.util.Comparator comp = l.insertComparator();
int xcc = comp.compare(new1, l.leftMostKey());
if (xcc < 0) /* If key exists it is in right part */
{
/* of current node */
if (p.lessThanHalfFull()) /* Node not even half full so the insert */
/* point now is high key of current */
point.setInsert(p, p.rightMostIndex());
else /* Keys exist beyond the median */
{
/* Must look for insert point */
p.findInsertPointInRight(new1, ip);
point.setInsert(p, ip);
}
}
else /* If key exists it is in left part */
{
/* of upper successor */
l.findInsertPointInLeft(new1, ip);
if (ip.isDuplicate()) /* Key is a duplicate */
point.setInsert(l, ip);
else /* Key is not a duplicate */
{
point.setInsertAndPosition(
p,
p.rightMostIndex(),
l,
ip.insertPoint());
point.setLeft();
}
}
} | [
"private",
"void",
"rightAddWithSuccessor",
"(",
"GBSNode",
"p",
",",
"GBSNode",
"l",
",",
"Object",
"new1",
",",
"NodeInsertPoint",
"ip",
",",
"InsertNodes",
"point",
")",
"{",
"java",
".",
"util",
".",
"Comparator",
"comp",
"=",
"l",
".",
"insertComparator",
"(",
")",
";",
"int",
"xcc",
"=",
"comp",
".",
"compare",
"(",
"new1",
",",
"l",
".",
"leftMostKey",
"(",
")",
")",
";",
"if",
"(",
"xcc",
"<",
"0",
")",
"/* If key exists it is in right part */",
"{",
"/* of current node */",
"if",
"(",
"p",
".",
"lessThanHalfFull",
"(",
")",
")",
"/* Node not even half full so the insert */",
"/* point now is high key of current */",
"point",
".",
"setInsert",
"(",
"p",
",",
"p",
".",
"rightMostIndex",
"(",
")",
")",
";",
"else",
"/* Keys exist beyond the median */",
"{",
"/* Must look for insert point */",
"p",
".",
"findInsertPointInRight",
"(",
"new1",
",",
"ip",
")",
";",
"point",
".",
"setInsert",
"(",
"p",
",",
"ip",
")",
";",
"}",
"}",
"else",
"/* If key exists it is in left part */",
"{",
"/* of upper successor */",
"l",
".",
"findInsertPointInLeft",
"(",
"new1",
",",
"ip",
")",
";",
"if",
"(",
"ip",
".",
"isDuplicate",
"(",
")",
")",
"/* Key is a duplicate */",
"point",
".",
"setInsert",
"(",
"l",
",",
"ip",
")",
";",
"else",
"/* Key is not a duplicate */",
"{",
"point",
".",
"setInsertAndPosition",
"(",
"p",
",",
"p",
".",
"rightMostIndex",
"(",
")",
",",
"l",
",",
"ip",
".",
"insertPoint",
"(",
")",
")",
";",
"point",
".",
"setLeft",
"(",
")",
";",
"}",
"}",
"}"
] | Add to right side with an upper successor present.
<p>There is an upper successor. If the current key is less than
the left-most key of the upper successor then the insert point is
in the right half of the current node.</p>
<p>Otherwise it is in the left part of the upper successor. If it
is not a duplicate of some key in the upper successor we insert the
new key in the upper successor and migrate down the left-most key
in the upper successor.</p>
@param p Current node from which we tried to move left
@param l Last node from which we actually moved left (logical successor)
@param new1 Key being inserted
@param ip Scratch NodeInsertPoint to avoid allocating a new one
@param point Returned insert points | [
"Add",
"to",
"right",
"side",
"with",
"an",
"upper",
"successor",
"present",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1571-L1609 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.finishInsert | private void finishInsert(
InsertNodes point,
InsertStack stack,
Object new1)
{
Object insertKey = new1;
if (point.positionNode() != null)
{
GBSNode p = point.positionNode();
int ix = point.positionIndex();
if (point.rightSide())
insertKey = p.insertByRightShift(ix, insertKey);
else
insertKey = p.insertByLeftShift(ix, insertKey);
}
/* If the insert point is at the right-most slot in a full node */
/* then we migrate the new key into the fringe. */
Object migrateKey = null;
if (point.insertIndex() == point.insertNode().topMostIndex())
migrateKey = insertKey;
else /* Insert within existing node */
migrateKey = /* Which may migrate a key out of it */
point.insertNode().insertByRightShift(
point.insertIndex(), insertKey);
insertFringeMigrate(stack, point.insertNode(), migrateKey);
} | java | private void finishInsert(
InsertNodes point,
InsertStack stack,
Object new1)
{
Object insertKey = new1;
if (point.positionNode() != null)
{
GBSNode p = point.positionNode();
int ix = point.positionIndex();
if (point.rightSide())
insertKey = p.insertByRightShift(ix, insertKey);
else
insertKey = p.insertByLeftShift(ix, insertKey);
}
/* If the insert point is at the right-most slot in a full node */
/* then we migrate the new key into the fringe. */
Object migrateKey = null;
if (point.insertIndex() == point.insertNode().topMostIndex())
migrateKey = insertKey;
else /* Insert within existing node */
migrateKey = /* Which may migrate a key out of it */
point.insertNode().insertByRightShift(
point.insertIndex(), insertKey);
insertFringeMigrate(stack, point.insertNode(), migrateKey);
} | [
"private",
"void",
"finishInsert",
"(",
"InsertNodes",
"point",
",",
"InsertStack",
"stack",
",",
"Object",
"new1",
")",
"{",
"Object",
"insertKey",
"=",
"new1",
";",
"if",
"(",
"point",
".",
"positionNode",
"(",
")",
"!=",
"null",
")",
"{",
"GBSNode",
"p",
"=",
"point",
".",
"positionNode",
"(",
")",
";",
"int",
"ix",
"=",
"point",
".",
"positionIndex",
"(",
")",
";",
"if",
"(",
"point",
".",
"rightSide",
"(",
")",
")",
"insertKey",
"=",
"p",
".",
"insertByRightShift",
"(",
"ix",
",",
"insertKey",
")",
";",
"else",
"insertKey",
"=",
"p",
".",
"insertByLeftShift",
"(",
"ix",
",",
"insertKey",
")",
";",
"}",
"/* If the insert point is at the right-most slot in a full node */",
"/* then we migrate the new key into the fringe. */",
"Object",
"migrateKey",
"=",
"null",
";",
"if",
"(",
"point",
".",
"insertIndex",
"(",
")",
"==",
"point",
".",
"insertNode",
"(",
")",
".",
"topMostIndex",
"(",
")",
")",
"migrateKey",
"=",
"insertKey",
";",
"else",
"/* Insert within existing node */",
"migrateKey",
"=",
"/* Which may migrate a key out of it */",
"point",
".",
"insertNode",
"(",
")",
".",
"insertByRightShift",
"(",
"point",
".",
"insertIndex",
"(",
")",
",",
"insertKey",
")",
";",
"insertFringeMigrate",
"(",
"stack",
",",
"point",
".",
"insertNode",
"(",
")",
",",
"migrateKey",
")",
";",
"}"
] | Do the write phase of the insert.
<p>findInsert does all of the reading needed to find the insert point.
finishInsert does all of the writing required to actually do the insert.
It is called by either optimisticInsert or pessimisticInsert as the
writing phase is the same regardless of the locking strategy.</p>
@param point The insert point and position point.
@param stack The InsertStack of nodes traversed.
@param new1 The Object to be inserted. | [
"Do",
"the",
"write",
"phase",
"of",
"the",
"insert",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1624-L1650 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.insertFringeMigrate | private void insertFringeMigrate(
InsertStack stack,
GBSNode p,
Object mkey)
{
GBSNode endp = p;
int endIndex = stack.index();
/* Maximum number of right child nodes */
/* before the fringe must be rebalanced */
int maxBal = maximumFringeImbalance();
stack.setMigratingKey(mkey);
if (mkey != null) /* Have a key to migrate */
{
stack.processSubFringe(p); /* See InsertStack.processNode */
endp = stack.lastNode();
endIndex = stack.lastIndex();
}
if (stack.migrating()) /* Need a right child for migrating key */
{
_xno++;
endp.addRightLeaf(stack.migratingKey());
}
insertCheckFringeBalance(
stack,
endp,
endIndex,
maxBal);
} | java | private void insertFringeMigrate(
InsertStack stack,
GBSNode p,
Object mkey)
{
GBSNode endp = p;
int endIndex = stack.index();
/* Maximum number of right child nodes */
/* before the fringe must be rebalanced */
int maxBal = maximumFringeImbalance();
stack.setMigratingKey(mkey);
if (mkey != null) /* Have a key to migrate */
{
stack.processSubFringe(p); /* See InsertStack.processNode */
endp = stack.lastNode();
endIndex = stack.lastIndex();
}
if (stack.migrating()) /* Need a right child for migrating key */
{
_xno++;
endp.addRightLeaf(stack.migratingKey());
}
insertCheckFringeBalance(
stack,
endp,
endIndex,
maxBal);
} | [
"private",
"void",
"insertFringeMigrate",
"(",
"InsertStack",
"stack",
",",
"GBSNode",
"p",
",",
"Object",
"mkey",
")",
"{",
"GBSNode",
"endp",
"=",
"p",
";",
"int",
"endIndex",
"=",
"stack",
".",
"index",
"(",
")",
";",
"/* Maximum number of right child nodes */",
"/* before the fringe must be rebalanced */",
"int",
"maxBal",
"=",
"maximumFringeImbalance",
"(",
")",
";",
"stack",
".",
"setMigratingKey",
"(",
"mkey",
")",
";",
"if",
"(",
"mkey",
"!=",
"null",
")",
"/* Have a key to migrate */",
"{",
"stack",
".",
"processSubFringe",
"(",
"p",
")",
";",
"/* See InsertStack.processNode */",
"endp",
"=",
"stack",
".",
"lastNode",
"(",
")",
";",
"endIndex",
"=",
"stack",
".",
"lastIndex",
"(",
")",
";",
"}",
"if",
"(",
"stack",
".",
"migrating",
"(",
")",
")",
"/* Need a right child for migrating key */",
"{",
"_xno",
"++",
";",
"endp",
".",
"addRightLeaf",
"(",
"stack",
".",
"migratingKey",
"(",
")",
")",
";",
"}",
"insertCheckFringeBalance",
"(",
"stack",
",",
"endp",
",",
"endIndex",
",",
"maxBal",
")",
";",
"}"
] | Migrate a key from a partial leaf through to the proper place
in its fringe, adding a node to the right side of the fringe
if necessary.
@param stack The stack that has been used to walk the tree
@param p Node from which we are migrating
@param mkey The migrating key. This may be null in which case
there is no key to migrate and we have nothing to do. | [
"Migrate",
"a",
"key",
"from",
"a",
"partial",
"leaf",
"through",
"to",
"the",
"proper",
"place",
"in",
"its",
"fringe",
"adding",
"a",
"node",
"to",
"the",
"right",
"side",
"of",
"the",
"fringe",
"if",
"necessary",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1662-L1692 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.insertCheckFringeBalance | private void insertCheckFringeBalance(
InsertStack stack,
GBSNode endp,
int endIndex,
int maxBal)
{
GBSNode fpoint = null; /* This points to the first half leaf we */
/* find that has a right child but no */
/* left child. If any rebalancing is */
/* to be done to a fringe, this will be */
/* the fringe balance point. */
int fDepth = 0; /* Fringe balance depth */
int fpidx = 0; /* Index into NodeStack where fpoint was */
/* last saved */
/* Check to see if we have filled out a final node, which may have */
/* filled out a fringe to the re-balance point. The absence of a */
/* left child means it is part of a fringe. If this is the case we */
/* walk backward through the tree looking for the top of the fringe. */
if ( (endp.isFull()) &&
(endp.leftChild() == null) )
{
fDepth = 1; /* Last node counts as one */
for (int j = endIndex; j > 0; j--)
{
GBSNode q = stack.node(j);
if (q.leftChild() != null)/* Found the top of the fringe */
break;
else /* Not yet the top of the fringe */
{
fDepth++; /* Bump fringe depth */
fpoint = q; /* Remember possible fringe balance point*/
fpidx = j; /* and its index in the stack */
}
}
if (fDepth >= maxBal)
{
_xno++;
GBSInsertFringe.singleInstance().balance(
kFactor(), stack, fpoint, fpidx, maxBal);
}
}
} | java | private void insertCheckFringeBalance(
InsertStack stack,
GBSNode endp,
int endIndex,
int maxBal)
{
GBSNode fpoint = null; /* This points to the first half leaf we */
/* find that has a right child but no */
/* left child. If any rebalancing is */
/* to be done to a fringe, this will be */
/* the fringe balance point. */
int fDepth = 0; /* Fringe balance depth */
int fpidx = 0; /* Index into NodeStack where fpoint was */
/* last saved */
/* Check to see if we have filled out a final node, which may have */
/* filled out a fringe to the re-balance point. The absence of a */
/* left child means it is part of a fringe. If this is the case we */
/* walk backward through the tree looking for the top of the fringe. */
if ( (endp.isFull()) &&
(endp.leftChild() == null) )
{
fDepth = 1; /* Last node counts as one */
for (int j = endIndex; j > 0; j--)
{
GBSNode q = stack.node(j);
if (q.leftChild() != null)/* Found the top of the fringe */
break;
else /* Not yet the top of the fringe */
{
fDepth++; /* Bump fringe depth */
fpoint = q; /* Remember possible fringe balance point*/
fpidx = j; /* and its index in the stack */
}
}
if (fDepth >= maxBal)
{
_xno++;
GBSInsertFringe.singleInstance().balance(
kFactor(), stack, fpoint, fpidx, maxBal);
}
}
} | [
"private",
"void",
"insertCheckFringeBalance",
"(",
"InsertStack",
"stack",
",",
"GBSNode",
"endp",
",",
"int",
"endIndex",
",",
"int",
"maxBal",
")",
"{",
"GBSNode",
"fpoint",
"=",
"null",
";",
"/* This points to the first half leaf we */",
"/* find that has a right child but no */",
"/* left child. If any rebalancing is */",
"/* to be done to a fringe, this will be */",
"/* the fringe balance point. */",
"int",
"fDepth",
"=",
"0",
";",
"/* Fringe balance depth */",
"int",
"fpidx",
"=",
"0",
";",
"/* Index into NodeStack where fpoint was */",
"/* last saved */",
"/* Check to see if we have filled out a final node, which may have */",
"/* filled out a fringe to the re-balance point. The absence of a */",
"/* left child means it is part of a fringe. If this is the case we */",
"/* walk backward through the tree looking for the top of the fringe. */",
"if",
"(",
"(",
"endp",
".",
"isFull",
"(",
")",
")",
"&&",
"(",
"endp",
".",
"leftChild",
"(",
")",
"==",
"null",
")",
")",
"{",
"fDepth",
"=",
"1",
";",
"/* Last node counts as one */",
"for",
"(",
"int",
"j",
"=",
"endIndex",
";",
"j",
">",
"0",
";",
"j",
"--",
")",
"{",
"GBSNode",
"q",
"=",
"stack",
".",
"node",
"(",
"j",
")",
";",
"if",
"(",
"q",
".",
"leftChild",
"(",
")",
"!=",
"null",
")",
"/* Found the top of the fringe */",
"break",
";",
"else",
"/* Not yet the top of the fringe */",
"{",
"fDepth",
"++",
";",
"/* Bump fringe depth */",
"fpoint",
"=",
"q",
";",
"/* Remember possible fringe balance point*/",
"fpidx",
"=",
"j",
";",
"/* and its index in the stack */",
"}",
"}",
"if",
"(",
"fDepth",
">=",
"maxBal",
")",
"{",
"_xno",
"++",
";",
"GBSInsertFringe",
".",
"singleInstance",
"(",
")",
".",
"balance",
"(",
"kFactor",
"(",
")",
",",
"stack",
",",
"fpoint",
",",
"fpidx",
",",
"maxBal",
")",
";",
"}",
"}",
"}"
] | Check to see if fringe balancing is necessary and do it if needed.
@param stack The stack that has been used to walk the tree
@param endp Last node visited during fringe migration
@param endIndex The index within stack of endp
@param maxBal Maximum fringe imbalance allowed for the tree | [
"Check",
"to",
"see",
"if",
"fringe",
"balancing",
"is",
"necessary",
"and",
"do",
"it",
"if",
"needed",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1702-L1747 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.getDeleteStack | private DeleteStack getDeleteStack()
{
Object x = _deleteStack.get();
DeleteStack g = null;
if (x != null)
{
g = (DeleteStack) x;
g.reset();
}
else
{
g = new DeleteStack(this);
x = (Object) g;
_deleteStack.set(x);
}
return g;
} | java | private DeleteStack getDeleteStack()
{
Object x = _deleteStack.get();
DeleteStack g = null;
if (x != null)
{
g = (DeleteStack) x;
g.reset();
}
else
{
g = new DeleteStack(this);
x = (Object) g;
_deleteStack.set(x);
}
return g;
} | [
"private",
"DeleteStack",
"getDeleteStack",
"(",
")",
"{",
"Object",
"x",
"=",
"_deleteStack",
".",
"get",
"(",
")",
";",
"DeleteStack",
"g",
"=",
"null",
";",
"if",
"(",
"x",
"!=",
"null",
")",
"{",
"g",
"=",
"(",
"DeleteStack",
")",
"x",
";",
"g",
".",
"reset",
"(",
")",
";",
"}",
"else",
"{",
"g",
"=",
"new",
"DeleteStack",
"(",
"this",
")",
";",
"x",
"=",
"(",
"Object",
")",
"g",
";",
"_deleteStack",
".",
"set",
"(",
"x",
")",
";",
"}",
"return",
"g",
";",
"}"
] | Find a DeleteStack for use by the current thread.
<p>Allocation of a DeleteStack is more expensive than serial reuse.
This is a very cheap form of pooling done by attaching a
DeleteStack to each thread that calls delete.</p> | [
"Find",
"a",
"DeleteStack",
"for",
"use",
"by",
"the",
"current",
"thread",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1772-L1788 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.optimisticDelete | private boolean optimisticDelete(
DeleteStack stack,
Object deleteKey)
{
DeleteNode point = stack.deleteNode();
int v1 = _vno;
if ((v1&1) != 0)
return pessimisticNeeded;
synchronized(stack)
{
}
try
{
findDelete(point, stack, deleteKey);
}
catch (NullPointerException npe)
{
//No FFDC Code Needed.
_nullPointerExceptions++;
return checkForPossibleIndexChange(v1, _vno, npe, "optimisticDelete");
}
catch (OptimisticDepthException ode)
{
//No FFDC Code Needed.
_optimisticDepthExceptions++;
return checkForPossibleIndexChange(v1, _vno, ode, "optimisticDelete");
}
synchronized(this)
{
if (v1 != _vno)
{
_optimisticDeleteSurprises++;
return pessimisticNeeded;
}
_optimisticDeletes++;
if (point.wasFound())
{
_vno++;
if ((_vno&1) == 1)
{
finishDelete(point, stack, deleteKey);
if (_population <= 0)
throw new GBSTreeException("_population = " + _population);
_population--;
}
synchronized(stack)
{
}
_vno++;
}
}
return optimisticWorked;
} | java | private boolean optimisticDelete(
DeleteStack stack,
Object deleteKey)
{
DeleteNode point = stack.deleteNode();
int v1 = _vno;
if ((v1&1) != 0)
return pessimisticNeeded;
synchronized(stack)
{
}
try
{
findDelete(point, stack, deleteKey);
}
catch (NullPointerException npe)
{
//No FFDC Code Needed.
_nullPointerExceptions++;
return checkForPossibleIndexChange(v1, _vno, npe, "optimisticDelete");
}
catch (OptimisticDepthException ode)
{
//No FFDC Code Needed.
_optimisticDepthExceptions++;
return checkForPossibleIndexChange(v1, _vno, ode, "optimisticDelete");
}
synchronized(this)
{
if (v1 != _vno)
{
_optimisticDeleteSurprises++;
return pessimisticNeeded;
}
_optimisticDeletes++;
if (point.wasFound())
{
_vno++;
if ((_vno&1) == 1)
{
finishDelete(point, stack, deleteKey);
if (_population <= 0)
throw new GBSTreeException("_population = " + _population);
_population--;
}
synchronized(stack)
{
}
_vno++;
}
}
return optimisticWorked;
} | [
"private",
"boolean",
"optimisticDelete",
"(",
"DeleteStack",
"stack",
",",
"Object",
"deleteKey",
")",
"{",
"DeleteNode",
"point",
"=",
"stack",
".",
"deleteNode",
"(",
")",
";",
"int",
"v1",
"=",
"_vno",
";",
"if",
"(",
"(",
"v1",
"&",
"1",
")",
"!=",
"0",
")",
"return",
"pessimisticNeeded",
";",
"synchronized",
"(",
"stack",
")",
"{",
"}",
"try",
"{",
"findDelete",
"(",
"point",
",",
"stack",
",",
"deleteKey",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"npe",
")",
"{",
"//No FFDC Code Needed.",
"_nullPointerExceptions",
"++",
";",
"return",
"checkForPossibleIndexChange",
"(",
"v1",
",",
"_vno",
",",
"npe",
",",
"\"optimisticDelete\"",
")",
";",
"}",
"catch",
"(",
"OptimisticDepthException",
"ode",
")",
"{",
"//No FFDC Code Needed.",
"_optimisticDepthExceptions",
"++",
";",
"return",
"checkForPossibleIndexChange",
"(",
"v1",
",",
"_vno",
",",
"ode",
",",
"\"optimisticDelete\"",
")",
";",
"}",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"v1",
"!=",
"_vno",
")",
"{",
"_optimisticDeleteSurprises",
"++",
";",
"return",
"pessimisticNeeded",
";",
"}",
"_optimisticDeletes",
"++",
";",
"if",
"(",
"point",
".",
"wasFound",
"(",
")",
")",
"{",
"_vno",
"++",
";",
"if",
"(",
"(",
"_vno",
"&",
"1",
")",
"==",
"1",
")",
"{",
"finishDelete",
"(",
"point",
",",
"stack",
",",
"deleteKey",
")",
";",
"if",
"(",
"_population",
"<=",
"0",
")",
"throw",
"new",
"GBSTreeException",
"(",
"\"_population = \"",
"+",
"_population",
")",
";",
"_population",
"--",
";",
"}",
"synchronized",
"(",
"stack",
")",
"{",
"}",
"_vno",
"++",
";",
"}",
"}",
"return",
"optimisticWorked",
";",
"}"
] | Optimistic delete from a GBS Tree.
@param stack The DeleteStack used to do the delete.
@param deleteKey The Object to be deleteed.
@return optimisticWorked if the delete worked, pessimisticNeeded if
the delete failed due to interference from another thread. | [
"Optimistic",
"delete",
"from",
"a",
"GBS",
"Tree",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1831-L1887 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.iteratorSpecialDelete | void iteratorSpecialDelete(
Iterator iter,
GBSNode node,
int index)
{
_vno++;
if ((_vno&1) == 1)
{
node.deleteByLeftShift(index);
node.adjustMedian();
_population--;
}
synchronized(iter)
{
}
_vno++;
} | java | void iteratorSpecialDelete(
Iterator iter,
GBSNode node,
int index)
{
_vno++;
if ((_vno&1) == 1)
{
node.deleteByLeftShift(index);
node.adjustMedian();
_population--;
}
synchronized(iter)
{
}
_vno++;
} | [
"void",
"iteratorSpecialDelete",
"(",
"Iterator",
"iter",
",",
"GBSNode",
"node",
",",
"int",
"index",
")",
"{",
"_vno",
"++",
";",
"if",
"(",
"(",
"_vno",
"&",
"1",
")",
"==",
"1",
")",
"{",
"node",
".",
"deleteByLeftShift",
"(",
"index",
")",
";",
"node",
".",
"adjustMedian",
"(",
")",
";",
"_population",
"--",
";",
"}",
"synchronized",
"(",
"iter",
")",
"{",
"}",
"_vno",
"++",
";",
"}"
] | Allow an Iterator to delete an item by direct removal from a single
node.
<p>The Iterator has determined that the item to be deleted resides
in a leaf node with more than one item in the node. Removal of the
item from the leaf can be done without further modification to the
tree. The Iterator has already synchronized on the index.</p>
@param iter The Iterator itself which is used as the
synchronization target for a void synchronization
block.
@param node The node from which to delete.
@param index The index within the node of the item to delete. | [
"Allow",
"an",
"Iterator",
"to",
"delete",
"an",
"item",
"by",
"direct",
"removal",
"from",
"a",
"single",
"node",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1945-L1961 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.finishDelete | private void finishDelete(
DeleteNode point,
DeleteStack stack,
Object deleteKey)
{
adjustTarget(point);
point.deleteNode().deleteByLeftShift(point.deleteIndex());
deleteFringeMigrate(stack, point.deleteNode());
} | java | private void finishDelete(
DeleteNode point,
DeleteStack stack,
Object deleteKey)
{
adjustTarget(point);
point.deleteNode().deleteByLeftShift(point.deleteIndex());
deleteFringeMigrate(stack, point.deleteNode());
} | [
"private",
"void",
"finishDelete",
"(",
"DeleteNode",
"point",
",",
"DeleteStack",
"stack",
",",
"Object",
"deleteKey",
")",
"{",
"adjustTarget",
"(",
"point",
")",
";",
"point",
".",
"deleteNode",
"(",
")",
".",
"deleteByLeftShift",
"(",
"point",
".",
"deleteIndex",
"(",
")",
")",
";",
"deleteFringeMigrate",
"(",
"stack",
",",
"point",
".",
"deleteNode",
"(",
")",
")",
";",
"}"
] | Do the write phase of the delete.
<p>findDelete does all of the reading needed to find the delete point.
finishDelete does all of the writing required to actually do the delete.
It is called by either optimisticDelete or pessimisticDelete as the
writing phase is the same regardless of the locking strategy.</p>
@param point The delete point and target point.
@param stack The Delete stack of nodes traversed.
@param deleteKey The Object to be deleted. | [
"Do",
"the",
"write",
"phase",
"of",
"the",
"delete",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L1976-L1985 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.findDelete | private void findDelete(
DeleteNode point,
DeleteStack stack,
Object deleteKey)
{
java.util.Comparator comp = deleteComparator();
GBSNode p; /* P is used to march down the tree */
int xcc; /* Compare result */
GBSNode l_last = null; /* Node from which we last departed by */
/* turning left (logical successor) */
GBSNode r_last = null; /* Node from which we last departed by */
/* turning right (logical predecessor) */
p = root(); /* Root of tree */
/* Remember father of root */
stack.start(dummyTopNode(), "GBSTree.findDelete");
while (p != null)
{
xcc = comp.compare(deleteKey, p.middleKey());
if (xcc == 0) /* Delete key = median key */
{
midDelete(stack, p, point);
p = null;
}
else if (xcc < 0) /* Delete key < median key */
{
if (p.leftChild() != null)
{
l_last = p; /* Remember node from which we */
/* last moved left (successor) */
stack.push(NodeStack.PROCESS_CURRENT, p, "GBSTree.findDelete(1)");
p = p.leftChild();
}
else /* There is no left child */
{
/* Delete on left side */
leftDelete(p, r_last, deleteKey, point);
p = null;
}
}
else /* Delete key > median key */
{
if (p.rightChild() != null)
{
r_last = p; /* Remember node from which we */
/* last moved right (predecessor) */
stack.push(NodeStack.DONE_VISITS, p, "GBSTree.findDelete(2)");
p = p.rightChild();
}
else /* There is no right child */
{
rightDelete(p, l_last, deleteKey, point);
p = null;
}
}
}
} | java | private void findDelete(
DeleteNode point,
DeleteStack stack,
Object deleteKey)
{
java.util.Comparator comp = deleteComparator();
GBSNode p; /* P is used to march down the tree */
int xcc; /* Compare result */
GBSNode l_last = null; /* Node from which we last departed by */
/* turning left (logical successor) */
GBSNode r_last = null; /* Node from which we last departed by */
/* turning right (logical predecessor) */
p = root(); /* Root of tree */
/* Remember father of root */
stack.start(dummyTopNode(), "GBSTree.findDelete");
while (p != null)
{
xcc = comp.compare(deleteKey, p.middleKey());
if (xcc == 0) /* Delete key = median key */
{
midDelete(stack, p, point);
p = null;
}
else if (xcc < 0) /* Delete key < median key */
{
if (p.leftChild() != null)
{
l_last = p; /* Remember node from which we */
/* last moved left (successor) */
stack.push(NodeStack.PROCESS_CURRENT, p, "GBSTree.findDelete(1)");
p = p.leftChild();
}
else /* There is no left child */
{
/* Delete on left side */
leftDelete(p, r_last, deleteKey, point);
p = null;
}
}
else /* Delete key > median key */
{
if (p.rightChild() != null)
{
r_last = p; /* Remember node from which we */
/* last moved right (predecessor) */
stack.push(NodeStack.DONE_VISITS, p, "GBSTree.findDelete(2)");
p = p.rightChild();
}
else /* There is no right child */
{
rightDelete(p, l_last, deleteKey, point);
p = null;
}
}
}
} | [
"private",
"void",
"findDelete",
"(",
"DeleteNode",
"point",
",",
"DeleteStack",
"stack",
",",
"Object",
"deleteKey",
")",
"{",
"java",
".",
"util",
".",
"Comparator",
"comp",
"=",
"deleteComparator",
"(",
")",
";",
"GBSNode",
"p",
";",
"/* P is used to march down the tree */",
"int",
"xcc",
";",
"/* Compare result */",
"GBSNode",
"l_last",
"=",
"null",
";",
"/* Node from which we last departed by */",
"/* turning left (logical successor) */",
"GBSNode",
"r_last",
"=",
"null",
";",
"/* Node from which we last departed by */",
"/* turning right (logical predecessor) */",
"p",
"=",
"root",
"(",
")",
";",
"/* Root of tree */",
"/* Remember father of root */",
"stack",
".",
"start",
"(",
"dummyTopNode",
"(",
")",
",",
"\"GBSTree.findDelete\"",
")",
";",
"while",
"(",
"p",
"!=",
"null",
")",
"{",
"xcc",
"=",
"comp",
".",
"compare",
"(",
"deleteKey",
",",
"p",
".",
"middleKey",
"(",
")",
")",
";",
"if",
"(",
"xcc",
"==",
"0",
")",
"/* Delete key = median key */",
"{",
"midDelete",
"(",
"stack",
",",
"p",
",",
"point",
")",
";",
"p",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"xcc",
"<",
"0",
")",
"/* Delete key < median key */",
"{",
"if",
"(",
"p",
".",
"leftChild",
"(",
")",
"!=",
"null",
")",
"{",
"l_last",
"=",
"p",
";",
"/* Remember node from which we */",
"/* last moved left (successor) */",
"stack",
".",
"push",
"(",
"NodeStack",
".",
"PROCESS_CURRENT",
",",
"p",
",",
"\"GBSTree.findDelete(1)\"",
")",
";",
"p",
"=",
"p",
".",
"leftChild",
"(",
")",
";",
"}",
"else",
"/* There is no left child */",
"{",
"/* Delete on left side */",
"leftDelete",
"(",
"p",
",",
"r_last",
",",
"deleteKey",
",",
"point",
")",
";",
"p",
"=",
"null",
";",
"}",
"}",
"else",
"/* Delete key > median key */",
"{",
"if",
"(",
"p",
".",
"rightChild",
"(",
")",
"!=",
"null",
")",
"{",
"r_last",
"=",
"p",
";",
"/* Remember node from which we */",
"/* last moved right (predecessor) */",
"stack",
".",
"push",
"(",
"NodeStack",
".",
"DONE_VISITS",
",",
"p",
",",
"\"GBSTree.findDelete(2)\"",
")",
";",
"p",
"=",
"p",
".",
"rightChild",
"(",
")",
";",
"}",
"else",
"/* There is no right child */",
"{",
"rightDelete",
"(",
"p",
",",
"l_last",
",",
"deleteKey",
",",
"point",
")",
";",
"p",
"=",
"null",
";",
"}",
"}",
"}",
"}"
] | Find the delete point within the tree.
@param point The DeleteNode that will identify the delete point.
@param stack The DeleteStack that records nodes traversed.
@param deleteKey Object to be deleted. | [
"Find",
"the",
"delete",
"point",
"within",
"the",
"tree",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L2040-L2096 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.midDelete | private void midDelete(
DeleteStack stack,
GBSNode p,
DeleteNode point)
{
/* Assume no lower predecessor/successor */
point.setDelete(p, p.middleIndex());
GBSNode q = p.lowerPredecessor(stack);
if (q != null) /* Have a lower predecessor */
{
/* Elevate right-most of lower pred. */
point.setDelete(q, q.rightMostIndex());
point.setTarget(p, p.middleIndex(), DeleteNode.ADD_LEFT);
}
else /* There is no lower predecessor */
{
/* Check for lower successor */
q = p.lowerSuccessor(stack);
if (q != null) /* Have a lower successor */
{
/* Elevate left-most of lower successor */
point.setDelete(q, 0);
point.setTarget(p, p.middleIndex(), DeleteNode.ADD_RIGHT);
}
}
} | java | private void midDelete(
DeleteStack stack,
GBSNode p,
DeleteNode point)
{
/* Assume no lower predecessor/successor */
point.setDelete(p, p.middleIndex());
GBSNode q = p.lowerPredecessor(stack);
if (q != null) /* Have a lower predecessor */
{
/* Elevate right-most of lower pred. */
point.setDelete(q, q.rightMostIndex());
point.setTarget(p, p.middleIndex(), DeleteNode.ADD_LEFT);
}
else /* There is no lower predecessor */
{
/* Check for lower successor */
q = p.lowerSuccessor(stack);
if (q != null) /* Have a lower successor */
{
/* Elevate left-most of lower successor */
point.setDelete(q, 0);
point.setTarget(p, p.middleIndex(), DeleteNode.ADD_RIGHT);
}
}
} | [
"private",
"void",
"midDelete",
"(",
"DeleteStack",
"stack",
",",
"GBSNode",
"p",
",",
"DeleteNode",
"point",
")",
"{",
"/* Assume no lower predecessor/successor */",
"point",
".",
"setDelete",
"(",
"p",
",",
"p",
".",
"middleIndex",
"(",
")",
")",
";",
"GBSNode",
"q",
"=",
"p",
".",
"lowerPredecessor",
"(",
"stack",
")",
";",
"if",
"(",
"q",
"!=",
"null",
")",
"/* Have a lower predecessor */",
"{",
"/* Elevate right-most of lower pred. */",
"point",
".",
"setDelete",
"(",
"q",
",",
"q",
".",
"rightMostIndex",
"(",
")",
")",
";",
"point",
".",
"setTarget",
"(",
"p",
",",
"p",
".",
"middleIndex",
"(",
")",
",",
"DeleteNode",
".",
"ADD_LEFT",
")",
";",
"}",
"else",
"/* There is no lower predecessor */",
"{",
"/* Check for lower successor */",
"q",
"=",
"p",
".",
"lowerSuccessor",
"(",
"stack",
")",
";",
"if",
"(",
"q",
"!=",
"null",
")",
"/* Have a lower successor */",
"{",
"/* Elevate left-most of lower successor */",
"point",
".",
"setDelete",
"(",
"q",
",",
"0",
")",
";",
"point",
".",
"setTarget",
"(",
"p",
",",
"p",
".",
"middleIndex",
"(",
")",
",",
"DeleteNode",
".",
"ADD_RIGHT",
")",
";",
"}",
"}",
"}"
] | Delete a key with an equal match.
<p>During the search, we happened upon an equal match. If there is
a predecessor at a lower level, we bring it up to fill the hole and
make it the delete key. Otherwise, the one we have found is the
delete key already.</p> | [
"Delete",
"a",
"key",
"with",
"an",
"equal",
"match",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L2107-L2132 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.leftDelete | private void leftDelete(
GBSNode p,
GBSNode r,
Object deleteKey,
DeleteNode point)
{
if (r == null) /* There is no upper predecessor */
leftDeleteNoPredecessor(p, deleteKey, point);
else /* There is an upper predecessor */
leftDeleteWithPredecessor(p, r, deleteKey, point);
} | java | private void leftDelete(
GBSNode p,
GBSNode r,
Object deleteKey,
DeleteNode point)
{
if (r == null) /* There is no upper predecessor */
leftDeleteNoPredecessor(p, deleteKey, point);
else /* There is an upper predecessor */
leftDeleteWithPredecessor(p, r, deleteKey, point);
} | [
"private",
"void",
"leftDelete",
"(",
"GBSNode",
"p",
",",
"GBSNode",
"r",
",",
"Object",
"deleteKey",
",",
"DeleteNode",
"point",
")",
"{",
"if",
"(",
"r",
"==",
"null",
")",
"/* There is no upper predecessor */",
"leftDeleteNoPredecessor",
"(",
"p",
",",
"deleteKey",
",",
"point",
")",
";",
"else",
"/* There is an upper predecessor */",
"leftDeleteWithPredecessor",
"(",
"p",
",",
"r",
",",
"deleteKey",
",",
"point",
")",
";",
"}"
] | Delete from current or predecessor.
<ol>
<li>There is no left child.
<li> There might or might not be a right child
<li>DELETE_KEY < MEDIAN of current node
<li>DELETE_KEY > MEDIAN of predecessor (if there is one)
</ol>
<p>In the example below, if the current node is GHI, then the delete
key is greater than E and less than H. If the current node is MNO,
then the delete key is greater than K and less than N. If the
current node is ABC, the delete key is less than B and there is no
predecessor because there is no node from which we moved right.</p>
<pre>
*------------------J.K.L------------------*
| |
| |
| |
*-------D.E.F-------* *-------P.Q.R-------*
| | | |
| | | |
| | | |
A.B.C G.H.I M.N.O S.T.U
</pre>
<p>We tried to move left and fell off the end. If the key value is
greater than the high key of the predecessor or if there is no
predecessor, the delete key is in the left half of the current
node. Otherwise, the delete key is in the right half of the
predecessor node.</p>
@param p Current node from which we tried to move left
@param r Last node from which we actually moved right (logical predecessor)
@param deleteKey Key being deleted
@param point Returned delete point | [
"Delete",
"from",
"current",
"or",
"predecessor",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L2175-L2185 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.leftDeleteNoPredecessor | private void leftDeleteNoPredecessor(
GBSNode p,
Object deleteKey,
DeleteNode point)
{
int idx = p.findDeleteInLeft(deleteKey);
if (idx >= 0)
point.setDelete(p, idx);
} | java | private void leftDeleteNoPredecessor(
GBSNode p,
Object deleteKey,
DeleteNode point)
{
int idx = p.findDeleteInLeft(deleteKey);
if (idx >= 0)
point.setDelete(p, idx);
} | [
"private",
"void",
"leftDeleteNoPredecessor",
"(",
"GBSNode",
"p",
",",
"Object",
"deleteKey",
",",
"DeleteNode",
"point",
")",
"{",
"int",
"idx",
"=",
"p",
".",
"findDeleteInLeft",
"(",
"deleteKey",
")",
";",
"if",
"(",
"idx",
">=",
"0",
")",
"point",
".",
"setDelete",
"(",
"p",
",",
"idx",
")",
";",
"}"
] | Delete from left side with no upper predecessor. | [
"Delete",
"from",
"left",
"side",
"with",
"no",
"upper",
"predecessor",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L2190-L2198 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.leftDeleteWithPredecessor | private void leftDeleteWithPredecessor(
GBSNode p,
GBSNode r,
Object deleteKey,
DeleteNode point)
{
java.util.Comparator comp = p.deleteComparator();
int xcc = comp.compare(deleteKey, r.rightMostKey());
if (xcc == 0) /* Target key IS predecessor high key */
{
/* Migrate up low key of current (delete key)
into high key of predecessor (target key) */
point.setDelete(p, 0);
point.setTarget(r, r.rightMostIndex(), DeleteNode.OVERLAY_RIGHT);
}
else if (xcc > 0) /* Target key > predecessor high key */
{
/* Target is in left part of current */
int ix = p.findDeleteInLeft(deleteKey);
if ( !(ix < 0) )
point.setDelete(p, ix);
}
else /* Target key < predecessor high */
{
/* It is in right half of predecessor */
int ix = r.findDeleteInRight(deleteKey);
if ( !(ix < 0) )
{
point.setTarget(r, ix, DeleteNode.ADD_RIGHT);
point.setDelete(p, 0);
}
}
} | java | private void leftDeleteWithPredecessor(
GBSNode p,
GBSNode r,
Object deleteKey,
DeleteNode point)
{
java.util.Comparator comp = p.deleteComparator();
int xcc = comp.compare(deleteKey, r.rightMostKey());
if (xcc == 0) /* Target key IS predecessor high key */
{
/* Migrate up low key of current (delete key)
into high key of predecessor (target key) */
point.setDelete(p, 0);
point.setTarget(r, r.rightMostIndex(), DeleteNode.OVERLAY_RIGHT);
}
else if (xcc > 0) /* Target key > predecessor high key */
{
/* Target is in left part of current */
int ix = p.findDeleteInLeft(deleteKey);
if ( !(ix < 0) )
point.setDelete(p, ix);
}
else /* Target key < predecessor high */
{
/* It is in right half of predecessor */
int ix = r.findDeleteInRight(deleteKey);
if ( !(ix < 0) )
{
point.setTarget(r, ix, DeleteNode.ADD_RIGHT);
point.setDelete(p, 0);
}
}
} | [
"private",
"void",
"leftDeleteWithPredecessor",
"(",
"GBSNode",
"p",
",",
"GBSNode",
"r",
",",
"Object",
"deleteKey",
",",
"DeleteNode",
"point",
")",
"{",
"java",
".",
"util",
".",
"Comparator",
"comp",
"=",
"p",
".",
"deleteComparator",
"(",
")",
";",
"int",
"xcc",
"=",
"comp",
".",
"compare",
"(",
"deleteKey",
",",
"r",
".",
"rightMostKey",
"(",
")",
")",
";",
"if",
"(",
"xcc",
"==",
"0",
")",
"/* Target key IS predecessor high key */",
"{",
"/* Migrate up low key of current (delete key)\n into high key of predecessor (target key) */",
"point",
".",
"setDelete",
"(",
"p",
",",
"0",
")",
";",
"point",
".",
"setTarget",
"(",
"r",
",",
"r",
".",
"rightMostIndex",
"(",
")",
",",
"DeleteNode",
".",
"OVERLAY_RIGHT",
")",
";",
"}",
"else",
"if",
"(",
"xcc",
">",
"0",
")",
"/* Target key > predecessor high key */",
"{",
"/* Target is in left part of current */",
"int",
"ix",
"=",
"p",
".",
"findDeleteInLeft",
"(",
"deleteKey",
")",
";",
"if",
"(",
"!",
"(",
"ix",
"<",
"0",
")",
")",
"point",
".",
"setDelete",
"(",
"p",
",",
"ix",
")",
";",
"}",
"else",
"/* Target key < predecessor high */",
"{",
"/* It is in right half of predecessor */",
"int",
"ix",
"=",
"r",
".",
"findDeleteInRight",
"(",
"deleteKey",
")",
";",
"if",
"(",
"!",
"(",
"ix",
"<",
"0",
")",
")",
"{",
"point",
".",
"setTarget",
"(",
"r",
",",
"ix",
",",
"DeleteNode",
".",
"ADD_RIGHT",
")",
";",
"point",
".",
"setDelete",
"(",
"p",
",",
"0",
")",
";",
"}",
"}",
"}"
] | Delete from left side with an upper predecessor present. | [
"Delete",
"from",
"left",
"side",
"with",
"an",
"upper",
"predecessor",
"present",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L2203-L2235 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.rightDelete | private void rightDelete(
GBSNode p,
GBSNode l,
Object deleteKey,
DeleteNode point)
{
if (l == null) /* There is no upper successor */
rightDeleteNoSuccessor(p, deleteKey, point);
else /* There is an upper successor */
rightDeleteWithSuccessor(p, l, deleteKey, point);
} | java | private void rightDelete(
GBSNode p,
GBSNode l,
Object deleteKey,
DeleteNode point)
{
if (l == null) /* There is no upper successor */
rightDeleteNoSuccessor(p, deleteKey, point);
else /* There is an upper successor */
rightDeleteWithSuccessor(p, l, deleteKey, point);
} | [
"private",
"void",
"rightDelete",
"(",
"GBSNode",
"p",
",",
"GBSNode",
"l",
",",
"Object",
"deleteKey",
",",
"DeleteNode",
"point",
")",
"{",
"if",
"(",
"l",
"==",
"null",
")",
"/* There is no upper successor */",
"rightDeleteNoSuccessor",
"(",
"p",
",",
"deleteKey",
",",
"point",
")",
";",
"else",
"/* There is an upper successor */",
"rightDeleteWithSuccessor",
"(",
"p",
",",
"l",
",",
"deleteKey",
",",
"point",
")",
";",
"}"
] | Delete from current or successor.
<ol>
<li>There is no right child
<li>There may or may not be a left child.
<li>DELETE_KEY > MEDIAN of current node.
<li>DELETE_KEY < MEDIAN of successor (if there is one)
</ol>
<p>In the example below, if the current node is GHI, then the delete
key is greater than H and less than K. If the current node is
MNO, then the delete key is greater than N and less than Q. If
the current node is STU, the insert key is greater than T and
there is no successor.</p>
<pre>
*------------------J.K.L------------------*
| |
| |
| |
*-------D.E.F-------* *-------P.Q.R-------*
| | | |
| | | |
| | | |
A.B.C G.H.I M.N.O S.T.U
</pre>
<p>We tried to move right and fell off the end. If the key value is
less than the low key of the successor or if there is no successor,
the delete key (if any) is in the right half of the current node.
Otherwise, the delete key (if any) is in the left half of the
successor node.</p>
@param p Current node from which we tried to move left
@param l Last node from which we actually moved left (logical successor)
@param deleteKey Key being deleted
@param point Returned delete point | [
"Delete",
"from",
"current",
"or",
"successor",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L2278-L2288 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.rightDeleteNoSuccessor | private void rightDeleteNoSuccessor(
GBSNode p,
Object deleteKey,
DeleteNode point)
{
int idx = p.findDeleteInRight(deleteKey);
if (idx >= 0)
point.setDelete(p, idx);
} | java | private void rightDeleteNoSuccessor(
GBSNode p,
Object deleteKey,
DeleteNode point)
{
int idx = p.findDeleteInRight(deleteKey);
if (idx >= 0)
point.setDelete(p, idx);
} | [
"private",
"void",
"rightDeleteNoSuccessor",
"(",
"GBSNode",
"p",
",",
"Object",
"deleteKey",
",",
"DeleteNode",
"point",
")",
"{",
"int",
"idx",
"=",
"p",
".",
"findDeleteInRight",
"(",
"deleteKey",
")",
";",
"if",
"(",
"idx",
">=",
"0",
")",
"point",
".",
"setDelete",
"(",
"p",
",",
"idx",
")",
";",
"}"
] | Delete from right side with no successor. | [
"Delete",
"from",
"right",
"side",
"with",
"no",
"successor",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L2293-L2301 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.rightDeleteWithSuccessor | private void rightDeleteWithSuccessor(
GBSNode p,
GBSNode l,
Object deleteKey,
DeleteNode point)
{
java.util.Comparator comp = p.deleteComparator();
int xcc = comp.compare(deleteKey, l.leftMostKey());
if (xcc == 0) /* Target key IS low key of successor */
{
/* Migrate up high key of current (delete key)
into low key of successor (target key) */
point.setDelete(p, p.rightMostIndex());
point.setTarget(l, 0, DeleteNode.OVERLAY_LEFT);
}
else if (xcc < 0) /* Less than left most key of successor */
{
/* Target is in right of current */
int ix = p.findDeleteInRight(deleteKey);
if (ix >= 0)
point.setDelete(p, ix);
}
else /* Greater than left most of successor */
{
/* Target is in left of successor */
int ix = l.findDeleteInLeft(deleteKey);
if (ix >= 0)
{
/* Migrate up high key of current (delete key) into
low key of successor (hole left after keys moved) */
point.setDelete(p, p.rightMostIndex());
point.setTarget(l, ix, DeleteNode.ADD_LEFT);
}
}
} | java | private void rightDeleteWithSuccessor(
GBSNode p,
GBSNode l,
Object deleteKey,
DeleteNode point)
{
java.util.Comparator comp = p.deleteComparator();
int xcc = comp.compare(deleteKey, l.leftMostKey());
if (xcc == 0) /* Target key IS low key of successor */
{
/* Migrate up high key of current (delete key)
into low key of successor (target key) */
point.setDelete(p, p.rightMostIndex());
point.setTarget(l, 0, DeleteNode.OVERLAY_LEFT);
}
else if (xcc < 0) /* Less than left most key of successor */
{
/* Target is in right of current */
int ix = p.findDeleteInRight(deleteKey);
if (ix >= 0)
point.setDelete(p, ix);
}
else /* Greater than left most of successor */
{
/* Target is in left of successor */
int ix = l.findDeleteInLeft(deleteKey);
if (ix >= 0)
{
/* Migrate up high key of current (delete key) into
low key of successor (hole left after keys moved) */
point.setDelete(p, p.rightMostIndex());
point.setTarget(l, ix, DeleteNode.ADD_LEFT);
}
}
} | [
"private",
"void",
"rightDeleteWithSuccessor",
"(",
"GBSNode",
"p",
",",
"GBSNode",
"l",
",",
"Object",
"deleteKey",
",",
"DeleteNode",
"point",
")",
"{",
"java",
".",
"util",
".",
"Comparator",
"comp",
"=",
"p",
".",
"deleteComparator",
"(",
")",
";",
"int",
"xcc",
"=",
"comp",
".",
"compare",
"(",
"deleteKey",
",",
"l",
".",
"leftMostKey",
"(",
")",
")",
";",
"if",
"(",
"xcc",
"==",
"0",
")",
"/* Target key IS low key of successor */",
"{",
"/* Migrate up high key of current (delete key)\n into low key of successor (target key) */",
"point",
".",
"setDelete",
"(",
"p",
",",
"p",
".",
"rightMostIndex",
"(",
")",
")",
";",
"point",
".",
"setTarget",
"(",
"l",
",",
"0",
",",
"DeleteNode",
".",
"OVERLAY_LEFT",
")",
";",
"}",
"else",
"if",
"(",
"xcc",
"<",
"0",
")",
"/* Less than left most key of successor */",
"{",
"/* Target is in right of current */",
"int",
"ix",
"=",
"p",
".",
"findDeleteInRight",
"(",
"deleteKey",
")",
";",
"if",
"(",
"ix",
">=",
"0",
")",
"point",
".",
"setDelete",
"(",
"p",
",",
"ix",
")",
";",
"}",
"else",
"/* Greater than left most of successor */",
"{",
"/* Target is in left of successor */",
"int",
"ix",
"=",
"l",
".",
"findDeleteInLeft",
"(",
"deleteKey",
")",
";",
"if",
"(",
"ix",
">=",
"0",
")",
"{",
"/* Migrate up high key of current (delete key) into\n low key of successor (hole left after keys moved) */",
"point",
".",
"setDelete",
"(",
"p",
",",
"p",
".",
"rightMostIndex",
"(",
")",
")",
";",
"point",
".",
"setTarget",
"(",
"l",
",",
"ix",
",",
"DeleteNode",
".",
"ADD_LEFT",
")",
";",
"}",
"}",
"}"
] | Delete from right side with successor node present. | [
"Delete",
"from",
"right",
"side",
"with",
"successor",
"node",
"present",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L2306-L2341 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.deleteFringeMigrate | private void deleteFringeMigrate(
DeleteStack stack,
GBSNode p)
{
GBSNode endp = p; /* Last node processed */
int endIndex = stack.index(); /* Index to last parent */
stack.add(0, p); /* Put last node in stack for possible */
/* use by rebalance */
/* Maximum number of right child nodes */
/* before the fringe must be rebalanced */
int maxBal = maximumFringeImbalance();
stack.processSubFringe(p); /* See DeleteStack.processNode */
endp = stack.lastNode();
endIndex = stack.lastIndex();
deleteCheckFringeBalance(
stack,
endp,
endIndex,
maxBal);
} | java | private void deleteFringeMigrate(
DeleteStack stack,
GBSNode p)
{
GBSNode endp = p; /* Last node processed */
int endIndex = stack.index(); /* Index to last parent */
stack.add(0, p); /* Put last node in stack for possible */
/* use by rebalance */
/* Maximum number of right child nodes */
/* before the fringe must be rebalanced */
int maxBal = maximumFringeImbalance();
stack.processSubFringe(p); /* See DeleteStack.processNode */
endp = stack.lastNode();
endIndex = stack.lastIndex();
deleteCheckFringeBalance(
stack,
endp,
endIndex,
maxBal);
} | [
"private",
"void",
"deleteFringeMigrate",
"(",
"DeleteStack",
"stack",
",",
"GBSNode",
"p",
")",
"{",
"GBSNode",
"endp",
"=",
"p",
";",
"/* Last node processed */",
"int",
"endIndex",
"=",
"stack",
".",
"index",
"(",
")",
";",
"/* Index to last parent */",
"stack",
".",
"add",
"(",
"0",
",",
"p",
")",
";",
"/* Put last node in stack for possible */",
"/* use by rebalance */",
"/* Maximum number of right child nodes */",
"/* before the fringe must be rebalanced */",
"int",
"maxBal",
"=",
"maximumFringeImbalance",
"(",
")",
";",
"stack",
".",
"processSubFringe",
"(",
"p",
")",
";",
"/* See DeleteStack.processNode */",
"endp",
"=",
"stack",
".",
"lastNode",
"(",
")",
";",
"endIndex",
"=",
"stack",
".",
"lastIndex",
"(",
")",
";",
"deleteCheckFringeBalance",
"(",
"stack",
",",
"endp",
",",
"endIndex",
",",
"maxBal",
")",
";",
"}"
] | Migrate a hole from a partial leaf through to the proper place
in its fringe, deleting a node from the right side of the fringe
if necessary.
<p>This may cause a fringe t0 tree to degenerate to a linear list
which, in turn, will trigger a height rebalancing.</p>
@param tree The index we are using
@param stack The stack that has been used to walk the tree
@param p Node from which we are migrating. Its right-most
slot is the hole being migrated. | [
"Migrate",
"a",
"hole",
"from",
"a",
"partial",
"leaf",
"through",
"to",
"the",
"proper",
"place",
"in",
"its",
"fringe",
"deleting",
"a",
"node",
"from",
"the",
"right",
"side",
"of",
"the",
"fringe",
"if",
"necessary",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L2356-L2378 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java | GBSTree.deleteCheckFringeBalance | private void deleteCheckFringeBalance(
DeleteStack stack,
GBSNode endp,
int endIndex,
int maxBal)
{
int fDepth = 0; /* Fringe balance depth */
fDepth = 0;
if (endp.leftChild() == null)
{
fDepth = 1; /* Last node counts as one */
for (int j = endIndex; j > 0; j--)
{
GBSNode q = stack.node(j);
if (q.leftChild() == null)/* Have not found end yet */
fDepth++;
else /* Found the top of the fringe */
break;
}
}
int t0_depth = tZeroDepth();
int t = t0_depth;
if (t < 1)
t = 1;
if ( (stack.maxDepth() >= t) &&/* Deep enough for a t0 and */
(endp.population() == (endp.width()-1)) )/* Last node was full */
{
/* Check for a possible t0 tree */
int j = 1;
if ((kFactor() % 3) == 0)
j = 2;
if (fDepth == j)
{
_xno++;
GBSDeleteFringe.singleInstance().balance(
tZeroDepth(), stack);
}
}
else /* Not a t0 fringe */
{
/* Check for empty node */
if (endp.population() != 0)
endp.adjustMedian();
else
{
_xno++;
GBSNode p = stack.node(endIndex);
if (p.leftChild() == endp)
p.setLeftChild(null);
else
p.setRightChild(null);
}
}
} | java | private void deleteCheckFringeBalance(
DeleteStack stack,
GBSNode endp,
int endIndex,
int maxBal)
{
int fDepth = 0; /* Fringe balance depth */
fDepth = 0;
if (endp.leftChild() == null)
{
fDepth = 1; /* Last node counts as one */
for (int j = endIndex; j > 0; j--)
{
GBSNode q = stack.node(j);
if (q.leftChild() == null)/* Have not found end yet */
fDepth++;
else /* Found the top of the fringe */
break;
}
}
int t0_depth = tZeroDepth();
int t = t0_depth;
if (t < 1)
t = 1;
if ( (stack.maxDepth() >= t) &&/* Deep enough for a t0 and */
(endp.population() == (endp.width()-1)) )/* Last node was full */
{
/* Check for a possible t0 tree */
int j = 1;
if ((kFactor() % 3) == 0)
j = 2;
if (fDepth == j)
{
_xno++;
GBSDeleteFringe.singleInstance().balance(
tZeroDepth(), stack);
}
}
else /* Not a t0 fringe */
{
/* Check for empty node */
if (endp.population() != 0)
endp.adjustMedian();
else
{
_xno++;
GBSNode p = stack.node(endIndex);
if (p.leftChild() == endp)
p.setLeftChild(null);
else
p.setRightChild(null);
}
}
} | [
"private",
"void",
"deleteCheckFringeBalance",
"(",
"DeleteStack",
"stack",
",",
"GBSNode",
"endp",
",",
"int",
"endIndex",
",",
"int",
"maxBal",
")",
"{",
"int",
"fDepth",
"=",
"0",
";",
"/* Fringe balance depth */",
"fDepth",
"=",
"0",
";",
"if",
"(",
"endp",
".",
"leftChild",
"(",
")",
"==",
"null",
")",
"{",
"fDepth",
"=",
"1",
";",
"/* Last node counts as one */",
"for",
"(",
"int",
"j",
"=",
"endIndex",
";",
"j",
">",
"0",
";",
"j",
"--",
")",
"{",
"GBSNode",
"q",
"=",
"stack",
".",
"node",
"(",
"j",
")",
";",
"if",
"(",
"q",
".",
"leftChild",
"(",
")",
"==",
"null",
")",
"/* Have not found end yet */",
"fDepth",
"++",
";",
"else",
"/* Found the top of the fringe */",
"break",
";",
"}",
"}",
"int",
"t0_depth",
"=",
"tZeroDepth",
"(",
")",
";",
"int",
"t",
"=",
"t0_depth",
";",
"if",
"(",
"t",
"<",
"1",
")",
"t",
"=",
"1",
";",
"if",
"(",
"(",
"stack",
".",
"maxDepth",
"(",
")",
">=",
"t",
")",
"&&",
"/* Deep enough for a t0 and */",
"(",
"endp",
".",
"population",
"(",
")",
"==",
"(",
"endp",
".",
"width",
"(",
")",
"-",
"1",
")",
")",
")",
"/* Last node was full */",
"{",
"/* Check for a possible t0 tree */",
"int",
"j",
"=",
"1",
";",
"if",
"(",
"(",
"kFactor",
"(",
")",
"%",
"3",
")",
"==",
"0",
")",
"j",
"=",
"2",
";",
"if",
"(",
"fDepth",
"==",
"j",
")",
"{",
"_xno",
"++",
";",
"GBSDeleteFringe",
".",
"singleInstance",
"(",
")",
".",
"balance",
"(",
"tZeroDepth",
"(",
")",
",",
"stack",
")",
";",
"}",
"}",
"else",
"/* Not a t0 fringe */",
"{",
"/* Check for empty node */",
"if",
"(",
"endp",
".",
"population",
"(",
")",
"!=",
"0",
")",
"endp",
".",
"adjustMedian",
"(",
")",
";",
"else",
"{",
"_xno",
"++",
";",
"GBSNode",
"p",
"=",
"stack",
".",
"node",
"(",
"endIndex",
")",
";",
"if",
"(",
"p",
".",
"leftChild",
"(",
")",
"==",
"endp",
")",
"p",
".",
"setLeftChild",
"(",
"null",
")",
";",
"else",
"p",
".",
"setRightChild",
"(",
"null",
")",
";",
"}",
"}",
"}"
] | Check to see if fringe balancing is required following a delete
and do the fringe rebalancing if needed. | [
"Check",
"to",
"see",
"if",
"fringe",
"balancing",
"is",
"required",
"following",
"a",
"delete",
"and",
"do",
"the",
"fringe",
"rebalancing",
"if",
"needed",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/GBSTree.java#L2384-L2441 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.context/src/com/ibm/wsspi/threadcontext/ThreadContextDeserializer.java | ThreadContextDeserializer.deserialize | public static ThreadContextDescriptor deserialize(byte[] bytes, Map<String, String> execProps) throws ClassNotFoundException, IOException {
return new ThreadContextDescriptorImpl(execProps, bytes);
} | java | public static ThreadContextDescriptor deserialize(byte[] bytes, Map<String, String> execProps) throws ClassNotFoundException, IOException {
return new ThreadContextDescriptorImpl(execProps, bytes);
} | [
"public",
"static",
"ThreadContextDescriptor",
"deserialize",
"(",
"byte",
"[",
"]",
"bytes",
",",
"Map",
"<",
"String",
",",
"String",
">",
"execProps",
")",
"throws",
"ClassNotFoundException",
",",
"IOException",
"{",
"return",
"new",
"ThreadContextDescriptorImpl",
"(",
"execProps",
",",
"bytes",
")",
";",
"}"
] | Deserializes a thread context descriptor.
@param bytes bytes obtained from the ThreadContextDescriptor.serialize method.
@param execProps execution properties.
@return a thread context descriptor.
@throws ClassNotFoundException if unable to find a class during deserialization.
@throws IOException if an error occurs during deserialization. | [
"Deserializes",
"a",
"thread",
"context",
"descriptor",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.context/src/com/ibm/wsspi/threadcontext/ThreadContextDeserializer.java#L33-L35 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java | FileUtils.listFiles | public static File[] listFiles(final File target, final List<Pattern> patterns, final boolean include) {
if (patterns == null || patterns.isEmpty())
return target.listFiles();
return target.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
for (Pattern pattern : patterns) {
Matcher matcher = pattern.matcher(name);
if (matcher.matches())
return include;
}
return !include;
}
});
} | java | public static File[] listFiles(final File target, final List<Pattern> patterns, final boolean include) {
if (patterns == null || patterns.isEmpty())
return target.listFiles();
return target.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
for (Pattern pattern : patterns) {
Matcher matcher = pattern.matcher(name);
if (matcher.matches())
return include;
}
return !include;
}
});
} | [
"public",
"static",
"File",
"[",
"]",
"listFiles",
"(",
"final",
"File",
"target",
",",
"final",
"List",
"<",
"Pattern",
">",
"patterns",
",",
"final",
"boolean",
"include",
")",
"{",
"if",
"(",
"patterns",
"==",
"null",
"||",
"patterns",
".",
"isEmpty",
"(",
")",
")",
"return",
"target",
".",
"listFiles",
"(",
")",
";",
"return",
"target",
".",
"listFiles",
"(",
"new",
"FilenameFilter",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"accept",
"(",
"File",
"dir",
",",
"String",
"name",
")",
"{",
"for",
"(",
"Pattern",
"pattern",
":",
"patterns",
")",
"{",
"Matcher",
"matcher",
"=",
"pattern",
".",
"matcher",
"(",
"name",
")",
";",
"if",
"(",
"matcher",
".",
"matches",
"(",
")",
")",
"return",
"include",
";",
"}",
"return",
"!",
"include",
";",
"}",
"}",
")",
";",
"}"
] | List files according to the patterns and the pattern type
@param target
@param patterns
@param include
@return | [
"List",
"files",
"according",
"to",
"the",
"patterns",
"and",
"the",
"pattern",
"type"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java#L53-L71 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java | FileUtils.copyFile | public static void copyFile(File dest, File source) throws IOException {
InputStream input = null;
try {
input = new FileInputStream(source);
createFile(dest, input);
} finally {
Utils.tryToClose(input);
}
} | java | public static void copyFile(File dest, File source) throws IOException {
InputStream input = null;
try {
input = new FileInputStream(source);
createFile(dest, input);
} finally {
Utils.tryToClose(input);
}
} | [
"public",
"static",
"void",
"copyFile",
"(",
"File",
"dest",
",",
"File",
"source",
")",
"throws",
"IOException",
"{",
"InputStream",
"input",
"=",
"null",
";",
"try",
"{",
"input",
"=",
"new",
"FileInputStream",
"(",
"source",
")",
";",
"createFile",
"(",
"dest",
",",
"input",
")",
";",
"}",
"finally",
"{",
"Utils",
".",
"tryToClose",
"(",
"input",
")",
";",
"}",
"}"
] | Copy from one file to the other
@param dest
@param source
@throws IOException | [
"Copy",
"from",
"one",
"file",
"to",
"the",
"other"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java#L80-L88 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java | FileUtils.createFile | public static void createFile(final File dest, final InputStream sourceInput) throws IOException {
if (sourceInput == null || dest == null)
return;
FileOutputStream fos = null;
try {
if (!dest.getParentFile().exists()) {
if (!dest.getParentFile().mkdirs()) {
throw new FileNotFoundException();
}
}
fos = TextFileOutputStreamFactory.createOutputStream(dest);
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int count = -1;
while ((count = sourceInput.read(buffer)) > 0) {
fos.write(buffer, 0, count);
}
fos.flush();
} finally {
Utils.tryToClose(fos);
Utils.tryToClose(sourceInput);
}
} | java | public static void createFile(final File dest, final InputStream sourceInput) throws IOException {
if (sourceInput == null || dest == null)
return;
FileOutputStream fos = null;
try {
if (!dest.getParentFile().exists()) {
if (!dest.getParentFile().mkdirs()) {
throw new FileNotFoundException();
}
}
fos = TextFileOutputStreamFactory.createOutputStream(dest);
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int count = -1;
while ((count = sourceInput.read(buffer)) > 0) {
fos.write(buffer, 0, count);
}
fos.flush();
} finally {
Utils.tryToClose(fos);
Utils.tryToClose(sourceInput);
}
} | [
"public",
"static",
"void",
"createFile",
"(",
"final",
"File",
"dest",
",",
"final",
"InputStream",
"sourceInput",
")",
"throws",
"IOException",
"{",
"if",
"(",
"sourceInput",
"==",
"null",
"||",
"dest",
"==",
"null",
")",
"return",
";",
"FileOutputStream",
"fos",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"!",
"dest",
".",
"getParentFile",
"(",
")",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"dest",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
")",
";",
"}",
"}",
"fos",
"=",
"TextFileOutputStreamFactory",
".",
"createOutputStream",
"(",
"dest",
")",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"DEFAULT_BUFFER_SIZE",
"]",
";",
"int",
"count",
"=",
"-",
"1",
";",
"while",
"(",
"(",
"count",
"=",
"sourceInput",
".",
"read",
"(",
"buffer",
")",
")",
">",
"0",
")",
"{",
"fos",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"count",
")",
";",
"}",
"fos",
".",
"flush",
"(",
")",
";",
"}",
"finally",
"{",
"Utils",
".",
"tryToClose",
"(",
"fos",
")",
";",
"Utils",
".",
"tryToClose",
"(",
"sourceInput",
")",
";",
"}",
"}"
] | Read the content from an inputStream and write out to the other file
@param dest
@param sourceInput
@throws IOException | [
"Read",
"the",
"content",
"from",
"an",
"inputStream",
"and",
"write",
"out",
"to",
"the",
"other",
"file"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java#L97-L121 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java | FileUtils.copyDir | public static void copyDir(File from, File to) throws FileNotFoundException, IOException {
File[] files = from.listFiles();
if (files != null) {
for (File ff : files) {
File tf = new File(to, ff.getName());
if (ff.isDirectory()) {
if (tf.mkdir()) {
copyDir(ff, tf);
}
} else if (ff.isFile()) {
copyFile(tf, ff);
}
}
}
} | java | public static void copyDir(File from, File to) throws FileNotFoundException, IOException {
File[] files = from.listFiles();
if (files != null) {
for (File ff : files) {
File tf = new File(to, ff.getName());
if (ff.isDirectory()) {
if (tf.mkdir()) {
copyDir(ff, tf);
}
} else if (ff.isFile()) {
copyFile(tf, ff);
}
}
}
} | [
"public",
"static",
"void",
"copyDir",
"(",
"File",
"from",
",",
"File",
"to",
")",
"throws",
"FileNotFoundException",
",",
"IOException",
"{",
"File",
"[",
"]",
"files",
"=",
"from",
".",
"listFiles",
"(",
")",
";",
"if",
"(",
"files",
"!=",
"null",
")",
"{",
"for",
"(",
"File",
"ff",
":",
"files",
")",
"{",
"File",
"tf",
"=",
"new",
"File",
"(",
"to",
",",
"ff",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"ff",
".",
"isDirectory",
"(",
")",
")",
"{",
"if",
"(",
"tf",
".",
"mkdir",
"(",
")",
")",
"{",
"copyDir",
"(",
"ff",
",",
"tf",
")",
";",
"}",
"}",
"else",
"if",
"(",
"ff",
".",
"isFile",
"(",
")",
")",
"{",
"copyFile",
"(",
"tf",
",",
"ff",
")",
";",
"}",
"}",
"}",
"}"
] | Recursively copy the files from one dir to the other.
@param from The directory to copy from, must exist.
@param to The directory to copy to, must exist, must be empty.
@throws IOException
@throws FileNotFoundException | [
"Recursively",
"copy",
"the",
"files",
"from",
"one",
"dir",
"to",
"the",
"other",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java#L162-L177 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java | FileUtils.isUnderDirectory | public static boolean isUnderDirectory(File child, File parent) {
if (child == null || parent == null)
return false;
URI childUri = child.toURI();
URI relativeUri = parent.toURI().relativize(childUri);
return relativeUri.equals(childUri) ? false : true;
} | java | public static boolean isUnderDirectory(File child, File parent) {
if (child == null || parent == null)
return false;
URI childUri = child.toURI();
URI relativeUri = parent.toURI().relativize(childUri);
return relativeUri.equals(childUri) ? false : true;
} | [
"public",
"static",
"boolean",
"isUnderDirectory",
"(",
"File",
"child",
",",
"File",
"parent",
")",
"{",
"if",
"(",
"child",
"==",
"null",
"||",
"parent",
"==",
"null",
")",
"return",
"false",
";",
"URI",
"childUri",
"=",
"child",
".",
"toURI",
"(",
")",
";",
"URI",
"relativeUri",
"=",
"parent",
".",
"toURI",
"(",
")",
".",
"relativize",
"(",
"childUri",
")",
";",
"return",
"relativeUri",
".",
"equals",
"(",
"childUri",
")",
"?",
"false",
":",
"true",
";",
"}"
] | If child is under parent, will return true, otherwise, return false.
@param child
@param parent
@return | [
"If",
"child",
"is",
"under",
"parent",
"will",
"return",
"true",
"otherwise",
"return",
"false",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java#L218-L226 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java | FileUtils.normalizeEntryPath | public static String normalizeEntryPath(String entryPath) {
if (entryPath == null || entryPath.isEmpty())
return "";
entryPath = entryPath.replace("\\", "/");
if (entryPath.startsWith("/")) {
if (entryPath.length() == 1) {
entryPath = "";
} else {
entryPath = entryPath.substring(1, entryPath.length());
}
}
return entryPath;
} | java | public static String normalizeEntryPath(String entryPath) {
if (entryPath == null || entryPath.isEmpty())
return "";
entryPath = entryPath.replace("\\", "/");
if (entryPath.startsWith("/")) {
if (entryPath.length() == 1) {
entryPath = "";
} else {
entryPath = entryPath.substring(1, entryPath.length());
}
}
return entryPath;
} | [
"public",
"static",
"String",
"normalizeEntryPath",
"(",
"String",
"entryPath",
")",
"{",
"if",
"(",
"entryPath",
"==",
"null",
"||",
"entryPath",
".",
"isEmpty",
"(",
")",
")",
"return",
"\"\"",
";",
"entryPath",
"=",
"entryPath",
".",
"replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
")",
";",
"if",
"(",
"entryPath",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"if",
"(",
"entryPath",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"entryPath",
"=",
"\"\"",
";",
"}",
"else",
"{",
"entryPath",
"=",
"entryPath",
".",
"substring",
"(",
"1",
",",
"entryPath",
".",
"length",
"(",
")",
")",
";",
"}",
"}",
"return",
"entryPath",
";",
"}"
] | Normalize a relative entry path, so that it can be used in an archive.
@param entryPath
@return | [
"Normalize",
"a",
"relative",
"entry",
"path",
"so",
"that",
"it",
"can",
"be",
"used",
"in",
"an",
"archive",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java#L287-L302 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java | FileUtils.normalizeDirPath | public static String normalizeDirPath(String dirPath) {
if (dirPath == null || dirPath.isEmpty())
return "";
dirPath = dirPath.replace("\\", "/");
if (!dirPath.endsWith("/")) {
dirPath = dirPath + "/";
}
return dirPath;
} | java | public static String normalizeDirPath(String dirPath) {
if (dirPath == null || dirPath.isEmpty())
return "";
dirPath = dirPath.replace("\\", "/");
if (!dirPath.endsWith("/")) {
dirPath = dirPath + "/";
}
return dirPath;
} | [
"public",
"static",
"String",
"normalizeDirPath",
"(",
"String",
"dirPath",
")",
"{",
"if",
"(",
"dirPath",
"==",
"null",
"||",
"dirPath",
".",
"isEmpty",
"(",
")",
")",
"return",
"\"\"",
";",
"dirPath",
"=",
"dirPath",
".",
"replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
")",
";",
"if",
"(",
"!",
"dirPath",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"dirPath",
"=",
"dirPath",
"+",
"\"/\"",
";",
"}",
"return",
"dirPath",
";",
"}"
] | Normalize a path that represents a directory
@param dirPath
@return | [
"Normalize",
"a",
"path",
"that",
"represents",
"a",
"directory"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal/FileUtils.java#L310-L321 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/jdbc/internal/JDBCDrivers.java | JDBCDrivers.contains | private static final boolean contains(Collection<String> list, String value) {
for (String item : list)
if (item.contains(value))
return true;
return false;
} | java | private static final boolean contains(Collection<String> list, String value) {
for (String item : list)
if (item.contains(value))
return true;
return false;
} | [
"private",
"static",
"final",
"boolean",
"contains",
"(",
"Collection",
"<",
"String",
">",
"list",
",",
"String",
"value",
")",
"{",
"for",
"(",
"String",
"item",
":",
"list",
")",
"if",
"(",
"item",
".",
"contains",
"(",
"value",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] | Utility method that determines if some text is found as a substring within the contents of a list.
@param list items through which to search.
@param value text for which to search.
@return true if found, otherwise false. | [
"Utility",
"method",
"that",
"determines",
"if",
"some",
"text",
"is",
"found",
"as",
"a",
"substring",
"within",
"the",
"contents",
"of",
"a",
"list",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/jdbc/internal/JDBCDrivers.java#L255-L260 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/jdbc/internal/JDBCDrivers.java | JDBCDrivers.getConnectionPoolDataSourceClassName | static String getConnectionPoolDataSourceClassName(String vendorPropertiesPID) {
String[] classNames = classNamesByPID.get(vendorPropertiesPID);
return classNames == null ? null : classNames[1];
} | java | static String getConnectionPoolDataSourceClassName(String vendorPropertiesPID) {
String[] classNames = classNamesByPID.get(vendorPropertiesPID);
return classNames == null ? null : classNames[1];
} | [
"static",
"String",
"getConnectionPoolDataSourceClassName",
"(",
"String",
"vendorPropertiesPID",
")",
"{",
"String",
"[",
"]",
"classNames",
"=",
"classNamesByPID",
".",
"get",
"(",
"vendorPropertiesPID",
")",
";",
"return",
"classNames",
"==",
"null",
"?",
"null",
":",
"classNames",
"[",
"1",
"]",
";",
"}"
] | Infer the vendor implementation class name for javax.sql.ConnectionPoolDataSource based on the PID of the vendor properties.
A best effort is made for the known vendors.
@param vendorPropertiesPID factory pid of the JDBC vendor properties.
@return name of vendor implementation class for javax.sql.ConnectionPoolDataSource. Null if unknown. | [
"Infer",
"the",
"vendor",
"implementation",
"class",
"name",
"for",
"javax",
".",
"sql",
".",
"ConnectionPoolDataSource",
"based",
"on",
"the",
"PID",
"of",
"the",
"vendor",
"properties",
".",
"A",
"best",
"effort",
"is",
"made",
"for",
"the",
"known",
"vendors",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/jdbc/internal/JDBCDrivers.java#L287-L290 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/jdbc/internal/JDBCDrivers.java | JDBCDrivers.getDataSourceClassName | static String getDataSourceClassName(Collection<String> fileNames) {
for (Map.Entry<String, String[]> entry : classNamesByKey.entrySet())
if (contains(fileNames, entry.getKey())) {
String[] classNames = entry.getValue();
return classNames == null ? null : classNames[0];
}
return null;
} | java | static String getDataSourceClassName(Collection<String> fileNames) {
for (Map.Entry<String, String[]> entry : classNamesByKey.entrySet())
if (contains(fileNames, entry.getKey())) {
String[] classNames = entry.getValue();
return classNames == null ? null : classNames[0];
}
return null;
} | [
"static",
"String",
"getDataSourceClassName",
"(",
"Collection",
"<",
"String",
">",
"fileNames",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
"[",
"]",
">",
"entry",
":",
"classNamesByKey",
".",
"entrySet",
"(",
")",
")",
"if",
"(",
"contains",
"(",
"fileNames",
",",
"entry",
".",
"getKey",
"(",
")",
")",
")",
"{",
"String",
"[",
"]",
"classNames",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"return",
"classNames",
"==",
"null",
"?",
"null",
":",
"classNames",
"[",
"0",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Infer the vendor implementation class name for javax.sql.DataSource based on the JAR or ZIP names.
A best effort is made for the known vendors.
@param fileNames all upper case names of JAR and/or ZIP files for the JDBC driver.
@return name of the vendor implementation class for javax.sql.DataSource. Null if unknown. | [
"Infer",
"the",
"vendor",
"implementation",
"class",
"name",
"for",
"javax",
".",
"sql",
".",
"DataSource",
"based",
"on",
"the",
"JAR",
"or",
"ZIP",
"names",
".",
"A",
"best",
"effort",
"is",
"made",
"for",
"the",
"known",
"vendors",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/jdbc/internal/JDBCDrivers.java#L299-L308 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/jdbc/internal/JDBCDrivers.java | JDBCDrivers.getDataSourceClassName | static String getDataSourceClassName(String vendorPropertiesPID) {
String[] classNames = classNamesByPID.get(vendorPropertiesPID);
return classNames == null ? null : classNames[0];
} | java | static String getDataSourceClassName(String vendorPropertiesPID) {
String[] classNames = classNamesByPID.get(vendorPropertiesPID);
return classNames == null ? null : classNames[0];
} | [
"static",
"String",
"getDataSourceClassName",
"(",
"String",
"vendorPropertiesPID",
")",
"{",
"String",
"[",
"]",
"classNames",
"=",
"classNamesByPID",
".",
"get",
"(",
"vendorPropertiesPID",
")",
";",
"return",
"classNames",
"==",
"null",
"?",
"null",
":",
"classNames",
"[",
"0",
"]",
";",
"}"
] | Infer the vendor implementation class name for javax.sql.DataSource based on the PID of the vendor properties.
A best effort is made for the known vendors.
@param vendorPropertiesPID factory pid of the JDBC vendor properties.
@return name of vendor implementation class for javax.sql.DataSource. Null if unknown. | [
"Infer",
"the",
"vendor",
"implementation",
"class",
"name",
"for",
"javax",
".",
"sql",
".",
"DataSource",
"based",
"on",
"the",
"PID",
"of",
"the",
"vendor",
"properties",
".",
"A",
"best",
"effort",
"is",
"made",
"for",
"the",
"known",
"vendors",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/jdbc/internal/JDBCDrivers.java#L317-L320 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/jdbc/internal/JDBCDrivers.java | JDBCDrivers.getXADataSourceClassName | static String getXADataSourceClassName(String vendorPropertiesPID) {
String[] classNames = classNamesByPID.get(vendorPropertiesPID);
return classNames == null ? null : classNames[2];
} | java | static String getXADataSourceClassName(String vendorPropertiesPID) {
String[] classNames = classNamesByPID.get(vendorPropertiesPID);
return classNames == null ? null : classNames[2];
} | [
"static",
"String",
"getXADataSourceClassName",
"(",
"String",
"vendorPropertiesPID",
")",
"{",
"String",
"[",
"]",
"classNames",
"=",
"classNamesByPID",
".",
"get",
"(",
"vendorPropertiesPID",
")",
";",
"return",
"classNames",
"==",
"null",
"?",
"null",
":",
"classNames",
"[",
"2",
"]",
";",
"}"
] | Infer the vendor implementation class name for javax.sql.XADataSource based on the PID of the vendor properties.
A best effort is made for the known vendors.
@param vendorPropertiesPID factory pid of the JDBC vendor properties.
@return name of vendor implementation class for javax.sql.XADataSource. Null if unknown. | [
"Infer",
"the",
"vendor",
"implementation",
"class",
"name",
"for",
"javax",
".",
"sql",
".",
"XADataSource",
"based",
"on",
"the",
"PID",
"of",
"the",
"vendor",
"properties",
".",
"A",
"best",
"effort",
"is",
"made",
"for",
"the",
"known",
"vendors",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/jdbc/internal/JDBCDrivers.java#L347-L350 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/jdbc/internal/JDBCDrivers.java | JDBCDrivers.tryToLoad | private static String tryToLoad(Class<?> type, ClassLoader loader, String... classNames) {
final boolean trace = TraceComponent.isAnyTracingEnabled();
for (String className : classNames)
try {
Class<?> c = loader.loadClass(className);
boolean isInstance = type.isAssignableFrom(c);
if (trace && tc.isDebugEnabled())
Tr.debug(tc, className + " is " + (isInstance ? "" : "not ") + "an instance of " + type.getName());
if (type.isAssignableFrom(c))
return className;
} catch (ClassNotFoundException x) {
if (trace && tc.isDebugEnabled())
Tr.debug(tc, className + " not found on " + loader);
}
return null;
} | java | private static String tryToLoad(Class<?> type, ClassLoader loader, String... classNames) {
final boolean trace = TraceComponent.isAnyTracingEnabled();
for (String className : classNames)
try {
Class<?> c = loader.loadClass(className);
boolean isInstance = type.isAssignableFrom(c);
if (trace && tc.isDebugEnabled())
Tr.debug(tc, className + " is " + (isInstance ? "" : "not ") + "an instance of " + type.getName());
if (type.isAssignableFrom(c))
return className;
} catch (ClassNotFoundException x) {
if (trace && tc.isDebugEnabled())
Tr.debug(tc, className + " not found on " + loader);
}
return null;
} | [
"private",
"static",
"String",
"tryToLoad",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"ClassLoader",
"loader",
",",
"String",
"...",
"classNames",
")",
"{",
"final",
"boolean",
"trace",
"=",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
";",
"for",
"(",
"String",
"className",
":",
"classNames",
")",
"try",
"{",
"Class",
"<",
"?",
">",
"c",
"=",
"loader",
".",
"loadClass",
"(",
"className",
")",
";",
"boolean",
"isInstance",
"=",
"type",
".",
"isAssignableFrom",
"(",
"c",
")",
";",
"if",
"(",
"trace",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"className",
"+",
"\" is \"",
"+",
"(",
"isInstance",
"?",
"\"\"",
":",
"\"not \"",
")",
"+",
"\"an instance of \"",
"+",
"type",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"type",
".",
"isAssignableFrom",
"(",
"c",
")",
")",
"return",
"className",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"x",
")",
"{",
"if",
"(",
"trace",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"className",
"+",
"\" not found on \"",
"+",
"loader",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Attempt to load the specified class names, returning the first that successfully loads
and is an instance of the specified type.
@param type data source interface
@param loader class loader
@param classNames ordered list of class names to check
@return the first class name that successfully loads and is an instance of the specified interface. Otherwise, NULL. | [
"Attempt",
"to",
"load",
"the",
"specified",
"class",
"names",
"returning",
"the",
"first",
"that",
"successfully",
"loads",
"and",
"is",
"an",
"instance",
"of",
"the",
"specified",
"type",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/jdbc/internal/JDBCDrivers.java#L504-L520 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.token.ltpa/src/com/ibm/ws/security/token/ltpa/internal/UserData.java | UserData.getAttributes | protected final String[] getAttributes(String key) {
ArrayList<String> array = this._attributes.get(key);
if (array != null && array.size() > 0) {
String[] type = new String[array.size()];
return array.toArray(type);
}
return null;
} | java | protected final String[] getAttributes(String key) {
ArrayList<String> array = this._attributes.get(key);
if (array != null && array.size() > 0) {
String[] type = new String[array.size()];
return array.toArray(type);
}
return null;
} | [
"protected",
"final",
"String",
"[",
"]",
"getAttributes",
"(",
"String",
"key",
")",
"{",
"ArrayList",
"<",
"String",
">",
"array",
"=",
"this",
".",
"_attributes",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"array",
"!=",
"null",
"&&",
"array",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"String",
"[",
"]",
"type",
"=",
"new",
"String",
"[",
"array",
".",
"size",
"(",
")",
"]",
";",
"return",
"array",
".",
"toArray",
"(",
"type",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Get the attribute value based on the named value. A string array
is returned containing all values of the attribute previously set.
@param key The name of a attribute
@return A list of the attribute values corresponding with the specified key | [
"Get",
"the",
"attribute",
"value",
"based",
"on",
"the",
"named",
"value",
".",
"A",
"string",
"array",
"is",
"returned",
"containing",
"all",
"values",
"of",
"the",
"attribute",
"previously",
"set",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.token.ltpa/src/com/ibm/ws/security/token/ltpa/internal/UserData.java#L70-L77 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jmx.connector.client.rest/src/com/ibm/ws/jmx/connector/client/rest/internal/FileTransferClient.java | FileTransferClient.handleOperation | public Object handleOperation(String operation, Object[] params) throws IOException {
if (OPERATION_DOWNLOAD.equals(operation)) {
if (params.length == 2) {
downloadFile((String) params[0], (String) params[1]);
} else {
//partial download
return downloadFile((String) params[0], (String) params[1], (Long) params[2], (Long) params[3]);
}
} else if (OPERATION_UPLOAD.equals(operation)) {
uploadFile((String) params[0], (String) params[1], (Boolean) params[2]);
} else if (OPERATION_DELETE.equals(operation)) {
deleteFile((String) params[0]);
} else if (OPERATION_DELETE_ALL.equals(operation)) {
deleteAll((List<String>) params[0]);
} else {
throw logUnsupportedOperationError("handleOperation", operation);
}
//currently all operations are void, so return null.
return null;
} | java | public Object handleOperation(String operation, Object[] params) throws IOException {
if (OPERATION_DOWNLOAD.equals(operation)) {
if (params.length == 2) {
downloadFile((String) params[0], (String) params[1]);
} else {
//partial download
return downloadFile((String) params[0], (String) params[1], (Long) params[2], (Long) params[3]);
}
} else if (OPERATION_UPLOAD.equals(operation)) {
uploadFile((String) params[0], (String) params[1], (Boolean) params[2]);
} else if (OPERATION_DELETE.equals(operation)) {
deleteFile((String) params[0]);
} else if (OPERATION_DELETE_ALL.equals(operation)) {
deleteAll((List<String>) params[0]);
} else {
throw logUnsupportedOperationError("handleOperation", operation);
}
//currently all operations are void, so return null.
return null;
} | [
"public",
"Object",
"handleOperation",
"(",
"String",
"operation",
",",
"Object",
"[",
"]",
"params",
")",
"throws",
"IOException",
"{",
"if",
"(",
"OPERATION_DOWNLOAD",
".",
"equals",
"(",
"operation",
")",
")",
"{",
"if",
"(",
"params",
".",
"length",
"==",
"2",
")",
"{",
"downloadFile",
"(",
"(",
"String",
")",
"params",
"[",
"0",
"]",
",",
"(",
"String",
")",
"params",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"//partial download",
"return",
"downloadFile",
"(",
"(",
"String",
")",
"params",
"[",
"0",
"]",
",",
"(",
"String",
")",
"params",
"[",
"1",
"]",
",",
"(",
"Long",
")",
"params",
"[",
"2",
"]",
",",
"(",
"Long",
")",
"params",
"[",
"3",
"]",
")",
";",
"}",
"}",
"else",
"if",
"(",
"OPERATION_UPLOAD",
".",
"equals",
"(",
"operation",
")",
")",
"{",
"uploadFile",
"(",
"(",
"String",
")",
"params",
"[",
"0",
"]",
",",
"(",
"String",
")",
"params",
"[",
"1",
"]",
",",
"(",
"Boolean",
")",
"params",
"[",
"2",
"]",
")",
";",
"}",
"else",
"if",
"(",
"OPERATION_DELETE",
".",
"equals",
"(",
"operation",
")",
")",
"{",
"deleteFile",
"(",
"(",
"String",
")",
"params",
"[",
"0",
"]",
")",
";",
"}",
"else",
"if",
"(",
"OPERATION_DELETE_ALL",
".",
"equals",
"(",
"operation",
")",
")",
"{",
"deleteAll",
"(",
"(",
"List",
"<",
"String",
">",
")",
"params",
"[",
"0",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"logUnsupportedOperationError",
"(",
"\"handleOperation\"",
",",
"operation",
")",
";",
"}",
"//currently all operations are void, so return null.",
"return",
"null",
";",
"}"
] | Handle MBean invocation requests | [
"Handle",
"MBean",
"invocation",
"requests"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jmx.connector.client.rest/src/com/ibm/ws/jmx/connector/client/rest/internal/FileTransferClient.java#L85-L105 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/h2internal/H2TCPReadRequestContext.java | H2TCPReadRequestContext.read | @Override
public long read(long numBytes, int timeout) throws IOException {
long readCount = 0;
H2StreamProcessor p = muxLink.getStreamProcessor(streamID);
try {
p.getReadLatch().await(timeout, TimeUnit.MILLISECONDS);
readCount = p.readCount(numBytes, this.getBuffers());
} catch (InterruptedException e) {
throw new IOException("read was stopped by an InterruptedException: " + e);
}
return readCount;
} | java | @Override
public long read(long numBytes, int timeout) throws IOException {
long readCount = 0;
H2StreamProcessor p = muxLink.getStreamProcessor(streamID);
try {
p.getReadLatch().await(timeout, TimeUnit.MILLISECONDS);
readCount = p.readCount(numBytes, this.getBuffers());
} catch (InterruptedException e) {
throw new IOException("read was stopped by an InterruptedException: " + e);
}
return readCount;
} | [
"@",
"Override",
"public",
"long",
"read",
"(",
"long",
"numBytes",
",",
"int",
"timeout",
")",
"throws",
"IOException",
"{",
"long",
"readCount",
"=",
"0",
";",
"H2StreamProcessor",
"p",
"=",
"muxLink",
".",
"getStreamProcessor",
"(",
"streamID",
")",
";",
"try",
"{",
"p",
".",
"getReadLatch",
"(",
")",
".",
"await",
"(",
"timeout",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"readCount",
"=",
"p",
".",
"readCount",
"(",
"numBytes",
",",
"this",
".",
"getBuffers",
"(",
")",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"read was stopped by an InterruptedException: \"",
"+",
"e",
")",
";",
"}",
"return",
"readCount",
";",
"}"
] | Get bytes from the stream processor associated with this read context | [
"Get",
"bytes",
"from",
"the",
"stream",
"processor",
"associated",
"with",
"this",
"read",
"context"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/h2internal/H2TCPReadRequestContext.java#L110-L123 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.context/src/com/ibm/ws/security/context/internal/SecurityContextProviderImpl.java | SecurityContextProviderImpl.getConfigNameForRef | @FFDCIgnore(PrivilegedActionException.class)
private String getConfigNameForRef(final String ref) {
String name = null;
if (ref != null) {
final ConfigurationAdmin configAdmin = configAdminRef.getService();
Configuration config;
try {
config = AccessController.doPrivileged(new PrivilegedExceptionAction<Configuration>() {
@Override
public Configuration run() throws IOException {
return configAdmin.getConfiguration(ref, configAdminRef.getReference().getBundle().getLocation());
}
});
} catch (PrivilegedActionException paex) {
return null;
}
Dictionary<String, Object> props = config.getProperties();
name = (String) props.get(KEY_NAME);
}
return name;
} | java | @FFDCIgnore(PrivilegedActionException.class)
private String getConfigNameForRef(final String ref) {
String name = null;
if (ref != null) {
final ConfigurationAdmin configAdmin = configAdminRef.getService();
Configuration config;
try {
config = AccessController.doPrivileged(new PrivilegedExceptionAction<Configuration>() {
@Override
public Configuration run() throws IOException {
return configAdmin.getConfiguration(ref, configAdminRef.getReference().getBundle().getLocation());
}
});
} catch (PrivilegedActionException paex) {
return null;
}
Dictionary<String, Object> props = config.getProperties();
name = (String) props.get(KEY_NAME);
}
return name;
} | [
"@",
"FFDCIgnore",
"(",
"PrivilegedActionException",
".",
"class",
")",
"private",
"String",
"getConfigNameForRef",
"(",
"final",
"String",
"ref",
")",
"{",
"String",
"name",
"=",
"null",
";",
"if",
"(",
"ref",
"!=",
"null",
")",
"{",
"final",
"ConfigurationAdmin",
"configAdmin",
"=",
"configAdminRef",
".",
"getService",
"(",
")",
";",
"Configuration",
"config",
";",
"try",
"{",
"config",
"=",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedExceptionAction",
"<",
"Configuration",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Configuration",
"run",
"(",
")",
"throws",
"IOException",
"{",
"return",
"configAdmin",
".",
"getConfiguration",
"(",
"ref",
",",
"configAdminRef",
".",
"getReference",
"(",
")",
".",
"getBundle",
"(",
")",
".",
"getLocation",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"PrivilegedActionException",
"paex",
")",
"{",
"return",
"null",
";",
"}",
"Dictionary",
"<",
"String",
",",
"Object",
">",
"props",
"=",
"config",
".",
"getProperties",
"(",
")",
";",
"name",
"=",
"(",
"String",
")",
"props",
".",
"get",
"(",
"KEY_NAME",
")",
";",
"}",
"return",
"name",
";",
"}"
] | Use the config admin service to get the name for a given service reference
@param ref the service reference string
@return the name or null if there were problems | [
"Use",
"the",
"config",
"admin",
"service",
"to",
"get",
"the",
"name",
"for",
"a",
"given",
"service",
"reference"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.context/src/com/ibm/ws/security/context/internal/SecurityContextProviderImpl.java#L170-L190 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.org.apache.cxf.cxf.rt.rs.client.3.2/src/com/ibm/ws/jaxrs21/clientconfig/JAXRSClientConfigHolder.java | JAXRSClientConfigHolder.addConfig | public static synchronized void addConfig(String id, String uri, Map<String, String> params) {
uriMap.put(id, uri);
configInfo.put(uri, params);
resolvedConfigInfo.clear();
if (uri.endsWith("*")) {
wildcardsPresentInConfigInfo = true;
}
} | java | public static synchronized void addConfig(String id, String uri, Map<String, String> params) {
uriMap.put(id, uri);
configInfo.put(uri, params);
resolvedConfigInfo.clear();
if (uri.endsWith("*")) {
wildcardsPresentInConfigInfo = true;
}
} | [
"public",
"static",
"synchronized",
"void",
"addConfig",
"(",
"String",
"id",
",",
"String",
"uri",
",",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"{",
"uriMap",
".",
"put",
"(",
"id",
",",
"uri",
")",
";",
"configInfo",
".",
"put",
"(",
"uri",
",",
"params",
")",
";",
"resolvedConfigInfo",
".",
"clear",
"(",
")",
";",
"if",
"(",
"uri",
".",
"endsWith",
"(",
"\"*\"",
")",
")",
"{",
"wildcardsPresentInConfigInfo",
"=",
"true",
";",
"}",
"}"
] | add a configuration for a URL
We'd like a set of hashmaps keyed by URL, however when osgi calls
deactivate, we have no arguments, so we have to associate a url with
the object id of the service. That allows us to remove the right one.
@param id - the object id of the service instance that added this.
@param url - the uri of the record being added. Might end with *
@param params - the properties applicable to this url. | [
"add",
"a",
"configuration",
"for",
"a",
"URL",
"We",
"d",
"like",
"a",
"set",
"of",
"hashmaps",
"keyed",
"by",
"URL",
"however",
"when",
"osgi",
"calls",
"deactivate",
"we",
"have",
"no",
"arguments",
"so",
"we",
"have",
"to",
"associate",
"a",
"url",
"with",
"the",
"object",
"id",
"of",
"the",
"service",
".",
"That",
"allows",
"us",
"to",
"remove",
"the",
"right",
"one",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.org.apache.cxf.cxf.rt.rs.client.3.2/src/com/ibm/ws/jaxrs21/clientconfig/JAXRSClientConfigHolder.java#L54-L61 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/application/viewstate/SessionIdGenerator.java | SessionIdGenerator.generateSessionId | public String generateSessionId()
{
byte random[] = new byte[16];
// Render the result as a String of hexadecimal digits
StringBuilder buffer = new StringBuilder();
int resultLenBytes = 0;
while (resultLenBytes < sessionIdLength)
{
getRandomBytes(random);
for (int j = 0;
j < random.length && resultLenBytes < sessionIdLength;
j++)
{
byte b1 = (byte) ((random[j] & 0xf0) >> 4);
byte b2 = (byte) (random[j] & 0x0f);
if (b1 < 10)
{
buffer.append((char) ('0' + b1));
}
else
{
buffer.append((char) ('A' + (b1 - 10)));
}
if (b2 < 10)
{
buffer.append((char) ('0' + b2));
}
else
{
buffer.append((char) ('A' + (b2 - 10)));
}
resultLenBytes++;
}
}
if (jvmRoute != null && jvmRoute.length() > 0)
{
buffer.append('.').append(jvmRoute);
}
return buffer.toString();
} | java | public String generateSessionId()
{
byte random[] = new byte[16];
// Render the result as a String of hexadecimal digits
StringBuilder buffer = new StringBuilder();
int resultLenBytes = 0;
while (resultLenBytes < sessionIdLength)
{
getRandomBytes(random);
for (int j = 0;
j < random.length && resultLenBytes < sessionIdLength;
j++)
{
byte b1 = (byte) ((random[j] & 0xf0) >> 4);
byte b2 = (byte) (random[j] & 0x0f);
if (b1 < 10)
{
buffer.append((char) ('0' + b1));
}
else
{
buffer.append((char) ('A' + (b1 - 10)));
}
if (b2 < 10)
{
buffer.append((char) ('0' + b2));
}
else
{
buffer.append((char) ('A' + (b2 - 10)));
}
resultLenBytes++;
}
}
if (jvmRoute != null && jvmRoute.length() > 0)
{
buffer.append('.').append(jvmRoute);
}
return buffer.toString();
} | [
"public",
"String",
"generateSessionId",
"(",
")",
"{",
"byte",
"random",
"[",
"]",
"=",
"new",
"byte",
"[",
"16",
"]",
";",
"// Render the result as a String of hexadecimal digits",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"resultLenBytes",
"=",
"0",
";",
"while",
"(",
"resultLenBytes",
"<",
"sessionIdLength",
")",
"{",
"getRandomBytes",
"(",
"random",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"random",
".",
"length",
"&&",
"resultLenBytes",
"<",
"sessionIdLength",
";",
"j",
"++",
")",
"{",
"byte",
"b1",
"=",
"(",
"byte",
")",
"(",
"(",
"random",
"[",
"j",
"]",
"&",
"0xf0",
")",
">>",
"4",
")",
";",
"byte",
"b2",
"=",
"(",
"byte",
")",
"(",
"random",
"[",
"j",
"]",
"&",
"0x0f",
")",
";",
"if",
"(",
"b1",
"<",
"10",
")",
"{",
"buffer",
".",
"append",
"(",
"(",
"char",
")",
"(",
"'",
"'",
"+",
"b1",
")",
")",
";",
"}",
"else",
"{",
"buffer",
".",
"append",
"(",
"(",
"char",
")",
"(",
"'",
"'",
"+",
"(",
"b1",
"-",
"10",
")",
")",
")",
";",
"}",
"if",
"(",
"b2",
"<",
"10",
")",
"{",
"buffer",
".",
"append",
"(",
"(",
"char",
")",
"(",
"'",
"'",
"+",
"b2",
")",
")",
";",
"}",
"else",
"{",
"buffer",
".",
"append",
"(",
"(",
"char",
")",
"(",
"'",
"'",
"+",
"(",
"b2",
"-",
"10",
")",
")",
")",
";",
"}",
"resultLenBytes",
"++",
";",
"}",
"}",
"if",
"(",
"jvmRoute",
"!=",
"null",
"&&",
"jvmRoute",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"buffer",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"jvmRoute",
")",
";",
"}",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | Generate and return a new session identifier. | [
"Generate",
"and",
"return",
"a",
"new",
"session",
"identifier",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/application/viewstate/SessionIdGenerator.java#L137-L182 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/matchspace/impl/MatchCache.java | MatchCache.containsKey | public boolean containsKey(Object key) {
FastHashtableEntry tab[] = table;
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
for (FastHashtableEntry e = tab[index] ; e != null ; e = e.next) {
if ((e.hash == hash) && e.key.equals(key)) {
return true;
}
}
return false;
} | java | public boolean containsKey(Object key) {
FastHashtableEntry tab[] = table;
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
for (FastHashtableEntry e = tab[index] ; e != null ; e = e.next) {
if ((e.hash == hash) && e.key.equals(key)) {
return true;
}
}
return false;
} | [
"public",
"boolean",
"containsKey",
"(",
"Object",
"key",
")",
"{",
"FastHashtableEntry",
"tab",
"[",
"]",
"=",
"table",
";",
"int",
"hash",
"=",
"key",
".",
"hashCode",
"(",
")",
";",
"int",
"index",
"=",
"(",
"hash",
"&",
"0x7FFFFFFF",
")",
"%",
"tab",
".",
"length",
";",
"for",
"(",
"FastHashtableEntry",
"e",
"=",
"tab",
"[",
"index",
"]",
";",
"e",
"!=",
"null",
";",
"e",
"=",
"e",
".",
"next",
")",
"{",
"if",
"(",
"(",
"e",
".",
"hash",
"==",
"hash",
")",
"&&",
"e",
".",
"key",
".",
"equals",
"(",
"key",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Tests if the specified object is a key in this hashtable.
@param key possible key.
@return <code>true</code> if the specified object is a key in this
hashtable; <code>false</code> otherwise.
@see java.util.Hashtable#contains(java.lang.Object)
@since JDK1.0 | [
"Tests",
"if",
"the",
"specified",
"object",
"is",
"a",
"key",
"in",
"this",
"hashtable",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/matchspace/impl/MatchCache.java#L269-L279 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/matchspace/impl/MatchCache.java | MatchCache.ableToFilter | private boolean ableToFilter() {
if (filter == null)
return false;
for (int i = table.length; i-- > 0 ;) {
FastHashtableEntry newContents = null, next = null;
for (FastHashtableEntry e = table[i] ; e != null ; e = next) {
next = e.next;
if (filter.shouldRetain(e.key, e.value)) {
e.next = newContents;
newContents = e;
}
else
count--;
}
table[i] = newContents;
}
return count < threshold;
} | java | private boolean ableToFilter() {
if (filter == null)
return false;
for (int i = table.length; i-- > 0 ;) {
FastHashtableEntry newContents = null, next = null;
for (FastHashtableEntry e = table[i] ; e != null ; e = next) {
next = e.next;
if (filter.shouldRetain(e.key, e.value)) {
e.next = newContents;
newContents = e;
}
else
count--;
}
table[i] = newContents;
}
return count < threshold;
} | [
"private",
"boolean",
"ableToFilter",
"(",
")",
"{",
"if",
"(",
"filter",
"==",
"null",
")",
"return",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"table",
".",
"length",
";",
"i",
"--",
">",
"0",
";",
")",
"{",
"FastHashtableEntry",
"newContents",
"=",
"null",
",",
"next",
"=",
"null",
";",
"for",
"(",
"FastHashtableEntry",
"e",
"=",
"table",
"[",
"i",
"]",
";",
"e",
"!=",
"null",
";",
"e",
"=",
"next",
")",
"{",
"next",
"=",
"e",
".",
"next",
";",
"if",
"(",
"filter",
".",
"shouldRetain",
"(",
"e",
".",
"key",
",",
"e",
".",
"value",
")",
")",
"{",
"e",
".",
"next",
"=",
"newContents",
";",
"newContents",
"=",
"e",
";",
"}",
"else",
"count",
"--",
";",
"}",
"table",
"[",
"i",
"]",
"=",
"newContents",
";",
"}",
"return",
"count",
"<",
"threshold",
";",
"}"
] | Avoids the need to rehash when some entries can be "filtered" out of the Hashtable by
an upcall to a separate decision routine.
@return true if filtering was able to reduce the size of the Hashtable sufficiently,
false if rehashing will be needed after all. | [
"Avoids",
"the",
"need",
"to",
"rehash",
"when",
"some",
"entries",
"can",
"be",
"filtered",
"out",
"of",
"the",
"Hashtable",
"by",
"an",
"upcall",
"to",
"a",
"separate",
"decision",
"routine",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/matchspace/impl/MatchCache.java#L340-L357 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/matchspace/impl/MatchCache.java | MatchCache.readObject | private void readObject(java.io.ObjectInputStream s)
throws IOException, ClassNotFoundException
{
// Read in the length, threshold, and loadfactor
s.defaultReadObject();
// Read the original length of the array and number of elements
int origlength = s.readInt();
int elements = s.readInt();
// Compute new size with a bit of room 5% to grow but
// No larger than the original size. Make the length
// odd if it's large enough, this helps distribute the entries.
// Guard against the length ending up zero, that's not valid.
int length = (int)(elements * loadFactor) + (elements / 20) + 3;
if (length > elements && (length & 1) == 0)
length--;
if (origlength > 0 && length > origlength)
length = origlength;
table = new FastHashtableEntry[length];
count = 0;
// Read the number of elements and then all the key/value objects
for (; elements > 0; elements--) {
Object key = s.readObject();
Object value = s.readObject();
put(key, value);
}
} | java | private void readObject(java.io.ObjectInputStream s)
throws IOException, ClassNotFoundException
{
// Read in the length, threshold, and loadfactor
s.defaultReadObject();
// Read the original length of the array and number of elements
int origlength = s.readInt();
int elements = s.readInt();
// Compute new size with a bit of room 5% to grow but
// No larger than the original size. Make the length
// odd if it's large enough, this helps distribute the entries.
// Guard against the length ending up zero, that's not valid.
int length = (int)(elements * loadFactor) + (elements / 20) + 3;
if (length > elements && (length & 1) == 0)
length--;
if (origlength > 0 && length > origlength)
length = origlength;
table = new FastHashtableEntry[length];
count = 0;
// Read the number of elements and then all the key/value objects
for (; elements > 0; elements--) {
Object key = s.readObject();
Object value = s.readObject();
put(key, value);
}
} | [
"private",
"void",
"readObject",
"(",
"java",
".",
"io",
".",
"ObjectInputStream",
"s",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"// Read in the length, threshold, and loadfactor",
"s",
".",
"defaultReadObject",
"(",
")",
";",
"// Read the original length of the array and number of elements",
"int",
"origlength",
"=",
"s",
".",
"readInt",
"(",
")",
";",
"int",
"elements",
"=",
"s",
".",
"readInt",
"(",
")",
";",
"// Compute new size with a bit of room 5% to grow but",
"// No larger than the original size. Make the length",
"// odd if it's large enough, this helps distribute the entries.",
"// Guard against the length ending up zero, that's not valid.",
"int",
"length",
"=",
"(",
"int",
")",
"(",
"elements",
"*",
"loadFactor",
")",
"+",
"(",
"elements",
"/",
"20",
")",
"+",
"3",
";",
"if",
"(",
"length",
">",
"elements",
"&&",
"(",
"length",
"&",
"1",
")",
"==",
"0",
")",
"length",
"--",
";",
"if",
"(",
"origlength",
">",
"0",
"&&",
"length",
">",
"origlength",
")",
"length",
"=",
"origlength",
";",
"table",
"=",
"new",
"FastHashtableEntry",
"[",
"length",
"]",
";",
"count",
"=",
"0",
";",
"// Read the number of elements and then all the key/value objects",
"for",
"(",
";",
"elements",
">",
"0",
";",
"elements",
"--",
")",
"{",
"Object",
"key",
"=",
"s",
".",
"readObject",
"(",
")",
";",
"Object",
"value",
"=",
"s",
".",
"readObject",
"(",
")",
";",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"}"
] | readObject is called to restore the state of the hashtable from
a stream. Only the keys and values are serialized since the
hash values may be different when the contents are restored.
Read count elements and insert into the hashtable. | [
"readObject",
"is",
"called",
"to",
"restore",
"the",
"state",
"of",
"the",
"hashtable",
"from",
"a",
"stream",
".",
"Only",
"the",
"keys",
"and",
"values",
"are",
"serialized",
"since",
"the",
"hash",
"values",
"may",
"be",
"different",
"when",
"the",
"contents",
"are",
"restored",
".",
"Read",
"count",
"elements",
"and",
"insert",
"into",
"the",
"hashtable",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/matchspace/impl/MatchCache.java#L628-L657 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLChannelData.java | SSLChannelData.getBooleanProperty | public boolean getBooleanProperty(String propertyName) {
boolean booleanValue = false;
// Pull the key from the property map
Object objectValue = this.properties.get(propertyName);
if (objectValue != null) {
if (objectValue instanceof Boolean) {
booleanValue = ((Boolean) objectValue).booleanValue();
} else if (objectValue instanceof String) {
booleanValue = Boolean.parseBoolean((String) objectValue);
}
}
return booleanValue;
} | java | public boolean getBooleanProperty(String propertyName) {
boolean booleanValue = false;
// Pull the key from the property map
Object objectValue = this.properties.get(propertyName);
if (objectValue != null) {
if (objectValue instanceof Boolean) {
booleanValue = ((Boolean) objectValue).booleanValue();
} else if (objectValue instanceof String) {
booleanValue = Boolean.parseBoolean((String) objectValue);
}
}
return booleanValue;
} | [
"public",
"boolean",
"getBooleanProperty",
"(",
"String",
"propertyName",
")",
"{",
"boolean",
"booleanValue",
"=",
"false",
";",
"// Pull the key from the property map",
"Object",
"objectValue",
"=",
"this",
".",
"properties",
".",
"get",
"(",
"propertyName",
")",
";",
"if",
"(",
"objectValue",
"!=",
"null",
")",
"{",
"if",
"(",
"objectValue",
"instanceof",
"Boolean",
")",
"{",
"booleanValue",
"=",
"(",
"(",
"Boolean",
")",
"objectValue",
")",
".",
"booleanValue",
"(",
")",
";",
"}",
"else",
"if",
"(",
"objectValue",
"instanceof",
"String",
")",
"{",
"booleanValue",
"=",
"Boolean",
".",
"parseBoolean",
"(",
"(",
"String",
")",
"objectValue",
")",
";",
"}",
"}",
"return",
"booleanValue",
";",
"}"
] | Query the boolean property value of the input name.
@param propertyName
@return boolean | [
"Query",
"the",
"boolean",
"property",
"value",
"of",
"the",
"input",
"name",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLChannelData.java#L272-L285 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLChannelData.java | SSLChannelData.getStringProperty | public String getStringProperty(String propertyName) {
Object value = this.properties.get(propertyName);
if (null != value && value instanceof String) {
return (String) value;
}
return null;
} | java | public String getStringProperty(String propertyName) {
Object value = this.properties.get(propertyName);
if (null != value && value instanceof String) {
return (String) value;
}
return null;
} | [
"public",
"String",
"getStringProperty",
"(",
"String",
"propertyName",
")",
"{",
"Object",
"value",
"=",
"this",
".",
"properties",
".",
"get",
"(",
"propertyName",
")",
";",
"if",
"(",
"null",
"!=",
"value",
"&&",
"value",
"instanceof",
"String",
")",
"{",
"return",
"(",
"String",
")",
"value",
";",
"}",
"return",
"null",
";",
"}"
] | Query the properties for the input name, the value will be null if not
found or was not a String object.
@param propertyName
@return String | [
"Query",
"the",
"properties",
"for",
"the",
"input",
"name",
"the",
"value",
"will",
"be",
"null",
"if",
"not",
"found",
"or",
"was",
"not",
"a",
"String",
"object",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLChannelData.java#L294-L300 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLChannelData.java | SSLChannelData.getBooleanProperty | private boolean getBooleanProperty(String key, String defaultValue, StringBuilder errors) {
boolean booleanValue = false;
String stringValue = null;
boolean valueCorrect = false;
// Pull the key from the property map
Object objectValue = this.properties.get(key);
if (objectValue != null) {
if (objectValue instanceof Boolean) {
booleanValue = ((Boolean) objectValue).booleanValue();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " set to " + booleanValue);
}
return booleanValue;
} else if (objectValue instanceof String) {
stringValue = (String) objectValue;
}
} else {
// Key is not in map.
if (defaultValue != null) {
stringValue = defaultValue;
} else {
// No default provided. Error.
errors.append(key);
errors.append(':');
errors.append(stringValue);
errors.append('\n');
return false;
}
}
// If we get this far, we have a non null string value to work with. May be the default.
// Verify the value.
if (stringValue != null) {
if (stringValue.equals("true")) {
booleanValue = true;
valueCorrect = true;
} else if (stringValue.equals("false")) {
booleanValue = false;
valueCorrect = true;
}
}
if (valueCorrect) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " set to " + booleanValue);
}
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " has invalid value " + stringValue);
}
errors.append(key);
errors.append(':');
errors.append(stringValue);
errors.append('\n');
}
return booleanValue;
} | java | private boolean getBooleanProperty(String key, String defaultValue, StringBuilder errors) {
boolean booleanValue = false;
String stringValue = null;
boolean valueCorrect = false;
// Pull the key from the property map
Object objectValue = this.properties.get(key);
if (objectValue != null) {
if (objectValue instanceof Boolean) {
booleanValue = ((Boolean) objectValue).booleanValue();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " set to " + booleanValue);
}
return booleanValue;
} else if (objectValue instanceof String) {
stringValue = (String) objectValue;
}
} else {
// Key is not in map.
if (defaultValue != null) {
stringValue = defaultValue;
} else {
// No default provided. Error.
errors.append(key);
errors.append(':');
errors.append(stringValue);
errors.append('\n');
return false;
}
}
// If we get this far, we have a non null string value to work with. May be the default.
// Verify the value.
if (stringValue != null) {
if (stringValue.equals("true")) {
booleanValue = true;
valueCorrect = true;
} else if (stringValue.equals("false")) {
booleanValue = false;
valueCorrect = true;
}
}
if (valueCorrect) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " set to " + booleanValue);
}
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " has invalid value " + stringValue);
}
errors.append(key);
errors.append(':');
errors.append(stringValue);
errors.append('\n');
}
return booleanValue;
} | [
"private",
"boolean",
"getBooleanProperty",
"(",
"String",
"key",
",",
"String",
"defaultValue",
",",
"StringBuilder",
"errors",
")",
"{",
"boolean",
"booleanValue",
"=",
"false",
";",
"String",
"stringValue",
"=",
"null",
";",
"boolean",
"valueCorrect",
"=",
"false",
";",
"// Pull the key from the property map",
"Object",
"objectValue",
"=",
"this",
".",
"properties",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"objectValue",
"!=",
"null",
")",
"{",
"if",
"(",
"objectValue",
"instanceof",
"Boolean",
")",
"{",
"booleanValue",
"=",
"(",
"(",
"Boolean",
")",
"objectValue",
")",
".",
"booleanValue",
"(",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Property \"",
"+",
"key",
"+",
"\" set to \"",
"+",
"booleanValue",
")",
";",
"}",
"return",
"booleanValue",
";",
"}",
"else",
"if",
"(",
"objectValue",
"instanceof",
"String",
")",
"{",
"stringValue",
"=",
"(",
"String",
")",
"objectValue",
";",
"}",
"}",
"else",
"{",
"// Key is not in map.",
"if",
"(",
"defaultValue",
"!=",
"null",
")",
"{",
"stringValue",
"=",
"defaultValue",
";",
"}",
"else",
"{",
"// No default provided. Error.",
"errors",
".",
"append",
"(",
"key",
")",
";",
"errors",
".",
"append",
"(",
"'",
"'",
")",
";",
"errors",
".",
"append",
"(",
"stringValue",
")",
";",
"errors",
".",
"append",
"(",
"'",
"'",
")",
";",
"return",
"false",
";",
"}",
"}",
"// If we get this far, we have a non null string value to work with. May be the default.",
"// Verify the value.",
"if",
"(",
"stringValue",
"!=",
"null",
")",
"{",
"if",
"(",
"stringValue",
".",
"equals",
"(",
"\"true\"",
")",
")",
"{",
"booleanValue",
"=",
"true",
";",
"valueCorrect",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"stringValue",
".",
"equals",
"(",
"\"false\"",
")",
")",
"{",
"booleanValue",
"=",
"false",
";",
"valueCorrect",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"valueCorrect",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Property \"",
"+",
"key",
"+",
"\" set to \"",
"+",
"booleanValue",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Property \"",
"+",
"key",
"+",
"\" has invalid value \"",
"+",
"stringValue",
")",
";",
"}",
"errors",
".",
"append",
"(",
"key",
")",
";",
"errors",
".",
"append",
"(",
"'",
"'",
")",
";",
"errors",
".",
"append",
"(",
"stringValue",
")",
";",
"errors",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"return",
"booleanValue",
";",
"}"
] | Extract String value from property list and convert to boolean.
@param key key to look up in the property map
@param defaultValue used if keynot found in map.
@param errors list of error string accumulating from reading invalid properties
@return value found for key in property map | [
"Extract",
"String",
"value",
"from",
"property",
"list",
"and",
"convert",
"to",
"boolean",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLChannelData.java#L320-L376 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLChannelData.java | SSLChannelData.getIntProperty | private int getIntProperty(String key, boolean defaultProvided, int defaultValue, StringBuilder errors) {
String value = getStringProperty(key);
if (null != value) {
try {
int realValue = Integer.parseInt(value);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " set to " + realValue);
}
return realValue;
} catch (NumberFormatException nfe) {
// no FFDC required;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + ", format error in [" + value + "]");
}
}
}
if (!defaultProvided) {
// No default available. This is an error.
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " not found. Error being tallied.");
}
errors.append(key);
errors.append(":null \n");
return -1;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " using default " + defaultValue);
}
return defaultValue;
} | java | private int getIntProperty(String key, boolean defaultProvided, int defaultValue, StringBuilder errors) {
String value = getStringProperty(key);
if (null != value) {
try {
int realValue = Integer.parseInt(value);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " set to " + realValue);
}
return realValue;
} catch (NumberFormatException nfe) {
// no FFDC required;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + ", format error in [" + value + "]");
}
}
}
if (!defaultProvided) {
// No default available. This is an error.
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " not found. Error being tallied.");
}
errors.append(key);
errors.append(":null \n");
return -1;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " using default " + defaultValue);
}
return defaultValue;
} | [
"private",
"int",
"getIntProperty",
"(",
"String",
"key",
",",
"boolean",
"defaultProvided",
",",
"int",
"defaultValue",
",",
"StringBuilder",
"errors",
")",
"{",
"String",
"value",
"=",
"getStringProperty",
"(",
"key",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"try",
"{",
"int",
"realValue",
"=",
"Integer",
".",
"parseInt",
"(",
"value",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Property \"",
"+",
"key",
"+",
"\" set to \"",
"+",
"realValue",
")",
";",
"}",
"return",
"realValue",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"// no FFDC required;",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Property \"",
"+",
"key",
"+",
"\", format error in [\"",
"+",
"value",
"+",
"\"]\"",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"defaultProvided",
")",
"{",
"// No default available. This is an error.",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Property \"",
"+",
"key",
"+",
"\" not found. Error being tallied.\"",
")",
";",
"}",
"errors",
".",
"append",
"(",
"key",
")",
";",
"errors",
".",
"append",
"(",
"\":null \\n\"",
")",
";",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Property \"",
"+",
"key",
"+",
"\" using default \"",
"+",
"defaultValue",
")",
";",
"}",
"return",
"defaultValue",
";",
"}"
] | Extract an integer property from the stored values. This might use a
default value if provided and the property was not found.
@param key
@param defaultProvided
@param defaultValue
@param errors
@return int | [
"Extract",
"an",
"integer",
"property",
"from",
"the",
"stored",
"values",
".",
"This",
"might",
"use",
"a",
"default",
"value",
"if",
"provided",
"and",
"the",
"property",
"was",
"not",
"found",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLChannelData.java#L388-L417 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.msgstore/src/com/ibm/ws/sib/msgstore/list/ReadWriteLock.java | ReadWriteLock.lockExclusive | public synchronized void lockExclusive()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "lockExclusive", this);
boolean interrupted = false;
// If another thread is attempting to lock exclusive,
// wait for it to finish first.
while (!tryLockExclusive())
{
try
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Waiting to get exclusive lock");
wait(1000);
}
catch (InterruptedException e)
{
// No FFDC code needed
interrupted = true;
}
}
// Wait for existing locks to be released
while (iLockCount > 0)
{
try
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Waiting for lock count to reach 0 " + iLockCount);
wait(1000);
}
catch (InterruptedException e)
{
// No FFDC code needed
interrupted = true;
}
}
if (interrupted)
{
Thread.currentThread().interrupt();
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "lockExclusive");
} | java | public synchronized void lockExclusive()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "lockExclusive", this);
boolean interrupted = false;
// If another thread is attempting to lock exclusive,
// wait for it to finish first.
while (!tryLockExclusive())
{
try
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Waiting to get exclusive lock");
wait(1000);
}
catch (InterruptedException e)
{
// No FFDC code needed
interrupted = true;
}
}
// Wait for existing locks to be released
while (iLockCount > 0)
{
try
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Waiting for lock count to reach 0 " + iLockCount);
wait(1000);
}
catch (InterruptedException e)
{
// No FFDC code needed
interrupted = true;
}
}
if (interrupted)
{
Thread.currentThread().interrupt();
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "lockExclusive");
} | [
"public",
"synchronized",
"void",
"lockExclusive",
"(",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"lockExclusive\"",
",",
"this",
")",
";",
"boolean",
"interrupted",
"=",
"false",
";",
"// If another thread is attempting to lock exclusive,",
"// wait for it to finish first.",
"while",
"(",
"!",
"tryLockExclusive",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"SibTr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"Waiting to get exclusive lock\"",
")",
";",
"wait",
"(",
"1000",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// No FFDC code needed",
"interrupted",
"=",
"true",
";",
"}",
"}",
"// Wait for existing locks to be released",
"while",
"(",
"iLockCount",
">",
"0",
")",
"{",
"try",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"SibTr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"Waiting for lock count to reach 0 \"",
"+",
"iLockCount",
")",
";",
"wait",
"(",
"1000",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// No FFDC code needed",
"interrupted",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"interrupted",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"lockExclusive\"",
")",
";",
"}"
] | This method locks the mutex so no other lockers can get the lock. | [
"This",
"method",
"locks",
"the",
"mutex",
"so",
"no",
"other",
"lockers",
"can",
"get",
"the",
"lock",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.msgstore/src/com/ibm/ws/sib/msgstore/list/ReadWriteLock.java#L158-L201 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/BeanMetaData.java | BeanMetaData.getLocalBusinessInterfaceIndex | public int getLocalBusinessInterfaceIndex(String interfaceName) {
if (ivBusinessLocalInterfaceClasses != null) {
for (int i = 0; i < ivBusinessLocalInterfaceClasses.length; i++) {
String bInterfaceName = ivBusinessLocalInterfaceClasses[i].getName();
if (bInterfaceName.equals(interfaceName)) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "getLocalBusinessInterfaceIndex : " +
bInterfaceName + " at index " + i);
return i;
}
}
}
return -1;
} | java | public int getLocalBusinessInterfaceIndex(String interfaceName) {
if (ivBusinessLocalInterfaceClasses != null) {
for (int i = 0; i < ivBusinessLocalInterfaceClasses.length; i++) {
String bInterfaceName = ivBusinessLocalInterfaceClasses[i].getName();
if (bInterfaceName.equals(interfaceName)) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "getLocalBusinessInterfaceIndex : " +
bInterfaceName + " at index " + i);
return i;
}
}
}
return -1;
} | [
"public",
"int",
"getLocalBusinessInterfaceIndex",
"(",
"String",
"interfaceName",
")",
"{",
"if",
"(",
"ivBusinessLocalInterfaceClasses",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ivBusinessLocalInterfaceClasses",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"bInterfaceName",
"=",
"ivBusinessLocalInterfaceClasses",
"[",
"i",
"]",
".",
"getName",
"(",
")",
";",
"if",
"(",
"bInterfaceName",
".",
"equals",
"(",
"interfaceName",
")",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"getLocalBusinessInterfaceIndex : \"",
"+",
"bInterfaceName",
"+",
"\" at index \"",
"+",
"i",
")",
";",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | Gets the index of the local business interface.
@param interfaceName the interface to find the index of
@return the index of the interface passed in | [
"Gets",
"the",
"index",
"of",
"the",
"local",
"business",
"interface",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/BeanMetaData.java#L1278-L1292 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/BeanMetaData.java | BeanMetaData.getRequiredLocalBusinessInterfaceIndex | public int getRequiredLocalBusinessInterfaceIndex(String interfaceName) throws IllegalStateException {
int interfaceIndex = getLocalBusinessInterfaceIndex(interfaceName);
if (interfaceIndex == -1) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "getRequiredLocalBusinessInterfaceIndex : IllegalStateException : " +
"Requested business interface not found : " +
interfaceName);
throw new IllegalStateException("Requested business interface not found : " + interfaceName);
}
return interfaceIndex;
} | java | public int getRequiredLocalBusinessInterfaceIndex(String interfaceName) throws IllegalStateException {
int interfaceIndex = getLocalBusinessInterfaceIndex(interfaceName);
if (interfaceIndex == -1) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "getRequiredLocalBusinessInterfaceIndex : IllegalStateException : " +
"Requested business interface not found : " +
interfaceName);
throw new IllegalStateException("Requested business interface not found : " + interfaceName);
}
return interfaceIndex;
} | [
"public",
"int",
"getRequiredLocalBusinessInterfaceIndex",
"(",
"String",
"interfaceName",
")",
"throws",
"IllegalStateException",
"{",
"int",
"interfaceIndex",
"=",
"getLocalBusinessInterfaceIndex",
"(",
"interfaceName",
")",
";",
"if",
"(",
"interfaceIndex",
"==",
"-",
"1",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"getRequiredLocalBusinessInterfaceIndex : IllegalStateException : \"",
"+",
"\"Requested business interface not found : \"",
"+",
"interfaceName",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"\"Requested business interface not found : \"",
"+",
"interfaceName",
")",
";",
"}",
"return",
"interfaceIndex",
";",
"}"
] | Gets the index of the local busines interface. This method will throw an
IllegalStateException if a local interface could not be matched. If it is
known that a match must occur on a local business interface, then this
method should be used.
@param interfaceName the interface to find a match on
@return the index of the business interface found
@throws IllegalStateException if the business interface cannot be found | [
"Gets",
"the",
"index",
"of",
"the",
"local",
"busines",
"interface",
".",
"This",
"method",
"will",
"throw",
"an",
"IllegalStateException",
"if",
"a",
"local",
"interface",
"could",
"not",
"be",
"matched",
".",
"If",
"it",
"is",
"known",
"that",
"a",
"match",
"must",
"occur",
"on",
"a",
"local",
"business",
"interface",
"then",
"this",
"method",
"should",
"be",
"used",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/BeanMetaData.java#L1333-L1346 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/BeanMetaData.java | BeanMetaData.getRemoteBusinessInterfaceIndex | public int getRemoteBusinessInterfaceIndex(String interfaceName) {
if (ivBusinessRemoteInterfaceClasses != null) {
for (int i = 0; i < ivBusinessRemoteInterfaceClasses.length; i++) {
String bInterface = ivBusinessRemoteInterfaceClasses[i].getName();
if (bInterface.equals(interfaceName)) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "getRemoteBusinessInterfaceIndex : " +
bInterface + " at index " + i);
return i;
}
}
}
return -1;
} | java | public int getRemoteBusinessInterfaceIndex(String interfaceName) {
if (ivBusinessRemoteInterfaceClasses != null) {
for (int i = 0; i < ivBusinessRemoteInterfaceClasses.length; i++) {
String bInterface = ivBusinessRemoteInterfaceClasses[i].getName();
if (bInterface.equals(interfaceName)) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "getRemoteBusinessInterfaceIndex : " +
bInterface + " at index " + i);
return i;
}
}
}
return -1;
} | [
"public",
"int",
"getRemoteBusinessInterfaceIndex",
"(",
"String",
"interfaceName",
")",
"{",
"if",
"(",
"ivBusinessRemoteInterfaceClasses",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ivBusinessRemoteInterfaceClasses",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"bInterface",
"=",
"ivBusinessRemoteInterfaceClasses",
"[",
"i",
"]",
".",
"getName",
"(",
")",
";",
"if",
"(",
"bInterface",
".",
"equals",
"(",
"interfaceName",
")",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"getRemoteBusinessInterfaceIndex : \"",
"+",
"bInterface",
"+",
"\" at index \"",
"+",
"i",
")",
";",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | Gets the index of the remote business interface.
@param interfaceName the interface to find the index of
@return the index of the interface passed in | [
"Gets",
"the",
"index",
"of",
"the",
"remote",
"business",
"interface",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/BeanMetaData.java#L1400-L1414 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/BeanMetaData.java | BeanMetaData.getRequiredRemoteBusinessInterfaceIndex | public int getRequiredRemoteBusinessInterfaceIndex(String interfaceName) throws IllegalStateException {
int interfaceIndex = getRemoteBusinessInterfaceIndex(interfaceName);
if (interfaceIndex == -1) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "getRequiredRemoteBusinessInterfaceIndex : IllegalStateException : " +
"Requested business interface not found : " +
interfaceName);
throw new IllegalStateException("Requested business interface not found : " + interfaceName);
}
return interfaceIndex;
} | java | public int getRequiredRemoteBusinessInterfaceIndex(String interfaceName) throws IllegalStateException {
int interfaceIndex = getRemoteBusinessInterfaceIndex(interfaceName);
if (interfaceIndex == -1) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "getRequiredRemoteBusinessInterfaceIndex : IllegalStateException : " +
"Requested business interface not found : " +
interfaceName);
throw new IllegalStateException("Requested business interface not found : " + interfaceName);
}
return interfaceIndex;
} | [
"public",
"int",
"getRequiredRemoteBusinessInterfaceIndex",
"(",
"String",
"interfaceName",
")",
"throws",
"IllegalStateException",
"{",
"int",
"interfaceIndex",
"=",
"getRemoteBusinessInterfaceIndex",
"(",
"interfaceName",
")",
";",
"if",
"(",
"interfaceIndex",
"==",
"-",
"1",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"getRequiredRemoteBusinessInterfaceIndex : IllegalStateException : \"",
"+",
"\"Requested business interface not found : \"",
"+",
"interfaceName",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"\"Requested business interface not found : \"",
"+",
"interfaceName",
")",
";",
"}",
"return",
"interfaceIndex",
";",
"}"
] | Gets the index of the remote busines interface. This method will throw an
IllegalStateException if a remte interface could not be matched. If it is
known that a match must occur on a remote business interface, then this
method should be used.
@param interfaceName the interface to find a match on
@return the index of the business interface found
@throws IllegalStateException if the requested business interface cannot be found. | [
"Gets",
"the",
"index",
"of",
"the",
"remote",
"busines",
"interface",
".",
"This",
"method",
"will",
"throw",
"an",
"IllegalStateException",
"if",
"a",
"remte",
"interface",
"could",
"not",
"be",
"matched",
".",
"If",
"it",
"is",
"known",
"that",
"a",
"match",
"must",
"occur",
"on",
"a",
"remote",
"business",
"interface",
"then",
"this",
"method",
"should",
"be",
"used",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/BeanMetaData.java#L1455-L1468 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/BeanMetaData.java | BeanMetaData.getMethodLevelCustomFinderMethodSignatures | public String[][] getMethodLevelCustomFinderMethodSignatures(String cfprocessstring) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(tc, "getMethodLevelCustomFinderMethodSignatures:" + cfprocessstring);
StringTokenizer st = new StringTokenizer(cfprocessstring, ":");
// array form [item#][CFMethodName]=methodname, e.g. findByCustomerName
// array form [item#][CFMethodParms]]=parameter list, e.g. int,java.lang.String
String cfMethodSignatureArray[][] = new String[st.countTokens()][2];
int methodCounter = 0;
while (st.hasMoreTokens()) {
String methodSignature = st.nextToken();
StringTokenizer methodSignaturest = new StringTokenizer(methodSignature, "()");
// format exepected, first attribute method name (can't be nul)
// second are the signatures parms, in order
try {
cfMethodSignatureArray[methodCounter][CF_METHOD_NAME_OFFSET] = methodSignaturest.nextToken();
if (methodSignature.equals("()")) {
cfMethodSignatureArray[methodCounter][CF_METHOD_SIG_OFFSET] = null; // no signature given, but followed expected format
} else {
cfMethodSignatureArray[methodCounter][CF_METHOD_SIG_OFFSET] = methodSignaturest.nextToken();
}
} catch (java.util.NoSuchElementException ex) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()
&& methodSignature != null)
Tr.debug(tc, "Processing offset [" + methodCounter + "] " + methodSignature + " failed, incorrect format");
// badSignatureGiven=true;
}
methodCounter++;
} // while
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "getMethodLevelCustomFinderMethodSignatures: " + cfMethodSignatureArray);
return cfMethodSignatureArray;
} | java | public String[][] getMethodLevelCustomFinderMethodSignatures(String cfprocessstring) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(tc, "getMethodLevelCustomFinderMethodSignatures:" + cfprocessstring);
StringTokenizer st = new StringTokenizer(cfprocessstring, ":");
// array form [item#][CFMethodName]=methodname, e.g. findByCustomerName
// array form [item#][CFMethodParms]]=parameter list, e.g. int,java.lang.String
String cfMethodSignatureArray[][] = new String[st.countTokens()][2];
int methodCounter = 0;
while (st.hasMoreTokens()) {
String methodSignature = st.nextToken();
StringTokenizer methodSignaturest = new StringTokenizer(methodSignature, "()");
// format exepected, first attribute method name (can't be nul)
// second are the signatures parms, in order
try {
cfMethodSignatureArray[methodCounter][CF_METHOD_NAME_OFFSET] = methodSignaturest.nextToken();
if (methodSignature.equals("()")) {
cfMethodSignatureArray[methodCounter][CF_METHOD_SIG_OFFSET] = null; // no signature given, but followed expected format
} else {
cfMethodSignatureArray[methodCounter][CF_METHOD_SIG_OFFSET] = methodSignaturest.nextToken();
}
} catch (java.util.NoSuchElementException ex) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()
&& methodSignature != null)
Tr.debug(tc, "Processing offset [" + methodCounter + "] " + methodSignature + " failed, incorrect format");
// badSignatureGiven=true;
}
methodCounter++;
} // while
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "getMethodLevelCustomFinderMethodSignatures: " + cfMethodSignatureArray);
return cfMethodSignatureArray;
} | [
"public",
"String",
"[",
"]",
"[",
"]",
"getMethodLevelCustomFinderMethodSignatures",
"(",
"String",
"cfprocessstring",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
"(",
"tc",
",",
"\"getMethodLevelCustomFinderMethodSignatures:\"",
"+",
"cfprocessstring",
")",
";",
"StringTokenizer",
"st",
"=",
"new",
"StringTokenizer",
"(",
"cfprocessstring",
",",
"\":\"",
")",
";",
"// array form [item#][CFMethodName]=methodname, e.g. findByCustomerName",
"// array form [item#][CFMethodParms]]=parameter list, e.g. int,java.lang.String",
"String",
"cfMethodSignatureArray",
"[",
"]",
"[",
"]",
"=",
"new",
"String",
"[",
"st",
".",
"countTokens",
"(",
")",
"]",
"[",
"2",
"]",
";",
"int",
"methodCounter",
"=",
"0",
";",
"while",
"(",
"st",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"methodSignature",
"=",
"st",
".",
"nextToken",
"(",
")",
";",
"StringTokenizer",
"methodSignaturest",
"=",
"new",
"StringTokenizer",
"(",
"methodSignature",
",",
"\"()\"",
")",
";",
"// format exepected, first attribute method name (can't be nul)",
"// second are the signatures parms, in order",
"try",
"{",
"cfMethodSignatureArray",
"[",
"methodCounter",
"]",
"[",
"CF_METHOD_NAME_OFFSET",
"]",
"=",
"methodSignaturest",
".",
"nextToken",
"(",
")",
";",
"if",
"(",
"methodSignature",
".",
"equals",
"(",
"\"()\"",
")",
")",
"{",
"cfMethodSignatureArray",
"[",
"methodCounter",
"]",
"[",
"CF_METHOD_SIG_OFFSET",
"]",
"=",
"null",
";",
"// no signature given, but followed expected format",
"}",
"else",
"{",
"cfMethodSignatureArray",
"[",
"methodCounter",
"]",
"[",
"CF_METHOD_SIG_OFFSET",
"]",
"=",
"methodSignaturest",
".",
"nextToken",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"java",
".",
"util",
".",
"NoSuchElementException",
"ex",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
"&&",
"methodSignature",
"!=",
"null",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Processing offset [\"",
"+",
"methodCounter",
"+",
"\"] \"",
"+",
"methodSignature",
"+",
"\" failed, incorrect format\"",
")",
";",
"// badSignatureGiven=true;",
"}",
"methodCounter",
"++",
";",
"}",
"// while",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"getMethodLevelCustomFinderMethodSignatures: \"",
"+",
"cfMethodSignatureArray",
")",
";",
"return",
"cfMethodSignatureArray",
";",
"}"
] | d112604.1 | [
"d112604",
".",
"1"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/BeanMetaData.java#L2528-L2570 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsMessageImpl.java | JsMessageImpl.transcribeToJmf | public JsMessage transcribeToJmf() throws MessageCopyFailedException
, IncorrectMessageTypeException
, UnsupportedEncodingException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "transcribeToJmf");
JsMsgObject newJmo = null;
// Try/catch block in case we get an MFPUnsupportedEncodingRuntimeException because the
// payload is in an unsupported codepage. d252277.2
try {
if (this instanceof JsJmsMessageImpl) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Transcribing from JsJmsMessageImpl");
newJmo = jmo.transcribeToJmf();
}
else {
// Non-JMS messages are not supported - they should have been converted into JMS by now
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Non-JMS Messages are not yet supported");
String exString = nls.getFormattedMessage("UNEXPECTED_MESSAGE_TYPE_CWSIF0102"
,new Object[] {getJsMessageType(), MessageType.JMS}
,"The Message can not be represented as a pure JMF Message");
throw new IncorrectMessageTypeException(exString);
}
}
catch (MFPUnsupportedEncodingRuntimeException e) {
FFDCFilter.processException(e, "com.ibm.ws.sib.mfp.impl.JsMessageImpl.transcribeToJmf", "721");
// Throw the original UnsupportedEncodingException
throw (UnsupportedEncodingException)e.getCause();
}
JsMessage newMsg;
// if we have a new jmo, create a new message from it
if (newJmo != this.jmo) {
newMsg = createNewGeneralized(newJmo);
}
// otherwise, just return ourself
else {
newMsg = this;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "transcribeToJmf", newMsg);
return newMsg;
} | java | public JsMessage transcribeToJmf() throws MessageCopyFailedException
, IncorrectMessageTypeException
, UnsupportedEncodingException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "transcribeToJmf");
JsMsgObject newJmo = null;
// Try/catch block in case we get an MFPUnsupportedEncodingRuntimeException because the
// payload is in an unsupported codepage. d252277.2
try {
if (this instanceof JsJmsMessageImpl) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Transcribing from JsJmsMessageImpl");
newJmo = jmo.transcribeToJmf();
}
else {
// Non-JMS messages are not supported - they should have been converted into JMS by now
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Non-JMS Messages are not yet supported");
String exString = nls.getFormattedMessage("UNEXPECTED_MESSAGE_TYPE_CWSIF0102"
,new Object[] {getJsMessageType(), MessageType.JMS}
,"The Message can not be represented as a pure JMF Message");
throw new IncorrectMessageTypeException(exString);
}
}
catch (MFPUnsupportedEncodingRuntimeException e) {
FFDCFilter.processException(e, "com.ibm.ws.sib.mfp.impl.JsMessageImpl.transcribeToJmf", "721");
// Throw the original UnsupportedEncodingException
throw (UnsupportedEncodingException)e.getCause();
}
JsMessage newMsg;
// if we have a new jmo, create a new message from it
if (newJmo != this.jmo) {
newMsg = createNewGeneralized(newJmo);
}
// otherwise, just return ourself
else {
newMsg = this;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "transcribeToJmf", newMsg);
return newMsg;
} | [
"public",
"JsMessage",
"transcribeToJmf",
"(",
")",
"throws",
"MessageCopyFailedException",
",",
"IncorrectMessageTypeException",
",",
"UnsupportedEncodingException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"transcribeToJmf\"",
")",
";",
"JsMsgObject",
"newJmo",
"=",
"null",
";",
"// Try/catch block in case we get an MFPUnsupportedEncodingRuntimeException because the",
"// payload is in an unsupported codepage. d252277.2",
"try",
"{",
"if",
"(",
"this",
"instanceof",
"JsJmsMessageImpl",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"SibTr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"Transcribing from JsJmsMessageImpl\"",
")",
";",
"newJmo",
"=",
"jmo",
".",
"transcribeToJmf",
"(",
")",
";",
"}",
"else",
"{",
"// Non-JMS messages are not supported - they should have been converted into JMS by now",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"SibTr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"Non-JMS Messages are not yet supported\"",
")",
";",
"String",
"exString",
"=",
"nls",
".",
"getFormattedMessage",
"(",
"\"UNEXPECTED_MESSAGE_TYPE_CWSIF0102\"",
",",
"new",
"Object",
"[",
"]",
"{",
"getJsMessageType",
"(",
")",
",",
"MessageType",
".",
"JMS",
"}",
",",
"\"The Message can not be represented as a pure JMF Message\"",
")",
";",
"throw",
"new",
"IncorrectMessageTypeException",
"(",
"exString",
")",
";",
"}",
"}",
"catch",
"(",
"MFPUnsupportedEncodingRuntimeException",
"e",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"e",
",",
"\"com.ibm.ws.sib.mfp.impl.JsMessageImpl.transcribeToJmf\"",
",",
"\"721\"",
")",
";",
"// Throw the original UnsupportedEncodingException",
"throw",
"(",
"UnsupportedEncodingException",
")",
"e",
".",
"getCause",
"(",
")",
";",
"}",
"JsMessage",
"newMsg",
";",
"// if we have a new jmo, create a new message from it",
"if",
"(",
"newJmo",
"!=",
"this",
".",
"jmo",
")",
"{",
"newMsg",
"=",
"createNewGeneralized",
"(",
"newJmo",
")",
";",
"}",
"// otherwise, just return ourself",
"else",
"{",
"newMsg",
"=",
"this",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"transcribeToJmf\"",
",",
"newMsg",
")",
";",
"return",
"newMsg",
";",
"}"
] | Transcribe this message to pure JMF
Javadoc description supplied by JsMessage interface. | [
"Transcribe",
"this",
"message",
"to",
"pure",
"JMF"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsMessageImpl.java#L457-L500 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsMessageImpl.java | JsMessageImpl.getApproximateLength | public int getApproximateLength() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getApproximateLength");
if (approxLength == -1) approxLength = guessApproxLength();
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getApproximateLength", Integer.valueOf(approxLength));
return approxLength;
} | java | public int getApproximateLength() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getApproximateLength");
if (approxLength == -1) approxLength = guessApproxLength();
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getApproximateLength", Integer.valueOf(approxLength));
return approxLength;
} | [
"public",
"int",
"getApproximateLength",
"(",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"getApproximateLength\"",
")",
";",
"if",
"(",
"approxLength",
"==",
"-",
"1",
")",
"approxLength",
"=",
"guessApproxLength",
"(",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"getApproximateLength\"",
",",
"Integer",
".",
"valueOf",
"(",
"approxLength",
")",
")",
";",
"return",
"approxLength",
";",
"}"
] | Return an approximate size for the flattened message. It is important that
this method is quick and cheap, rather than highly accurate.
Javadoc description supplied by JsMessage interface. | [
"Return",
"an",
"approximate",
"size",
"for",
"the",
"flattened",
"message",
".",
"It",
"is",
"important",
"that",
"this",
"method",
"is",
"quick",
"and",
"cheap",
"rather",
"than",
"highly",
"accurate",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsMessageImpl.java#L583-L590 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsMessageImpl.java | JsMessageImpl.createNew | private final JsMessageImpl createNew() throws MessageCopyFailedException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "createNew");
JsMessageImpl newMsg = null;
Class msgClass = this.getClass();
try {
/* Create the new JsMessage*/
newMsg = (JsMessageImpl)msgClass.newInstance();
/* copy transients before copying JMO to ensure safe ordering - see SIB0121.mfp.2 */
copyTransients(newMsg);
/* Get a new copy of the JMO and set it into the new message*/
JsMsgObject newJmo = jmo.getCopy();
newMsg.setJmo(newJmo);
}
catch (IllegalAccessException e1) {
FFDCFilter.processException(e1, "com.ibm.ws.sib.mfp.impl.JsMessageImpl.createNew", "jsm1600");
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "IllegalAccessException " + e1.getMessage() + " instantiating class " + msgClass.getName());
throw new MessageCopyFailedException(e1);
}
catch (InstantiationException e2) {
FFDCFilter.processException(e2, "com.ibm.ws.sib.mfp.impl.JsMessageImpl.createNew", "jsm1610");
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "InstantiationException " + e2.getMessage() + " instantiating class " + msgClass.getName());
throw new MessageCopyFailedException(e2);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "createNew", newMsg);
return newMsg;
} | java | private final JsMessageImpl createNew() throws MessageCopyFailedException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "createNew");
JsMessageImpl newMsg = null;
Class msgClass = this.getClass();
try {
/* Create the new JsMessage*/
newMsg = (JsMessageImpl)msgClass.newInstance();
/* copy transients before copying JMO to ensure safe ordering - see SIB0121.mfp.2 */
copyTransients(newMsg);
/* Get a new copy of the JMO and set it into the new message*/
JsMsgObject newJmo = jmo.getCopy();
newMsg.setJmo(newJmo);
}
catch (IllegalAccessException e1) {
FFDCFilter.processException(e1, "com.ibm.ws.sib.mfp.impl.JsMessageImpl.createNew", "jsm1600");
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "IllegalAccessException " + e1.getMessage() + " instantiating class " + msgClass.getName());
throw new MessageCopyFailedException(e1);
}
catch (InstantiationException e2) {
FFDCFilter.processException(e2, "com.ibm.ws.sib.mfp.impl.JsMessageImpl.createNew", "jsm1610");
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "InstantiationException " + e2.getMessage() + " instantiating class " + msgClass.getName());
throw new MessageCopyFailedException(e2);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "createNew", newMsg);
return newMsg;
} | [
"private",
"final",
"JsMessageImpl",
"createNew",
"(",
")",
"throws",
"MessageCopyFailedException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"createNew\"",
")",
";",
"JsMessageImpl",
"newMsg",
"=",
"null",
";",
"Class",
"msgClass",
"=",
"this",
".",
"getClass",
"(",
")",
";",
"try",
"{",
"/* Create the new JsMessage*/",
"newMsg",
"=",
"(",
"JsMessageImpl",
")",
"msgClass",
".",
"newInstance",
"(",
")",
";",
"/* copy transients before copying JMO to ensure safe ordering - see SIB0121.mfp.2 */",
"copyTransients",
"(",
"newMsg",
")",
";",
"/* Get a new copy of the JMO and set it into the new message*/",
"JsMsgObject",
"newJmo",
"=",
"jmo",
".",
"getCopy",
"(",
")",
";",
"newMsg",
".",
"setJmo",
"(",
"newJmo",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e1",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"e1",
",",
"\"com.ibm.ws.sib.mfp.impl.JsMessageImpl.createNew\"",
",",
"\"jsm1600\"",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"SibTr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"IllegalAccessException \"",
"+",
"e1",
".",
"getMessage",
"(",
")",
"+",
"\" instantiating class \"",
"+",
"msgClass",
".",
"getName",
"(",
")",
")",
";",
"throw",
"new",
"MessageCopyFailedException",
"(",
"e1",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"e2",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"e2",
",",
"\"com.ibm.ws.sib.mfp.impl.JsMessageImpl.createNew\"",
",",
"\"jsm1610\"",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"SibTr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"InstantiationException \"",
"+",
"e2",
".",
"getMessage",
"(",
")",
"+",
"\" instantiating class \"",
"+",
"msgClass",
".",
"getName",
"(",
")",
")",
";",
"throw",
"new",
"MessageCopyFailedException",
"(",
"e2",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"createNew\"",
",",
"newMsg",
")",
";",
"return",
"newMsg",
";",
"}"
] | Return a new Jsmessage, of the same specialization as this, containing the
given JsMsgObject.
@param newJmo The JsMsgObject the new JsMessage will contain.
@return JsMessage A new JsMessage instance of the appropriate specialization.
@exception MessageCopyFailedException A MessageCopyFailedException is thrown if
either the constructor could not be found or the instantiation failed. The
Exception contains the toString() result of the original Exception. | [
"Return",
"a",
"new",
"Jsmessage",
"of",
"the",
"same",
"specialization",
"as",
"this",
"containing",
"the",
"given",
"JsMsgObject",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsMessageImpl.java#L871-L900 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsMessageImpl.java | JsMessageImpl.createNewGeneralized | private final JsMessageImpl createNewGeneralized(JsMsgObject newJmo) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "createNewGeneralized");
JsMessageImpl newMsg = null;
/* Now create the new JsMessage */
newMsg = new JsMessageImpl(newJmo);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "createNewGeneralized", newMsg);
return newMsg;
} | java | private final JsMessageImpl createNewGeneralized(JsMsgObject newJmo) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "createNewGeneralized");
JsMessageImpl newMsg = null;
/* Now create the new JsMessage */
newMsg = new JsMessageImpl(newJmo);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "createNewGeneralized", newMsg);
return newMsg;
} | [
"private",
"final",
"JsMessageImpl",
"createNewGeneralized",
"(",
"JsMsgObject",
"newJmo",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"createNewGeneralized\"",
")",
";",
"JsMessageImpl",
"newMsg",
"=",
"null",
";",
"/* Now create the new JsMessage */",
"newMsg",
"=",
"new",
"JsMessageImpl",
"(",
"newJmo",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"createNewGeneralized\"",
",",
"newMsg",
")",
";",
"return",
"newMsg",
";",
"}"
] | Return a new JsMessage, generalizing the message to just be a JsMessageImpl.
The new message contains the given JsMsgObject.
@param newJmo The JsMsgObject the new JsMessage will contain.
@return JsMessage A new JsMessage instance at the JsMessageImpl specialization. | [
"Return",
"a",
"new",
"JsMessage",
"generalizing",
"the",
"message",
"to",
"just",
"be",
"a",
"JsMessageImpl",
".",
"The",
"new",
"message",
"contains",
"the",
"given",
"JsMsgObject",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsMessageImpl.java#L910-L919 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/servlet/RequestUtils.java | RequestUtils.parsePostData | @SuppressWarnings("rawtypes")
public static Hashtable parsePostData(ServletInputStream in, String encoding, boolean multireadPropertyEnabled) /* 157338 add throws */ throws IOException
{
int inputLen;
byte[] postedBytes = null;
String postedBody;
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
logger.logp(Level.FINE, CLASS_NAME,"parsePostData","parsing chunked post data. encoding = " + encoding);
if (in == null)
throw new IllegalArgumentException("post data inputstream is null");
try
{
//
// Make sure we read the entire POSTed body.
//
ByteArrayOutputStream byteOS = new ByteArrayOutputStream(DEFAULT_BUFFER_SIZE);
do
{
byte [] readInBytes = new byte[DEFAULT_BUFFER_SIZE];
inputLen = in.read(readInBytes, 0, DEFAULT_BUFFER_SIZE);
if (inputLen > 0){
byteOS.write(readInBytes,0,inputLen);
}
}
while (inputLen != -1);
// MultiRead Start
if (multireadPropertyEnabled) {
in.close();
}
// MultiRead End
postedBytes = byteOS.toByteArray();
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
logger.logp(Level.FINE, CLASS_NAME,"parsePostData","finished reading ["+postedBytes.length+"] bytes");
}
catch (IOException e)
{
com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(e, "com.ibm.ws.webcontainer.servlet.RequestUtils.parsePostData", "598");
// begin 157338
throw e;
//return new Hashtable();
// begin 157338
}
// XXX we shouldn't assume that the only kind of POST body
// is FORM data encoded using ASCII or ISO Latin/1 ... or
// that the body should always be treated as FORM data.
//
try
{
postedBody = new String(postedBytes, encoding);
}
catch (UnsupportedEncodingException e)
{
com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(e, "com.ibm.ws.webcontainer.servlet.RequestUtils.parsePostData", "618");
postedBody = new String(postedBytes);
}
if (WCCustomProperties.PARSE_UTF8_POST_DATA && encoding.equalsIgnoreCase("UTF-8")) {
for (byte nextByte : postedBytes) {
if (nextByte < (byte)0 ) {
encoding = "8859_1";
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
logger.logp(Level.FINE, CLASS_NAME,"parsePostData","UTF8 post data, set encoing to 8859_1 to prevent futrther encoding");
break;
}
}
}
return parseQueryString(postedBody, encoding);
} | java | @SuppressWarnings("rawtypes")
public static Hashtable parsePostData(ServletInputStream in, String encoding, boolean multireadPropertyEnabled) /* 157338 add throws */ throws IOException
{
int inputLen;
byte[] postedBytes = null;
String postedBody;
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
logger.logp(Level.FINE, CLASS_NAME,"parsePostData","parsing chunked post data. encoding = " + encoding);
if (in == null)
throw new IllegalArgumentException("post data inputstream is null");
try
{
//
// Make sure we read the entire POSTed body.
//
ByteArrayOutputStream byteOS = new ByteArrayOutputStream(DEFAULT_BUFFER_SIZE);
do
{
byte [] readInBytes = new byte[DEFAULT_BUFFER_SIZE];
inputLen = in.read(readInBytes, 0, DEFAULT_BUFFER_SIZE);
if (inputLen > 0){
byteOS.write(readInBytes,0,inputLen);
}
}
while (inputLen != -1);
// MultiRead Start
if (multireadPropertyEnabled) {
in.close();
}
// MultiRead End
postedBytes = byteOS.toByteArray();
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
logger.logp(Level.FINE, CLASS_NAME,"parsePostData","finished reading ["+postedBytes.length+"] bytes");
}
catch (IOException e)
{
com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(e, "com.ibm.ws.webcontainer.servlet.RequestUtils.parsePostData", "598");
// begin 157338
throw e;
//return new Hashtable();
// begin 157338
}
// XXX we shouldn't assume that the only kind of POST body
// is FORM data encoded using ASCII or ISO Latin/1 ... or
// that the body should always be treated as FORM data.
//
try
{
postedBody = new String(postedBytes, encoding);
}
catch (UnsupportedEncodingException e)
{
com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(e, "com.ibm.ws.webcontainer.servlet.RequestUtils.parsePostData", "618");
postedBody = new String(postedBytes);
}
if (WCCustomProperties.PARSE_UTF8_POST_DATA && encoding.equalsIgnoreCase("UTF-8")) {
for (byte nextByte : postedBytes) {
if (nextByte < (byte)0 ) {
encoding = "8859_1";
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
logger.logp(Level.FINE, CLASS_NAME,"parsePostData","UTF8 post data, set encoing to 8859_1 to prevent futrther encoding");
break;
}
}
}
return parseQueryString(postedBody, encoding);
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"Hashtable",
"parsePostData",
"(",
"ServletInputStream",
"in",
",",
"String",
"encoding",
",",
"boolean",
"multireadPropertyEnabled",
")",
"/* 157338 add throws */",
"throws",
"IOException",
"{",
"int",
"inputLen",
";",
"byte",
"[",
"]",
"postedBytes",
"=",
"null",
";",
"String",
"postedBody",
";",
"if",
"(",
"com",
".",
"ibm",
".",
"ejs",
".",
"ras",
".",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINE",
",",
"CLASS_NAME",
",",
"\"parsePostData\"",
",",
"\"parsing chunked post data. encoding = \"",
"+",
"encoding",
")",
";",
"if",
"(",
"in",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"post data inputstream is null\"",
")",
";",
"try",
"{",
"//",
"// Make sure we read the entire POSTed body.",
"//",
"ByteArrayOutputStream",
"byteOS",
"=",
"new",
"ByteArrayOutputStream",
"(",
"DEFAULT_BUFFER_SIZE",
")",
";",
"do",
"{",
"byte",
"[",
"]",
"readInBytes",
"=",
"new",
"byte",
"[",
"DEFAULT_BUFFER_SIZE",
"]",
";",
"inputLen",
"=",
"in",
".",
"read",
"(",
"readInBytes",
",",
"0",
",",
"DEFAULT_BUFFER_SIZE",
")",
";",
"if",
"(",
"inputLen",
">",
"0",
")",
"{",
"byteOS",
".",
"write",
"(",
"readInBytes",
",",
"0",
",",
"inputLen",
")",
";",
"}",
"}",
"while",
"(",
"inputLen",
"!=",
"-",
"1",
")",
";",
"// MultiRead Start",
"if",
"(",
"multireadPropertyEnabled",
")",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"// MultiRead End",
"postedBytes",
"=",
"byteOS",
".",
"toByteArray",
"(",
")",
";",
"if",
"(",
"com",
".",
"ibm",
".",
"ejs",
".",
"ras",
".",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINE",
",",
"CLASS_NAME",
",",
"\"parsePostData\"",
",",
"\"finished reading [\"",
"+",
"postedBytes",
".",
"length",
"+",
"\"] bytes\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"com",
".",
"ibm",
".",
"wsspi",
".",
"webcontainer",
".",
"util",
".",
"FFDCWrapper",
".",
"processException",
"(",
"e",
",",
"\"com.ibm.ws.webcontainer.servlet.RequestUtils.parsePostData\"",
",",
"\"598\"",
")",
";",
"// begin 157338",
"throw",
"e",
";",
"//return new Hashtable();",
"// begin 157338",
"}",
"// XXX we shouldn't assume that the only kind of POST body",
"// is FORM data encoded using ASCII or ISO Latin/1 ... or",
"// that the body should always be treated as FORM data.",
"//",
"try",
"{",
"postedBody",
"=",
"new",
"String",
"(",
"postedBytes",
",",
"encoding",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"com",
".",
"ibm",
".",
"wsspi",
".",
"webcontainer",
".",
"util",
".",
"FFDCWrapper",
".",
"processException",
"(",
"e",
",",
"\"com.ibm.ws.webcontainer.servlet.RequestUtils.parsePostData\"",
",",
"\"618\"",
")",
";",
"postedBody",
"=",
"new",
"String",
"(",
"postedBytes",
")",
";",
"}",
"if",
"(",
"WCCustomProperties",
".",
"PARSE_UTF8_POST_DATA",
"&&",
"encoding",
".",
"equalsIgnoreCase",
"(",
"\"UTF-8\"",
")",
")",
"{",
"for",
"(",
"byte",
"nextByte",
":",
"postedBytes",
")",
"{",
"if",
"(",
"nextByte",
"<",
"(",
"byte",
")",
"0",
")",
"{",
"encoding",
"=",
"\"8859_1\"",
";",
"if",
"(",
"com",
".",
"ibm",
".",
"ejs",
".",
"ras",
".",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINE",
",",
"CLASS_NAME",
",",
"\"parsePostData\"",
",",
"\"UTF8 post data, set encoing to 8859_1 to prevent futrther encoding\"",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"parseQueryString",
"(",
"postedBody",
",",
"encoding",
")",
";",
"}"
] | begin 231634 Support posts with query parms in chunked body WAS.webcontainer | [
"begin",
"231634",
"Support",
"posts",
"with",
"query",
"parms",
"in",
"chunked",
"body",
"WAS",
".",
"webcontainer"
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/servlet/RequestUtils.java#L349-L423 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/ItemStream.java | ItemStream.findOldestItem | public final Item findOldestItem() throws MessageStoreException
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "findOldestItem");
ItemCollection ic = ((ItemCollection) _getMembership());
if (null == ic)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "findOldestItem");
throw new NotInMessageStore();
}
Item item = null;
if (ic != null)
{
item = (Item) ic.findOldestItem();
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "findOldestItem", item);
return item;
} | java | public final Item findOldestItem() throws MessageStoreException
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "findOldestItem");
ItemCollection ic = ((ItemCollection) _getMembership());
if (null == ic)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "findOldestItem");
throw new NotInMessageStore();
}
Item item = null;
if (ic != null)
{
item = (Item) ic.findOldestItem();
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "findOldestItem", item);
return item;
} | [
"public",
"final",
"Item",
"findOldestItem",
"(",
")",
"throws",
"MessageStoreException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"findOldestItem\"",
")",
";",
"ItemCollection",
"ic",
"=",
"(",
"(",
"ItemCollection",
")",
"_getMembership",
"(",
")",
")",
";",
"if",
"(",
"null",
"==",
"ic",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"findOldestItem\"",
")",
";",
"throw",
"new",
"NotInMessageStore",
"(",
")",
";",
"}",
"Item",
"item",
"=",
"null",
";",
"if",
"(",
"ic",
"!=",
"null",
")",
"{",
"item",
"=",
"(",
"Item",
")",
"ic",
".",
"findOldestItem",
"(",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"findOldestItem\"",
",",
"item",
")",
";",
"return",
"item",
";",
"}"
] | Find the item that has been known to the stream for longest. The item returned
may be in any of the states defined in the state model. The caller should not
assume that the item can be used for any particular purpose.
@return Item may be null.
@throws {@link MessageStoreException} if the item was spilled and could not
be unspilled. Or if item not found in backing store. | [
"Find",
"the",
"item",
"that",
"has",
"been",
"known",
"to",
"the",
"stream",
"for",
"longest",
".",
"The",
"item",
"returned",
"may",
"be",
"in",
"any",
"of",
"the",
"states",
"defined",
"in",
"the",
"state",
"model",
".",
"The",
"caller",
"should",
"not",
"assume",
"that",
"the",
"item",
"can",
"be",
"used",
"for",
"any",
"particular",
"purpose",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/ItemStream.java#L442-L463 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.channelfw/src/com/ibm/ws/tcpchannel/internal/TCPBaseRequestContext.java | TCPBaseRequestContext.abort | protected void abort() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Aborting connection");
}
this.aborted = true;
} | java | protected void abort() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Aborting connection");
}
this.aborted = true;
} | [
"protected",
"void",
"abort",
"(",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"Aborting connection\"",
")",
";",
"}",
"this",
".",
"aborted",
"=",
"true",
";",
"}"
] | Abort this context to trigger immediate exceptions on future IO requests. | [
"Abort",
"this",
"context",
"to",
"trigger",
"immediate",
"exceptions",
"on",
"future",
"IO",
"requests",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/ws/tcpchannel/internal/TCPBaseRequestContext.java#L92-L97 | train |
OpenLiberty/open-liberty | dev/com.ibm.ws.channelfw/src/com/ibm/ws/tcpchannel/internal/TCPBaseRequestContext.java | TCPBaseRequestContext.setTimeoutTime | protected void setTimeoutTime(int time) {
int timeout = time;
if (timeout == TCPRequestContext.NO_TIMEOUT) {
this.timeoutTime = TCPRequestContext.NO_TIMEOUT;
this.timeoutInterval = 0;
} else {
if (timeout == TCPRequestContext.USE_CHANNEL_TIMEOUT) {
timeout = getConfig().getInactivityTimeout();
}
if (timeout != ValidateUtils.INACTIVITY_TIMEOUT_NO_TIMEOUT) {
this.timeoutTime = System.currentTimeMillis() + timeout;
this.timeoutInterval = timeout;
} else {
this.timeoutTime = TCPRequestContext.NO_TIMEOUT;
this.timeoutInterval = 0;
}
}
} | java | protected void setTimeoutTime(int time) {
int timeout = time;
if (timeout == TCPRequestContext.NO_TIMEOUT) {
this.timeoutTime = TCPRequestContext.NO_TIMEOUT;
this.timeoutInterval = 0;
} else {
if (timeout == TCPRequestContext.USE_CHANNEL_TIMEOUT) {
timeout = getConfig().getInactivityTimeout();
}
if (timeout != ValidateUtils.INACTIVITY_TIMEOUT_NO_TIMEOUT) {
this.timeoutTime = System.currentTimeMillis() + timeout;
this.timeoutInterval = timeout;
} else {
this.timeoutTime = TCPRequestContext.NO_TIMEOUT;
this.timeoutInterval = 0;
}
}
} | [
"protected",
"void",
"setTimeoutTime",
"(",
"int",
"time",
")",
"{",
"int",
"timeout",
"=",
"time",
";",
"if",
"(",
"timeout",
"==",
"TCPRequestContext",
".",
"NO_TIMEOUT",
")",
"{",
"this",
".",
"timeoutTime",
"=",
"TCPRequestContext",
".",
"NO_TIMEOUT",
";",
"this",
".",
"timeoutInterval",
"=",
"0",
";",
"}",
"else",
"{",
"if",
"(",
"timeout",
"==",
"TCPRequestContext",
".",
"USE_CHANNEL_TIMEOUT",
")",
"{",
"timeout",
"=",
"getConfig",
"(",
")",
".",
"getInactivityTimeout",
"(",
")",
";",
"}",
"if",
"(",
"timeout",
"!=",
"ValidateUtils",
".",
"INACTIVITY_TIMEOUT_NO_TIMEOUT",
")",
"{",
"this",
".",
"timeoutTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"timeout",
";",
"this",
".",
"timeoutInterval",
"=",
"timeout",
";",
"}",
"else",
"{",
"this",
".",
"timeoutTime",
"=",
"TCPRequestContext",
".",
"NO_TIMEOUT",
";",
"this",
".",
"timeoutInterval",
"=",
"0",
";",
"}",
"}",
"}"
] | Sets the timeout value returned by 'getTimeoutTime'.
@param time | [
"Sets",
"the",
"timeout",
"value",
"returned",
"by",
"getTimeoutTime",
"."
] | ca725d9903e63645018f9fa8cbda25f60af83a5d | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/ws/tcpchannel/internal/TCPBaseRequestContext.java#L405-L422 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.