repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ziccardi/jnrpe | jnrpe-server/src/main/java/it/jnrpe/server/EventLoggerListener.java | EventLoggerListener.receive | @Subscribe
public final void receive(final LogEvent logEvent) {
final String sClassName = logEvent.getSource().getClass().getName();
Logger logger = loggersMap.get(sClassName);
if (logger == null) {
logger = LoggerFactory.getLogger(logEvent.getSource().getClass());
loggersMap.put(sClassName, logger);
}
final Throwable error = logEvent.getCause();
switch (logEvent.getLogType()) {
case TRACE:
logger.trace(logEvent.getMessage(), error);
break;
case DEBUG:
logger.debug(logEvent.getMessage(), error);
break;
case INFO:
logger.info(logEvent.getMessage(), error);
break;
case WARNING:
logger.warn(logEvent.getMessage(), error);
break;
case ERROR:
logger.error(logEvent.getMessage(), error);
break;
case FATAL:
logger.error(logEvent.getMessage(), error);
break;
}
} | java | @Subscribe
public final void receive(final LogEvent logEvent) {
final String sClassName = logEvent.getSource().getClass().getName();
Logger logger = loggersMap.get(sClassName);
if (logger == null) {
logger = LoggerFactory.getLogger(logEvent.getSource().getClass());
loggersMap.put(sClassName, logger);
}
final Throwable error = logEvent.getCause();
switch (logEvent.getLogType()) {
case TRACE:
logger.trace(logEvent.getMessage(), error);
break;
case DEBUG:
logger.debug(logEvent.getMessage(), error);
break;
case INFO:
logger.info(logEvent.getMessage(), error);
break;
case WARNING:
logger.warn(logEvent.getMessage(), error);
break;
case ERROR:
logger.error(logEvent.getMessage(), error);
break;
case FATAL:
logger.error(logEvent.getMessage(), error);
break;
}
} | [
"@",
"Subscribe",
"public",
"final",
"void",
"receive",
"(",
"final",
"LogEvent",
"logEvent",
")",
"{",
"final",
"String",
"sClassName",
"=",
"logEvent",
".",
"getSource",
"(",
")",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"Logger",
"log... | This method receives the log event and logs it.
@param logEvent
Event to be logged | [
"This",
"method",
"receives",
"the",
"log",
"event",
"and",
"logs",
"it",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-server/src/main/java/it/jnrpe/server/EventLoggerListener.java#L46-L79 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/io/StreamUtil.java | StreamUtil.routeStreamThroughProcess | public static InputStream routeStreamThroughProcess(final Process p, final InputStream origin, final boolean closeInput)
{
InputStream processSTDOUT = p.getInputStream();
OutputStream processSTDIN = p.getOutputStream();
// Kick off a background copy to the process
StreamUtil.doBackgroundCopy(origin, processSTDIN, DUMMY_MONITOR, true, closeInput);
return processSTDOUT;
} | java | public static InputStream routeStreamThroughProcess(final Process p, final InputStream origin, final boolean closeInput)
{
InputStream processSTDOUT = p.getInputStream();
OutputStream processSTDIN = p.getOutputStream();
// Kick off a background copy to the process
StreamUtil.doBackgroundCopy(origin, processSTDIN, DUMMY_MONITOR, true, closeInput);
return processSTDOUT;
} | [
"public",
"static",
"InputStream",
"routeStreamThroughProcess",
"(",
"final",
"Process",
"p",
",",
"final",
"InputStream",
"origin",
",",
"final",
"boolean",
"closeInput",
")",
"{",
"InputStream",
"processSTDOUT",
"=",
"p",
".",
"getInputStream",
"(",
")",
";",
... | Given a Process, this function will route the flow of data through it & out again
@param p
@param origin
@param closeInput
@return | [
"Given",
"a",
"Process",
"this",
"function",
"will",
"route",
"the",
"flow",
"of",
"data",
"through",
"it",
"&",
"out",
"again"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/io/StreamUtil.java#L105-L114 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/io/StreamUtil.java | StreamUtil.eatInputStream | public static long eatInputStream(InputStream is)
{
try
{
long eaten = 0;
try
{
Thread.sleep(STREAM_SLEEP_TIME);
}
catch (InterruptedException e)
{
// ignore
}
int avail = Math.min(is.available(), CHUNKSIZE);
byte[] eatingArray = new byte[CHUNKSIZE];
while (avail > 0)
{
is.read(eatingArray, 0, avail);
eaten += avail;
if (avail < CHUNKSIZE)
{ // If the buffer wasn't full, wait a short amount of time to let it fill up
if (STREAM_SLEEP_TIME != 0)
try
{
Thread.sleep(STREAM_SLEEP_TIME);
}
catch (InterruptedException e)
{
// ignore
}
}
avail = Math.min(is.available(), CHUNKSIZE);
}
return eaten;
}
catch (IOException e)
{
log.error(e.getMessage(), e);
return -1;
}
} | java | public static long eatInputStream(InputStream is)
{
try
{
long eaten = 0;
try
{
Thread.sleep(STREAM_SLEEP_TIME);
}
catch (InterruptedException e)
{
// ignore
}
int avail = Math.min(is.available(), CHUNKSIZE);
byte[] eatingArray = new byte[CHUNKSIZE];
while (avail > 0)
{
is.read(eatingArray, 0, avail);
eaten += avail;
if (avail < CHUNKSIZE)
{ // If the buffer wasn't full, wait a short amount of time to let it fill up
if (STREAM_SLEEP_TIME != 0)
try
{
Thread.sleep(STREAM_SLEEP_TIME);
}
catch (InterruptedException e)
{
// ignore
}
}
avail = Math.min(is.available(), CHUNKSIZE);
}
return eaten;
}
catch (IOException e)
{
log.error(e.getMessage(), e);
return -1;
}
} | [
"public",
"static",
"long",
"eatInputStream",
"(",
"InputStream",
"is",
")",
"{",
"try",
"{",
"long",
"eaten",
"=",
"0",
";",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"STREAM_SLEEP_TIME",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{"... | Eats an inputstream, discarding its contents
@param is
InputStream The input stream to read to the end of
@return long The size of the stream | [
"Eats",
"an",
"inputstream",
"discarding",
"its",
"contents"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/io/StreamUtil.java#L125-L169 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/io/StreamUtil.java | StreamUtil.streamCopy | public static void streamCopy(InputStream input, Writer output) throws IOException
{
if (input == null)
throw new IllegalArgumentException("Must provide something to read from");
if (output == null)
throw new IllegalArgumentException("Must provide something to write to");
streamCopy(new InputStreamReader(input), output);
} | java | public static void streamCopy(InputStream input, Writer output) throws IOException
{
if (input == null)
throw new IllegalArgumentException("Must provide something to read from");
if (output == null)
throw new IllegalArgumentException("Must provide something to write to");
streamCopy(new InputStreamReader(input), output);
} | [
"public",
"static",
"void",
"streamCopy",
"(",
"InputStream",
"input",
",",
"Writer",
"output",
")",
"throws",
"IOException",
"{",
"if",
"(",
"input",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Must provide something to read from\"",
")",... | Copies the contents of an InputStream, using the default encoding, into a Writer
@param input
@param output
@throws IOException | [
"Copies",
"the",
"contents",
"of",
"an",
"InputStream",
"using",
"the",
"default",
"encoding",
"into",
"a",
"Writer"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/io/StreamUtil.java#L343-L351 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/InetSubnet.java | InetSubnet.recache | private void recache()
{
// If we've already cached the values then don't bother recalculating; we
// assume a mask of 0 means a recompute is needed (unless prefix is also 0)
// We skip the computation completely is prefix is 0 - this is fine, since
// the mask and maskedNetwork for prefix 0 result in 0, the default values.
// We need to special-case /0 because our mask generation code doesn't work for
// prefix=0 (since -1 << 32 != 0)
if (mask == 0 && prefix != 0)
{
this.mask = -1 << (32 - prefix);
this.maskedNetwork = IpHelper.aton(network) & mask;
}
} | java | private void recache()
{
// If we've already cached the values then don't bother recalculating; we
// assume a mask of 0 means a recompute is needed (unless prefix is also 0)
// We skip the computation completely is prefix is 0 - this is fine, since
// the mask and maskedNetwork for prefix 0 result in 0, the default values.
// We need to special-case /0 because our mask generation code doesn't work for
// prefix=0 (since -1 << 32 != 0)
if (mask == 0 && prefix != 0)
{
this.mask = -1 << (32 - prefix);
this.maskedNetwork = IpHelper.aton(network) & mask;
}
} | [
"private",
"void",
"recache",
"(",
")",
"{",
"// If we've already cached the values then don't bother recalculating; we",
"// assume a mask of 0 means a recompute is needed (unless prefix is also 0)",
"// We skip the computation completely is prefix is 0 - this is fine, since",
"// the mask and ma... | Repopulates the transient fields based on the IP and prefix | [
"Repopulates",
"the",
"transient",
"fields",
"based",
"on",
"the",
"IP",
"and",
"prefix"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/InetSubnet.java#L149-L163 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/threading/Timeout.java | Timeout.get | public long get(final TimeUnit toUnit)
{
if (this.unit == toUnit)
return period;
else
return toUnit.convert(period, this.unit);
} | java | public long get(final TimeUnit toUnit)
{
if (this.unit == toUnit)
return period;
else
return toUnit.convert(period, this.unit);
} | [
"public",
"long",
"get",
"(",
"final",
"TimeUnit",
"toUnit",
")",
"{",
"if",
"(",
"this",
".",
"unit",
"==",
"toUnit",
")",
"return",
"period",
";",
"else",
"return",
"toUnit",
".",
"convert",
"(",
"period",
",",
"this",
".",
"unit",
")",
";",
"}"
] | Get this timeout represented in a different unit
@param toUnit
@return | [
"Get",
"this",
"timeout",
"represented",
"in",
"a",
"different",
"unit"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/threading/Timeout.java#L144-L150 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/threading/Timeout.java | Timeout.max | public static Timeout max(Timeout... timeouts)
{
Timeout max = null;
for (Timeout timeout : timeouts)
{
if (timeout != null)
if (max == null || max.getMilliseconds() < timeout.getMilliseconds())
max = timeout;
}
if (max != null)
return max;
else
throw new IllegalArgumentException("Must specify at least one non-null timeout!");
} | java | public static Timeout max(Timeout... timeouts)
{
Timeout max = null;
for (Timeout timeout : timeouts)
{
if (timeout != null)
if (max == null || max.getMilliseconds() < timeout.getMilliseconds())
max = timeout;
}
if (max != null)
return max;
else
throw new IllegalArgumentException("Must specify at least one non-null timeout!");
} | [
"public",
"static",
"Timeout",
"max",
"(",
"Timeout",
"...",
"timeouts",
")",
"{",
"Timeout",
"max",
"=",
"null",
";",
"for",
"(",
"Timeout",
"timeout",
":",
"timeouts",
")",
"{",
"if",
"(",
"timeout",
"!=",
"null",
")",
"if",
"(",
"max",
"==",
"null... | Filter through a number of timeouts to find the one with the longest period
@param timeouts
a list of timeouts (nulls are ignored)
@return the timeout with the longest period
@throws IllegalArgumentException
if no non-null timeouts are presented | [
"Filter",
"through",
"a",
"number",
"of",
"timeouts",
"to",
"find",
"the",
"one",
"with",
"the",
"longest",
"period"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/threading/Timeout.java#L289-L304 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/threading/Timeout.java | Timeout.min | public static Timeout min(Timeout... timeouts)
{
Timeout min = null;
for (Timeout timeout : timeouts)
{
if (timeout != null)
if (min == null || min.getMilliseconds() > timeout.getMilliseconds())
min = timeout;
}
if (min != null)
return min;
else
throw new IllegalArgumentException("Must specify at least one non-null timeout!");
} | java | public static Timeout min(Timeout... timeouts)
{
Timeout min = null;
for (Timeout timeout : timeouts)
{
if (timeout != null)
if (min == null || min.getMilliseconds() > timeout.getMilliseconds())
min = timeout;
}
if (min != null)
return min;
else
throw new IllegalArgumentException("Must specify at least one non-null timeout!");
} | [
"public",
"static",
"Timeout",
"min",
"(",
"Timeout",
"...",
"timeouts",
")",
"{",
"Timeout",
"min",
"=",
"null",
";",
"for",
"(",
"Timeout",
"timeout",
":",
"timeouts",
")",
"{",
"if",
"(",
"timeout",
"!=",
"null",
")",
"if",
"(",
"min",
"==",
"null... | Filter through a number of timeouts to find the one with the shortest period
@param timeouts
a list of timeouts (nulls are ignored)
@return the timeout with the shortest period
@throws IllegalArgumentException
if no non-null timeouts are presented | [
"Filter",
"through",
"a",
"number",
"of",
"timeouts",
"to",
"find",
"the",
"one",
"with",
"the",
"shortest",
"period"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/threading/Timeout.java#L318-L333 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/threading/Timeout.java | Timeout.sum | public static Timeout sum(Timeout... timeouts)
{
long sum = 0;
for (Timeout timeout : timeouts)
if (timeout != null)
sum += timeout.getMilliseconds();
if (sum != 0)
return new Timeout(sum);
else
return Timeout.ZERO;
} | java | public static Timeout sum(Timeout... timeouts)
{
long sum = 0;
for (Timeout timeout : timeouts)
if (timeout != null)
sum += timeout.getMilliseconds();
if (sum != 0)
return new Timeout(sum);
else
return Timeout.ZERO;
} | [
"public",
"static",
"Timeout",
"sum",
"(",
"Timeout",
"...",
"timeouts",
")",
"{",
"long",
"sum",
"=",
"0",
";",
"for",
"(",
"Timeout",
"timeout",
":",
"timeouts",
")",
"if",
"(",
"timeout",
"!=",
"null",
")",
"sum",
"+=",
"timeout",
".",
"getMilliseco... | Adds together all the supplied timeouts
@param timeouts
a list of timeouts (nulls are ignored)
@return the sum of all the timeouts specified | [
"Adds",
"together",
"all",
"the",
"supplied",
"timeouts"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/threading/Timeout.java#L344-L356 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/system/exec/SudoFeature.java | SudoFeature.hasSudo | public synchronized static boolean hasSudo()
{
if (!sudoTested)
{
String[] cmdArr = new String[]{"which", "sudo"};
List<String> cmd = new ArrayList<String>(cmdArr.length);
Collections.addAll(cmd, cmdArr);
ProcessBuilder whichsudo = new ProcessBuilder(cmd);
try
{
Process p = whichsudo.start();
try
{
Execed e = new Execed(cmd, p, false);
// Let it run
int returnCode = e.waitForExit(new Deadline(3, TimeUnit.SECONDS));
sudoSupported = (returnCode == 0);
sudoTested = true;
}
finally
{
p.destroy();
}
}
catch (Throwable t)
{
sudoSupported = false;
sudoTested = true;
}
}
return sudoSupported;
} | java | public synchronized static boolean hasSudo()
{
if (!sudoTested)
{
String[] cmdArr = new String[]{"which", "sudo"};
List<String> cmd = new ArrayList<String>(cmdArr.length);
Collections.addAll(cmd, cmdArr);
ProcessBuilder whichsudo = new ProcessBuilder(cmd);
try
{
Process p = whichsudo.start();
try
{
Execed e = new Execed(cmd, p, false);
// Let it run
int returnCode = e.waitForExit(new Deadline(3, TimeUnit.SECONDS));
sudoSupported = (returnCode == 0);
sudoTested = true;
}
finally
{
p.destroy();
}
}
catch (Throwable t)
{
sudoSupported = false;
sudoTested = true;
}
}
return sudoSupported;
} | [
"public",
"synchronized",
"static",
"boolean",
"hasSudo",
"(",
")",
"{",
"if",
"(",
"!",
"sudoTested",
")",
"{",
"String",
"[",
"]",
"cmdArr",
"=",
"new",
"String",
"[",
"]",
"{",
"\"which\"",
",",
"\"sudo\"",
"}",
";",
"List",
"<",
"String",
">",
"c... | Determines whether sudo is supported on the local machine
@return | [
"Determines",
"whether",
"sudo",
"is",
"supported",
"on",
"the",
"local",
"machine"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/system/exec/SudoFeature.java#L52-L88 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/net/JNRPEServerHandler.java | JNRPEServerHandler.channelRead | @Override
public final void channelRead(final ChannelHandlerContext ctx, final Object msg) {
try {
JNRPERequest req = (JNRPERequest) msg;
ReturnValue ret = commandInvoker.invoke(req.getCommand(), req.getArguments());
JNRPEResponse res = new JNRPEResponse();
res.setResult(ret.getStatus().intValue(), ret.getMessage());
ChannelFuture channelFuture = ctx.writeAndFlush(res);
channelFuture.addListener(ChannelFutureListener.CLOSE);
} catch ( RuntimeException re ) {
re.printStackTrace();
} finally {
ReferenceCountUtil.release(msg);
}
} | java | @Override
public final void channelRead(final ChannelHandlerContext ctx, final Object msg) {
try {
JNRPERequest req = (JNRPERequest) msg;
ReturnValue ret = commandInvoker.invoke(req.getCommand(), req.getArguments());
JNRPEResponse res = new JNRPEResponse();
res.setResult(ret.getStatus().intValue(), ret.getMessage());
ChannelFuture channelFuture = ctx.writeAndFlush(res);
channelFuture.addListener(ChannelFutureListener.CLOSE);
} catch ( RuntimeException re ) {
re.printStackTrace();
} finally {
ReferenceCountUtil.release(msg);
}
} | [
"@",
"Override",
"public",
"final",
"void",
"channelRead",
"(",
"final",
"ChannelHandlerContext",
"ctx",
",",
"final",
"Object",
"msg",
")",
"{",
"try",
"{",
"JNRPERequest",
"req",
"=",
"(",
"JNRPERequest",
")",
"msg",
";",
"ReturnValue",
"ret",
"=",
"comman... | Method channelRead.
@param ctx ChannelHandlerContext
@param msg Object
@see io.netty.channel.ChannelInboundHandler#channelRead(ChannelHandlerContext, Object) | [
"Method",
"channelRead",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/net/JNRPEServerHandler.java#L70-L87 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/apploader/impl/GuiceFactory.java | GuiceFactory.applyConfigs | private static void applyConfigs(final ClassLoader classloader, final GuiceConfig config)
{
// Load all the local configs
for (String configFile : getPropertyFiles(config))
{
try
{
for (PropertyFile properties : loadConfig(classloader, configFile))
config.setAll(properties);
}
catch (IOException e)
{
throw new IllegalArgumentException("Error loading configuration URLs from " + configFile, e);
}
}
// Load the network config (if enabled)
try
{
applyNetworkConfiguration(config);
}
catch (Throwable t)
{
throw new RuntimeException("Failed to retrieve configuration from network!", t);
}
} | java | private static void applyConfigs(final ClassLoader classloader, final GuiceConfig config)
{
// Load all the local configs
for (String configFile : getPropertyFiles(config))
{
try
{
for (PropertyFile properties : loadConfig(classloader, configFile))
config.setAll(properties);
}
catch (IOException e)
{
throw new IllegalArgumentException("Error loading configuration URLs from " + configFile, e);
}
}
// Load the network config (if enabled)
try
{
applyNetworkConfiguration(config);
}
catch (Throwable t)
{
throw new RuntimeException("Failed to retrieve configuration from network!", t);
}
} | [
"private",
"static",
"void",
"applyConfigs",
"(",
"final",
"ClassLoader",
"classloader",
",",
"final",
"GuiceConfig",
"config",
")",
"{",
"// Load all the local configs",
"for",
"(",
"String",
"configFile",
":",
"getPropertyFiles",
"(",
"config",
")",
")",
"{",
"t... | Discover and add to the configuration any properties on disk and on the network
@param classloader
@param config | [
"Discover",
"and",
"add",
"to",
"the",
"configuration",
"any",
"properties",
"on",
"disk",
"and",
"on",
"the",
"network"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/apploader/impl/GuiceFactory.java#L338-L363 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/BracketStage.java | BracketStage.parse | @Override
public String parse(final String threshold, final RangeConfig tc) {
configure(tc);
return threshold.substring(1);
} | java | @Override
public String parse(final String threshold, final RangeConfig tc) {
configure(tc);
return threshold.substring(1);
} | [
"@",
"Override",
"public",
"String",
"parse",
"(",
"final",
"String",
"threshold",
",",
"final",
"RangeConfig",
"tc",
")",
"{",
"configure",
"(",
"tc",
")",
";",
"return",
"threshold",
".",
"substring",
"(",
"1",
")",
";",
"}"
] | Parses the threshold to remove the matched braket.
No checks are performed against the passed in string: the object assumes
that the string is correct since the {@link #canParse(String)} method
<b>must</b> be called <b>before</b> this method.
@param threshold
The threshold to parse
@param tc
The threshold config object. This object will be populated
according to the passed in threshold.
@return the remaining part of the threshold | [
"Parses",
"the",
"threshold",
"to",
"remove",
"the",
"matched",
"braket",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/BracketStage.java#L59-L63 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/plugins/PluginCommandLine.java | PluginCommandLine.getOptionValue | public String getOptionValue(final String optionName) {
if (optionName.length() == 1) {
return getOptionValue(optionName.charAt(0));
}
return (String) commandLine.getValue("--" + optionName);
} | java | public String getOptionValue(final String optionName) {
if (optionName.length() == 1) {
return getOptionValue(optionName.charAt(0));
}
return (String) commandLine.getValue("--" + optionName);
} | [
"public",
"String",
"getOptionValue",
"(",
"final",
"String",
"optionName",
")",
"{",
"if",
"(",
"optionName",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"return",
"getOptionValue",
"(",
"optionName",
".",
"charAt",
"(",
"0",
")",
")",
";",
"}",
"re... | Returns the value of the specified option.
@param optionName
The option name
@return The value of the option * @see it.jnrpe.ICommandLine#getOptionValue(String) | [
"Returns",
"the",
"value",
"of",
"the",
"specified",
"option",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/plugins/PluginCommandLine.java#L56-L61 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/plugins/PluginCommandLine.java | PluginCommandLine.getOptionValue | public String getOptionValue(final char shortOption, final String defaultValue) {
return (String) commandLine.getValue("-" + shortOption, defaultValue);
} | java | public String getOptionValue(final char shortOption, final String defaultValue) {
return (String) commandLine.getValue("-" + shortOption, defaultValue);
} | [
"public",
"String",
"getOptionValue",
"(",
"final",
"char",
"shortOption",
",",
"final",
"String",
"defaultValue",
")",
"{",
"return",
"(",
"String",
")",
"commandLine",
".",
"getValue",
"(",
"\"-\"",
"+",
"shortOption",
",",
"defaultValue",
")",
";",
"}"
] | Returns the value of the specified option If the option is not present,
returns the default value.
@param shortOption
The option short name
@param defaultValue
The default value
@return The option value or, if not specified, the default value * @see it.jnrpe.ICommandLine#getOptionValue(char, String) | [
"Returns",
"the",
"value",
"of",
"the",
"specified",
"option",
"If",
"the",
"option",
"is",
"not",
"present",
"returns",
"the",
"default",
"value",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/plugins/PluginCommandLine.java#L130-L132 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/TimecodeRange.java | TimecodeRange.add | public TimecodeRange add(SampleCount samples)
{
final Timecode newStart = start.add(samples);
final Timecode newEnd = end.add(samples);
return new TimecodeRange(newStart, newEnd);
} | java | public TimecodeRange add(SampleCount samples)
{
final Timecode newStart = start.add(samples);
final Timecode newEnd = end.add(samples);
return new TimecodeRange(newStart, newEnd);
} | [
"public",
"TimecodeRange",
"add",
"(",
"SampleCount",
"samples",
")",
"{",
"final",
"Timecode",
"newStart",
"=",
"start",
".",
"add",
"(",
"samples",
")",
";",
"final",
"Timecode",
"newEnd",
"=",
"end",
".",
"add",
"(",
"samples",
")",
";",
"return",
"ne... | Move the range right by the specified number of samples
@param samples
@return | [
"Move",
"the",
"range",
"right",
"by",
"the",
"specified",
"number",
"of",
"samples"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/TimecodeRange.java#L100-L106 | train |
petergeneric/stdlib | user-manager/service/src/main/java/com/peterphi/usermanager/guice/authentication/ldap/LDAPUserAuthenticationService.java | LDAPUserAuthenticationService.opportunisticallyRefreshUserData | public synchronized void opportunisticallyRefreshUserData(final String username, final String password)
{
if (shouldOpportunisticallyRefreshUserData())
{
this.lastOpportunisticUserDataRefresh = System.currentTimeMillis();
Thread thread = new Thread(() -> refreshAllUserData(ldap.parseUser(username), password, true));
thread.setDaemon(true);
thread.setName("UserManager_OpportunisticRefresh");
thread.start();
}
} | java | public synchronized void opportunisticallyRefreshUserData(final String username, final String password)
{
if (shouldOpportunisticallyRefreshUserData())
{
this.lastOpportunisticUserDataRefresh = System.currentTimeMillis();
Thread thread = new Thread(() -> refreshAllUserData(ldap.parseUser(username), password, true));
thread.setDaemon(true);
thread.setName("UserManager_OpportunisticRefresh");
thread.start();
}
} | [
"public",
"synchronized",
"void",
"opportunisticallyRefreshUserData",
"(",
"final",
"String",
"username",
",",
"final",
"String",
"password",
")",
"{",
"if",
"(",
"shouldOpportunisticallyRefreshUserData",
"(",
")",
")",
"{",
"this",
".",
"lastOpportunisticUserDataRefres... | Temporarily borrow a user's credentials to run an opportunistic user data refresh
@param username
@param password | [
"Temporarily",
"borrow",
"a",
"user",
"s",
"credentials",
"to",
"run",
"an",
"opportunistic",
"user",
"data",
"refresh"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/user-manager/service/src/main/java/com/peterphi/usermanager/guice/authentication/ldap/LDAPUserAuthenticationService.java#L195-L205 | train |
petergeneric/stdlib | guice/freemarker/src/main/java/com/peterphi/std/guice/freemarker/FreemarkerURLHelper.java | FreemarkerURLHelper.relative | public String relative(String url)
{
try
{
final URI uri = absolute(url).build();
return new URI(null, null, uri.getPath(), uri.getQuery(), uri.getFragment()).toString();
}
catch (URISyntaxException e)
{
throw new IllegalArgumentException(e);
}
} | java | public String relative(String url)
{
try
{
final URI uri = absolute(url).build();
return new URI(null, null, uri.getPath(), uri.getQuery(), uri.getFragment()).toString();
}
catch (URISyntaxException e)
{
throw new IllegalArgumentException(e);
}
} | [
"public",
"String",
"relative",
"(",
"String",
"url",
")",
"{",
"try",
"{",
"final",
"URI",
"uri",
"=",
"absolute",
"(",
"url",
")",
".",
"build",
"(",
")",
";",
"return",
"new",
"URI",
"(",
"null",
",",
"null",
",",
"uri",
".",
"getPath",
"(",
"... | Return only the path for a given URL
@param url
@return | [
"Return",
"only",
"the",
"path",
"for",
"a",
"given",
"URL"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/freemarker/src/main/java/com/peterphi/std/guice/freemarker/FreemarkerURLHelper.java#L120-L132 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/net/NetworkConfigReloadDaemon.java | NetworkConfigReloadDaemon.reload | void reload(NetworkConfig config)
{
try
{
log.trace("Load config data from " + config.path + " into " + config);
final ConfigPropertyData read = configService.read(config.path, configInstanceId, config.getLastRevision());
// Abort if the server returns no config - we have the latest revision
if (read == null || read.properties == null || read.properties.isEmpty())
return;
for (ConfigPropertyValue property : read.properties)
{
config.properties.set(property.getName(), property.getValue());
}
config.setLastRevision(read.revision);
}
catch (Throwable t)
{
log.warn("Error loading config from path " + config.path, t);
}
} | java | void reload(NetworkConfig config)
{
try
{
log.trace("Load config data from " + config.path + " into " + config);
final ConfigPropertyData read = configService.read(config.path, configInstanceId, config.getLastRevision());
// Abort if the server returns no config - we have the latest revision
if (read == null || read.properties == null || read.properties.isEmpty())
return;
for (ConfigPropertyValue property : read.properties)
{
config.properties.set(property.getName(), property.getValue());
}
config.setLastRevision(read.revision);
}
catch (Throwable t)
{
log.warn("Error loading config from path " + config.path, t);
}
} | [
"void",
"reload",
"(",
"NetworkConfig",
"config",
")",
"{",
"try",
"{",
"log",
".",
"trace",
"(",
"\"Load config data from \"",
"+",
"config",
".",
"path",
"+",
"\" into \"",
"+",
"config",
")",
";",
"final",
"ConfigPropertyData",
"read",
"=",
"configService",... | Called to initiate an intelligent reload of a particular config
@param config | [
"Called",
"to",
"initiate",
"an",
"intelligent",
"reload",
"of",
"a",
"particular",
"config"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/net/NetworkConfigReloadDaemon.java#L94-L116 | train |
petergeneric/stdlib | service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/guice/ServiceManagerGuiceModule.java | ServiceManagerGuiceModule.getLogDataTable | @Provides
@Named("logdata")
public CloudTable getLogDataTable(@Named("azure.storage-connection-string") String storageConnectionString,
@Named("azure.logging-table")
String logTableName) throws URISyntaxException, StorageException, InvalidKeyException
{
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
// Create the table client.
CloudTableClient tableClient = storageAccount.createCloudTableClient();
// Create the table if it doesn't exist.
CloudTable table = tableClient.getTableReference(logTableName);
table.createIfNotExists();
return table;
} | java | @Provides
@Named("logdata")
public CloudTable getLogDataTable(@Named("azure.storage-connection-string") String storageConnectionString,
@Named("azure.logging-table")
String logTableName) throws URISyntaxException, StorageException, InvalidKeyException
{
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
// Create the table client.
CloudTableClient tableClient = storageAccount.createCloudTableClient();
// Create the table if it doesn't exist.
CloudTable table = tableClient.getTableReference(logTableName);
table.createIfNotExists();
return table;
} | [
"@",
"Provides",
"@",
"Named",
"(",
"\"logdata\"",
")",
"public",
"CloudTable",
"getLogDataTable",
"(",
"@",
"Named",
"(",
"\"azure.storage-connection-string\"",
")",
"String",
"storageConnectionString",
",",
"@",
"Named",
"(",
"\"azure.logging-table\"",
")",
"String"... | For the Azure Log Store, the underlying table to use
@param storageConnectionString
@return
@throws URISyntaxException
@throws StorageException
@throws InvalidKeyException | [
"For",
"the",
"Azure",
"Log",
"Store",
"the",
"underlying",
"table",
"to",
"use"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/guice/ServiceManagerGuiceModule.java#L72-L89 | train |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/jmx/CCheckJMX.java | CCheckJMX.execute | public final ReturnValue execute(final ICommandLine cl) {
if (cl.hasOption('U')) {
setUrl(cl.getOptionValue('U'));
}
if (cl.hasOption('O')) {
setObject(cl.getOptionValue('O'));
}
if (cl.hasOption('A')) {
setAttribute(cl.getOptionValue('A'));
}
if (cl.hasOption('I')) {
setInfo_attribute(cl.getOptionValue('I'));
}
if (cl.hasOption('J')) {
setInfo_key(cl.getOptionValue('J'));
}
if (cl.hasOption('K')) {
setAttribute_key(cl.getOptionValue('K'));
}
if (cl.hasOption('w')) {
setWarning(cl.getOptionValue('w'));
}
if (cl.hasOption('c')) {
setCritical(cl.getOptionValue('c'));
}
if (cl.hasOption("username")) {
setUsername(cl.getOptionValue("username"));
}
if (cl.hasOption("password")) {
setPassword(cl.getOptionValue("password"));
}
setVerbatim(2);
// setVerbatim(4);
try {
connect();
execute();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bout);
Status status = report(ps);
ps.flush();
ps.close();
return new ReturnValue(status, new String(bout.toByteArray()));
} catch (Exception ex) {
LOG.warn(getContext(), "An error has occurred during execution " + "of the CHECK_JMX plugin : " + ex.getMessage(), ex);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bout);
Status status = report(ex, ps);
ps.flush();
ps.close();
return new ReturnValue(status, new String(bout.toByteArray()));
} finally {
try {
disconnect();
} catch (IOException e) {
LOG.warn(getContext(), "An error has occurred during execution (disconnect) of the CHECK_JMX plugin : " + e.getMessage(), e);
// ByteArrayOutputStream bout = new ByteArrayOutputStream();
// PrintStream ps = new PrintStream(bout);
//
// Status status = report(e, ps);
// ps.flush();
// ps.close();
// return new ReturnValue(status, new String(bout.toByteArray()));
}
}
} | java | public final ReturnValue execute(final ICommandLine cl) {
if (cl.hasOption('U')) {
setUrl(cl.getOptionValue('U'));
}
if (cl.hasOption('O')) {
setObject(cl.getOptionValue('O'));
}
if (cl.hasOption('A')) {
setAttribute(cl.getOptionValue('A'));
}
if (cl.hasOption('I')) {
setInfo_attribute(cl.getOptionValue('I'));
}
if (cl.hasOption('J')) {
setInfo_key(cl.getOptionValue('J'));
}
if (cl.hasOption('K')) {
setAttribute_key(cl.getOptionValue('K'));
}
if (cl.hasOption('w')) {
setWarning(cl.getOptionValue('w'));
}
if (cl.hasOption('c')) {
setCritical(cl.getOptionValue('c'));
}
if (cl.hasOption("username")) {
setUsername(cl.getOptionValue("username"));
}
if (cl.hasOption("password")) {
setPassword(cl.getOptionValue("password"));
}
setVerbatim(2);
// setVerbatim(4);
try {
connect();
execute();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bout);
Status status = report(ps);
ps.flush();
ps.close();
return new ReturnValue(status, new String(bout.toByteArray()));
} catch (Exception ex) {
LOG.warn(getContext(), "An error has occurred during execution " + "of the CHECK_JMX plugin : " + ex.getMessage(), ex);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bout);
Status status = report(ex, ps);
ps.flush();
ps.close();
return new ReturnValue(status, new String(bout.toByteArray()));
} finally {
try {
disconnect();
} catch (IOException e) {
LOG.warn(getContext(), "An error has occurred during execution (disconnect) of the CHECK_JMX plugin : " + e.getMessage(), e);
// ByteArrayOutputStream bout = new ByteArrayOutputStream();
// PrintStream ps = new PrintStream(bout);
//
// Status status = report(e, ps);
// ps.flush();
// ps.close();
// return new ReturnValue(status, new String(bout.toByteArray()));
}
}
} | [
"public",
"final",
"ReturnValue",
"execute",
"(",
"final",
"ICommandLine",
"cl",
")",
"{",
"if",
"(",
"cl",
".",
"hasOption",
"(",
"'",
"'",
")",
")",
"{",
"setUrl",
"(",
"cl",
".",
"getOptionValue",
"(",
"'",
"'",
")",
")",
";",
"}",
"if",
"(",
... | Executes the plugin.
@param cl
The command line
@return the result of the execution | [
"Executes",
"the",
"plugin",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/jmx/CCheckJMX.java#L41-L107 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/Version.java | Version.overlapping | public static boolean overlapping(Version min1, Version max1, Version min2, Version max2)
{
// Versions overlap if:
// - either Min or Max values are identical (fast test for real scenarios)
// - Min1|Max1 are within the range Min2-Max2
// - Min2|Max2 are within the range Min1-Max1
return min1.equals(min2) || max1.equals(max2) || min2.within(min1, max1) || max2.within(min1, min2) ||
min1.within(min2, max2) || max1.within(min2, max2);
} | java | public static boolean overlapping(Version min1, Version max1, Version min2, Version max2)
{
// Versions overlap if:
// - either Min or Max values are identical (fast test for real scenarios)
// - Min1|Max1 are within the range Min2-Max2
// - Min2|Max2 are within the range Min1-Max1
return min1.equals(min2) || max1.equals(max2) || min2.within(min1, max1) || max2.within(min1, min2) ||
min1.within(min2, max2) || max1.within(min2, max2);
} | [
"public",
"static",
"boolean",
"overlapping",
"(",
"Version",
"min1",
",",
"Version",
"max1",
",",
"Version",
"min2",
",",
"Version",
"max2",
")",
"{",
"// Versions overlap if:",
"// - either Min or Max values are identical (fast test for real scenarios)",
"// - Min1|Max1 are... | Determines if 2 version ranges have any overlap
@param min1
Version The 1st range
@param max1
Version The 1st range
@param min2
Version The 2nd range
@param max2
Version The 2nd range
@return boolean True if the version ranges overlap | [
"Determines",
"if",
"2",
"version",
"ranges",
"have",
"any",
"overlap"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/Version.java#L210-L219 | train |
petergeneric/stdlib | service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/logging/azure/AzureLogStore.java | AzureLogStore.createPartitionAndRowQuery | public String createPartitionAndRowQuery(final DateTime from, final DateTime to)
{
final String parMin = TableQuery.generateFilterCondition("PartitionKey",
TableQuery.QueryComparisons.GREATER_THAN_OR_EQUAL,
from.toLocalDate().toString());
final String rowMin = TableQuery.generateFilterCondition("RowKey",
TableQuery.QueryComparisons.GREATER_THAN_OR_EQUAL,
LogLineTableEntity.toRowKey(from, null));
if (to == null || from.toLocalDate().equals(to.toLocalDate()) || to.isAfterNow())
{
// There's no upper bound (or the upper bound doesn't make sense to include in the query)
return andFilters(parMin, rowMin);
}
else
{
// From and To required
final String parMax = TableQuery.generateFilterCondition("PartitionKey",
TableQuery.QueryComparisons.LESS_THAN,
to.toLocalDate().plusDays(1).toString());
final String rowMax = TableQuery.generateFilterCondition("RowKey",
TableQuery.QueryComparisons.LESS_THAN,
LogLineTableEntity.toRowKey(to.plusSeconds(1), null));
return andFilters(parMin, parMax, rowMin, rowMax);
}
} | java | public String createPartitionAndRowQuery(final DateTime from, final DateTime to)
{
final String parMin = TableQuery.generateFilterCondition("PartitionKey",
TableQuery.QueryComparisons.GREATER_THAN_OR_EQUAL,
from.toLocalDate().toString());
final String rowMin = TableQuery.generateFilterCondition("RowKey",
TableQuery.QueryComparisons.GREATER_THAN_OR_EQUAL,
LogLineTableEntity.toRowKey(from, null));
if (to == null || from.toLocalDate().equals(to.toLocalDate()) || to.isAfterNow())
{
// There's no upper bound (or the upper bound doesn't make sense to include in the query)
return andFilters(parMin, rowMin);
}
else
{
// From and To required
final String parMax = TableQuery.generateFilterCondition("PartitionKey",
TableQuery.QueryComparisons.LESS_THAN,
to.toLocalDate().plusDays(1).toString());
final String rowMax = TableQuery.generateFilterCondition("RowKey",
TableQuery.QueryComparisons.LESS_THAN,
LogLineTableEntity.toRowKey(to.plusSeconds(1), null));
return andFilters(parMin, parMax, rowMin, rowMax);
}
} | [
"public",
"String",
"createPartitionAndRowQuery",
"(",
"final",
"DateTime",
"from",
",",
"final",
"DateTime",
"to",
")",
"{",
"final",
"String",
"parMin",
"=",
"TableQuery",
".",
"generateFilterCondition",
"(",
"\"PartitionKey\"",
",",
"TableQuery",
".",
"QueryCompa... | Create a filter condition that returns log lines between two dates. Designed to be used in addition to other criteria
@param from
@param to
@return | [
"Create",
"a",
"filter",
"condition",
"that",
"returns",
"log",
"lines",
"between",
"two",
"dates",
".",
"Designed",
"to",
"be",
"used",
"in",
"addition",
"to",
"other",
"criteria"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/logging/azure/AzureLogStore.java#L199-L228 | train |
petergeneric/stdlib | service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/rest/impl/ServiceIdCache.java | ServiceIdCache.get | public ServiceInstanceEntity get(final String serviceId)
{
try
{
return serviceCache.get(serviceId, () -> dao.getById(serviceId));
}
catch (Exception e)
{
throw new RuntimeException("Error loading service: " + serviceId, e);
}
} | java | public ServiceInstanceEntity get(final String serviceId)
{
try
{
return serviceCache.get(serviceId, () -> dao.getById(serviceId));
}
catch (Exception e)
{
throw new RuntimeException("Error loading service: " + serviceId, e);
}
} | [
"public",
"ServiceInstanceEntity",
"get",
"(",
"final",
"String",
"serviceId",
")",
"{",
"try",
"{",
"return",
"serviceCache",
".",
"get",
"(",
"serviceId",
",",
"(",
")",
"->",
"dao",
".",
"getById",
"(",
"serviceId",
")",
")",
";",
"}",
"catch",
"(",
... | Get service information, reading from cache if possible
@param serviceId
@return | [
"Get",
"service",
"information",
"reading",
"from",
"cache",
"if",
"possible"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/rest/impl/ServiceIdCache.java#L37-L47 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/plugins/PluginProxy.java | PluginProxy.execute | public ReturnValue execute(final String[] argsAry) throws BadThresholdException {
// CommandLineParser clp = new PosixParser();
try {
HelpFormatter hf = new HelpFormatter();
// configure a parser
Parser cliParser = new Parser();
cliParser.setGroup(mainOptionsGroup);
cliParser.setHelpFormatter(hf);
CommandLine cl = cliParser.parse(argsAry);
// Inject the context...
InjectionUtils.inject(proxiedPlugin, getContext());
Thread.currentThread().setContextClassLoader(proxiedPlugin.getClass().getClassLoader());
ReturnValue retValue = proxiedPlugin.execute(new PluginCommandLine(cl));
if (retValue == null) {
String msg = "Plugin [" + getPluginName() + "] with args [" + StringUtils.join(argsAry) + "] returned null";
retValue = new ReturnValue(Status.UNKNOWN, msg);
}
return retValue;
} catch (OptionException e) {
String msg = e.getMessage();
LOG.error(getContext(), "Error parsing plugin '" + getPluginName() + "' command line : " + msg, e);
return new ReturnValue(Status.UNKNOWN, msg);
}
} | java | public ReturnValue execute(final String[] argsAry) throws BadThresholdException {
// CommandLineParser clp = new PosixParser();
try {
HelpFormatter hf = new HelpFormatter();
// configure a parser
Parser cliParser = new Parser();
cliParser.setGroup(mainOptionsGroup);
cliParser.setHelpFormatter(hf);
CommandLine cl = cliParser.parse(argsAry);
// Inject the context...
InjectionUtils.inject(proxiedPlugin, getContext());
Thread.currentThread().setContextClassLoader(proxiedPlugin.getClass().getClassLoader());
ReturnValue retValue = proxiedPlugin.execute(new PluginCommandLine(cl));
if (retValue == null) {
String msg = "Plugin [" + getPluginName() + "] with args [" + StringUtils.join(argsAry) + "] returned null";
retValue = new ReturnValue(Status.UNKNOWN, msg);
}
return retValue;
} catch (OptionException e) {
String msg = e.getMessage();
LOG.error(getContext(), "Error parsing plugin '" + getPluginName() + "' command line : " + msg, e);
return new ReturnValue(Status.UNKNOWN, msg);
}
} | [
"public",
"ReturnValue",
"execute",
"(",
"final",
"String",
"[",
"]",
"argsAry",
")",
"throws",
"BadThresholdException",
"{",
"// CommandLineParser clp = new PosixParser();",
"try",
"{",
"HelpFormatter",
"hf",
"=",
"new",
"HelpFormatter",
"(",
")",
";",
"// configure ... | Executes the proxied plugin passing the received arguments as parameters.
@param argsAry The parameters to be passed to the plugin
@return The return value of the plugin.
@throws BadThresholdException if an error occurs parsing the threshold | [
"Executes",
"the",
"proxied",
"plugin",
"passing",
"the",
"received",
"arguments",
"as",
"parameters",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/plugins/PluginProxy.java#L103-L133 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/plugins/PluginProxy.java | PluginProxy.printHelp | public void printHelp(final PrintWriter out) {
HelpFormatter hf = new HelpFormatter();
StringBuilder sbDivider = new StringBuilder("=");
while (sbDivider.length() < hf.getPageWidth()) {
sbDivider.append('=');
}
out.println(sbDivider.toString());
out.println("PLUGIN NAME : " + proxyedPluginDefinition.getName());
if (description != null && description.trim().length() != 0) {
out.println(sbDivider.toString());
out.println("Description : ");
out.println();
out.println(description);
}
hf.setGroup(mainOptionsGroup);
// hf.setHeader(m_pluginDef.getName());
hf.setDivider(sbDivider.toString());
hf.setPrintWriter(out);
hf.print();
// hf.printHelp(m_pluginDef.getName(), m_Options);
} | java | public void printHelp(final PrintWriter out) {
HelpFormatter hf = new HelpFormatter();
StringBuilder sbDivider = new StringBuilder("=");
while (sbDivider.length() < hf.getPageWidth()) {
sbDivider.append('=');
}
out.println(sbDivider.toString());
out.println("PLUGIN NAME : " + proxyedPluginDefinition.getName());
if (description != null && description.trim().length() != 0) {
out.println(sbDivider.toString());
out.println("Description : ");
out.println();
out.println(description);
}
hf.setGroup(mainOptionsGroup);
// hf.setHeader(m_pluginDef.getName());
hf.setDivider(sbDivider.toString());
hf.setPrintWriter(out);
hf.print();
// hf.printHelp(m_pluginDef.getName(), m_Options);
} | [
"public",
"void",
"printHelp",
"(",
"final",
"PrintWriter",
"out",
")",
"{",
"HelpFormatter",
"hf",
"=",
"new",
"HelpFormatter",
"(",
")",
";",
"StringBuilder",
"sbDivider",
"=",
"new",
"StringBuilder",
"(",
"\"=\"",
")",
";",
"while",
"(",
"sbDivider",
".",... | Prints the help related to the plugin to a specified output.
@param out
the writer where the help should be written | [
"Prints",
"the",
"help",
"related",
"to",
"the",
"plugin",
"to",
"a",
"specified",
"output",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/plugins/PluginProxy.java#L141-L162 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/TimecodeComparator.java | TimecodeComparator.max | public static Timecode max(final Timecode... timecodes)
{
Timecode max = null;
for (Timecode timecode : timecodes)
if (max == null || lt(max, timecode))
max = timecode;
return max;
} | java | public static Timecode max(final Timecode... timecodes)
{
Timecode max = null;
for (Timecode timecode : timecodes)
if (max == null || lt(max, timecode))
max = timecode;
return max;
} | [
"public",
"static",
"Timecode",
"max",
"(",
"final",
"Timecode",
"...",
"timecodes",
")",
"{",
"Timecode",
"max",
"=",
"null",
";",
"for",
"(",
"Timecode",
"timecode",
":",
"timecodes",
")",
"if",
"(",
"max",
"==",
"null",
"||",
"lt",
"(",
"max",
",",
... | Returns the larger of a number of timecodes
@param timecodes
some timecodes
@return | [
"Returns",
"the",
"larger",
"of",
"a",
"number",
"of",
"timecodes"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/TimecodeComparator.java#L128-L137 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/TimecodeComparator.java | TimecodeComparator.min | public static Timecode min(final Timecode... timecodes)
{
Timecode min = null;
for (Timecode timecode : timecodes)
if (min == null || ge(min, timecode))
min = timecode;
return min;
} | java | public static Timecode min(final Timecode... timecodes)
{
Timecode min = null;
for (Timecode timecode : timecodes)
if (min == null || ge(min, timecode))
min = timecode;
return min;
} | [
"public",
"static",
"Timecode",
"min",
"(",
"final",
"Timecode",
"...",
"timecodes",
")",
"{",
"Timecode",
"min",
"=",
"null",
";",
"for",
"(",
"Timecode",
"timecode",
":",
"timecodes",
")",
"if",
"(",
"min",
"==",
"null",
"||",
"ge",
"(",
"min",
",",
... | Returns the smaller of some timecodes
@param timecodes
some timecodes
@return | [
"Returns",
"the",
"smaller",
"of",
"some",
"timecodes"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/TimecodeComparator.java#L148-L157 | train |
petergeneric/stdlib | util/carbon-client/src/main/java/com/peterphi/carbon/util/mediainfo/MediaInfoTrack.java | MediaInfoTrack.getDurationMillis | public long getDurationMillis()
{
List<Element> durations = element.getChildren("Duration");
if (durations.size() != 0)
{
final String durationString = durations.get(0).getValue();
final long duration = Long.parseLong(durationString);
return duration;
}
else
{
throw new RuntimeException("No Duration elements present on track!");
}
} | java | public long getDurationMillis()
{
List<Element> durations = element.getChildren("Duration");
if (durations.size() != 0)
{
final String durationString = durations.get(0).getValue();
final long duration = Long.parseLong(durationString);
return duration;
}
else
{
throw new RuntimeException("No Duration elements present on track!");
}
} | [
"public",
"long",
"getDurationMillis",
"(",
")",
"{",
"List",
"<",
"Element",
">",
"durations",
"=",
"element",
".",
"getChildren",
"(",
"\"Duration\"",
")",
";",
"if",
"(",
"durations",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"final",
"String",
"d... | Gets duration of video track in milliseconds.
@return | [
"Gets",
"duration",
"of",
"video",
"track",
"in",
"milliseconds",
"."
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/util/carbon-client/src/main/java/com/peterphi/carbon/util/mediainfo/MediaInfoTrack.java#L27-L43 | train |
ziccardi/jnrpe | jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java | JNRPEServer.configureCommandLine | private static Group configureCommandLine() {
DefaultOptionBuilder oBuilder = new DefaultOptionBuilder();
ArgumentBuilder aBuilder = new ArgumentBuilder();
GroupBuilder gBuilder = new GroupBuilder();
DefaultOption listOption = oBuilder.withLongName("list").withShortName("l").withDescription("Lists all the installed plugins").create();
DefaultOption versionOption = oBuilder.withLongName("version").withShortName("v").withDescription("Print the server version number").create();
DefaultOption helpOption = oBuilder.withLongName("help").withShortName("h").withDescription("Show this help").create();
// DefaultOption pluginNameOption = oBuilder.withLongName("plugin")
// .withShortName("p").withDescription("The plugin name")
// .withArgument(
// aBuilder.withName("name").withMinimum(1).withMaximum(1)
// .create()).create();
DefaultOption pluginHelpOption = oBuilder.withLongName("help").withShortName("h").withDescription("Shows help about a plugin")
.withArgument(aBuilder.withName("name").withMinimum(1).withMaximum(1).create()).create();
Group alternativeOptions = gBuilder.withOption(listOption).withOption(pluginHelpOption).create();
DefaultOption confOption = oBuilder.withLongName("conf").withShortName("c").withDescription("Specifies the JNRPE configuration file")
.withArgument(aBuilder.withName("path").withMinimum(1).withMaximum(1).create()).withChildren(alternativeOptions).withRequired(true)
.create();
DefaultOption interactiveOption = oBuilder.withLongName("interactive").withShortName("i")
.withDescription("Starts JNRPE in command line mode").create();
Group jnrpeOptions = gBuilder.withOption(confOption).withOption(interactiveOption).withMinimum(1).create();
return gBuilder.withOption(versionOption).withOption(helpOption).withOption(jnrpeOptions).create();
} | java | private static Group configureCommandLine() {
DefaultOptionBuilder oBuilder = new DefaultOptionBuilder();
ArgumentBuilder aBuilder = new ArgumentBuilder();
GroupBuilder gBuilder = new GroupBuilder();
DefaultOption listOption = oBuilder.withLongName("list").withShortName("l").withDescription("Lists all the installed plugins").create();
DefaultOption versionOption = oBuilder.withLongName("version").withShortName("v").withDescription("Print the server version number").create();
DefaultOption helpOption = oBuilder.withLongName("help").withShortName("h").withDescription("Show this help").create();
// DefaultOption pluginNameOption = oBuilder.withLongName("plugin")
// .withShortName("p").withDescription("The plugin name")
// .withArgument(
// aBuilder.withName("name").withMinimum(1).withMaximum(1)
// .create()).create();
DefaultOption pluginHelpOption = oBuilder.withLongName("help").withShortName("h").withDescription("Shows help about a plugin")
.withArgument(aBuilder.withName("name").withMinimum(1).withMaximum(1).create()).create();
Group alternativeOptions = gBuilder.withOption(listOption).withOption(pluginHelpOption).create();
DefaultOption confOption = oBuilder.withLongName("conf").withShortName("c").withDescription("Specifies the JNRPE configuration file")
.withArgument(aBuilder.withName("path").withMinimum(1).withMaximum(1).create()).withChildren(alternativeOptions).withRequired(true)
.create();
DefaultOption interactiveOption = oBuilder.withLongName("interactive").withShortName("i")
.withDescription("Starts JNRPE in command line mode").create();
Group jnrpeOptions = gBuilder.withOption(confOption).withOption(interactiveOption).withMinimum(1).create();
return gBuilder.withOption(versionOption).withOption(helpOption).withOption(jnrpeOptions).create();
} | [
"private",
"static",
"Group",
"configureCommandLine",
"(",
")",
"{",
"DefaultOptionBuilder",
"oBuilder",
"=",
"new",
"DefaultOptionBuilder",
"(",
")",
";",
"ArgumentBuilder",
"aBuilder",
"=",
"new",
"ArgumentBuilder",
"(",
")",
";",
"GroupBuilder",
"gBuilder",
"=",
... | Configure the command line parser.
@return The configuration | [
"Configure",
"the",
"command",
"line",
"parser",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java#L71-L103 | train |
ziccardi/jnrpe | jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java | JNRPEServer.printHelp | private static void printHelp(final IPluginRepository pr, final String pluginName) {
try {
PluginProxy pp = (PluginProxy) pr.getPlugin(pluginName);
// CPluginProxy pp =
// CPluginFactory.getInstance().getPlugin(sPluginName);
if (pp == null) {
System.out.println("Plugin " + pluginName + " does not exists.");
} else {
pp.printHelp();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.exit(0);
} | java | private static void printHelp(final IPluginRepository pr, final String pluginName) {
try {
PluginProxy pp = (PluginProxy) pr.getPlugin(pluginName);
// CPluginProxy pp =
// CPluginFactory.getInstance().getPlugin(sPluginName);
if (pp == null) {
System.out.println("Plugin " + pluginName + " does not exists.");
} else {
pp.printHelp();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.exit(0);
} | [
"private",
"static",
"void",
"printHelp",
"(",
"final",
"IPluginRepository",
"pr",
",",
"final",
"String",
"pluginName",
")",
"{",
"try",
"{",
"PluginProxy",
"pp",
"=",
"(",
"PluginProxy",
")",
"pr",
".",
"getPlugin",
"(",
"pluginName",
")",
";",
"// CPlugin... | Prints the help about a plugin.
@param pr
The plugin repository
@param pluginName
The plugin name | [
"Prints",
"the",
"help",
"about",
"a",
"plugin",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java#L141-L157 | train |
ziccardi/jnrpe | jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java | JNRPEServer.printVersion | private static void printVersion() {
System.out.println("JNRPE version " + VERSION);
System.out.println("Copyright (c) 2011 Massimiliano Ziccardi");
System.out.println("Licensed under the Apache License, Version 2.0");
System.out.println();
} | java | private static void printVersion() {
System.out.println("JNRPE version " + VERSION);
System.out.println("Copyright (c) 2011 Massimiliano Ziccardi");
System.out.println("Licensed under the Apache License, Version 2.0");
System.out.println();
} | [
"private",
"static",
"void",
"printVersion",
"(",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"JNRPE version \"",
"+",
"VERSION",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Copyright (c) 2011 Massimiliano Ziccardi\"",
")",
";",
"System",
... | Prints the JNRPE Server version. | [
"Prints",
"the",
"JNRPE",
"Server",
"version",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java#L162-L167 | train |
ziccardi/jnrpe | jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java | JNRPEServer.printUsage | @SuppressWarnings("unchecked")
private static void printUsage(final Exception e) {
printVersion();
if (e != null) {
System.out.println(e.getMessage() + "\n");
}
HelpFormatter hf = new HelpFormatter();
StringBuilder sbDivider = new StringBuilder("=");
while (sbDivider.length() < hf.getPageWidth()) {
sbDivider.append("=");
}
// DISPLAY SETTING
hf.getDisplaySettings().clear();
hf.getDisplaySettings().add(DisplaySetting.DISPLAY_GROUP_EXPANDED);
hf.getDisplaySettings().add(DisplaySetting.DISPLAY_PARENT_CHILDREN);
// USAGE SETTING
hf.getFullUsageSettings().clear();
hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_PARENT_ARGUMENT);
hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_ARGUMENT_BRACKETED);
hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_PARENT_CHILDREN);
hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_GROUP_EXPANDED);
hf.setDivider(sbDivider.toString());
hf.setGroup(configureCommandLine());
hf.print();
System.exit(0);
} | java | @SuppressWarnings("unchecked")
private static void printUsage(final Exception e) {
printVersion();
if (e != null) {
System.out.println(e.getMessage() + "\n");
}
HelpFormatter hf = new HelpFormatter();
StringBuilder sbDivider = new StringBuilder("=");
while (sbDivider.length() < hf.getPageWidth()) {
sbDivider.append("=");
}
// DISPLAY SETTING
hf.getDisplaySettings().clear();
hf.getDisplaySettings().add(DisplaySetting.DISPLAY_GROUP_EXPANDED);
hf.getDisplaySettings().add(DisplaySetting.DISPLAY_PARENT_CHILDREN);
// USAGE SETTING
hf.getFullUsageSettings().clear();
hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_PARENT_ARGUMENT);
hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_ARGUMENT_BRACKETED);
hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_PARENT_CHILDREN);
hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_GROUP_EXPANDED);
hf.setDivider(sbDivider.toString());
hf.setGroup(configureCommandLine());
hf.print();
System.exit(0);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"static",
"void",
"printUsage",
"(",
"final",
"Exception",
"e",
")",
"{",
"printVersion",
"(",
")",
";",
"if",
"(",
"e",
"!=",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"... | Prints the JNRPE Server usage and, eventually, the error about the last
invocation.
@param e
The last error. Can be null. | [
"Prints",
"the",
"JNRPE",
"Server",
"usage",
"and",
"eventually",
"the",
"error",
"about",
"the",
"last",
"invocation",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java#L176-L208 | train |
ziccardi/jnrpe | jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java | JNRPEServer.loadConfiguration | private static JNRPEConfiguration loadConfiguration(final String configurationFilePath) throws ConfigurationException {
File confFile = new File(configurationFilePath);
if (!confFile.exists() || !confFile.canRead()) {
throw new ConfigurationException("Cannot access config file : " + configurationFilePath);
}
return JNRPEConfigurationFactory.createConfiguration(configurationFilePath);
} | java | private static JNRPEConfiguration loadConfiguration(final String configurationFilePath) throws ConfigurationException {
File confFile = new File(configurationFilePath);
if (!confFile.exists() || !confFile.canRead()) {
throw new ConfigurationException("Cannot access config file : " + configurationFilePath);
}
return JNRPEConfigurationFactory.createConfiguration(configurationFilePath);
} | [
"private",
"static",
"JNRPEConfiguration",
"loadConfiguration",
"(",
"final",
"String",
"configurationFilePath",
")",
"throws",
"ConfigurationException",
"{",
"File",
"confFile",
"=",
"new",
"File",
"(",
"configurationFilePath",
")",
";",
"if",
"(",
"!",
"confFile",
... | Loads the JNRPE configuration from the INI or the XML file.
@param configurationFilePath
The path to the configuration file
@return The parsed configuration.
@throws ConfigurationException
- | [
"Loads",
"the",
"JNRPE",
"configuration",
"from",
"the",
"INI",
"or",
"the",
"XML",
"file",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java#L219-L228 | train |
ziccardi/jnrpe | jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java | JNRPEServer.loadPluginDefinitions | private static IPluginRepository loadPluginDefinitions(final String sPluginDirPath) throws PluginConfigurationException {
File fDir = new File(sPluginDirPath);
DynaPluginRepository repo = new DynaPluginRepository();
repo.load(fDir);
return repo;
} | java | private static IPluginRepository loadPluginDefinitions(final String sPluginDirPath) throws PluginConfigurationException {
File fDir = new File(sPluginDirPath);
DynaPluginRepository repo = new DynaPluginRepository();
repo.load(fDir);
return repo;
} | [
"private",
"static",
"IPluginRepository",
"loadPluginDefinitions",
"(",
"final",
"String",
"sPluginDirPath",
")",
"throws",
"PluginConfigurationException",
"{",
"File",
"fDir",
"=",
"new",
"File",
"(",
"sPluginDirPath",
")",
";",
"DynaPluginRepository",
"repo",
"=",
"... | Loads a plugin repository from a directory.
@param sPluginDirPath
The path to the directory
@return The plugin repository
@throws PluginConfigurationException
- | [
"Loads",
"a",
"plugin",
"repository",
"from",
"a",
"directory",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java#L239-L245 | train |
ziccardi/jnrpe | jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java | JNRPEServer.printPluginList | private static void printPluginList(final IPluginRepository pr) {
System.out.println("List of installed plugins : ");
for (PluginDefinition pd : pr.getAllPlugins()) {
System.out.println(" * " + pd.getName());
}
System.exit(0);
} | java | private static void printPluginList(final IPluginRepository pr) {
System.out.println("List of installed plugins : ");
for (PluginDefinition pd : pr.getAllPlugins()) {
System.out.println(" * " + pd.getName());
}
System.exit(0);
} | [
"private",
"static",
"void",
"printPluginList",
"(",
"final",
"IPluginRepository",
"pr",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"List of installed plugins : \"",
")",
";",
"for",
"(",
"PluginDefinition",
"pd",
":",
"pr",
".",
"getAllPlugins",
"("... | Prints the list of installed plugins.
@param pr
The plugin repository | [
"Prints",
"the",
"list",
"of",
"installed",
"plugins",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-server/src/main/java/it/jnrpe/server/JNRPEServer.java#L253-L261 | train |
petergeneric/stdlib | util/carbon-client/src/main/java/com/peterphi/carbon/type/XMLWrapper.java | XMLWrapper.setAttribute | public void setAttribute(String name, String value)
{
if (value != null)
getElement().setAttribute(name, value);
else
getElement().removeAttribute(name);
} | java | public void setAttribute(String name, String value)
{
if (value != null)
getElement().setAttribute(name, value);
else
getElement().removeAttribute(name);
} | [
"public",
"void",
"setAttribute",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
")",
"getElement",
"(",
")",
".",
"setAttribute",
"(",
"name",
",",
"value",
")",
";",
"else",
"getElement",
"(",
")",
".",
"... | Helper method to set the value of an attribute on this Element
@param name
the attribute name
@param value
the value to set - if null the attribute is removed | [
"Helper",
"method",
"to",
"set",
"the",
"value",
"of",
"an",
"attribute",
"on",
"this",
"Element"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/util/carbon-client/src/main/java/com/peterphi/carbon/type/XMLWrapper.java#L40-L46 | train |
petergeneric/stdlib | util/carbon-client/src/main/java/com/peterphi/carbon/type/XMLWrapper.java | XMLWrapper.getElement | protected Element getElement(String name, int index)
{
List<Element> children = getElement().getChildren(name);
if (children.size() > index)
return children.get(index);
else
return null;
} | java | protected Element getElement(String name, int index)
{
List<Element> children = getElement().getChildren(name);
if (children.size() > index)
return children.get(index);
else
return null;
} | [
"protected",
"Element",
"getElement",
"(",
"String",
"name",
",",
"int",
"index",
")",
"{",
"List",
"<",
"Element",
">",
"children",
"=",
"getElement",
"(",
")",
".",
"getChildren",
"(",
"name",
")",
";",
"if",
"(",
"children",
".",
"size",
"(",
")",
... | Helper method to retrieve a child element with a particular name and index
@param name
the name of the element
@param index
the index (where 0 is the first element with that name)
@return an Element (or null if none could be found by that name or with that index) | [
"Helper",
"method",
"to",
"retrieve",
"a",
"child",
"element",
"with",
"a",
"particular",
"name",
"and",
"index"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/util/carbon-client/src/main/java/com/peterphi/carbon/type/XMLWrapper.java#L72-L80 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/stringparsing/TimeoutConverter.java | TimeoutConverter.pickUnit | private static @NotNull
TimeUnit pickUnit(final @NotNull Duration iso)
{
final long millis = iso.toMillis();
// Special-case values under 1 second
if (millis < 1000)
return TimeUnit.MILLISECONDS;
final long SECOND = 1000;
final long MINUTE = 60 * SECOND;
final long HOUR = 60 * MINUTE;
final long DAY = 24 * HOUR;
if (millis % DAY == 0)
return TimeUnit.DAYS;
else if (millis % HOUR == 0)
return TimeUnit.HOURS;
else if (millis % MINUTE == 0)
return TimeUnit.MINUTES;
else if (millis % SECOND == 0)
return TimeUnit.SECONDS;
else
return TimeUnit.MILLISECONDS;
} | java | private static @NotNull
TimeUnit pickUnit(final @NotNull Duration iso)
{
final long millis = iso.toMillis();
// Special-case values under 1 second
if (millis < 1000)
return TimeUnit.MILLISECONDS;
final long SECOND = 1000;
final long MINUTE = 60 * SECOND;
final long HOUR = 60 * MINUTE;
final long DAY = 24 * HOUR;
if (millis % DAY == 0)
return TimeUnit.DAYS;
else if (millis % HOUR == 0)
return TimeUnit.HOURS;
else if (millis % MINUTE == 0)
return TimeUnit.MINUTES;
else if (millis % SECOND == 0)
return TimeUnit.SECONDS;
else
return TimeUnit.MILLISECONDS;
} | [
"private",
"static",
"@",
"NotNull",
"TimeUnit",
"pickUnit",
"(",
"final",
"@",
"NotNull",
"Duration",
"iso",
")",
"{",
"final",
"long",
"millis",
"=",
"iso",
".",
"toMillis",
"(",
")",
";",
"// Special-case values under 1 second",
"if",
"(",
"millis",
"<",
... | Identify the largest unit that can accurately represent the provided duration
@param iso
@return | [
"Identify",
"the",
"largest",
"unit",
"that",
"can",
"accurately",
"represent",
"the",
"provided",
"duration"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/stringparsing/TimeoutConverter.java#L70-L94 | train |
ops4j/org.ops4j.pax.swissbox | pax-swissbox-tracker/src/main/java/org/ops4j/pax/swissbox/tracker/ServiceCollection.java | ServiceCollection.iterator | @SuppressWarnings( "unchecked" )
public Iterator<T> iterator()
{
final List<T> services = new ArrayList<T>();
if( m_serviceTracker != null )
{
final Object[] trackedServices = m_serviceTracker.getServices();
if( trackedServices != null )
{
for( Object trackedService : trackedServices )
{
services.add( (T) trackedService );
}
}
}
return Collections.unmodifiableCollection( services ).iterator();
} | java | @SuppressWarnings( "unchecked" )
public Iterator<T> iterator()
{
final List<T> services = new ArrayList<T>();
if( m_serviceTracker != null )
{
final Object[] trackedServices = m_serviceTracker.getServices();
if( trackedServices != null )
{
for( Object trackedService : trackedServices )
{
services.add( (T) trackedService );
}
}
}
return Collections.unmodifiableCollection( services ).iterator();
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Iterator",
"<",
"T",
">",
"iterator",
"(",
")",
"{",
"final",
"List",
"<",
"T",
">",
"services",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"if",
"(",
"m_serviceTracker",
"!=",
... | Returns an iterator over the tracked services at the call point in time.
Note that a susequent call can produce a different list of services as the services are dynamic.
If there are no services available returns an empty iterator.
@see Iterable#iterator() | [
"Returns",
"an",
"iterator",
"over",
"the",
"tracked",
"services",
"at",
"the",
"call",
"point",
"in",
"time",
".",
"Note",
"that",
"a",
"susequent",
"call",
"can",
"produce",
"a",
"different",
"list",
"of",
"services",
"as",
"the",
"services",
"are",
"dyn... | 00b0ee16cdbe8017984a4d7ba808b10d985c5b5c | https://github.com/ops4j/org.ops4j.pax.swissbox/blob/00b0ee16cdbe8017984a4d7ba808b10d985c5b5c/pax-swissbox-tracker/src/main/java/org/ops4j/pax/swissbox/tracker/ServiceCollection.java#L113-L129 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/jaxbref/JAXBResourceFactory.java | JAXBResourceFactory.get | public <T> T get(Class<T> clazz, final String name)
{
JAXBNamedResourceFactory<T> cached = cachedReferences.get(name);
if (cached == null)
{
cached = new JAXBNamedResourceFactory<T>(this.config, this.factory, name, clazz);
cachedReferences.put(name, cached);
}
return cached.get();
} | java | public <T> T get(Class<T> clazz, final String name)
{
JAXBNamedResourceFactory<T> cached = cachedReferences.get(name);
if (cached == null)
{
cached = new JAXBNamedResourceFactory<T>(this.config, this.factory, name, clazz);
cachedReferences.put(name, cached);
}
return cached.get();
} | [
"public",
"<",
"T",
">",
"T",
"get",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"String",
"name",
")",
"{",
"JAXBNamedResourceFactory",
"<",
"T",
">",
"cached",
"=",
"cachedReferences",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"cached",... | Resolve the JAXB resource, permitting caching behind the scenes
@param clazz
the jaxb resource to read
@param name
the name of the property
@param <T>
@return | [
"Resolve",
"the",
"JAXB",
"resource",
"permitting",
"caching",
"behind",
"the",
"scenes"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/jaxbref/JAXBResourceFactory.java#L39-L50 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/jaxbref/JAXBResourceFactory.java | JAXBResourceFactory.getOnce | public <T> T getOnce(final Class<T> clazz, final String name)
{
return new JAXBNamedResourceFactory<T>(this.config, this.factory, name, clazz).get();
} | java | public <T> T getOnce(final Class<T> clazz, final String name)
{
return new JAXBNamedResourceFactory<T>(this.config, this.factory, name, clazz).get();
} | [
"public",
"<",
"T",
">",
"T",
"getOnce",
"(",
"final",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"String",
"name",
")",
"{",
"return",
"new",
"JAXBNamedResourceFactory",
"<",
"T",
">",
"(",
"this",
".",
"config",
",",
"this",
".",
"factory",
","... | Resolve the JAXB resource once without caching anything
@param clazz
@param name
@param <T>
@return | [
"Resolve",
"the",
"JAXB",
"resource",
"once",
"without",
"caching",
"anything"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/jaxbref/JAXBResourceFactory.java#L89-L92 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/util/DOMUtils.java | DOMUtils.pretty | public static String pretty(final Source source)
{
StreamResult result = new StreamResult(new StringWriter());
pretty(source, result);
return result.getWriter().toString();
} | java | public static String pretty(final Source source)
{
StreamResult result = new StreamResult(new StringWriter());
pretty(source, result);
return result.getWriter().toString();
} | [
"public",
"static",
"String",
"pretty",
"(",
"final",
"Source",
"source",
")",
"{",
"StreamResult",
"result",
"=",
"new",
"StreamResult",
"(",
"new",
"StringWriter",
"(",
")",
")",
";",
"pretty",
"(",
"source",
",",
"result",
")",
";",
"return",
"result",
... | Serialise the provided source to a pretty-printed String with the default indent settings
@param source the input Source | [
"Serialise",
"the",
"provided",
"source",
"to",
"a",
"pretty",
"-",
"printed",
"String",
"with",
"the",
"default",
"indent",
"settings"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/util/DOMUtils.java#L244-L251 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/util/DOMUtils.java | DOMUtils.pretty | public static void pretty(final Source input, final StreamResult output)
{
try
{
// Configure transformer
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", Integer.toString(DEFAULT_INDENT));
transformer.transform(input, output);
}
catch (Throwable t)
{
throw new RuntimeException("Error during pretty-print operation", t);
}
} | java | public static void pretty(final Source input, final StreamResult output)
{
try
{
// Configure transformer
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", Integer.toString(DEFAULT_INDENT));
transformer.transform(input, output);
}
catch (Throwable t)
{
throw new RuntimeException("Error during pretty-print operation", t);
}
} | [
"public",
"static",
"void",
"pretty",
"(",
"final",
"Source",
"input",
",",
"final",
"StreamResult",
"output",
")",
"{",
"try",
"{",
"// Configure transformer",
"Transformer",
"transformer",
"=",
"TransformerFactory",
".",
"newInstance",
"(",
")",
".",
"newTransfo... | Serialise the provided source to the provided destination, pretty-printing with the default indent settings
@param input the source
@param output the destination | [
"Serialise",
"the",
"provided",
"source",
"to",
"the",
"provided",
"destination",
"pretty",
"-",
"printing",
"with",
"the",
"default",
"indent",
"settings"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/util/DOMUtils.java#L260-L278 | train |
petergeneric/stdlib | guice/freemarker/src/main/java/com/peterphi/std/guice/freemarker/FreemarkerCall.java | FreemarkerCall.process | @Override
public void process(Writer writer)
{
try
{
template.process(data, writer);
}
catch (IOException e)
{
throw new RuntimeException("Error writing template to writer", e);
}
catch (TemplateException e)
{
throw new RuntimeException(e.getMessage(), e);
}
} | java | @Override
public void process(Writer writer)
{
try
{
template.process(data, writer);
}
catch (IOException e)
{
throw new RuntimeException("Error writing template to writer", e);
}
catch (TemplateException e)
{
throw new RuntimeException(e.getMessage(), e);
}
} | [
"@",
"Override",
"public",
"void",
"process",
"(",
"Writer",
"writer",
")",
"{",
"try",
"{",
"template",
".",
"process",
"(",
"data",
",",
"writer",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"... | Render the template to a Writer | [
"Render",
"the",
"template",
"to",
"a",
"Writer"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/freemarker/src/main/java/com/peterphi/std/guice/freemarker/FreemarkerCall.java#L77-L92 | train |
petergeneric/stdlib | service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/logging/hub/LoggingService.java | LoggingService.storeWithSubscribers | private void storeWithSubscribers(final List<LogLineTableEntity> lines)
{
synchronized (subscribers)
{
if (subscribers.isEmpty())
return; // No subscribers, ignore call
for (LogSubscriber subscriber : subscribers)
{
subscriber.append(lines);
}
if (System.currentTimeMillis() > nextSubscriberPurge)
{
purgeIdleSubscribers();
nextSubscriberPurge = System.currentTimeMillis() + purgeSubscriberInterval.getMilliseconds();
}
}
} | java | private void storeWithSubscribers(final List<LogLineTableEntity> lines)
{
synchronized (subscribers)
{
if (subscribers.isEmpty())
return; // No subscribers, ignore call
for (LogSubscriber subscriber : subscribers)
{
subscriber.append(lines);
}
if (System.currentTimeMillis() > nextSubscriberPurge)
{
purgeIdleSubscribers();
nextSubscriberPurge = System.currentTimeMillis() + purgeSubscriberInterval.getMilliseconds();
}
}
} | [
"private",
"void",
"storeWithSubscribers",
"(",
"final",
"List",
"<",
"LogLineTableEntity",
">",
"lines",
")",
"{",
"synchronized",
"(",
"subscribers",
")",
"{",
"if",
"(",
"subscribers",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"// No subscribers, ignore c... | Makes the provided log lines available to all log tail subscribers
@param lines | [
"Makes",
"the",
"provided",
"log",
"lines",
"available",
"to",
"all",
"log",
"tail",
"subscribers"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/logging/hub/LoggingService.java#L108-L127 | train |
petergeneric/stdlib | user-manager/service/src/main/java/com/peterphi/usermanager/guice/authentication/UserLoginModule.java | UserLoginModule.getLogin | @Provides
@SessionScoped
public UserLogin getLogin(@Named(JAXRS_SERVER_WEBAUTH_PROVIDER) CurrentUser user)
{
return (UserLogin) user;
} | java | @Provides
@SessionScoped
public UserLogin getLogin(@Named(JAXRS_SERVER_WEBAUTH_PROVIDER) CurrentUser user)
{
return (UserLogin) user;
} | [
"@",
"Provides",
"@",
"SessionScoped",
"public",
"UserLogin",
"getLogin",
"(",
"@",
"Named",
"(",
"JAXRS_SERVER_WEBAUTH_PROVIDER",
")",
"CurrentUser",
"user",
")",
"{",
"return",
"(",
"UserLogin",
")",
"user",
";",
"}"
] | Auto-cast the user manager's CurrentUser to a UserLogin
@param user
@return | [
"Auto",
"-",
"cast",
"the",
"user",
"manager",
"s",
"CurrentUser",
"to",
"a",
"UserLogin"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/user-manager/service/src/main/java/com/peterphi/usermanager/guice/authentication/UserLoginModule.java#L72-L77 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/plugins/PluginRepository.java | PluginRepository.getPlugin | public final IPluginInterface getPlugin(final String name) throws UnknownPluginException {
PluginDefinition pluginDef = pluginsDefinitionsMap.get(name);
if (pluginDef == null) {
throw new UnknownPluginException(name);
}
try {
IPluginInterface pluginInterface = pluginDef.getPluginInterface();
if (pluginInterface == null) {
pluginInterface = pluginDef.getPluginClass().newInstance();
}
return new PluginProxy(pluginInterface, pluginDef);
} catch (Exception e) {
// FIXME : handle this exception
e.printStackTrace();
}
return null;
} | java | public final IPluginInterface getPlugin(final String name) throws UnknownPluginException {
PluginDefinition pluginDef = pluginsDefinitionsMap.get(name);
if (pluginDef == null) {
throw new UnknownPluginException(name);
}
try {
IPluginInterface pluginInterface = pluginDef.getPluginInterface();
if (pluginInterface == null) {
pluginInterface = pluginDef.getPluginClass().newInstance();
}
return new PluginProxy(pluginInterface, pluginDef);
} catch (Exception e) {
// FIXME : handle this exception
e.printStackTrace();
}
return null;
} | [
"public",
"final",
"IPluginInterface",
"getPlugin",
"(",
"final",
"String",
"name",
")",
"throws",
"UnknownPluginException",
"{",
"PluginDefinition",
"pluginDef",
"=",
"pluginsDefinitionsMap",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"pluginDef",
"==",
"null"... | Returns the implementation of the plugin identified by the given name.
@param name
The plugin name
@return the plugin identified by the given name * @throws UnknownPluginException
if no plugin with the given name exists. * @see it.jnrpe.plugins.IPluginRepository#getPlugin(String) | [
"Returns",
"the",
"implementation",
"of",
"the",
"plugin",
"identified",
"by",
"the",
"given",
"name",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/plugins/PluginRepository.java#L70-L89 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/util/JDOMUtils.java | JDOMUtils.convert | public static org.w3c.dom.Element convert(org.jdom2.Element node) throws JDOMException
{
if (node == null)
return null; // Convert null->null
try
{
DOMOutputter outputter = new DOMOutputter();
return outputter.output(node);
}
catch (JDOMException e)
{
throw new RuntimeException("Error converting JDOM to DOM: " + e.getMessage(), e);
}
} | java | public static org.w3c.dom.Element convert(org.jdom2.Element node) throws JDOMException
{
if (node == null)
return null; // Convert null->null
try
{
DOMOutputter outputter = new DOMOutputter();
return outputter.output(node);
}
catch (JDOMException e)
{
throw new RuntimeException("Error converting JDOM to DOM: " + e.getMessage(), e);
}
} | [
"public",
"static",
"org",
".",
"w3c",
".",
"dom",
".",
"Element",
"convert",
"(",
"org",
".",
"jdom2",
".",
"Element",
"node",
")",
"throws",
"JDOMException",
"{",
"if",
"(",
"node",
"==",
"null",
")",
"return",
"null",
";",
"// Convert null->null",
"tr... | Convert a JDOM Element to a DOM Element
@param node
@return | [
"Convert",
"a",
"JDOM",
"Element",
"to",
"a",
"DOM",
"Element"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/util/JDOMUtils.java#L81-L96 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/util/JDOMUtils.java | JDOMUtils.convert | public static org.jdom2.Element convert(org.w3c.dom.Element node)
{
if (node == null)
return null; // Convert null->null
DOMBuilder builder = new DOMBuilder();
return builder.build(node);
} | java | public static org.jdom2.Element convert(org.w3c.dom.Element node)
{
if (node == null)
return null; // Convert null->null
DOMBuilder builder = new DOMBuilder();
return builder.build(node);
} | [
"public",
"static",
"org",
".",
"jdom2",
".",
"Element",
"convert",
"(",
"org",
".",
"w3c",
".",
"dom",
".",
"Element",
"node",
")",
"{",
"if",
"(",
"node",
"==",
"null",
")",
"return",
"null",
";",
"// Convert null->null",
"DOMBuilder",
"builder",
"=",
... | Convert a DOM Element to a JDOM Element
@param node
@return | [
"Convert",
"a",
"DOM",
"Element",
"to",
"a",
"JDOM",
"Element"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/util/JDOMUtils.java#L105-L113 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/serviceregistry/rest/RestResourceRegistry.java | RestResourceRegistry.register | public static synchronized void register(Class<?> clazz, boolean indexable)
{
if (!resources.containsKey(clazz))
{
resources.put(clazz, new RestResource(clazz));
// Optionally register this service as Indexable
if (indexable)
{
IndexableServiceRegistry.register(clazz);
}
revision++;
}
} | java | public static synchronized void register(Class<?> clazz, boolean indexable)
{
if (!resources.containsKey(clazz))
{
resources.put(clazz, new RestResource(clazz));
// Optionally register this service as Indexable
if (indexable)
{
IndexableServiceRegistry.register(clazz);
}
revision++;
}
} | [
"public",
"static",
"synchronized",
"void",
"register",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"boolean",
"indexable",
")",
"{",
"if",
"(",
"!",
"resources",
".",
"containsKey",
"(",
"clazz",
")",
")",
"{",
"resources",
".",
"put",
"(",
"clazz",
",... | Register a new resource - N.B. currently this resource cannot be safely unregistered without restarting the webapp
@param clazz
@param indexable
true if this service should also be exposed to any configured index service | [
"Register",
"a",
"new",
"resource",
"-",
"N",
".",
"B",
".",
"currently",
"this",
"resource",
"cannot",
"be",
"safely",
"unregistered",
"without",
"restarting",
"the",
"webapp"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/serviceregistry/rest/RestResourceRegistry.java#L36-L50 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/util/jaxb/XSDValidator.java | XSDValidator.validate | public void validate(final Node document) throws SchemaValidationException
{
try
{
final Validator validator = schema.newValidator();
validator.validate(new DOMSource(document));
}
catch (SAXException | IOException e)
{
throw new SchemaValidationException(e.getMessage(), e);
}
} | java | public void validate(final Node document) throws SchemaValidationException
{
try
{
final Validator validator = schema.newValidator();
validator.validate(new DOMSource(document));
}
catch (SAXException | IOException e)
{
throw new SchemaValidationException(e.getMessage(), e);
}
} | [
"public",
"void",
"validate",
"(",
"final",
"Node",
"document",
")",
"throws",
"SchemaValidationException",
"{",
"try",
"{",
"final",
"Validator",
"validator",
"=",
"schema",
".",
"newValidator",
"(",
")",
";",
"validator",
".",
"validate",
"(",
"new",
"DOMSou... | Validate some XML against this schema
@param document
@throws SchemaValidationException
if the document does not validate against the schema | [
"Validate",
"some",
"XML",
"against",
"this",
"schema"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/util/jaxb/XSDValidator.java#L174-L186 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/NegativeInfinityStage.java | NegativeInfinityStage.parse | @Override
public String parse(final String threshold, final RangeConfig tc) {
tc.setNegativeInfinity(true);
if (threshold.startsWith(INFINITY)) {
return threshold.substring(INFINITY.length());
} else {
return threshold.substring(NEG_INFINITY.length());
}
} | java | @Override
public String parse(final String threshold, final RangeConfig tc) {
tc.setNegativeInfinity(true);
if (threshold.startsWith(INFINITY)) {
return threshold.substring(INFINITY.length());
} else {
return threshold.substring(NEG_INFINITY.length());
}
} | [
"@",
"Override",
"public",
"String",
"parse",
"(",
"final",
"String",
"threshold",
",",
"final",
"RangeConfig",
"tc",
")",
"{",
"tc",
".",
"setNegativeInfinity",
"(",
"true",
")",
";",
"if",
"(",
"threshold",
".",
"startsWith",
"(",
"INFINITY",
")",
")",
... | Parses the threshold to remove the matched '-inf' or 'inf' string.
No checks are performed against the passed in string: the object assumes
that the string is correct since the {@link #canParse(String)} method
<b>must</b> be called <b>before</b> this method.
@param threshold
The threshold chunk to be parsed
@param tc
The threshold config object. This object will be populated
according to the passed in threshold.
@return the remaining part of the threshold * @see RangeConfig#setNegativeInfinity(boolean) | [
"Parses",
"the",
"threshold",
"to",
"remove",
"the",
"matched",
"-",
"inf",
"or",
"inf",
"string",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/NegativeInfinityStage.java#L70-L80 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/internal/InjectionUtils.java | InjectionUtils.inject | @SuppressWarnings("rawtypes")
private static void inject(final Class c, final IPluginInterface plugin, final IJNRPEExecutionContext context) throws IllegalAccessException {
final Field[] fields = c.getDeclaredFields();
for (final Field f : fields) {
final Annotation an = f.getAnnotation(Inject.class);
if (an != null) {
final boolean isAccessible = f.isAccessible();
if (!isAccessible) {
// Change accessible flag if necessary
f.setAccessible(true);
}
f.set(plugin, context);
if (!isAccessible) {
// Restore accessible flag if necessary
f.setAccessible(false);
}
}
}
} | java | @SuppressWarnings("rawtypes")
private static void inject(final Class c, final IPluginInterface plugin, final IJNRPEExecutionContext context) throws IllegalAccessException {
final Field[] fields = c.getDeclaredFields();
for (final Field f : fields) {
final Annotation an = f.getAnnotation(Inject.class);
if (an != null) {
final boolean isAccessible = f.isAccessible();
if (!isAccessible) {
// Change accessible flag if necessary
f.setAccessible(true);
}
f.set(plugin, context);
if (!isAccessible) {
// Restore accessible flag if necessary
f.setAccessible(false);
}
}
}
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"private",
"static",
"void",
"inject",
"(",
"final",
"Class",
"c",
",",
"final",
"IPluginInterface",
"plugin",
",",
"final",
"IJNRPEExecutionContext",
"context",
")",
"throws",
"IllegalAccessException",
"{",
"final"... | Perform the real injection.
@param c the object class
@param plugin teh plugin instance
@param context the context to be injected
@throws IllegalAccessException on any error accessing the field | [
"Perform",
"the",
"real",
"injection",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/internal/InjectionUtils.java#L48-L71 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/internal/InjectionUtils.java | InjectionUtils.inject | @SuppressWarnings("rawtypes")
public static void inject(final IPluginInterface plugin, final IJNRPEExecutionContext context) {
try {
Class clazz = plugin.getClass();
inject(clazz, plugin, context);
while (IPluginInterface.class.isAssignableFrom(clazz.getSuperclass())) {
clazz = clazz.getSuperclass();
inject(clazz, plugin, context);
}
} catch (Exception e) {
throw new Error(e.getMessage(), e);
}
} | java | @SuppressWarnings("rawtypes")
public static void inject(final IPluginInterface plugin, final IJNRPEExecutionContext context) {
try {
Class clazz = plugin.getClass();
inject(clazz, plugin, context);
while (IPluginInterface.class.isAssignableFrom(clazz.getSuperclass())) {
clazz = clazz.getSuperclass();
inject(clazz, plugin, context);
}
} catch (Exception e) {
throw new Error(e.getMessage(), e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"void",
"inject",
"(",
"final",
"IPluginInterface",
"plugin",
",",
"final",
"IJNRPEExecutionContext",
"context",
")",
"{",
"try",
"{",
"Class",
"clazz",
"=",
"plugin",
".",
"getClass",
"(",
... | Inject JNRPE code inside the passed in plugin.
The annotation is searched in the whole hierarchy.
@param plugin plugin to be injected
@param context the jnrpe context | [
"Inject",
"JNRPE",
"code",
"inside",
"the",
"passed",
"in",
"plugin",
".",
"The",
"annotation",
"is",
"searched",
"in",
"the",
"whole",
"hierarchy",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/internal/InjectionUtils.java#L80-L94 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/NumberBoundaryStage.java | NumberBoundaryStage.parse | @Override
public String parse(final String threshold, final RangeConfig tc) throws RangeException {
StringBuilder numberString = new StringBuilder();
for (int i = 0; i < threshold.length(); i++) {
if (Character.isDigit(threshold.charAt(i))) {
numberString.append(threshold.charAt(i));
continue;
}
if (threshold.charAt(i) == '.') {
if (numberString.toString().endsWith(".")) {
numberString.deleteCharAt(numberString.length() - 1);
break;
} else {
numberString.append(threshold.charAt(i));
continue;
}
}
if (threshold.charAt(i) == '+' || threshold.charAt(i) == '-') {
if (numberString.length() == 0) {
numberString.append(threshold.charAt(i));
continue;
} else {
throw new RangeException("Unexpected '" + threshold.charAt(i) + "' sign parsing boundary");
}
}
// throw new InvalidRangeSyntaxException(this,
// threshold.substring(numberString.length()));
break;
}
if (numberString.length() != 0 && !justSign(numberString.toString())) {
BigDecimal bd = new BigDecimal(numberString.toString());
setBoundary(tc, bd);
return threshold.substring(numberString.length());
} else {
throw new InvalidRangeSyntaxException(this, threshold);
}
} | java | @Override
public String parse(final String threshold, final RangeConfig tc) throws RangeException {
StringBuilder numberString = new StringBuilder();
for (int i = 0; i < threshold.length(); i++) {
if (Character.isDigit(threshold.charAt(i))) {
numberString.append(threshold.charAt(i));
continue;
}
if (threshold.charAt(i) == '.') {
if (numberString.toString().endsWith(".")) {
numberString.deleteCharAt(numberString.length() - 1);
break;
} else {
numberString.append(threshold.charAt(i));
continue;
}
}
if (threshold.charAt(i) == '+' || threshold.charAt(i) == '-') {
if (numberString.length() == 0) {
numberString.append(threshold.charAt(i));
continue;
} else {
throw new RangeException("Unexpected '" + threshold.charAt(i) + "' sign parsing boundary");
}
}
// throw new InvalidRangeSyntaxException(this,
// threshold.substring(numberString.length()));
break;
}
if (numberString.length() != 0 && !justSign(numberString.toString())) {
BigDecimal bd = new BigDecimal(numberString.toString());
setBoundary(tc, bd);
return threshold.substring(numberString.length());
} else {
throw new InvalidRangeSyntaxException(this, threshold);
}
} | [
"@",
"Override",
"public",
"String",
"parse",
"(",
"final",
"String",
"threshold",
",",
"final",
"RangeConfig",
"tc",
")",
"throws",
"RangeException",
"{",
"StringBuilder",
"numberString",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"... | Parses the threshold to remove the matched number string.
No checks are performed against the passed in string: the object assumes
that the string is correct since the {@link #canParse(String)} method
<b>must</b> be called <b>before</b> this method.
@param threshold
The threshold chunk to be parsed
@param tc
The threshold config object. This object will be populated
according to the passed in threshold.
@return the remaining part of the threshold * @throws RangeException
if the threshold can't be parsed | [
"Parses",
"the",
"threshold",
"to",
"remove",
"the",
"matched",
"number",
"string",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/NumberBoundaryStage.java#L52-L88 | train |
petergeneric/stdlib | rules/src/main/java/com/peterphi/rules/types/Rule.java | Rule.assessMatch | public boolean assessMatch(final OgnlContext ognlContext) throws OgnlException
{
if (! inputRun)
{
throw new IllegalArgumentException("Attempted to match on a rule whose rulesets input has not yet been produced");
}
final Object result = condition.run(ognlContext, ognlContext);
if (result == null || !Boolean.class.isAssignableFrom(result.getClass()))
{
throw new IllegalArgumentException("Expression " + condition.getOriginalExpression() +
" did not return a boolean value");
}
matches = (Boolean) result;
return matches;
} | java | public boolean assessMatch(final OgnlContext ognlContext) throws OgnlException
{
if (! inputRun)
{
throw new IllegalArgumentException("Attempted to match on a rule whose rulesets input has not yet been produced");
}
final Object result = condition.run(ognlContext, ognlContext);
if (result == null || !Boolean.class.isAssignableFrom(result.getClass()))
{
throw new IllegalArgumentException("Expression " + condition.getOriginalExpression() +
" did not return a boolean value");
}
matches = (Boolean) result;
return matches;
} | [
"public",
"boolean",
"assessMatch",
"(",
"final",
"OgnlContext",
"ognlContext",
")",
"throws",
"OgnlException",
"{",
"if",
"(",
"!",
"inputRun",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Attempted to match on a rule whose rulesets input has not yet been ... | returns true if the rules condition holds, should not be called until after the rule sets input has been produced
@param ognlContext
@return
@throws OgnlException | [
"returns",
"true",
"if",
"the",
"rules",
"condition",
"holds",
"should",
"not",
"be",
"called",
"until",
"after",
"the",
"rule",
"sets",
"input",
"has",
"been",
"produced"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/rules/src/main/java/com/peterphi/rules/types/Rule.java#L62-L81 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/crypto/PEMHelper.java | PEMHelper.loadCertificates | public static KeyStore loadCertificates(final File pemFile)
{
try (final PemReader pem = new PemReader(new FileReader(pemFile)))
{
final KeyStore ks = createEmptyKeyStore();
int certIndex = 0;
Object obj;
while ((obj = parse(pem.readPemObject())) != null)
{
if (obj instanceof Certificate)
{
final Certificate cert = (Certificate) obj;
ks.setCertificateEntry("cert" + Integer.toString(certIndex++), cert);
}
else
{
throw new RuntimeException("Unknown PEM contents: " + obj + ". Expected a Certificate");
}
}
return ks;
}
catch (Exception e)
{
throw new RuntimeException("Error parsing PEM " + pemFile, e);
}
} | java | public static KeyStore loadCertificates(final File pemFile)
{
try (final PemReader pem = new PemReader(new FileReader(pemFile)))
{
final KeyStore ks = createEmptyKeyStore();
int certIndex = 0;
Object obj;
while ((obj = parse(pem.readPemObject())) != null)
{
if (obj instanceof Certificate)
{
final Certificate cert = (Certificate) obj;
ks.setCertificateEntry("cert" + Integer.toString(certIndex++), cert);
}
else
{
throw new RuntimeException("Unknown PEM contents: " + obj + ". Expected a Certificate");
}
}
return ks;
}
catch (Exception e)
{
throw new RuntimeException("Error parsing PEM " + pemFile, e);
}
} | [
"public",
"static",
"KeyStore",
"loadCertificates",
"(",
"final",
"File",
"pemFile",
")",
"{",
"try",
"(",
"final",
"PemReader",
"pem",
"=",
"new",
"PemReader",
"(",
"new",
"FileReader",
"(",
"pemFile",
")",
")",
")",
"{",
"final",
"KeyStore",
"ks",
"=",
... | Load one or more X.509 Certificates from a PEM file
@param pemFile
A PKCS8 PEM file containing only <code>CERTIFICATE</code> / <code>X.509 CERTIFICATE</code> blocks
@return a JKS KeyStore with the certificate aliases "cert<code>index</code>" where index is the 0-based index of the
certificate in the PEM
@throws RuntimeException
if a problem occurs | [
"Load",
"one",
"or",
"more",
"X",
".",
"509",
"Certificates",
"from",
"a",
"PEM",
"file"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/crypto/PEMHelper.java#L40-L68 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/jaxbref/JAXBNamedResourceFactory.java | JAXBNamedResourceFactory.get | public T get()
{
T value = get(null);
if (value == null)
throw new RuntimeException("Missing property for JAXB resource: " + name);
else
return value;
} | java | public T get()
{
T value = get(null);
if (value == null)
throw new RuntimeException("Missing property for JAXB resource: " + name);
else
return value;
} | [
"public",
"T",
"get",
"(",
")",
"{",
"T",
"value",
"=",
"get",
"(",
"null",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Missing property for JAXB resource: \"",
"+",
"name",
")",
";",
"else",
"return",
"va... | Resolve this property reference to a deserialised JAXB value
@return | [
"Resolve",
"this",
"property",
"reference",
"to",
"a",
"deserialised",
"JAXB",
"value"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/jaxbref/JAXBNamedResourceFactory.java#L111-L119 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/jaxbref/JAXBNamedResourceFactory.java | JAXBNamedResourceFactory.loadResourceValue | private T loadResourceValue(final URL resource)
{
try (final InputStream is = resource.openStream())
{
cached = null; // Prevent the old value from being used
return setCached(clazz.cast(factory.getInstance(clazz).deserialise(is)));
}
catch (IOException e)
{
throw new RuntimeException("Error loading JAXB resource " + name + " " + clazz + " from " + resource, e);
}
} | java | private T loadResourceValue(final URL resource)
{
try (final InputStream is = resource.openStream())
{
cached = null; // Prevent the old value from being used
return setCached(clazz.cast(factory.getInstance(clazz).deserialise(is)));
}
catch (IOException e)
{
throw new RuntimeException("Error loading JAXB resource " + name + " " + clazz + " from " + resource, e);
}
} | [
"private",
"T",
"loadResourceValue",
"(",
"final",
"URL",
"resource",
")",
"{",
"try",
"(",
"final",
"InputStream",
"is",
"=",
"resource",
".",
"openStream",
"(",
")",
")",
"{",
"cached",
"=",
"null",
";",
"// Prevent the old value from being used",
"return",
... | Load from a classpath resource; reloads every time
@param resource
@return | [
"Load",
"from",
"a",
"classpath",
"resource",
";",
"reloads",
"every",
"time"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/jaxbref/JAXBNamedResourceFactory.java#L227-L239 | train |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckTime.java | CheckTime.analyze | private void analyze(final List<Metric> metrics, final long elapsed, final Date now, final Date date) {
long diff = 0;
boolean behind = false;
if (now.before(date)) {
behind = true;
diff = date.getTime() - now.getTime();
} else if (now.after(date)) {
diff = now.getTime() - date.getTime();
}
Elapsed elapsedTime = new Elapsed(diff, TimeUnit.MILLISECOND);
String msg = getMessage(elapsedTime);
if (diff > TimeUnit.SECOND.convert(1)) {
if (behind) {
msg += "behind";
} else {
msg += "ahead";
}
}
metrics.add(new Metric("offset", msg, new BigDecimal(TimeUnit.MILLISECOND.convert(diff, TimeUnit.SECOND)), null, null));
metrics.add(new Metric("time", "", new BigDecimal(TimeUnit.MILLISECOND.convert(elapsed, TimeUnit.SECOND)), null, null));
} | java | private void analyze(final List<Metric> metrics, final long elapsed, final Date now, final Date date) {
long diff = 0;
boolean behind = false;
if (now.before(date)) {
behind = true;
diff = date.getTime() - now.getTime();
} else if (now.after(date)) {
diff = now.getTime() - date.getTime();
}
Elapsed elapsedTime = new Elapsed(diff, TimeUnit.MILLISECOND);
String msg = getMessage(elapsedTime);
if (diff > TimeUnit.SECOND.convert(1)) {
if (behind) {
msg += "behind";
} else {
msg += "ahead";
}
}
metrics.add(new Metric("offset", msg, new BigDecimal(TimeUnit.MILLISECOND.convert(diff, TimeUnit.SECOND)), null, null));
metrics.add(new Metric("time", "", new BigDecimal(TimeUnit.MILLISECOND.convert(elapsed, TimeUnit.SECOND)), null, null));
} | [
"private",
"void",
"analyze",
"(",
"final",
"List",
"<",
"Metric",
">",
"metrics",
",",
"final",
"long",
"elapsed",
",",
"final",
"Date",
"now",
",",
"final",
"Date",
"date",
")",
"{",
"long",
"diff",
"=",
"0",
";",
"boolean",
"behind",
"=",
"false",
... | Analizes the data and produces the metrics.
@param metrics
produced metrics
@param elapsed
elapsed time
@param now
date as of now
@param date | [
"Analizes",
"the",
"data",
"and",
"produces",
"the",
"metrics",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckTime.java#L126-L149 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/PositiveInfinityStage.java | PositiveInfinityStage.parse | @Override
public String parse(final String threshold, final RangeConfig tc) {
tc.setPositiveInfinity(true);
if (threshold.startsWith(INFINITY)) {
return threshold.substring(INFINITY.length());
} else {
return threshold.substring(POS_INFINITY.length());
}
} | java | @Override
public String parse(final String threshold, final RangeConfig tc) {
tc.setPositiveInfinity(true);
if (threshold.startsWith(INFINITY)) {
return threshold.substring(INFINITY.length());
} else {
return threshold.substring(POS_INFINITY.length());
}
} | [
"@",
"Override",
"public",
"String",
"parse",
"(",
"final",
"String",
"threshold",
",",
"final",
"RangeConfig",
"tc",
")",
"{",
"tc",
".",
"setPositiveInfinity",
"(",
"true",
")",
";",
"if",
"(",
"threshold",
".",
"startsWith",
"(",
"INFINITY",
")",
")",
... | Parses the threshold to remove the matched 'inf' or '+inf' string.
No checks are performed against the passed in string: the object assumes
that the string is correct since the {@link #canParse(String)} method
<b>must</b> be called <b>before</b> this method.
@param threshold
The threshold chunk to be parsed
@param tc
The threshold config object. This object will be populated
according to the passed in threshold.
@return the remaining part of the threshold | [
"Parses",
"the",
"threshold",
"to",
"remove",
"the",
"matched",
"inf",
"or",
"+",
"inf",
"string",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/PositiveInfinityStage.java#L70-L80 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/crypto/digest/DigestHelper.java | DigestHelper.sha1hmac | public static String sha1hmac(String key, String plaintext)
{
return sha1hmac(key, plaintext, ENCODE_HEX);
} | java | public static String sha1hmac(String key, String plaintext)
{
return sha1hmac(key, plaintext, ENCODE_HEX);
} | [
"public",
"static",
"String",
"sha1hmac",
"(",
"String",
"key",
",",
"String",
"plaintext",
")",
"{",
"return",
"sha1hmac",
"(",
"key",
",",
"plaintext",
",",
"ENCODE_HEX",
")",
";",
"}"
] | Performs HMAC-SHA1 on the UTF-8 byte representation of strings
@param key
@param plaintext
@return | [
"Performs",
"HMAC",
"-",
"SHA1",
"on",
"the",
"UTF",
"-",
"8",
"byte",
"representation",
"of",
"strings"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/crypto/digest/DigestHelper.java#L42-L45 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/crypto/digest/DigestHelper.java | DigestHelper.sha1hmac | public static String sha1hmac(String key, String plaintext, int encoding)
{
byte[] signature = sha1hmac(key.getBytes(), plaintext.getBytes());
return encode(signature, encoding);
} | java | public static String sha1hmac(String key, String plaintext, int encoding)
{
byte[] signature = sha1hmac(key.getBytes(), plaintext.getBytes());
return encode(signature, encoding);
} | [
"public",
"static",
"String",
"sha1hmac",
"(",
"String",
"key",
",",
"String",
"plaintext",
",",
"int",
"encoding",
")",
"{",
"byte",
"[",
"]",
"signature",
"=",
"sha1hmac",
"(",
"key",
".",
"getBytes",
"(",
")",
",",
"plaintext",
".",
"getBytes",
"(",
... | Performs HMAC-SHA1 on the UTF-8 byte representation of strings, returning the hexidecimal hash as a result
@param key
@param plaintext
@return | [
"Performs",
"HMAC",
"-",
"SHA1",
"on",
"the",
"UTF",
"-",
"8",
"byte",
"representation",
"of",
"strings",
"returning",
"the",
"hexidecimal",
"hash",
"as",
"a",
"result"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/crypto/digest/DigestHelper.java#L56-L61 | train |
ops4j/org.ops4j.pax.swissbox | pax-swissbox-extender/src/main/java/org/ops4j/pax/swissbox/extender/BundleWatcher.java | BundleWatcher.register | private void register( final Bundle bundle )
{
LOG.debug( "Scanning bundle [" + bundle.getSymbolicName() + "]" );
final List<T> resources = m_scanner.scan( bundle );
m_mappings.put( bundle, resources );
if( resources != null && resources.size() > 0 )
{
LOG.debug( "Found resources " + resources );
for( final BundleObserver<T> observer : m_observers )
{
try
{
//here the executor service completes the job in an extra thread.
executorService.submit(new Runnable() {
public void run() {
try
{
observer.addingEntries( bundle, Collections.unmodifiableList( resources ) );
}
catch (Throwable t)
{
LOG.error( "Exception in executor thread", t );
}
}
});
}
catch( Throwable ignore )
{
LOG.error( "Ignored exception during register", ignore );
}
}
}
} | java | private void register( final Bundle bundle )
{
LOG.debug( "Scanning bundle [" + bundle.getSymbolicName() + "]" );
final List<T> resources = m_scanner.scan( bundle );
m_mappings.put( bundle, resources );
if( resources != null && resources.size() > 0 )
{
LOG.debug( "Found resources " + resources );
for( final BundleObserver<T> observer : m_observers )
{
try
{
//here the executor service completes the job in an extra thread.
executorService.submit(new Runnable() {
public void run() {
try
{
observer.addingEntries( bundle, Collections.unmodifiableList( resources ) );
}
catch (Throwable t)
{
LOG.error( "Exception in executor thread", t );
}
}
});
}
catch( Throwable ignore )
{
LOG.error( "Ignored exception during register", ignore );
}
}
}
} | [
"private",
"void",
"register",
"(",
"final",
"Bundle",
"bundle",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Scanning bundle [\"",
"+",
"bundle",
".",
"getSymbolicName",
"(",
")",
"+",
"\"]\"",
")",
";",
"final",
"List",
"<",
"T",
">",
"resources",
"=",
"m_sc... | Scans entries using the bundle scanner and registers the result of scanning process.
Then notify the observers. If an exception appears during notification, it is ignored.
@param bundle registered bundle | [
"Scans",
"entries",
"using",
"the",
"bundle",
"scanner",
"and",
"registers",
"the",
"result",
"of",
"scanning",
"process",
".",
"Then",
"notify",
"the",
"observers",
".",
"If",
"an",
"exception",
"appears",
"during",
"notification",
"it",
"is",
"ignored",
"."
... | 00b0ee16cdbe8017984a4d7ba808b10d985c5b5c | https://github.com/ops4j/org.ops4j.pax.swissbox/blob/00b0ee16cdbe8017984a4d7ba808b10d985c5b5c/pax-swissbox-extender/src/main/java/org/ops4j/pax/swissbox/extender/BundleWatcher.java#L209-L241 | train |
ops4j/org.ops4j.pax.swissbox | pax-swissbox-extender/src/main/java/org/ops4j/pax/swissbox/extender/BundleWatcher.java | BundleWatcher.unregister | private void unregister( final Bundle bundle )
{
if (bundle == null)
return; // no need to go any further, system probably stopped.
LOG.debug( "Releasing bundle [" + bundle.getSymbolicName() + "]" );
final List<T> resources = m_mappings.get( bundle );
if( resources != null && resources.size() > 0 )
{
LOG.debug( "Un-registering " + resources );
for( BundleObserver<T> observer : m_observers )
{
try
{
observer.removingEntries( bundle, Collections.unmodifiableList( resources ) );
}
catch( Throwable ignore )
{
LOG.error( "Ignored exception during un-register", ignore );
}
}
}
m_mappings.remove( bundle );
} | java | private void unregister( final Bundle bundle )
{
if (bundle == null)
return; // no need to go any further, system probably stopped.
LOG.debug( "Releasing bundle [" + bundle.getSymbolicName() + "]" );
final List<T> resources = m_mappings.get( bundle );
if( resources != null && resources.size() > 0 )
{
LOG.debug( "Un-registering " + resources );
for( BundleObserver<T> observer : m_observers )
{
try
{
observer.removingEntries( bundle, Collections.unmodifiableList( resources ) );
}
catch( Throwable ignore )
{
LOG.error( "Ignored exception during un-register", ignore );
}
}
}
m_mappings.remove( bundle );
} | [
"private",
"void",
"unregister",
"(",
"final",
"Bundle",
"bundle",
")",
"{",
"if",
"(",
"bundle",
"==",
"null",
")",
"return",
";",
"// no need to go any further, system probably stopped. \r",
"LOG",
".",
"debug",
"(",
"\"Releasing bundle [\"",
"+",
"bundle",
".",
... | Un-registers each entry from the unregistered bundle by first notifying the observers. If an exception appears
during notification, it is ignored.
@param bundle the un-registred bundle | [
"Un",
"-",
"registers",
"each",
"entry",
"from",
"the",
"unregistered",
"bundle",
"by",
"first",
"notifying",
"the",
"observers",
".",
"If",
"an",
"exception",
"appears",
"during",
"notification",
"it",
"is",
"ignored",
"."
] | 00b0ee16cdbe8017984a4d7ba808b10d985c5b5c | https://github.com/ops4j/org.ops4j.pax.swissbox/blob/00b0ee16cdbe8017984a4d7ba808b10d985c5b5c/pax-swissbox-extender/src/main/java/org/ops4j/pax/swissbox/extender/BundleWatcher.java#L249-L271 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/crypto/CertificateChainUtil.java | CertificateChainUtil.verifyChain | public static void verifyChain(List<X509Certificate> chain)
{
if (chain == null || chain.isEmpty())
throw new IllegalArgumentException("Must provide a chain that is non-null and non-empty");
for (int i = 0; i < chain.size(); i++)
{
final X509Certificate certificate = chain.get(i);
final int issuerIndex = (i != 0) ?
i - 1 :
0; // The index of the issuer is the previous cert (& the root must, of course, sign itself)
final X509Certificate issuer = chain.get(issuerIndex);
// Verify the certificate was indeed issued by the previous certificate in the chain
try
{
certificate.verify(issuer.getPublicKey());
}
catch (GeneralSecurityException e)
{
final String msg = "Failure verifying " + certificate + " against claimed issuer " + issuer;
throw new IllegalArgumentException(msg + ": " + e.getMessage(), e);
}
}
} | java | public static void verifyChain(List<X509Certificate> chain)
{
if (chain == null || chain.isEmpty())
throw new IllegalArgumentException("Must provide a chain that is non-null and non-empty");
for (int i = 0; i < chain.size(); i++)
{
final X509Certificate certificate = chain.get(i);
final int issuerIndex = (i != 0) ?
i - 1 :
0; // The index of the issuer is the previous cert (& the root must, of course, sign itself)
final X509Certificate issuer = chain.get(issuerIndex);
// Verify the certificate was indeed issued by the previous certificate in the chain
try
{
certificate.verify(issuer.getPublicKey());
}
catch (GeneralSecurityException e)
{
final String msg = "Failure verifying " + certificate + " against claimed issuer " + issuer;
throw new IllegalArgumentException(msg + ": " + e.getMessage(), e);
}
}
} | [
"public",
"static",
"void",
"verifyChain",
"(",
"List",
"<",
"X509Certificate",
">",
"chain",
")",
"{",
"if",
"(",
"chain",
"==",
"null",
"||",
"chain",
".",
"isEmpty",
"(",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Must provide a chain tha... | Verifies that a certificate chain is valid
@param chain
a certificate chain with the root certificate first
@throws IllegalArgumentException
if the chain is invalid, null or empty | [
"Verifies",
"that",
"a",
"certificate",
"chain",
"is",
"valid"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/crypto/CertificateChainUtil.java#L328-L353 | train |
rackerlabs/clouddocs-maven-plugin | src/main/java/com/rackspace/cloud/api/docs/calabash/extensions/util/RelativePath.java | RelativePath.main | public static void main(String args[]) {
String home = "/home/user1/content/myfolder";
String file = "/home/user1/figures/fig.png";
System.out.println("home = " + home);
System.out.println("file = " + file);
System.out.println("path = " + getRelativePath(new File(home),new File(file)));
} | java | public static void main(String args[]) {
String home = "/home/user1/content/myfolder";
String file = "/home/user1/figures/fig.png";
System.out.println("home = " + home);
System.out.println("file = " + file);
System.out.println("path = " + getRelativePath(new File(home),new File(file)));
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"args",
"[",
"]",
")",
"{",
"String",
"home",
"=",
"\"/home/user1/content/myfolder\"",
";",
"String",
"file",
"=",
"\"/home/user1/figures/fig.png\"",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"home = \""... | test the function | [
"test",
"the",
"function"
] | ba8554dc340db674307efdaac647c6fd2b58a34b | https://github.com/rackerlabs/clouddocs-maven-plugin/blob/ba8554dc340db674307efdaac647c6fd2b58a34b/src/main/java/com/rackspace/cloud/api/docs/calabash/extensions/util/RelativePath.java#L94-L100 | train |
rackerlabs/clouddocs-maven-plugin | src/main/java/com/rackspace/cloud/api/docs/builders/PDFBuilder.java | PDFBuilder.createEntityResolver | private InjectingEntityResolver createEntityResolver(EntityResolver resolver) {
if (getEntities() != null) {
return new InjectingEntityResolver(getEntities(), resolver, getType(), getLog());
} else {
return null;
}
} | java | private InjectingEntityResolver createEntityResolver(EntityResolver resolver) {
if (getEntities() != null) {
return new InjectingEntityResolver(getEntities(), resolver, getType(), getLog());
} else {
return null;
}
} | [
"private",
"InjectingEntityResolver",
"createEntityResolver",
"(",
"EntityResolver",
"resolver",
")",
"{",
"if",
"(",
"getEntities",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"new",
"InjectingEntityResolver",
"(",
"getEntities",
"(",
")",
",",
"resolver",
",",
... | Creates an XML entity resolver.
@param resolver The initial resolver to use.
@return The new XML entity resolver or null if there is no entities to resolve.
@see com.agilejava.docbkx.maven.InjectingEntityResolver | [
"Creates",
"an",
"XML",
"entity",
"resolver",
"."
] | ba8554dc340db674307efdaac647c6fd2b58a34b | https://github.com/rackerlabs/clouddocs-maven-plugin/blob/ba8554dc340db674307efdaac647c6fd2b58a34b/src/main/java/com/rackspace/cloud/api/docs/builders/PDFBuilder.java#L849-L855 | train |
rackerlabs/clouddocs-maven-plugin | src/main/java/com/rackspace/cloud/api/docs/builders/PDFBuilder.java | PDFBuilder.getNonDefaultStylesheetURL | protected URL getNonDefaultStylesheetURL() {
if (getNonDefaultStylesheetLocation() != null) {
URL url = this.getClass().getClassLoader().getResource(getNonDefaultStylesheetLocation());
return url;
} else {
return null;
}
} | java | protected URL getNonDefaultStylesheetURL() {
if (getNonDefaultStylesheetLocation() != null) {
URL url = this.getClass().getClassLoader().getResource(getNonDefaultStylesheetLocation());
return url;
} else {
return null;
}
} | [
"protected",
"URL",
"getNonDefaultStylesheetURL",
"(",
")",
"{",
"if",
"(",
"getNonDefaultStylesheetLocation",
"(",
")",
"!=",
"null",
")",
"{",
"URL",
"url",
"=",
"this",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
... | Returns the URL of the default stylesheet.
@return The URL of the stylesheet. | [
"Returns",
"the",
"URL",
"of",
"the",
"default",
"stylesheet",
"."
] | ba8554dc340db674307efdaac647c6fd2b58a34b | https://github.com/rackerlabs/clouddocs-maven-plugin/blob/ba8554dc340db674307efdaac647c6fd2b58a34b/src/main/java/com/rackspace/cloud/api/docs/builders/PDFBuilder.java#L868-L875 | train |
rackerlabs/clouddocs-maven-plugin | src/main/java/com/rackspace/cloud/api/docs/builders/PDFBuilder.java | PDFBuilder.scanIncludedFiles | private String[] scanIncludedFiles() {
final DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(sourceDirectory);
scanner.setIncludes(new String[]{inputFilename});
scanner.scan();
return scanner.getIncludedFiles();
} | java | private String[] scanIncludedFiles() {
final DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(sourceDirectory);
scanner.setIncludes(new String[]{inputFilename});
scanner.scan();
return scanner.getIncludedFiles();
} | [
"private",
"String",
"[",
"]",
"scanIncludedFiles",
"(",
")",
"{",
"final",
"DirectoryScanner",
"scanner",
"=",
"new",
"DirectoryScanner",
"(",
")",
";",
"scanner",
".",
"setBasedir",
"(",
"sourceDirectory",
")",
";",
"scanner",
".",
"setIncludes",
"(",
"new",... | Returns the list of docbook files to include. | [
"Returns",
"the",
"list",
"of",
"docbook",
"files",
"to",
"include",
"."
] | ba8554dc340db674307efdaac647c6fd2b58a34b | https://github.com/rackerlabs/clouddocs-maven-plugin/blob/ba8554dc340db674307efdaac647c6fd2b58a34b/src/main/java/com/rackspace/cloud/api/docs/builders/PDFBuilder.java#L880-L886 | train |
igniterealtime/jbosh | src/main/java/org/igniterealtime/jbosh/HTTPExchange.java | HTTPExchange.setHTTPResponse | void setHTTPResponse(HTTPResponse resp) {
lock.lock();
try {
if (response != null) {
throw(new IllegalStateException(
"HTTPResponse was already set"));
}
response = resp;
ready.signalAll();
} finally {
lock.unlock();
}
} | java | void setHTTPResponse(HTTPResponse resp) {
lock.lock();
try {
if (response != null) {
throw(new IllegalStateException(
"HTTPResponse was already set"));
}
response = resp;
ready.signalAll();
} finally {
lock.unlock();
}
} | [
"void",
"setHTTPResponse",
"(",
"HTTPResponse",
"resp",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"response",
"!=",
"null",
")",
"{",
"throw",
"(",
"new",
"IllegalStateException",
"(",
"\"HTTPResponse was already set\"",
")",
")",
... | Set the HTTPResponse instance.
@return HTTPResponse instance associated with the request. | [
"Set",
"the",
"HTTPResponse",
"instance",
"."
] | b43378f27e19b753b552b1e9666abc0476cdceff | https://github.com/igniterealtime/jbosh/blob/b43378f27e19b753b552b1e9666abc0476cdceff/src/main/java/org/igniterealtime/jbosh/HTTPExchange.java#L91-L103 | train |
igniterealtime/jbosh | src/main/java/org/igniterealtime/jbosh/HTTPExchange.java | HTTPExchange.getHTTPResponse | HTTPResponse getHTTPResponse() {
lock.lock();
try {
while (response == null) {
try {
ready.await();
} catch (InterruptedException intx) {
LOG.log(Level.FINEST, "Interrupted", intx);
}
}
return response;
} finally {
lock.unlock();
}
} | java | HTTPResponse getHTTPResponse() {
lock.lock();
try {
while (response == null) {
try {
ready.await();
} catch (InterruptedException intx) {
LOG.log(Level.FINEST, "Interrupted", intx);
}
}
return response;
} finally {
lock.unlock();
}
} | [
"HTTPResponse",
"getHTTPResponse",
"(",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"while",
"(",
"response",
"==",
"null",
")",
"{",
"try",
"{",
"ready",
".",
"await",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"intx",
"... | Get the HTTPResponse instance.
@return HTTPResponse instance associated with the request. | [
"Get",
"the",
"HTTPResponse",
"instance",
"."
] | b43378f27e19b753b552b1e9666abc0476cdceff | https://github.com/igniterealtime/jbosh/blob/b43378f27e19b753b552b1e9666abc0476cdceff/src/main/java/org/igniterealtime/jbosh/HTTPExchange.java#L110-L124 | train |
igniterealtime/jbosh | src/main/java/org/igniterealtime/jbosh/ServiceLib.java | ServiceLib.loadServicesImplementations | private static List<String> loadServicesImplementations(
final Class<?> ofClass) {
List<String> result = new ArrayList<String>();
// Allow a sysprop to specify the first candidate
String override = System.getProperty(ofClass.getName());
if (override != null) {
result.add(override);
}
ClassLoader loader = ServiceLib.class.getClassLoader();
URL url = loader.getResource("org.igniterealtime.jbosh/" + ofClass.getName());
if (url == null) {
// Early-out
return result;
}
InputStream inStream = null;
InputStreamReader reader = null;
BufferedReader bReader = null;
try {
inStream = url.openStream();
reader = new InputStreamReader(inStream);
bReader = new BufferedReader(reader);
String line;
while ((line = bReader.readLine()) != null) {
if (!line.matches("\\s*(#.*)?")) {
// not a comment or blank line
result.add(line.trim());
}
}
} catch (IOException iox) {
LOG.log(Level.WARNING,
"Could not load services descriptor: " + url.toString(),
iox);
} finally {
finalClose(bReader);
finalClose(reader);
finalClose(inStream);
}
return result;
} | java | private static List<String> loadServicesImplementations(
final Class<?> ofClass) {
List<String> result = new ArrayList<String>();
// Allow a sysprop to specify the first candidate
String override = System.getProperty(ofClass.getName());
if (override != null) {
result.add(override);
}
ClassLoader loader = ServiceLib.class.getClassLoader();
URL url = loader.getResource("org.igniterealtime.jbosh/" + ofClass.getName());
if (url == null) {
// Early-out
return result;
}
InputStream inStream = null;
InputStreamReader reader = null;
BufferedReader bReader = null;
try {
inStream = url.openStream();
reader = new InputStreamReader(inStream);
bReader = new BufferedReader(reader);
String line;
while ((line = bReader.readLine()) != null) {
if (!line.matches("\\s*(#.*)?")) {
// not a comment or blank line
result.add(line.trim());
}
}
} catch (IOException iox) {
LOG.log(Level.WARNING,
"Could not load services descriptor: " + url.toString(),
iox);
} finally {
finalClose(bReader);
finalClose(reader);
finalClose(inStream);
}
return result;
} | [
"private",
"static",
"List",
"<",
"String",
">",
"loadServicesImplementations",
"(",
"final",
"Class",
"<",
"?",
">",
"ofClass",
")",
"{",
"List",
"<",
"String",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"// Allow a sysprop... | Generates a list of implementation class names by using
the Jar SPI technique. The order in which the class names occur
in the service manifest is significant.
@return list of all declared implementation class names | [
"Generates",
"a",
"list",
"of",
"implementation",
"class",
"names",
"by",
"using",
"the",
"Jar",
"SPI",
"technique",
".",
"The",
"order",
"in",
"which",
"the",
"class",
"names",
"occur",
"in",
"the",
"service",
"manifest",
"is",
"significant",
"."
] | b43378f27e19b753b552b1e9666abc0476cdceff | https://github.com/igniterealtime/jbosh/blob/b43378f27e19b753b552b1e9666abc0476cdceff/src/main/java/org/igniterealtime/jbosh/ServiceLib.java#L97-L138 | train |
igniterealtime/jbosh | src/main/java/org/igniterealtime/jbosh/ServiceLib.java | ServiceLib.attemptLoad | private static <T> T attemptLoad(
final Class<T> ofClass,
final String className) {
if (LOG.isLoggable(Level.FINEST)) {
LOG.finest("Attempting service load: " + className);
}
Level level;
Throwable thrown;
try {
Class<?> clazz = Class.forName(className);
if (!ofClass.isAssignableFrom(clazz)) {
if (LOG.isLoggable(Level.WARNING)) {
LOG.warning(clazz.getName() + " is not assignable to "
+ ofClass.getName());
}
return null;
}
return ofClass.cast(clazz.newInstance());
} catch (LinkageError ex) {
level = Level.FINEST;
thrown = ex;
} catch (ClassNotFoundException ex) {
level = Level.FINEST;
thrown = ex;
} catch (InstantiationException ex) {
level = Level.WARNING;
thrown = ex;
} catch (IllegalAccessException ex) {
level = Level.WARNING;
thrown = ex;
}
LOG.log(level,
"Could not load " + ofClass.getSimpleName()
+ " instance: " + className,
thrown);
return null;
} | java | private static <T> T attemptLoad(
final Class<T> ofClass,
final String className) {
if (LOG.isLoggable(Level.FINEST)) {
LOG.finest("Attempting service load: " + className);
}
Level level;
Throwable thrown;
try {
Class<?> clazz = Class.forName(className);
if (!ofClass.isAssignableFrom(clazz)) {
if (LOG.isLoggable(Level.WARNING)) {
LOG.warning(clazz.getName() + " is not assignable to "
+ ofClass.getName());
}
return null;
}
return ofClass.cast(clazz.newInstance());
} catch (LinkageError ex) {
level = Level.FINEST;
thrown = ex;
} catch (ClassNotFoundException ex) {
level = Level.FINEST;
thrown = ex;
} catch (InstantiationException ex) {
level = Level.WARNING;
thrown = ex;
} catch (IllegalAccessException ex) {
level = Level.WARNING;
thrown = ex;
}
LOG.log(level,
"Could not load " + ofClass.getSimpleName()
+ " instance: " + className,
thrown);
return null;
} | [
"private",
"static",
"<",
"T",
">",
"T",
"attemptLoad",
"(",
"final",
"Class",
"<",
"T",
">",
"ofClass",
",",
"final",
"String",
"className",
")",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINEST",
")",
")",
"{",
"LOG",
".",
"fi... | Attempts to load the specified implementation class.
Attempts will fail if - for example - the implementation depends
on a class not found on the classpath.
@param className implementation class to attempt to load
@return service instance, or {@code null} if the instance could not be
loaded | [
"Attempts",
"to",
"load",
"the",
"specified",
"implementation",
"class",
".",
"Attempts",
"will",
"fail",
"if",
"-",
"for",
"example",
"-",
"the",
"implementation",
"depends",
"on",
"a",
"class",
"not",
"found",
"on",
"the",
"classpath",
"."
] | b43378f27e19b753b552b1e9666abc0476cdceff | https://github.com/igniterealtime/jbosh/blob/b43378f27e19b753b552b1e9666abc0476cdceff/src/main/java/org/igniterealtime/jbosh/ServiceLib.java#L149-L185 | train |
igniterealtime/jbosh | src/main/java/org/igniterealtime/jbosh/ServiceLib.java | ServiceLib.finalClose | private static void finalClose(final Closeable closeMe) {
if (closeMe != null) {
try {
closeMe.close();
} catch (IOException iox) {
LOG.log(Level.FINEST, "Could not close: " + closeMe, iox);
}
}
} | java | private static void finalClose(final Closeable closeMe) {
if (closeMe != null) {
try {
closeMe.close();
} catch (IOException iox) {
LOG.log(Level.FINEST, "Could not close: " + closeMe, iox);
}
}
} | [
"private",
"static",
"void",
"finalClose",
"(",
"final",
"Closeable",
"closeMe",
")",
"{",
"if",
"(",
"closeMe",
"!=",
"null",
")",
"{",
"try",
"{",
"closeMe",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"iox",
")",
"{",
"LOG",
"."... | Check and close a closeable object, trapping and ignoring any
exception that might result.
@param closeMe the thing to close | [
"Check",
"and",
"close",
"a",
"closeable",
"object",
"trapping",
"and",
"ignoring",
"any",
"exception",
"that",
"might",
"result",
"."
] | b43378f27e19b753b552b1e9666abc0476cdceff | https://github.com/igniterealtime/jbosh/blob/b43378f27e19b753b552b1e9666abc0476cdceff/src/main/java/org/igniterealtime/jbosh/ServiceLib.java#L193-L201 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.getConfigurationAgent | public synchronized ConfigurationAgent getConfigurationAgent() {
if (this.configurationAgent == null) {
if (isService) {
this.configurationAgent =
new ConfigurationAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.configurationAgent =
new ConfigurationAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.configurationAgent;
} | java | public synchronized ConfigurationAgent getConfigurationAgent() {
if (this.configurationAgent == null) {
if (isService) {
this.configurationAgent =
new ConfigurationAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.configurationAgent =
new ConfigurationAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.configurationAgent;
} | [
"public",
"synchronized",
"ConfigurationAgent",
"getConfigurationAgent",
"(",
")",
"{",
"if",
"(",
"this",
".",
"configurationAgent",
"==",
"null",
")",
"{",
"if",
"(",
"isService",
")",
"{",
"this",
".",
"configurationAgent",
"=",
"new",
"ConfigurationAgent",
"... | Returns a ConfigurationAgent with which requests regarding Configurations can be sent to the
NFVO.
@return a ConfigurationAgent | [
"Returns",
"a",
"ConfigurationAgent",
"with",
"which",
"requests",
"regarding",
"Configurations",
"can",
"be",
"sent",
"to",
"the",
"NFVO",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L205-L230 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.getNetworkServiceDescriptorAgent | public synchronized NetworkServiceDescriptorAgent getNetworkServiceDescriptorAgent() {
if (this.networkServiceDescriptorAgent == null) {
if (isService) {
this.networkServiceDescriptorAgent =
new NetworkServiceDescriptorAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.networkServiceDescriptorAgent =
new NetworkServiceDescriptorAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.networkServiceDescriptorAgent;
} | java | public synchronized NetworkServiceDescriptorAgent getNetworkServiceDescriptorAgent() {
if (this.networkServiceDescriptorAgent == null) {
if (isService) {
this.networkServiceDescriptorAgent =
new NetworkServiceDescriptorAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.networkServiceDescriptorAgent =
new NetworkServiceDescriptorAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.networkServiceDescriptorAgent;
} | [
"public",
"synchronized",
"NetworkServiceDescriptorAgent",
"getNetworkServiceDescriptorAgent",
"(",
")",
"{",
"if",
"(",
"this",
".",
"networkServiceDescriptorAgent",
"==",
"null",
")",
"{",
"if",
"(",
"isService",
")",
"{",
"this",
".",
"networkServiceDescriptorAgent",... | Returns a NetworkServiceDescriptorAgent with which requests regarding NetworkServiceDescriptors
can be sent to the NFVO.
@return a NetworkServiceDescriptorAgent | [
"Returns",
"a",
"NetworkServiceDescriptorAgent",
"with",
"which",
"requests",
"regarding",
"NetworkServiceDescriptors",
"can",
"be",
"sent",
"to",
"the",
"NFVO",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L238-L263 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.getNetworkServiceRecordAgent | public synchronized NetworkServiceRecordAgent getNetworkServiceRecordAgent() {
if (this.networkServiceRecordAgent == null) {
if (isService) {
this.networkServiceRecordAgent =
new NetworkServiceRecordAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.networkServiceRecordAgent =
new NetworkServiceRecordAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.networkServiceRecordAgent;
} | java | public synchronized NetworkServiceRecordAgent getNetworkServiceRecordAgent() {
if (this.networkServiceRecordAgent == null) {
if (isService) {
this.networkServiceRecordAgent =
new NetworkServiceRecordAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.networkServiceRecordAgent =
new NetworkServiceRecordAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.networkServiceRecordAgent;
} | [
"public",
"synchronized",
"NetworkServiceRecordAgent",
"getNetworkServiceRecordAgent",
"(",
")",
"{",
"if",
"(",
"this",
".",
"networkServiceRecordAgent",
"==",
"null",
")",
"{",
"if",
"(",
"isService",
")",
"{",
"this",
".",
"networkServiceRecordAgent",
"=",
"new",... | Returns a NetworkServiceRecordAgent with which requests regarding NetworkServiceRecords can be
sent to the NFVO.
@return a NetworkServiceRecordAgent | [
"Returns",
"a",
"NetworkServiceRecordAgent",
"with",
"which",
"requests",
"regarding",
"NetworkServiceRecords",
"can",
"be",
"sent",
"to",
"the",
"NFVO",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L305-L330 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.getVimInstanceAgent | public synchronized VimInstanceAgent getVimInstanceAgent() {
if (this.vimInstanceAgent == null) {
if (isService) {
this.vimInstanceAgent =
new VimInstanceAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.vimInstanceAgent =
new VimInstanceAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.vimInstanceAgent;
} | java | public synchronized VimInstanceAgent getVimInstanceAgent() {
if (this.vimInstanceAgent == null) {
if (isService) {
this.vimInstanceAgent =
new VimInstanceAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.vimInstanceAgent =
new VimInstanceAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.vimInstanceAgent;
} | [
"public",
"synchronized",
"VimInstanceAgent",
"getVimInstanceAgent",
"(",
")",
"{",
"if",
"(",
"this",
".",
"vimInstanceAgent",
"==",
"null",
")",
"{",
"if",
"(",
"isService",
")",
"{",
"this",
".",
"vimInstanceAgent",
"=",
"new",
"VimInstanceAgent",
"(",
"thi... | Returns a VimInstanceAgent with which requests regarding VimInstances can be sent to the NFVO.
@return a VimInstanceAgent | [
"Returns",
"a",
"VimInstanceAgent",
"with",
"which",
"requests",
"regarding",
"VimInstances",
"can",
"be",
"sent",
"to",
"the",
"NFVO",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L337-L362 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.getVirtualLinkAgent | public synchronized VirtualLinkAgent getVirtualLinkAgent() {
if (this.virtualLinkAgent == null) {
if (isService) {
this.virtualLinkAgent =
new VirtualLinkAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.virtualLinkAgent =
new VirtualLinkAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.virtualLinkAgent;
} | java | public synchronized VirtualLinkAgent getVirtualLinkAgent() {
if (this.virtualLinkAgent == null) {
if (isService) {
this.virtualLinkAgent =
new VirtualLinkAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.virtualLinkAgent =
new VirtualLinkAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.virtualLinkAgent;
} | [
"public",
"synchronized",
"VirtualLinkAgent",
"getVirtualLinkAgent",
"(",
")",
"{",
"if",
"(",
"this",
".",
"virtualLinkAgent",
"==",
"null",
")",
"{",
"if",
"(",
"isService",
")",
"{",
"this",
".",
"virtualLinkAgent",
"=",
"new",
"VirtualLinkAgent",
"(",
"thi... | Returns a VirtualLinkAgent with which requests regarding VirtualLinks can be sent to the NFVO.
@return a VirtualLinkAgent | [
"Returns",
"a",
"VirtualLinkAgent",
"with",
"which",
"requests",
"regarding",
"VirtualLinks",
"can",
"be",
"sent",
"to",
"the",
"NFVO",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L369-L394 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.getVirtualNetworkFunctionDescriptorRestAgent | public synchronized VirtualNetworkFunctionDescriptorAgent
getVirtualNetworkFunctionDescriptorRestAgent() {
if (this.virtualNetworkFunctionDescriptorAgent == null) {
if (isService) {
this.virtualNetworkFunctionDescriptorAgent =
new VirtualNetworkFunctionDescriptorAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.virtualNetworkFunctionDescriptorAgent =
new VirtualNetworkFunctionDescriptorAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.virtualNetworkFunctionDescriptorAgent;
} | java | public synchronized VirtualNetworkFunctionDescriptorAgent
getVirtualNetworkFunctionDescriptorRestAgent() {
if (this.virtualNetworkFunctionDescriptorAgent == null) {
if (isService) {
this.virtualNetworkFunctionDescriptorAgent =
new VirtualNetworkFunctionDescriptorAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.virtualNetworkFunctionDescriptorAgent =
new VirtualNetworkFunctionDescriptorAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.virtualNetworkFunctionDescriptorAgent;
} | [
"public",
"synchronized",
"VirtualNetworkFunctionDescriptorAgent",
"getVirtualNetworkFunctionDescriptorRestAgent",
"(",
")",
"{",
"if",
"(",
"this",
".",
"virtualNetworkFunctionDescriptorAgent",
"==",
"null",
")",
"{",
"if",
"(",
"isService",
")",
"{",
"this",
".",
"vir... | Returns a VirtualNetworkFunctionDescriptorAgent with which requests regarding
VirtualNetworkFunctionDescriptors can be sent to the NFVO.
@return a VirtualNetworkFunctionDescriptorAgent | [
"Returns",
"a",
"VirtualNetworkFunctionDescriptorAgent",
"with",
"which",
"requests",
"regarding",
"VirtualNetworkFunctionDescriptors",
"can",
"be",
"sent",
"to",
"the",
"NFVO",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L402-L428 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.getVNFFGAgent | public synchronized VNFFGAgent getVNFFGAgent() {
if (this.vnffgAgent == null) {
if (isService) {
this.vnffgAgent =
new VNFFGAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.vnffgAgent =
new VNFFGAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.vnffgAgent;
} | java | public synchronized VNFFGAgent getVNFFGAgent() {
if (this.vnffgAgent == null) {
if (isService) {
this.vnffgAgent =
new VNFFGAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.vnffgAgent =
new VNFFGAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.vnffgAgent;
} | [
"public",
"synchronized",
"VNFFGAgent",
"getVNFFGAgent",
"(",
")",
"{",
"if",
"(",
"this",
".",
"vnffgAgent",
"==",
"null",
")",
"{",
"if",
"(",
"isService",
")",
"{",
"this",
".",
"vnffgAgent",
"=",
"new",
"VNFFGAgent",
"(",
"this",
".",
"serviceName",
... | Returns a VNFFGAgent with which requests regarding VNFFGAgent can be sent to the NFVO.
@return a VNFFGAgent | [
"Returns",
"a",
"VNFFGAgent",
"with",
"which",
"requests",
"regarding",
"VNFFGAgent",
"can",
"be",
"sent",
"to",
"the",
"NFVO",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L435-L460 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.getEventAgent | public synchronized EventAgent getEventAgent() {
if (this.eventAgent == null) {
if (isService) {
this.eventAgent =
new EventAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.eventAgent =
new EventAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.eventAgent;
} | java | public synchronized EventAgent getEventAgent() {
if (this.eventAgent == null) {
if (isService) {
this.eventAgent =
new EventAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.eventAgent =
new EventAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.eventAgent;
} | [
"public",
"synchronized",
"EventAgent",
"getEventAgent",
"(",
")",
"{",
"if",
"(",
"this",
".",
"eventAgent",
"==",
"null",
")",
"{",
"if",
"(",
"isService",
")",
"{",
"this",
".",
"eventAgent",
"=",
"new",
"EventAgent",
"(",
"this",
".",
"serviceName",
... | Returns an EventAgent with which requests regarding Events can be sent to the NFVO.
@return an EventAgent | [
"Returns",
"an",
"EventAgent",
"with",
"which",
"requests",
"regarding",
"Events",
"can",
"be",
"sent",
"to",
"the",
"NFVO",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L467-L492 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.getVNFPackageAgent | public synchronized VNFPackageAgent getVNFPackageAgent() {
if (this.vnfPackageAgent == null) {
if (isService) {
this.vnfPackageAgent =
new VNFPackageAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.vnfPackageAgent =
new VNFPackageAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.vnfPackageAgent;
} | java | public synchronized VNFPackageAgent getVNFPackageAgent() {
if (this.vnfPackageAgent == null) {
if (isService) {
this.vnfPackageAgent =
new VNFPackageAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.vnfPackageAgent =
new VNFPackageAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.vnfPackageAgent;
} | [
"public",
"synchronized",
"VNFPackageAgent",
"getVNFPackageAgent",
"(",
")",
"{",
"if",
"(",
"this",
".",
"vnfPackageAgent",
"==",
"null",
")",
"{",
"if",
"(",
"isService",
")",
"{",
"this",
".",
"vnfPackageAgent",
"=",
"new",
"VNFPackageAgent",
"(",
"this",
... | Returns a VNFPackageAgent with which requests regarding VNFPackages can be sent to the NFVO.
@return a VNFPackageAgent | [
"Returns",
"a",
"VNFPackageAgent",
"with",
"which",
"requests",
"regarding",
"VNFPackages",
"can",
"be",
"sent",
"to",
"the",
"NFVO",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L499-L524 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.getProjectAgent | public synchronized ProjectAgent getProjectAgent() {
if (this.projectAgent == null) {
if (isService) {
this.projectAgent =
new ProjectAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.projectAgent =
new ProjectAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.projectAgent;
} | java | public synchronized ProjectAgent getProjectAgent() {
if (this.projectAgent == null) {
if (isService) {
this.projectAgent =
new ProjectAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.projectAgent =
new ProjectAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.projectAgent;
} | [
"public",
"synchronized",
"ProjectAgent",
"getProjectAgent",
"(",
")",
"{",
"if",
"(",
"this",
".",
"projectAgent",
"==",
"null",
")",
"{",
"if",
"(",
"isService",
")",
"{",
"this",
".",
"projectAgent",
"=",
"new",
"ProjectAgent",
"(",
"this",
".",
"servic... | Returns a ProjectAgent with which requests regarding Projects can be sent to the NFVO.
@return a ProjectAgent | [
"Returns",
"a",
"ProjectAgent",
"with",
"which",
"requests",
"regarding",
"Projects",
"can",
"be",
"sent",
"to",
"the",
"NFVO",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L531-L556 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.getUserAgent | public synchronized UserAgent getUserAgent() {
if (this.userAgent == null) {
if (isService) {
this.userAgent =
new UserAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.userAgent =
new UserAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.userAgent;
} | java | public synchronized UserAgent getUserAgent() {
if (this.userAgent == null) {
if (isService) {
this.userAgent =
new UserAgent(
this.serviceName,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version,
this.serviceKey);
} else {
this.userAgent =
new UserAgent(
this.username,
this.password,
this.projectId,
this.sslEnabled,
this.nfvoIp,
this.nfvoPort,
this.version);
}
}
return this.userAgent;
} | [
"public",
"synchronized",
"UserAgent",
"getUserAgent",
"(",
")",
"{",
"if",
"(",
"this",
".",
"userAgent",
"==",
"null",
")",
"{",
"if",
"(",
"isService",
")",
"{",
"this",
".",
"userAgent",
"=",
"new",
"UserAgent",
"(",
"this",
".",
"serviceName",
",",
... | Returns a UserAgent with which requests regarding Users can be sent to the NFVO.
@return a UserAgent | [
"Returns",
"a",
"UserAgent",
"with",
"which",
"requests",
"regarding",
"Users",
"can",
"be",
"sent",
"to",
"the",
"NFVO",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L563-L588 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.getProjectIdForProjectName | private String getProjectIdForProjectName(String projectName) throws SDKException {
String projectId =
this.getProjectAgent()
.findAll()
.stream()
.filter(p -> p.getName().equals(projectName))
.findFirst()
.orElseThrow(
() ->
new SDKException(
"Did not find a Project named " + projectName,
null,
"Did not find a Project named " + projectName))
.getId();
this.projectAgent = null;
return projectId;
} | java | private String getProjectIdForProjectName(String projectName) throws SDKException {
String projectId =
this.getProjectAgent()
.findAll()
.stream()
.filter(p -> p.getName().equals(projectName))
.findFirst()
.orElseThrow(
() ->
new SDKException(
"Did not find a Project named " + projectName,
null,
"Did not find a Project named " + projectName))
.getId();
this.projectAgent = null;
return projectId;
} | [
"private",
"String",
"getProjectIdForProjectName",
"(",
"String",
"projectName",
")",
"throws",
"SDKException",
"{",
"String",
"projectId",
"=",
"this",
".",
"getProjectAgent",
"(",
")",
".",
"findAll",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
... | Return the project id for a given project name.
@param projectName the name of the project
@return the project id for the given project name
@throws SDKException in case of exception | [
"Return",
"the",
"project",
"id",
"for",
"a",
"given",
"project",
"name",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L701-L717 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java | NFVORequestor.resetAgents | private void resetAgents() {
this.configurationAgent = null;
this.keyAgent = null;
this.userAgent = null;
this.vnfPackageAgent = null;
this.projectAgent = null;
this.eventAgent = null;
this.vnffgAgent = null;
this.virtualNetworkFunctionDescriptorAgent = null;
this.virtualLinkAgent = null;
this.vimInstanceAgent = null;
this.networkServiceDescriptorAgent = null;
this.networkServiceRecordAgent = null;
this.serviceAgent = null;
} | java | private void resetAgents() {
this.configurationAgent = null;
this.keyAgent = null;
this.userAgent = null;
this.vnfPackageAgent = null;
this.projectAgent = null;
this.eventAgent = null;
this.vnffgAgent = null;
this.virtualNetworkFunctionDescriptorAgent = null;
this.virtualLinkAgent = null;
this.vimInstanceAgent = null;
this.networkServiceDescriptorAgent = null;
this.networkServiceRecordAgent = null;
this.serviceAgent = null;
} | [
"private",
"void",
"resetAgents",
"(",
")",
"{",
"this",
".",
"configurationAgent",
"=",
"null",
";",
"this",
".",
"keyAgent",
"=",
"null",
";",
"this",
".",
"userAgent",
"=",
"null",
";",
"this",
".",
"vnfPackageAgent",
"=",
"null",
";",
"this",
".",
... | Set all the agent objects to null. | [
"Set",
"all",
"the",
"agent",
"objects",
"to",
"null",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/NFVORequestor.java#L720-L734 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java | NetworkServiceDescriptorAgent.getVirtualNetworkFunctionDescriptors | @Help(
help =
"Get all the VirtualNetworkFunctionDescriptors of a NetworkServiceDescriptor with specific id"
)
@Deprecated
public List<VirtualNetworkFunctionDescriptor> getVirtualNetworkFunctionDescriptors(
final String idNSD) throws SDKException {
String url = idNSD + "/vnfdescriptors";
return Arrays.asList(
(VirtualNetworkFunctionDescriptor[])
requestGetAll(url, VirtualNetworkFunctionDescriptor.class));
} | java | @Help(
help =
"Get all the VirtualNetworkFunctionDescriptors of a NetworkServiceDescriptor with specific id"
)
@Deprecated
public List<VirtualNetworkFunctionDescriptor> getVirtualNetworkFunctionDescriptors(
final String idNSD) throws SDKException {
String url = idNSD + "/vnfdescriptors";
return Arrays.asList(
(VirtualNetworkFunctionDescriptor[])
requestGetAll(url, VirtualNetworkFunctionDescriptor.class));
} | [
"@",
"Help",
"(",
"help",
"=",
"\"Get all the VirtualNetworkFunctionDescriptors of a NetworkServiceDescriptor with specific id\"",
")",
"@",
"Deprecated",
"public",
"List",
"<",
"VirtualNetworkFunctionDescriptor",
">",
"getVirtualNetworkFunctionDescriptors",
"(",
"final",
"String",... | Get all VirtualNetworkFunctionDescriptors contained in a NetworkServiceDescriptor specified by
its ID.
@param idNSD the NetworkServiceDescriptor's id
@return a List of all VirtualNetworkServiceDescriptors contained in the
NetworkServiceDescriptor
@throws SDKException if the request fails | [
"Get",
"all",
"VirtualNetworkFunctionDescriptors",
"contained",
"in",
"a",
"NetworkServiceDescriptor",
"specified",
"by",
"its",
"ID",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java#L104-L115 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java | NetworkServiceDescriptorAgent.getVirtualNetworkFunctionDescriptor | @Help(
help =
"Get a specific VirtualNetworkFunctionDescriptor of a particular NetworkServiceDescriptor specified by their IDs"
)
@Deprecated
public VirtualNetworkFunctionDescriptor getVirtualNetworkFunctionDescriptor(
final String idNSD, final String idVfn) throws SDKException {
String url = idNSD + "/vnfdescriptors" + "/" + idVfn;
return (VirtualNetworkFunctionDescriptor)
requestGet(url, VirtualNetworkFunctionDescriptor.class);
} | java | @Help(
help =
"Get a specific VirtualNetworkFunctionDescriptor of a particular NetworkServiceDescriptor specified by their IDs"
)
@Deprecated
public VirtualNetworkFunctionDescriptor getVirtualNetworkFunctionDescriptor(
final String idNSD, final String idVfn) throws SDKException {
String url = idNSD + "/vnfdescriptors" + "/" + idVfn;
return (VirtualNetworkFunctionDescriptor)
requestGet(url, VirtualNetworkFunctionDescriptor.class);
} | [
"@",
"Help",
"(",
"help",
"=",
"\"Get a specific VirtualNetworkFunctionDescriptor of a particular NetworkServiceDescriptor specified by their IDs\"",
")",
"@",
"Deprecated",
"public",
"VirtualNetworkFunctionDescriptor",
"getVirtualNetworkFunctionDescriptor",
"(",
"final",
"String",
"id... | Return a VirtualNetworkFunctionDescriptor that is contained in a particular
NetworkServiceDescriptor.
@param idNSD the ID of the NetworkServiceDescriptor
@param idVfn the id of the VirtualNetworkFunctionDescriptor
@return the VirtualNetworkFunctionDescriptor
@throws SDKException if the request fails | [
"Return",
"a",
"VirtualNetworkFunctionDescriptor",
"that",
"is",
"contained",
"in",
"a",
"particular",
"NetworkServiceDescriptor",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java#L126-L136 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java | NetworkServiceDescriptorAgent.deleteVirtualNetworkFunctionDescriptors | @Help(
help =
"Delete the VirtualNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id"
)
@Deprecated
public void deleteVirtualNetworkFunctionDescriptors(final String idNSD, final String idVnf)
throws SDKException {
String url = idNSD + "/vnfdescriptors" + "/" + idVnf;
requestDelete(url);
} | java | @Help(
help =
"Delete the VirtualNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id"
)
@Deprecated
public void deleteVirtualNetworkFunctionDescriptors(final String idNSD, final String idVnf)
throws SDKException {
String url = idNSD + "/vnfdescriptors" + "/" + idVnf;
requestDelete(url);
} | [
"@",
"Help",
"(",
"help",
"=",
"\"Delete the VirtualNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id\"",
")",
"@",
"Deprecated",
"public",
"void",
"deleteVirtualNetworkFunctionDescriptors",
"(",
"final",
"String",
"idNSD",
",",
"final",
"String",
"idVnf"... | Delete a specific VirtualNetworkFunctionDescriptor that is contained in a particular
NetworkServiceDescriptor.
@param idNSD the ID of the NetworkServiceDescriptor
@param idVnf the id of the VirtualNetworkFunctionDescriptor
@throws SDKException if the request fails | [
"Delete",
"a",
"specific",
"VirtualNetworkFunctionDescriptor",
"that",
"is",
"contained",
"in",
"a",
"particular",
"NetworkServiceDescriptor",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java#L146-L155 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java | NetworkServiceDescriptorAgent.createVNFD | @Help(
help =
"create the VirtualNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id"
)
@Deprecated
public VirtualNetworkFunctionDescriptor createVNFD(
final String idNSD, final VirtualNetworkFunctionDescriptor virtualNetworkFunctionDescriptor)
throws SDKException {
String url = idNSD + "/vnfdescriptors" + "/";
return (VirtualNetworkFunctionDescriptor) requestPost(url, virtualNetworkFunctionDescriptor);
} | java | @Help(
help =
"create the VirtualNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id"
)
@Deprecated
public VirtualNetworkFunctionDescriptor createVNFD(
final String idNSD, final VirtualNetworkFunctionDescriptor virtualNetworkFunctionDescriptor)
throws SDKException {
String url = idNSD + "/vnfdescriptors" + "/";
return (VirtualNetworkFunctionDescriptor) requestPost(url, virtualNetworkFunctionDescriptor);
} | [
"@",
"Help",
"(",
"help",
"=",
"\"create the VirtualNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id\"",
")",
"@",
"Deprecated",
"public",
"VirtualNetworkFunctionDescriptor",
"createVNFD",
"(",
"final",
"String",
"idNSD",
",",
"final",
"VirtualNetworkFunct... | Create a VirtualNetworkFunctionDescriptor in a specific NetworkServiceDescriptor.
@param idNSD : The id of the networkServiceDescriptor the vnfd shall be created at
@param virtualNetworkFunctionDescriptor : : the Network Service Descriptor to be updated
@throws SDKException if the request fails
@return the created VNFD | [
"Create",
"a",
"VirtualNetworkFunctionDescriptor",
"in",
"a",
"specific",
"NetworkServiceDescriptor",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java#L165-L175 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java | NetworkServiceDescriptorAgent.updateVNFD | @Help(
help =
"Update the VirtualNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id"
)
@Deprecated
public VirtualNetworkFunctionDescriptor updateVNFD(
final String idNSD,
final String idVfn,
final VirtualNetworkFunctionDescriptor virtualNetworkFunctionDescriptor)
throws SDKException {
String url = idNSD + "/vnfdescriptors" + "/" + idVfn;
return (VirtualNetworkFunctionDescriptor) requestPut(url, virtualNetworkFunctionDescriptor);
} | java | @Help(
help =
"Update the VirtualNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id"
)
@Deprecated
public VirtualNetworkFunctionDescriptor updateVNFD(
final String idNSD,
final String idVfn,
final VirtualNetworkFunctionDescriptor virtualNetworkFunctionDescriptor)
throws SDKException {
String url = idNSD + "/vnfdescriptors" + "/" + idVfn;
return (VirtualNetworkFunctionDescriptor) requestPut(url, virtualNetworkFunctionDescriptor);
} | [
"@",
"Help",
"(",
"help",
"=",
"\"Update the VirtualNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id\"",
")",
"@",
"Deprecated",
"public",
"VirtualNetworkFunctionDescriptor",
"updateVNFD",
"(",
"final",
"String",
"idNSD",
",",
"final",
"String",
"idVfn",... | Update a specific VirtualNetworkFunctionDescriptor that is contained in a particular
NetworkServiceDescriptor.
@param idNSD the ID of the NetworkServiceRecord containing the VirtualNetworkFunctionDescriptor
@param idVfn the ID of the VNF Descriptor that shall be updated
@param virtualNetworkFunctionDescriptor the updated version of the
VirtualNetworkFunctionDescriptor
@return the updated VirtualNetworkFunctionDescriptor
@throws SDKException if the request fails | [
"Update",
"a",
"specific",
"VirtualNetworkFunctionDescriptor",
"that",
"is",
"contained",
"in",
"a",
"particular",
"NetworkServiceDescriptor",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java#L188-L200 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java | NetworkServiceDescriptorAgent.getVNFDependencies | @Help(
help =
"Get all the VirtualNetworkFunctionDescriptor Dependency of a NetworkServiceDescriptor with specific id"
)
public List<VNFDependency> getVNFDependencies(final String idNSD) throws SDKException {
String url = idNSD + "/vnfdependencies";
return Arrays.asList((VNFDependency[]) requestGetAll(url, VNFDependency.class));
} | java | @Help(
help =
"Get all the VirtualNetworkFunctionDescriptor Dependency of a NetworkServiceDescriptor with specific id"
)
public List<VNFDependency> getVNFDependencies(final String idNSD) throws SDKException {
String url = idNSD + "/vnfdependencies";
return Arrays.asList((VNFDependency[]) requestGetAll(url, VNFDependency.class));
} | [
"@",
"Help",
"(",
"help",
"=",
"\"Get all the VirtualNetworkFunctionDescriptor Dependency of a NetworkServiceDescriptor with specific id\"",
")",
"public",
"List",
"<",
"VNFDependency",
">",
"getVNFDependencies",
"(",
"final",
"String",
"idNSD",
")",
"throws",
"SDKException",
... | Return a List with all the VNFDependencies that are contained in a specific
NetworkServiceDescriptor.
@param idNSD the ID of the NetworkServiceDescriptor
@return the List of VNFDependencies
@throws SDKException if the request fails | [
"Return",
"a",
"List",
"with",
"all",
"the",
"VNFDependencies",
"that",
"are",
"contained",
"in",
"a",
"specific",
"NetworkServiceDescriptor",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java#L210-L217 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java | NetworkServiceDescriptorAgent.getVNFDependency | @Help(
help =
"get the VirtualNetworkFunctionDescriptor dependency with specific id of a NetworkServiceDescriptor with specific id"
)
public VNFDependency getVNFDependency(final String idNSD, final String idVnfd)
throws SDKException {
String url = idNSD + "/vnfdependencies" + "/" + idVnfd;
return (VNFDependency) requestGet(url, VNFDependency.class);
} | java | @Help(
help =
"get the VirtualNetworkFunctionDescriptor dependency with specific id of a NetworkServiceDescriptor with specific id"
)
public VNFDependency getVNFDependency(final String idNSD, final String idVnfd)
throws SDKException {
String url = idNSD + "/vnfdependencies" + "/" + idVnfd;
return (VNFDependency) requestGet(url, VNFDependency.class);
} | [
"@",
"Help",
"(",
"help",
"=",
"\"get the VirtualNetworkFunctionDescriptor dependency with specific id of a NetworkServiceDescriptor with specific id\"",
")",
"public",
"VNFDependency",
"getVNFDependency",
"(",
"final",
"String",
"idNSD",
",",
"final",
"String",
"idVnfd",
")",
... | Return a specific VNFDependency that is contained in a particular NetworkServiceDescriptor.
@param idNSD the ID of the NetworkServiceDescriptor
@param idVnfd the VNFDependencies' ID
@return the VNFDependency
@throws SDKException if the request fails | [
"Return",
"a",
"specific",
"VNFDependency",
"that",
"is",
"contained",
"in",
"a",
"particular",
"NetworkServiceDescriptor",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java#L227-L235 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java | NetworkServiceDescriptorAgent.deleteVNFDependency | @Help(
help =
"Delete the VirtualNetworkFunctionDescriptor dependency of a NetworkServiceDescriptor with specific id"
)
public void deleteVNFDependency(final String idNSD, final String idVnfd) throws SDKException {
String url = idNSD + "/vnfdependencies" + "/" + idVnfd;
requestDelete(url);
} | java | @Help(
help =
"Delete the VirtualNetworkFunctionDescriptor dependency of a NetworkServiceDescriptor with specific id"
)
public void deleteVNFDependency(final String idNSD, final String idVnfd) throws SDKException {
String url = idNSD + "/vnfdependencies" + "/" + idVnfd;
requestDelete(url);
} | [
"@",
"Help",
"(",
"help",
"=",
"\"Delete the VirtualNetworkFunctionDescriptor dependency of a NetworkServiceDescriptor with specific id\"",
")",
"public",
"void",
"deleteVNFDependency",
"(",
"final",
"String",
"idNSD",
",",
"final",
"String",
"idVnfd",
")",
"throws",
"SDKExce... | Delete a VNFDependency.
@param idNSD the ID of the NetworkServiceDescriptor which contains the VNFDependency
@param idVnfd the ID of the VNFDependency that shall be deleted
@throws SDKException if the request fails | [
"Delete",
"a",
"VNFDependency",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java#L244-L251 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java | NetworkServiceDescriptorAgent.createVNFDependency | @Help(
help =
"Create the VirtualNetworkFunctionDescriptor dependency of a NetworkServiceDescriptor with specific id"
)
public VNFDependency createVNFDependency(final String idNSD, final VNFDependency vnfDependency)
throws SDKException {
String url = idNSD + "/vnfdependencies" + "/";
return (VNFDependency) requestPost(url, vnfDependency);
} | java | @Help(
help =
"Create the VirtualNetworkFunctionDescriptor dependency of a NetworkServiceDescriptor with specific id"
)
public VNFDependency createVNFDependency(final String idNSD, final VNFDependency vnfDependency)
throws SDKException {
String url = idNSD + "/vnfdependencies" + "/";
return (VNFDependency) requestPost(url, vnfDependency);
} | [
"@",
"Help",
"(",
"help",
"=",
"\"Create the VirtualNetworkFunctionDescriptor dependency of a NetworkServiceDescriptor with specific id\"",
")",
"public",
"VNFDependency",
"createVNFDependency",
"(",
"final",
"String",
"idNSD",
",",
"final",
"VNFDependency",
"vnfDependency",
")",... | Add a new VNFDependency to a specific NetworkServiceDescriptor.
@param idNSD the ID of the NetworkServiceDescriptor
@param vnfDependency the new VNFDependency
@return the new VNFDependency
@throws SDKException if the request fails | [
"Add",
"a",
"new",
"VNFDependency",
"to",
"a",
"specific",
"NetworkServiceDescriptor",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java#L261-L269 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java | NetworkServiceDescriptorAgent.updateVNFD | @Help(
help =
"Update the VirtualNetworkFunctionDescriptor dependency of a NetworkServiceDescriptor with specific id"
)
public VNFDependency updateVNFD(
final String idNSD, final String idVnfDep, final VNFDependency vnfDependency)
throws SDKException {
String url = idNSD + "/vnfdependencies" + "/" + idVnfDep;
return (VNFDependency) requestPut(url, vnfDependency);
} | java | @Help(
help =
"Update the VirtualNetworkFunctionDescriptor dependency of a NetworkServiceDescriptor with specific id"
)
public VNFDependency updateVNFD(
final String idNSD, final String idVnfDep, final VNFDependency vnfDependency)
throws SDKException {
String url = idNSD + "/vnfdependencies" + "/" + idVnfDep;
return (VNFDependency) requestPut(url, vnfDependency);
} | [
"@",
"Help",
"(",
"help",
"=",
"\"Update the VirtualNetworkFunctionDescriptor dependency of a NetworkServiceDescriptor with specific id\"",
")",
"public",
"VNFDependency",
"updateVNFD",
"(",
"final",
"String",
"idNSD",
",",
"final",
"String",
"idVnfDep",
",",
"final",
"VNFDep... | Update a specific VNFDependency which is contained in a particular NetworkServiceDescriptor.
@param idNSD the ID of the NetworkServiceDescriptor containing the VNFDependency
@param idVnfDep the ID of the VNFDependency which shall be updated
@param vnfDependency the updated version of the VNFDependency
@return the updated VNFDependency
@throws SDKException if the request fails | [
"Update",
"a",
"specific",
"VNFDependency",
"which",
"is",
"contained",
"in",
"a",
"particular",
"NetworkServiceDescriptor",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java#L280-L289 | train |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java | NetworkServiceDescriptorAgent.getPhysicalNetworkFunctionDescriptors | @Help(
help =
"Get all the PhysicalNetworkFunctionDescriptors of a NetworkServiceDescriptor with specific id"
)
public List<PhysicalNetworkFunctionDescriptor> getPhysicalNetworkFunctionDescriptors(
final String idNSD) throws SDKException {
String url = idNSD + "/pnfdescriptors";
return Arrays.asList(
(PhysicalNetworkFunctionDescriptor[])
requestGetAll(url, PhysicalNetworkFunctionDescriptor.class));
} | java | @Help(
help =
"Get all the PhysicalNetworkFunctionDescriptors of a NetworkServiceDescriptor with specific id"
)
public List<PhysicalNetworkFunctionDescriptor> getPhysicalNetworkFunctionDescriptors(
final String idNSD) throws SDKException {
String url = idNSD + "/pnfdescriptors";
return Arrays.asList(
(PhysicalNetworkFunctionDescriptor[])
requestGetAll(url, PhysicalNetworkFunctionDescriptor.class));
} | [
"@",
"Help",
"(",
"help",
"=",
"\"Get all the PhysicalNetworkFunctionDescriptors of a NetworkServiceDescriptor with specific id\"",
")",
"public",
"List",
"<",
"PhysicalNetworkFunctionDescriptor",
">",
"getPhysicalNetworkFunctionDescriptors",
"(",
"final",
"String",
"idNSD",
")",
... | Returns the List of PhysicalNetworkFunctionDescriptors that are contained in a specific
NetworkServiceDescriptor.
@param idNSD the ID of the NetworkServiceDescriptor
@return the List of PhysicalNetworkFunctionDescriptors
@throws SDKException if the request fails | [
"Returns",
"the",
"List",
"of",
"PhysicalNetworkFunctionDescriptors",
"that",
"are",
"contained",
"in",
"a",
"specific",
"NetworkServiceDescriptor",
"."
] | 6ca6dd6b62a23940d312213d6fa489d5b636061a | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceDescriptorAgent.java#L299-L309 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.