id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
124,600 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/UniformSnapshot.java | UniformSnapshot.getMean | @Override
public double getMean() {
if (values.length == 0) {
return 0;
}
double sum = 0;
for (long value : values) {
sum += value;
}
return sum / values.length;
} | java | @Override
public double getMean() {
if (values.length == 0) {
return 0;
}
double sum = 0;
for (long value : values) {
sum += value;
}
return sum / values.length;
} | [
"@",
"Override",
"public",
"double",
"getMean",
"(",
")",
"{",
"if",
"(",
"values",
".",
"length",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"double",
"sum",
"=",
"0",
";",
"for",
"(",
"long",
"value",
":",
"values",
")",
"{",
"sum",
"+=",
... | Returns the arithmetic mean of the values in the snapshot.
@return the arithmetic mean | [
"Returns",
"the",
"arithmetic",
"mean",
"of",
"the",
"values",
"in",
"the",
"snapshot",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/UniformSnapshot.java#L158-L169 |
124,601 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/UniformSnapshot.java | UniformSnapshot.getStdDev | @Override
public double getStdDev() {
// two-pass algorithm for variance, avoids numeric overflow
if (values.length <= 1) {
return 0;
}
final double mean = getMean();
double sum = 0;
for (long value : values) {
final double diff = value - me... | java | @Override
public double getStdDev() {
// two-pass algorithm for variance, avoids numeric overflow
if (values.length <= 1) {
return 0;
}
final double mean = getMean();
double sum = 0;
for (long value : values) {
final double diff = value - me... | [
"@",
"Override",
"public",
"double",
"getStdDev",
"(",
")",
"{",
"// two-pass algorithm for variance, avoids numeric overflow",
"if",
"(",
"values",
".",
"length",
"<=",
"1",
")",
"{",
"return",
"0",
";",
"}",
"final",
"double",
"mean",
"=",
"getMean",
"(",
")... | Returns the standard deviation of the values in the snapshot.
@return the standard deviation value | [
"Returns",
"the",
"standard",
"deviation",
"of",
"the",
"values",
"in",
"the",
"snapshot",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/UniformSnapshot.java#L176-L194 |
124,602 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/UniformSnapshot.java | UniformSnapshot.dump | @Override
public void dump(OutputStream output) {
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(output, UTF_8))) {
for (long value : values) {
out.printf("%d%n", value);
}
}
} | java | @Override
public void dump(OutputStream output) {
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(output, UTF_8))) {
for (long value : values) {
out.printf("%d%n", value);
}
}
} | [
"@",
"Override",
"public",
"void",
"dump",
"(",
"OutputStream",
"output",
")",
"{",
"try",
"(",
"PrintWriter",
"out",
"=",
"new",
"PrintWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"output",
",",
"UTF_8",
")",
")",
")",
"{",
"for",
"(",
"long",
"value... | Writes the values of the snapshot to the given stream.
@param output an output stream | [
"Writes",
"the",
"values",
"of",
"the",
"snapshot",
"to",
"the",
"given",
"stream",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/UniformSnapshot.java#L201-L208 |
124,603 | networknt/light-4j | service/src/main/java/com/networknt/service/ServiceUtil.java | ServiceUtil.constructByNamedParams | public static Object constructByNamedParams(Class clazz, Map params) throws Exception {
Object obj = clazz.getConstructor().newInstance();
Method[] allMethods = clazz.getMethods();
for(Method method : allMethods) {
if(method.getName().startsWith("set")) {
Object [] o... | java | public static Object constructByNamedParams(Class clazz, Map params) throws Exception {
Object obj = clazz.getConstructor().newInstance();
Method[] allMethods = clazz.getMethods();
for(Method method : allMethods) {
if(method.getName().startsWith("set")) {
Object [] o... | [
"public",
"static",
"Object",
"constructByNamedParams",
"(",
"Class",
"clazz",
",",
"Map",
"params",
")",
"throws",
"Exception",
"{",
"Object",
"obj",
"=",
"clazz",
".",
"getConstructor",
"(",
")",
".",
"newInstance",
"(",
")",
";",
"Method",
"[",
"]",
"al... | Build an object out of a given class and a map for field names to values.
@param clazz The class to be created.
@param params A map of the parameters.
@return An instantiated object.
@throws Exception when constructor fails. | [
"Build",
"an",
"object",
"out",
"of",
"a",
"given",
"class",
"and",
"a",
"map",
"for",
"field",
"names",
"to",
"values",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/service/src/main/java/com/networknt/service/ServiceUtil.java#L66-L81 |
124,604 | networknt/light-4j | service/src/main/java/com/networknt/service/ServiceUtil.java | ServiceUtil.constructByParameterizedConstructor | public static Object constructByParameterizedConstructor(Class clazz, List parameters) throws Exception {
// find out how many constructors this class has and match the one with the same sequence of
// parameters.
Object instance = null;
Constructor[] allConstructors = clazz.getDeclared... | java | public static Object constructByParameterizedConstructor(Class clazz, List parameters) throws Exception {
// find out how many constructors this class has and match the one with the same sequence of
// parameters.
Object instance = null;
Constructor[] allConstructors = clazz.getDeclared... | [
"public",
"static",
"Object",
"constructByParameterizedConstructor",
"(",
"Class",
"clazz",
",",
"List",
"parameters",
")",
"throws",
"Exception",
"{",
"// find out how many constructors this class has and match the one with the same sequence of",
"// parameters.",
"Object",
"insta... | Build an object out of a given class and a list of single element maps of object type to value.
A constructor is searched for that matches the given set. If not found, the default is attempted.
@param clazz The class to be created.
@param parameters A list of single element maps of object type to value.
@return An ins... | [
"Build",
"an",
"object",
"out",
"of",
"a",
"given",
"class",
"and",
"a",
"list",
"of",
"single",
"element",
"maps",
"of",
"object",
"type",
"to",
"value",
".",
"A",
"constructor",
"is",
"searched",
"for",
"that",
"matches",
"the",
"given",
"set",
".",
... | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/service/src/main/java/com/networknt/service/ServiceUtil.java#L92-L143 |
124,605 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/MetricRegistry.java | MetricRegistry.name | public static MetricName name(String name, String... names) {
final int length;
if (names == null) {
length = 0;
} else {
length = names.length;
}
final String[] parts = new String[length + 1];
parts[0] = name;
System.arraycopy(names, 0,... | java | public static MetricName name(String name, String... names) {
final int length;
if (names == null) {
length = 0;
} else {
length = names.length;
}
final String[] parts = new String[length + 1];
parts[0] = name;
System.arraycopy(names, 0,... | [
"public",
"static",
"MetricName",
"name",
"(",
"String",
"name",
",",
"String",
"...",
"names",
")",
"{",
"final",
"int",
"length",
";",
"if",
"(",
"names",
"==",
"null",
")",
"{",
"length",
"=",
"0",
";",
"}",
"else",
"{",
"length",
"=",
"names",
... | Shorthand method for backwards compatibility in creating metric names.
Uses {@link MetricName#build(String...)} for its
heavy lifting.
@see MetricName#build(String...)
@param name The first element of the name
@param names The remaining elements of the name
@return A metric name matching the specified components. | [
"Shorthand",
"method",
"for",
"backwards",
"compatibility",
"in",
"creating",
"metric",
"names",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/MetricRegistry.java#L62-L77 |
124,606 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/MetricRegistry.java | MetricRegistry.removeAll | public void removeAll() {
for(Iterator<Map.Entry<MetricName, Metric>> it = metrics.entrySet().iterator(); it.hasNext();) {
Map.Entry<MetricName, Metric> entry = it.next();
Metric metric = entry.getValue();
if(metric != null) {
onMetricRemoved(entry.getKey(), m... | java | public void removeAll() {
for(Iterator<Map.Entry<MetricName, Metric>> it = metrics.entrySet().iterator(); it.hasNext();) {
Map.Entry<MetricName, Metric> entry = it.next();
Metric metric = entry.getValue();
if(metric != null) {
onMetricRemoved(entry.getKey(), m... | [
"public",
"void",
"removeAll",
"(",
")",
"{",
"for",
"(",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"MetricName",
",",
"Metric",
">",
">",
"it",
"=",
"metrics",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
... | Removes all the metrics in registry. | [
"Removes",
"all",
"the",
"metrics",
"in",
"registry",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/MetricRegistry.java#L245-L254 |
124,607 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/ScheduledReporter.java | ScheduledReporter.stop | public void stop() {
executor.shutdown(); // Disable new tasks from being submitted
try {
// Wait a while for existing tasks to terminate
if (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
executor.shutdownNow(); // Cancel currently executing tasks
... | java | public void stop() {
executor.shutdown(); // Disable new tasks from being submitted
try {
// Wait a while for existing tasks to terminate
if (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
executor.shutdownNow(); // Cancel currently executing tasks
... | [
"public",
"void",
"stop",
"(",
")",
"{",
"executor",
".",
"shutdown",
"(",
")",
";",
"// Disable new tasks from being submitted",
"try",
"{",
"// Wait a while for existing tasks to terminate",
"if",
"(",
"!",
"executor",
".",
"awaitTermination",
"(",
"1",
",",
"Time... | Stops the reporter and shuts down its thread of execution.
Uses the shutdown pattern from http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ExecutorService.html | [
"Stops",
"the",
"reporter",
"and",
"shuts",
"down",
"its",
"thread",
"of",
"execution",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/ScheduledReporter.java#L142-L159 |
124,608 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/ScheduledReporter.java | ScheduledReporter.report | public void report() {
synchronized (this) {
report(registry.getGauges(filter),
registry.getCounters(filter),
registry.getHistograms(filter),
registry.getMeters(filter),
registry.getTimers(filter));
}
} | java | public void report() {
synchronized (this) {
report(registry.getGauges(filter),
registry.getCounters(filter),
registry.getHistograms(filter),
registry.getMeters(filter),
registry.getTimers(filter));
}
} | [
"public",
"void",
"report",
"(",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"report",
"(",
"registry",
".",
"getGauges",
"(",
"filter",
")",
",",
"registry",
".",
"getCounters",
"(",
"filter",
")",
",",
"registry",
".",
"getHistograms",
"(",
"filte... | Report the current values of all metrics in the registry. | [
"Report",
"the",
"current",
"values",
"of",
"all",
"metrics",
"in",
"the",
"registry",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/ScheduledReporter.java#L172-L180 |
124,609 | networknt/light-4j | balance/src/main/java/com/networknt/balance/LocalFirstLoadBalance.java | LocalFirstLoadBalance.select | @Override
public URL select(List<URL> urls, String requestKey) {
// search for a URL in the same ip first
List<URL> localUrls = searchLocalUrls(urls, ip);
if(localUrls.size() > 0) {
if(localUrls.size() == 1) {
return localUrls.get(0);
} else {
... | java | @Override
public URL select(List<URL> urls, String requestKey) {
// search for a URL in the same ip first
List<URL> localUrls = searchLocalUrls(urls, ip);
if(localUrls.size() > 0) {
if(localUrls.size() == 1) {
return localUrls.get(0);
} else {
... | [
"@",
"Override",
"public",
"URL",
"select",
"(",
"List",
"<",
"URL",
">",
"urls",
",",
"String",
"requestKey",
")",
"{",
"// search for a URL in the same ip first",
"List",
"<",
"URL",
">",
"localUrls",
"=",
"searchLocalUrls",
"(",
"urls",
",",
"ip",
")",
";... | Local first requestKey is not used as it is ip on the localhost. It first needs to
find a list of urls on the localhost for the service, and then round robin in the
list to pick up one.
Currently, this load balance is only used if you deploy the service as standalone
java process on data center hosts. We need to find ... | [
"Local",
"first",
"requestKey",
"is",
"not",
"used",
"as",
"it",
"is",
"ip",
"on",
"the",
"localhost",
".",
"It",
"first",
"needs",
"to",
"find",
"a",
"list",
"of",
"urls",
"on",
"the",
"localhost",
"for",
"the",
"service",
"and",
"then",
"round",
"rob... | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/balance/src/main/java/com/networknt/balance/LocalFirstLoadBalance.java#L71-L86 |
124,610 | networknt/light-4j | server/src/main/java/com/networknt/server/Server.java | Server.serverOptionInit | private static void serverOptionInit() {
Map<String, Object> mapConfig = Config.getInstance().getJsonMapConfigNoCache(SERVER_CONFIG_NAME);
ServerOption.serverOptionInit(mapConfig, getServerConfig());
} | java | private static void serverOptionInit() {
Map<String, Object> mapConfig = Config.getInstance().getJsonMapConfigNoCache(SERVER_CONFIG_NAME);
ServerOption.serverOptionInit(mapConfig, getServerConfig());
} | [
"private",
"static",
"void",
"serverOptionInit",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"mapConfig",
"=",
"Config",
".",
"getInstance",
"(",
")",
".",
"getJsonMapConfigNoCache",
"(",
"SERVER_CONFIG_NAME",
")",
";",
"ServerOption",
".",
"serve... | Method used to initialize server options. If the user has configured a valid server option,
load it into the server configuration, otherwise use the default value | [
"Method",
"used",
"to",
"initialize",
"server",
"options",
".",
"If",
"the",
"user",
"has",
"configured",
"a",
"valid",
"server",
"option",
"load",
"it",
"into",
"the",
"server",
"configuration",
"otherwise",
"use",
"the",
"default",
"value"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/server/src/main/java/com/networknt/server/Server.java#L215-L218 |
124,611 | networknt/light-4j | server/src/main/java/com/networknt/server/Server.java | Server.shutdown | static public void shutdown() {
// need to unregister the service
if (getServerConfig().enableRegistry && registry != null && serviceUrls != null) {
for(URL serviceUrl: serviceUrls) {
registry.unregister(serviceUrl);
// Please don't remove the following line.... | java | static public void shutdown() {
// need to unregister the service
if (getServerConfig().enableRegistry && registry != null && serviceUrls != null) {
for(URL serviceUrl: serviceUrls) {
registry.unregister(serviceUrl);
// Please don't remove the following line.... | [
"static",
"public",
"void",
"shutdown",
"(",
")",
"{",
"// need to unregister the service",
"if",
"(",
"getServerConfig",
"(",
")",
".",
"enableRegistry",
"&&",
"registry",
"!=",
"null",
"&&",
"serviceUrls",
"!=",
"null",
")",
"{",
"for",
"(",
"URL",
"serviceU... | implement shutdown hook here. | [
"implement",
"shutdown",
"hook",
"here",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/server/src/main/java/com/networknt/server/Server.java#L316-L347 |
124,612 | networknt/light-4j | server/src/main/java/com/networknt/server/Server.java | Server.mergeStatusConfig | protected static void mergeStatusConfig() {
Map<String, Object> appStatusConfig = Config.getInstance().getJsonMapConfigNoCache(STATUS_CONFIG_NAME[1]);
if (appStatusConfig == null) {
return;
}
Map<String, Object> statusConfig = Config.getInstance().getJsonMapConfig(STATUS_CONF... | java | protected static void mergeStatusConfig() {
Map<String, Object> appStatusConfig = Config.getInstance().getJsonMapConfigNoCache(STATUS_CONFIG_NAME[1]);
if (appStatusConfig == null) {
return;
}
Map<String, Object> statusConfig = Config.getInstance().getJsonMapConfig(STATUS_CONF... | [
"protected",
"static",
"void",
"mergeStatusConfig",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"appStatusConfig",
"=",
"Config",
".",
"getInstance",
"(",
")",
".",
"getJsonMapConfigNoCache",
"(",
"STATUS_CONFIG_NAME",
"[",
"1",
"]",
")",
";",
"... | method used to merge status.yml and app-status.yml | [
"method",
"used",
"to",
"merge",
"status",
".",
"yml",
"and",
"app",
"-",
"status",
".",
"yml"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/server/src/main/java/com/networknt/server/Server.java#L444-L459 |
124,613 | networknt/light-4j | server/src/main/java/com/networknt/server/Server.java | Server.register | public static URL register(String serviceId, int port) {
try {
registry = SingletonServiceFactory.getBean(Registry.class);
if (registry == null)
throw new RuntimeException("Could not find registry instance in service map");
// in kubernetes pod, the hostIP is ... | java | public static URL register(String serviceId, int port) {
try {
registry = SingletonServiceFactory.getBean(Registry.class);
if (registry == null)
throw new RuntimeException("Could not find registry instance in service map");
// in kubernetes pod, the hostIP is ... | [
"public",
"static",
"URL",
"register",
"(",
"String",
"serviceId",
",",
"int",
"port",
")",
"{",
"try",
"{",
"registry",
"=",
"SingletonServiceFactory",
".",
"getBean",
"(",
"Registry",
".",
"class",
")",
";",
"if",
"(",
"registry",
"==",
"null",
")",
"t... | Register the service to the Consul or other service registry. Make it as a separate static method so that it
can be called from light-hybrid-4j to register individual service.
@param serviceId Service Id that is registered
@param port Port number of the service | [
"Register",
"the",
"service",
"to",
"the",
"Consul",
"or",
"other",
"service",
"registry",
".",
"Make",
"it",
"as",
"a",
"separate",
"static",
"method",
"so",
"that",
"it",
"can",
"be",
"called",
"from",
"light",
"-",
"hybrid",
"-",
"4j",
"to",
"register... | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/server/src/main/java/com/networknt/server/Server.java#L473-L506 |
124,614 | networknt/light-4j | client/src/main/java/org/apache/hc/core5/util/copied/CharArrayBuffer.java | CharArrayBuffer.append | public void append(final String str) {
final String s = str != null ? str : "null";
final int strlen = s.length();
final int newlen = this.len + strlen;
if (newlen > this.array.length) {
expand(newlen);
}
s.getChars(0, strlen, this.array, this.len);
th... | java | public void append(final String str) {
final String s = str != null ? str : "null";
final int strlen = s.length();
final int newlen = this.len + strlen;
if (newlen > this.array.length) {
expand(newlen);
}
s.getChars(0, strlen, this.array, this.len);
th... | [
"public",
"void",
"append",
"(",
"final",
"String",
"str",
")",
"{",
"final",
"String",
"s",
"=",
"str",
"!=",
"null",
"?",
"str",
":",
"\"null\"",
";",
"final",
"int",
"strlen",
"=",
"s",
".",
"length",
"(",
")",
";",
"final",
"int",
"newlen",
"="... | Appends chars of the given string to this buffer. The capacity of the
buffer is increased, if necessary, to accommodate all chars.
@param str the string. | [
"Appends",
"chars",
"of",
"the",
"given",
"string",
"to",
"this",
"buffer",
".",
"The",
"capacity",
"of",
"the",
"buffer",
"is",
"increased",
"if",
"necessary",
"to",
"accommodate",
"all",
"chars",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/org/apache/hc/core5/util/copied/CharArrayBuffer.java#L102-L111 |
124,615 | networknt/light-4j | client/src/main/java/org/apache/hc/core5/util/copied/CharArrayBuffer.java | CharArrayBuffer.toCharArray | public char[] toCharArray() {
final char[] b = new char[this.len];
if (this.len > 0) {
System.arraycopy(this.array, 0, b, 0, this.len);
}
return b;
} | java | public char[] toCharArray() {
final char[] b = new char[this.len];
if (this.len > 0) {
System.arraycopy(this.array, 0, b, 0, this.len);
}
return b;
} | [
"public",
"char",
"[",
"]",
"toCharArray",
"(",
")",
"{",
"final",
"char",
"[",
"]",
"b",
"=",
"new",
"char",
"[",
"this",
".",
"len",
"]",
";",
"if",
"(",
"this",
".",
"len",
">",
"0",
")",
"{",
"System",
".",
"arraycopy",
"(",
"this",
".",
... | Converts the content of this buffer to an array of chars.
@return char array | [
"Converts",
"the",
"content",
"of",
"this",
"buffer",
"to",
"an",
"array",
"of",
"chars",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/org/apache/hc/core5/util/copied/CharArrayBuffer.java#L242-L248 |
124,616 | networknt/light-4j | dump/src/main/java/com/networknt/dump/BodyDumper.java | BodyDumper.putDumpInfoTo | @Override
protected void putDumpInfoTo(Map<String, Object> result) {
if(StringUtils.isNotBlank(this.bodyContent)) {
result.put(DumpConstants.BODY, this.bodyContent);
}
} | java | @Override
protected void putDumpInfoTo(Map<String, Object> result) {
if(StringUtils.isNotBlank(this.bodyContent)) {
result.put(DumpConstants.BODY, this.bodyContent);
}
} | [
"@",
"Override",
"protected",
"void",
"putDumpInfoTo",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"this",
".",
"bodyContent",
")",
")",
"{",
"result",
".",
"put",
"(",
"DumpConstan... | put bodyContent to result
@param result a Map<String, Object> you want to put dumping info to. | [
"put",
"bodyContent",
"to",
"result"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/BodyDumper.java#L51-L56 |
124,617 | networknt/light-4j | dump/src/main/java/com/networknt/dump/BodyDumper.java | BodyDumper.dumpRequest | @Override
public void dumpRequest(Map<String, Object> result) {
String contentType = exchange.getRequestHeaders().getFirst(Headers.CONTENT_TYPE);
//only dump json info
if (contentType != null && contentType.startsWith("application/json")) {
//if body info already grab by body han... | java | @Override
public void dumpRequest(Map<String, Object> result) {
String contentType = exchange.getRequestHeaders().getFirst(Headers.CONTENT_TYPE);
//only dump json info
if (contentType != null && contentType.startsWith("application/json")) {
//if body info already grab by body han... | [
"@",
"Override",
"public",
"void",
"dumpRequest",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
")",
"{",
"String",
"contentType",
"=",
"exchange",
".",
"getRequestHeaders",
"(",
")",
".",
"getFirst",
"(",
"Headers",
".",
"CONTENT_TYPE",
")",
";... | impl of dumping request body to result
@param result A map you want to put dump information to | [
"impl",
"of",
"dumping",
"request",
"body",
"to",
"result"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/BodyDumper.java#L62-L79 |
124,618 | networknt/light-4j | dump/src/main/java/com/networknt/dump/BodyDumper.java | BodyDumper.dumpResponse | @Override
public void dumpResponse(Map<String, Object> result) {
byte[] responseBodyAttachment = exchange.getAttachment(StoreResponseStreamSinkConduit.RESPONSE);
if(responseBodyAttachment != null) {
this.bodyContent = config.isMaskEnabled() ? Mask.maskJson(new ByteArrayInputStream(respon... | java | @Override
public void dumpResponse(Map<String, Object> result) {
byte[] responseBodyAttachment = exchange.getAttachment(StoreResponseStreamSinkConduit.RESPONSE);
if(responseBodyAttachment != null) {
this.bodyContent = config.isMaskEnabled() ? Mask.maskJson(new ByteArrayInputStream(respon... | [
"@",
"Override",
"public",
"void",
"dumpResponse",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
")",
"{",
"byte",
"[",
"]",
"responseBodyAttachment",
"=",
"exchange",
".",
"getAttachment",
"(",
"StoreResponseStreamSinkConduit",
".",
"RESPONSE",
")",
... | impl of dumping response body to result
@param result A map you want to put dump information to | [
"impl",
"of",
"dumping",
"response",
"body",
"to",
"result"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/BodyDumper.java#L85-L92 |
124,619 | networknt/light-4j | dump/src/main/java/com/networknt/dump/BodyDumper.java | BodyDumper.dumpInputStream | private void dumpInputStream(){
//dump request body
exchange.startBlocking();
InputStream inputStream = exchange.getInputStream();
try {
if(config.isMaskEnabled() && inputStream.available() != -1) {
this.bodyContent = Mask.maskJson(inputStream, "requestBody");... | java | private void dumpInputStream(){
//dump request body
exchange.startBlocking();
InputStream inputStream = exchange.getInputStream();
try {
if(config.isMaskEnabled() && inputStream.available() != -1) {
this.bodyContent = Mask.maskJson(inputStream, "requestBody");... | [
"private",
"void",
"dumpInputStream",
"(",
")",
"{",
"//dump request body",
"exchange",
".",
"startBlocking",
"(",
")",
";",
"InputStream",
"inputStream",
"=",
"exchange",
".",
"getInputStream",
"(",
")",
";",
"try",
"{",
"if",
"(",
"config",
".",
"isMaskEnabl... | read from input stream, convert it to string, put into this.bodyContent | [
"read",
"from",
"input",
"stream",
"convert",
"it",
"to",
"string",
"put",
"into",
"this",
".",
"bodyContent"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/BodyDumper.java#L97-L114 |
124,620 | networknt/light-4j | dump/src/main/java/com/networknt/dump/BodyDumper.java | BodyDumper.dumpBodyAttachment | private void dumpBodyAttachment(Object requestBodyAttachment) {
this.bodyContent = config.isMaskEnabled() ? Mask.maskJson(requestBodyAttachment, "requestBody") : requestBodyAttachment.toString();
} | java | private void dumpBodyAttachment(Object requestBodyAttachment) {
this.bodyContent = config.isMaskEnabled() ? Mask.maskJson(requestBodyAttachment, "requestBody") : requestBodyAttachment.toString();
} | [
"private",
"void",
"dumpBodyAttachment",
"(",
"Object",
"requestBodyAttachment",
")",
"{",
"this",
".",
"bodyContent",
"=",
"config",
".",
"isMaskEnabled",
"(",
")",
"?",
"Mask",
".",
"maskJson",
"(",
"requestBodyAttachment",
",",
"\"requestBody\"",
")",
":",
"r... | read from body attachment from Body Handler, convert it to string, put into this.bodyContent | [
"read",
"from",
"body",
"attachment",
"from",
"Body",
"Handler",
"convert",
"it",
"to",
"string",
"put",
"into",
"this",
".",
"bodyContent"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/BodyDumper.java#L119-L121 |
124,621 | networknt/light-4j | security/src/main/java/com/networknt/security/JwtHelper.java | JwtHelper.readCertificate | static public X509Certificate readCertificate(String filename)
throws Exception {
InputStream inStream = null;
X509Certificate cert = null;
try {
inStream = Config.getInstance().getInputStreamFromFile(filename);
if (inStream != null) {
Certific... | java | static public X509Certificate readCertificate(String filename)
throws Exception {
InputStream inStream = null;
X509Certificate cert = null;
try {
inStream = Config.getInstance().getInputStreamFromFile(filename);
if (inStream != null) {
Certific... | [
"static",
"public",
"X509Certificate",
"readCertificate",
"(",
"String",
"filename",
")",
"throws",
"Exception",
"{",
"InputStream",
"inStream",
"=",
"null",
";",
"X509Certificate",
"cert",
"=",
"null",
";",
"try",
"{",
"inStream",
"=",
"Config",
".",
"getInstan... | Read certificate from a file and convert it into X509Certificate object
@param filename certificate file name
@return X509Certificate object
@throws Exception Exception while reading certificate | [
"Read",
"certificate",
"from",
"a",
"file",
"and",
"convert",
"it",
"into",
"X509Certificate",
"object"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/security/src/main/java/com/networknt/security/JwtHelper.java#L94-L118 |
124,622 | networknt/light-4j | security/src/main/java/com/networknt/security/JwtHelper.java | JwtHelper.getJwtFromAuthorization | public static String getJwtFromAuthorization(String authorization) {
String jwt = null;
if(authorization != null) {
String[] parts = authorization.split(" ");
if (parts.length == 2) {
String scheme = parts[0];
String credentials = parts[1];
... | java | public static String getJwtFromAuthorization(String authorization) {
String jwt = null;
if(authorization != null) {
String[] parts = authorization.split(" ");
if (parts.length == 2) {
String scheme = parts[0];
String credentials = parts[1];
... | [
"public",
"static",
"String",
"getJwtFromAuthorization",
"(",
"String",
"authorization",
")",
"{",
"String",
"jwt",
"=",
"null",
";",
"if",
"(",
"authorization",
"!=",
"null",
")",
"{",
"String",
"[",
"]",
"parts",
"=",
"authorization",
".",
"split",
"(",
... | Parse the jwt token from Authorization header.
@param authorization authorization header.
@return JWT token | [
"Parse",
"the",
"jwt",
"token",
"from",
"Authorization",
"header",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/security/src/main/java/com/networknt/security/JwtHelper.java#L145-L159 |
124,623 | networknt/light-4j | utility/src/main/java/com/networknt/utility/StringUtils.java | StringUtils.inputStreamToString | public static String inputStreamToString(InputStream inputStream, Charset charset) throws IOException {
if (inputStream != null && inputStream.available() != -1) {
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
... | java | public static String inputStreamToString(InputStream inputStream, Charset charset) throws IOException {
if (inputStream != null && inputStream.available() != -1) {
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
... | [
"public",
"static",
"String",
"inputStreamToString",
"(",
"InputStream",
"inputStream",
",",
"Charset",
"charset",
")",
"throws",
"IOException",
"{",
"if",
"(",
"inputStream",
"!=",
"null",
"&&",
"inputStream",
".",
"available",
"(",
")",
"!=",
"-",
"1",
")",
... | Convert an InputStream into a String.
Highest performing conversion per: https://stackoverflow.com/a/35446009
@param inputStream The input stream to be converted.
@param charset The decoding charset to use.
@return The string value of the input stream, null otherwise.
@throws IOException If there are any issues in re... | [
"Convert",
"an",
"InputStream",
"into",
"a",
"String",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/StringUtils.java#L1265-L1279 |
124,624 | networknt/light-4j | dump/src/main/java/com/networknt/dump/CookiesDumper.java | CookiesDumper.dumpRequest | @Override
public void dumpRequest(Map<String, Object> result) {
Map<String, Cookie> cookiesMap = exchange.getRequestCookies();
dumpCookies(cookiesMap, "requestCookies");
this.putDumpInfoTo(result);
} | java | @Override
public void dumpRequest(Map<String, Object> result) {
Map<String, Cookie> cookiesMap = exchange.getRequestCookies();
dumpCookies(cookiesMap, "requestCookies");
this.putDumpInfoTo(result);
} | [
"@",
"Override",
"public",
"void",
"dumpRequest",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
")",
"{",
"Map",
"<",
"String",
",",
"Cookie",
">",
"cookiesMap",
"=",
"exchange",
".",
"getRequestCookies",
"(",
")",
";",
"dumpCookies",
"(",
"co... | impl of dumping request cookies to result
@param result A map you want to put dump information to | [
"impl",
"of",
"dumping",
"request",
"cookies",
"to",
"result"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/CookiesDumper.java#L38-L44 |
124,625 | networknt/light-4j | dump/src/main/java/com/networknt/dump/CookiesDumper.java | CookiesDumper.dumpResponse | @Override
public void dumpResponse(Map<String, Object> result) {
Map<String, Cookie> cookiesMap = exchange.getResponseCookies();
dumpCookies(cookiesMap, "responseCookies");
this.putDumpInfoTo(result);
} | java | @Override
public void dumpResponse(Map<String, Object> result) {
Map<String, Cookie> cookiesMap = exchange.getResponseCookies();
dumpCookies(cookiesMap, "responseCookies");
this.putDumpInfoTo(result);
} | [
"@",
"Override",
"public",
"void",
"dumpResponse",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
")",
"{",
"Map",
"<",
"String",
",",
"Cookie",
">",
"cookiesMap",
"=",
"exchange",
".",
"getResponseCookies",
"(",
")",
";",
"dumpCookies",
"(",
"... | impl of dumping response cookies to result
@param result A map you want to put dump information to | [
"impl",
"of",
"dumping",
"response",
"cookies",
"to",
"result"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/CookiesDumper.java#L50-L55 |
124,626 | networknt/light-4j | dump/src/main/java/com/networknt/dump/CookiesDumper.java | CookiesDumper.dumpCookies | private void dumpCookies(Map<String, Cookie> cookiesMap, String maskKey) {
cookiesMap.forEach((key, cookie) -> {
if(!config.getRequestFilteredCookies().contains(cookie.getName())) {
List<Map<String, String>> cookieInfoList = new ArrayList<>();
//mask cookieValue
... | java | private void dumpCookies(Map<String, Cookie> cookiesMap, String maskKey) {
cookiesMap.forEach((key, cookie) -> {
if(!config.getRequestFilteredCookies().contains(cookie.getName())) {
List<Map<String, String>> cookieInfoList = new ArrayList<>();
//mask cookieValue
... | [
"private",
"void",
"dumpCookies",
"(",
"Map",
"<",
"String",
",",
"Cookie",
">",
"cookiesMap",
",",
"String",
"maskKey",
")",
"{",
"cookiesMap",
".",
"forEach",
"(",
"(",
"key",
",",
"cookie",
")",
"->",
"{",
"if",
"(",
"!",
"config",
".",
"getRequestF... | put cookies info to cookieMap
@param cookiesMap Map of cookies | [
"put",
"cookies",
"info",
"to",
"cookieMap"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/CookiesDumper.java#L61-L74 |
124,627 | networknt/light-4j | dump/src/main/java/com/networknt/dump/CookiesDumper.java | CookiesDumper.putDumpInfoTo | @Override
protected void putDumpInfoTo(Map<String, Object> result) {
if(this.cookieMap.size() > 0) {
result.put(DumpConstants.COOKIES, cookieMap);
}
} | java | @Override
protected void putDumpInfoTo(Map<String, Object> result) {
if(this.cookieMap.size() > 0) {
result.put(DumpConstants.COOKIES, cookieMap);
}
} | [
"@",
"Override",
"protected",
"void",
"putDumpInfoTo",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
")",
"{",
"if",
"(",
"this",
".",
"cookieMap",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"result",
".",
"put",
"(",
"DumpConstants",
".",... | put cookieMap to result
@param result a Map you want to put dumping info to. | [
"put",
"cookieMap",
"to",
"result"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/CookiesDumper.java#L80-L85 |
124,628 | networknt/light-4j | consul/src/main/java/com/networknt/consul/ConsulUtils.java | ConsulUtils.isSame | public static boolean isSame(List<URL> urls1, List<URL> urls2) {
if (urls1 == null || urls2 == null) {
return false;
}
if (urls1.size() != urls2.size()) {
return false;
}
return urls1.containsAll(urls2);
} | java | public static boolean isSame(List<URL> urls1, List<URL> urls2) {
if (urls1 == null || urls2 == null) {
return false;
}
if (urls1.size() != urls2.size()) {
return false;
}
return urls1.containsAll(urls2);
} | [
"public",
"static",
"boolean",
"isSame",
"(",
"List",
"<",
"URL",
">",
"urls1",
",",
"List",
"<",
"URL",
">",
"urls2",
")",
"{",
"if",
"(",
"urls1",
"==",
"null",
"||",
"urls2",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"url... | Check if two lists have the same urls. If any list is empty, return false
@param urls1 first url list
@param urls2 second url list
@return boolean true when they are the same | [
"Check",
"if",
"two",
"lists",
"have",
"the",
"same",
"urls",
".",
"If",
"any",
"list",
"is",
"empty",
"return",
"false"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/consul/src/main/java/com/networknt/consul/ConsulUtils.java#L38-L46 |
124,629 | networknt/light-4j | consul/src/main/java/com/networknt/consul/ConsulUtils.java | ConsulUtils.buildService | public static ConsulService buildService(URL url) {
ConsulService service = new ConsulService();
service.setAddress(url.getHost());
service.setId(ConsulUtils.convertConsulSerivceId(url));
service.setName(url.getPath());
service.setPort(url.getPort());
List<String> tags = ... | java | public static ConsulService buildService(URL url) {
ConsulService service = new ConsulService();
service.setAddress(url.getHost());
service.setId(ConsulUtils.convertConsulSerivceId(url));
service.setName(url.getPath());
service.setPort(url.getPort());
List<String> tags = ... | [
"public",
"static",
"ConsulService",
"buildService",
"(",
"URL",
"url",
")",
"{",
"ConsulService",
"service",
"=",
"new",
"ConsulService",
"(",
")",
";",
"service",
".",
"setAddress",
"(",
"url",
".",
"getHost",
"(",
")",
")",
";",
"service",
".",
"setId",... | build consul service from url
@param url a URL object
@return ConsulService consul service | [
"build",
"consul",
"service",
"from",
"url"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/consul/src/main/java/com/networknt/consul/ConsulUtils.java#L54-L66 |
124,630 | networknt/light-4j | consul/src/main/java/com/networknt/consul/ConsulUtils.java | ConsulUtils.buildUrl | public static URL buildUrl(ConsulService service) {
URL url = null;
if (url == null) {
Map<String, String> params = new HashMap<String, String>();
//String group = service.getName();
//params.put(URLParamType.group.getName(), group);
//params.put(URLParamT... | java | public static URL buildUrl(ConsulService service) {
URL url = null;
if (url == null) {
Map<String, String> params = new HashMap<String, String>();
//String group = service.getName();
//params.put(URLParamType.group.getName(), group);
//params.put(URLParamT... | [
"public",
"static",
"URL",
"buildUrl",
"(",
"ConsulService",
"service",
")",
"{",
"URL",
"url",
"=",
"null",
";",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"HashMap",
"<",
"String",
",",... | build url from service
@param service consul service
@return URL object | [
"build",
"url",
"from",
"service"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/consul/src/main/java/com/networknt/consul/ConsulUtils.java#L74-L88 |
124,631 | networknt/light-4j | consul/src/main/java/com/networknt/consul/ConsulUtils.java | ConsulUtils.getPathFromServiceId | public static String getPathFromServiceId(String serviceId) {
return serviceId.substring(serviceId.indexOf(":") + 1, serviceId.lastIndexOf(":"));
} | java | public static String getPathFromServiceId(String serviceId) {
return serviceId.substring(serviceId.indexOf(":") + 1, serviceId.lastIndexOf(":"));
} | [
"public",
"static",
"String",
"getPathFromServiceId",
"(",
"String",
"serviceId",
")",
"{",
"return",
"serviceId",
".",
"substring",
"(",
"serviceId",
".",
"indexOf",
"(",
"\":\"",
")",
"+",
"1",
",",
"serviceId",
".",
"lastIndexOf",
"(",
"\":\"",
")",
")",
... | get path of url from service id in consul
@param serviceId service id
@return path | [
"get",
"path",
"of",
"url",
"from",
"service",
"id",
"in",
"consul"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/consul/src/main/java/com/networknt/consul/ConsulUtils.java#L139-L141 |
124,632 | networknt/light-4j | security/src/main/java/com/networknt/security/JwtIssuer.java | JwtIssuer.getJwt | public static String getJwt(JwtClaims claims) throws JoseException {
String jwt;
RSAPrivateKey privateKey = (RSAPrivateKey) getPrivateKey(
jwtConfig.getKey().getFilename(), (String)secretConfig.get(JWT_PRIVATE_KEY_PASSWORD), jwtConfig.getKey().getKeyName());
// A JWT is a JWS an... | java | public static String getJwt(JwtClaims claims) throws JoseException {
String jwt;
RSAPrivateKey privateKey = (RSAPrivateKey) getPrivateKey(
jwtConfig.getKey().getFilename(), (String)secretConfig.get(JWT_PRIVATE_KEY_PASSWORD), jwtConfig.getKey().getKeyName());
// A JWT is a JWS an... | [
"public",
"static",
"String",
"getJwt",
"(",
"JwtClaims",
"claims",
")",
"throws",
"JoseException",
"{",
"String",
"jwt",
";",
"RSAPrivateKey",
"privateKey",
"=",
"(",
"RSAPrivateKey",
")",
"getPrivateKey",
"(",
"jwtConfig",
".",
"getKey",
"(",
")",
".",
"getF... | A static method that generate JWT token from JWT claims object
@param claims JwtClaims object
@return A string represents jwt token
@throws JoseException JoseException | [
"A",
"static",
"method",
"that",
"generate",
"JWT",
"token",
"from",
"JWT",
"claims",
"object"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/security/src/main/java/com/networknt/security/JwtIssuer.java#L53-L92 |
124,633 | networknt/light-4j | security/src/main/java/com/networknt/security/JwtIssuer.java | JwtIssuer.getPrivateKey | private static PrivateKey getPrivateKey(String filename, String password, String key) {
if(logger.isDebugEnabled()) logger.debug("filename = " + filename + " key = " + key);
PrivateKey privateKey = null;
try {
KeyStore keystore = KeyStore.getInstance("JKS");
keystore.loa... | java | private static PrivateKey getPrivateKey(String filename, String password, String key) {
if(logger.isDebugEnabled()) logger.debug("filename = " + filename + " key = " + key);
PrivateKey privateKey = null;
try {
KeyStore keystore = KeyStore.getInstance("JKS");
keystore.loa... | [
"private",
"static",
"PrivateKey",
"getPrivateKey",
"(",
"String",
"filename",
",",
"String",
"password",
",",
"String",
"key",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"filename = \"",
"+",
"filenam... | Get private key from java key store
@param filename Key store file name
@param password Key store password
@param key key name in keystore
@return A PrivateKey object | [
"Get",
"private",
"key",
"from",
"java",
"key",
"store"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/security/src/main/java/com/networknt/security/JwtIssuer.java#L141-L161 |
124,634 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/influxdb/TimeUtils.java | TimeUtils.toTimePrecision | public static String toTimePrecision(final TimeUnit t) {
switch (t) {
case HOURS:
return "h";
case MINUTES:
return "m";
case SECONDS:
return "s";
case MILLISECONDS:
return "ms";
case MICRO... | java | public static String toTimePrecision(final TimeUnit t) {
switch (t) {
case HOURS:
return "h";
case MINUTES:
return "m";
case SECONDS:
return "s";
case MILLISECONDS:
return "ms";
case MICRO... | [
"public",
"static",
"String",
"toTimePrecision",
"(",
"final",
"TimeUnit",
"t",
")",
"{",
"switch",
"(",
"t",
")",
"{",
"case",
"HOURS",
":",
"return",
"\"h\"",
";",
"case",
"MINUTES",
":",
"return",
"\"m\"",
";",
"case",
"SECONDS",
":",
"return",
"\"s\"... | Convert from a TimeUnit to a influxDB timeunit String.
@param t time unit
@return the String representation. | [
"Convert",
"from",
"a",
"TimeUnit",
"to",
"a",
"influxDB",
"timeunit",
"String",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/influxdb/TimeUtils.java#L32-L56 |
124,635 | networknt/light-4j | client/src/main/java/com/networknt/client/oauth/TokenManager.java | TokenManager.getJwt | private synchronized Jwt getJwt(ICacheStrategy cacheStrategy, Jwt.Key key) {
Jwt result = cacheStrategy.getCachedJwt(key);
if(result == null) {
//cache an empty JWT first.
result = new Jwt(key);
cacheStrategy.cacheJwt(key, result);
}
return result;
... | java | private synchronized Jwt getJwt(ICacheStrategy cacheStrategy, Jwt.Key key) {
Jwt result = cacheStrategy.getCachedJwt(key);
if(result == null) {
//cache an empty JWT first.
result = new Jwt(key);
cacheStrategy.cacheJwt(key, result);
}
return result;
... | [
"private",
"synchronized",
"Jwt",
"getJwt",
"(",
"ICacheStrategy",
"cacheStrategy",
",",
"Jwt",
".",
"Key",
"key",
")",
"{",
"Jwt",
"result",
"=",
"cacheStrategy",
".",
"getCachedJwt",
"(",
"key",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"/... | cache jwt if not exist | [
"cache",
"jwt",
"if",
"not",
"exist"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/oauth/TokenManager.java#L87-L95 |
124,636 | networknt/light-4j | consul/src/main/java/com/networknt/consul/ConsulHeartbeatManager.java | ConsulHeartbeatManager.isSwitcherChange | private boolean isSwitcherChange(boolean switcherStatus) {
boolean ret = false;
if (switcherStatus != lastHeartBeatSwitcherStatus) {
ret = true;
lastHeartBeatSwitcherStatus = switcherStatus;
logger.info("heartbeat switcher change to " + switcherStatus);
}
return ret;
} | java | private boolean isSwitcherChange(boolean switcherStatus) {
boolean ret = false;
if (switcherStatus != lastHeartBeatSwitcherStatus) {
ret = true;
lastHeartBeatSwitcherStatus = switcherStatus;
logger.info("heartbeat switcher change to " + switcherStatus);
}
return ret;
} | [
"private",
"boolean",
"isSwitcherChange",
"(",
"boolean",
"switcherStatus",
")",
"{",
"boolean",
"ret",
"=",
"false",
";",
"if",
"(",
"switcherStatus",
"!=",
"lastHeartBeatSwitcherStatus",
")",
"{",
"ret",
"=",
"true",
";",
"lastHeartBeatSwitcherStatus",
"=",
"swi... | check heart beat switcher status, if switcher is changed, then change lastHeartBeatSwitcherStatus
to the latest status.
@param switcherStatus
@return | [
"check",
"heart",
"beat",
"switcher",
"status",
"if",
"switcher",
"is",
"changed",
"then",
"change",
"lastHeartBeatSwitcherStatus",
"to",
"the",
"latest",
"status",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/consul/src/main/java/com/networknt/consul/ConsulHeartbeatManager.java#L105-L113 |
124,637 | networknt/light-4j | registry/src/main/java/com/networknt/registry/URLImpl.java | URLImpl.getIdentity | @Override
public String getIdentity() {
return protocol + Constants.PROTOCOL_SEPARATOR + host + ":" + port +
"/" + getParameter(URLParamType.group.getName(), URLParamType.group.getValue()) + "/" +
getPath() + "/" + getParameter(URLParamType.version.getName(), URLParamType.ver... | java | @Override
public String getIdentity() {
return protocol + Constants.PROTOCOL_SEPARATOR + host + ":" + port +
"/" + getParameter(URLParamType.group.getName(), URLParamType.group.getValue()) + "/" +
getPath() + "/" + getParameter(URLParamType.version.getName(), URLParamType.ver... | [
"@",
"Override",
"public",
"String",
"getIdentity",
"(",
")",
"{",
"return",
"protocol",
"+",
"Constants",
".",
"PROTOCOL_SEPARATOR",
"+",
"host",
"+",
"\":\"",
"+",
"port",
"+",
"\"/\"",
"+",
"getParameter",
"(",
"URLParamType",
".",
"group",
".",
"getName"... | Return service identity, if two urls have the same identity, then same service
@return the identity | [
"Return",
"service",
"identity",
"if",
"two",
"urls",
"have",
"the",
"same",
"identity",
"then",
"same",
"service"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/registry/src/main/java/com/networknt/registry/URLImpl.java#L334-L340 |
124,638 | networknt/light-4j | registry/src/main/java/com/networknt/registry/URLImpl.java | URLImpl.canServe | @Override
public boolean canServe(URL refUrl) {
if (refUrl == null || !this.getPath().equals(refUrl.getPath())) {
return false;
}
if(!protocol.equals(refUrl.getProtocol())) {
return false;
}
if (!Constants.NODE_TYPE_SERVICE.equals(this.getParameter(U... | java | @Override
public boolean canServe(URL refUrl) {
if (refUrl == null || !this.getPath().equals(refUrl.getPath())) {
return false;
}
if(!protocol.equals(refUrl.getProtocol())) {
return false;
}
if (!Constants.NODE_TYPE_SERVICE.equals(this.getParameter(U... | [
"@",
"Override",
"public",
"boolean",
"canServe",
"(",
"URL",
"refUrl",
")",
"{",
"if",
"(",
"refUrl",
"==",
"null",
"||",
"!",
"this",
".",
"getPath",
"(",
")",
".",
"equals",
"(",
"refUrl",
".",
"getPath",
"(",
")",
")",
")",
"{",
"return",
"fals... | check if this url can serve the refUrl.
@param refUrl a URL object
@return boolean true can serve | [
"check",
"if",
"this",
"url",
"can",
"serve",
"the",
"refUrl",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/registry/src/main/java/com/networknt/registry/URLImpl.java#L348-L376 |
124,639 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/MetricName.java | MetricName.resolve | public MetricName resolve(String p) {
final String next;
if (p != null && !p.isEmpty()) {
if (key != null && !key.isEmpty()) {
next = key + SEPARATOR + p;
} else {
next = p;
}
} else {
next = this.key;
}
... | java | public MetricName resolve(String p) {
final String next;
if (p != null && !p.isEmpty()) {
if (key != null && !key.isEmpty()) {
next = key + SEPARATOR + p;
} else {
next = p;
}
} else {
next = this.key;
}
... | [
"public",
"MetricName",
"resolve",
"(",
"String",
"p",
")",
"{",
"final",
"String",
"next",
";",
"if",
"(",
"p",
"!=",
"null",
"&&",
"!",
"p",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"key",
"!=",
"null",
"&&",
"!",
"key",
".",
"isEmpty",
... | Build the MetricName that is this with another path appended to it.
The new MetricName inherits the tags of this one.
@param p The extra path element to add to the new metric.
@return A new metric name relative to the original by the path specified
in p. | [
"Build",
"the",
"MetricName",
"that",
"is",
"this",
"with",
"another",
"path",
"appended",
"to",
"it",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/MetricName.java#L82-L96 |
124,640 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/MetricName.java | MetricName.tagged | public MetricName tagged(Map<String, String> add) {
final Map<String, String> tags = new HashMap<>(add);
tags.putAll(this.tags);
return new MetricName(key, tags);
} | java | public MetricName tagged(Map<String, String> add) {
final Map<String, String> tags = new HashMap<>(add);
tags.putAll(this.tags);
return new MetricName(key, tags);
} | [
"public",
"MetricName",
"tagged",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"add",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
"=",
"new",
"HashMap",
"<>",
"(",
"add",
")",
";",
"tags",
".",
"putAll",
"(",
"this",
".",... | Add tags to a metric name and return the newly created MetricName.
@param add Tags to add.
@return A newly created metric name with the specified tags associated with it. | [
"Add",
"tags",
"to",
"a",
"metric",
"name",
"and",
"return",
"the",
"newly",
"created",
"MetricName",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/MetricName.java#L104-L108 |
124,641 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/MetricName.java | MetricName.join | public static MetricName join(MetricName... parts) {
final StringBuilder nameBuilder = new StringBuilder();
final Map<String, String> tags = new HashMap<>();
boolean first = true;
for (MetricName part : parts) {
final String name = part.getKey();
if (name != nu... | java | public static MetricName join(MetricName... parts) {
final StringBuilder nameBuilder = new StringBuilder();
final Map<String, String> tags = new HashMap<>();
boolean first = true;
for (MetricName part : parts) {
final String name = part.getKey();
if (name != nu... | [
"public",
"static",
"MetricName",
"join",
"(",
"MetricName",
"...",
"parts",
")",
"{",
"final",
"StringBuilder",
"nameBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
"=",
"new",
"HashMap",
"<... | Join the specified set of metric names.
@param parts Multiple metric names to join using the separator.
@return A newly created metric name which has the name of the specified
parts and includes all tags of all child metric names. | [
"Join",
"the",
"specified",
"set",
"of",
"metric",
"names",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/MetricName.java#L144-L168 |
124,642 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/MetricName.java | MetricName.build | public static MetricName build(String... parts) {
if (parts == null || parts.length == 0)
return MetricName.EMPTY;
if (parts.length == 1)
return new MetricName(parts[0], EMPTY_TAGS);
return new MetricName(buildName(parts), EMPTY_TAGS);
} | java | public static MetricName build(String... parts) {
if (parts == null || parts.length == 0)
return MetricName.EMPTY;
if (parts.length == 1)
return new MetricName(parts[0], EMPTY_TAGS);
return new MetricName(buildName(parts), EMPTY_TAGS);
} | [
"public",
"static",
"MetricName",
"build",
"(",
"String",
"...",
"parts",
")",
"{",
"if",
"(",
"parts",
"==",
"null",
"||",
"parts",
".",
"length",
"==",
"0",
")",
"return",
"MetricName",
".",
"EMPTY",
";",
"if",
"(",
"parts",
".",
"length",
"==",
"1... | Build a new metric name using the specific path components.
@param parts Path of the new metric name.
@return A newly created metric name with the specified path. | [
"Build",
"a",
"new",
"metric",
"name",
"using",
"the",
"specific",
"path",
"components",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/MetricName.java#L176-L184 |
124,643 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.initPaths | static void initPaths() {
if (config != null && config.getPaths() != null) {
for (PathChain pathChain : config.getPaths()) {
pathChain.validate(configName + " config"); // raises exception on misconfiguration
if(pathChain.getPath() == null) {
addSourceChain(pathChain);
} else {
addPathChain(p... | java | static void initPaths() {
if (config != null && config.getPaths() != null) {
for (PathChain pathChain : config.getPaths()) {
pathChain.validate(configName + " config"); // raises exception on misconfiguration
if(pathChain.getPath() == null) {
addSourceChain(pathChain);
} else {
addPathChain(p... | [
"static",
"void",
"initPaths",
"(",
")",
"{",
"if",
"(",
"config",
"!=",
"null",
"&&",
"config",
".",
"getPaths",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"PathChain",
"pathChain",
":",
"config",
".",
"getPaths",
"(",
")",
")",
"{",
"pathChain",... | Build "handlerListById" and "reqTypeMatcherMap" from the paths in the config. | [
"Build",
"handlerListById",
"and",
"reqTypeMatcherMap",
"from",
"the",
"paths",
"in",
"the",
"config",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L121-L132 |
124,644 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.initDefaultHandlers | static void initDefaultHandlers() {
if (config != null && config.getDefaultHandlers() != null) {
defaultHandlers = getHandlersFromExecList(config.getDefaultHandlers());
handlerListById.put("defaultHandlers", defaultHandlers);
}
} | java | static void initDefaultHandlers() {
if (config != null && config.getDefaultHandlers() != null) {
defaultHandlers = getHandlersFromExecList(config.getDefaultHandlers());
handlerListById.put("defaultHandlers", defaultHandlers);
}
} | [
"static",
"void",
"initDefaultHandlers",
"(",
")",
"{",
"if",
"(",
"config",
"!=",
"null",
"&&",
"config",
".",
"getDefaultHandlers",
"(",
")",
"!=",
"null",
")",
"{",
"defaultHandlers",
"=",
"getHandlersFromExecList",
"(",
"config",
".",
"getDefaultHandlers",
... | Build "defaultHandlers" from the defaultHandlers in the config. | [
"Build",
"defaultHandlers",
"from",
"the",
"defaultHandlers",
"in",
"the",
"config",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L137-L142 |
124,645 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.addSourceChain | private static void addSourceChain(PathChain sourceChain) {
try {
Class sourceClass = Class.forName(sourceChain.getSource());
EndpointSource source = (EndpointSource)sourceClass.newInstance();
for (EndpointSource.Endpoint endpoint : source.listEndpoints()) {
PathChain sourcedPath = new PathChain();
s... | java | private static void addSourceChain(PathChain sourceChain) {
try {
Class sourceClass = Class.forName(sourceChain.getSource());
EndpointSource source = (EndpointSource)sourceClass.newInstance();
for (EndpointSource.Endpoint endpoint : source.listEndpoints()) {
PathChain sourcedPath = new PathChain();
s... | [
"private",
"static",
"void",
"addSourceChain",
"(",
"PathChain",
"sourceChain",
")",
"{",
"try",
"{",
"Class",
"sourceClass",
"=",
"Class",
".",
"forName",
"(",
"sourceChain",
".",
"getSource",
"(",
")",
")",
";",
"EndpointSource",
"source",
"=",
"(",
"Endpo... | Add PathChains crated from the EndpointSource given in sourceChain | [
"Add",
"PathChains",
"crated",
"from",
"the",
"EndpointSource",
"given",
"in",
"sourceChain"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L147-L167 |
124,646 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.next | public static void next(HttpServerExchange httpServerExchange) throws Exception {
HttpHandler httpHandler = getNext(httpServerExchange);
if (httpHandler != null) {
httpHandler.handleRequest(httpServerExchange);
} else if(lastHandler != null) {
lastHandler.handleRequest(httpServerExchange);
}
} | java | public static void next(HttpServerExchange httpServerExchange) throws Exception {
HttpHandler httpHandler = getNext(httpServerExchange);
if (httpHandler != null) {
httpHandler.handleRequest(httpServerExchange);
} else if(lastHandler != null) {
lastHandler.handleRequest(httpServerExchange);
}
} | [
"public",
"static",
"void",
"next",
"(",
"HttpServerExchange",
"httpServerExchange",
")",
"throws",
"Exception",
"{",
"HttpHandler",
"httpHandler",
"=",
"getNext",
"(",
"httpServerExchange",
")",
";",
"if",
"(",
"httpHandler",
"!=",
"null",
")",
"{",
"httpHandler"... | Handle the next request in the chain.
@param httpServerExchange
The current requests server exchange.
@throws Exception
Propagated exception in the handleRequest chain. | [
"Handle",
"the",
"next",
"request",
"in",
"the",
"chain",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L204-L211 |
124,647 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.next | public static void next(HttpServerExchange httpServerExchange, HttpHandler next) throws Exception {
if (next != null) {
next.handleRequest(httpServerExchange);
} else {
next(httpServerExchange);
}
} | java | public static void next(HttpServerExchange httpServerExchange, HttpHandler next) throws Exception {
if (next != null) {
next.handleRequest(httpServerExchange);
} else {
next(httpServerExchange);
}
} | [
"public",
"static",
"void",
"next",
"(",
"HttpServerExchange",
"httpServerExchange",
",",
"HttpHandler",
"next",
")",
"throws",
"Exception",
"{",
"if",
"(",
"next",
"!=",
"null",
")",
"{",
"next",
".",
"handleRequest",
"(",
"httpServerExchange",
")",
";",
"}",... | Go to the next handler if the given next is none null. Reason for this is for
middleware to provide their instance next if it exists. Since if it exists,
the server hasn't been able to find the handler.yml.
@param httpServerExchange
The current requests server exchange.
@param next
The next HttpHandler to go to if it'... | [
"Go",
"to",
"the",
"next",
"handler",
"if",
"the",
"given",
"next",
"is",
"none",
"null",
".",
"Reason",
"for",
"this",
"is",
"for",
"middleware",
"to",
"provide",
"their",
"instance",
"next",
"if",
"it",
"exists",
".",
"Since",
"if",
"it",
"exists",
"... | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L224-L230 |
124,648 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.next | public static void next(HttpServerExchange httpServerExchange, String execName, Boolean returnToOrigFlow)
throws Exception {
String currentChainId = httpServerExchange.getAttachment(CHAIN_ID);
Integer currentNextIndex = httpServerExchange.getAttachment(CHAIN_SEQ);
httpServerExchange.putAttachment(CHAIN_ID, ex... | java | public static void next(HttpServerExchange httpServerExchange, String execName, Boolean returnToOrigFlow)
throws Exception {
String currentChainId = httpServerExchange.getAttachment(CHAIN_ID);
Integer currentNextIndex = httpServerExchange.getAttachment(CHAIN_SEQ);
httpServerExchange.putAttachment(CHAIN_ID, ex... | [
"public",
"static",
"void",
"next",
"(",
"HttpServerExchange",
"httpServerExchange",
",",
"String",
"execName",
",",
"Boolean",
"returnToOrigFlow",
")",
"throws",
"Exception",
"{",
"String",
"currentChainId",
"=",
"httpServerExchange",
".",
"getAttachment",
"(",
"CHAI... | Allow nexting directly to a flow.
@param httpServerExchange
The current requests server exchange.
@param execName
The name of the next executable to go to, ie chain or handler.
Chain resolved first.
@param returnToOrigFlow
True if you want to call the next handler defined in your original
chain after the provided exec... | [
"Allow",
"nexting",
"directly",
"to",
"a",
"flow",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L246-L262 |
124,649 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.getNext | public static HttpHandler getNext(HttpServerExchange httpServerExchange) {
String chainId = httpServerExchange.getAttachment(CHAIN_ID);
List<HttpHandler> handlersForId = handlerListById.get(chainId);
Integer nextIndex = httpServerExchange.getAttachment(CHAIN_SEQ);
// Check if we've reached the end of the chain.... | java | public static HttpHandler getNext(HttpServerExchange httpServerExchange) {
String chainId = httpServerExchange.getAttachment(CHAIN_ID);
List<HttpHandler> handlersForId = handlerListById.get(chainId);
Integer nextIndex = httpServerExchange.getAttachment(CHAIN_SEQ);
// Check if we've reached the end of the chain.... | [
"public",
"static",
"HttpHandler",
"getNext",
"(",
"HttpServerExchange",
"httpServerExchange",
")",
"{",
"String",
"chainId",
"=",
"httpServerExchange",
".",
"getAttachment",
"(",
"CHAIN_ID",
")",
";",
"List",
"<",
"HttpHandler",
">",
"handlersForId",
"=",
"handlerL... | Returns the instance of the next handler, rather then calling handleRequest
on it.
@param httpServerExchange
The current requests server exchange.
@return The HttpHandler that should be executed next. | [
"Returns",
"the",
"instance",
"of",
"the",
"next",
"handler",
"rather",
"then",
"calling",
"handleRequest",
"on",
"it",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L272-L282 |
124,650 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.getNext | public static HttpHandler getNext(HttpServerExchange httpServerExchange, HttpHandler next) throws Exception {
if (next != null) {
return next;
}
return getNext(httpServerExchange);
} | java | public static HttpHandler getNext(HttpServerExchange httpServerExchange, HttpHandler next) throws Exception {
if (next != null) {
return next;
}
return getNext(httpServerExchange);
} | [
"public",
"static",
"HttpHandler",
"getNext",
"(",
"HttpServerExchange",
"httpServerExchange",
",",
"HttpHandler",
"next",
")",
"throws",
"Exception",
"{",
"if",
"(",
"next",
"!=",
"null",
")",
"{",
"return",
"next",
";",
"}",
"return",
"getNext",
"(",
"httpSe... | Returns the instance of the next handler, or the given next param if it's not
null.
@param httpServerExchange
The current requests server exchange.
@param next
If not null, return this.
@return The next handler in the chain, or next if it's not null.
@throws Exception exception | [
"Returns",
"the",
"instance",
"of",
"the",
"next",
"handler",
"or",
"the",
"given",
"next",
"param",
"if",
"it",
"s",
"not",
"null",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L295-L300 |
124,651 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.start | public static boolean start(HttpServerExchange httpServerExchange) {
// Get the matcher corresponding to the current request type.
PathTemplateMatcher<String> pathTemplateMatcher = methodToMatcherMap.get(httpServerExchange.getRequestMethod());
if (pathTemplateMatcher != null) {
// Match the current request pat... | java | public static boolean start(HttpServerExchange httpServerExchange) {
// Get the matcher corresponding to the current request type.
PathTemplateMatcher<String> pathTemplateMatcher = methodToMatcherMap.get(httpServerExchange.getRequestMethod());
if (pathTemplateMatcher != null) {
// Match the current request pat... | [
"public",
"static",
"boolean",
"start",
"(",
"HttpServerExchange",
"httpServerExchange",
")",
"{",
"// Get the matcher corresponding to the current request type.",
"PathTemplateMatcher",
"<",
"String",
">",
"pathTemplateMatcher",
"=",
"methodToMatcherMap",
".",
"get",
"(",
"h... | On the first step of the request, match the request against the configured
paths. If the match is successful, store the chain id within the exchange.
Otherwise return false.
@param httpServerExchange
The current requests server exchange.
@return true if a handler has been defined for the given path. | [
"On",
"the",
"first",
"step",
"of",
"the",
"request",
"match",
"the",
"request",
"against",
"the",
"configured",
"paths",
".",
"If",
"the",
"match",
"is",
"successful",
"store",
"the",
"chain",
"id",
"within",
"the",
"exchange",
".",
"Otherwise",
"return",
... | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L311-L337 |
124,652 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.startDefaultHandlers | public static boolean startDefaultHandlers(HttpServerExchange httpServerExchange) {
// check if defaultHandlers is empty
if(defaultHandlers != null && defaultHandlers.size() > 0) {
httpServerExchange.putAttachment(CHAIN_ID, "defaultHandlers");
httpServerExchange.putAttachment(CHAIN_SEQ, 0);
return true;
... | java | public static boolean startDefaultHandlers(HttpServerExchange httpServerExchange) {
// check if defaultHandlers is empty
if(defaultHandlers != null && defaultHandlers.size() > 0) {
httpServerExchange.putAttachment(CHAIN_ID, "defaultHandlers");
httpServerExchange.putAttachment(CHAIN_SEQ, 0);
return true;
... | [
"public",
"static",
"boolean",
"startDefaultHandlers",
"(",
"HttpServerExchange",
"httpServerExchange",
")",
"{",
"// check if defaultHandlers is empty",
"if",
"(",
"defaultHandlers",
"!=",
"null",
"&&",
"defaultHandlers",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
... | If there is no matching path, the OrchestrationHandler is going to try to start the defaultHandlers.
If there are default handlers defined, store the chain id within the exchange.
Otherwise return false.
@param httpServerExchange
The current requests server exchange.
@return true if a handler has been defined for the ... | [
"If",
"there",
"is",
"no",
"matching",
"path",
"the",
"OrchestrationHandler",
"is",
"going",
"to",
"try",
"to",
"start",
"the",
"defaultHandlers",
".",
"If",
"there",
"are",
"default",
"handlers",
"defined",
"store",
"the",
"chain",
"id",
"within",
"the",
"e... | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L349-L357 |
124,653 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.getHandlersFromExecList | private static List<HttpHandler> getHandlersFromExecList(List<String> execs) {
List<HttpHandler> handlersFromExecList = new ArrayList<>();
if (execs != null) {
for (String exec : execs) {
List<HttpHandler> handlerList = handlerListById.get(exec);
if (handlerList == null)
throw new RuntimeException("... | java | private static List<HttpHandler> getHandlersFromExecList(List<String> execs) {
List<HttpHandler> handlersFromExecList = new ArrayList<>();
if (execs != null) {
for (String exec : execs) {
List<HttpHandler> handlerList = handlerListById.get(exec);
if (handlerList == null)
throw new RuntimeException("... | [
"private",
"static",
"List",
"<",
"HttpHandler",
">",
"getHandlersFromExecList",
"(",
"List",
"<",
"String",
">",
"execs",
")",
"{",
"List",
"<",
"HttpHandler",
">",
"handlersFromExecList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"execs",
... | Converts the list of chains and handlers to a flat list of handlers. If a
chain is named the same as a handler, the chain is resolved first.
@param execs
The list of names of chains and handlers.
@return A list containing references to the instantiated handlers | [
"Converts",
"the",
"list",
"of",
"chains",
"and",
"handlers",
"to",
"a",
"flat",
"list",
"of",
"handlers",
".",
"If",
"a",
"chain",
"is",
"named",
"the",
"same",
"as",
"a",
"handler",
"the",
"chain",
"is",
"resolved",
"first",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L367-L388 |
124,654 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.registerMiddlewareHandler | private static void registerMiddlewareHandler(Object handler) {
if(handler instanceof MiddlewareHandler) {
// register the middleware handler if it is enabled.
if(((MiddlewareHandler) handler).isEnabled()) {
((MiddlewareHandler) handler).register();
}
}
} | java | private static void registerMiddlewareHandler(Object handler) {
if(handler instanceof MiddlewareHandler) {
// register the middleware handler if it is enabled.
if(((MiddlewareHandler) handler).isEnabled()) {
((MiddlewareHandler) handler).register();
}
}
} | [
"private",
"static",
"void",
"registerMiddlewareHandler",
"(",
"Object",
"handler",
")",
"{",
"if",
"(",
"handler",
"instanceof",
"MiddlewareHandler",
")",
"{",
"// register the middleware handler if it is enabled.",
"if",
"(",
"(",
"(",
"MiddlewareHandler",
")",
"handl... | Detect if the handler is a MiddlewareHandler instance. If yes, then register it.
@param handler | [
"Detect",
"if",
"the",
"handler",
"is",
"a",
"MiddlewareHandler",
"instance",
".",
"If",
"yes",
"then",
"register",
"it",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L394-L401 |
124,655 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.initMapDefinedHandler | private static void initMapDefinedHandler(Map<String, Object> handler) {
// If the handler is a map, the keys are the class name, values are the
// parameters.
for (Map.Entry<String, Object> entry : handler.entrySet()) {
Tuple<String, Class> namedClass = splitClassAndName(entry.getKey());
// If the values ... | java | private static void initMapDefinedHandler(Map<String, Object> handler) {
// If the handler is a map, the keys are the class name, values are the
// parameters.
for (Map.Entry<String, Object> entry : handler.entrySet()) {
Tuple<String, Class> namedClass = splitClassAndName(entry.getKey());
// If the values ... | [
"private",
"static",
"void",
"initMapDefinedHandler",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"handler",
")",
"{",
"// If the handler is a map, the keys are the class name, values are the",
"// parameters.",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
... | Helper method for generating the instance of a handler from its map
definition in config. Ie. No mapped values for setters, or list of
constructor fields.
@param handler | [
"Helper",
"method",
"for",
"generating",
"the",
"instance",
"of",
"a",
"handler",
"from",
"its",
"map",
"definition",
"in",
"config",
".",
"Ie",
".",
"No",
"mapped",
"values",
"for",
"setters",
"or",
"list",
"of",
"constructor",
"fields",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L444-L481 |
124,656 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.splitClassAndName | static Tuple<String, Class> splitClassAndName(String classLabel) {
String[] stringNameSplit = classLabel.split("@");
// If i don't have a @, then no name is provided, use the class as the name.
if (stringNameSplit.length == 1) {
try {
return new Tuple<>(classLabel, Class.forName(classLabel));
} catch (C... | java | static Tuple<String, Class> splitClassAndName(String classLabel) {
String[] stringNameSplit = classLabel.split("@");
// If i don't have a @, then no name is provided, use the class as the name.
if (stringNameSplit.length == 1) {
try {
return new Tuple<>(classLabel, Class.forName(classLabel));
} catch (C... | [
"static",
"Tuple",
"<",
"String",
",",
"Class",
">",
"splitClassAndName",
"(",
"String",
"classLabel",
")",
"{",
"String",
"[",
"]",
"stringNameSplit",
"=",
"classLabel",
".",
"split",
"(",
"\"@\"",
")",
";",
"// If i don't have a @, then no name is provided, use th... | To support multiple instances of the same class, support a naming
@param classLabel
The label as seen in the config file.
@return A tuple where the first value is the name, and the second is the
class.
@throws Exception
On invalid format of label. | [
"To",
"support",
"multiple",
"instances",
"of",
"the",
"same",
"class",
"support",
"a",
"naming"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L493-L511 |
124,657 | networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.setConfig | static void setConfig(String configName) throws Exception {
Handler.configName = configName;
config = (HandlerConfig) Config.getInstance().getJsonObjectConfig(configName, HandlerConfig.class);
initHandlers();
initPaths();
} | java | static void setConfig(String configName) throws Exception {
Handler.configName = configName;
config = (HandlerConfig) Config.getInstance().getJsonObjectConfig(configName, HandlerConfig.class);
initHandlers();
initPaths();
} | [
"static",
"void",
"setConfig",
"(",
"String",
"configName",
")",
"throws",
"Exception",
"{",
"Handler",
".",
"configName",
"=",
"configName",
";",
"config",
"=",
"(",
"HandlerConfig",
")",
"Config",
".",
"getInstance",
"(",
")",
".",
"getJsonObjectConfig",
"("... | Exposed for testing only. | [
"Exposed",
"for",
"testing",
"only",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L514-L519 |
124,658 | networknt/light-4j | client/src/main/java/com/networknt/client/oauth/ClientRequestComposerProvider.java | ClientRequestComposerProvider.getComposer | public IClientRequestComposable getComposer(ClientRequestComposers composerName) {
IClientRequestComposable composer = composersMap.get(composerName);
if(composer == null) {
initDefaultComposer(composerName);
}
return composersMap.get(composerName);
} | java | public IClientRequestComposable getComposer(ClientRequestComposers composerName) {
IClientRequestComposable composer = composersMap.get(composerName);
if(composer == null) {
initDefaultComposer(composerName);
}
return composersMap.get(composerName);
} | [
"public",
"IClientRequestComposable",
"getComposer",
"(",
"ClientRequestComposers",
"composerName",
")",
"{",
"IClientRequestComposable",
"composer",
"=",
"composersMap",
".",
"get",
"(",
"composerName",
")",
";",
"if",
"(",
"composer",
"==",
"null",
")",
"{",
"init... | get IClientRequestComposable based on ClientRequestComposers composer name
@param composerName
@return IClientRequestComposable composer | [
"get",
"IClientRequestComposable",
"based",
"on",
"ClientRequestComposers",
"composer",
"name"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/oauth/ClientRequestComposerProvider.java#L41-L47 |
124,659 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/WeightedSnapshot.java | WeightedSnapshot.getMean | @Override
public double getMean() {
if (values.length == 0) {
return 0;
}
double sum = 0;
for (int i = 0; i < values.length; i++) {
sum += values[i] * normWeights[i];
}
return sum;
} | java | @Override
public double getMean() {
if (values.length == 0) {
return 0;
}
double sum = 0;
for (int i = 0; i < values.length; i++) {
sum += values[i] * normWeights[i];
}
return sum;
} | [
"@",
"Override",
"public",
"double",
"getMean",
"(",
")",
"{",
"if",
"(",
"values",
".",
"length",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"double",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"... | Returns the weighted arithmetic mean of the values in the snapshot.
@return the weighted arithmetic mean | [
"Returns",
"the",
"weighted",
"arithmetic",
"mean",
"of",
"the",
"values",
"in",
"the",
"snapshot",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/WeightedSnapshot.java#L168-L179 |
124,660 | networknt/light-4j | metrics/src/main/java/io/dropwizard/metrics/WeightedSnapshot.java | WeightedSnapshot.getStdDev | @Override
public double getStdDev() {
// two-pass algorithm for variance, avoids numeric overflow
if (values.length <= 1) {
return 0;
}
final double mean = getMean();
double variance = 0;
for (int i = 0; i < values.length; i++) {
final doubl... | java | @Override
public double getStdDev() {
// two-pass algorithm for variance, avoids numeric overflow
if (values.length <= 1) {
return 0;
}
final double mean = getMean();
double variance = 0;
for (int i = 0; i < values.length; i++) {
final doubl... | [
"@",
"Override",
"public",
"double",
"getStdDev",
"(",
")",
"{",
"// two-pass algorithm for variance, avoids numeric overflow",
"if",
"(",
"values",
".",
"length",
"<=",
"1",
")",
"{",
"return",
"0",
";",
"}",
"final",
"double",
"mean",
"=",
"getMean",
"(",
")... | Returns the weighted standard deviation of the values in the snapshot.
@return the weighted standard deviation value | [
"Returns",
"the",
"weighted",
"standard",
"deviation",
"of",
"the",
"values",
"in",
"the",
"snapshot",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/metrics/src/main/java/io/dropwizard/metrics/WeightedSnapshot.java#L186-L203 |
124,661 | networknt/light-4j | handler/src/main/java/com/networknt/handler/config/PathChain.java | PathChain.validate | public void validate(String origin) {
List<String> problems = new ArrayList<>();
if(source == null) {
if(path == null) {
problems.add("You must specify either path or source");
} else if(method == null) {
problems.add("You must specify method along... | java | public void validate(String origin) {
List<String> problems = new ArrayList<>();
if(source == null) {
if(path == null) {
problems.add("You must specify either path or source");
} else if(method == null) {
problems.add("You must specify method along... | [
"public",
"void",
"validate",
"(",
"String",
"origin",
")",
"{",
"List",
"<",
"String",
">",
"problems",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"problems... | Validate the settings and raise Exception on error.
The origin is used to help locate problems.
@param origin the origin | [
"Validate",
"the",
"settings",
"and",
"raise",
"Exception",
"on",
"error",
".",
"The",
"origin",
"is",
"used",
"to",
"help",
"locate",
"problems",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/config/PathChain.java#L74-L96 |
124,662 | networknt/light-4j | consul/src/main/java/com/networknt/consul/ConsulRegistry.java | ConsulRegistry.startListenerThreadIfNewService | private void startListenerThreadIfNewService(URL url) {
String serviceName = url.getPath();
if (!lookupServices.containsKey(serviceName)) {
Long value = lookupServices.putIfAbsent(serviceName, 0L);
if (value == null) {
ServiceLookupThread lookupThread = new Servic... | java | private void startListenerThreadIfNewService(URL url) {
String serviceName = url.getPath();
if (!lookupServices.containsKey(serviceName)) {
Long value = lookupServices.putIfAbsent(serviceName, 0L);
if (value == null) {
ServiceLookupThread lookupThread = new Servic... | [
"private",
"void",
"startListenerThreadIfNewService",
"(",
"URL",
"url",
")",
"{",
"String",
"serviceName",
"=",
"url",
".",
"getPath",
"(",
")",
";",
"if",
"(",
"!",
"lookupServices",
".",
"containsKey",
"(",
"serviceName",
")",
")",
"{",
"Long",
"value",
... | if new service registered, start a new lookup thread
each serviceName start a lookup thread to discover service
@param url | [
"if",
"new",
"service",
"registered",
"start",
"a",
"new",
"lookup",
"thread",
"each",
"serviceName",
"start",
"a",
"lookup",
"thread",
"to",
"discover",
"service"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/consul/src/main/java/com/networknt/consul/ConsulRegistry.java#L118-L128 |
124,663 | networknt/light-4j | consul/src/main/java/com/networknt/consul/ConsulRegistry.java | ConsulRegistry.lookupConsulService | private ConsulResponse<List<ConsulService>> lookupConsulService(String serviceName, Long lastConsulIndexId) {
ConsulResponse<List<ConsulService>> response = client.lookupHealthService(serviceName, null, lastConsulIndexId, getConsulToken());
return response;
} | java | private ConsulResponse<List<ConsulService>> lookupConsulService(String serviceName, Long lastConsulIndexId) {
ConsulResponse<List<ConsulService>> response = client.lookupHealthService(serviceName, null, lastConsulIndexId, getConsulToken());
return response;
} | [
"private",
"ConsulResponse",
"<",
"List",
"<",
"ConsulService",
">",
">",
"lookupConsulService",
"(",
"String",
"serviceName",
",",
"Long",
"lastConsulIndexId",
")",
"{",
"ConsulResponse",
"<",
"List",
"<",
"ConsulService",
">>",
"response",
"=",
"client",
".",
... | directly fetch consul service data.
@param serviceName
@return ConsulResponse or null | [
"directly",
"fetch",
"consul",
"service",
"data",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/consul/src/main/java/com/networknt/consul/ConsulRegistry.java#L216-L219 |
124,664 | networknt/light-4j | consul/src/main/java/com/networknt/consul/ConsulRegistry.java | ConsulRegistry.updateServiceCache | private void updateServiceCache(String serviceName, ConcurrentHashMap<String, List<URL>> serviceUrls, boolean needNotify) {
if (serviceUrls != null && !serviceUrls.isEmpty()) {
List<URL> urls = serviceCache.get(serviceName);
if (urls == null) {
if(logger.isDebugEnabled())... | java | private void updateServiceCache(String serviceName, ConcurrentHashMap<String, List<URL>> serviceUrls, boolean needNotify) {
if (serviceUrls != null && !serviceUrls.isEmpty()) {
List<URL> urls = serviceCache.get(serviceName);
if (urls == null) {
if(logger.isDebugEnabled())... | [
"private",
"void",
"updateServiceCache",
"(",
"String",
"serviceName",
",",
"ConcurrentHashMap",
"<",
"String",
",",
"List",
"<",
"URL",
">",
">",
"serviceUrls",
",",
"boolean",
"needNotify",
")",
"{",
"if",
"(",
"serviceUrls",
"!=",
"null",
"&&",
"!",
"serv... | update service cache of the serviceName.
update local cache when service list changed,
if need notify, notify service
@param serviceName
@param serviceUrls
@param needNotify | [
"update",
"service",
"cache",
"of",
"the",
"serviceName",
".",
"update",
"local",
"cache",
"when",
"service",
"list",
"changed",
"if",
"need",
"notify",
"notify",
"service"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/consul/src/main/java/com/networknt/consul/ConsulRegistry.java#L230-L263 |
124,665 | networknt/light-4j | client/src/main/java/com/networknt/client/ssl/APINameChecker.java | APINameChecker.verifyAndThrow | public static void verifyAndThrow(final Set<String> nameSet, final X509Certificate cert) throws CertificateException{
if (!verify(nameSet, cert)) {
throw new CertificateException("No name matching " + nameSet + " found");
}
} | java | public static void verifyAndThrow(final Set<String> nameSet, final X509Certificate cert) throws CertificateException{
if (!verify(nameSet, cert)) {
throw new CertificateException("No name matching " + nameSet + " found");
}
} | [
"public",
"static",
"void",
"verifyAndThrow",
"(",
"final",
"Set",
"<",
"String",
">",
"nameSet",
",",
"final",
"X509Certificate",
"cert",
")",
"throws",
"CertificateException",
"{",
"if",
"(",
"!",
"verify",
"(",
"nameSet",
",",
"cert",
")",
")",
"{",
"th... | Perform server identify check using given names and throw CertificateException if the check fails.
@param nameSet - a set of names from the config file
@param cert - the server certificate
@throws CertificateException - throws CertificateException if none of the name in the nameSet matches the names in the cert | [
"Perform",
"server",
"identify",
"check",
"using",
"given",
"names",
"and",
"throw",
"CertificateException",
"if",
"the",
"check",
"fails",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/ssl/APINameChecker.java#L41-L45 |
124,666 | networknt/light-4j | client/src/main/java/com/networknt/client/ssl/APINameChecker.java | APINameChecker.verifyAndThrow | public static void verifyAndThrow(final String name, final X509Certificate cert) throws CertificateException{
if (!verify(name, cert)) {
throw new CertificateException("No name matching " + name + " found");
}
} | java | public static void verifyAndThrow(final String name, final X509Certificate cert) throws CertificateException{
if (!verify(name, cert)) {
throw new CertificateException("No name matching " + name + " found");
}
} | [
"public",
"static",
"void",
"verifyAndThrow",
"(",
"final",
"String",
"name",
",",
"final",
"X509Certificate",
"cert",
")",
"throws",
"CertificateException",
"{",
"if",
"(",
"!",
"verify",
"(",
"name",
",",
"cert",
")",
")",
"{",
"throw",
"new",
"Certificate... | Perform server identify check using given name and throw CertificateException if the check fails.
@param name
@param cert
@throws CertificateException | [
"Perform",
"server",
"identify",
"check",
"using",
"given",
"name",
"and",
"throw",
"CertificateException",
"if",
"the",
"check",
"fails",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/ssl/APINameChecker.java#L54-L58 |
124,667 | networknt/light-4j | client/src/main/java/com/networknt/client/Http2Client.java | Http2Client.addAuthToken | public void addAuthToken(ClientRequest request, String token) {
if(token != null && !token.startsWith("Bearer ")) {
if(token.toUpperCase().startsWith("BEARER ")) {
// other cases of Bearer
token = "Bearer " + token.substring(7);
} else {
to... | java | public void addAuthToken(ClientRequest request, String token) {
if(token != null && !token.startsWith("Bearer ")) {
if(token.toUpperCase().startsWith("BEARER ")) {
// other cases of Bearer
token = "Bearer " + token.substring(7);
} else {
to... | [
"public",
"void",
"addAuthToken",
"(",
"ClientRequest",
"request",
",",
"String",
"token",
")",
"{",
"if",
"(",
"token",
"!=",
"null",
"&&",
"!",
"token",
".",
"startsWith",
"(",
"\"Bearer \"",
")",
")",
"{",
"if",
"(",
"token",
".",
"toUpperCase",
"(",
... | Add Authorization Code grant token the caller app gets from OAuth2 server.
This is the method called from client like web server
@param request the http request
@param token the bearer token | [
"Add",
"Authorization",
"Code",
"grant",
"token",
"the",
"caller",
"app",
"gets",
"from",
"OAuth2",
"server",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/Http2Client.java#L273-L283 |
124,668 | networknt/light-4j | client/src/main/java/com/networknt/client/Http2Client.java | Http2Client.addAuthTokenTrace | public void addAuthTokenTrace(ClientRequest request, String token, String traceabilityId) {
if(token != null && !token.startsWith("Bearer ")) {
if(token.toUpperCase().startsWith("BEARER ")) {
// other cases of Bearer
token = "Bearer " + token.substring(7);
... | java | public void addAuthTokenTrace(ClientRequest request, String token, String traceabilityId) {
if(token != null && !token.startsWith("Bearer ")) {
if(token.toUpperCase().startsWith("BEARER ")) {
// other cases of Bearer
token = "Bearer " + token.substring(7);
... | [
"public",
"void",
"addAuthTokenTrace",
"(",
"ClientRequest",
"request",
",",
"String",
"token",
",",
"String",
"traceabilityId",
")",
"{",
"if",
"(",
"token",
"!=",
"null",
"&&",
"!",
"token",
".",
"startsWith",
"(",
"\"Bearer \"",
")",
")",
"{",
"if",
"("... | Add Authorization Code grant token the caller app gets from OAuth2 server and add traceabilityId
This is the method called from client like web server that want to have traceabilityId pass through.
@param request the http request
@param token the bearer token
@param traceabilityId the traceability id | [
"Add",
"Authorization",
"Code",
"grant",
"token",
"the",
"caller",
"app",
"gets",
"from",
"OAuth2",
"server",
"and",
"add",
"traceabilityId"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/Http2Client.java#L294-L305 |
124,669 | networknt/light-4j | client/src/main/java/com/networknt/client/Http2Client.java | Http2Client.propagateHeaders | public Result propagateHeaders(ClientRequest request, final HttpServerExchange exchange) {
String tid = exchange.getRequestHeaders().getFirst(HttpStringConstants.TRACEABILITY_ID);
String token = exchange.getRequestHeaders().getFirst(Headers.AUTHORIZATION);
String cid = exchange.getRequestHeaders... | java | public Result propagateHeaders(ClientRequest request, final HttpServerExchange exchange) {
String tid = exchange.getRequestHeaders().getFirst(HttpStringConstants.TRACEABILITY_ID);
String token = exchange.getRequestHeaders().getFirst(Headers.AUTHORIZATION);
String cid = exchange.getRequestHeaders... | [
"public",
"Result",
"propagateHeaders",
"(",
"ClientRequest",
"request",
",",
"final",
"HttpServerExchange",
"exchange",
")",
"{",
"String",
"tid",
"=",
"exchange",
".",
"getRequestHeaders",
"(",
")",
".",
"getFirst",
"(",
"HttpStringConstants",
".",
"TRACEABILITY_I... | Support API to API calls with scope token. The token is the original token from consumer and
the client credentials token of caller API is added from cache.
This method is used in API to API call
@param request the http request
@param exchange the http server exchange | [
"Support",
"API",
"to",
"API",
"calls",
"with",
"scope",
"token",
".",
"The",
"token",
"is",
"the",
"original",
"token",
"from",
"consumer",
"and",
"the",
"client",
"credentials",
"token",
"of",
"caller",
"API",
"is",
"added",
"from",
"cache",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/Http2Client.java#L350-L355 |
124,670 | networknt/light-4j | client/src/main/java/com/networknt/client/Http2Client.java | Http2Client.populateHeader | public Result populateHeader(ClientRequest request, String authToken, String correlationId, String traceabilityId) {
if(traceabilityId != null) {
addAuthTokenTrace(request, authToken, traceabilityId);
} else {
addAuthToken(request, authToken);
}
Result<Jwt> result... | java | public Result populateHeader(ClientRequest request, String authToken, String correlationId, String traceabilityId) {
if(traceabilityId != null) {
addAuthTokenTrace(request, authToken, traceabilityId);
} else {
addAuthToken(request, authToken);
}
Result<Jwt> result... | [
"public",
"Result",
"populateHeader",
"(",
"ClientRequest",
"request",
",",
"String",
"authToken",
",",
"String",
"correlationId",
",",
"String",
"traceabilityId",
")",
"{",
"if",
"(",
"traceabilityId",
"!=",
"null",
")",
"{",
"addAuthTokenTrace",
"(",
"request",
... | Support API to API calls with scope token. The token is the original token from consumer and
the client credentials token of caller API is added from cache. authToken, correlationId and
traceabilityId are passed in as strings.
This method is used in API to API call
@param request the http request
@param authToken the... | [
"Support",
"API",
"to",
"API",
"calls",
"with",
"scope",
"token",
".",
"The",
"token",
"is",
"the",
"original",
"token",
"from",
"consumer",
"and",
"the",
"client",
"credentials",
"token",
"of",
"caller",
"API",
"is",
"added",
"from",
"cache",
".",
"authTo... | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/Http2Client.java#L370-L381 |
124,671 | networknt/light-4j | client/src/main/java/com/networknt/client/Http2Client.java | Http2Client.createSSLContext | public static SSLContext createSSLContext() throws IOException {
Map<String, Object> tlsMap = (Map<String, Object>)ClientConfig.get().getMappedConfig().get(TLS);
return null==tlsMap?null:createSSLContext((String)tlsMap.get(TLSConfig.DEFAULT_GROUP_KEY));
} | java | public static SSLContext createSSLContext() throws IOException {
Map<String, Object> tlsMap = (Map<String, Object>)ClientConfig.get().getMappedConfig().get(TLS);
return null==tlsMap?null:createSSLContext((String)tlsMap.get(TLSConfig.DEFAULT_GROUP_KEY));
} | [
"public",
"static",
"SSLContext",
"createSSLContext",
"(",
")",
"throws",
"IOException",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"tlsMap",
"=",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"ClientConfig",
".",
"get",
"(",
")",
".",
"getMapp... | default method for creating ssl context. trustedNames config is not used.
@return SSLContext
@throws IOException | [
"default",
"method",
"for",
"creating",
"ssl",
"context",
".",
"trustedNames",
"config",
"is",
"not",
"used",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/Http2Client.java#L408-L412 |
124,672 | networknt/light-4j | client/src/main/java/com/networknt/client/Http2Client.java | Http2Client.connectAsync | public CompletableFuture<ClientConnection> connectAsync(URI uri) {
return this.connectAsync(null, uri, com.networknt.client.Http2Client.WORKER, com.networknt.client.Http2Client.SSL, com.networknt.client.Http2Client.BUFFER_POOL,
OptionMap.create(UndertowOptions.ENABLE_HTTP2, true));
} | java | public CompletableFuture<ClientConnection> connectAsync(URI uri) {
return this.connectAsync(null, uri, com.networknt.client.Http2Client.WORKER, com.networknt.client.Http2Client.SSL, com.networknt.client.Http2Client.BUFFER_POOL,
OptionMap.create(UndertowOptions.ENABLE_HTTP2, true));
} | [
"public",
"CompletableFuture",
"<",
"ClientConnection",
">",
"connectAsync",
"(",
"URI",
"uri",
")",
"{",
"return",
"this",
".",
"connectAsync",
"(",
"null",
",",
"uri",
",",
"com",
".",
"networknt",
".",
"client",
".",
"Http2Client",
".",
"WORKER",
",",
"... | Create async connection with default config value | [
"Create",
"async",
"connection",
"with",
"default",
"config",
"value"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/Http2Client.java#L714-L717 |
124,673 | networknt/light-4j | utility/src/main/java/com/networknt/utility/CharSequenceUtils.java | CharSequenceUtils.toCharArray | static char[] toCharArray(final CharSequence cs) {
if (cs instanceof String) {
return ((String) cs).toCharArray();
}
final int sz = cs.length();
final char[] array = new char[cs.length()];
for (int i = 0; i < sz; i++) {
array[i] = cs.charAt(i);
}
... | java | static char[] toCharArray(final CharSequence cs) {
if (cs instanceof String) {
return ((String) cs).toCharArray();
}
final int sz = cs.length();
final char[] array = new char[cs.length()];
for (int i = 0; i < sz; i++) {
array[i] = cs.charAt(i);
}
... | [
"static",
"char",
"[",
"]",
"toCharArray",
"(",
"final",
"CharSequence",
"cs",
")",
"{",
"if",
"(",
"cs",
"instanceof",
"String",
")",
"{",
"return",
"(",
"(",
"String",
")",
"cs",
")",
".",
"toCharArray",
"(",
")",
";",
"}",
"final",
"int",
"sz",
... | Green implementation of toCharArray.
@param cs the {@code CharSequence} to be processed
@return the resulting char array | [
"Green",
"implementation",
"of",
"toCharArray",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/CharSequenceUtils.java#L239-L249 |
124,674 | networknt/light-4j | utility/src/main/java/com/networknt/utility/CharSequenceUtils.java | CharSequenceUtils.regionMatches | static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, final int thisStart,
final CharSequence substring, final int start, final int length) {
if (cs instanceof String && substring instanceof String) {
return ((String) cs).regionMatches(igno... | java | static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, final int thisStart,
final CharSequence substring, final int start, final int length) {
if (cs instanceof String && substring instanceof String) {
return ((String) cs).regionMatches(igno... | [
"static",
"boolean",
"regionMatches",
"(",
"final",
"CharSequence",
"cs",
",",
"final",
"boolean",
"ignoreCase",
",",
"final",
"int",
"thisStart",
",",
"final",
"CharSequence",
"substring",
",",
"final",
"int",
"start",
",",
"final",
"int",
"length",
")",
"{",... | Green implementation of regionMatches.
@param cs the {@code CharSequence} to be processed
@param ignoreCase whether or not to be case insensitive
@param thisStart the index to start on the {@code cs} CharSequence
@param substring the {@code CharSequence} to be looked for
@param start the index to start on the {@code s... | [
"Green",
"implementation",
"of",
"regionMatches",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/CharSequenceUtils.java#L262-L305 |
124,675 | networknt/light-4j | utility/src/main/java/com/networknt/utility/NioUtils.java | NioUtils.createZipFileSystem | private static FileSystem createZipFileSystem(String zipFilename, boolean create) throws IOException {
// convert the filename to a URI
final Path path = Paths.get(zipFilename);
if(Files.notExists(path.getParent())) {
Files.createDirectories(path.getParent());
}
fina... | java | private static FileSystem createZipFileSystem(String zipFilename, boolean create) throws IOException {
// convert the filename to a URI
final Path path = Paths.get(zipFilename);
if(Files.notExists(path.getParent())) {
Files.createDirectories(path.getParent());
}
fina... | [
"private",
"static",
"FileSystem",
"createZipFileSystem",
"(",
"String",
"zipFilename",
",",
"boolean",
"create",
")",
"throws",
"IOException",
"{",
"// convert the filename to a URI",
"final",
"Path",
"path",
"=",
"Paths",
".",
"get",
"(",
"zipFilename",
")",
";",
... | Returns a zip file system
@param zipFilename to construct the file system from
@param create true if the zip file should be created
@return a zip file system
@throws IOException | [
"Returns",
"a",
"zip",
"file",
"system"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/NioUtils.java#L54-L68 |
124,676 | networknt/light-4j | utility/src/main/java/com/networknt/utility/NioUtils.java | NioUtils.list | public static void list(String zipFilename) throws IOException{
if(logger.isDebugEnabled()) logger.debug("Listing Archive: %s",zipFilename);
//create the file system
try (FileSystem zipFileSystem = createZipFileSystem(zipFilename, false)) {
final Path root = zipFileSystem.getPath(... | java | public static void list(String zipFilename) throws IOException{
if(logger.isDebugEnabled()) logger.debug("Listing Archive: %s",zipFilename);
//create the file system
try (FileSystem zipFileSystem = createZipFileSystem(zipFilename, false)) {
final Path root = zipFileSystem.getPath(... | [
"public",
"static",
"void",
"list",
"(",
"String",
"zipFilename",
")",
"throws",
"IOException",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"Listing Archive: %s\"",
",",
"zipFilename",
")",
";",
"//create the... | List the contents of the specified zip file
@param zipFilename zip filename
@throws IOException IOException | [
"List",
"the",
"contents",
"of",
"the",
"specified",
"zip",
"file"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/NioUtils.java#L179-L222 |
124,677 | networknt/light-4j | utility/src/main/java/com/networknt/utility/NioUtils.java | NioUtils.deleteOldFiles | public static void deleteOldFiles(String dirPath, int olderThanMinute) {
File folder = new File(dirPath);
if (folder.exists()) {
File[] listFiles = folder.listFiles();
long eligibleForDeletion = System.currentTimeMillis() - (olderThanMinute * 60 * 1000L);
for (File ... | java | public static void deleteOldFiles(String dirPath, int olderThanMinute) {
File folder = new File(dirPath);
if (folder.exists()) {
File[] listFiles = folder.listFiles();
long eligibleForDeletion = System.currentTimeMillis() - (olderThanMinute * 60 * 1000L);
for (File ... | [
"public",
"static",
"void",
"deleteOldFiles",
"(",
"String",
"dirPath",
",",
"int",
"olderThanMinute",
")",
"{",
"File",
"folder",
"=",
"new",
"File",
"(",
"dirPath",
")",
";",
"if",
"(",
"folder",
".",
"exists",
"(",
")",
")",
"{",
"File",
"[",
"]",
... | Delele old files
@param dirPath path of the filesystem
@param olderThanMinute the minutes that defines older files | [
"Delele",
"old",
"files"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/NioUtils.java#L230-L244 |
124,678 | networknt/light-4j | utility/src/main/java/com/networknt/utility/NioUtils.java | NioUtils.toByteBuffer | public static ByteBuffer toByteBuffer(String s) {
ByteBuffer buffer = ByteBuffer.allocateDirect(s.length());
buffer.put(s.getBytes(UTF_8));
buffer.flip();
return buffer;
} | java | public static ByteBuffer toByteBuffer(String s) {
ByteBuffer buffer = ByteBuffer.allocateDirect(s.length());
buffer.put(s.getBytes(UTF_8));
buffer.flip();
return buffer;
} | [
"public",
"static",
"ByteBuffer",
"toByteBuffer",
"(",
"String",
"s",
")",
"{",
"ByteBuffer",
"buffer",
"=",
"ByteBuffer",
".",
"allocateDirect",
"(",
"s",
".",
"length",
"(",
")",
")",
";",
"buffer",
".",
"put",
"(",
"s",
".",
"getBytes",
"(",
"UTF_8",
... | convert String to ByteBuffer
@param s string to be converted
@return ByteBuffer the result ByteBuffer | [
"convert",
"String",
"to",
"ByteBuffer"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/NioUtils.java#L251-L256 |
124,679 | networknt/light-4j | utility/src/main/java/com/networknt/utility/NioUtils.java | NioUtils.toByteBuffer | public static ByteBuffer toByteBuffer(File file) {
ByteBuffer buffer = ByteBuffer.allocateDirect((int) file.length());
try {
buffer.put(toByteArray(new FileInputStream(file)));
} catch (IOException e) {
logger.error("Failed to write file to byte array: " + e.getMessage())... | java | public static ByteBuffer toByteBuffer(File file) {
ByteBuffer buffer = ByteBuffer.allocateDirect((int) file.length());
try {
buffer.put(toByteArray(new FileInputStream(file)));
} catch (IOException e) {
logger.error("Failed to write file to byte array: " + e.getMessage())... | [
"public",
"static",
"ByteBuffer",
"toByteBuffer",
"(",
"File",
"file",
")",
"{",
"ByteBuffer",
"buffer",
"=",
"ByteBuffer",
".",
"allocateDirect",
"(",
"(",
"int",
")",
"file",
".",
"length",
"(",
")",
")",
";",
"try",
"{",
"buffer",
".",
"put",
"(",
"... | Convert a File into a ByteBuffer
@param file File to be converted
@return ByteBuffer containing the file | [
"Convert",
"a",
"File",
"into",
"a",
"ByteBuffer"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/NioUtils.java#L263-L272 |
124,680 | networknt/light-4j | utility/src/main/java/com/networknt/utility/NioUtils.java | NioUtils.getTempDir | public static String getTempDir() {
// default is user home directory
String tempDir = System.getProperty("user.home");
try{
//create a temp file
File temp = File.createTempFile("A0393939", ".tmp");
//Get tempropary file path
String absolutePath = ... | java | public static String getTempDir() {
// default is user home directory
String tempDir = System.getProperty("user.home");
try{
//create a temp file
File temp = File.createTempFile("A0393939", ".tmp");
//Get tempropary file path
String absolutePath = ... | [
"public",
"static",
"String",
"getTempDir",
"(",
")",
"{",
"// default is user home directory",
"String",
"tempDir",
"=",
"System",
".",
"getProperty",
"(",
"\"user.home\"",
")",
";",
"try",
"{",
"//create a temp file",
"File",
"temp",
"=",
"File",
".",
"createTem... | get temp dir from OS.
@return String temp dir | [
"get",
"temp",
"dir",
"from",
"OS",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/NioUtils.java#L279-L290 |
124,681 | networknt/light-4j | utility/src/main/java/com/networknt/utility/NioUtils.java | NioUtils.toByteArray | public static byte[] toByteArray(InputStream is) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
byte[] b = new byte[BUFFER_SIZE];
int n = 0;
while ((n = is.read(b)) != -1) {
output.write(b, 0, n);
}
... | java | public static byte[] toByteArray(InputStream is) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
byte[] b = new byte[BUFFER_SIZE];
int n = 0;
while ((n = is.read(b)) != -1) {
output.write(b, 0, n);
}
... | [
"public",
"static",
"byte",
"[",
"]",
"toByteArray",
"(",
"InputStream",
"is",
")",
"throws",
"IOException",
"{",
"ByteArrayOutputStream",
"output",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"try",
"{",
"byte",
"[",
"]",
"b",
"=",
"new",
"byte",
... | Reads and returns the rest of the given input stream as a byte array.
Caller is responsible for closing the given input stream.
@param is input stream
@return byte[] byte array
@throws IOException IOException | [
"Reads",
"and",
"returns",
"the",
"rest",
"of",
"the",
"given",
"input",
"stream",
"as",
"a",
"byte",
"array",
".",
"Caller",
"is",
"responsible",
"for",
"closing",
"the",
"given",
"input",
"stream",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/NioUtils.java#L299-L311 |
124,682 | networknt/light-4j | config/src/main/java/com/networknt/config/ConfigInjection.java | ConfigInjection.getInjectValue | public static Object getInjectValue(String string) {
Matcher m = pattern.matcher(string);
StringBuffer sb = new StringBuffer();
// Parse the content inside pattern "${}" when this pattern is found
while (m.find()) {
// Get parsing result
Object value = getValue(m.... | java | public static Object getInjectValue(String string) {
Matcher m = pattern.matcher(string);
StringBuffer sb = new StringBuffer();
// Parse the content inside pattern "${}" when this pattern is found
while (m.find()) {
// Get parsing result
Object value = getValue(m.... | [
"public",
"static",
"Object",
"getInjectValue",
"(",
"String",
"string",
")",
"{",
"Matcher",
"m",
"=",
"pattern",
".",
"matcher",
"(",
"string",
")",
";",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"// Parse the content inside pattern \"${... | Method used to generate the values from environment variables or "values.yaml" | [
"Method",
"used",
"to",
"generate",
"the",
"values",
"from",
"environment",
"variables",
"or",
"values",
".",
"yaml"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/config/src/main/java/com/networknt/config/ConfigInjection.java#L61-L75 |
124,683 | networknt/light-4j | config/src/main/java/com/networknt/config/ConfigInjection.java | ConfigInjection.isExclusionConfigFile | public static boolean isExclusionConfigFile(String configName) {
List<Object> exclusionConfigFileList = (exclusionMap == null) ? new ArrayList<>() : (List<Object>) exclusionMap.get(EXCLUSION_CONFIG_FILE_LIST);
return CENTRALIZED_MANAGEMENT.equals(configName)
|| SCALABLE_CONFIG.equals(con... | java | public static boolean isExclusionConfigFile(String configName) {
List<Object> exclusionConfigFileList = (exclusionMap == null) ? new ArrayList<>() : (List<Object>) exclusionMap.get(EXCLUSION_CONFIG_FILE_LIST);
return CENTRALIZED_MANAGEMENT.equals(configName)
|| SCALABLE_CONFIG.equals(con... | [
"public",
"static",
"boolean",
"isExclusionConfigFile",
"(",
"String",
"configName",
")",
"{",
"List",
"<",
"Object",
">",
"exclusionConfigFileList",
"=",
"(",
"exclusionMap",
"==",
"null",
")",
"?",
"new",
"ArrayList",
"<>",
"(",
")",
":",
"(",
"List",
"<",... | Double check values and exclusions to ensure no dead loop | [
"Double",
"check",
"values",
"and",
"exclusions",
"to",
"ensure",
"no",
"dead",
"loop"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/config/src/main/java/com/networknt/config/ConfigInjection.java#L79-L84 |
124,684 | networknt/light-4j | config/src/main/java/com/networknt/config/ConfigInjection.java | ConfigInjection.typeCast | private static Object typeCast(String str) {
if (str == null || str.equals("")) {
return null;
}
// Try to cast to boolean true
for (String trueString : trueArray) {
if (trueString.equals(str)) {
return true;
}
}
// Try ... | java | private static Object typeCast(String str) {
if (str == null || str.equals("")) {
return null;
}
// Try to cast to boolean true
for (String trueString : trueArray) {
if (trueString.equals(str)) {
return true;
}
}
// Try ... | [
"private",
"static",
"Object",
"typeCast",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"null",
"||",
"str",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"null",
";",
"}",
"// Try to cast to boolean true",
"for",
"(",
"String",
"trueSt... | Method used to cast string into int, double or boolean | [
"Method",
"used",
"to",
"cast",
"string",
"into",
"int",
"double",
"or",
"boolean"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/config/src/main/java/com/networknt/config/ConfigInjection.java#L193-L219 |
124,685 | networknt/light-4j | dump/src/main/java/com/networknt/dump/DumperFactory.java | DumperFactory.createRequestDumpers | public List<IRequestDumpable> createRequestDumpers(DumpConfig config, HttpServerExchange exchange) {
RequestDumperFactory factory = new RequestDumperFactory();
List<IRequestDumpable> dumpers = new ArrayList<>();
for(String dumperNames: requestDumpers) {
IRequestDumpable dumper = fac... | java | public List<IRequestDumpable> createRequestDumpers(DumpConfig config, HttpServerExchange exchange) {
RequestDumperFactory factory = new RequestDumperFactory();
List<IRequestDumpable> dumpers = new ArrayList<>();
for(String dumperNames: requestDumpers) {
IRequestDumpable dumper = fac... | [
"public",
"List",
"<",
"IRequestDumpable",
">",
"createRequestDumpers",
"(",
"DumpConfig",
"config",
",",
"HttpServerExchange",
"exchange",
")",
"{",
"RequestDumperFactory",
"factory",
"=",
"new",
"RequestDumperFactory",
"(",
")",
";",
"List",
"<",
"IRequestDumpable",... | use RequestDumperFactory to create dumpers listed in this.requestDumpers
@param config type: DumpConfig
@param exchange type: HttpServerExchange
@return a list of IRequestDumpable, dumpers can dump http request info | [
"use",
"RequestDumperFactory",
"to",
"create",
"dumpers",
"listed",
"in",
"this",
".",
"requestDumpers"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/DumperFactory.java#L45-L54 |
124,686 | networknt/light-4j | dump/src/main/java/com/networknt/dump/DumperFactory.java | DumperFactory.createResponseDumpers | public List<IResponseDumpable> createResponseDumpers(DumpConfig config, HttpServerExchange exchange) {
ResponseDumperFactory factory = new ResponseDumperFactory();
List<IResponseDumpable> dumpers = new ArrayList<>();
for(String dumperNames: responseDumpers) {
IResponseDumpable dumper... | java | public List<IResponseDumpable> createResponseDumpers(DumpConfig config, HttpServerExchange exchange) {
ResponseDumperFactory factory = new ResponseDumperFactory();
List<IResponseDumpable> dumpers = new ArrayList<>();
for(String dumperNames: responseDumpers) {
IResponseDumpable dumper... | [
"public",
"List",
"<",
"IResponseDumpable",
">",
"createResponseDumpers",
"(",
"DumpConfig",
"config",
",",
"HttpServerExchange",
"exchange",
")",
"{",
"ResponseDumperFactory",
"factory",
"=",
"new",
"ResponseDumperFactory",
"(",
")",
";",
"List",
"<",
"IResponseDumpa... | use ResponseDumperFactory to create dumpers listed in this.responseDumpers
@param config type: DumpConfig
@param exchange type: HttpServerExchange
@return a list of IResponseDumpable, dumpers can dump http response info | [
"use",
"ResponseDumperFactory",
"to",
"create",
"dumpers",
"listed",
"in",
"this",
".",
"responseDumpers"
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/dump/src/main/java/com/networknt/dump/DumperFactory.java#L62-L70 |
124,687 | networknt/light-4j | cors/src/main/java/com/networknt/cors/CorsUtil.java | CorsUtil.defaultOrigin | public static String defaultOrigin(HttpServerExchange exchange) {
String host = NetworkUtils.formatPossibleIpv6Address(exchange.getHostName());
String protocol = exchange.getRequestScheme();
int port = exchange.getHostPort();
//This browser set header should not need IPv6 escaping
... | java | public static String defaultOrigin(HttpServerExchange exchange) {
String host = NetworkUtils.formatPossibleIpv6Address(exchange.getHostName());
String protocol = exchange.getRequestScheme();
int port = exchange.getHostPort();
//This browser set header should not need IPv6 escaping
... | [
"public",
"static",
"String",
"defaultOrigin",
"(",
"HttpServerExchange",
"exchange",
")",
"{",
"String",
"host",
"=",
"NetworkUtils",
".",
"formatPossibleIpv6Address",
"(",
"exchange",
".",
"getHostName",
"(",
")",
")",
";",
"String",
"protocol",
"=",
"exchange",... | Determine the default origin, to allow for local access.
@param exchange the current HttpExchange.
@return the default origin (aka current server). | [
"Determine",
"the",
"default",
"origin",
"to",
"allow",
"for",
"local",
"access",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/cors/src/main/java/com/networknt/cors/CorsUtil.java#L87-L98 |
124,688 | networknt/light-4j | cors/src/main/java/com/networknt/cors/CorsUtil.java | CorsUtil.sanitizeDefaultPort | public static String sanitizeDefaultPort(String url) {
int afterSchemeIndex = url.indexOf("://");
if(afterSchemeIndex < 0) {
return url;
}
String scheme = url.substring(0, afterSchemeIndex);
int fromIndex = scheme.length() + 3;
//Let's see if it is an IPv6 Add... | java | public static String sanitizeDefaultPort(String url) {
int afterSchemeIndex = url.indexOf("://");
if(afterSchemeIndex < 0) {
return url;
}
String scheme = url.substring(0, afterSchemeIndex);
int fromIndex = scheme.length() + 3;
//Let's see if it is an IPv6 Add... | [
"public",
"static",
"String",
"sanitizeDefaultPort",
"(",
"String",
"url",
")",
"{",
"int",
"afterSchemeIndex",
"=",
"url",
".",
"indexOf",
"(",
"\"://\"",
")",
";",
"if",
"(",
"afterSchemeIndex",
"<",
"0",
")",
"{",
"return",
"url",
";",
"}",
"String",
... | Removes the port from a URL if this port is the default one for the URL's scheme.
@param url the url to be sanitized.
@return the sanitized url. | [
"Removes",
"the",
"port",
"from",
"a",
"URL",
"if",
"this",
"port",
"is",
"the",
"default",
"one",
"for",
"the",
"URL",
"s",
"scheme",
"."
] | 2a60257c60663684c8f6dc8b5ea3cf184e534db6 | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/cors/src/main/java/com/networknt/cors/CorsUtil.java#L109-L129 |
124,689 | alibaba/canal | client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java | MutablePropertySources.addFirst | public void addFirst(PropertySource<?> propertySource) {
if (logger.isDebugEnabled()) {
logger.debug("Adding PropertySource '" + propertySource.getName() + "' with highest search precedence");
}
removeIfPresent(propertySource);
this.propertySourceList.add(0, propertySource);
... | java | public void addFirst(PropertySource<?> propertySource) {
if (logger.isDebugEnabled()) {
logger.debug("Adding PropertySource '" + propertySource.getName() + "' with highest search precedence");
}
removeIfPresent(propertySource);
this.propertySourceList.add(0, propertySource);
... | [
"public",
"void",
"addFirst",
"(",
"PropertySource",
"<",
"?",
">",
"propertySource",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Adding PropertySource '\"",
"+",
"propertySource",
".",
"getName",
... | Add the given property source object with highest precedence. | [
"Add",
"the",
"given",
"property",
"source",
"object",
"with",
"highest",
"precedence",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java#L81-L87 |
124,690 | alibaba/canal | client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java | MutablePropertySources.addBefore | public void addBefore(String relativePropertySourceName, PropertySource<?> propertySource) {
if (logger.isDebugEnabled()) {
logger.debug("Adding PropertySource '" + propertySource.getName()
+ "' with search precedence immediately higher than '" + relativePropertySourceName +... | java | public void addBefore(String relativePropertySourceName, PropertySource<?> propertySource) {
if (logger.isDebugEnabled()) {
logger.debug("Adding PropertySource '" + propertySource.getName()
+ "' with search precedence immediately higher than '" + relativePropertySourceName +... | [
"public",
"void",
"addBefore",
"(",
"String",
"relativePropertySourceName",
",",
"PropertySource",
"<",
"?",
">",
"propertySource",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Adding PropertySource '\... | Add the given property source object with precedence immediately higher than
the named relative property source. | [
"Add",
"the",
"given",
"property",
"source",
"object",
"with",
"precedence",
"immediately",
"higher",
"than",
"the",
"named",
"relative",
"property",
"source",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java#L104-L113 |
124,691 | alibaba/canal | client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java | MutablePropertySources.replace | public void replace(String name, PropertySource<?> propertySource) {
if (logger.isDebugEnabled()) {
logger.debug("Replacing PropertySource '" + name + "' with '" + propertySource.getName() + "'");
}
int index = assertPresentAndGetIndex(name);
this.propertySourceList.set(index... | java | public void replace(String name, PropertySource<?> propertySource) {
if (logger.isDebugEnabled()) {
logger.debug("Replacing PropertySource '" + name + "' with '" + propertySource.getName() + "'");
}
int index = assertPresentAndGetIndex(name);
this.propertySourceList.set(index... | [
"public",
"void",
"replace",
"(",
"String",
"name",
",",
"PropertySource",
"<",
"?",
">",
"propertySource",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Replacing PropertySource '\"",
"+",
"name",
... | Replace the property source with the given name with the given property
source object.
@param name the name of the property source to find and replace
@param propertySource the replacement property source
@throws IllegalArgumentException if no property source with the given name is
present
@see #contains | [
"Replace",
"the",
"property",
"source",
"with",
"the",
"given",
"name",
"with",
"the",
"given",
"property",
"source",
"object",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java#L161-L167 |
124,692 | alibaba/canal | client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java | MutablePropertySources.assertLegalRelativeAddition | protected void assertLegalRelativeAddition(String relativePropertySourceName, PropertySource<?> propertySource) {
String newPropertySourceName = propertySource.getName();
if (relativePropertySourceName.equals(newPropertySourceName)) {
throw new IllegalArgumentException(
"Prop... | java | protected void assertLegalRelativeAddition(String relativePropertySourceName, PropertySource<?> propertySource) {
String newPropertySourceName = propertySource.getName();
if (relativePropertySourceName.equals(newPropertySourceName)) {
throw new IllegalArgumentException(
"Prop... | [
"protected",
"void",
"assertLegalRelativeAddition",
"(",
"String",
"relativePropertySourceName",
",",
"PropertySource",
"<",
"?",
">",
"propertySource",
")",
"{",
"String",
"newPropertySourceName",
"=",
"propertySource",
".",
"getName",
"(",
")",
";",
"if",
"(",
"re... | Ensure that the given property source is not being added relative to itself. | [
"Ensure",
"that",
"the",
"given",
"property",
"source",
"is",
"not",
"being",
"added",
"relative",
"to",
"itself",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java#L184-L190 |
124,693 | alibaba/canal | client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java | MutablePropertySources.addAtIndex | private void addAtIndex(int index, PropertySource<?> propertySource) {
removeIfPresent(propertySource);
this.propertySourceList.add(index, propertySource);
} | java | private void addAtIndex(int index, PropertySource<?> propertySource) {
removeIfPresent(propertySource);
this.propertySourceList.add(index, propertySource);
} | [
"private",
"void",
"addAtIndex",
"(",
"int",
"index",
",",
"PropertySource",
"<",
"?",
">",
"propertySource",
")",
"{",
"removeIfPresent",
"(",
"propertySource",
")",
";",
"this",
".",
"propertySourceList",
".",
"add",
"(",
"index",
",",
"propertySource",
")",... | Add the given property source at a particular index in the list. | [
"Add",
"the",
"given",
"property",
"source",
"at",
"a",
"particular",
"index",
"in",
"the",
"list",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java#L202-L205 |
124,694 | alibaba/canal | client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java | MutablePropertySources.assertPresentAndGetIndex | private int assertPresentAndGetIndex(String name) {
int index = this.propertySourceList.indexOf(PropertySource.named(name));
if (index == -1) {
throw new IllegalArgumentException("PropertySource named '" + name + "' does not exist");
}
return index;
} | java | private int assertPresentAndGetIndex(String name) {
int index = this.propertySourceList.indexOf(PropertySource.named(name));
if (index == -1) {
throw new IllegalArgumentException("PropertySource named '" + name + "' does not exist");
}
return index;
} | [
"private",
"int",
"assertPresentAndGetIndex",
"(",
"String",
"name",
")",
"{",
"int",
"index",
"=",
"this",
".",
"propertySourceList",
".",
"indexOf",
"(",
"PropertySource",
".",
"named",
"(",
"name",
")",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")... | Assert that the named property source is present and return its index.
@param name {@linkplain PropertySource#getName() name of the property source}
to find
@throws IllegalArgumentException if the named property source is not present | [
"Assert",
"that",
"the",
"named",
"property",
"source",
"is",
"present",
"and",
"return",
"its",
"index",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java#L214-L220 |
124,695 | alibaba/canal | client/src/main/java/com/alibaba/otter/canal/client/rocketmq/ConsumerBatchMessage.java | ConsumerBatchMessage.fail | public void fail() {
hasFailure = true;
// fail fast
long count = latch.getCount();
for (int i = 0; i < count; i++) {
latch.countDown();
}
} | java | public void fail() {
hasFailure = true;
// fail fast
long count = latch.getCount();
for (int i = 0; i < count; i++) {
latch.countDown();
}
} | [
"public",
"void",
"fail",
"(",
")",
"{",
"hasFailure",
"=",
"true",
";",
"// fail fast",
"long",
"count",
"=",
"latch",
".",
"getCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"latch",
... | Countdown and fail-fast if the sub message is failed. | [
"Countdown",
"and",
"fail",
"-",
"fast",
"if",
"the",
"sub",
"message",
"is",
"failed",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client/src/main/java/com/alibaba/otter/canal/client/rocketmq/ConsumerBatchMessage.java#L40-L47 |
124,696 | alibaba/canal | dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcher.java | DirectLogFetcher.putInt16 | protected final void putInt16(int i16) {
ensureCapacity(position + 2);
byte[] buf = buffer;
buf[position++] = (byte) (i16 & 0xff);
buf[position++] = (byte) (i16 >>> 8);
} | java | protected final void putInt16(int i16) {
ensureCapacity(position + 2);
byte[] buf = buffer;
buf[position++] = (byte) (i16 & 0xff);
buf[position++] = (byte) (i16 >>> 8);
} | [
"protected",
"final",
"void",
"putInt16",
"(",
"int",
"i16",
")",
"{",
"ensureCapacity",
"(",
"position",
"+",
"2",
")",
";",
"byte",
"[",
"]",
"buf",
"=",
"buffer",
";",
"buf",
"[",
"position",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"i16",
"&",
... | Put 16-bit integer in the buffer.
@param i16 the integer to put in the buffer | [
"Put",
"16",
"-",
"bit",
"integer",
"in",
"the",
"buffer",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcher.java#L216-L222 |
124,697 | alibaba/canal | dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcher.java | DirectLogFetcher.putInt32 | protected final void putInt32(long i32) {
ensureCapacity(position + 4);
byte[] buf = buffer;
buf[position++] = (byte) (i32 & 0xff);
buf[position++] = (byte) (i32 >>> 8);
buf[position++] = (byte) (i32 >>> 16);
buf[position++] = (byte) (i32 >>> 24);
} | java | protected final void putInt32(long i32) {
ensureCapacity(position + 4);
byte[] buf = buffer;
buf[position++] = (byte) (i32 & 0xff);
buf[position++] = (byte) (i32 >>> 8);
buf[position++] = (byte) (i32 >>> 16);
buf[position++] = (byte) (i32 >>> 24);
} | [
"protected",
"final",
"void",
"putInt32",
"(",
"long",
"i32",
")",
"{",
"ensureCapacity",
"(",
"position",
"+",
"4",
")",
";",
"byte",
"[",
"]",
"buf",
"=",
"buffer",
";",
"buf",
"[",
"position",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"i32",
"&",
... | Put 32-bit integer in the buffer.
@param i32 the integer to put in the buffer | [
"Put",
"32",
"-",
"bit",
"integer",
"in",
"the",
"buffer",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcher.java#L229-L237 |
124,698 | alibaba/canal | dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcher.java | DirectLogFetcher.putString | protected final void putString(String s) {
ensureCapacity(position + (s.length() * 2) + 1);
System.arraycopy(s.getBytes(), 0, buffer, position, s.length());
position += s.length();
buffer[position++] = 0;
} | java | protected final void putString(String s) {
ensureCapacity(position + (s.length() * 2) + 1);
System.arraycopy(s.getBytes(), 0, buffer, position, s.length());
position += s.length();
buffer[position++] = 0;
} | [
"protected",
"final",
"void",
"putString",
"(",
"String",
"s",
")",
"{",
"ensureCapacity",
"(",
"position",
"+",
"(",
"s",
".",
"length",
"(",
")",
"*",
"2",
")",
"+",
"1",
")",
";",
"System",
".",
"arraycopy",
"(",
"s",
".",
"getBytes",
"(",
")",
... | Put a string in the buffer.
@param s the value to put in the buffer | [
"Put",
"a",
"string",
"in",
"the",
"buffer",
"."
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcher.java#L244-L250 |
124,699 | alibaba/canal | driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/utils/CharsetUtil.java | CharsetUtil.collateCharset | public static final String collateCharset(String charset) {
String[] output = StringUtils.split(charset, "COLLATE");
return output[0].replace('\'', ' ').trim();
} | java | public static final String collateCharset(String charset) {
String[] output = StringUtils.split(charset, "COLLATE");
return output[0].replace('\'', ' ').trim();
} | [
"public",
"static",
"final",
"String",
"collateCharset",
"(",
"String",
"charset",
")",
"{",
"String",
"[",
"]",
"output",
"=",
"StringUtils",
".",
"split",
"(",
"charset",
",",
"\"COLLATE\"",
")",
";",
"return",
"output",
"[",
"0",
"]",
".",
"replace",
... | 'utf8' COLLATE 'utf8_general_ci'
@param charset
@return | [
"utf8",
"COLLATE",
"utf8_general_ci"
] | 8f088cddc0755f4350c5aaae95c6e4002d90a40f | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/utils/CharsetUtil.java#L238-L241 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.