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
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/ByteCodeClassScanner.java
ByteCodeClassScanner.scanAttributeForAnnotation
private void scanAttributeForAnnotation(InputStream is) throws IOException { int nameIndex = readShort(is); // String name = _cp.getUtf8(nameIndex).getValue(); int length = readInt(is); if (! isNameAnnotation(nameIndex)) { is.skip(length); return; } int count = readShort(is); for (int i = 0; i < count; i++) { int annTypeIndex = scanAnnotation(is); if (annTypeIndex > 0 && _cpLengths[annTypeIndex] > 2) { _matcher.addClassAnnotation(_charBuffer, _cpData[annTypeIndex] + 1, _cpLengths[annTypeIndex] - 2); } } }
java
private void scanAttributeForAnnotation(InputStream is) throws IOException { int nameIndex = readShort(is); // String name = _cp.getUtf8(nameIndex).getValue(); int length = readInt(is); if (! isNameAnnotation(nameIndex)) { is.skip(length); return; } int count = readShort(is); for (int i = 0; i < count; i++) { int annTypeIndex = scanAnnotation(is); if (annTypeIndex > 0 && _cpLengths[annTypeIndex] > 2) { _matcher.addClassAnnotation(_charBuffer, _cpData[annTypeIndex] + 1, _cpLengths[annTypeIndex] - 2); } } }
[ "private", "void", "scanAttributeForAnnotation", "(", "InputStream", "is", ")", "throws", "IOException", "{", "int", "nameIndex", "=", "readShort", "(", "is", ")", ";", "// String name = _cp.getUtf8(nameIndex).getValue();", "int", "length", "=", "readInt", "(", "is", ...
Parses an attribute for an annotation.
[ "Parses", "an", "attribute", "for", "an", "annotation", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/ByteCodeClassScanner.java#L454-L479
train
baratine/baratine
web/src/main/java/com/caucho/v5/util/PeriodUtil.java
PeriodUtil.toPeriod
public static long toPeriod(String value, long defaultUnits) throws ConfigException { if (value == null) return 0; long sign = 1; long period = 0; int i = 0; int length = value.length(); if (length > 0 && value.charAt(i) == '-') { sign = -1; i++; } while (i < length) { long delta = 0; char ch; for (; i < length && (ch = value.charAt(i)) >= '0' && ch <= '9'; i++) delta = 10 * delta + ch - '0'; if (length <= i) period += defaultUnits * delta; else { ch = value.charAt(i++); switch (ch) { case 's': period += 1000 * delta; break; case 'm': if (i < value.length() && value.charAt(i) == 's') { i++; period += delta; } else period += 60 * 1000 * delta; break; case 'h': period += 60L * 60 * 1000 * delta; break; case 'D': period += DAY * delta; break; case 'W': period += 7L * DAY * delta; break; case 'M': period += 30L * DAY * delta; break; case 'Y': period += 365L * DAY * delta; break; default: throw new ConfigException(L.l("Unknown unit `{0}' in period `{1}'. Valid units are:\n '10ms' milliseconds\n '10s' seconds\n '10m' minutes\n '10h' hours\n '10D' days\n '10W' weeks\n '10M' months\n '10Y' years", String.valueOf(ch), value)); } } } period = sign * period; // server/137w /* if (period < 0) return INFINITE; else return period; */ return period; }
java
public static long toPeriod(String value, long defaultUnits) throws ConfigException { if (value == null) return 0; long sign = 1; long period = 0; int i = 0; int length = value.length(); if (length > 0 && value.charAt(i) == '-') { sign = -1; i++; } while (i < length) { long delta = 0; char ch; for (; i < length && (ch = value.charAt(i)) >= '0' && ch <= '9'; i++) delta = 10 * delta + ch - '0'; if (length <= i) period += defaultUnits * delta; else { ch = value.charAt(i++); switch (ch) { case 's': period += 1000 * delta; break; case 'm': if (i < value.length() && value.charAt(i) == 's') { i++; period += delta; } else period += 60 * 1000 * delta; break; case 'h': period += 60L * 60 * 1000 * delta; break; case 'D': period += DAY * delta; break; case 'W': period += 7L * DAY * delta; break; case 'M': period += 30L * DAY * delta; break; case 'Y': period += 365L * DAY * delta; break; default: throw new ConfigException(L.l("Unknown unit `{0}' in period `{1}'. Valid units are:\n '10ms' milliseconds\n '10s' seconds\n '10m' minutes\n '10h' hours\n '10D' days\n '10W' weeks\n '10M' months\n '10Y' years", String.valueOf(ch), value)); } } } period = sign * period; // server/137w /* if (period < 0) return INFINITE; else return period; */ return period; }
[ "public", "static", "long", "toPeriod", "(", "String", "value", ",", "long", "defaultUnits", ")", "throws", "ConfigException", "{", "if", "(", "value", "==", "null", ")", "return", "0", ";", "long", "sign", "=", "1", ";", "long", "period", "=", "0", ";...
Converts a period string to a time. <table> <tr><td>ms<td>milliseconds <tr><td>s<td>seconds <tr><td>m<td>minutes <tr><td>h<td>hours <tr><td>D<td>days <tr><td>W<td>weeks <tr><td>M<td>months <tr><td>Y<td>years </table>
[ "Converts", "a", "period", "string", "to", "a", "time", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/util/PeriodUtil.java#L129-L209
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/HttpStream.java
HttpStream.openRead
static HttpStreamWrapper openRead(HttpPath path) throws IOException { HttpStream stream = createStream(path); stream._isPost = false; HttpStreamWrapper wrapper = new HttpStreamWrapper(stream); String status = (String) wrapper.getAttribute("status"); // ioc/23p0 if ("404".equals(status)) { throw new FileNotFoundException(L.l("'{0}' returns a HTTP 404.", path.getURL())); } return wrapper; }
java
static HttpStreamWrapper openRead(HttpPath path) throws IOException { HttpStream stream = createStream(path); stream._isPost = false; HttpStreamWrapper wrapper = new HttpStreamWrapper(stream); String status = (String) wrapper.getAttribute("status"); // ioc/23p0 if ("404".equals(status)) { throw new FileNotFoundException(L.l("'{0}' returns a HTTP 404.", path.getURL())); } return wrapper; }
[ "static", "HttpStreamWrapper", "openRead", "(", "HttpPath", "path", ")", "throws", "IOException", "{", "HttpStream", "stream", "=", "createStream", "(", "path", ")", ";", "stream", ".", "_isPost", "=", "false", ";", "HttpStreamWrapper", "wrapper", "=", "new", ...
Opens a new HTTP stream for reading, i.e. a GET request. @param path the URL for the stream @return the opened stream
[ "Opens", "a", "new", "HTTP", "stream", "for", "reading", "i", ".", "e", ".", "a", "GET", "request", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/HttpStream.java#L152-L168
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/HttpStream.java
HttpStream.openReadWrite
static HttpStreamWrapper openReadWrite(HttpPath path) throws IOException { HttpStream stream = createStream(path); stream._isPost = true; return new HttpStreamWrapper(stream); }
java
static HttpStreamWrapper openReadWrite(HttpPath path) throws IOException { HttpStream stream = createStream(path); stream._isPost = true; return new HttpStreamWrapper(stream); }
[ "static", "HttpStreamWrapper", "openReadWrite", "(", "HttpPath", "path", ")", "throws", "IOException", "{", "HttpStream", "stream", "=", "createStream", "(", "path", ")", ";", "stream", ".", "_isPost", "=", "true", ";", "return", "new", "HttpStreamWrapper", "(",...
Opens a new HTTP stream for reading and writing, i.e. a POST request. @param path the URL for the stream @return the opened stream
[ "Opens", "a", "new", "HTTP", "stream", "for", "reading", "and", "writing", "i", ".", "e", ".", "a", "POST", "request", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/HttpStream.java#L182-L188
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/HttpStream.java
HttpStream.createStream
static private HttpStream createStream(HttpPath path) throws IOException { String host = path.getHost(); int port = path.getPort(); HttpStream stream = null; long streamTime = 0; synchronized (LOCK) { if (_savedStream != null && host.equals(_savedStream.getHost()) && port == _savedStream.getPort()) { stream = _savedStream; streamTime = _saveTime; _savedStream = null; } } if (stream != null) { long now; now = CurrentTime.currentTime(); if (now < streamTime + 5000) { // if the stream is still valid, use it stream.init(path); return stream; } else { // if the stream has timed out, close it try { stream._isKeepalive = false; stream.close(); } catch (IOException e) { log.log(Level.FINE, e.toString(), e); } } } Socket s; try { s = new Socket(host, port); if (path instanceof HttpsPath) { SSLContext context = SSLContext.getInstance("TLS"); javax.net.ssl.TrustManager tm = new javax.net.ssl.X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] cert, String foo) { } public void checkServerTrusted( java.security.cert.X509Certificate[] cert, String foo) { } }; context.init(null, new javax.net.ssl.TrustManager[] { tm }, null); SSLSocketFactory factory = context.getSocketFactory(); s = factory.createSocket(s, host, port, true); } } catch (ConnectException e) { throw new ConnectException(path.getURL() + ": " + e.getMessage()); } catch (Exception e) { throw new ConnectException(path.getURL() + ": " + e.toString()); } int socketTimeout = 300 * 1000; try { s.setSoTimeout(socketTimeout); } catch (Exception e) { } return new HttpStream(path, host, port, s); }
java
static private HttpStream createStream(HttpPath path) throws IOException { String host = path.getHost(); int port = path.getPort(); HttpStream stream = null; long streamTime = 0; synchronized (LOCK) { if (_savedStream != null && host.equals(_savedStream.getHost()) && port == _savedStream.getPort()) { stream = _savedStream; streamTime = _saveTime; _savedStream = null; } } if (stream != null) { long now; now = CurrentTime.currentTime(); if (now < streamTime + 5000) { // if the stream is still valid, use it stream.init(path); return stream; } else { // if the stream has timed out, close it try { stream._isKeepalive = false; stream.close(); } catch (IOException e) { log.log(Level.FINE, e.toString(), e); } } } Socket s; try { s = new Socket(host, port); if (path instanceof HttpsPath) { SSLContext context = SSLContext.getInstance("TLS"); javax.net.ssl.TrustManager tm = new javax.net.ssl.X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] cert, String foo) { } public void checkServerTrusted( java.security.cert.X509Certificate[] cert, String foo) { } }; context.init(null, new javax.net.ssl.TrustManager[] { tm }, null); SSLSocketFactory factory = context.getSocketFactory(); s = factory.createSocket(s, host, port, true); } } catch (ConnectException e) { throw new ConnectException(path.getURL() + ": " + e.getMessage()); } catch (Exception e) { throw new ConnectException(path.getURL() + ": " + e.toString()); } int socketTimeout = 300 * 1000; try { s.setSoTimeout(socketTimeout); } catch (Exception e) { } return new HttpStream(path, host, port, s); }
[ "static", "private", "HttpStream", "createStream", "(", "HttpPath", "path", ")", "throws", "IOException", "{", "String", "host", "=", "path", ".", "getHost", "(", ")", ";", "int", "port", "=", "path", ".", "getPort", "(", ")", ";", "HttpStream", "stream", ...
Creates a new HTTP stream. If there is a saved connection to the same host, use it. @param path the URL for the stream @return the opened stream
[ "Creates", "a", "new", "HTTP", "stream", ".", "If", "there", "is", "a", "saved", "connection", "to", "the", "same", "host", "use", "it", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/HttpStream.java#L198-L278
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/HttpStream.java
HttpStream.init
private void init(PathImpl path) { _contentLength = -1; _isChunked = false; _isRequestDone = false; _didGet = false; _isPost = false; _isHead = false; _method = null; _attributes.clear(); //setPath(path); if (path instanceof HttpPath) _virtualHost = ((HttpPath) path).getVirtualHost(); }
java
private void init(PathImpl path) { _contentLength = -1; _isChunked = false; _isRequestDone = false; _didGet = false; _isPost = false; _isHead = false; _method = null; _attributes.clear(); //setPath(path); if (path instanceof HttpPath) _virtualHost = ((HttpPath) path).getVirtualHost(); }
[ "private", "void", "init", "(", "PathImpl", "path", ")", "{", "_contentLength", "=", "-", "1", ";", "_isChunked", "=", "false", ";", "_isRequestDone", "=", "false", ";", "_didGet", "=", "false", ";", "_isPost", "=", "false", ";", "_isHead", "=", "false",...
Initializes the stream for the next request.
[ "Initializes", "the", "stream", "for", "the", "next", "request", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/HttpStream.java#L283-L298
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/HttpStream.java
HttpStream.getConnInput
private void getConnInput() throws IOException { if (_didGet) return; try { getConnInputImpl(); } catch (IOException e) { _isKeepalive = false; throw e; } catch (RuntimeException e) { _isKeepalive = false; throw e; } }
java
private void getConnInput() throws IOException { if (_didGet) return; try { getConnInputImpl(); } catch (IOException e) { _isKeepalive = false; throw e; } catch (RuntimeException e) { _isKeepalive = false; throw e; } }
[ "private", "void", "getConnInput", "(", ")", "throws", "IOException", "{", "if", "(", "_didGet", ")", "return", ";", "try", "{", "getConnInputImpl", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "_isKeepalive", "=", "false", ";", "throw...
Sends the request and initializes the response.
[ "Sends", "the", "request", "and", "initializes", "the", "response", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/HttpStream.java#L583-L597
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java
RolloverLogBase.setPathFormat
public void setPathFormat(String pathFormat) throws ConfigException { _pathFormat = pathFormat; if (pathFormat.endsWith(".zip")) { throw new ConfigException(L.l(".zip extension to path-format is not supported.")); } }
java
public void setPathFormat(String pathFormat) throws ConfigException { _pathFormat = pathFormat; if (pathFormat.endsWith(".zip")) { throw new ConfigException(L.l(".zip extension to path-format is not supported.")); } }
[ "public", "void", "setPathFormat", "(", "String", "pathFormat", ")", "throws", "ConfigException", "{", "_pathFormat", "=", "pathFormat", ";", "if", "(", "pathFormat", ".", "endsWith", "(", "\".zip\"", ")", ")", "{", "throw", "new", "ConfigException", "(", "L",...
Sets the formatted path.
[ "Sets", "the", "formatted", "path", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java#L184-L192
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java
RolloverLogBase.setArchiveFormat
public void setArchiveFormat(String format) { if (format.endsWith(".gz")) { _archiveFormat = format.substring(0, format.length() - ".gz".length()); _archiveSuffix = ".gz"; } else if (format.endsWith(".zip")) { _archiveFormat = format.substring(0, format.length() - ".zip".length()); _archiveSuffix = ".zip"; } else { _archiveFormat = format; _archiveSuffix = ""; } }
java
public void setArchiveFormat(String format) { if (format.endsWith(".gz")) { _archiveFormat = format.substring(0, format.length() - ".gz".length()); _archiveSuffix = ".gz"; } else if (format.endsWith(".zip")) { _archiveFormat = format.substring(0, format.length() - ".zip".length()); _archiveSuffix = ".zip"; } else { _archiveFormat = format; _archiveSuffix = ""; } }
[ "public", "void", "setArchiveFormat", "(", "String", "format", ")", "{", "if", "(", "format", ".", "endsWith", "(", "\".gz\"", ")", ")", "{", "_archiveFormat", "=", "format", ".", "substring", "(", "0", ",", "format", ".", "length", "(", ")", "-", "\"....
Sets the archive name format
[ "Sets", "the", "archive", "name", "format" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java#L197-L211
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java
RolloverLogBase.setRolloverPeriod
public void setRolloverPeriod(Duration period) { _rolloverPeriod = period.toMillis(); if (_rolloverPeriod > 0) { _rolloverPeriod += 3600000L - 1; _rolloverPeriod -= _rolloverPeriod % 3600000L; } else _rolloverPeriod = Integer.MAX_VALUE; // Period.INFINITE; }
java
public void setRolloverPeriod(Duration period) { _rolloverPeriod = period.toMillis(); if (_rolloverPeriod > 0) { _rolloverPeriod += 3600000L - 1; _rolloverPeriod -= _rolloverPeriod % 3600000L; } else _rolloverPeriod = Integer.MAX_VALUE; // Period.INFINITE; }
[ "public", "void", "setRolloverPeriod", "(", "Duration", "period", ")", "{", "_rolloverPeriod", "=", "period", ".", "toMillis", "(", ")", ";", "if", "(", "_rolloverPeriod", ">", "0", ")", "{", "_rolloverPeriod", "+=", "3600000L", "-", "1", ";", "_rolloverPeri...
Sets the log rollover period, rounded up to the nearest hour. @param period the new rollover period in milliseconds.
[ "Sets", "the", "log", "rollover", "period", "rounded", "up", "to", "the", "nearest", "hour", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java#L237-L247
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java
RolloverLogBase.setRolloverCheckPeriod
public void setRolloverCheckPeriod(long period) { if (period > 1000) _rolloverCheckPeriod = period; else if (period > 0) _rolloverCheckPeriod = 1000; if (DAY < _rolloverCheckPeriod) { log.info(this + " rollover-check-period " + _rolloverCheckPeriod + "ms is longer than 24h"); _rolloverCheckPeriod = DAY; } }
java
public void setRolloverCheckPeriod(long period) { if (period > 1000) _rolloverCheckPeriod = period; else if (period > 0) _rolloverCheckPeriod = 1000; if (DAY < _rolloverCheckPeriod) { log.info(this + " rollover-check-period " + _rolloverCheckPeriod + "ms is longer than 24h"); _rolloverCheckPeriod = DAY; } }
[ "public", "void", "setRolloverCheckPeriod", "(", "long", "period", ")", "{", "if", "(", "period", ">", "1000", ")", "_rolloverCheckPeriod", "=", "period", ";", "else", "if", "(", "period", ">", "0", ")", "_rolloverCheckPeriod", "=", "1000", ";", "if", "(",...
Sets how often the log rollover will be checked. @param period how often the log rollover will be checked.
[ "Sets", "how", "often", "the", "log", "rollover", "will", "be", "checked", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java#L292-L305
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java
RolloverLogBase.write
@Override public void write(byte []buffer, int offset, int length) throws IOException { synchronized (_logLock) { if (_isRollingOver && getTempStreamMax() < _tempStreamSize) { try { _logLock.wait(); } catch (Exception e) { } } if (! _isRollingOver) { if (_os == null) openLog(); if (_os != null) _os.write(buffer, offset, length); } else { // XXX: throw new UnsupportedOperationException(getClass().getName()); /* if (_tempStream == null) { _tempStream = createTempStream(); _tempStreamSize = 0; } _tempStreamSize += length; _tempStream.write(buffer, offset, length); */ } } }
java
@Override public void write(byte []buffer, int offset, int length) throws IOException { synchronized (_logLock) { if (_isRollingOver && getTempStreamMax() < _tempStreamSize) { try { _logLock.wait(); } catch (Exception e) { } } if (! _isRollingOver) { if (_os == null) openLog(); if (_os != null) _os.write(buffer, offset, length); } else { // XXX: throw new UnsupportedOperationException(getClass().getName()); /* if (_tempStream == null) { _tempStream = createTempStream(); _tempStreamSize = 0; } _tempStreamSize += length; _tempStream.write(buffer, offset, length); */ } } }
[ "@", "Override", "public", "void", "write", "(", "byte", "[", "]", "buffer", ",", "int", "offset", ",", "int", "length", ")", "throws", "IOException", "{", "synchronized", "(", "_logLock", ")", "{", "if", "(", "_isRollingOver", "&&", "getTempStreamMax", "(...
Writes to the underlying log.
[ "Writes", "to", "the", "underlying", "log", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java#L407-L441
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java
RolloverLogBase.rolloverLogTask
private void rolloverLogTask() { try { if (_isInit) { flush(); } } catch (Exception e) { log.log(Level.WARNING, e.toString(), e); } _isRollingOver = true; try { if (! _isInit) return; Path savedPath = null; long now = CurrentTime.currentTime(); long lastPeriodEnd = _nextPeriodEnd; _nextPeriodEnd = nextRolloverTime(now); Path path = getPath(); synchronized (_logLock) { flushTempStream(); long length = Files.size(path); if (lastPeriodEnd <= now && lastPeriodEnd > 0) { closeLogStream(); savedPath = getSavedPath(lastPeriodEnd - 1); } else if (path != null && getRolloverSize() <= length) { closeLogStream(); savedPath = getSavedPath(now); } } // archiving of path is outside of the synchronized block to // avoid freezing during archive if (savedPath != null) { movePathToArchive(savedPath); } } catch (IOException e) { e.printStackTrace(); } finally { synchronized (_logLock) { _isRollingOver = false; flushTempStream(); } _rolloverListener.requeue(_rolloverAlarm); } }
java
private void rolloverLogTask() { try { if (_isInit) { flush(); } } catch (Exception e) { log.log(Level.WARNING, e.toString(), e); } _isRollingOver = true; try { if (! _isInit) return; Path savedPath = null; long now = CurrentTime.currentTime(); long lastPeriodEnd = _nextPeriodEnd; _nextPeriodEnd = nextRolloverTime(now); Path path = getPath(); synchronized (_logLock) { flushTempStream(); long length = Files.size(path); if (lastPeriodEnd <= now && lastPeriodEnd > 0) { closeLogStream(); savedPath = getSavedPath(lastPeriodEnd - 1); } else if (path != null && getRolloverSize() <= length) { closeLogStream(); savedPath = getSavedPath(now); } } // archiving of path is outside of the synchronized block to // avoid freezing during archive if (savedPath != null) { movePathToArchive(savedPath); } } catch (IOException e) { e.printStackTrace(); } finally { synchronized (_logLock) { _isRollingOver = false; flushTempStream(); } _rolloverListener.requeue(_rolloverAlarm); } }
[ "private", "void", "rolloverLogTask", "(", ")", "{", "try", "{", "if", "(", "_isInit", ")", "{", "flush", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "WARNING", ",", "e", ".", "toString...
Called from rollover worker
[ "Called", "from", "rollover", "worker" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java#L480-L538
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java
RolloverLogBase.openLog
private void openLog() { closeLogStream(); WriteStream os = _os; _os = null; IoUtil.close(os); Path path = getPath(); if (path == null) { path = getPath(CurrentTime.currentTime()); } Path parent = path.getParent(); try { if (! Files.isDirectory(parent)) { Files.createDirectory(parent); } } catch (Exception e) { logWarning(L.l("Can't create log directory {0}.\n Exception={1}", parent, e), e); } Exception exn = null; for (int i = 0; i < 3 && _os == null; i++) { try { OutputStream out = Files.newOutputStream(path, StandardOpenOption.APPEND); _os = new WriteStream(out); } catch (IOException e) { exn = e; } } String pathName = path.toString(); try { if (pathName.endsWith(".gz")) { _zipOut = _os; _os = new WriteStream(new GZIPOutputStream(_zipOut)); } else if (pathName.endsWith(".zip")) { throw new ConfigException("Can't support .zip in path-format"); } } catch (Exception e) { if (exn == null) exn = e; } if (exn != null) logWarning(L.l("Can't create log for {0}.\n User={1} Exception={2}", path, System.getProperty("user.name"), exn), exn); }
java
private void openLog() { closeLogStream(); WriteStream os = _os; _os = null; IoUtil.close(os); Path path = getPath(); if (path == null) { path = getPath(CurrentTime.currentTime()); } Path parent = path.getParent(); try { if (! Files.isDirectory(parent)) { Files.createDirectory(parent); } } catch (Exception e) { logWarning(L.l("Can't create log directory {0}.\n Exception={1}", parent, e), e); } Exception exn = null; for (int i = 0; i < 3 && _os == null; i++) { try { OutputStream out = Files.newOutputStream(path, StandardOpenOption.APPEND); _os = new WriteStream(out); } catch (IOException e) { exn = e; } } String pathName = path.toString(); try { if (pathName.endsWith(".gz")) { _zipOut = _os; _os = new WriteStream(new GZIPOutputStream(_zipOut)); } else if (pathName.endsWith(".zip")) { throw new ConfigException("Can't support .zip in path-format"); } } catch (Exception e) { if (exn == null) exn = e; } if (exn != null) logWarning(L.l("Can't create log for {0}.\n User={1} Exception={2}", path, System.getProperty("user.name"), exn), exn); }
[ "private", "void", "openLog", "(", ")", "{", "closeLogStream", "(", ")", ";", "WriteStream", "os", "=", "_os", ";", "_os", "=", "null", ";", "IoUtil", ".", "close", "(", "os", ")", ";", "Path", "path", "=", "getPath", "(", ")", ";", "if", "(", "p...
Tries to open the log. Called from inside _logLock
[ "Tries", "to", "open", "the", "log", ".", "Called", "from", "inside", "_logLock" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java#L551-L606
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java
RolloverLogBase.removeOldLogs
private void removeOldLogs() { try { Path path = getPath(); Path parent = path.getParent(); ArrayList<String> matchList = new ArrayList<String>(); Pattern archiveRegexp = getArchiveRegexp(); Files.list(parent).forEach(child->{ String subPath = child.getFileName().toString(); Matcher matcher = archiveRegexp.matcher(subPath); if (matcher.matches()) matchList.add(subPath); }); Collections.sort(matchList); if (_rolloverCount <= 0 || matchList.size() < _rolloverCount) return; for (int i = 0; i + _rolloverCount < matchList.size(); i++) { try { Files.delete(parent.resolve(matchList.get(i))); } catch (Throwable e) { } } } catch (Throwable e) { } }
java
private void removeOldLogs() { try { Path path = getPath(); Path parent = path.getParent(); ArrayList<String> matchList = new ArrayList<String>(); Pattern archiveRegexp = getArchiveRegexp(); Files.list(parent).forEach(child->{ String subPath = child.getFileName().toString(); Matcher matcher = archiveRegexp.matcher(subPath); if (matcher.matches()) matchList.add(subPath); }); Collections.sort(matchList); if (_rolloverCount <= 0 || matchList.size() < _rolloverCount) return; for (int i = 0; i + _rolloverCount < matchList.size(); i++) { try { Files.delete(parent.resolve(matchList.get(i))); } catch (Throwable e) { } } } catch (Throwable e) { } }
[ "private", "void", "removeOldLogs", "(", ")", "{", "try", "{", "Path", "path", "=", "getPath", "(", ")", ";", "Path", "parent", "=", "path", ".", "getParent", "(", ")", ";", "ArrayList", "<", "String", ">", "matchList", "=", "new", "ArrayList", "<", ...
Removes logs passing the rollover count.
[ "Removes", "logs", "passing", "the", "rollover", "count", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java#L703-L734
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java
RolloverLogBase.getPath
protected Path getPath(long time) { String formatString = getPathFormat(); if (formatString == null) throw new IllegalStateException(L.l("getPath requires a format path")); String pathString = getFormatName(formatString, time); return getPwd().resolve(pathString); }
java
protected Path getPath(long time) { String formatString = getPathFormat(); if (formatString == null) throw new IllegalStateException(L.l("getPath requires a format path")); String pathString = getFormatName(formatString, time); return getPwd().resolve(pathString); }
[ "protected", "Path", "getPath", "(", "long", "time", ")", "{", "String", "formatString", "=", "getPathFormat", "(", ")", ";", "if", "(", "formatString", "==", "null", ")", "throw", "new", "IllegalStateException", "(", "L", ".", "l", "(", "\"getPath requires ...
Returns the path of the format file @param time the archive date
[ "Returns", "the", "path", "of", "the", "format", "file" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java#L769-L779
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java
RolloverLogBase.close
public void close() throws IOException { _isClosed = true; _rolloverWorker.wake(); _rolloverWorker.close(); synchronized (_logLock) { closeLogStream(); } Alarm alarm = _rolloverAlarm; _rolloverAlarm = null; if (alarm != null) alarm.dequeue(); }
java
public void close() throws IOException { _isClosed = true; _rolloverWorker.wake(); _rolloverWorker.close(); synchronized (_logLock) { closeLogStream(); } Alarm alarm = _rolloverAlarm; _rolloverAlarm = null; if (alarm != null) alarm.dequeue(); }
[ "public", "void", "close", "(", ")", "throws", "IOException", "{", "_isClosed", "=", "true", ";", "_rolloverWorker", ".", "wake", "(", ")", ";", "_rolloverWorker", ".", "close", "(", ")", ";", "synchronized", "(", "_logLock", ")", "{", "closeLogStream", "(...
Closes the log, flushing the results.
[ "Closes", "the", "log", "flushing", "the", "results", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java#L868-L886
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java
RolloverLogBase.closeLogStream
private void closeLogStream() { try { WriteStream os = _os; _os = null; if (os != null) os.close(); } catch (Throwable e) { // can't log in log routines } try { WriteStream zipOut = _zipOut; _zipOut = null; if (zipOut != null) zipOut.close(); } catch (Throwable e) { // can't log in log routines } }
java
private void closeLogStream() { try { WriteStream os = _os; _os = null; if (os != null) os.close(); } catch (Throwable e) { // can't log in log routines } try { WriteStream zipOut = _zipOut; _zipOut = null; if (zipOut != null) zipOut.close(); } catch (Throwable e) { // can't log in log routines } }
[ "private", "void", "closeLogStream", "(", ")", "{", "try", "{", "WriteStream", "os", "=", "_os", ";", "_os", "=", "null", ";", "if", "(", "os", "!=", "null", ")", "os", ".", "close", "(", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", ...
Tries to close the log.
[ "Tries", "to", "close", "the", "log", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/RolloverLogBase.java#L891-L912
train
SeaCloudsEU/SeaCloudsPlatform
dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java
DeployerProxy.getApplication
public ApplicationSummary getApplication(String brooklynId) throws IOException { Invocation invocation = getJerseyClient().target(getEndpoint() + "/v1/applications/" + brooklynId).request().buildGet(); return invocation.invoke().readEntity(ApplicationSummary.class); }
java
public ApplicationSummary getApplication(String brooklynId) throws IOException { Invocation invocation = getJerseyClient().target(getEndpoint() + "/v1/applications/" + brooklynId).request().buildGet(); return invocation.invoke().readEntity(ApplicationSummary.class); }
[ "public", "ApplicationSummary", "getApplication", "(", "String", "brooklynId", ")", "throws", "IOException", "{", "Invocation", "invocation", "=", "getJerseyClient", "(", ")", ".", "target", "(", "getEndpoint", "(", ")", "+", "\"/v1/applications/\"", "+", "brooklynI...
Creates proxied HTTP GET request to Apache Brooklyn which returns the details about a particular hosted application @param brooklynId of the desired application to fetch. This ID may differ from SeaClouds Application ID @return ApplicationSummary
[ "Creates", "proxied", "HTTP", "GET", "request", "to", "Apache", "Brooklyn", "which", "returns", "the", "details", "about", "a", "particular", "hosted", "application" ]
b199fe6de2c63b808cb248d3aca947d802375df8
https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java#L46-L49
train
SeaCloudsEU/SeaCloudsPlatform
dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java
DeployerProxy.getApplicationsTree
public JsonNode getApplicationsTree() throws IOException { Invocation invocation = getJerseyClient().target(getEndpoint() + "/v1/applications/fetch").request().buildGet(); return invocation.invoke().readEntity(JsonNode.class); }
java
public JsonNode getApplicationsTree() throws IOException { Invocation invocation = getJerseyClient().target(getEndpoint() + "/v1/applications/fetch").request().buildGet(); return invocation.invoke().readEntity(JsonNode.class); }
[ "public", "JsonNode", "getApplicationsTree", "(", ")", "throws", "IOException", "{", "Invocation", "invocation", "=", "getJerseyClient", "(", ")", ".", "target", "(", "getEndpoint", "(", ")", "+", "\"/v1/applications/fetch\"", ")", ".", "request", "(", ")", ".",...
Creates proxied HTTP GET request to Apache Brooklyn which returns the whole applications tree @return JsonNode
[ "Creates", "proxied", "HTTP", "GET", "request", "to", "Apache", "Brooklyn", "which", "returns", "the", "whole", "applications", "tree" ]
b199fe6de2c63b808cb248d3aca947d802375df8
https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java#L57-L60
train
SeaCloudsEU/SeaCloudsPlatform
dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java
DeployerProxy.removeApplication
public TaskSummary removeApplication(String brooklynId) throws IOException { Invocation invocation = getJerseyClient().target(getEndpoint() + "/v1/applications/" + brooklynId).request().buildDelete(); return invocation.invoke().readEntity(TaskSummary.class); }
java
public TaskSummary removeApplication(String brooklynId) throws IOException { Invocation invocation = getJerseyClient().target(getEndpoint() + "/v1/applications/" + brooklynId).request().buildDelete(); return invocation.invoke().readEntity(TaskSummary.class); }
[ "public", "TaskSummary", "removeApplication", "(", "String", "brooklynId", ")", "throws", "IOException", "{", "Invocation", "invocation", "=", "getJerseyClient", "(", ")", ".", "target", "(", "getEndpoint", "(", ")", "+", "\"/v1/applications/\"", "+", "brooklynId", ...
Creates a proxied HTTP DELETE request to Apache Brooklyn to remove an application @param brooklynId of the desired application to remove. This ID may differ from SeaClouds Application ID @return TaskSummary representing the running process
[ "Creates", "a", "proxied", "HTTP", "DELETE", "request", "to", "Apache", "Brooklyn", "to", "remove", "an", "application" ]
b199fe6de2c63b808cb248d3aca947d802375df8
https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java#L69-L72
train
SeaCloudsEU/SeaCloudsPlatform
dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java
DeployerProxy.deployApplication
public TaskSummary deployApplication(String tosca) throws IOException { Entity content = Entity.entity(tosca, "application/x-yaml"); Invocation invocation = getJerseyClient().target(getEndpoint() + "/v1/applications").request().buildPost(content); return invocation.invoke().readEntity(TaskSummary.class); }
java
public TaskSummary deployApplication(String tosca) throws IOException { Entity content = Entity.entity(tosca, "application/x-yaml"); Invocation invocation = getJerseyClient().target(getEndpoint() + "/v1/applications").request().buildPost(content); return invocation.invoke().readEntity(TaskSummary.class); }
[ "public", "TaskSummary", "deployApplication", "(", "String", "tosca", ")", "throws", "IOException", "{", "Entity", "content", "=", "Entity", ".", "entity", "(", "tosca", ",", "\"application/x-yaml\"", ")", ";", "Invocation", "invocation", "=", "getJerseyClient", "...
Creates a proxied HTTP POST request to Apache Brooklyn to deploy a new application @param tosca file compliant with the Apache Brooklyn TOSCA specification @return TaskSummary representing the running process
[ "Creates", "a", "proxied", "HTTP", "POST", "request", "to", "Apache", "Brooklyn", "to", "deploy", "a", "new", "application" ]
b199fe6de2c63b808cb248d3aca947d802375df8
https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java#L80-L84
train
SeaCloudsEU/SeaCloudsPlatform
dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java
DeployerProxy.getEntitiesFromApplication
public List<EntitySummary> getEntitiesFromApplication(String brooklynId) throws IOException { Invocation invocation = getJerseyClient().target(getEndpoint() + "/v1/applications/" + brooklynId + "/entities") .request().buildGet(); return invocation.invoke().readEntity(new GenericType<List<EntitySummary>>(){}); }
java
public List<EntitySummary> getEntitiesFromApplication(String brooklynId) throws IOException { Invocation invocation = getJerseyClient().target(getEndpoint() + "/v1/applications/" + brooklynId + "/entities") .request().buildGet(); return invocation.invoke().readEntity(new GenericType<List<EntitySummary>>(){}); }
[ "public", "List", "<", "EntitySummary", ">", "getEntitiesFromApplication", "(", "String", "brooklynId", ")", "throws", "IOException", "{", "Invocation", "invocation", "=", "getJerseyClient", "(", ")", ".", "target", "(", "getEndpoint", "(", ")", "+", "\"/v1/applic...
Creates a proxied HTTP GET request to Apache Brooklyn to retrieve the Application's Entities @param brooklynId of the desired application to fetch. This ID may differ from SeaClouds Application ID @return List<EntitySummary> with all the children entities of the application
[ "Creates", "a", "proxied", "HTTP", "GET", "request", "to", "Apache", "Brooklyn", "to", "retrieve", "the", "Application", "s", "Entities" ]
b199fe6de2c63b808cb248d3aca947d802375df8
https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java#L92-L97
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/SchemeMap.java
SchemeMap.get
public PathImpl get(String scheme) { ConcurrentHashMap<String,SchemeRoot> map = getMap(); SchemeRoot root = map.get(scheme); if (root == null) { PathImpl rootPath = createLazyScheme(scheme); if (rootPath != null) { map.putIfAbsent(scheme, new SchemeRoot(rootPath)); root = map.get(scheme); } } PathImpl path = null; if (root != null) { path = root.getRoot(); } if (path != null) { return path; } else { return new NotFoundPath(this, scheme + ":"); } }
java
public PathImpl get(String scheme) { ConcurrentHashMap<String,SchemeRoot> map = getMap(); SchemeRoot root = map.get(scheme); if (root == null) { PathImpl rootPath = createLazyScheme(scheme); if (rootPath != null) { map.putIfAbsent(scheme, new SchemeRoot(rootPath)); root = map.get(scheme); } } PathImpl path = null; if (root != null) { path = root.getRoot(); } if (path != null) { return path; } else { return new NotFoundPath(this, scheme + ":"); } }
[ "public", "PathImpl", "get", "(", "String", "scheme", ")", "{", "ConcurrentHashMap", "<", "String", ",", "SchemeRoot", ">", "map", "=", "getMap", "(", ")", ";", "SchemeRoot", "root", "=", "map", ".", "get", "(", "scheme", ")", ";", "if", "(", "root", ...
Gets the scheme from the schemeMap.
[ "Gets", "the", "scheme", "from", "the", "schemeMap", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/SchemeMap.java#L95-L122
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/SchemeMap.java
SchemeMap.remove
public PathImpl remove(String scheme) { SchemeRoot oldRoot = getUpdateMap().remove(scheme); return oldRoot != null ? oldRoot.getRoot() : null; }
java
public PathImpl remove(String scheme) { SchemeRoot oldRoot = getUpdateMap().remove(scheme); return oldRoot != null ? oldRoot.getRoot() : null; }
[ "public", "PathImpl", "remove", "(", "String", "scheme", ")", "{", "SchemeRoot", "oldRoot", "=", "getUpdateMap", "(", ")", ".", "remove", "(", "scheme", ")", ";", "return", "oldRoot", "!=", "null", "?", "oldRoot", ".", "getRoot", "(", ")", ":", "null", ...
Removes value from the schemeMap.
[ "Removes", "value", "from", "the", "schemeMap", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/SchemeMap.java#L160-L165
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/cpool/MethodHandleConstant.java
MethodHandleConstant.export
@Override public int export(ConstantPool target) { int entryIndex = _entry.export(target); return target.addMethodHandle(_type, target.getEntry(entryIndex)).getIndex(); }
java
@Override public int export(ConstantPool target) { int entryIndex = _entry.export(target); return target.addMethodHandle(_type, target.getEntry(entryIndex)).getIndex(); }
[ "@", "Override", "public", "int", "export", "(", "ConstantPool", "target", ")", "{", "int", "entryIndex", "=", "_entry", ".", "export", "(", "target", ")", ";", "return", "target", ".", "addMethodHandle", "(", "_type", ",", "target", ".", "getEntry", "(", ...
Exports to the target pool.
[ "Exports", "to", "the", "target", "pool", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/cpool/MethodHandleConstant.java#L85-L91
train
baratine/baratine
web/src/main/java/com/caucho/v5/web/builder/WebServerBuilderImpl.java
WebServerBuilderImpl.initHttpSystem
protected void initHttpSystem(SystemManager system, ServerBartender selfServer) throws IOException { //RootConfigBoot rootConfig = getRootConfig(); String clusterId = selfServer.getClusterId(); //ClusterConfigBoot clusterConfig = rootConfig.findCluster(clusterId); String serverHeader = config().get("server.header"); if (serverHeader != null) { } else if (! CurrentTime.isTest()) { serverHeader = getProgramName() + "/" + Version.getVersion(); } else { serverHeader = getProgramName() + "/1.1"; } // XXX: need cleaner config class names (root vs cluster at minimum) /* ServerContainerConfig serverConfig = new ServerContainerConfig(this, system, selfServer); */ // rootConfig.getProgram().configure(serverConfig); //clusterConfig.getProgram().configure(serverConfig); /* ServerConfig config = new ServerConfig(serverConfig); clusterConfig.getServerDefault().configure(config); ServerConfigBoot serverConfigBoot = rootConfig.findServer(selfServer.getDisplayName()); if (serverConfigBoot != null) { serverConfigBoot.getServerProgram().configure(config); } */ /* _args.getProgram().configure(config); */ // _bootServerConfig.getServerProgram().configure(config); // serverConfig.init(); //int port = getServerPort(); HttpContainerBuilder httpBuilder = createHttpBuilder(selfServer, serverHeader); // serverConfig.getProgram().configure(httpBuilder); //httpBuilder.init(); //PodSystem.createAndAddSystem(httpBuilder); HttpSystem.createAndAddSystem(httpBuilder); //return http; }
java
protected void initHttpSystem(SystemManager system, ServerBartender selfServer) throws IOException { //RootConfigBoot rootConfig = getRootConfig(); String clusterId = selfServer.getClusterId(); //ClusterConfigBoot clusterConfig = rootConfig.findCluster(clusterId); String serverHeader = config().get("server.header"); if (serverHeader != null) { } else if (! CurrentTime.isTest()) { serverHeader = getProgramName() + "/" + Version.getVersion(); } else { serverHeader = getProgramName() + "/1.1"; } // XXX: need cleaner config class names (root vs cluster at minimum) /* ServerContainerConfig serverConfig = new ServerContainerConfig(this, system, selfServer); */ // rootConfig.getProgram().configure(serverConfig); //clusterConfig.getProgram().configure(serverConfig); /* ServerConfig config = new ServerConfig(serverConfig); clusterConfig.getServerDefault().configure(config); ServerConfigBoot serverConfigBoot = rootConfig.findServer(selfServer.getDisplayName()); if (serverConfigBoot != null) { serverConfigBoot.getServerProgram().configure(config); } */ /* _args.getProgram().configure(config); */ // _bootServerConfig.getServerProgram().configure(config); // serverConfig.init(); //int port = getServerPort(); HttpContainerBuilder httpBuilder = createHttpBuilder(selfServer, serverHeader); // serverConfig.getProgram().configure(httpBuilder); //httpBuilder.init(); //PodSystem.createAndAddSystem(httpBuilder); HttpSystem.createAndAddSystem(httpBuilder); //return http; }
[ "protected", "void", "initHttpSystem", "(", "SystemManager", "system", ",", "ServerBartender", "selfServer", ")", "throws", "IOException", "{", "//RootConfigBoot rootConfig = getRootConfig();", "String", "clusterId", "=", "selfServer", ".", "getClusterId", "(", ")", ";", ...
Configures the selected server from the boot config.
[ "Configures", "the", "selected", "server", "from", "the", "boot", "config", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/web/builder/WebServerBuilderImpl.java#L1119-L1182
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/Depend.java
Depend.isModified
@Override public boolean isModified() { if (_isDigestModified) { if (log.isLoggable(Level.FINE)) log.fine(_source.getNativePath() + " digest is modified."); return true; } long sourceLastModified = _source.getLastModified(); long sourceLength = _source.length(); // if the source was deleted and we need the source if (! _requireSource && sourceLastModified == 0) { return false; } // if the length changed else if (sourceLength != _length) { if (log.isLoggable(Level.FINE)) { log.fine(_source.getNativePath() + " length is modified (" + _length + " -> " + sourceLength + ")"); } return true; } // if the source is newer than the old value else if (sourceLastModified != _lastModified) { if (log.isLoggable(Level.FINE)) log.fine(_source.getNativePath() + " time is modified."); return true; } else return false; }
java
@Override public boolean isModified() { if (_isDigestModified) { if (log.isLoggable(Level.FINE)) log.fine(_source.getNativePath() + " digest is modified."); return true; } long sourceLastModified = _source.getLastModified(); long sourceLength = _source.length(); // if the source was deleted and we need the source if (! _requireSource && sourceLastModified == 0) { return false; } // if the length changed else if (sourceLength != _length) { if (log.isLoggable(Level.FINE)) { log.fine(_source.getNativePath() + " length is modified (" + _length + " -> " + sourceLength + ")"); } return true; } // if the source is newer than the old value else if (sourceLastModified != _lastModified) { if (log.isLoggable(Level.FINE)) log.fine(_source.getNativePath() + " time is modified."); return true; } else return false; }
[ "@", "Override", "public", "boolean", "isModified", "(", ")", "{", "if", "(", "_isDigestModified", ")", "{", "if", "(", "log", ".", "isLoggable", "(", "Level", ".", "FINE", ")", ")", "log", ".", "fine", "(", "_source", ".", "getNativePath", "(", ")", ...
If the source modified date changes at all, treat it as a modification. This protects against the case where multiple computers have misaligned dates and a '<' comparison may fail.
[ "If", "the", "source", "modified", "date", "changes", "at", "all", "treat", "it", "as", "a", "modification", ".", "This", "protects", "against", "the", "case", "where", "multiple", "computers", "have", "misaligned", "dates", "and", "a", "<", "comparison", "m...
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/Depend.java#L164-L199
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/Depend.java
Depend.logModified
public boolean logModified(Logger log) { if (_isDigestModified) { log.info(_source.getNativePath() + " digest is modified."); return true; } long sourceLastModified = _source.getLastModified(); long sourceLength = _source.length(); // if the source was deleted and we need the source if (! _requireSource && sourceLastModified == 0) { return false; } // if the length changed else if (sourceLength != _length) { log.info(_source.getNativePath() + " length is modified (" + _length + " -> " + sourceLength + ")"); return true; } // if the source is newer than the old value else if (sourceLastModified != _lastModified) { log.info(_source.getNativePath() + " time is modified."); return true; } else return false; }
java
public boolean logModified(Logger log) { if (_isDigestModified) { log.info(_source.getNativePath() + " digest is modified."); return true; } long sourceLastModified = _source.getLastModified(); long sourceLength = _source.length(); // if the source was deleted and we need the source if (! _requireSource && sourceLastModified == 0) { return false; } // if the length changed else if (sourceLength != _length) { log.info(_source.getNativePath() + " length is modified (" + _length + " -> " + sourceLength + ")"); return true; } // if the source is newer than the old value else if (sourceLastModified != _lastModified) { log.info(_source.getNativePath() + " time is modified."); return true; } else return false; }
[ "public", "boolean", "logModified", "(", "Logger", "log", ")", "{", "if", "(", "_isDigestModified", ")", "{", "log", ".", "info", "(", "_source", ".", "getNativePath", "(", ")", "+", "\" digest is modified.\"", ")", ";", "return", "true", ";", "}", "long",...
Log the reason for modification
[ "Log", "the", "reason", "for", "modification" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/Depend.java#L204-L234
train
baratine/baratine
framework/src/main/java/com/caucho/v5/config/reflect/BaseType.java
BaseType.createGenericClass
public static BaseType createGenericClass(Class<?> type) { TypeVariable<?> []typeParam = type.getTypeParameters(); if (typeParam == null || typeParam.length == 0) return ClassType.create(type); BaseType []args = new BaseType[typeParam.length]; HashMap<String,BaseType> newParamMap = new HashMap<String,BaseType>(); String paramDeclName = null; for (int i = 0; i < args.length; i++) { args[i] = create(typeParam[i], newParamMap, paramDeclName, ClassFill.TARGET); if (args[i] == null) { throw new NullPointerException("unsupported BaseType: " + type); } newParamMap.put(typeParam[i].getName(), args[i]); } // ioc/07f2 return new GenericParamType(type, args, newParamMap); }
java
public static BaseType createGenericClass(Class<?> type) { TypeVariable<?> []typeParam = type.getTypeParameters(); if (typeParam == null || typeParam.length == 0) return ClassType.create(type); BaseType []args = new BaseType[typeParam.length]; HashMap<String,BaseType> newParamMap = new HashMap<String,BaseType>(); String paramDeclName = null; for (int i = 0; i < args.length; i++) { args[i] = create(typeParam[i], newParamMap, paramDeclName, ClassFill.TARGET); if (args[i] == null) { throw new NullPointerException("unsupported BaseType: " + type); } newParamMap.put(typeParam[i].getName(), args[i]); } // ioc/07f2 return new GenericParamType(type, args, newParamMap); }
[ "public", "static", "BaseType", "createGenericClass", "(", "Class", "<", "?", ">", "type", ")", "{", "TypeVariable", "<", "?", ">", "[", "]", "typeParam", "=", "type", ".", "getTypeParameters", "(", ")", ";", "if", "(", "typeParam", "==", "null", "||", ...
Create a class-based type, where any parameters are filled with the variables, not Object.
[ "Create", "a", "class", "-", "based", "type", "where", "any", "parameters", "are", "filled", "with", "the", "variables", "not", "Object", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/config/reflect/BaseType.java#L285-L312
train
baratine/baratine
web/src/main/java/com/caucho/v5/jni/JniFileStream.java
JniFileStream.read
@Override public int read(byte []buf, int offset, int length) throws IOException { if (buf == null) throw new NullPointerException(); else if (offset < 0 || buf.length < offset + length) throw new ArrayIndexOutOfBoundsException(); int result = nativeRead(_fd, buf, offset, length); if (result > 0) _pos += result; return result; }
java
@Override public int read(byte []buf, int offset, int length) throws IOException { if (buf == null) throw new NullPointerException(); else if (offset < 0 || buf.length < offset + length) throw new ArrayIndexOutOfBoundsException(); int result = nativeRead(_fd, buf, offset, length); if (result > 0) _pos += result; return result; }
[ "@", "Override", "public", "int", "read", "(", "byte", "[", "]", "buf", ",", "int", "offset", ",", "int", "length", ")", "throws", "IOException", "{", "if", "(", "buf", "==", "null", ")", "throw", "new", "NullPointerException", "(", ")", ";", "else", ...
Reads data from the file.
[ "Reads", "data", "from", "the", "file", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/jni/JniFileStream.java#L142-L157
train
baratine/baratine
web/src/main/java/com/caucho/v5/jni/JniFileStream.java
JniFileStream.lock
public boolean lock(boolean shared, boolean block) { if (shared && !_canRead) { // Invalid request for a shared "read" lock on a write only stream. return false; } if (!shared && !_canWrite) { // Invalid request for an exclusive "write" lock on a read only stream. return false; } return true; }
java
public boolean lock(boolean shared, boolean block) { if (shared && !_canRead) { // Invalid request for a shared "read" lock on a write only stream. return false; } if (!shared && !_canWrite) { // Invalid request for an exclusive "write" lock on a read only stream. return false; } return true; }
[ "public", "boolean", "lock", "(", "boolean", "shared", ",", "boolean", "block", ")", "{", "if", "(", "shared", "&&", "!", "_canRead", ")", "{", "// Invalid request for a shared \"read\" lock on a write only stream.", "return", "false", ";", "}", "if", "(", "!", ...
Implement LockableStream as a no-op, but maintain compatibility with FileWriteStream and FileReadStream wrt returning false to indicate error case.
[ "Implement", "LockableStream", "as", "a", "no", "-", "op", "but", "maintain", "compatibility", "with", "FileWriteStream", "and", "FileReadStream", "wrt", "returning", "false", "to", "indicate", "error", "case", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/jni/JniFileStream.java#L320-L335
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/JMethod.java
JMethod.getFullName
public String getFullName() { StringBuilder name = new StringBuilder(); name.append(getName()); name.append("("); JClass []params = getParameterTypes(); for (int i = 0; i < params.length; i++) { if (i != 0) name.append(", "); name.append(params[i].getShortName()); } name.append(')'); return name.toString(); }
java
public String getFullName() { StringBuilder name = new StringBuilder(); name.append(getName()); name.append("("); JClass []params = getParameterTypes(); for (int i = 0; i < params.length; i++) { if (i != 0) name.append(", "); name.append(params[i].getShortName()); } name.append(')'); return name.toString(); }
[ "public", "String", "getFullName", "(", ")", "{", "StringBuilder", "name", "=", "new", "StringBuilder", "(", ")", ";", "name", ".", "append", "(", "getName", "(", ")", ")", ";", "name", ".", "append", "(", "\"(\"", ")", ";", "JClass", "[", "]", "para...
Returns a full method name with arguments.
[ "Returns", "a", "full", "method", "name", "with", "arguments", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/JMethod.java#L104-L122
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kelp/TableGcServiceImpl.java
TableGcServiceImpl.afterBatch
@AfterBatch public void afterBatch() { if (_isGc) { return; } long gcSequence = _gcSequence; _gcSequence = 0; if (gcSequence <= 0) { return; } try { ArrayList<SegmentHeaderGc> collectList = findCollectList(gcSequence); if (collectList.size() < _table.database().getGcMinCollect()) { return; } _gcGeneration++; /* while (collectList.size() > 0) { ArrayList<SegmentHeaderGc> sublist = new ArrayList<>(); // int sublen = Math.min(_db.getGcMinCollect(), collectList.size()); int size = collectList.size(); int sublen = size; if (size > 16) { sublen = Math.min(16, collectList.size() / 2); } // System.out.println("GC: count=" + sublen + " gcSeq=" + gcSequence); //if (_db.getGcMinCollect() <= sublist.size()) { // sublen = Math.max(2, _db.getGcMinCollect() / 2); //} for (int i = 0; i < sublen; i++) { SegmentHeaderGc header = collectList.remove(0); header.startGc(); sublist.add(header); } collect(gcSequence, sublist); } */ collect(gcSequence, collectList); } catch (Throwable e) { e.printStackTrace(); } }
java
@AfterBatch public void afterBatch() { if (_isGc) { return; } long gcSequence = _gcSequence; _gcSequence = 0; if (gcSequence <= 0) { return; } try { ArrayList<SegmentHeaderGc> collectList = findCollectList(gcSequence); if (collectList.size() < _table.database().getGcMinCollect()) { return; } _gcGeneration++; /* while (collectList.size() > 0) { ArrayList<SegmentHeaderGc> sublist = new ArrayList<>(); // int sublen = Math.min(_db.getGcMinCollect(), collectList.size()); int size = collectList.size(); int sublen = size; if (size > 16) { sublen = Math.min(16, collectList.size() / 2); } // System.out.println("GC: count=" + sublen + " gcSeq=" + gcSequence); //if (_db.getGcMinCollect() <= sublist.size()) { // sublen = Math.max(2, _db.getGcMinCollect() / 2); //} for (int i = 0; i < sublen; i++) { SegmentHeaderGc header = collectList.remove(0); header.startGc(); sublist.add(header); } collect(gcSequence, sublist); } */ collect(gcSequence, collectList); } catch (Throwable e) { e.printStackTrace(); } }
[ "@", "AfterBatch", "public", "void", "afterBatch", "(", ")", "{", "if", "(", "_isGc", ")", "{", "return", ";", "}", "long", "gcSequence", "=", "_gcSequence", ";", "_gcSequence", "=", "0", ";", "if", "(", "gcSequence", "<=", "0", ")", "{", "return", "...
GC executes in @AfterBatch because it can be slower than the new requests under heavy load.
[ "GC", "executes", "in" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/TableGcServiceImpl.java#L121-L177
train
sputnikdev/bluetooth-utils
src/main/java/org/sputnikdev/bluetooth/URL.java
URL.copyWithDevice
public URL copyWithDevice(String deviceAddress, String attrName, String attrValue) { return new URL(this.protocol, this.adapterAddress, deviceAddress, Collections.singletonMap(attrName, attrValue), this.serviceUUID, this.characteristicUUID, this.fieldName); }
java
public URL copyWithDevice(String deviceAddress, String attrName, String attrValue) { return new URL(this.protocol, this.adapterAddress, deviceAddress, Collections.singletonMap(attrName, attrValue), this.serviceUUID, this.characteristicUUID, this.fieldName); }
[ "public", "URL", "copyWithDevice", "(", "String", "deviceAddress", ",", "String", "attrName", ",", "String", "attrValue", ")", "{", "return", "new", "URL", "(", "this", ".", "protocol", ",", "this", ".", "adapterAddress", ",", "deviceAddress", ",", "Collection...
Makes a copy of a given URL with a new device name and a single attribute. @param deviceAddress bluetooth device MAC address @param attrName attribute name @param attrValue attribute value @return a copy of a given URL with some additional components
[ "Makes", "a", "copy", "of", "a", "given", "URL", "with", "a", "new", "device", "name", "and", "a", "single", "attribute", "." ]
794e4a8644c1eed54cd043de2bc967f4ef58acca
https://github.com/sputnikdev/bluetooth-utils/blob/794e4a8644c1eed54cd043de2bc967f4ef58acca/src/main/java/org/sputnikdev/bluetooth/URL.java#L278-L281
train
sputnikdev/bluetooth-utils
src/main/java/org/sputnikdev/bluetooth/URL.java
URL.getDeviceURL
public URL getDeviceURL() { return new URL(this.protocol, this.adapterAddress, this.deviceAddress, this.deviceAttributes, null, null, null); }
java
public URL getDeviceURL() { return new URL(this.protocol, this.adapterAddress, this.deviceAddress, this.deviceAttributes, null, null, null); }
[ "public", "URL", "getDeviceURL", "(", ")", "{", "return", "new", "URL", "(", "this", ".", "protocol", ",", "this", ".", "adapterAddress", ",", "this", ".", "deviceAddress", ",", "this", ".", "deviceAttributes", ",", "null", ",", "null", ",", "null", ")",...
Returns a copy of a given URL truncated to its device component. Service, characteristic and field components will be null. @return a copy of a given URL truncated to the device component
[ "Returns", "a", "copy", "of", "a", "given", "URL", "truncated", "to", "its", "device", "component", ".", "Service", "characteristic", "and", "field", "components", "will", "be", "null", "." ]
794e4a8644c1eed54cd043de2bc967f4ef58acca
https://github.com/sputnikdev/bluetooth-utils/blob/794e4a8644c1eed54cd043de2bc967f4ef58acca/src/main/java/org/sputnikdev/bluetooth/URL.java#L341-L343
train
sputnikdev/bluetooth-utils
src/main/java/org/sputnikdev/bluetooth/URL.java
URL.getServiceURL
public URL getServiceURL() { return new URL(this.protocol, this.adapterAddress, this.deviceAddress, this.deviceAttributes, this.serviceUUID, null, null); }
java
public URL getServiceURL() { return new URL(this.protocol, this.adapterAddress, this.deviceAddress, this.deviceAttributes, this.serviceUUID, null, null); }
[ "public", "URL", "getServiceURL", "(", ")", "{", "return", "new", "URL", "(", "this", ".", "protocol", ",", "this", ".", "adapterAddress", ",", "this", ".", "deviceAddress", ",", "this", ".", "deviceAttributes", ",", "this", ".", "serviceUUID", ",", "null"...
Returns a copy of a given URL truncated to its service component. Characteristic and field components will be null. @return a copy of a given URL truncated to the service component
[ "Returns", "a", "copy", "of", "a", "given", "URL", "truncated", "to", "its", "service", "component", ".", "Characteristic", "and", "field", "components", "will", "be", "null", "." ]
794e4a8644c1eed54cd043de2bc967f4ef58acca
https://github.com/sputnikdev/bluetooth-utils/blob/794e4a8644c1eed54cd043de2bc967f4ef58acca/src/main/java/org/sputnikdev/bluetooth/URL.java#L358-L361
train
sputnikdev/bluetooth-utils
src/main/java/org/sputnikdev/bluetooth/URL.java
URL.getCharacteristicURL
public URL getCharacteristicURL() { return new URL(this.protocol, this.adapterAddress, this.deviceAddress, this.deviceAttributes, this.serviceUUID, this.characteristicUUID, null); }
java
public URL getCharacteristicURL() { return new URL(this.protocol, this.adapterAddress, this.deviceAddress, this.deviceAttributes, this.serviceUUID, this.characteristicUUID, null); }
[ "public", "URL", "getCharacteristicURL", "(", ")", "{", "return", "new", "URL", "(", "this", ".", "protocol", ",", "this", ".", "adapterAddress", ",", "this", ".", "deviceAddress", ",", "this", ".", "deviceAttributes", ",", "this", ".", "serviceUUID", ",", ...
Returns a copy of a given URL truncated to its characteristic component. The field component will be null. @return a copy of a given URL truncated to the service component
[ "Returns", "a", "copy", "of", "a", "given", "URL", "truncated", "to", "its", "characteristic", "component", ".", "The", "field", "component", "will", "be", "null", "." ]
794e4a8644c1eed54cd043de2bc967f4ef58acca
https://github.com/sputnikdev/bluetooth-utils/blob/794e4a8644c1eed54cd043de2bc967f4ef58acca/src/main/java/org/sputnikdev/bluetooth/URL.java#L368-L371
train
sputnikdev/bluetooth-utils
src/main/java/org/sputnikdev/bluetooth/URL.java
URL.getParent
public URL getParent() { if (isField()) { return getCharacteristicURL(); } else if (isCharacteristic()) { return getServiceURL(); } else if (isService()) { return getDeviceURL(); } else if (isDevice()) { return getAdapterURL(); } else if (isAdapter()) { return getProtocolURL(); } else { return null; } }
java
public URL getParent() { if (isField()) { return getCharacteristicURL(); } else if (isCharacteristic()) { return getServiceURL(); } else if (isService()) { return getDeviceURL(); } else if (isDevice()) { return getAdapterURL(); } else if (isAdapter()) { return getProtocolURL(); } else { return null; } }
[ "public", "URL", "getParent", "(", ")", "{", "if", "(", "isField", "(", ")", ")", "{", "return", "getCharacteristicURL", "(", ")", ";", "}", "else", "if", "(", "isCharacteristic", "(", ")", ")", "{", "return", "getServiceURL", "(", ")", ";", "}", "el...
Returns a new URL representing its "parent" component. @return a new URL representing its "parent" component
[ "Returns", "a", "new", "URL", "representing", "its", "parent", "component", "." ]
794e4a8644c1eed54cd043de2bc967f4ef58acca
https://github.com/sputnikdev/bluetooth-utils/blob/794e4a8644c1eed54cd043de2bc967f4ef58acca/src/main/java/org/sputnikdev/bluetooth/URL.java#L512-L526
train
sputnikdev/bluetooth-utils
src/main/java/org/sputnikdev/bluetooth/URL.java
URL.isDescendant
public boolean isDescendant(URL url) { if (url.protocol != null && protocol != null && !protocol.equals(url.protocol)) { return false; } if (adapterAddress != null && url.adapterAddress == null) { return true; } if (adapterAddress != null && !adapterAddress.equals(url.adapterAddress)) { return false; } if (deviceAddress != null && url.deviceAddress == null) { return true; } if (deviceAddress != null && !deviceAddress.equals(url.deviceAddress)) { return false; } if (serviceUUID != null && url.serviceUUID == null) { return true; } if (serviceUUID != null ? !serviceUUID.equals(url.serviceUUID) : url.serviceUUID != null) { return false; } if (characteristicUUID != null && url.characteristicUUID == null) { return true; } if (characteristicUUID != null ? !characteristicUUID.equals(url.characteristicUUID) : url.characteristicUUID != null) { return false; } return fieldName != null && url.fieldName == null; }
java
public boolean isDescendant(URL url) { if (url.protocol != null && protocol != null && !protocol.equals(url.protocol)) { return false; } if (adapterAddress != null && url.adapterAddress == null) { return true; } if (adapterAddress != null && !adapterAddress.equals(url.adapterAddress)) { return false; } if (deviceAddress != null && url.deviceAddress == null) { return true; } if (deviceAddress != null && !deviceAddress.equals(url.deviceAddress)) { return false; } if (serviceUUID != null && url.serviceUUID == null) { return true; } if (serviceUUID != null ? !serviceUUID.equals(url.serviceUUID) : url.serviceUUID != null) { return false; } if (characteristicUUID != null && url.characteristicUUID == null) { return true; } if (characteristicUUID != null ? !characteristicUUID.equals(url.characteristicUUID) : url.characteristicUUID != null) { return false; } return fieldName != null && url.fieldName == null; }
[ "public", "boolean", "isDescendant", "(", "URL", "url", ")", "{", "if", "(", "url", ".", "protocol", "!=", "null", "&&", "protocol", "!=", "null", "&&", "!", "protocol", ".", "equals", "(", "url", ".", "protocol", ")", ")", "{", "return", "false", ";...
Checks whether the URL is a descendant of a URL provided as an argument. If the provided URL does not specify protocol, then it will match any protocol of the URL @param url a bluetooth URL @return true if the URL is a descendant of a provided URL
[ "Checks", "whether", "the", "URL", "is", "a", "descendant", "of", "a", "URL", "provided", "as", "an", "argument", ".", "If", "the", "provided", "URL", "does", "not", "specify", "protocol", "then", "it", "will", "match", "any", "protocol", "of", "the", "U...
794e4a8644c1eed54cd043de2bc967f4ef58acca
https://github.com/sputnikdev/bluetooth-utils/blob/794e4a8644c1eed54cd043de2bc967f4ef58acca/src/main/java/org/sputnikdev/bluetooth/URL.java#L534-L572
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/JavaAnnotation.java
JavaAnnotation.putValue
public Object putValue(String key, Object value) { return _valueMap.put(key, value); }
java
public Object putValue(String key, Object value) { return _valueMap.put(key, value); }
[ "public", "Object", "putValue", "(", "String", "key", ",", "Object", "value", ")", "{", "return", "_valueMap", ".", "put", "(", "key", ",", "value", ")", ";", "}" ]
Sets a value.
[ "Sets", "a", "value", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/JavaAnnotation.java#L97-L100
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/JavaAnnotation.java
JavaAnnotation.parseAnnotations
static JavaAnnotation []parseAnnotations(InputStream is, ConstantPool cp, JavaClassLoader loader) throws IOException { int n = readShort(is); JavaAnnotation []annArray = new JavaAnnotation[n]; for (int i = 0; i < n; i++) { annArray[i] = parseAnnotation(is, cp, loader); } return annArray; }
java
static JavaAnnotation []parseAnnotations(InputStream is, ConstantPool cp, JavaClassLoader loader) throws IOException { int n = readShort(is); JavaAnnotation []annArray = new JavaAnnotation[n]; for (int i = 0; i < n; i++) { annArray[i] = parseAnnotation(is, cp, loader); } return annArray; }
[ "static", "JavaAnnotation", "[", "]", "parseAnnotations", "(", "InputStream", "is", ",", "ConstantPool", "cp", ",", "JavaClassLoader", "loader", ")", "throws", "IOException", "{", "int", "n", "=", "readShort", "(", "is", ")", ";", "JavaAnnotation", "[", "]", ...
Parses the annotation from an annotation block.
[ "Parses", "the", "annotation", "from", "an", "annotation", "block", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/JavaAnnotation.java#L105-L119
train
baratine/baratine
core/src/main/java/com/caucho/v5/util/Alarm.java
Alarm.run
@Override public void run() { try { handleAlarm(); } catch (Throwable e) { log.log(Level.WARNING, e.toString(), e); } finally { _isRunning = false; _runningAlarmCount.decrementAndGet(); } }
java
@Override public void run() { try { handleAlarm(); } catch (Throwable e) { log.log(Level.WARNING, e.toString(), e); } finally { _isRunning = false; _runningAlarmCount.decrementAndGet(); } }
[ "@", "Override", "public", "void", "run", "(", ")", "{", "try", "{", "handleAlarm", "(", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "WARNING", ",", "e", ".", "toString", "(", ")", ",", "e", ")...
Runs the alarm. This is only called from the worker thread.
[ "Runs", "the", "alarm", ".", "This", "is", "only", "called", "from", "the", "worker", "thread", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/Alarm.java#L492-L503
train
baratine/baratine
core/src/main/java/com/caucho/v5/util/Alarm.java
Alarm.handleAlarm
private void handleAlarm() { AlarmListener listener = getListener(); if (listener == null) { return; } Thread thread = Thread.currentThread(); ClassLoader loader = getContextLoader(); if (loader != null) { thread.setContextClassLoader(loader); } else { thread.setContextClassLoader(_systemLoader); } try { listener.handleAlarm(this); } finally { thread.setContextClassLoader(_systemLoader); } }
java
private void handleAlarm() { AlarmListener listener = getListener(); if (listener == null) { return; } Thread thread = Thread.currentThread(); ClassLoader loader = getContextLoader(); if (loader != null) { thread.setContextClassLoader(loader); } else { thread.setContextClassLoader(_systemLoader); } try { listener.handleAlarm(this); } finally { thread.setContextClassLoader(_systemLoader); } }
[ "private", "void", "handleAlarm", "(", ")", "{", "AlarmListener", "listener", "=", "getListener", "(", ")", ";", "if", "(", "listener", "==", "null", ")", "{", "return", ";", "}", "Thread", "thread", "=", "Thread", ".", "currentThread", "(", ")", ";", ...
Handles the alarm.
[ "Handles", "the", "alarm", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/Alarm.java#L508-L531
train
SeaCloudsEU/SeaCloudsPlatform
deployer/src/main/java/org/apache/brooklyn/entity/openshift/webapp/PaasWebAppOpenShiftDriver.java
PaasWebAppOpenShiftDriver.createDomainIfNotExist
private IDomain createDomainIfNotExist(String domainId){ IDomain foundDomain=findDomainByID(domainId); if(foundDomain==null){ foundDomain=user.createDomain(domainName); } return foundDomain; }
java
private IDomain createDomainIfNotExist(String domainId){ IDomain foundDomain=findDomainByID(domainId); if(foundDomain==null){ foundDomain=user.createDomain(domainName); } return foundDomain; }
[ "private", "IDomain", "createDomainIfNotExist", "(", "String", "domainId", ")", "{", "IDomain", "foundDomain", "=", "findDomainByID", "(", "domainId", ")", ";", "if", "(", "foundDomain", "==", "null", ")", "{", "foundDomain", "=", "user", ".", "createDomain", ...
This method checks if the domain exists for the user. If the domain was not found, it will be created using the domainId. @param domainId The domainId which will be used for finding o creating the domain the user. @return a the found or created domain.
[ "This", "method", "checks", "if", "the", "domain", "exists", "for", "the", "user", ".", "If", "the", "domain", "was", "not", "found", "it", "will", "be", "created", "using", "the", "domainId", "." ]
b199fe6de2c63b808cb248d3aca947d802375df8
https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/deployer/src/main/java/org/apache/brooklyn/entity/openshift/webapp/PaasWebAppOpenShiftDriver.java#L122-L128
train
SeaCloudsEU/SeaCloudsPlatform
deployer/src/main/java/org/apache/brooklyn/entity/openshift/webapp/PaasWebAppOpenShiftDriver.java
PaasWebAppOpenShiftDriver.configureEnv
protected void configureEnv() { //TODO a sensor with the custom-environment variables? Map<String, String> envs=getEntity().getConfig(OpenShiftWebApp.ENV); if((envs!=null)&&(envs.size()!=0)){ deployedApp.addEnvironmentVariables(envs); deployedApp.restart(); } }
java
protected void configureEnv() { //TODO a sensor with the custom-environment variables? Map<String, String> envs=getEntity().getConfig(OpenShiftWebApp.ENV); if((envs!=null)&&(envs.size()!=0)){ deployedApp.addEnvironmentVariables(envs); deployedApp.restart(); } }
[ "protected", "void", "configureEnv", "(", ")", "{", "//TODO a sensor with the custom-environment variables?", "Map", "<", "String", ",", "String", ">", "envs", "=", "getEntity", "(", ")", ".", "getConfig", "(", "OpenShiftWebApp", ".", "ENV", ")", ";", "if", "(",...
Add the env tot he application
[ "Add", "the", "env", "tot", "he", "application" ]
b199fe6de2c63b808cb248d3aca947d802375df8
https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/deployer/src/main/java/org/apache/brooklyn/entity/openshift/webapp/PaasWebAppOpenShiftDriver.java#L199-L206
train
baratine/baratine
web/src/main/java/com/caucho/v5/deploy2/Strategy2Base.java
Strategy2Base.shutdown
@Override public void shutdown(DeployService2Impl<I> deploy, ShutdownModeAmp mode, Result<Boolean> result) { deploy.shutdownImpl(mode, result); }
java
@Override public void shutdown(DeployService2Impl<I> deploy, ShutdownModeAmp mode, Result<Boolean> result) { deploy.shutdownImpl(mode, result); }
[ "@", "Override", "public", "void", "shutdown", "(", "DeployService2Impl", "<", "I", ">", "deploy", ",", "ShutdownModeAmp", "mode", ",", "Result", "<", "Boolean", ">", "result", ")", "{", "deploy", ".", "shutdownImpl", "(", "mode", ",", "result", ")", ";", ...
Stops the instance from an admin command. @param deploy the owning controller
[ "Stops", "the", "instance", "from", "an", "admin", "command", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/deploy2/Strategy2Base.java#L84-L90
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/ByteCode.java
ByteCode.readFromClassPath
public JavaClass readFromClassPath(String classFile) throws IOException { Thread thread = Thread.currentThread(); ClassLoader loader = thread.getContextClassLoader(); InputStream is = loader.getResourceAsStream(classFile); try { return parse(is); } finally { is.close(); } }
java
public JavaClass readFromClassPath(String classFile) throws IOException { Thread thread = Thread.currentThread(); ClassLoader loader = thread.getContextClassLoader(); InputStream is = loader.getResourceAsStream(classFile); try { return parse(is); } finally { is.close(); } }
[ "public", "JavaClass", "readFromClassPath", "(", "String", "classFile", ")", "throws", "IOException", "{", "Thread", "thread", "=", "Thread", ".", "currentThread", "(", ")", ";", "ClassLoader", "loader", "=", "thread", ".", "getContextClassLoader", "(", ")", ";"...
Reads the class from the classpath.
[ "Reads", "the", "class", "from", "the", "classpath", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/ByteCode.java#L41-L53
train
SeaCloudsEU/SeaCloudsPlatform
discoverer/src/main/java/eu/seaclouds/platform/discoverer/crawler/PaasifyCrawler.java
PaasifyCrawler.updateLocalRepository
private void updateLocalRepository() throws GitAPIException { try { Git.open(new File(paasifyRepositoryDirecory)).pull().call(); } catch (IOException e) { log.error("Cannot update local Git repository"); log.error(e.getMessage()); } }
java
private void updateLocalRepository() throws GitAPIException { try { Git.open(new File(paasifyRepositoryDirecory)).pull().call(); } catch (IOException e) { log.error("Cannot update local Git repository"); log.error(e.getMessage()); } }
[ "private", "void", "updateLocalRepository", "(", ")", "throws", "GitAPIException", "{", "try", "{", "Git", ".", "open", "(", "new", "File", "(", "paasifyRepositoryDirecory", ")", ")", ".", "pull", "(", ")", ".", "call", "(", ")", ";", "}", "catch", "(", ...
Updates local Paasify repository @throws GitAPIException
[ "Updates", "local", "Paasify", "repository" ]
b199fe6de2c63b808cb248d3aca947d802375df8
https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/discoverer/src/main/java/eu/seaclouds/platform/discoverer/crawler/PaasifyCrawler.java#L110-L118
train
SeaCloudsEU/SeaCloudsPlatform
discoverer/src/main/java/eu/seaclouds/platform/discoverer/crawler/PaasifyCrawler.java
PaasifyCrawler.getOfferingFromJSON
private Offering getOfferingFromJSON(JSONObject obj) throws IOException { JSONArray infrastructures = (JSONArray) obj.get("infrastructures"); String name = (String) obj.get("name"); Offering offering = null; if (infrastructures == null || infrastructures.size() == 0) { String providerName = Offering.sanitizeName(name); offering = this.parseOffering(providerName, providerName, obj); } else { for (Object element: infrastructures) { JSONObject infrastructure = (JSONObject) element; String continent = ""; String country = ""; String fullName = name; if (infrastructure.containsKey("continent")) { continent = infrastructure.get("continent").toString(); if (!continent.isEmpty()) { continent = continentFullName.get(continent); fullName = fullName + "." + continent; } } if (infrastructure.containsKey("country")) { country = infrastructure.get("country").toString(); if (!country.isEmpty()) fullName = fullName + "." + country; } String providerName = Offering.sanitizeName(name); String offeringName = Offering.sanitizeName(fullName); offering = this.parseOffering(providerName, offeringName, obj); if (!continent.isEmpty()) offering.addProperty("continent", continent); if (!country.isEmpty()) offering.addProperty("country", country); } } return offering; }
java
private Offering getOfferingFromJSON(JSONObject obj) throws IOException { JSONArray infrastructures = (JSONArray) obj.get("infrastructures"); String name = (String) obj.get("name"); Offering offering = null; if (infrastructures == null || infrastructures.size() == 0) { String providerName = Offering.sanitizeName(name); offering = this.parseOffering(providerName, providerName, obj); } else { for (Object element: infrastructures) { JSONObject infrastructure = (JSONObject) element; String continent = ""; String country = ""; String fullName = name; if (infrastructure.containsKey("continent")) { continent = infrastructure.get("continent").toString(); if (!continent.isEmpty()) { continent = continentFullName.get(continent); fullName = fullName + "." + continent; } } if (infrastructure.containsKey("country")) { country = infrastructure.get("country").toString(); if (!country.isEmpty()) fullName = fullName + "." + country; } String providerName = Offering.sanitizeName(name); String offeringName = Offering.sanitizeName(fullName); offering = this.parseOffering(providerName, offeringName, obj); if (!continent.isEmpty()) offering.addProperty("continent", continent); if (!country.isEmpty()) offering.addProperty("country", country); } } return offering; }
[ "private", "Offering", "getOfferingFromJSON", "(", "JSONObject", "obj", ")", "throws", "IOException", "{", "JSONArray", "infrastructures", "=", "(", "JSONArray", ")", "obj", ".", "get", "(", "\"infrastructures\"", ")", ";", "String", "name", "=", "(", "String", ...
Conversion from Paasify JSON model into TOSCA PaaS model @param obj the decoded JSON offering @throws IOException
[ "Conversion", "from", "Paasify", "JSON", "model", "into", "TOSCA", "PaaS", "model" ]
b199fe6de2c63b808cb248d3aca947d802375df8
https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/discoverer/src/main/java/eu/seaclouds/platform/discoverer/crawler/PaasifyCrawler.java#L160-L205
train
baratine/baratine
web/src/main/java/com/caucho/v5/jni/JniSocketImpl.java
JniSocketImpl.acceptInitialRead
@Override public int acceptInitialRead(byte []buffer, int offset, int length) { synchronized (_readLock) { // initialize fields from the _fd int result = nativeAcceptInit(_socketFd, _localAddrBuffer, _remoteAddrBuffer, buffer, offset, length); return result; } }
java
@Override public int acceptInitialRead(byte []buffer, int offset, int length) { synchronized (_readLock) { // initialize fields from the _fd int result = nativeAcceptInit(_socketFd, _localAddrBuffer, _remoteAddrBuffer, buffer, offset, length); return result; } }
[ "@", "Override", "public", "int", "acceptInitialRead", "(", "byte", "[", "]", "buffer", ",", "int", "offset", ",", "int", "length", ")", "{", "synchronized", "(", "_readLock", ")", "{", "// initialize fields from the _fd", "int", "result", "=", "nativeAcceptInit...
Initialize new connection from the socket. @param buf the initial buffer @param offset the initial buffer offset @param length the initial buffer length @return int as if by read
[ "Initialize", "new", "connection", "from", "the", "socket", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/jni/JniSocketImpl.java#L245-L255
train
baratine/baratine
web/src/main/java/com/caucho/v5/jni/JniSocketImpl.java
JniSocketImpl.getRemoteHost
@Override public String getRemoteHost() { if (_remoteName == null) { byte []remoteAddrBuffer = _remoteAddrBuffer; char []remoteAddrCharBuffer = _remoteAddrCharBuffer; if (_remoteAddrLength <= 0) { _remoteAddrLength = InetAddressUtil.createIpAddress(remoteAddrBuffer, remoteAddrCharBuffer); } _remoteName = new String(remoteAddrCharBuffer, 0, _remoteAddrLength); } return _remoteName; }
java
@Override public String getRemoteHost() { if (_remoteName == null) { byte []remoteAddrBuffer = _remoteAddrBuffer; char []remoteAddrCharBuffer = _remoteAddrCharBuffer; if (_remoteAddrLength <= 0) { _remoteAddrLength = InetAddressUtil.createIpAddress(remoteAddrBuffer, remoteAddrCharBuffer); } _remoteName = new String(remoteAddrCharBuffer, 0, _remoteAddrLength); } return _remoteName; }
[ "@", "Override", "public", "String", "getRemoteHost", "(", ")", "{", "if", "(", "_remoteName", "==", "null", ")", "{", "byte", "[", "]", "remoteAddrBuffer", "=", "_remoteAddrBuffer", ";", "char", "[", "]", "remoteAddrCharBuffer", "=", "_remoteAddrCharBuffer", ...
Returns the remote client's host name.
[ "Returns", "the", "remote", "client", "s", "host", "name", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/jni/JniSocketImpl.java#L285-L301
train
baratine/baratine
web/src/main/java/com/caucho/v5/jni/JniSocketImpl.java
JniSocketImpl.getLocalHost
@Override public String getLocalHost() { if (_localName == null) { byte []localAddrBuffer = _localAddrBuffer; char []localAddrCharBuffer = _localAddrCharBuffer; if (_localAddrLength <= 0) { _localAddrLength = InetAddressUtil.createIpAddress(localAddrBuffer, localAddrCharBuffer); } _localName = new String(localAddrCharBuffer, 0, _localAddrLength); } return _localName; }
java
@Override public String getLocalHost() { if (_localName == null) { byte []localAddrBuffer = _localAddrBuffer; char []localAddrCharBuffer = _localAddrCharBuffer; if (_localAddrLength <= 0) { _localAddrLength = InetAddressUtil.createIpAddress(localAddrBuffer, localAddrCharBuffer); } _localName = new String(localAddrCharBuffer, 0, _localAddrLength); } return _localName; }
[ "@", "Override", "public", "String", "getLocalHost", "(", ")", "{", "if", "(", "_localName", "==", "null", ")", "{", "byte", "[", "]", "localAddrBuffer", "=", "_localAddrBuffer", ";", "char", "[", "]", "localAddrCharBuffer", "=", "_localAddrCharBuffer", ";", ...
Returns the local server's host name.
[ "Returns", "the", "local", "server", "s", "host", "name", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/jni/JniSocketImpl.java#L363-L379
train
baratine/baratine
web/src/main/java/com/caucho/v5/jni/JniSocketImpl.java
JniSocketImpl.read
public int read(byte []buffer, int offset, int length, long timeout) throws IOException { if (length == 0) { throw new IllegalArgumentException(); } long requestExpireTime = _requestExpireTime; if (requestExpireTime > 0 && requestExpireTime < CurrentTime.currentTime()) { close(); throw new ClientDisconnectException(L.l("{0}: request-timeout read", addressRemote())); } int result = 0; synchronized (_readLock) { long now = CurrentTime.getCurrentTimeActual(); long expires; // gap is because getCurrentTimeActual() isn't exact long gap = 20; if (timeout >= 0) expires = timeout + now - gap; else expires = _socketTimeout + now - gap; do { result = readNative(_socketFd, buffer, offset, length, timeout); now = CurrentTime.getCurrentTimeActual(); timeout = expires - now; } while (result == JniStream.TIMEOUT_EXN && timeout > 0); } return result; }
java
public int read(byte []buffer, int offset, int length, long timeout) throws IOException { if (length == 0) { throw new IllegalArgumentException(); } long requestExpireTime = _requestExpireTime; if (requestExpireTime > 0 && requestExpireTime < CurrentTime.currentTime()) { close(); throw new ClientDisconnectException(L.l("{0}: request-timeout read", addressRemote())); } int result = 0; synchronized (_readLock) { long now = CurrentTime.getCurrentTimeActual(); long expires; // gap is because getCurrentTimeActual() isn't exact long gap = 20; if (timeout >= 0) expires = timeout + now - gap; else expires = _socketTimeout + now - gap; do { result = readNative(_socketFd, buffer, offset, length, timeout); now = CurrentTime.getCurrentTimeActual(); timeout = expires - now; } while (result == JniStream.TIMEOUT_EXN && timeout > 0); } return result; }
[ "public", "int", "read", "(", "byte", "[", "]", "buffer", ",", "int", "offset", ",", "int", "length", ",", "long", "timeout", ")", "throws", "IOException", "{", "if", "(", "length", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", ...
Reads from the socket.
[ "Reads", "from", "the", "socket", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/jni/JniSocketImpl.java#L546-L586
train
baratine/baratine
web/src/main/java/com/caucho/v5/jni/JniSocketImpl.java
JniSocketImpl.write
public int write(byte []buffer, int offset, int length, boolean isEnd) throws IOException { int result; long requestExpireTime = _requestExpireTime; if (requestExpireTime > 0 && requestExpireTime < CurrentTime.currentTime()) { close(); throw new ClientDisconnectException(L.l("{0}: request-timeout write exp={0}s", addressRemote(), CurrentTime.currentTime() - requestExpireTime)); } synchronized (_writeLock) { long now = CurrentTime.getCurrentTimeActual(); long expires = _socketTimeout + now; // _isNativeFlushRequired = true; do { result = writeNative(_socketFd, buffer, offset, length); //byte []tempBuffer = _byteBuffer.array(); //System.out.println("TEMP: " + tempBuffer); //System.arraycopy(buffer, offset, tempBuffer, 0, length); //_byteBuffer.position(0); //_byteBuffer.put(buffer, offset, length); //result = writeNativeNio(_fd, _byteBuffer, 0, length); } while (result == JniStream.TIMEOUT_EXN && CurrentTime.getCurrentTimeActual() < expires); } if (isEnd) { // websocket/1261 closeWrite(); } return result; }
java
public int write(byte []buffer, int offset, int length, boolean isEnd) throws IOException { int result; long requestExpireTime = _requestExpireTime; if (requestExpireTime > 0 && requestExpireTime < CurrentTime.currentTime()) { close(); throw new ClientDisconnectException(L.l("{0}: request-timeout write exp={0}s", addressRemote(), CurrentTime.currentTime() - requestExpireTime)); } synchronized (_writeLock) { long now = CurrentTime.getCurrentTimeActual(); long expires = _socketTimeout + now; // _isNativeFlushRequired = true; do { result = writeNative(_socketFd, buffer, offset, length); //byte []tempBuffer = _byteBuffer.array(); //System.out.println("TEMP: " + tempBuffer); //System.arraycopy(buffer, offset, tempBuffer, 0, length); //_byteBuffer.position(0); //_byteBuffer.put(buffer, offset, length); //result = writeNativeNio(_fd, _byteBuffer, 0, length); } while (result == JniStream.TIMEOUT_EXN && CurrentTime.getCurrentTimeActual() < expires); } if (isEnd) { // websocket/1261 closeWrite(); } return result; }
[ "public", "int", "write", "(", "byte", "[", "]", "buffer", ",", "int", "offset", ",", "int", "length", ",", "boolean", "isEnd", ")", "throws", "IOException", "{", "int", "result", ";", "long", "requestExpireTime", "=", "_requestExpireTime", ";", "if", "(",...
Writes to the socket.
[ "Writes", "to", "the", "socket", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/jni/JniSocketImpl.java#L591-L630
train
baratine/baratine
web/src/main/java/com/caucho/v5/jni/JniSocketImpl.java
JniSocketImpl.stream
@Override public StreamImpl stream() throws IOException { if (_stream == null) { _stream = new JniStream(this); } _stream.init(); return _stream; }
java
@Override public StreamImpl stream() throws IOException { if (_stream == null) { _stream = new JniStream(this); } _stream.init(); return _stream; }
[ "@", "Override", "public", "StreamImpl", "stream", "(", ")", "throws", "IOException", "{", "if", "(", "_stream", "==", "null", ")", "{", "_stream", "=", "new", "JniStream", "(", "this", ")", ";", "}", "_stream", ".", "init", "(", ")", ";", "return", ...
Returns a stream impl for the socket encapsulating the input and output stream.
[ "Returns", "a", "stream", "impl", "for", "the", "socket", "encapsulating", "the", "input", "and", "output", "stream", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/jni/JniSocketImpl.java#L759-L770
train
baratine/baratine
framework/src/main/java/com/caucho/v5/ramp/vault/VaultDriverDataImpl.java
VaultDriverDataImpl.onLoad
private boolean onLoad(Cursor cursor, T entity) { if (cursor == null) { if (log.isLoggable(Level.FINEST)) { log.finest(L.l("{0} load returned null", _entityInfo)); } _entityInfo.loadFail(entity); return false; } else { _entityInfo.load(cursor, entity); if (log.isLoggable(Level.FINER)) { log.finer("loaded " + entity); } return true; } }
java
private boolean onLoad(Cursor cursor, T entity) { if (cursor == null) { if (log.isLoggable(Level.FINEST)) { log.finest(L.l("{0} load returned null", _entityInfo)); } _entityInfo.loadFail(entity); return false; } else { _entityInfo.load(cursor, entity); if (log.isLoggable(Level.FINER)) { log.finer("loaded " + entity); } return true; } }
[ "private", "boolean", "onLoad", "(", "Cursor", "cursor", ",", "T", "entity", ")", "{", "if", "(", "cursor", "==", "null", ")", "{", "if", "(", "log", ".", "isLoggable", "(", "Level", ".", "FINEST", ")", ")", "{", "log", ".", "finest", "(", "L", "...
Fills the entity on load complete.
[ "Fills", "the", "entity", "on", "load", "complete", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/ramp/vault/VaultDriverDataImpl.java#L190-L210
train
baratine/baratine
framework/src/main/java/com/caucho/v5/ramp/vault/VaultDriverDataImpl.java
VaultDriverDataImpl.findOne
@Override public void findOne(String sql, Object[] params, Result<Cursor> result) { _db.findOne(sql, result, params); }
java
@Override public void findOne(String sql, Object[] params, Result<Cursor> result) { _db.findOne(sql, result, params); }
[ "@", "Override", "public", "void", "findOne", "(", "String", "sql", ",", "Object", "[", "]", "params", ",", "Result", "<", "Cursor", ">", "result", ")", "{", "_db", ".", "findOne", "(", "sql", ",", "result", ",", "params", ")", ";", "}" ]
Finds a single value, returning a cursor.
[ "Finds", "a", "single", "value", "returning", "a", "cursor", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/ramp/vault/VaultDriverDataImpl.java#L247-L254
train
baratine/baratine
framework/src/main/java/com/caucho/v5/ramp/vault/VaultDriverDataImpl.java
VaultDriverDataImpl.findAll
@Override public void findAll(String sql, Object[] params, Result<Iterable<Cursor>> result) { _db.findAll(sql, result, params); }
java
@Override public void findAll(String sql, Object[] params, Result<Iterable<Cursor>> result) { _db.findAll(sql, result, params); }
[ "@", "Override", "public", "void", "findAll", "(", "String", "sql", ",", "Object", "[", "]", "params", ",", "Result", "<", "Iterable", "<", "Cursor", ">", ">", "result", ")", "{", "_db", ".", "findAll", "(", "sql", ",", "result", ",", "params", ")", ...
Finds a list of values, returning a list of cursors
[ "Finds", "a", "list", "of", "values", "returning", "a", "list", "of", "cursors" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/ramp/vault/VaultDriverDataImpl.java#L259-L265
train
baratine/baratine
framework/src/main/java/com/caucho/v5/ramp/vault/VaultDriverDataImpl.java
VaultDriverDataImpl.cursorToBean
public <V> Function<Cursor, V> cursorToBean(Class<V> api) { return (FindDataVault<ID,T,V>) _valueBeans.get(api); }
java
public <V> Function<Cursor, V> cursorToBean(Class<V> api) { return (FindDataVault<ID,T,V>) _valueBeans.get(api); }
[ "public", "<", "V", ">", "Function", "<", "Cursor", ",", "V", ">", "cursorToBean", "(", "Class", "<", "V", ">", "api", ")", "{", "return", "(", "FindDataVault", "<", "ID", ",", "T", ",", "V", ">", ")", "_valueBeans", ".", "get", "(", "api", ")", ...
Extract a bean from a cursor.
[ "Extract", "a", "bean", "from", "a", "cursor", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/ramp/vault/VaultDriverDataImpl.java#L444-L447
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/TempCharBuffer.java
TempCharBuffer.allocate
public static TempCharBuffer allocate() { TempCharBuffer next = _freeList.allocate(); if (next == null) return new TempCharBuffer(SIZE); next._next = null; next._offset = 0; next._length = 0; next._bufferCount = 0; return next; }
java
public static TempCharBuffer allocate() { TempCharBuffer next = _freeList.allocate(); if (next == null) return new TempCharBuffer(SIZE); next._next = null; next._offset = 0; next._length = 0; next._bufferCount = 0; return next; }
[ "public", "static", "TempCharBuffer", "allocate", "(", ")", "{", "TempCharBuffer", "next", "=", "_freeList", ".", "allocate", "(", ")", ";", "if", "(", "next", "==", "null", ")", "return", "new", "TempCharBuffer", "(", "SIZE", ")", ";", "next", ".", "_ne...
Allocate a TempCharBuffer, reusing one if available.
[ "Allocate", "a", "TempCharBuffer", "reusing", "one", "if", "available", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/TempCharBuffer.java#L58-L72
train
baratine/baratine
framework/src/main/java/com/caucho/v5/vfs/TempCharBuffer.java
TempCharBuffer.free
public static void free(TempCharBuffer buf) { buf._next = null; if (buf._buf.length == SIZE) _freeList.free(buf); }
java
public static void free(TempCharBuffer buf) { buf._next = null; if (buf._buf.length == SIZE) _freeList.free(buf); }
[ "public", "static", "void", "free", "(", "TempCharBuffer", "buf", ")", "{", "buf", ".", "_next", "=", "null", ";", "if", "(", "buf", ".", "_buf", ".", "length", "==", "SIZE", ")", "_freeList", ".", "free", "(", "buf", ")", ";", "}" ]
Frees a single buffer.
[ "Frees", "a", "single", "buffer", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/TempCharBuffer.java#L150-L156
train
AludraTest/aludratest
src/main/java/org/apache/velocity/slf4j/Slf4jLogChute.java
Slf4jLogChute.log
@Override public void log(int level, String message) { switch (level) { case LogChute.WARN_ID: log.warn(message); break; case LogChute.INFO_ID: log.info(message); break; case LogChute.TRACE_ID: log.trace(message); break; case LogChute.ERROR_ID: log.error(message); break; case LogChute.DEBUG_ID: default: log.debug(message); break; } }
java
@Override public void log(int level, String message) { switch (level) { case LogChute.WARN_ID: log.warn(message); break; case LogChute.INFO_ID: log.info(message); break; case LogChute.TRACE_ID: log.trace(message); break; case LogChute.ERROR_ID: log.error(message); break; case LogChute.DEBUG_ID: default: log.debug(message); break; } }
[ "@", "Override", "public", "void", "log", "(", "int", "level", ",", "String", "message", ")", "{", "switch", "(", "level", ")", "{", "case", "LogChute", ".", "WARN_ID", ":", "log", ".", "warn", "(", "message", ")", ";", "break", ";", "case", "LogChut...
Send a log message from Velocity.
[ "Send", "a", "log", "message", "from", "Velocity", "." ]
37b13cebefc8449bab3a8c5fc46a9aa8758a3eec
https://github.com/AludraTest/aludratest/blob/37b13cebefc8449bab3a8c5fc46a9aa8758a3eec/src/main/java/org/apache/velocity/slf4j/Slf4jLogChute.java#L93-L113
train
AludraTest/aludratest
src/main/java/org/apache/velocity/slf4j/Slf4jLogChute.java
Slf4jLogChute.isLevelEnabled
@Override public boolean isLevelEnabled(int level) { switch (level) { case LogChute.DEBUG_ID: return log.isDebugEnabled(); case LogChute.INFO_ID: return log.isInfoEnabled(); case LogChute.TRACE_ID: return log.isTraceEnabled(); case LogChute.WARN_ID: return log.isWarnEnabled(); case LogChute.ERROR_ID: return log.isErrorEnabled(); default: return true; } }
java
@Override public boolean isLevelEnabled(int level) { switch (level) { case LogChute.DEBUG_ID: return log.isDebugEnabled(); case LogChute.INFO_ID: return log.isInfoEnabled(); case LogChute.TRACE_ID: return log.isTraceEnabled(); case LogChute.WARN_ID: return log.isWarnEnabled(); case LogChute.ERROR_ID: return log.isErrorEnabled(); default: return true; } }
[ "@", "Override", "public", "boolean", "isLevelEnabled", "(", "int", "level", ")", "{", "switch", "(", "level", ")", "{", "case", "LogChute", ".", "DEBUG_ID", ":", "return", "log", ".", "isDebugEnabled", "(", ")", ";", "case", "LogChute", ".", "INFO_ID", ...
Checks whether the specified log level is enabled.
[ "Checks", "whether", "the", "specified", "log", "level", "is", "enabled", "." ]
37b13cebefc8449bab3a8c5fc46a9aa8758a3eec
https://github.com/AludraTest/aludratest/blob/37b13cebefc8449bab3a8c5fc46a9aa8758a3eec/src/main/java/org/apache/velocity/slf4j/Slf4jLogChute.java#L143-L159
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/table/WatchTable.java
WatchTable.onPut
@Override public void onPut(byte[] key, TypePut type) { //_watchKey.init(key); WatchKey watchKey = new WatchKey(key); switch (type) { case LOCAL: ArrayList<WatchEntry> listLocal = _entryMapLocal.get(watchKey); onPut(listLocal, key); break; case REMOTE: { int hash = _table.getPodHash(key); TablePodNodeAmp node = _table.getTablePod().getNode(hash); if (node.isSelfCopy()) { // copies are responsible for their own local watch events onPut(key, TypePut.LOCAL); } if (node.isSelfOwner()) { // only the owner sends remote watch events /* System.out.println("NSO: " + BartenderSystem.getCurrentSelfServer().getDisplayName() + " " + node.isSelfOwner() + " " + node + " " + Hex.toHex(key)); */ ArrayList<WatchEntry> listRemote = _entryMapRemote.get(watchKey); onPut(listRemote, key); } break; } default: throw new IllegalArgumentException(String.valueOf(type)); } }
java
@Override public void onPut(byte[] key, TypePut type) { //_watchKey.init(key); WatchKey watchKey = new WatchKey(key); switch (type) { case LOCAL: ArrayList<WatchEntry> listLocal = _entryMapLocal.get(watchKey); onPut(listLocal, key); break; case REMOTE: { int hash = _table.getPodHash(key); TablePodNodeAmp node = _table.getTablePod().getNode(hash); if (node.isSelfCopy()) { // copies are responsible for their own local watch events onPut(key, TypePut.LOCAL); } if (node.isSelfOwner()) { // only the owner sends remote watch events /* System.out.println("NSO: " + BartenderSystem.getCurrentSelfServer().getDisplayName() + " " + node.isSelfOwner() + " " + node + " " + Hex.toHex(key)); */ ArrayList<WatchEntry> listRemote = _entryMapRemote.get(watchKey); onPut(listRemote, key); } break; } default: throw new IllegalArgumentException(String.valueOf(type)); } }
[ "@", "Override", "public", "void", "onPut", "(", "byte", "[", "]", "key", ",", "TypePut", "type", ")", "{", "//_watchKey.init(key);", "WatchKey", "watchKey", "=", "new", "WatchKey", "(", "key", ")", ";", "switch", "(", "type", ")", "{", "case", "LOCAL", ...
Notification on a table put. @param key the key of the updated row @param type the notification type (local/remote)
[ "Notification", "on", "a", "table", "put", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/table/WatchTable.java#L151-L188
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/kraken/table/WatchTable.java
WatchTable.onPut
private void onPut(ArrayList<WatchEntry> list, byte []key) { if (list != null) { int size = list.size(); for (int i = 0; i < size; i++) { WatchEntry entry = list.get(i); RowCursor rowCursor = _table.cursor(); rowCursor.setKey(key, 0); EnvKelp envKelp = null; CursorKraken cursor = new CursorKraken(table(), envKelp, rowCursor, _results); entry.onPut(cursor); } } }
java
private void onPut(ArrayList<WatchEntry> list, byte []key) { if (list != null) { int size = list.size(); for (int i = 0; i < size; i++) { WatchEntry entry = list.get(i); RowCursor rowCursor = _table.cursor(); rowCursor.setKey(key, 0); EnvKelp envKelp = null; CursorKraken cursor = new CursorKraken(table(), envKelp, rowCursor, _results); entry.onPut(cursor); } } }
[ "private", "void", "onPut", "(", "ArrayList", "<", "WatchEntry", ">", "list", ",", "byte", "[", "]", "key", ")", "{", "if", "(", "list", "!=", "null", ")", "{", "int", "size", "=", "list", ".", "size", "(", ")", ";", "for", "(", "int", "i", "="...
Notify all watches with the updated row for the given key. @param list watch list @param key the updated row's key
[ "Notify", "all", "watches", "with", "the", "updated", "row", "for", "the", "given", "key", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kraken/table/WatchTable.java#L196-L214
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/SocketStream.java
SocketStream.skip
@Override public long skip(long n) throws IOException { if (_is == null) { if (_s == null) return -1; _is = _s.getInputStream(); } return _is.skip(n); }
java
@Override public long skip(long n) throws IOException { if (_is == null) { if (_s == null) return -1; _is = _s.getInputStream(); } return _is.skip(n); }
[ "@", "Override", "public", "long", "skip", "(", "long", "n", ")", "throws", "IOException", "{", "if", "(", "_is", "==", "null", ")", "{", "if", "(", "_s", "==", "null", ")", "return", "-", "1", ";", "_is", "=", "_s", ".", "getInputStream", "(", "...
Skips bytes in the file. @param n the number of bytes to skip @return the actual bytes skipped.
[ "Skips", "bytes", "in", "the", "file", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/SocketStream.java#L152-L164
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/SocketStream.java
SocketStream.getAvailable
@Override public int getAvailable() throws IOException { if (_is == null) { if (_s == null) return -1; _is = _s.getInputStream(); } return _is.available(); }
java
@Override public int getAvailable() throws IOException { if (_is == null) { if (_s == null) return -1; _is = _s.getInputStream(); } return _is.available(); }
[ "@", "Override", "public", "int", "getAvailable", "(", ")", "throws", "IOException", "{", "if", "(", "_is", "==", "null", ")", "{", "if", "(", "_s", "==", "null", ")", "return", "-", "1", ";", "_is", "=", "_s", ".", "getInputStream", "(", ")", ";",...
Returns the number of bytes available to be read from the input stream.
[ "Returns", "the", "number", "of", "bytes", "available", "to", "be", "read", "from", "the", "input", "stream", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/SocketStream.java#L275-L286
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/SocketStream.java
SocketStream.flush
@Override public void flush() throws IOException { if (_os == null || ! _needsFlush) return; _needsFlush = false; try { _os.flush(); } catch (IOException e) { try { close(); } catch (IOException e1) { } throw ClientDisconnectException.create(e); } }
java
@Override public void flush() throws IOException { if (_os == null || ! _needsFlush) return; _needsFlush = false; try { _os.flush(); } catch (IOException e) { try { close(); } catch (IOException e1) { } throw ClientDisconnectException.create(e); } }
[ "@", "Override", "public", "void", "flush", "(", ")", "throws", "IOException", "{", "if", "(", "_os", "==", "null", "||", "!", "_needsFlush", ")", "return", ";", "_needsFlush", "=", "false", ";", "try", "{", "_os", ".", "flush", "(", ")", ";", "}", ...
Flushes the socket.
[ "Flushes", "the", "socket", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/SocketStream.java#L367-L384
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/ReadStream.java
ReadStream.available
@Override public int available() throws IOException { if (_readOffset < _readLength) { return _readLength - _readOffset; } StreamImpl source = _source; if (source != null) { return source.getAvailable(); } else { return -1; } }
java
@Override public int available() throws IOException { if (_readOffset < _readLength) { return _readLength - _readOffset; } StreamImpl source = _source; if (source != null) { return source.getAvailable(); } else { return -1; } }
[ "@", "Override", "public", "int", "available", "(", ")", "throws", "IOException", "{", "if", "(", "_readOffset", "<", "_readLength", ")", "{", "return", "_readLength", "-", "_readOffset", ";", "}", "StreamImpl", "source", "=", "_source", ";", "if", "(", "s...
Returns an estimate of the available bytes. If a read would not block, it will always return greater than 0.
[ "Returns", "an", "estimate", "of", "the", "available", "bytes", ".", "If", "a", "read", "would", "not", "block", "it", "will", "always", "return", "greater", "than", "0", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/ReadStream.java#L275-L290
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/LogManagerImpl.java
LogManagerImpl.addLogger
@Override public synchronized boolean addLogger(Logger logger) { EnvironmentLogger envLogger = addLogger(logger.getName(), logger.getResourceBundleName()); // handle custom logger if (! logger.getClass().equals(Logger.class)) { return envLogger.addCustomLogger(logger); } return false; }
java
@Override public synchronized boolean addLogger(Logger logger) { EnvironmentLogger envLogger = addLogger(logger.getName(), logger.getResourceBundleName()); // handle custom logger if (! logger.getClass().equals(Logger.class)) { return envLogger.addCustomLogger(logger); } return false; }
[ "@", "Override", "public", "synchronized", "boolean", "addLogger", "(", "Logger", "logger", ")", "{", "EnvironmentLogger", "envLogger", "=", "addLogger", "(", "logger", ".", "getName", "(", ")", ",", "logger", ".", "getResourceBundleName", "(", ")", ")", ";", ...
Adds a logger.
[ "Adds", "a", "logger", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/LogManagerImpl.java#L57-L69
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/LogManagerImpl.java
LogManagerImpl.buildParentTree
private EnvironmentLogger buildParentTree(String childName) { if (childName == null || childName.equals("")) return null; int p = childName.lastIndexOf('.'); String parentName; if (p > 0) parentName = childName.substring(0, p); else parentName = ""; EnvironmentLogger parent = null; SoftReference<EnvironmentLogger> parentRef = _envLoggers.get(parentName); if (parentRef != null) parent = parentRef.get(); if (parent != null) return parent; else { parent = new EnvironmentLogger(parentName, null); _envLoggers.put(parentName, new SoftReference<EnvironmentLogger>(parent)); EnvironmentLogger grandparent = buildParentTree(parentName); if (grandparent != null) parent.setParent(grandparent); return parent; } }
java
private EnvironmentLogger buildParentTree(String childName) { if (childName == null || childName.equals("")) return null; int p = childName.lastIndexOf('.'); String parentName; if (p > 0) parentName = childName.substring(0, p); else parentName = ""; EnvironmentLogger parent = null; SoftReference<EnvironmentLogger> parentRef = _envLoggers.get(parentName); if (parentRef != null) parent = parentRef.get(); if (parent != null) return parent; else { parent = new EnvironmentLogger(parentName, null); _envLoggers.put(parentName, new SoftReference<EnvironmentLogger>(parent)); EnvironmentLogger grandparent = buildParentTree(parentName); if (grandparent != null) parent.setParent(grandparent); return parent; } }
[ "private", "EnvironmentLogger", "buildParentTree", "(", "String", "childName", ")", "{", "if", "(", "childName", "==", "null", "||", "childName", ".", "equals", "(", "\"\"", ")", ")", "return", "null", ";", "int", "p", "=", "childName", ".", "lastIndexOf", ...
Recursively builds the parents of the logger.
[ "Recursively", "builds", "the", "parents", "of", "the", "logger", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/LogManagerImpl.java#L97-L130
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/LogManagerImpl.java
LogManagerImpl.getLogger
@Override public synchronized Logger getLogger(String name) { SoftReference<EnvironmentLogger> envLoggerRef = _envLoggers.get(name); EnvironmentLogger envLogger = null; if (envLoggerRef != null) envLogger = envLoggerRef.get(); if (envLogger == null) envLogger = addLogger(name, null); Logger customLogger = envLogger.getLogger(); if (customLogger != null) return customLogger; else return envLogger; }
java
@Override public synchronized Logger getLogger(String name) { SoftReference<EnvironmentLogger> envLoggerRef = _envLoggers.get(name); EnvironmentLogger envLogger = null; if (envLoggerRef != null) envLogger = envLoggerRef.get(); if (envLogger == null) envLogger = addLogger(name, null); Logger customLogger = envLogger.getLogger(); if (customLogger != null) return customLogger; else return envLogger; }
[ "@", "Override", "public", "synchronized", "Logger", "getLogger", "(", "String", "name", ")", "{", "SoftReference", "<", "EnvironmentLogger", ">", "envLoggerRef", "=", "_envLoggers", ".", "get", "(", "name", ")", ";", "EnvironmentLogger", "envLogger", "=", "null...
Returns the named logger.
[ "Returns", "the", "named", "logger", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/LogManagerImpl.java#L135-L153
train
baratine/baratine
framework/src/main/java/com/caucho/v5/javac/JavacConfig.java
JavacConfig.getLocalConfig
public static JavacConfig getLocalConfig() { JavacConfig config; config = _localJavac.get(); if (config != null) return config; else return new JavacConfig(); }
java
public static JavacConfig getLocalConfig() { JavacConfig config; config = _localJavac.get(); if (config != null) return config; else return new JavacConfig(); }
[ "public", "static", "JavacConfig", "getLocalConfig", "(", ")", "{", "JavacConfig", "config", ";", "config", "=", "_localJavac", ".", "get", "(", ")", ";", "if", "(", "config", "!=", "null", ")", "return", "config", ";", "else", "return", "new", "JavacConfi...
Returns the environment configuration.
[ "Returns", "the", "environment", "configuration", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/javac/JavacConfig.java#L52-L62
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/SocketSystem.java
SocketSystem.getLocalAddresses
public ArrayList<InetAddress> getLocalAddresses() { synchronized (_addressCache) { ArrayList<InetAddress> localAddresses = _addressCache.get("addresses"); if (localAddresses == null) { localAddresses = new ArrayList<InetAddress>(); try { for (NetworkInterfaceBase iface : getNetworkInterfaces()) { for (InetAddress addr : iface.getInetAddresses()) { localAddresses.add(addr); } } Collections.sort(localAddresses, new LocalIpCompare()); _addressCache.put("addresses", localAddresses); } catch (Exception e) { log.log(Level.WARNING, e.toString(), e); } finally { _addressCache.put("addresses", localAddresses); } } return new ArrayList<>(localAddresses); } }
java
public ArrayList<InetAddress> getLocalAddresses() { synchronized (_addressCache) { ArrayList<InetAddress> localAddresses = _addressCache.get("addresses"); if (localAddresses == null) { localAddresses = new ArrayList<InetAddress>(); try { for (NetworkInterfaceBase iface : getNetworkInterfaces()) { for (InetAddress addr : iface.getInetAddresses()) { localAddresses.add(addr); } } Collections.sort(localAddresses, new LocalIpCompare()); _addressCache.put("addresses", localAddresses); } catch (Exception e) { log.log(Level.WARNING, e.toString(), e); } finally { _addressCache.put("addresses", localAddresses); } } return new ArrayList<>(localAddresses); } }
[ "public", "ArrayList", "<", "InetAddress", ">", "getLocalAddresses", "(", ")", "{", "synchronized", "(", "_addressCache", ")", "{", "ArrayList", "<", "InetAddress", ">", "localAddresses", "=", "_addressCache", ".", "get", "(", "\"addresses\"", ")", ";", "if", ...
Returns the InetAddresses for the local machine.
[ "Returns", "the", "InetAddresses", "for", "the", "local", "machine", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/SocketSystem.java#L126-L153
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/SocketSystem.java
SocketSystem.getHardwareAddress
public byte[] getHardwareAddress() { if (CurrentTime.isTest() || System.getProperty("test.mac") != null) { return new byte[] { 10, 0, 0, 0, 0, 10 }; } for (NetworkInterfaceBase nic : getNetworkInterfaces()) { if (! nic.isLoopback()) { return nic.getHardwareAddress(); } } try { InetAddress localHost = InetAddress.getLocalHost(); return localHost.getAddress(); } catch (Exception e) { log.log(Level.FINER, e.toString(), e); } return new byte[0]; }
java
public byte[] getHardwareAddress() { if (CurrentTime.isTest() || System.getProperty("test.mac") != null) { return new byte[] { 10, 0, 0, 0, 0, 10 }; } for (NetworkInterfaceBase nic : getNetworkInterfaces()) { if (! nic.isLoopback()) { return nic.getHardwareAddress(); } } try { InetAddress localHost = InetAddress.getLocalHost(); return localHost.getAddress(); } catch (Exception e) { log.log(Level.FINER, e.toString(), e); } return new byte[0]; }
[ "public", "byte", "[", "]", "getHardwareAddress", "(", ")", "{", "if", "(", "CurrentTime", ".", "isTest", "(", ")", "||", "System", ".", "getProperty", "(", "\"test.mac\"", ")", "!=", "null", ")", "{", "return", "new", "byte", "[", "]", "{", "10", ",...
Returns a unique identifying byte array for the server, generally the mac address.
[ "Returns", "a", "unique", "identifying", "byte", "array", "for", "the", "server", "generally", "the", "mac", "address", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/SocketSystem.java#L171-L192
train
baratine/baratine
web/src/main/java/com/caucho/v5/web/WebServerImpl.java
WebServerImpl.waitForExit
public void waitForExit() throws IOException { Thread thread = Thread.currentThread(); ClassLoader oldLoader = thread.getContextClassLoader(); try { thread.setContextClassLoader(_systemManager.getClassLoader()); _waitForExitService = new WaitForExitService3(this, _systemManager); _waitForExitService.waitForExit(); } finally { thread.setContextClassLoader(oldLoader); } }
java
public void waitForExit() throws IOException { Thread thread = Thread.currentThread(); ClassLoader oldLoader = thread.getContextClassLoader(); try { thread.setContextClassLoader(_systemManager.getClassLoader()); _waitForExitService = new WaitForExitService3(this, _systemManager); _waitForExitService.waitForExit(); } finally { thread.setContextClassLoader(oldLoader); } }
[ "public", "void", "waitForExit", "(", ")", "throws", "IOException", "{", "Thread", "thread", "=", "Thread", ".", "currentThread", "(", ")", ";", "ClassLoader", "oldLoader", "=", "thread", ".", "getContextClassLoader", "(", ")", ";", "try", "{", "thread", "."...
Thread to wait until Baratine should be stopped.
[ "Thread", "to", "wait", "until", "Baratine", "should", "be", "stopped", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/web/WebServerImpl.java#L481-L497
train
baratine/baratine
core/src/main/java/com/caucho/v5/util/LruCache.java
LruCache.compareAndPut
public boolean compareAndPut(V testValue, K key, V value) { V result = compareAndPut(testValue, key, value, true); return testValue == result; }
java
public boolean compareAndPut(V testValue, K key, V value) { V result = compareAndPut(testValue, key, value, true); return testValue == result; }
[ "public", "boolean", "compareAndPut", "(", "V", "testValue", ",", "K", "key", ",", "V", "value", ")", "{", "V", "result", "=", "compareAndPut", "(", "testValue", ",", "key", ",", "value", ",", "true", ")", ";", "return", "testValue", "==", "result", ";...
Puts a new item in the cache if the current value matches oldValue. @param key the key @param value the new value @param testValue the value to test against the current @return true if the put succeeds
[ "Puts", "a", "new", "item", "in", "the", "cache", "if", "the", "current", "value", "matches", "oldValue", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/LruCache.java#L302-L307
train
baratine/baratine
core/src/main/java/com/caucho/v5/util/LruCache.java
LruCache.updateLru
private void updateLru(CacheItem<K,V> item) { long lruCounter = _lruCounter; long itemCounter = item._lruCounter; long delta = (lruCounter - itemCounter) & 0x3fffffff; if (_lruTimeout < delta || delta < 0) { // update LRU only if not used recently updateLruImpl(item); } }
java
private void updateLru(CacheItem<K,V> item) { long lruCounter = _lruCounter; long itemCounter = item._lruCounter; long delta = (lruCounter - itemCounter) & 0x3fffffff; if (_lruTimeout < delta || delta < 0) { // update LRU only if not used recently updateLruImpl(item); } }
[ "private", "void", "updateLru", "(", "CacheItem", "<", "K", ",", "V", ">", "item", ")", "{", "long", "lruCounter", "=", "_lruCounter", ";", "long", "itemCounter", "=", "item", ".", "_lruCounter", ";", "long", "delta", "=", "(", "lruCounter", "-", "itemCo...
Put item at the head of the used-twice lru list. This is always called while synchronized.
[ "Put", "item", "at", "the", "head", "of", "the", "used", "-", "twice", "lru", "list", ".", "This", "is", "always", "called", "while", "synchronized", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/LruCache.java#L413-L424
train
baratine/baratine
core/src/main/java/com/caucho/v5/util/LruCache.java
LruCache.removeTail
public boolean removeTail() { CacheItem<K,V> tail = null; if (_capacity1 <= _size1) tail = _tail1; if (tail == null) { tail = _tail2; if (tail == null) { tail = _tail1; if (tail == null) return false; } } V oldValue = tail._value; if (oldValue instanceof LruListener) { ((LruListener) oldValue).lruEvent(); } V value = remove(tail._key); return true; }
java
public boolean removeTail() { CacheItem<K,V> tail = null; if (_capacity1 <= _size1) tail = _tail1; if (tail == null) { tail = _tail2; if (tail == null) { tail = _tail1; if (tail == null) return false; } } V oldValue = tail._value; if (oldValue instanceof LruListener) { ((LruListener) oldValue).lruEvent(); } V value = remove(tail._key); return true; }
[ "public", "boolean", "removeTail", "(", ")", "{", "CacheItem", "<", "K", ",", "V", ">", "tail", "=", "null", ";", "if", "(", "_capacity1", "<=", "_size1", ")", "tail", "=", "_tail1", ";", "if", "(", "tail", "==", "null", ")", "{", "tail", "=", "_...
Remove the last item in the LRU
[ "Remove", "the", "last", "item", "in", "the", "LRU" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/LruCache.java#L516-L542
train
baratine/baratine
core/src/main/java/com/caucho/v5/util/LruCache.java
LruCache.keys
public Iterator<K> keys() { KeyIterator<K,V> iter = new KeyIterator<K,V>(this); iter.init(this); return iter; }
java
public Iterator<K> keys() { KeyIterator<K,V> iter = new KeyIterator<K,V>(this); iter.init(this); return iter; }
[ "public", "Iterator", "<", "K", ">", "keys", "(", ")", "{", "KeyIterator", "<", "K", ",", "V", ">", "iter", "=", "new", "KeyIterator", "<", "K", ",", "V", ">", "(", "this", ")", ";", "iter", ".", "init", "(", "this", ")", ";", "return", "iter",...
Returns the keys stored in the cache
[ "Returns", "the", "keys", "stored", "in", "the", "cache" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/LruCache.java#L692-L699
train
baratine/baratine
core/src/main/java/com/caucho/v5/util/LruCache.java
LruCache.keys
public Iterator<K> keys(Iterator<K> oldIter) { KeyIterator<K,V> iter = (KeyIterator<K,V>) oldIter; iter.init(this); return oldIter; }
java
public Iterator<K> keys(Iterator<K> oldIter) { KeyIterator<K,V> iter = (KeyIterator<K,V>) oldIter; iter.init(this); return oldIter; }
[ "public", "Iterator", "<", "K", ">", "keys", "(", "Iterator", "<", "K", ">", "oldIter", ")", "{", "KeyIterator", "<", "K", ",", "V", ">", "iter", "=", "(", "KeyIterator", "<", "K", ",", "V", ">", ")", "oldIter", ";", "iter", ".", "init", "(", "...
Returns keys stored in the cache using an old iterator
[ "Returns", "keys", "stored", "in", "the", "cache", "using", "an", "old", "iterator" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/LruCache.java#L704-L711
train
baratine/baratine
core/src/main/java/com/caucho/v5/util/LruCache.java
LruCache.values
public Iterator<V> values() { ValueIterator<K,V> iter = new ValueIterator<K,V>(this); iter.init(this); return iter; }
java
public Iterator<V> values() { ValueIterator<K,V> iter = new ValueIterator<K,V>(this); iter.init(this); return iter; }
[ "public", "Iterator", "<", "V", ">", "values", "(", ")", "{", "ValueIterator", "<", "K", ",", "V", ">", "iter", "=", "new", "ValueIterator", "<", "K", ",", "V", ">", "(", "this", ")", ";", "iter", ".", "init", "(", "this", ")", ";", "return", "...
Returns the values in the cache
[ "Returns", "the", "values", "in", "the", "cache" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/LruCache.java#L724-L729
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/SocketChannelWrapperBar.java
SocketChannelWrapperBar.ssl
@Override public void ssl(SSLFactory sslFactory) { try { Objects.requireNonNull(sslFactory); SocketChannel channel = _channel; Objects.requireNonNull(channel); _sslSocket = sslFactory.ssl(channel); _sslSocket.startHandshake(); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e); } }
java
@Override public void ssl(SSLFactory sslFactory) { try { Objects.requireNonNull(sslFactory); SocketChannel channel = _channel; Objects.requireNonNull(channel); _sslSocket = sslFactory.ssl(channel); _sslSocket.startHandshake(); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e); } }
[ "@", "Override", "public", "void", "ssl", "(", "SSLFactory", "sslFactory", ")", "{", "try", "{", "Objects", ".", "requireNonNull", "(", "sslFactory", ")", ";", "SocketChannel", "channel", "=", "_channel", ";", "Objects", ".", "requireNonNull", "(", "channel", ...
Initialize the ssl
[ "Initialize", "the", "ssl" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/SocketChannelWrapperBar.java#L158-L173
train
baratine/baratine
web/src/main/java/com/caucho/v5/io/SocketChannelWrapperBar.java
SocketChannelWrapperBar.portRemote
@Override public int portRemote() { if (_channel != null) { try { SocketAddress addr = _channel.getRemoteAddress(); return 0; } catch (Exception e) { e.printStackTrace(); return 0; } } else return 0; }
java
@Override public int portRemote() { if (_channel != null) { try { SocketAddress addr = _channel.getRemoteAddress(); return 0; } catch (Exception e) { e.printStackTrace(); return 0; } } else return 0; }
[ "@", "Override", "public", "int", "portRemote", "(", ")", "{", "if", "(", "_channel", "!=", "null", ")", "{", "try", "{", "SocketAddress", "addr", "=", "_channel", ".", "getRemoteAddress", "(", ")", ";", "return", "0", ";", "}", "catch", "(", "Exceptio...
Returns the remote client's port.
[ "Returns", "the", "remote", "client", "s", "port", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/io/SocketChannelWrapperBar.java#L285-L300
train
SeaCloudsEU/SeaCloudsPlatform
sla/sla-core/sla-enforcement/src/main/java/eu/atos/sla/evaluation/AgreementEvaluator.java
AgreementEvaluator.evaluate
public Map<IGuaranteeTerm, GuaranteeTermEvaluationResult> evaluate(IAgreement agreement, Map<IGuaranteeTerm, List<IMonitoringMetric>> metricsMap) { checkInitialized(false); Map<IGuaranteeTerm,GuaranteeTermEvaluationResult> result = new HashMap<IGuaranteeTerm,GuaranteeTermEvaluationResult>(); Date now = new Date(); for (IGuaranteeTerm term : metricsMap.keySet()) { List<IMonitoringMetric> metrics = metricsMap.get(term); if (metrics.size() > 0) { GuaranteeTermEvaluationResult aux = termEval.evaluate(agreement, term, metrics, now); result.put(term, aux); } } return result; }
java
public Map<IGuaranteeTerm, GuaranteeTermEvaluationResult> evaluate(IAgreement agreement, Map<IGuaranteeTerm, List<IMonitoringMetric>> metricsMap) { checkInitialized(false); Map<IGuaranteeTerm,GuaranteeTermEvaluationResult> result = new HashMap<IGuaranteeTerm,GuaranteeTermEvaluationResult>(); Date now = new Date(); for (IGuaranteeTerm term : metricsMap.keySet()) { List<IMonitoringMetric> metrics = metricsMap.get(term); if (metrics.size() > 0) { GuaranteeTermEvaluationResult aux = termEval.evaluate(agreement, term, metrics, now); result.put(term, aux); } } return result; }
[ "public", "Map", "<", "IGuaranteeTerm", ",", "GuaranteeTermEvaluationResult", ">", "evaluate", "(", "IAgreement", "agreement", ",", "Map", "<", "IGuaranteeTerm", ",", "List", "<", "IMonitoringMetric", ">", ">", "metricsMap", ")", "{", "checkInitialized", "(", "fal...
Evaluate if the metrics fulfill the agreement's service levels. @param agreement Agreement to evaluate. @param metricsMap Contains the list of metrics to check for each guarantee term. @return list of violations and compensations detected.
[ "Evaluate", "if", "the", "metrics", "fulfill", "the", "agreement", "s", "service", "levels", "." ]
b199fe6de2c63b808cb248d3aca947d802375df8
https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/sla/sla-core/sla-enforcement/src/main/java/eu/atos/sla/evaluation/AgreementEvaluator.java#L77-L96
train
SeaCloudsEU/SeaCloudsPlatform
sla/sla-core/sla-enforcement/src/main/java/eu/atos/sla/evaluation/AgreementEvaluator.java
AgreementEvaluator.evaluateBusiness
public Map<IGuaranteeTerm, GuaranteeTermEvaluationResult> evaluateBusiness(IAgreement agreement, Map<IGuaranteeTerm, List<IViolation>> violationsMap) { checkInitialized(false); Map<IGuaranteeTerm,GuaranteeTermEvaluationResult> result = new HashMap<IGuaranteeTerm,GuaranteeTermEvaluationResult>(); Date now = new Date(); for (IGuaranteeTerm term : violationsMap.keySet()) { List<IViolation> violations = violationsMap.get(term); if (violations.size() > 0) { GuaranteeTermEvaluationResult aux = termEval.evaluateBusiness(agreement, term, violations, now); result.put(term, aux); } } return result; }
java
public Map<IGuaranteeTerm, GuaranteeTermEvaluationResult> evaluateBusiness(IAgreement agreement, Map<IGuaranteeTerm, List<IViolation>> violationsMap) { checkInitialized(false); Map<IGuaranteeTerm,GuaranteeTermEvaluationResult> result = new HashMap<IGuaranteeTerm,GuaranteeTermEvaluationResult>(); Date now = new Date(); for (IGuaranteeTerm term : violationsMap.keySet()) { List<IViolation> violations = violationsMap.get(term); if (violations.size() > 0) { GuaranteeTermEvaluationResult aux = termEval.evaluateBusiness(agreement, term, violations, now); result.put(term, aux); } } return result; }
[ "public", "Map", "<", "IGuaranteeTerm", ",", "GuaranteeTermEvaluationResult", ">", "evaluateBusiness", "(", "IAgreement", "agreement", ",", "Map", "<", "IGuaranteeTerm", ",", "List", "<", "IViolation", ">", ">", "violationsMap", ")", "{", "checkInitialized", "(", ...
Evaluate if the detected violations imply any compensation. @param agreement Agreement to evaluate. @param violationsMap Contains the list of metrics to check for each guarantee term. @return list of violations and compensations detected.
[ "Evaluate", "if", "the", "detected", "violations", "imply", "any", "compensation", "." ]
b199fe6de2c63b808cb248d3aca947d802375df8
https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/sla/sla-core/sla-enforcement/src/main/java/eu/atos/sla/evaluation/AgreementEvaluator.java#L104-L122
train
baratine/baratine
examples/auction/src/mainarena/java/example/auction/AuctionQueryServiceImpl.java
AuctionQueryServiceImpl.createAuction
@Override public Auction createAuction(String userId, long durationMs, long startPrice, String title, String description) { ResourceManager manager = getResourceManager(); ServiceRef ref = manager.create(userId, durationMs, startPrice, title, description); Auction auction = ref.as(Auction.class); Auction copy = new Auction(auction); return copy; }
java
@Override public Auction createAuction(String userId, long durationMs, long startPrice, String title, String description) { ResourceManager manager = getResourceManager(); ServiceRef ref = manager.create(userId, durationMs, startPrice, title, description); Auction auction = ref.as(Auction.class); Auction copy = new Auction(auction); return copy; }
[ "@", "Override", "public", "Auction", "createAuction", "(", "String", "userId", ",", "long", "durationMs", ",", "long", "startPrice", ",", "String", "title", ",", "String", "description", ")", "{", "ResourceManager", "manager", "=", "getResourceManager", "(", ")...
private ResourceManager _manager;
[ "private", "ResourceManager", "_manager", ";" ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/examples/auction/src/mainarena/java/example/auction/AuctionQueryServiceImpl.java#L28-L42
train
baratine/baratine
core/src/main/java/com/caucho/v5/amp/pipe/PipeImpl.java
PipeImpl.read
public void read() { StateInPipe stateOld; StateInPipe stateNew; do { stateOld = _stateInRef.get(); stateNew = stateOld.toActive(); } while (! _stateInRef.compareAndSet(stateOld, stateNew)); while (stateNew.isActive()) { readPipe(); wakeOut(); do { stateOld = _stateInRef.get(); stateNew = stateOld.toIdle(); } while (! _stateInRef.compareAndSet(stateOld, stateNew)); } if (_stateInRef.get().isClosed()) { StateOutPipe outStateOld = _stateOutRef.getAndSet(StateOutPipe.CLOSE); if (! outStateOld.isClosed()) { _outFlow.cancel(); } } }
java
public void read() { StateInPipe stateOld; StateInPipe stateNew; do { stateOld = _stateInRef.get(); stateNew = stateOld.toActive(); } while (! _stateInRef.compareAndSet(stateOld, stateNew)); while (stateNew.isActive()) { readPipe(); wakeOut(); do { stateOld = _stateInRef.get(); stateNew = stateOld.toIdle(); } while (! _stateInRef.compareAndSet(stateOld, stateNew)); } if (_stateInRef.get().isClosed()) { StateOutPipe outStateOld = _stateOutRef.getAndSet(StateOutPipe.CLOSE); if (! outStateOld.isClosed()) { _outFlow.cancel(); } } }
[ "public", "void", "read", "(", ")", "{", "StateInPipe", "stateOld", ";", "StateInPipe", "stateNew", ";", "do", "{", "stateOld", "=", "_stateInRef", ".", "get", "(", ")", ";", "stateNew", "=", "stateOld", ".", "toActive", "(", ")", ";", "}", "while", "(...
Reads data from the pipe.
[ "Reads", "data", "from", "the", "pipe", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/pipe/PipeImpl.java#L361-L389
train
baratine/baratine
core/src/main/java/com/caucho/v5/amp/pipe/PipeImpl.java
PipeImpl.wakeIn
private void wakeIn() { StateInPipe stateOld; StateInPipe stateNew; do { stateOld = _stateInRef.get(); if (stateOld.isActive()) { return; } stateNew = stateOld.toWake(); } while (! _stateInRef.compareAndSet(stateOld, stateNew)); if (stateOld == StateInPipe.IDLE) { try (OutboxAmp outbox = OutboxAmp.currentOrCreate(_services)) { Objects.requireNonNull(outbox); PipeWakeInMessage<T> msg = new PipeWakeInMessage<>(outbox, _inRef, this); outbox.offer(msg); } } }
java
private void wakeIn() { StateInPipe stateOld; StateInPipe stateNew; do { stateOld = _stateInRef.get(); if (stateOld.isActive()) { return; } stateNew = stateOld.toWake(); } while (! _stateInRef.compareAndSet(stateOld, stateNew)); if (stateOld == StateInPipe.IDLE) { try (OutboxAmp outbox = OutboxAmp.currentOrCreate(_services)) { Objects.requireNonNull(outbox); PipeWakeInMessage<T> msg = new PipeWakeInMessage<>(outbox, _inRef, this); outbox.offer(msg); } } }
[ "private", "void", "wakeIn", "(", ")", "{", "StateInPipe", "stateOld", ";", "StateInPipe", "stateNew", ";", "do", "{", "stateOld", "=", "_stateInRef", ".", "get", "(", ")", ";", "if", "(", "stateOld", ".", "isActive", "(", ")", ")", "{", "return", ";",...
Notify the reader of available data in the pipe. If the writer is asleep, wake it.
[ "Notify", "the", "reader", "of", "available", "data", "in", "the", "pipe", ".", "If", "the", "writer", "is", "asleep", "wake", "it", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/pipe/PipeImpl.java#L443-L467
train
baratine/baratine
core/src/main/java/com/caucho/v5/amp/pipe/PipeImpl.java
PipeImpl.wakeOut
void wakeOut() { OnAvailable outFlow = _outFlow; if (outFlow == null) { return; } if (_creditsIn <= _queue.head()) { return; } StateOutPipe stateOld; StateOutPipe stateNew; do { stateOld = _stateOutRef.get(); if (! stateOld.isFull()) { return; } stateNew = stateOld.toWake(); } while (! _stateOutRef.compareAndSet(stateOld, stateNew)); try (OutboxAmp outbox = OutboxAmp.currentOrCreate(_outRef.services())) { Objects.requireNonNull(outbox); PipeWakeOutMessage<T> msg = new PipeWakeOutMessage<>(outbox, _outRef, this, outFlow); outbox.offer(msg); } }
java
void wakeOut() { OnAvailable outFlow = _outFlow; if (outFlow == null) { return; } if (_creditsIn <= _queue.head()) { return; } StateOutPipe stateOld; StateOutPipe stateNew; do { stateOld = _stateOutRef.get(); if (! stateOld.isFull()) { return; } stateNew = stateOld.toWake(); } while (! _stateOutRef.compareAndSet(stateOld, stateNew)); try (OutboxAmp outbox = OutboxAmp.currentOrCreate(_outRef.services())) { Objects.requireNonNull(outbox); PipeWakeOutMessage<T> msg = new PipeWakeOutMessage<>(outbox, _outRef, this, outFlow); outbox.offer(msg); } }
[ "void", "wakeOut", "(", ")", "{", "OnAvailable", "outFlow", "=", "_outFlow", ";", "if", "(", "outFlow", "==", "null", ")", "{", "return", ";", "}", "if", "(", "_creditsIn", "<=", "_queue", ".", "head", "(", ")", ")", "{", "return", ";", "}", "State...
Notify the reader of available space in the pipe. If the writer is asleep, wake it.
[ "Notify", "the", "reader", "of", "available", "space", "in", "the", "pipe", ".", "If", "the", "writer", "is", "asleep", "wake", "it", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/pipe/PipeImpl.java#L484-L516
train
baratine/baratine
web/src/main/java/com/caucho/v5/log/impl/LevelHandler.java
LevelHandler.flush
public void flush() { int level = getLevel().intValue(); for (int i = 0; i < _handlers.length; i++) { Handler handler = _handlers[i]; if (level <= handler.getLevel().intValue()) handler.flush(); } }
java
public void flush() { int level = getLevel().intValue(); for (int i = 0; i < _handlers.length; i++) { Handler handler = _handlers[i]; if (level <= handler.getLevel().intValue()) handler.flush(); } }
[ "public", "void", "flush", "(", ")", "{", "int", "level", "=", "getLevel", "(", ")", ".", "intValue", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "_handlers", ".", "length", ";", "i", "++", ")", "{", "Handler", "handler", "=...
Flush the handler.
[ "Flush", "the", "handler", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/LevelHandler.java#L69-L79
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/db/journal/JournalSegment.java
JournalSegment.checkpointStart
public void checkpointStart() { if (_isWhileCheckpoint) { throw new IllegalStateException(); } _isWhileCheckpoint = true; long sequence = ++_sequence; setSequence(sequence); byte []headerBuffer = _headerBuffer; BitsUtil.writeInt16(headerBuffer, 0, CHECKPOINT_START); writeImpl(headerBuffer, 0, 2); _lastCheckpointStart = _index - _startAddress; }
java
public void checkpointStart() { if (_isWhileCheckpoint) { throw new IllegalStateException(); } _isWhileCheckpoint = true; long sequence = ++_sequence; setSequence(sequence); byte []headerBuffer = _headerBuffer; BitsUtil.writeInt16(headerBuffer, 0, CHECKPOINT_START); writeImpl(headerBuffer, 0, 2); _lastCheckpointStart = _index - _startAddress; }
[ "public", "void", "checkpointStart", "(", ")", "{", "if", "(", "_isWhileCheckpoint", ")", "{", "throw", "new", "IllegalStateException", "(", ")", ";", "}", "_isWhileCheckpoint", "=", "true", ";", "long", "sequence", "=", "++", "_sequence", ";", "setSequence", ...
Starts checkpoint processing. A checkpoint start changes the epoch ID for new journal entries, but does not yet close the previous epoch. Journal entries written between checkpointStart() and checkpointEnd() belong to the successor epoch.
[ "Starts", "checkpoint", "processing", ".", "A", "checkpoint", "start", "changes", "the", "epoch", "ID", "for", "new", "journal", "entries", "but", "does", "not", "yet", "close", "the", "previous", "epoch", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/db/journal/JournalSegment.java#L314-L331
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/db/journal/JournalSegment.java
JournalSegment.checkpointEnd
public void checkpointEnd() { if (! _isWhileCheckpoint) { throw new IllegalStateException(); } _isWhileCheckpoint = false; byte []headerBuffer = _headerBuffer; BitsUtil.writeInt16(headerBuffer, 0, CHECKPOINT_END); writeImpl(headerBuffer, 0, 2); flush(); _lastCheckpointEnd = _index - _startAddress; writeTail(_os); }
java
public void checkpointEnd() { if (! _isWhileCheckpoint) { throw new IllegalStateException(); } _isWhileCheckpoint = false; byte []headerBuffer = _headerBuffer; BitsUtil.writeInt16(headerBuffer, 0, CHECKPOINT_END); writeImpl(headerBuffer, 0, 2); flush(); _lastCheckpointEnd = _index - _startAddress; writeTail(_os); }
[ "public", "void", "checkpointEnd", "(", ")", "{", "if", "(", "!", "_isWhileCheckpoint", ")", "{", "throw", "new", "IllegalStateException", "(", ")", ";", "}", "_isWhileCheckpoint", "=", "false", ";", "byte", "[", "]", "headerBuffer", "=", "_headerBuffer", ";...
Closes the previous epoch. Journal entries in a closed epoch will not be replayed on a journal restore.
[ "Closes", "the", "previous", "epoch", ".", "Journal", "entries", "in", "a", "closed", "epoch", "will", "not", "be", "replayed", "on", "a", "journal", "restore", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/db/journal/JournalSegment.java#L337-L354
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/db/journal/JournalSegment.java
JournalSegment.replay
public void replay(ReplayCallback replayCallback) { TempBuffer tReadBuffer = TempBuffer.createLarge(); byte []readBuffer = tReadBuffer.buffer(); int bufferLength = readBuffer.length; try (InStore jIn = _blockStore.openRead(_startAddress, getSegmentSize())) { Replay replay = readReplay(jIn); if (replay == null) { return; } long address = replay.getCheckpointStart(); long next; setSequence(replay.getSequence()); TempBuffer tBuffer = TempBuffer.create(); byte []tempBuffer = tBuffer.buffer(); jIn.read(getBlockAddress(address), readBuffer, 0, bufferLength); ReadStream is = new ReadStream(); while (address < _tailAddress && (next = scanItem(jIn, address, readBuffer, tempBuffer)) > 0) { boolean isOverflow = getBlockAddress(address) != getBlockAddress(next); // if scanning has passed the buffer boundary, need to re-read // the initial buffer if (isOverflow) { jIn.read(getBlockAddress(address), readBuffer, 0, bufferLength); } ReplayInputStream rIn = new ReplayInputStream(jIn, readBuffer, address); is.init(rIn); try { replayCallback.onItem(is); } catch (Exception e) { e.printStackTrace(); log.log(Level.FINER, e.toString(), e); } address = next; if (isOverflow) { jIn.read(getBlockAddress(address), readBuffer, 0, bufferLength); } _index = address; _flushIndex = address; } } }
java
public void replay(ReplayCallback replayCallback) { TempBuffer tReadBuffer = TempBuffer.createLarge(); byte []readBuffer = tReadBuffer.buffer(); int bufferLength = readBuffer.length; try (InStore jIn = _blockStore.openRead(_startAddress, getSegmentSize())) { Replay replay = readReplay(jIn); if (replay == null) { return; } long address = replay.getCheckpointStart(); long next; setSequence(replay.getSequence()); TempBuffer tBuffer = TempBuffer.create(); byte []tempBuffer = tBuffer.buffer(); jIn.read(getBlockAddress(address), readBuffer, 0, bufferLength); ReadStream is = new ReadStream(); while (address < _tailAddress && (next = scanItem(jIn, address, readBuffer, tempBuffer)) > 0) { boolean isOverflow = getBlockAddress(address) != getBlockAddress(next); // if scanning has passed the buffer boundary, need to re-read // the initial buffer if (isOverflow) { jIn.read(getBlockAddress(address), readBuffer, 0, bufferLength); } ReplayInputStream rIn = new ReplayInputStream(jIn, readBuffer, address); is.init(rIn); try { replayCallback.onItem(is); } catch (Exception e) { e.printStackTrace(); log.log(Level.FINER, e.toString(), e); } address = next; if (isOverflow) { jIn.read(getBlockAddress(address), readBuffer, 0, bufferLength); } _index = address; _flushIndex = address; } } }
[ "public", "void", "replay", "(", "ReplayCallback", "replayCallback", ")", "{", "TempBuffer", "tReadBuffer", "=", "TempBuffer", ".", "createLarge", "(", ")", ";", "byte", "[", "]", "readBuffer", "=", "tReadBuffer", ".", "buffer", "(", ")", ";", "int", "buffer...
Replays all open journal entries. The journal entry will call into the callback listener with an open InputStream to read the entry.
[ "Replays", "all", "open", "journal", "entries", ".", "The", "journal", "entry", "will", "call", "into", "the", "callback", "listener", "with", "an", "open", "InputStream", "to", "read", "the", "entry", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/db/journal/JournalSegment.java#L375-L430
train
baratine/baratine
kraken/src/main/java/com/caucho/v5/db/journal/JournalSegment.java
JournalSegment.scanItem
private long scanItem(InStore is, long address, byte []readBuffer, byte []tempBuffer) { startRead(); byte []headerBuffer = _headerBuffer; while (address + 2 < _tailAddress) { readImpl(is, address, readBuffer, headerBuffer, 0, 2); address += 2; int len = BitsUtil.readInt16(headerBuffer, 0); if ((len & 0x8000) != 0) { if (len == CHECKPOINT_START) { setSequence(_sequence + 1); } startRead(); continue; } if (len == 0) { readImpl(is, address, readBuffer, headerBuffer, 0, 4); address += 4; int crc = BitsUtil.readInt(headerBuffer, 0); int digest = (int) _crc.getValue(); if (crc == digest) { return address; } else { return -1; } } if (_tailAddress < address + len) { return -1; } int readLen = len; while (readLen > 0) { int sublen = Math.min(readLen, tempBuffer.length); readImpl(is, address, readBuffer, tempBuffer, 0, sublen); _crc.update(tempBuffer, 0, sublen); address += sublen; readLen -= sublen; } } return -1; }
java
private long scanItem(InStore is, long address, byte []readBuffer, byte []tempBuffer) { startRead(); byte []headerBuffer = _headerBuffer; while (address + 2 < _tailAddress) { readImpl(is, address, readBuffer, headerBuffer, 0, 2); address += 2; int len = BitsUtil.readInt16(headerBuffer, 0); if ((len & 0x8000) != 0) { if (len == CHECKPOINT_START) { setSequence(_sequence + 1); } startRead(); continue; } if (len == 0) { readImpl(is, address, readBuffer, headerBuffer, 0, 4); address += 4; int crc = BitsUtil.readInt(headerBuffer, 0); int digest = (int) _crc.getValue(); if (crc == digest) { return address; } else { return -1; } } if (_tailAddress < address + len) { return -1; } int readLen = len; while (readLen > 0) { int sublen = Math.min(readLen, tempBuffer.length); readImpl(is, address, readBuffer, tempBuffer, 0, sublen); _crc.update(tempBuffer, 0, sublen); address += sublen; readLen -= sublen; } } return -1; }
[ "private", "long", "scanItem", "(", "InStore", "is", ",", "long", "address", ",", "byte", "[", "]", "readBuffer", ",", "byte", "[", "]", "tempBuffer", ")", "{", "startRead", "(", ")", ";", "byte", "[", "]", "headerBuffer", "=", "_headerBuffer", ";", "w...
Validates that the item is complete and correct.
[ "Validates", "that", "the", "item", "is", "complete", "and", "correct", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/db/journal/JournalSegment.java#L435-L493
train
baratine/baratine
framework/src/main/java/com/caucho/v5/server/main/BaratineServer.java
BaratineServer.main
public static void main(String []argv) { EnvLoader.init(); ArgsServerBase args = new ArgsServerBaratine(argv); args.doMain(); }
java
public static void main(String []argv) { EnvLoader.init(); ArgsServerBase args = new ArgsServerBaratine(argv); args.doMain(); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "argv", ")", "{", "EnvLoader", ".", "init", "(", ")", ";", "ArgsServerBase", "args", "=", "new", "ArgsServerBaratine", "(", "argv", ")", ";", "args", ".", "doMain", "(", ")", ";", "}" ]
The main start of the web server. <pre> -conf resin.xml : alternate configuration file -port port : set the server's portt <pre>
[ "The", "main", "start", "of", "the", "web", "server", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/server/main/BaratineServer.java#L50-L57
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/JavaMethod.java
JavaMethod.getLine
public int getLine() { if (_line >= 0) return _line; Attribute attr = getAttribute("LineNumberTable"); if (attr == null) { _line = 0; return _line; } _line = 0; return _line; }
java
public int getLine() { if (_line >= 0) return _line; Attribute attr = getAttribute("LineNumberTable"); if (attr == null) { _line = 0; return _line; } _line = 0; return _line; }
[ "public", "int", "getLine", "(", ")", "{", "if", "(", "_line", ">=", "0", ")", "return", "_line", ";", "Attribute", "attr", "=", "getAttribute", "(", "\"LineNumberTable\"", ")", ";", "if", "(", "attr", "==", "null", ")", "{", "_line", "=", "0", ";", ...
Returns the line number.
[ "Returns", "the", "line", "number", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/JavaMethod.java#L114-L128
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/JavaMethod.java
JavaMethod.getReturnType
public JClass getReturnType() { String descriptor = getDescriptor(); int i = descriptor.lastIndexOf(')'); return getClassLoader().descriptorToClass(descriptor, i + 1); }
java
public JClass getReturnType() { String descriptor = getDescriptor(); int i = descriptor.lastIndexOf(')'); return getClassLoader().descriptorToClass(descriptor, i + 1); }
[ "public", "JClass", "getReturnType", "(", ")", "{", "String", "descriptor", "=", "getDescriptor", "(", ")", ";", "int", "i", "=", "descriptor", ".", "lastIndexOf", "(", "'", "'", ")", ";", "return", "getClassLoader", "(", ")", ".", "descriptorToClass", "("...
Returns the return types.
[ "Returns", "the", "return", "types", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/JavaMethod.java#L232-L239
train
baratine/baratine
core/src/main/java/com/caucho/v5/bytecode/JavaMethod.java
JavaMethod.removeAttribute
public Attribute removeAttribute(String name) { for (int i = _attributes.size() - 1; i >= 0; i--) { Attribute attr = _attributes.get(i); if (attr.getName().equals(name)) { _attributes.remove(i); return attr; } } return null; }
java
public Attribute removeAttribute(String name) { for (int i = _attributes.size() - 1; i >= 0; i--) { Attribute attr = _attributes.get(i); if (attr.getName().equals(name)) { _attributes.remove(i); return attr; } } return null; }
[ "public", "Attribute", "removeAttribute", "(", "String", "name", ")", "{", "for", "(", "int", "i", "=", "_attributes", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "Attribute", "attr", "=", "_attributes", ".", "ge...
Removes an attribute.
[ "Removes", "an", "attribute", "." ]
db34b45c03c5a5e930d8142acc72319125569fcf
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/bytecode/JavaMethod.java#L361-L373
train